Need help in a rexx scenario for creating and updating PDS



IBM's Command List programming language & Restructured Extended Executor

Need help in a rexx scenario for creating and updating PDS

Postby princesam89 » Fri Feb 02, 2024 4:20 pm

Hello All,
I am new into the Mainframe world. I have gone through rexx manuals and started off with few codes.

I have a scenario where i will get the input from the user and have to create a PDS dataset and then create members dynamically inside the PDS. Where there is a condition if the member is already present then i will reuse them and append the data to the member

SAY 'ENTER THE SETNAME:'
PULL SETNAME

NEWDSN = 'HLQ.REPORT'
NEWDSN = NEWDSN || '.' || SETNAME
SAY NEWDSN

ADDRESS TSO
"ALLOC F(LISTDAT) DS('"NEWDSN"') NEW SPACE (50,20) DIR (10),
DSORG (PO) RECFM (F,B) LRECL (80) BLKSIZE (8000)"

IF SYSDSN("'"NEWDSN"'") = 'OK' THEN
SAY "THE DATASET EXISTS."
ELSE
SAY "THE DATASET DOES NOT EXIST."

ADDRESS TSO
"ALLOC F(INFILE) SHR DS('"DSNAME"')"
/* READ THE DATA to STEM */
"EXECIO * DISKR INFILE (FINIS STEM INDATA."
SAY INDATA.0

INPD = INDATA.1

CALL MEMLIST NEWDSN,"MEM001",INPD

MEMLIST:
PARSE ARG PDS,MEM,DATA
DSN = PDS || "(" || MEM || ")"

SAY 'NEW OUTPUT MEMBER DSN:' DSN /* displaying HLQ.REPORT.SETNAME(MEM001)

ADDRESS TSO
"ALLOC DA('"PDS"("MEM")') F(MYOTDD) NEW"
"EXECIO 0 DISKW MYOTDD (STEM DATA. FINIS"
SAY 'RCE:' RC
"FREE F(MYOTDD)"

Using the above code i m able to create the dataset HLQ.REPORT.SETNAME but the member "MEM001" is not getting created

i checked via ispf panel and it is showing as no members found.

I checked the error code rc and it is 0 as well.

kindly share your thoughts and thanks in advance
princesam89
 
Posts: 1
Joined: Fri Feb 02, 2024 1:03 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Need help in a rexx scenario for creating and updating P

Postby sergeyken » Fri Feb 02, 2024 6:39 pm

1. Please, learn how to use the Code button when posting your code and/or data.

2. You can create an empty PDS dataset, with no members added, but you cannot create an empty PDS member without trying to write data into it.

This statement does nothing else but close the dataset:
"EXECIO 0 DISKW MYOTDD (STEM DATA. FINIS"


An "empty member" actually makes no sense, from any point of view.
There is no need to have new member already created before writing real data to this member.
Javas and Pythons come and go, but JCL and SORT stay forever.
User avatar
sergeyken
 
Posts: 409
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 6 times
Been thanked: 40 times

Re: Need help in a rexx scenario for creating and updating P

Postby willy jensen » Sat Feb 03, 2024 5:08 pm

A couple of things for starters.

You don't have an EXIT statement after "CALL MEMLIST NEWDSN,"MEM001",INPD", which means that the pgm will continue with the MEMLIST subroutine efter the call.

The "ALLOC DA('"PDS"("MEM")') F(MYOTDD) NEW" statement will fail as the dataset exists already, the DISP parameter is for the dataset, not the member.

You call MEMLIST with the value of indata.1 as the 3rd parameter, then it looks as if you try to use that in the EXECIO parameter?
willy jensen
 
Posts: 455
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 69 times

Re: Need help in a rexx scenario for creating and updating P

Postby willy jensen » Sat Feb 03, 2024 8:07 pm

I'm not quite sure what you want to accomplish with this sequence:
 INPD = INDATA.1
  CALL MEMLIST NEWDSN,"MEM001",INPD
  ...
  MEMLIST:
  PARSE ARG PDS,MEM,DATA
  ...
  "EXECIO 0 DISKW MYOTDD (STEM DATA. FINIS"

but if the aim is to name the stem to write, then it won't work. Here is one that does:
 CALL MEMLIST NEWDSN,'MEM001','data.'
  ...
  MEMLIST:
  PARSE ARG PDS,MEM,stemname
  ...
  "EXECIO" value(stemname'0') "DISKW MYOTDD (STEM" stemname "FINIS"
willy jensen
 
Posts: 455
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 69 times


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post