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

Problem in EDIT Dataset after EXECIO


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

New User


Joined: 25 Jan 2013
Posts: 4
Location: India

PostPosted: Fri Jan 25, 2013 1:17 pm
Reply with quote

Hi,
I am trying to Concatenate 2 members and store the result in another member of different PDS. I am doing this to automate a process in our project.
The problem is, after EXECIO DISKW command, when I am trying to open the member in Edit mode, I am not able to see the data; but
when I open it after the REXX is executed, I can see the data.
May be this is happening because the data written is not getting saved from buffer to the member when I open it...
The code is as given:

Code:

/*  REXX */                                                     
   TRACE I                                                       
DSN1 = "HLQ1.HLQ2.JCL3"                                     
DSN2 = "HLQ1.HLQ2.JCL3(CONC)"                               
ADDRESS TSO                                                     
 "ALLOCATE DATASET('"DSN1"') F(DAT) NEW SPACE(50,20) DIR(100)", 
 "DSORG(PO) RECFM(F,B) LRECL(80) BLKSIZE(8000)"                 
 "FREE F(DAT)"                                                   
                                                                 
"ALLOC DA('"DSN2"') F(OUTDD)  OLD REUSE"     
                                             
LIM = 1                                           
NUM_STEP = 2                                       
DO WHILE LIM <= NUM_STEP                           
                                                   
DD_NUM    = 'DD'LIM                               
SKEL_NUM  = 'SKEL'LIM                             
DSN_NUM   = 'HLQ1.UTIL.SKELS('||SKEL_NUM||')'   
                                                   
"ALLOC F("DD_NUM") DA('"DSN_NUM"') SHR"           
                                                   
'EXECIO * DISKR 'DD_NUM' (STEM DATA.FINIS'         
QUEUE''                                           
                                                   
'EXECIO * DISKW OUTDD (STEM DATA.FINIS'           
                                                   
LIM = LIM + 1                                     
END                                               
"ISPEXEC EDIT DATASET("DSN2")"           
EXIT   


LMCOPY could have worked if I want to copy from one member to another, but here there are multiple members and I want the concatenated output in third member.

The code is getting executed properly, except for one thing that I am not able to see the output in EDIT mode when I open it in REXX itself.

Please help me solve this problem.
Back to top
View user's profile Send private message
Stefan

Active User


Joined: 12 Jan 2006
Posts: 110
Location: Germany

PostPosted: Fri Jan 25, 2013 2:32 pm
Reply with quote

Dataset DSN2 is allocated exclusively (DISP=OLD). So first issue a FREE DD(OUTDD) before you try to edit it.

By the way: Within your loop (DO WHILE LIM <= NUM_STEP) you allocate the input dataset without freeing it afterwards. You have to get yourself used to always FREE a dataset as quick as possible !
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Fri Jan 25, 2013 3:02 pm
Reply with quote

and ...
using EXECIO * for write is a very bad practice !

meditate on
what will happen if the first file read into the stem has more records than the second one

the proper way would be ....

Code:
"EXECIO  * DISKR ..... ( STEM <stemvar>. finis "
"EXECIO" <stemvar>.0 "DISKW...... (STEM <stemvar>."


not to talk about the fact that using FINIS on every DISKW will close the output dataset
and You will end up with just the last file processed
Back to top
View user's profile Send private message
Mayur Soneji

New User


Joined: 25 Jan 2013
Posts: 4
Location: India

PostPosted: Fri Jan 25, 2013 5:06 pm
Reply with quote

Quote:

FREE DD(OUTDD)


Stefan, thanks for the suggestion. icon_smile.gif
But, this command just before EDIT is also not working. icon_sad.gif

The error I am getting is:

Code:

IKJ56861I  FILE OUTDD NOT FREED, DATA SET IS OPEN
       +++ RC(12) +++


Its evident from the error, that file is not Closed; but how do we close it before I can open it in Edit mode ??


