Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Problem in EDIT Dataset after EXECIO

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
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    Post subject: Problem in EDIT Dataset after EXECIO
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Fri Jan 25, 2013 3:02 pm    Post subject: Reply to: Problem in EDIT Dataset after EXECIO
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Fri Jan 25, 2013 5:08 pm    Post subject: Reply to: Problem in EDIT Dataset after EXECIO
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Fri Jan 25, 2013 5:29 pm    Post subject: Reply to: Problem in EDIT Dataset after EXECIO
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Fri Jan 25, 2013 5:41 pm    Post subject: Reply to: Problem in EDIT Dataset after EXECIO
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Fri Jan 25, 2013 6:05 pm    Post subject: Reply to: Problem in EDIT Dataset after EXECIO
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Fri Jan 25, 2013 6:28 pm    Post subject: Reply to: Problem in EDIT Dataset after EXECIO
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts FTP - JCL failed while passing FTP co... Suneetha1612 JCL & VSAM 12 Wed Nov 16, 2016 7:33 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm
No new posts Problem in Running Query via JCL vickey_dw DB2 3 Tue Oct 18, 2016 11:11 pm
No new posts To trim spaces in a pipe delimited da... Nish84 COBOL Programming 16 Mon Oct 10, 2016 1:54 pm
No new posts DB2 Streaming Batch Processing Problem Manshadi DB2 4 Sat Sep 24, 2016 12:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us