IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

REXX - Do - Not able to LOOP


IBM Mainframe Forums -> CLIST & REXX
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
saikarthik94

New User


Joined: 04 Sep 2019
Posts: 12
Location: India

PostPosted: Mon Oct 09, 2023 8:20 pm
Reply with quote

Hello, I am trying to extract the dataset from the PDS starting with specific word. If the give the PDS member individually, i am able to get the DS names, but when i try with LISTDS and loop over the members in the PDS, i don't see the OUTPUT.

Code:
 
/* REXX TO EXTRACT XXX FILES FROM THE FILES */
 DSN='mypds'
 X = OUTTRAP('VAR.')
 "LISTDS mypds MEMBERS"
 X=OUTTRAP OFF
 DO I = 7 TO VAR.0
    SAY VAR.0
    SAY VAR.I
    MEM=STRIP(VAR.I,'B')
    SAY 'MEMBER NAME' MEM
    IDSN=DSN!!'('!!MEM!!')'
 /* SAY IDSN */
    "ALLOC DDN(D19) DSN('"IDSN"') MOD"
    "EXECIO * DISKR D19(STEM IDATA. FINIS"
    COUNT=1
    DO I = 1 TO IDATA.0
   DO I = 1 TO IDATA.0
      CALL READLINES
   END
END
ODSN='output ps'

"ALLOC DDN(D20) DSN('"ODSN"') SHR"
"EXECIO * DISKW D20(STEM RDATA. FINIS"

/* TO READ THE JCL LINE BY LINE */
READLINES:
    SAY 'READLINES'
    PARSE VAR IDATA.I 1 INDATA 73
    PARSE VAR INDATA 1 CMNT 4
    IF CMNT = '//*' THEN
       DO
          NO
       END
    ELSE
       DO
          CALL CHECKDSN
       END
RETURN
/* TO EXTRACT THE DATASET NAMES WITH XXX. */
CHECKDSN:
     SAY 'CHECKDSN:'
     SELECT
        WHEN POS(' DSN=XXX.',INDATA) >=1  THEN
           DO
             CALL TOMEXTRACT
           END
        OTHERWISE
           DO
              NOP
           END
     END
RETURN
TOMEXTRACT:
     PARSE VAR INDATA D19DUMY ' DSN=' DNAME ','
     DNAME=STRIP(DNAME,'B')
     SAY 'DNAME:' DNAME
     RDATA.COUNT=DNAME
     COUNT = COUNT  + 1
RETURN



I am able to get the DSN name if i directly give the PDS name & the member name like below:

Code:

DSN='mypds'
MEM='mymem' 


But i want to extract the dataset with the specific word from the entire members present in PDS. Could please help / guide me where i am making a miss ?
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Mon Oct 09, 2023 8:38 pm
Reply with quote

A couple of things ....

You have an outer loop - DO I - 7 to VAR.0

and within that loop you have

DO I = 1 to IDATA.0 (twice !!)

Your then have END statements which terminate the two DO I = 1 to IDATA.0 loops and no END statement for the outer loop.

I suggest you don't reuse I as a counter for the inner loop and remove one of the Do I = 1 to IDATA.0 lines.

Garry.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Tue Oct 10, 2023 12:22 am
Reply with quote

Approx. 85% of all source code lines are either syntactically or logically incorrect. The list of all errors, if presented, would have the size much bigger than the code itself.

Please, add trace statement trace r or trace i somewhere at the beginning of your code, then start fixing your bugs one by one, according to the trace results.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Tue Oct 10, 2023 4:23 am
Reply with quote

Quote:
extract the dataset with the specific word from the entire members present in PDS

This statement is not clear to me. Can you provide an exampe?
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Tue Oct 10, 2023 9:03 am
Reply with quote

Quote:
within that loop you have

DO I = 1 to IDATA.0 (twice !!)


Issue HI ON and HI LOGIC commands in the ISPF editor. You can easily match the DO and END statements based on the color highlighting.
Back to top
View user's profile Send private message
saikarthik94

New User


Joined: 04 Sep 2019
Posts: 12
Location: India

PostPosted: Tue Oct 10, 2023 1:07 pm
Reply with quote

Hello Gary,

I am sorry. The DO -
Code:
 DO I = 1 to IDATA.0


was pasted twice here, but it is only once in the CODE.

Also, i have updated the second I usage as J.

Code:
 DO J = 1 TO IDATA.0
. Now, it is fetching only the XXX file ONLY from the FIRST member, although i can see the code is reading the next members, but still the it is displaying the first member XXX only icon_sad.gif
Back to top
View user's profile Send private message
saikarthik94

New User


Joined: 04 Sep 2019
Posts: 12
Location: India

PostPosted: Tue Oct 10, 2023 1:09 pm
Reply with quote

Hello Pedro, If the have DSN name starting with XXX.AAA.BBB.CCC, then i need to extract the DS name into a PS.

There can be many DS name in the member starting with AAA., XXX., YYY., but i want to extract only the DSN starting with XXX.