Enrico,
Thanks a lot for your input.
It makes sense that if first file is larger than the other ones, it can create a problem. The reason I have used EXECIO * is that the files are not larger than a 100 records, so its fair to use EXECIO.
Correct me if I am wrong. icon_smile.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Fri Jan 25, 2013 5:08 pm
Reply with quote

Quote:
The reason I have used EXECIO * is that the files are not larger than a 100 records, so its fair to use EXECIO.


there was a typo in my previous post ...should have been

Code:
"EXECIO  * DISKR ..... ( STEM <stemvar>. finis "
"EXECIO" <stemvar>.0 "DISKW...... (STEM <stemvar>."


I am questioning the use of EXECIO * for write, not for read

the number of records which can be reasonably processed thru rexx is a different can of worms
Back to top
View user's profile Send private message
Mayur Soneji

New User


Joined: 25 Jan 2013
Posts: 4
Location: India

PostPosted: Fri Jan 25, 2013 5:20 pm
Reply with quote

Ok...

Quote:
LMCOPY could have worked if I want to copy from one member to another, but here there are multiple members and I want the concatenated output in third member.


I am not able to think of any other option to read from multiple members and write it into a different one.
Can you please suggest.... icon_redface.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Fri Jan 25, 2013 5:29 pm
Reply with quote

looks like there is language barrier here

repeat on ...
for such a small number of records EXECIO is an acceptable solution

what is wrong is to use EXECIO * DISKW

it might result in dropped records , or extra records from previous invocations
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Fri Jan 25, 2013 5:41 pm
Reply with quote

try this

Code:
 ****** ***************************** Top of Data ******************************
 000001 /* rexx */
 000002 trace "o"
 000003 signal on novalue name novalue
 000004 do i = 1 to 100
 000005    stem.i = "line"i
 000006 end
 000007 stem.10 = ""
 000008 Address TSO
 000009 "ALLOC FI(F1) DS('ENRICO.TEST.PS1') SHR REUS"
 000010 "EXECIO * DISKW F1 (STEM STEM. FINIS"
 000011 exit
 000012 novalue:
 000013 say  "*********************************"
 000014 say  "**                             **"
 000015 say  "** novalue trapped at line" || right(sigl,4) || " **"
 000016 say  "**                             **"
 000017 say  "*********************************"
 000018 exit
 ****** **************************** Bottom of Data ****************************


allocate PS dataset insert the snippet the proper dsname

and run three times
1) without statement 7
2) with statement 7
3) with statement 7 using 100 instead of the "*"
Back to top
View user's profile Send private message
Stefan

Active User


Joined: 12 Jan 2006
Posts: 110
Location: Germany

PostPosted: Fri Jan 25, 2013 5:43 pm
Reply with quote

Mayur Soneji wrote:
Quote:

FREE DD(OUTDD)


Stefan, thanks for the suggestion. icon_smile.gif
But, this command just before EDIT is also not working. icon_sad.gif

The error I am getting is:

Code:

IKJ56861I  FILE OUTDD NOT FREED, DATA SET IS OPEN
       +++ RC(12) +++


Its evident from the error, that file is not Closed; but how do we close it before I can open it in Edit mode ??

You haven't closed the file because the keyword FINIS is missing on the EXECIO DISKW statement. You missed the blank between the stem variable DATA. and the keyword FINIS so that it is not recognized. I assume that when you insert the missing blank, the file will be closed and the changed data will be written to the new dataset.

Give it a try!
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Fri Jan 25, 2013 6:05 pm
Reply with quote

that' s what happens when giving too much credit to sloppy coders

