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
 

 

Reformatting Header and Trailer

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Reformatting Header and Trailer
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: 578
Location: USA

PostPosted: Thu Sep 02, 2010 6:07 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts DSN name in trailer kranthikumarb DFSORT/ICETOOL 7 Mon Feb 29, 2016 11:30 am
No new posts JCL SORT to split the file and put re... Bill Woodger DFSORT/ICETOOL 17 Wed Feb 17, 2016 4:17 pm
No new posts Remove header only knobi SYNCSORT 5 Mon Feb 15, 2016 10:42 pm
No new posts GROUP - header data to be repeated in... Musab Ahmed DFSORT/ICETOOL 3 Mon Feb 01, 2016 11:36 am


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