Hope it is clear now.
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Tue Oct 10, 2023 1:31 pm
Reply with quote

Sergeyken has pointed out that most of your code is syntactically or logically incorrect. Using trace, as suggested, and RTFM will help you resolve your errors.

You allocate the first member in the dataset with ALLOC DDN(DD19) with a DISP of MOD. Why MOD, if you're not going to add to it? Also, since you don't FREE DD19 you will always have this first member allocated.

In your reply to Pedro, you are confusing/mixing the use of member and DSN terms. I believe you want to extract the member from the DSN that has the high level qualifier XXX.

Garry.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Tue Oct 10, 2023 8:19 pm
Reply with quote

saikarthik94 wrote:
Hello Pedro, If the have DSN name starting with XXX.AAA.BBB.CCC, then i need to extract the DS name into a PS.

There can be many DS name in the member starting with AAA., XXX., YYY., but i want to extract only the DSN starting with XXX.

Hope it is clear now.

Your samples demonstrate that you have not a minor idea neither about programming in general, nor about writing code in REXX.
Even your terminology in plain English is extremely doubtful, like "I am trying to extract the dataset from the PDS starting with specific word". (OMG!!!)

I recommend you to start from HELLO, WORLD!
Code:
/* REXX */
Say "Hello, world!"
Return


Next, try to understand how simple loops work:
Code:
/* REXX */
Do I = 1 To 5
   Say "Hello, world! I =" I
End I
Return


Next, extend your knowledge to nested loops:
Code:
/* REXX */
Do I = 1 To 5
   Say "Hello, first loop! I =" I
   Do J = 7 To 11
      Say "Hello, second loop! J =" J
   End J
End I
Return


E.t.c. add your new statements ONE BY ONE!!!
Do not try to create such a mess from the very beginning.
Then you'll be able to detect immediately: which of added parts is wrong!

358.gif 36_2_51.gif


P.S.
It is also useful to RTFM, and to understand, that every "ALLOCATE" command requires matching "FREE" command, and every "EXECIO" (with assumed or explicit OPEN!!!) requires matching "EXECIO ... (FINIS"
Back to top
View user's profile Send private message
saikarthik94

New User


Joined: 04 Sep 2019
Posts: 12
Location: India

PostPosted: Tue Oct 10, 2023 8:55 pm
Reply with quote

ifyuknowyuknow wrote:
Hello, I am trying to extract the dataset from the PDS starting with specific word. If the give the PDS member individually, i am able to get the DS names, but when i try with LISTDS and loop over the members in the PDS, i don't see the OUTPUT.

Code:
 
/* REXX TO EXTRACT XXX FILES FROM THE FILES */
 DSN='mypds'
 X = OUTTRAP('VAR.')
 "LISTDS mypds MEMBERS"
 X=OUTTRAP OFF
 DO I = 7 TO VAR.0
    SAY VAR.0
    SAY VAR.I
    MEM=STRIP(VAR.I,'B')
    SAY 'MEMBER NAME' MEM
    IDSN=DSN!!'('!!MEM!!')'
 /* SAY IDSN */
    "ALLOC DDN(D19) DSN('"IDSN"') MOD"
    "EXECIO * DISKR D19(STEM IDATA. FINIS"
    COUNT=1
    DO I = 1 TO IDATA.0
   DO I = 1 TO IDATA.0
      CALL READLINES
   END
END
ODSN='output ps'

"ALLOC DDN(D20) DSN('"ODSN"') SHR"
"EXECIO * DISKW D20(STEM RDATA. FINIS"

/* TO READ THE JCL LINE BY LINE */
READLINES:
    SAY 'READLINES'
    PARSE VAR IDATA.I 1 INDATA 73
    PARSE VAR INDATA 1 CMNT 4
    IF CMNT = '//*' THEN
       DO
          NO
       END
    ELSE
       DO
          CALL CHECKDSN
       END
RETURN
/* TO EXTRACT THE DATASET NAMES WITH XXX. */
CHECKDSN:
     SAY 'CHECKDSN:'
     SELECT
        WHEN POS(' DSN=XXX.',INDATA) >=1  THEN
           DO
             CALL TOMEXTRACT
           END
        OTHERWISE
           DO
              NOP
           END
     END
RETURN
TOMEXTRACT:
     PARSE VAR INDATA D19DUMY ' DSN=' DNAME ','
     DNAME=STRIP(DNAME,'B')
     SAY 'DNAME:' DNAME
     RDATA.COUNT=DNAME
     COUNT = COUNT  + 1
RETURN



I am able to get the DSN name if i directly give the PDS name & the member name like below:

Code:

DSN='mypds'
MEM='mymem' 


But i want to extract the dataset with the specific word from the entire members present in PDS. Could please help / guide me where i am making a miss ?
Back to top
View user's profile Send private message
saikarthik94

New User


Joined: 04 Sep 2019
Posts: 12
Location: India

PostPosted: Tue Oct 10, 2023 8:56 pm
Reply with quote

Solved the issue by myself!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
Search our Forums:

Back to Top