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

How to generate variable number of records


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

New User


Joined: 25 Jan 2007
Posts: 42
Location: france

PostPosted: Fri Mar 27, 2015 12:49 pm
Reply with quote

Hello,

I have to generate a variable number of records to an output file. In a symnames card I have this number of variable records. Is there a way to do this ?

Exemple
Code:

//SYMNAMES DD *                                           
NUMREC,5                                                   
*/                                                         
//INFILE   DD DUMMY,LRECL=80,RECFM=FB                     
//OUTPUT   DD DISP=(NEW,CATLG,DELETE),                     
//            DSN=&SYSUID..NEW.RECORDS,                   
//            DCB=(LRECL=80,RECFM=FB,BLKSIZE=0,DSORG=PS), 
//            SPACE=(TRK,(1,1),RLSE),UNIT=SYSALLDA         


Expected output file
Code:

RECORD WITH VALUE 10
RECORD WITH VALUE 19
RECORD WITH VALUE 28
RECORD WITH VALUE 37
RECORD WITH VALUE 46


VALUE for the first record is 10 but for all other VALUE = previous VALUE + 9

Thanks for your help
Best regards
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Mar 27, 2015 1:56 pm
Reply with quote

OUTFIL REPEAT= will give you multiple output records per input record. REPEAT= up to DFSORT 2.1 can't use a symbol/SYMNAME. If you have 2.1, you may be lucky. If you don't, you'll have to use the symbol to generate the sort control cards to a dataset and run a second step using that dataset as the SYSIN.

To get your steps-of-nine from your starting point, temporarily extend the record to have a sequence number starting from zero, multiply by the sequence number by nine and add it to 10. Something like that.
Back to top
View user's profile Send private message
tuxama

New User


Joined: 25 Jan 2007
Posts: 42
Location: france

PostPosted: Fri Mar 27, 2015 6:29 pm
Reply with quote

Here, the piece of code I developed

The needed sysin :

Code:

  OPTION COPY
  OUTFIL REPEAT=5,IFOUTLEN=80,
   IFTHEN=(WHEN=INIT,OVERLAY=(90:SEQNUM,2,ZD,START=0,INCR=1)),
   IFTHEN=(WHEN=INIT,OVERLAY=(20:90,2,ZD,MUL,+9,ADD,+10,
                              M11,LENGTH=3))


Step S02 generates the expected sysin :

Code:

//S02      EXEC PGM=ICEMAN
//SYSOUT   DD SYSOUT=*
//SYMNAMES DD *
NREC,'5'
IFT,'IFTHEN=(WHEN=INIT,'
/*
//SORTIN   DD DUMMY,LRECL=80,RECFM=FB
//SORTOUT  DD DISP=(NEW,CATLG,DELETE),
//            DSN=&SYSUID..REPEAT.T1,
//            DCB=(LRECL=80,RECFM=FB,BLKSIZE=0,DSORG=PS),
//            SPACE=(TRK,(1,1),RLSE),UNIT=SYSALLDA
//SYSIN    DD *
  OPTION COPY
  OUTFIL REMOVECC,
   HEADER1=(2X,'OPTION COPY',/,
            2X,'OUTFIL REPEAT=',NREC,',IFOUTLEN=80,',/,
            3X,IFT,'OVERLAY=(90:SEQNUM,2,ZD,START=0,INCR=1)),',/,
            3X,IFT,'OVERLAY=(20:90,2,ZD,MUL,+9,ADD,+10,',/,
            30X,'M11,LENGTH=3))')
/*


Step S03 gives the final result :

Code:

//S03      EXEC PGM=ICEMAN
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
RECORD WHITH VALUE ---
/*
//SORTOUT  DD SYSOUT=*
//SYSIN    DD DISP=SHR,DSN=&SYSUID..REPEAT.T1


Here are the contents of the sysout :

Code:

********************************* TOP OF DATA *******
RECORD WHITH VALUE 010
RECORD WHITH VALUE 019
RECORD WHITH VALUE 028
RECORD WHITH VALUE 037
RECORD WHITH VALUE 046
******************************** BOTTOM OF DATA *****


Thanks a lot Bill.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Mar 27, 2015 6:53 pm
Reply with quote

Thanks for posting your solution, and good work getting there.

I'd suggest you remove the DCB from the SORTOUT, SORT will do that, which means if it is in the JCL you'll have two places to maintain it.

The INCR=1 is not needed, as it is the default increment.
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top