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

I have to insert a blank line after every 18th record


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

New User


Joined: 28 Apr 2005
Posts: 99

PostPosted: Thu Jan 03, 2008 4:02 am
Reply with quote

The LRECL is 121. We have text lines one below the other. For better presentation, we want to insert a blank line after every 18th line.

RECFM= FB
RECL=121.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Jan 03, 2008 5:30 am
Reply with quote

Here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/121)
//SORTOUT DD DSN=...  output file (FB/121)
//SYSIN    DD    *
  OPTION COPY
  OUTFIL IFOUTLEN=121,
   IFTHEN=(WHEN=INIT,
     OVERLAY=(122:SEQNUM,8,ZD,START=0,
         130:122,8,ZD,MOD,+18,TO=ZD,LENGTH=2)),
   IFTHEN=(WHEN=(130,2,ZD,EQ,+17),
     BUILD=(1,121,/,X))
/*
Back to top
View user's profile Send private message
Prabha
Warnings : 2

New User


Joined: 05 Dec 2005
Posts: 79

PostPosted: Thu Jan 03, 2008 4:29 pm
Reply with quote

Could you pls explain yr code..

OUTFIL IFOUTLEN=121,
IFTHEN=(WHEN=INIT,
OVERLAY=(122:SEQNUM,8,ZD,START=0,
130:122,8,ZD,MOD,+18,TO=ZD,LENGTH=2)),
IFTHEN=(WHEN=(130,2,ZD,EQ,+17),
BUILD=(1,121,/,X))
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Thu Jan 03, 2008 5:12 pm
Reply with quote

Prabha,

Find below the explanations.

Code:
OUTFIL IFOUTLEN=121,


IFOUTLEN=121 parameter tells DFSORT that the length you want to use for the reformatted records is 121.

Code:
IFTHEN=(WHEN=INIT,
OVERLAY=(122:SEQNUM,8,ZD,START=0,


For all the records in the input file, we are generating the 8-byte ZD sequence number in the position 122. The sequence no starts from 00000000 and increments by 1.

Code:
130:122,8,ZD,MOD,+18,TO=ZD,LENGTH=2)),


Puts the result in position 130
122,8,ZD,MOD,+18 -> This gets the remainder (modulus) of the 8 byte ZD seqnum divided by 18.
TO=ZD,LENGTH=2 -> The reminder is stored with length 2.

The sequence number starts from 0 and hence your 18th record will have the sequence number as 00000017. The remainder is 17 When the sequence number in the 18th record, 36th record, etc is divided by 18.

Code:
IFTHEN=(WHEN=(130,2,ZD,EQ,+17),
BUILD=(1,121,/,X))


When the remainder is 17, we are building the first 121 bytes (required bytes) and then writing a new blank line (/,X). The other records are just copied without changes.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Jan 03, 2008 10:11 pm
Reply with quote

Aaru,

Pretty good explanation. I edited it a bit for clarity.

Prabha,

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Fri Jan 04, 2008 11:17 am
Reply with quote

Frank,

Quote:
Pretty good explanation.


Thanks.

Quote:
I edited it a bit for clarity


Yes, Now the explanation looks great. Thanks.
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:

Back to Top