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

troubleshooting !! How to create multiple members in PDS ?


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pravin1234jd

New User


Joined: 31 May 2010
Posts: 11
Location: India

PostPosted: Fri Dec 30, 2011 12:22 am
Reply with quote

Hi guys,

My requirement: I want to create multiple members is a PDS file, Name of the member will be decided dynamically in the program.

My code:
Below para will be called in a loop with different value of varibale "MEMBER "


Code:
ALLOCATE_MEM:

CODECOMP = TESTDATA.CODE
                                                                   
COMP_MFILE = CODECOMP || "(" || MEMBER || ")"                 
FILE_EXISTS  = SYSDSN(CODECOMP_MFILE)                               
SAY 'FILE_EXISTS  : ' FILE_EXISTS     

IF FILE_EXISTS   /= 'OK' THEN DO                                         
   "ALLOC F(DD1) DS("COMP_MFILE")  SHR REU"                       
   SAY "ALLOCATION COMP_MFILE : " RC COMP_MFILE               
END
                                                                   
HDR_OUTPUT1.1 = " TEST DATA REPORT"                               
                                                                   
"EXECIO * DISKW DD1 (STEM HDR_OUTPUT1."                             
SAY " RC : " RC

RETURN


This code is working fine for allocating first member but when I am trying to allocate the second member I am getting below error

IKJ56861I FILE DD1 NOT UNALLOCATED, DATA SET IS OPEN
ALLOCATION COMP_MFILE : 12
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Fri Dec 30, 2011 12:46 am
Reply with quote

pravin1234jd wrote:
Hi guys,

My requirement: I want to create multiple members is a PDS file, Name of the member will be decided dynamically in the program.

My code:
Below para will be called in a loop with different value of varibale "MEMBER "


Code:
ALLOCATE_MEM:

CODECOMP = TESTDATA.CODE
                                                                   
COMP_MFILE = CODECOMP || "(" || MEMBER || ")"                 
FILE_EXISTS  = SYSDSN(CODECOMP_MFILE)                               
SAY 'FILE_EXISTS  : ' FILE_EXISTS     

IF FILE_EXISTS   /= 'OK' THEN DO                                         
   "ALLOC F(DD1) DS("COMP_MFILE")  SHR REU"                       
   SAY "ALLOCATION COMP_MFILE : " RC COMP_MFILE               
END
                                                                   
HDR_OUTPUT1.1 = " TEST DATA REPORT"                               
                                                                   
"EXECIO * DISKW DD1 (STEM HDR_OUTPUT1."                             
SAY " RC : " RC

RETURN


This code is working fine for allocating first member but when I am trying to allocate the second member I am getting below error

IKJ56861I FILE DD1 NOT UNALLOCATED, DATA SET IS OPEN
ALLOCATION COMP_MFILE : 12

You need to close and free the data set by
Code:
"EXECIO 0 DISKW (FINIS"
"FREE FI(DD1)"


(Alternatively, you could change your existing EXECIO statement to close the data set after writing to it:
Code:
"EXECIO * DISKW DD1 (STEM HDR_OUTPUT1. FINIS"


Although it is ISPF rather Rexx, you may want to check out the ISPF LMM* services.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Dec 30, 2011 1:37 am
Reply with quote

this is a line of code which will always be false (NOT = 'OK'):

Code:
FILE_EXISTS  = SYSDSN(CODECOMP_MFILE)
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Fri Dec 30, 2011 5:47 pm
Reply with quote

Quote:
Code:
CODECOMP = TESTDATA.CODE
Code:
HDR_OUTPUT1.1 = " TEST DATA REPORT"
"EXECIO * DISKW DD1 (STEM HDR_OUTPUT1."

may lead to problems too.
Better do:
Code:
CODECOMP = "TESTDATA.CODE"
and
Code:
HDR_OUTPUT1.1 = " TEST DATA REPORT"
"EXECIO 1 DISKW DD1 (FINIS STEM HDR_OUTPUT1."
or
Code:
HDR_OUTPUT1. = ""
HDR_OUTPUT1.1 = " TEST DATA REPORT"
"EXECIO * DISKW DD1 (FINIS STEM HDR_OUTPUT1."
or
Code:
HDR_OUTPUT1.1 = " TEST DATA REPORT"
HDR_OUTPUT1.2 = ""
"EXECIO * DISKW DD1 (FINIS STEM HDR_OUTPUT1."
Back to top
View user's profile Send private message
pravin1234jd

New User


Joined: 31 May 2010
Posts: 11
Location: India

PostPosted: Tue Jan 03, 2012 7:50 pm
Reply with quote

Thanks all for your reply.

I understood where I was making mistake. I was not closing the member when i was writing into it. i used the FINIS and its working properly now.
Back to top
View user's profile Send private message
marlm

New User


Joined: 08 Apr 2008
Posts: 2
Location: Brazil

PostPosted: Wed Feb 12, 2014 12:37 am
Reply with quote

I need to write lines one by one and using FINIS it closes the file, therefore on next iteration it will not add a new line on member but delete the previous line and overwrite it. Any other suggestion ? Any way of write a member without allocate the dataset?

ibmmainframes.com/viewtopic.php?t=57113&highlight=rexx+pds+allocation
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Wed Feb 12, 2014 1:09 am
Reply with quote

marlm wrote:
I need to write lines one by one and using FINIS it closes the file, therefore on next iteration it will not add a new line on member but delete the previous line and overwrite it. Any other suggestion ? Any way of write a member without allocate the dataset?

Please do not add your query to a thread that has been dormant any length of time, certainly not for two years; start a new thread instead and, if if seems necessary, add a link to the older thread(s).

As you see by the previous discussion, using the FINIS keyword on an EXECIO statement closes the data set or member; therefore, if you intend to write more data to it, do not close it (i.e., use the FINIS keyword). Note that you can append to a PS data set by giving it a status of MOD when allocating, but there is no way to do likewise for a member of a PDS(E); you read the whole thing into and write it out again.

As you will realize if you think about, a data set cannot be written to (or indeed read from) without its being allocated to the program. There are ways of doing this that don't look like a TSO ALLOCATE command, but they amount to the same thing in the end.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts How to create a list of SAR jobs with... CA Products 3
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Grouping by multiple headers DFSORT/ICETOOL 7
Search our Forums:

Back to Top