I am passing the ACCTNO from REXX program.Based on certain conditions in the program ,I can have two or more accounts in the INCLUDE COND using 'AND' & 'OR' dynamically.Please suggest me how to do that in REXX program ?
"ALLOC DA('ITA.TEST.ADCXWXM.TEMPABC') F(INPUT) SHR REUSE"
"EXECIO * DISKR INPUT (STEM LINES. FINIS)"
"ISPEXEC FTINCL REXXG"
DO I = 1 TO LINES.0
SAY LINES.I
PARSE VAR LINES.I VAR1 VAR2 VAR3
IF VAR2 = OLDDSN1 THEN
DO
ACCTNO = STRIP(VAR3)
ITERATE
END
OLDDSN1 = VAR2
NEWDSN1 = VAR2
ACCTNO = STRIP(VAR3)
IF VAR1 = 'MTGKPTD' THEN
DO
OLDDSN = 'ITA.TEST.MTGKPTD.'
NEWDSN = 'ITA.TEST.MTGKPTD.OUTPUT'
END
ELSE
DO
OLDDSN = 'ITA.TEST.MTGKLOT.'
NEWDSN = 'ITA.TEST.MTGKLOT.OUTPUT'
END
K = I
My requirement is that if VAR2 is repeated in the input file,it should not write a new step,instead in the same step it should add the account number(VAR3) in the sort card using 'AND or 'OR'
So based on the same GDG i.e. VAR2 ,I need to have a single sort step including both the account no's - AAAF0000011 & AACF0000011.For the Step 2 ,I will have ony one account for the GDG ver G02V001 i.e. AACF0000011 in the INCLUDE COND in SORT.
Let's say that you will allow up to FOUR account numbers.
In your REXX, name them ACCT1, ACCT2, ACCT3, and ACCT4. Initialize them all to spaces, then populate them IN ORDER depending on how many account numbers are requested.
Then, in your SKELETON code:
Code:
//SYSIN DD *
SORT FIELDS=COPY
)SEL &ACCT2 LT A
INCLUDE COND=(5,11,CH,EQ,C'&ACCT1')
)ENDSEL
)SEL &ACCT2 GT A
INCLUDE COND=(5,11,CH,EQ,C'&ACCT1',OR,
)SEL &ACCT3 LT A
5,11,CH,EQ,C'&ACCT2')
)ENDSEL
)SEL &ACCT3 GT A
5,11,CH,EQ,C'&ACCT2',OR,
)SEL &ACCT4 LT A
5,11,CH,EQ,C'&ACCT3')
)ENDSEL
)SEL &ACCT4 GT A
5,11,CH,EQ,C'&ACCT3',OR,
5,11,CH,EQ,C'&ACCT4')
)ENDSEL
)ENDSEL
)ENDSEL
the most elegant way would be to do it using a table if more than one account
the skel would look something along the lines of ...
Code:
INCLUDE COND=(5,11,CH,EQ,C'&FIRSTACCT'
)SEL &COUNT > 1
)DOT <accounts table>
,OR,11,CH,EQ,C'&OTHERACCTS'
)ENDDOT
)ENDSEL
the last one
)
the suggestion is related only to the technique for handling an
<unknown> number of occurrences
the rest depends on the smartness of Your sort product to detect continuations!
)DOT / )ENDDOT determine the beginning and the end of the <lines>
to ve customized according to the content of the ISPF table specified
in the )DOT statement
DOT kind of a mnemonics for DO Table ( I guess )
I used the approach quite a few time and i must say that it is very effective
I just tought about a smarter trick
build a tables made of three fields
HEAD,body,TAIL
Code:
for the first and only line the table would look like
head "INCLUDE COND=("
body "5,11,CH,EQ,C'11111111111''"
tail ")"
for multiple occurrences
first entry
head "INCLUDE COND=("
body "5,11,CH,EQ,C'11111111111'"
tail ",OR,"
middle entries
head " "
body "5,11,CH,EQ,C'22222222222'"
tail ",OR,"
head " "
body "5,11,CH,EQ,C33333333333'"
tail ",OR,"
last entry
head " "
body "5,11,CH,EQ,C'nnnnnnnnnnn'"
tail ")"
to take care of the continuation quirks of a dummy sort product
yes, for each <account> a table row is needed
the snippets are just snippets, to clear a bit the concept,
more work has to be done to have running code!
the issue might be murky at the beginning, but after a while,
everybody should have his/her own snippet library for the most common tasks
for example for ISPF DIALOGS and EDIT MACROS I have to skels with all
the prolog/epilog and error handling in place
writing the body, since the infrastructure is there, takes usually a very short time