View previous topic :: View next topic
|
Author |
Message |
saikarthik94
New User
Joined: 04 Sep 2019 Posts: 12 Location: India
|
|
|
|
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 |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1205 Location: Dublin, Ireland
|
|
|
|
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 |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2140 Location: USA
|
|
|
|
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 |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2593 Location: Silicon Valley
|
|
|
|
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 |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2593 Location: Silicon Valley
|
|
|
|
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 |
|
|
saikarthik94
New User
Joined: 04 Sep 2019 Posts: 12 Location: India
|
|
|
|
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 |
|
Back to top |
|
|
saikarthik94
New User
Joined: 04 Sep 2019 Posts: 12 Location: India
|
|
|
|
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 |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1205 Location: Dublin, Ireland
|
|
|
|
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 |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2140 Location: USA
|
|
|
|
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!
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 |
|
|
saikarthik94
New User
Joined: 04 Sep 2019 Posts: 12 Location: India
|
|
|
|
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 |
|
|
saikarthik94
New User
Joined: 04 Sep 2019 Posts: 12 Location: India
|
|
|
|
Solved the issue by myself! |
|
Back to top |
|
|
|