|
Thnaks everyone for replying to my question ref 'variable variable' names One reply (Bruce Guetzkow) mentioned the possibility of using REXX. Is this something that we would do by a call from RPG. I must admit I know little about REXX. Paul -----Message d'origine----- De : rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] De la part de rpg400-l-request@xxxxxxxxxxxx Envoyé : vendredi 18 mars 2005 21:18 À : rpg400-l@xxxxxxxxxxxx Objet : RPG400-L Digest, Vol 4, Issue 313 Send RPG400-L mailing list submissions to rpg400-l@xxxxxxxxxxxx To subscribe or unsubscribe via the World Wide Web, visit http://lists.midrange.com/mailman/listinfo/rpg400-l or, via email, send a message with subject or body 'help' to rpg400-l-request@xxxxxxxxxxxx You can reach the person managing the list at rpg400-l-owner@xxxxxxxxxxxx When replying, please edit your Subject line so it is more specific than "Re: Contents of RPG400-L digest..." Today's Topics: 1. Re: Conversion Error Help (Peter Dow) 2. using record to build a screen (Keith Fischer) 3. Re: Conversion Error Help (Brian Parkins) 4. RE: Variable Variable names (Holden Tommy) 5. RE: Conversion Error Help (Brian Piotrowski) 6. Re: Variable Variable names (Rich Duzenbury) 7. RE: Variable Variable names (Bruce Guetzkow) ---------------------------------------------------------------------- message: 1 date: Fri, 18 Mar 2005 10:52:35 -0800 from: "Peter Dow" <maillist@xxxxxxxxxxxxxxx> subject: Re: Conversion Error Help Hi Brian, Try FLDQTY = %DEC(%SUBST(FLD5:2) : 6 : 0) if you're on v5r2 or higher. Peter Dow Dow Software Services, Inc. 909 793-9050 voice 909 793-4480 fax 951 522-3214 cell ----- Original Message ----- From: "Brian Piotrowski" <bpiotrowski@xxxxxxxxxxxxxxx> To: "RPG programming on the AS400 / iSeries" <rpg400-l@xxxxxxxxxxxx> Sent: Friday, March 18, 2005 10:22 AM Subject: Conversion Error Help Hi All, I'm having a bit of a problem with a data evaluation / conversion, and I'm wondering if you veterans can help (Yes, I am still fairly new to RPG)? In my code, I have this statement: /FREE CHAIN KEYPB SSM05A11; IF %FOUND(SSM05A11); FLDQTY = %SUBST(FLD5:2:%LEN(FLD5)); GTBOXQTY = (%INT(FLDQTY) > PNBQTY); ENDIF; /END-FREE KEYPB is a key that contains a part number FLD5 is a 9A field PNBQTY is a 6S field for box quantity -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.7.3 - Release Date: 3/15/2005 ------------------------------ message: 2 date: Fri, 18 Mar 2005 14:10:46 -0500 from: "Keith Fischer" <keithf@xxxxxxxxxxxxxxxx> subject: using record to build a screen I have a file from a third party that has 2 record types. The first record type has field name and description. There are 30 different field names. The second record type has the list of values for the field name. Most of the record types are for future fields and when the fields are to be used a new file will be sent. The question I have is is there a way to have a field description for a screen get updated from a file. Also, can the list of values be updated for a screen from a file. Thanks Keith ------------------------------ message: 3 date: Fri, 18 Mar 2005 19:18:49 +0000 from: Brian Parkins <parkib@xxxxxxxxxx> subject: Re: Conversion Error Help The following seems to work OK: D FLD5 S 9A Inz('Q901') D FLDQTY S Like(Fld5) D PNBQTY S 6S 0 D GTBOXQTY S N /Free Dsply 'Enter Value for PNBQTY' '*REQUESTER' PNBQTY; FLDQTY = %SUBST(FLD5:2:(%Len(%TrimR(FLD5))-1)); GTBOXQTY = (%INT(FLDQTY) > PNBQTY); Dsply GTBOXQTY '*REQUESTER'; *InLR = *On; /End-Free Brian Parkins ------------------------------ message: 4 date: Fri, 18 Mar 2005 13:36:02 -0600 from: Holden Tommy <Tommy.Holden@xxxxxxxxxxxxxxxxx> subject: RE: Variable Variable names There are only 2 ways that I know of to do this. One is to write a code generator program, the other is via embedded SQL. Here is a sample of the embedded SQL. Hope this helps!!! Thanks, Tommy Holden -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of Lim Hock-Chai Sent: Friday, March 18, 2005 10:45 AM To: RPG programming on the AS400 / iSeries Subject: RE: Variable Variable names Clarify. Datastructure mentioned below should be an external datastructure. -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of Lim Hock-Chai Sent: Friday, March 18, 2005 10:26 AM To: RPG programming on the AS400 / iSeries Subject: RE: Variable Variable names There is no such bif in RPG. It is possible if all those variables are in a datastrucure. You can use an api to get a list of field location of the datastructure and then use %subst to get the value. -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of PAPWORTH Paul Sent: Friday, March 18, 2005 9:28 AM To: rpg400-l@xxxxxxxxxxxx Cc: GAZIN Florence; DEVILLE Jacques Subject: Variable Variable names Does any one know if it is possible in RPG (or any other i_series) language to do the following Ws_work_zone = %pgmvar(var) %pgmvar would be a function which would allow you to get the contents of a variable , whose name is contained in a variable. Eg if in my imaginary function var contains the name of a field 'FRED' , and FRED contains 'ABC' , I would end up with 'ABC' in ws_work_zone Many thanks in advance -- This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l. -- This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l. -- This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l. -------------- next part -------------- H DFTACTGRP(*NO) H OPTION(*SRCSTMT: *NODEBUGIO: *NOSHOWCPY) /copy prodkr/qcopysrc,clcmdexec /copy prodkr/qcopysrc,getcurdb * SQLDA Descriptor Area D SQLDA DS D SQLDAID 1 8A D SQLDABC 9 12B 0 D SQLN 13 14B 0 D SQLD 15 16B 0 D SQL_VAR 80A DIM(400) D SQL_Data_Type 17 18B 0 D SQL_Var_Len 19 20B 0 D SQL_Resrvd 21 32A D SQL_Data_Pntr 33 48* D SQL_Null_Ind 49 64* D SQL_Name_Len 65 66B 0 D SQL_Col_Name 67 96A * SQLDA Variable Data D SQLVAR DS D SQLTYPE 1 2B 0 D SQLLEN 3 4B 0 D SQLRES 5 16A D SQLDATA 17 32* D SQLIND 33 48* D SQLNAMELEN 49 50B 0 D SQLNAME 51 80A * SQLDA Variable Data (Extended) D SQLVAR2 DS D SQLLONGL 1 4B 0 D SQLRSVDL 5 32A D SQLDATAL 33 48* D SQLTNAMELN 49 50B 0 D SQLTNAME 51 80A * Work Variables D File s 10a D Lib s 10a D TempFile s 10a D TempLib s 10a Drowcountx s 10I 0 DOrdinal s 10I 0 DColName s 10a DDataType s 8a DLength s 10i 0 DScale s 10i 0 Dn1 s 4b 0 DPuNo s 6a DDatabaseName s 100a D XLSPath s 100a D SQLSelect s 5000a Varying DColumnNumber s 10i 0 D RecordData s 32766a DElement s 10i 0 * Parameter Entry C *Entry PList C Parm FileName 20 C Parm TemplateFile 20 C Parm XLSPath * SQL Error Trapping c/exec sql c+ Whenever SQLError Continue c/end-exec /free //* Extract The Input File Name //* & Load The Output Path If Not Specified If XLSPath=*Blanks; XLSPath='/tmp/xl.xls'; EndIf; File=%Subst(FileName:1:10); Lib=%Subst(FileName:11:10); TempFile=%Subst(TemplateFile:1:10); TempLib=%Subst(TemplateFile:11:10); //* Override The Database File Being Processed CmdStr='OVRDBF '+%Trim(File)+' '+ %Trim(Lib)+'/'+%Trim(File)+ ' Share(*Yes)'; CmdStrSize=%Len(%Trim(CmdStr)); monitor; Run(CmdStr:CmdStrSize); on-error; endmon; //* Build The Dynamic Excel Generation Program ExSR SQLSelectBuild; /end-free c/exec sql c+ Prepare SQLExtract From :SQLSelect c/end-exec c Eval SqlN=1 C/exec sql c+ Describe SQLExtract Into :SQLDA c/end-exec c Eval SqlN=SqlD c Eval SQLABC=SqlN*%Len(SqlVar)+16 c/exec sql c+ Describe SQLExtract Into :SQLDA c/end-exec c/exec sql c+ Declare SQL_Extract Cursor For SQLExtract c/end-exec c/exec sql c+ open SQL_Extract Using Descriptor :SQLDA c/end-exec c DoU SqlCod=100 c/exec sql c+ Fetch SQL_Extract Into Descriptor :SQLDA c/end-exec c If SqlCod=100 c/exec sql c+ Close SQL_Extract c/end-exec c Leave c EndIf c ExSR ExtractData c EndDo /free //* Terminate *inlr = *on; BegSR ExtractData; For Element = 1 By 1 To SqlD; SQLVAR=SQL_VAR(Element); EndFor; EndSR; /end-free * * Build SQL Select Statement From Template File C SQLSelectBuildBegSR C Eval SQLSelect='Select ' * Declare The SQL Cursor c/exec sql c+ Declare StringBuild Cursor c+ For Select Column_Name,Data_Type,Length,Numeric_Scale, c+ Ordinal_Position From SYSCOLUMNS c+ Where System_Table_Name= :TempFile And c+ System_Table_Schema = :TempLib c+ Order By Ordinal_Position c/end-exec * Open The SQL Cursor c/exec sql c+ Open StringBuild c/end-exec * Error Occurred On Open c If SQLCod<0 c LeaveSR c EndIf * Load The Source Code For All Fields In the File c Eval rowcountx=4 c DoU SQLCod=100 c/exec sql c+ Fetch StringBuild Into :ColName,:DataType,:Length, c+ :Scale:n1,:Ordinal c/end-exec * End Of Records c If SQLCod=100 c Leave c EndIf * Error On Fetch c If SQLCod<0 c Iter c EndIf c Eval SQLSelect=%Trim(SQLSelect)+' '+ c %Trim(ColName)+',' c EndDo c Eval Length=%Len(%Trim(SQLSelect)) c Eval SQLSelect=%Subst(SQLSelect:1:Length-1) c Eval SQLSelect=%Trim(SQLSelect)+ c ' From '+%Trim(Lib)+'/' c +%Trim(File) c EndSR ------------------------------ message: 5 date: Fri, 18 Mar 2005 15:03:44 -0500 from: "Brian Piotrowski" <bpiotrowski@xxxxxxxxxxxxxxx> subject: RE: Conversion Error Help Hi All, Thanks for the great responses. I gave all of them a try, and I still get the conversion error. Could it be something with the way I'm defining the fields? Thanks, Brian. -----Original Message----- From: Peter Dow [mailto:maillist@xxxxxxxxxxxxxxx] Sent: Friday, March 18, 2005 1:53 PM To: RPG programming on the AS400 / iSeries Subject: Re: Conversion Error Help Hi Brian, Try FLDQTY = %DEC(%SUBST(FLD5:2) : 6 : 0) if you're on v5r2 or higher. Peter Dow Dow Software Services, Inc. 909 793-9050 voice 909 793-4480 fax 951 522-3214 cell ----- Original Message ----- From: "Brian Piotrowski" <bpiotrowski@xxxxxxxxxxxxxxx> To: "RPG programming on the AS400 / iSeries" <rpg400-l@xxxxxxxxxxxx> Sent: Friday, March 18, 2005 10:22 AM Subject: Conversion Error Help Hi All, I'm having a bit of a problem with a data evaluation / conversion, and I'm wondering if you veterans can help (Yes, I am still fairly new to RPG)? In my code, I have this statement: /FREE CHAIN KEYPB SSM05A11; IF %FOUND(SSM05A11); FLDQTY = %SUBST(FLD5:2:%LEN(FLD5)); GTBOXQTY = (%INT(FLDQTY) > PNBQTY); ENDIF; /END-FREE KEYPB is a key that contains a part number FLD5 is a 9A field PNBQTY is a 6S field for box quantity -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.7.3 - Release Date: 3/15/2005 -- This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l. ------------------------------ message: 6 date: Fri, 18 Mar 2005 14:04:10 -0600 from: Rich Duzenbury <rduz-midrange@xxxxxxxxxxxxxxxxxxx> subject: Re: Variable Variable names On Fri, 2005-03-18 at 16:27 +0100, PAPWORTH Paul wrote: > Does any one know if it is possible in RPG (or any other i_series) > language to do the following > > > > Ws_work_zone = %pgmvar(var) About fifteen years ago, we needed to write a program where the user could define rules that edited fields in a set of records. They needed to be able to edit against the contents of any field (in a defined list of several hundred) to see if it was blank, or zero, or matched a list, or matched one of the other fields in the list. There were ranges, and all sorts of requirements. We thought about various methods, including writing a program generator, but at the time, it would have been too slow to have the user generate and compile some kind of program every time they changed the ruleset, which was frequently. Finally, someone not really connected to the project said - As soon as the data is in memory, why not just copy each field into an array element? At first we dismissed the idea out of hand, because it wasn't 'real' softcoding, which we thought we were after. However, after a bit of thought, it became clear that the only 'hardcoding' in the project would be the bit of code to copy each field into it's array element. Once that was done, the user could write a rule like "if account type is 111 and end_date is 0, reject the record". Since we knew account type was in (say) field 15, and end date was in field (say) 38, we could easily, at run time, parse the rule(s), and then compare fields(15) with 111 and fields(38) with 0. HTH -- Regards, Rich Current Conditions in Des Moines, IA Overcast Temp 46.4F Winds out of the Southwest at 15mph Moderate Rain ------------------------------ message: 7 date: Fri, 18 Mar 2005 14:17:08 -0600 from: "Bruce Guetzkow" <bruceg@xxxxxxxxxxxxxxxxxxxxxxx> subject: RE: Variable Variable names Paul: <snip> Does any one know if it is possible in RPG (or any other i_series) language to do the following Ws_work_zone = %pgmvar(var) </snip> The only language that I know of that allows this is REXX. Using the VALUE function you can do the following... data = 'Some Value' var = 'data' say value(var) The "value(var)" can be translated into English as "give me the contents (or value) of the variable specified in the variable name var". Having said this, REXX is somewhat limited in processing data directly, although you can do an OVRDBF to file STDIN and read data from a single file, or execute SQL statements in REXX (which is much more powerful). Hope that helps, --Bruce Guetzkow ------------------------------ -- This is the RPG programming on the AS400 / iSeries (RPG400-L) digest list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l. End of RPG400-L Digest, Vol 4, Issue 313 ****************************************
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.