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

How to sum PD values in the trailer


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

New User


Joined: 09 Dec 2006
Posts: 56
Location: Pune

PostPosted: Wed Dec 29, 2010 8:04 pm
Reply with quote

can we sum the comp-3 amounts and write them in trailer with PD format
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: Wed Dec 29, 2010 9:45 pm
Reply with quote

Hello,

When you have a question, you should start a new topic for your question (rather than post a reply to a topic that has been inactive for years. . .).

Suggest you show some sample input and the output you want from this input. Mention the recfm and lrecl of the files.
Back to top
View user's profile Send private message
Help-Me-Out

New User


Joined: 09 Dec 2006
Posts: 56
Location: Pune

PostPosted: Wed Dec 29, 2010 9:55 pm
Reply with quote

Applologies!! I was searching the forum n replied to that..

Here is my requirement -

I have a file of 159 FB, which has amount PIC S9(9)V99 COMP-3 along with other fields. I need to generate the update the trailer with the count & sum of the amount, both in PD. Can we do this??

INPUT
000000026JAN2010
1234456000010
1234456000010
1234456000010
99999999

OUTPUT
000000026JAN2010
Account amount in PD
1234456 000010
1234457 000010
1234458 000010
99999999count in PD sum in PD
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: Wed Dec 29, 2010 10:04 pm
Reply with quote

Hello,

Quote:
Applologies!! I was searching the forum n replied to that..
Not to worry icon_smile.gif

And we highly encourage searching icon_idea.gif
If there is a topic you want to refer, you can post the link to it (the topic you found) in your new topic.

Why did pos 1-7 change in the output? In the new trailer, what should be the count (i.e. should the count include the header and/or trailer)? Should the "sum" for the sample data be 30?
Back to top
View user's profile Send private message
Help-Me-Out

New User


Joined: 09 Dec 2006
Posts: 56
Location: Pune

PostPosted: Wed Dec 29, 2010 10:13 pm
Reply with quote

Not that way..I was just showing wt is first field n second field.

OUTPUT
000000026JAN2010
Account amount in PD
1234456 000010
1234457 000010
1234458 000010
99999999count in PD sum in PD

In trailer count should exclude HDR & TLR. and sum willbe 30 but in comp-3 format.
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: Wed Dec 29, 2010 10:56 pm
Reply with quote

What is the starting position, length and format of each relevant field in your input records, and expected trailer record?

Is the Account record really in the input file?

Are you sorting the records or just copying them?
Back to top
View user's profile Send private message
Help-Me-Out

New User


Joined: 09 Dec 2006
Posts: 56
Location: Pune

PostPosted: Thu Dec 30, 2010 10:21 am
Reply with quote

Yes, I am sorting the input on account.

Account no is in file of 19 bytes (starting at pos 1) & amount is in S9(9)V99 COMP-3 (starting at pos 20). Account & amount is in input file only.

Trailer should have TLR identifier of 19 chars (19 9's), Total count excluding HDR & TLR in PD lenght of 9 & sum of amounts after that.
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 Dec 31, 2010 12:10 am
Reply with quote

Well, your description doesn't really match your example. It looks like you have a 7-byte account number rather than a 19-byte account number. but assuming that 7 bytes of 0s and 9s is enough to identify the header and trailer record, respectively, you can use a DFSORT job like the following to do what I think you want:

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/159)
//SORTOUT DD DSN=...  output file (FB/159)
//SYSIN DD *
  OMIT COND=(1,7,CH,EQ,C'9999999')
  INREC IFTHEN=(WHEN=(1,7,CH,EQ,C'0000000'),
    OVERLAY=(160:+0,TO=PD,LENGTH=6)),
   IFTHEN=(WHEN=NONE,OVERLAY=(160:20,6))
  SORT FIELDS=(1,19,CH,A)
  OUTFIL REMOVECC,
    BUILD=(1,159),
    TRAILER1=(19C'9',TOT=(160,6,PD,TO=PD,LENGTH=9))
/*
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 INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Insert trailer for non empty file only DFSORT/ICETOOL 6
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
Search our Forums:

Back to Top