Page 1 of 3

Read PDS member in array

PostPosted: Wed Jan 04, 2017 8:31 pm
by arya_starc
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.

Re: Read PDS member in array

PostPosted: Wed Jan 04, 2017 8:40 pm
by NicC
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).

Re: Read PDS member in array

PostPosted: Wed Jan 04, 2017 9:17 pm
by arya_starc
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.

Re: Read PDS member in array

PostPosted: Wed Jan 04, 2017 9:22 pm
by enrico-sorichetti
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

Re: Read PDS member in array

PostPosted: Wed Jan 04, 2017 9:55 pm
by steve-myers
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.

Re: Read PDS member in array

PostPosted: Wed Jan 04, 2017 10:34 pm
by arya_starc
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

Re: Read PDS member in array

PostPosted: Wed Jan 04, 2017 11:48 pm
by Akatsukami
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")

Re: Read PDS member in array

PostPosted: Thu Jan 05, 2017 12:22 am
by arya_starc
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

Re: Read PDS member in array

PostPosted: Thu Jan 05, 2017 12:50 am
by Akatsukami
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.)
"

Re: Read PDS member in array

PostPosted: Thu Jan 05, 2017 12:56 am
by arya_starc
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?