Read PDS member in array



IBM's Command List programming language & Restructured Extended Executor

Read PDS member in array

Postby arya_starc » Wed Jan 04, 2017 8:31 pm

Hello, I am tyro in rexx
My requirement is I need to compare the member name give in one SE with one pds which contains the mebers name. If the member name in SE file match(In se file content is only members name) with the member name in PDS then I need to copy that member in some other pds.
I am able to read the PS file by this below code

ADDRESS TSO                                    
"ALLOC F(INFILE) DSN('my.seq.dsn') SHR REU"    
"EXECIO * DISKR INFILE ( FINIS STEM MYFILE."
"FREE F(INFILE)"
I = 1
DO WHILE I <= MYFILE.0
   SAY ' LINE ' I ' : ' MYFILE.I
   I = I + 1
END
 

Now I need to compare the se file member to pds member name. For this I need to read the PDS member name.
I am not getting how to read and compare the PDS member name with se file content.
How can i read the PDS member in array so that I can comare the pds member name with other variable.
arya_starc
 
Posts: 136
Joined: Mon Sep 21, 2015 1:39 pm
Has thanked: 5 times
Been thanked: 0 time

Re: Read PDS member in array

Postby NicC » Wed Jan 04, 2017 8:40 pm

What is an 'SE file'? Rexx does not hve arrays - it has stem variables (similar to arrays but not). z/OS does not have files it has data sets (that is why, in JCL, you have DSN= not FN=).

You need to read the rexx manual - not in depth but justy enough to know which items to read in depth for this particuar project. You also need to read the ISPF Dialog services manual to read up on the library services. You also need neeed to read through the forum for topics that look like yours as there are many (of course we do not know what SE means so I may be wrong).
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Read PDS member in array

Postby arya_starc » Wed Jan 04, 2017 9:17 pm

NicC wrote:What is an 'SE file'? Rexx does not hve arrays - it has stem variables (similar to arrays but not). z/OS does not have files it has data sets (that is why, in JCL, you have DSN= not FN=).

You need to read the rexx manual - not in depth but justy enough to know which items to read in depth for this particuar project. You also need to read the ISPF Dialog services manual to read up on the library services. You also need neeed to read through the forum for topics that look like yours as there are many (of course we do not know what SE means so I may be wrong).


Thanks NicC for correcting. I will remember these terms next time and Yes I am reading REXX manual.
arya_starc
 
Posts: 136
Joined: Mon Sep 21, 2015 1:39 pm
Has thanked: 5 times
Been thanked: 0 time

Re: Read PDS member in array

Postby enrico-sorichetti » Wed Jan 04, 2017 9:22 pm

I = 1
DO WHILE I <= MYFILE.0
   SAY ' LINE ' I ' : ' MYFILE.I
   I = I + 1
END


Why not use the simpler construct

do i = 1 to myfile.0
    say "Line-"right(i,4,"0") ">>>"myfile.i"<<<"
end
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 165 times

Re: Read PDS member in array

Postby steve-myers » Wed Jan 04, 2017 9:55 pm

arya_starc wrote:Hello, I am tyro in rexx ...
My requirement is I need to compare the member name give in one SE with one pds which contains the mebers name. If the member name in SE file match(In se file content is only members name) with the member name in PDS then I need to copy that member in some other pds.
I am able to read the PS file by this below code

ADDRESS TSO                                    
"ALLOC F(INFILE) DSN('my.seq.dsn') SHR REU"    
"EXECIO * DISKR INFILE ( FINIS STEM MYFILE."
"FREE F(INFILE)"
I = 1
DO WHILE I <= MYFILE.0
   SAY ' LINE ' I ' : ' MYFILE.I
   I = I + 1
END
 

Now I need to compare the se file member to pds member name. For this I need to read the PDS member name.
I am not getting how to read and compare the PDS member name with se file content.
How can i read the PDS member in array so that I can comare the pds member name with other variable.


Now, I gather from this you have a data set containing member names, one member name in each line of the data set. In other words, something like this -

