View previous topic :: View next topic
|
Author |
Message |
pravin1234jd
New User
Joined: 31 May 2010 Posts: 11 Location: India
|
|
|
|
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 |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
this is a line of code which will always be false (NOT = 'OK'):
Code: |
FILE_EXISTS = SYSDSN(CODECOMP_MFILE) |
|
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
pravin1234jd
New User
Joined: 31 May 2010 Posts: 11 Location: India
|
|
|
|
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 |
|
|
marlm
New User
Joined: 08 Apr 2008 Posts: 2 Location: Brazil
|
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
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 |
|
|
|