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

OUTFIL with SAVE option


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jzhardy

Active User


Joined: 31 Oct 2006
Posts: 139
Location: brisbane

PostPosted: Fri Aug 25, 2023 10:49 am
Reply with quote

Asking this more out of academic interest as I have a plan B (REXX)

I have a requirement to split an input file into an output file + (NEW) Input file.

eg, INPUT1:
Code:
1,2,3
4 5 6 7
12   24    ,45
66 77
777
...


OUTPUT1 (first N records, formatted) - suppose N = 2 for simplicity
Code:
// ,1,2,3 //
// ,4 ,5 ,6 ,7  //


==>INPUT1 (remainer, but unformatted)
Code:
12   24    ,45
66 77
777
...



Input records sometimes have space separators, sometimes commas, sometimes a mix.

My solution is :
Code:
//STEP0100 EXEC PGM=SORT                               
//SYSOUT   DD SYSOUT=*                                 
//SORTIN   DD DISP=SHR,DSN=<some DSN> 
//SORTOUT1 DD DSN=&&SRTOUT,DISP=(,PASS)                 
//SORTOUT2 DD DISP=OLD,DSN=<some DSN>   
//SYSIN    DD *                                         
  OPTION COPY                                           
  OMIT COND=(1,80,CH,EQ,C' ')                           
  OUTFIL FNAMES=SORTOUT1,ACCEPT=10                     
  OUTFIL FNAMES=SORTOUT2,SAVE                           
//*         
//STEP0200 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD DSN=&&SRTOUT,DISP=(SHR,PASS)                 
//SORTOUT  DD DSN=<another DSN>, 
//            DISP=(NEW,CATLG,DELETE),                     
//            SPACE=(CYL,(3,2),RLSE),                       
//            DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)             
//SYSIN    DD *                                             
  OPTION COPY                                               
  OUTREC FIELDS=(1,80,SQZ=(SHIFT=LEFT,                     
     PREBLANK=C',',LEAD=C'// ,',MID=C',',TRAIL=C' //'))     
//*     



1\
can this be collapsed into one step ? The SAVE records are implicitly formatted, and I can't see an obvious way to switch that behaviour off.

2\
Ideally what I'd really like is to split based on a tally of numbers rather than an arbitrary record count (10 in the example above). Some records in the INPUT dataset might have just one number; others may have up to 8. i'd like to break when the tally exceeds a limit (say, 100).

I can do this in REXX which is my fallback.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1337
Location: Bamberg, Germany

PostPosted: Fri Aug 25, 2023 12:48 pm
Reply with quote

Even if you specify SAVE keyword for an OUTFIL, you can still apply formatting.
Back to top
View user's profile Send private message
jzhardy

Active User


Joined: 31 Oct 2006
Posts: 139
Location: brisbane

PostPosted: Fri Aug 25, 2023 3:35 pm
Reply with quote

that's correct, which is why I don't think this can be reduced to a single step, at least not elegantly.

When I tried this as one step, I found that formats were applied across both OUTFILEs. I want only the first N records to have formats applied (==>OUTFILE1); but no formats applied into (OUTFILE2 ==> INPUT)

In terms of part (2), I could have rephrased the problem better as : split after N commas have been applied.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2141
Location: USA

PostPosted: Fri Aug 25, 2023 5:24 pm
Reply with quote

Code:
 . . . . . .
//SYSIN    DD *                                         
  OPTION COPY                                           
  OMIT COND=(1,80,CH,EQ,C' ')                           
  OUTFIL FNAMES=SORTOUT1,ACCEPT=10,
         BUILD=(format part 1)                     
  OUTFIL FNAMES=SORTOUT2,SAVE,
         BUILD=(format part 2)                         
//*
 . . . . . . . . . .
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1337
Location: Bamberg, Germany

PostPosted: Fri Aug 25, 2023 5:32 pm
Reply with quote

sergeyken wrote:
Code:
 . . . . . .
//SYSIN    DD *                                         
  OPTION COPY                                           
  OMIT COND=(1,80,CH,EQ,C' ')                           
  OUTFIL FNAMES=SORTOUT1,ACCEPT=10,
         BUILD=(format part 1)                     
  OUTFIL FNAMES=SORTOUT2,SAVE,
         BUILD=(format part 2)                         
//*
 . . . . . . . . . .

What I meant, but didn't dare to write. icon_wink.gif
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2141
Location: USA

PostPosted: Fri Aug 25, 2023 6:08 pm
Reply with quote

Joerg.Findeisen wrote:
sergeyken wrote:
Code:
 . . . . . .
//SYSIN    DD *                                         
  OPTION COPY                                           
  OMIT COND=(1,80,CH,EQ,C' ')                           
  OUTFIL FNAMES=SORTOUT1,ACCEPT=10,
         BUILD=(format part 1)                     
  OUTFIL FNAMES=SORTOUT2,SAVE,
         BUILD=(format part 2)                         
//*
 . . . . . . . . . .

What I meant, but didn't dare to write. icon_wink.gif


Nowadays IT experts do not understand any hints, besides copy-and-paste examples. It makes me crazy... 12.gif
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1337
Location: Bamberg, Germany

PostPosted: Fri Aug 25, 2023 6:18 pm
Reply with quote

I treasure your expertise. I miss that since my colleague has retired.
Back to top
View user's profile Send private message
jzhardy

Active User


Joined: 31 Oct 2006
Posts: 139
Location: brisbane

PostPosted: Sat Aug 26, 2023 8:10 am
Reply with quote

thanks, yes that works fine
Code:
//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD *                                           
    1 2,   4                                               
    4 5 6 7 555                                           
    333  444 666                                           
    23456                                                 
    3333  4444                                             
/*                                                         
//SORTOUT1 DD SYSOUT=*                                     
//SORTOUT2 DD SYSOUT=*                                     
//SYSIN    DD *                                           
  OPTION COPY                                             
  OMIT COND=(1,80,CH,EQ,C' ')                             
  OUTFIL FNAMES=SORTOUT1,ACCEPT=2,                         
         BUILD=(1,80,SQZ=(SHIFT=LEFT,                     
     PREBLANK=C',',LEAD=C'// ,',MID=C',',TRAIL=C' //'))   
  OUTFIL FNAMES=SORTOUT2,SAVE,                             
         BUILD=(1:1,80)                                   
//*


yields:

SORTOUT1:
Code:
// ,1,2,4 //     
// ,4,5,6,7,555 //

SORTOUT2:
Code:
    333  444 666
    23456       
    3333  4444   
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Save SYSLOG in a MASS complex All Other Mainframe Topics 3
No new posts can an ISPF appl save user changes in... TSO/ISPF 14
No new posts How to save SYSLOG as text data via P... All Other Mainframe Topics 4
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts SCOPE PENDING option -check data DB2 2
Search our Forums:

Back to Top