i thought that (STEM stem.finis was a typo ... for (STEM STEM. FINIS

but stem.finis verbatim is a good variable

and

Code:
 ****** ***************************** Top of Data ******************************
 000001 /* rexx */
 000002 trace "o"
 000003 signal on novalue name novalue
 000004 Address TSO
 000005 "ALLOC FI(F1) DS('ENRICO.TEST.PS1') SHR REUS"
 000006 "EXECIO *   DISKR F1 (STEM STEM.FINIS"
 000007 say RC
 000008 say rxvars()
 000009 exit
 ...... ...


gives back

Code:
 0
 RC STEM.FINIS0 STEM.FINIS1 STEM.FINIS2
 


it would be wiser for the TS to start over from scratch
icon_cool.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Fri Jan 25, 2013 6:28 pm
Reply with quote

here is how a better written script could look like

Code:

/*  REXX */                                                     
Trace "I"   
                                                   
outds = "HLQ1.HLQ2.JCL3"                                     
outmbr = "HLQ1.HLQ2.JCL3(CONC)"                               

Address TSO                                                     

"ALLOC FI(OU) DS('"outds"') F(DAT) NEW SPACE(50,20) DIR(100)", 
      "DSORG(PO) RECFM(F,B) LRECL(80) BLKSIZE(8000)"                 
if ( RC \= 0 ) then do
    exit
end

"FREE FI(OU)"                                                   
if ( RC \= 0 ) then do
    exit
end

                                                                                         
"ALLOC FI(OU) DS('"outmbr"') OLD REUSE"     
if ( RC \= 0 ) then do
    exit
end

                     
coun  = 0                                           
steps = 2                                       
Do s = 1 to steps                           
                                                                                 
    inpmbr  = "SKEL"s                             
    inpds   = "HLQ1.UTIL.SKELS("inpmbr")"   
                                                   
    "ALLOC FI(IN) DA('"inpds"') SHR REUSE"           
    if ( RC \= 0 ) then do
        exit
    end
                                                   
    "EXECIO * DISKR IN (STEM DATA. FINIS'                         
    if ( RC \= 0 ) then do
        exit
    end
    "FREE FI(IN)"                                                   
                                   
    "EXECIO" data.0 "DISKW OU (STEM DATA."           
    if ( RC \= 0 ) then do
        exit
    end
    coun = coun + data.0                                           

end
 "EXECIO 0 DISKW OU (FINIS" 
"FREE FI(OU)"                                                   
                                             
Address ISPEXEC "EDIT DATASET("outmbr")"           

exit


[/code]
Back to top
View user's profile Send private message
Mayur Soneji

New User


Joined: 25 Jan 2013
Posts: 4
Location: India

PostPosted: Mon Jan 28, 2013 12:33 pm
Reply with quote

Stefan,
You were right... There was a silly mistake of missing out a blank.
After correcting that, it took me to what Enrico has pointed out:

Quote:

what is wrong is to use EXECIO * DISKW

it might result in dropped records , or extra records from previous invocations


Enrico,
Thanks a lot for your valuabe inputs.
The result was having dropped records, it only reflected data from second member because of FINIS I was using while writing everytime.
Your modified script worked like a Gem. icon_smile.gif

Also, the code snippet that you asked me to try
Code:

 ****** ***************************** Top of Data ******************************
 000001 /* rexx */
 000002 trace "o"
 000003 signal on novalue name novalue
 000004 do i = 1 to 100
 000005    stem.i = "line"i
 000006 end
 000007 stem.10 = ""
 000008 Address TSO
 000009 "ALLOC FI(F1) DS('ENRICO.TEST.PS1') SHR REUS"
 000010 "EXECIO * DISKW F1 (STEM STEM. FINIS"
 000011 exit
 000012 novalue:
 000013 say  "*********************************"
 000014 say  "**                             **"
 000015 say  "** novalue trapped at line" || right(sigl,4) || " **"
 000016 say  "**                             **"
 000017 say  "*********************************"
 000018 exit
 ****** **************************** Bottom of Data ****************************


gave me a better insight of how things work.

Thanks a ton for your inputs Enrico and Stefan.
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 batch SFTP job using AOPBATCH unable ... All Other Mainframe Topics 7
No new posts Reading Empty Dataset DFSORT/ICETOOL 5
No new posts Mainframe Dataset Binary or ASCII Mainframe Interview Questions 4
No new posts SPOOL to Mainframe dataset in batch mode JCL & VSAM 7
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
Search our Forums:

Back to Top