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

Adding a field in TRAILER based on another field.


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

New User


Joined: 27 Jun 2005
Posts: 36
Location: India

PostPosted: Fri Jan 25, 2008 1:59 am
Reply with quote

Hi All,
After a long time I am back to mainframe again.. :)
I got a requirement recently which I don’t know how to do that through sort parm. So need your help.
Here is the detail of the requirement:
1. We are matching two files based on a key, in a program and giving an o/p file which has the fields--> Key, Amount and the Indicator(Matched & Unmatched).
2. In the next step we are using Report Sort parm to generate a report. The requirements of that report are:
a. The TRAILER should have a Total field having the sum of all the amount for that key and an UNMATCHED Total field which should have the sum amount of unmatched records for that key.

Please advice if there are way to do this.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Jan 25, 2008 2:12 am
Reply with quote

Welcome back icon_smile.gif

Please post the lrecl and recfm of the files.

Also, please post some sample input data and the otput you need when that input is processed. Show the field positions in the inputs and the output(s).
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: Fri Jan 25, 2008 2:14 am
Reply with quote

Quote:
Please advice if there are way to do this.


I'm sure there's a way to do this with DFSORT, but in order to tell you how to do it I need you to give me more information for step 2 as follows:

(When I refer to "input file" below, I mean the output file from step 1 with the Key, Amount and the Indicator(Matched & Unmatched) which is the input file for step 2.)

What is the RECFM and LRECL of the input file?

What is the starting position, length and format of the following fields in the input file: Key, Amount, Indicator?

Please show an example of the record in the input file (relevant fields only) and what you expect the output to look like.
Back to top
View user's profile Send private message
Hritam

New User


Joined: 27 Jun 2005
Posts: 36
Location: India

PostPosted: Fri Jan 25, 2008 3:02 am
Reply with quote

Thanks!

Here are the details you asked for:
I/P
===========
LRECL = 79
RECFM = FB

UM --> Unmatched indicator
M --> Matched Indicator

I/p and o/p record structure are attached.

I took lots of time to edit that notepad, so please find and respond.

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

New User


Joined: 27 Jun 2005
Posts: 36
Location: India

PostPosted: Fri Jan 25, 2008 3:04 am
Reply with quote

Yes Frank, STEP2 Input is the O/p file of STEP1...
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: Fri Jan 25, 2008 4:54 am
Reply with quote

Well, your totals don't really seem to add up to what's in your data, but I think I get the idea. You can use a DFSORT job like the following. Just adjust everything for your actual input fields and expected output. The trick is to use IFTHEN to put 16-23 in 80-87 for the 'UM' records and PD 0's in 80-87 for the other records, and then do a TOT on 80-87 to get the total for the 'UM' records.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=... input file (FB/79)
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=... input file (FB/79)
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=INIT,
     OVERLAY=(80:+0,TO=PD,LENGTH=8)),
    IFTHEN=(WHEN=(78,2,CH,EQ,C'UM'),OVERLAY=(80:16,8))
  SORT FIELDS=(1,15,CH,A)
  OUTFIL BUILD=(33,14,45:16,8,PD,EDIT=(IIIT.TTTT)),
    SECTIONS=(1,15,
      HEADER3=(/,'header stuff'),
      TRAILER3=(/,'UNMATCHED TOTAL',
        45:TOT=(80,8,PD,EDIT=(IIIT.TTTT)),/,
       11:'TOTAL',
        45:TOT=(16,8,PD,EDIT=(IIIT.TTTT))))
/*
Back to top
View user's profile Send private message
Hritam

New User


Joined: 27 Jun 2005
Posts: 36
Location: India

PostPosted: Wed Jan 30, 2008 2:56 am
Reply with quote

Thanks Frank!
Sorry for this delay in response.
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 Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Adding QMF and SPUFI to the ISPF menu DB2 20
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts Adding first / last acct numerber to ... DFSORT/ICETOOL 7
No new posts Join 2 files according to one key field. JCL & VSAM 3
Search our Forums:

Back to Top