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

Reformatting Header and Trailer


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

New User


Joined: 31 Aug 2010
Posts: 20
Location: Edinburgh

PostPosted: Thu Sep 02, 2010 1:05 pm
Reply with quote

I would like to use DFSORT to reformat a header and trailer. I have been
palying around with OUTREC IFTHEN statements and OUTFIL TRAILER1
statements for almost two days now but I can't get the thing do what I
want and I can't find a post that covers it either.
I normally only use DFSORT for basic sorting but from looking at
the Application Programmers guide I should be able to reformat my
headers and trailers. I'm hoping someone who is a lot slicker with these
commands can give me some pointers or examples I can expand.

Here is an example of a small infile and outfile of what I'd like to
achieve:
Col: 05-10 record type
Col: 11-14 amount

INFILE:

0 BLAHBLAH-INFO FROM ORIGINAL HEADER-
XXXXTYPE A0002
XXXXTYPE C0003
XXXXTYPE A0006
XXXXTYPE A0005
XXXXTYPE B0008
XXXXTYPE B0002
XXXXTYPE A0009
XXXXTYPE C0002
XXXXTYPE A0006
XXXXTYPE B0004
XXXXTYPE A0003
XXXXTYPE B0008
XXXXTYPE C0004
9 OLD TRAILER STUFF NOT REQUIRED

New File:
Header with new date, new text and part of the old header. Detail recs
unchanged.

OUTFILE:

0DDMMYYYYHHMMSSNEW TEXT-INFO FROM ORIGINAL HEADER-
XXXXTYPE A0002
XXXXTYPE C0003
XXXXTYPE A0006
XXXXTYPE A0005
XXXXTYPE B0008
XXXXTYPE B0002
XXXXTYPE A0009
XXXXTYPE C0002
XXXXTYPE A0006
XXXXTYPE B0004
XXXXTYPE A0003
XXXXTYPE B0008
XXXXTYPE C0004
900000000130000000062000000000600000000310000000004000000002200000000030000000009

New trailer fields explained:
9 - Trailer ID
0000000013 - Number of total detail recs
0000000062 - Sum of all amount fields
0000000006 - Number of 'TYPE A' recs
0000000031 - Sum of all amount fields for 'TYPE A'
0000000004 - Number of 'TYPE B' recs
0000000022 - Sum of all amount fields for 'TYPE B'
0000000003 - Number of 'TYPE C' recs
0000000009 - Sum of all amount fields for 'TYPE C'

And finally, the input file is 50 wide and the output is 81 wide

Many thanks,

Yvonne.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Thu Sep 02, 2010 6:07 pm
Reply with quote

Yvonne,
Do you care for the original order of the detail records? Is it ok to sort detail records by record type? What is the field def. for amount field?
Also could you have multiple sets like the one you have shown above?

Thanks,
Back to top
View user's profile Send private message
Yvonne1980

New User


Joined: 31 Aug 2010
Posts: 20
Location: Edinburgh

PostPosted: Thu Sep 02, 2010 6:52 pm
Reply with quote

Hi,

Unfortunately I need to leave the detail records unchanged and in their original order.

The amount field is an unsigned integer, no decimal places, just a basic 4 digit number.

Yes, there could be many more sets like the one above, and many more permutations similar to the one above, the file could also have no ‘TYPE B’ recs for example. What I have shown is a very small representative sample I was using in my as yet unsuccessful tests.

Thanks,

Yvonne
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Sep 02, 2010 9:29 pm
Reply with quote

Yvonne1980,

The following DFSORT JCL will give you the desired results. I assumed that you want to pick up 25 byte from position 20 on the header record.

Code:

//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD DSN=Your input FB 50 byte file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                 
  OMIT COND=(1,1,ZD,EQ,9)                                       
  SORT FIELDS=COPY                                               
                                                                 
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(51:11,4,15C'0')),             
  IFTHEN=(WHEN=(1,1,ZD,EQ,0),BUILD=(1,1,DATENS=(DM4),           
  C'NEW TEXT INFO ',20,25,51:4C'0',55,15)),                     
  IFTHEN=(WHEN=(5,6,CH,EQ,C'TYPE A'),OVERLAY=(55:11,4,67:C'1')),
  IFTHEN=(WHEN=(5,6,CH,EQ,C'TYPE B'),OVERLAY=(59:11,4,68:C'1')),
  IFTHEN=(WHEN=(5,6,CH,EQ,C'TYPE C'),OVERLAY=(63:11,4,69:C'1')) 
                                                                 
  OUTFIL REMOVECC,BUILD=(1,50,81:X),                             
  TRAILER1=('9',COUNT-1=(M11,LENGTH=10),                         
                TOT=(51,4,ZD,M11,LENGTH=10),                     
                TOT=(67,1,ZD,M11,LENGTH=10),                     
                TOT=(55,4,ZD,M11,LENGTH=10),                     
                TOT=(68,1,ZD,M11,LENGTH=10),                     
                TOT=(59,4,ZD,M11,LENGTH=10),                     
                TOT=(69,1,ZD,M11,LENGTH=10),                     
                TOT=(63,4,ZD,M11,LENGTH=10))
//*
Back to top
View user's profile Send private message
Yvonne1980

New User


Joined: 31 Aug 2010
Posts: 20
Location: Edinburgh

PostPosted: Fri Sep 03, 2010 1:03 pm
Reply with quote

FANTASTIC Koluso !! Your code worked first run and I laughed with delight, you’ve saved me lots of time and hassle.

I wasn’t too far off, I was playing with the EDIT function, but could not get rid of extra spaces on the trailer.

Many thanks,

Yvonne
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Sep 03, 2010 10:26 pm
Reply with quote

Yvonne1980 wrote:
FANTASTIC Koluso !! Your code worked first run and I laughed with delight, you’ve saved me lots of time and hassle.


Yvonne1980,

Glad I could help. I would be grateful if you can take 10 secs of the saved time and spell my name right.

Thank you.

Kolusu
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 Insert header record with record coun... DFSORT/ICETOOL 14
No new posts Insert trailer for non empty file only DFSORT/ICETOOL 6
No new posts Comparing Header and Trailer. DFSORT/ICETOOL 7
No new posts Adding a trailer with record count an... JCL & VSAM 4
No new posts Build a trailer with total an count SYNCSORT 6
Search our Forums:

Back to Top