Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Help in REXX

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
kishpra

New User


Joined: 24 May 2010
Posts: 86
Location: Pune

PostPosted: Mon Feb 07, 2011 5:13 pm    Post subject: Help in REXX
Reply with quote

I have a skeleton JCL as -

//STEP&K EXEC PGM=SORT
//INPUT DD DISP=SHR,DSN=&OLDDSN.&OLDDSN1
//OUTPUT DD DSN=&NEWDSN,
// UNIT=DISK,
// SPACE=(CYL,(0,0)),
// DISP=(MOD,CATLG,CATLG)
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(5,11,CH,EQ,C'&ACCTNO')


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 ?


Thanks!
Back to top
View user's profile Send private message

vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Mon Feb 07, 2011 6:03 pm    Post subject:
Reply with quote

Hi,

Show us your REXX program from where you pass the ACCTNO variable,
I guess you can pass the whole include condition in a single variable.
Back to top
View user's profile Send private message
kishpra

New User


Joined: 24 May 2010
Posts: 86
Location: Pune

PostPosted: Mon Feb 07, 2011 6:09 pm    Post subject: Reply to: Help in REXX
Reply with quote

/*REXX */
"ISPEXEC LIBDEF ISPSLIB DATASET ID('ITA.TEST.ADCXWXM.REXX')"
"ISPEXEC LIBDEF ISPFILE DATASET ID('ITA.TEST.TEMPNEW')"

"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

"ISPEXEC FTOPEN "
"ISPEXEC FTINCL REXXI"
"ISPEXEC FTINCL SYNCSORT"
END
"ISPEXEC FTCLOSE"
"ISPEXEC EDIT DATASET("'ITA.TEST.TEMPNEW'")"
/* ADDRESS TSO
SUB "'ITA.TEST.TEMPNEW'" */
"FREE F(INPUT)"

EXIT
Back to top
View user's profile Send private message
kishpra

New User


Joined: 24 May 2010
Posts: 86
Location: Pune

PostPosted: Mon Feb 07, 2011 6:12 pm    Post subject: Reply to: Help in REXX
Reply with quote

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'


Thanks
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 645
Location: Pennsylvania

PostPosted: Mon Feb 07, 2011 6:14 pm    Post subject:
Reply with quote

Depending on how complex your include cond will be, you are probably better off changing:

SYSIN DD *

to:

SYSIN DD DSN=&temp.dataset.with.incude

Allocate the above dataset in your REXX program and write your include to this dataset, with as many and/or statements you need.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Mon Feb 07, 2011 6:27 pm    Post subject:
Reply with quote

Hi,
You could remove
Code:
INCLUDE COND=(5,11,CH,EQ,C'&ACCTNO')

and substitute

Code:
&built.                  <-- on skeleton lib



Code:
/*rexx*/
"ISPEXEC LIBDEF ISPSLIB DATASET ID('ITA.TEST.ADCXWXM.REXX')"
"ISPEXEC LIBDEF ISPFILE DATASET ID('ITA.TEST.TEMPNEW')"
.
.
built = "INCLUDE COND=(5,11,CH,EQ,C" || statements ")"


What is the scenario in which you will have multiple ACCTNOs with dynamic AND or combination.

[edited]
I did not see daveporcelan's post when replying. I agree his suggestion is way better.
Back to top
View user's profile Send private message
kishpra

New User


Joined: 24 May 2010
Posts: 86
Location: Pune

PostPosted: Mon Feb 07, 2011 6:34 pm    Post subject: Reply to: Help in REXX
Reply with quote

Can you please elaborate it,as it would lend me in the same problem as I am facing it now.



Thanks
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1445
Location: Azeroth

PostPosted: Mon Feb 07, 2011 6:37 pm    Post subject:
Reply with quote

What is the scenario in which you will have multiple ACCTNOs with dynamic AND OR combination.

Please show us some input scenarios and the expected include conditions which would give a clear understanding of your requirement.
Back to top
View user's profile Send private message
kishpra

New User


Joined: 24 May 2010
Posts: 86
Location: Pune

PostPosted: Mon Feb 07, 2011 6:39 pm    Post subject: Reply to: Help in REXX
Reply with quote

Lets say my input file is -

EDIT ITA.TEST.ADCXWXM.TEMPABC
Command ===>
****** *****************************
000001 MTGKPTD G01V001 AAAF0000011
000002 MTGKPTD G01V001 AACF0000011
000003 MTGKPTD G02V001 AACF0000011
****** ****************************


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.