ASMAC
ASMACG
ASMACL
ASMACLG
CBCB
CBCBG
CBCC
CBCCB
CBCCBG
CBCCL
CBCCLG

Ignoring the question about how this data set was initially populated, first you want to determine if the member exists in the PDS? Find the discussion about SYSDSN in your Rexx book. SYSDSN returns either OK or a message indicating the reason for the problem.

If it returns OK, then ALLOC F(INFILE) DSN('MY.pds(MEMBER)') will prepare the INFILE "file" to read the member as though it is a sequential data set with EXECIO.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Read PDS member in array

Postby arya_starc » Wed Jan 04, 2017 10:34 pm

yes Steve. I am reading the content of data set which is driver file for this Rexx and content only member name.
And that member name I am checking in the PDS by this below command

ISOK = (SYSDSN("'PDS.NAME(MYFILE.I)'"))
IF ISOK = "OK"
 


but i am getting error code INVALID DATASET NAME
arya_starc
 
Posts: 136
Joined: Mon Sep 21, 2015 1:39 pm
Has thanked: 5 times
Been thanked: 0 time

Re: Read PDS member in array

Postby Akatsukami » Wed Jan 04, 2017 11:48 pm

I believe that you have your code searching for a member of a PDS(E) named PDS.NAME(MYFILE.I), which is extremely unlikely to exist.

I suggest that you substitute
lookfor = "'PDS.NAME("myfile.i")'"
isok = sysdsn(lookfor)

if (isok="OK")
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Read PDS member in array

Postby arya_starc » Thu Jan 05, 2017 12:22 am

Akatsukami wrote:I believe that you have your code searching for a member of a PDS(E) named PDS.NAME(MYFILE.I), which is extremely unlikely to exist.

I suggest that you substitute
lookfor = "'PDS.NAME("myfile.i")'"
isok = sysdsn(lookfor)

if (isok="OK")


Thanks Akasukami this syntax is working.

Now I add the ok condition but in my code repro is not working inside the IF-THE-ELSE CONDITION. Below is the code

IF X ='OK' THEN

    SAY YES


    "repro infile(indd)",

    "outfile(outdd) replace"

    "FREE F(indd,outdd)"

ELSE

    SAY NO



 

I am trying to populate the second PDS with the matched member.
but I am getting the error unexpected then or else
arya_starc
 
Posts: 136
Joined: Mon Sep 21, 2015 1:39 pm
Has thanked: 5 times
Been thanked: 0 time

Re: Read PDS member in array

Postby Akatsukami » Thu Jan 05, 2017 12:50 am

Again, remember that the THEN clause must contain only one statement, which is in this case the SAY statement. The IDCAMS and TSO commands are separate statements, then you have the ELSE floating in space, unsupported, which gives the error.

A DO block (including the END delimiter) is considered a single statement. Therefore, change your script to read:

if (x="OK") then
do
  say "Yes!"
  "REPRO INFILE(INDD) OUTFILE(OUTDD) REPLACE"
  "FREE F(INDD, OUTDD)"
end
else
  say "No :("


(Incidentally: is IDCAMS integrated into your TSO environment? At my last client, it was a separate environment; IDCAMS commands had to be preceded by an ADDRESS instruction.)
"
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Read PDS member in array

Postby arya_starc » Thu Jan 05, 2017 12:56 am

And one more question if I am giving this below syntax.

if (x="OK") then
do
  say "Yes!"
  "REPRO INFILE(INDD) OUTFILE(OUTDD) REPLACE"
  "FREE F(INDD, OUTDD)"
end
else
  say "No :("
 


It will copy the same member for which if condition is satisfied.

Akatsukami wrote:
(Incidentally: is IDCAMS integrated into your TSO environment? At my last client, it was a separate environment; IDCAMS commands had to be preceded by an ADDRESS instruction.)
"


Yes I am getting error NO ACTIVE MODULE FOUND nad USER COMPLETION CODE =0913
Is it because of IDCAMS not integration in TSO Environment?
arya_starc
 
Posts: 136
Joined: Mon Sep 21, 2015 1:39 pm
Has thanked: 5 times
Been thanked: 0 time

Next

Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post