Thanks
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 645
Location: Pennsylvania

PostPosted: Mon Feb 07, 2011 6:41 pm    Post subject:
Reply with quote

Start by manually writing how your sort cards would look under selected scenarios.

Show an example here (using code tag) of one simple condition, and one more complex one.

You can then use these as you target goal, and change your REXX code to generate this as output into your sysin dataset.

Hint: the ITERATE statement would need to be change to new logic creating another OR condition.

I will not be writing this code for you, but from what you have already written, you should be able to do this.
Back to top
View user's profile Send private message
kishpra

New User


Joined: 24 May 2010
Posts: 86
Location: Pune

PostPosted: Mon Feb 07, 2011 6:48 pm    Post subject: Reply to: Help in REXX
Reply with quote

For the above input file specifies,my sort card would look like as -

STEP1 :
SORT FIELDS=COPY
INCLUDE COND=(5,11,CH,EQ,C'AAAF0000011' ,OR,
5,11,CH,EQ,C'AACF0000011')


STEP2 :
SORT FIELDS=COPY
INCLUDE COND=(5,11,CH,EQ,C'AACF0000011')



Thanks!
Back to top
View user's profile Send private message
kishpra

New User


Joined: 24 May 2010
Posts: 86
Location: Pune

PostPosted: Mon Feb 07, 2011 6:59 pm    Post subject: Reply to: Help in REXX
Reply with quote

Hi expat ,

Can you please let me know some example in the forum or some link,as I am new to this forum also in REXX.


Appreciate your help !
Back to top
View user's profile Send private message
kishpra

New User


Joined: 24 May 2010
Posts: 86
Location: Pune

PostPosted: Mon Feb 07, 2011 7:06 pm    Post subject: Reply to: Help in REXX
Reply with quote

Sorry for the reply to Expat as I was looking into other topic.
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Mon Feb 07, 2011 7:21 pm    Post subject:
Reply with quote

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
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Mon Feb 07, 2011 9:01 pm    Post subject: Reply to: Help in REXX
Reply with quote

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!
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 645
Location: Pennsylvania

PostPosted: Mon Feb 07, 2011 9:11 pm    Post subject:
Reply with quote

Enrico,

I really like this solution. This is new to me.

Please tell me:
Is variable OTHERACCTS a stem variable in the REXX program?

Does the )DOT )ENDDOT structure automatically repeat based on the number of non-null occurances in the stem or is the stem.0 value needed?

I will 'play' with this some when I have the chance.

Thanks.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Mon Feb 07, 2011 9:27 pm    Post subject: Reply to: Help in REXX
Reply with quote

)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

and the relative skel would look like
Code:
)DOT <accounts table>
&HEAD&BODY&TAIL
)ENDDOT
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 645
Location: Pennsylvania

PostPosted: Mon Feb 07, 2011 9:35 pm    Post subject:
Reply with quote

I think I see now.

OTHERACCTS is an ISPF table (name length limit is eight?).

So for each occurence a TBADD is required.

Please correct me if I am wrong.

Thanks...
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Mon Feb 07, 2011 9:50 pm    Post subject: Reply to: Help in REXX
Reply with quote

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

for my coding style see ...
http://ibmmainframes.com/viewtopic.php?t=25947&highlight=
Back to top
View user's profile Send private message
kishpra

New User


Joined: 24 May 2010
Posts: 86
Location: Pune

PostPosted: Tue Feb 08, 2011 12:29 pm    Post subject: Reply to: Help in REXX
Reply with quote

Can anyone explain me how to insert and use the table in this case ?





Thanks!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
This topic is locked: you cannot edit posts or make replies. Rexx to create GDG by scanning JJ result krish.deepu CLIST & REXX 5 Tue Oct 25, 2016 5:32 pm
No new posts Replace repeated JCL with looping REXX prino CLIST & REXX 3 Thu Oct 13, 2016 5:30 am
This topic is locked: you cannot edit posts or make replies. Need to code a Rexx PGM sundaram.naveen CLIST & REXX 18 Thu Oct 06, 2016 6:45 pm
No new posts Need Rexx Program to Load in to DB2 T... Hareesh Verma CLIST & REXX 22 Tue Sep 20, 2016 2:59 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us