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

Sum of a field and put in end of record


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

New User


Joined: 06 Feb 2007
Posts: 29
Location: Noida

PostPosted: Fri Aug 23, 2013 5:30 pm
Reply with quote

Hello,

I have a VB file of length 4022 which consists of a header, detail and trailer record.
Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2----+----3--
$$ABCBOF|AB|CD|FILE.NAME                                   |20130819|160021|
6|4000019579824|+000031900|02*19|02|001|
1|ND|20130819|000000031900|02*19|02|
6|4000280445423|+000186300|NIP81|01|001|
6|4000280217723|+005208900|NIP81|01|002|
$$ABCEOF|AB|CD|FILE.NAME                                   |20130819|160021|0000000156|


What I would need is to sum up the field which starts with 6 from position 19 to 28 (VB considered), basically sum up +000031900 , +000186300 and +005208900 and add it at position 92 of length 12 including the sign to the end of the trailer record $$ABCEOF after |0000000156| which ends at position 91(VB considered). Also add a pipe delimiter at the end.
So my output should be
Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2----+----3--
$$ABCBOF|AB|CD|FILE.NAME                                   |20130819|160021|
6|4000019579824|+000031900|02*19|02|001|
1|ND|20130819|000000031900|02*19|02|
6|4000280445423|+000186300|NIP81|01|001|
6|4000280217723|+005208900|NIP81|01|002|
$$ABCEOF|AB|CD|FILE.NAME                                   |20130819|160021|0000000156|+00054271000|

Thanks a lot for the help.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Aug 23, 2013 9:43 pm
Reply with quote

Can you run this and post the sysout from the step please?

Code:
//S1 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN DD *
Nothing to do with the solution, just for your SORT level
/*
//SORTOUT DD DUMMY
//SYSIN   DD   *
  OPTION COPY
/*


In general, you will pre-pend your records, temporarily, with a zero value, put the actual value there for your "6" records, then place that in the correct location on the trailer and drop the pre-pended bytes.

Specifics depend on your DFSORT level, which we know when you post the above.
Back to top
View user's profile Send private message
sudib19

New User


Joined: 06 Feb 2007
Posts: 29
Location: Noida

PostPosted: Fri Aug 23, 2013 9:53 pm
Reply with quote

Hi Bill,

Below is the Sysout.

Code:

ICE201I H RECORD TYPE IS F - DATA STARTS IN POSITION 1
ICE751I 0 C5-K62149 C6-K90026 C7-K58148 C8-K67572 E9-K60824 C9-BASE   E5-K72040 E7-K70685
ICE143I 0 BLOCKSET     COPY  TECHNIQUE SELECTED
ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES AND MORE
ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R12 - 12:21 ON FRI AUG 23, 2013 -
            OPTION COPY
ICE201I H RECORD TYPE IS F - DATA STARTS IN POSITION 1
ICE751I 0 C5-K62149 C6-K90026 C7-K58148 C8-K67572 E9-K60824 C9-BASE   E5-K72040 E7-K70685
ICE193I 0 ICEAM1 INVOCATION ENVIRONMENT IN EFFECT - ICEAM1 ENVIRONMENT SELECTED
ICE088I 0 CI#R25NE.S1      .        , INPUT LRECL = 80, BLKSIZE = 80, TYPE = FB
ICE093I 0 MAIN STORAGE = (MAX,6291456,6278238)
ICE156I 0 MAIN STORAGE ABOVE 16MB = (6200798,6200798)
ICE127I 0 OPTIONS: OVFLO=RC0 ,PAD=RC0 ,TRUNC=RC0 ,SPANINC=RC16,VLSCMP=N,SZERO=Y,RESET=Y,VSAMEMT=Y,DYNSPC=256
ICE128I 0 OPTIONS: SIZE=6291456,MAXLIM=2097152,MINLIM=450560,EQUALS=N,LIST=Y,ERET=RC16 ,MSGDDN=SYSOUT
ICE129I 0 OPTIONS: VIO=N,RESDNT=ALL ,SMF=NO   ,WRKSEC=Y,OUTSEC=Y,VERIFY=N,CHALT=N,DYNALOC=N             ,ABCODE=MSG
ICE130I 0 OPTIONS: RESALL=8192,RESINV=0,SVC=109 ,CHECK=Y,WRKREL=Y,OUTREL=Y,CKPT=N,COBEXIT=COB2
ICE131I 0 OPTIONS: TMAXLIM=6291456,ARESALL=0,ARESINV=0,OVERRGN=65536,CINV=Y,CFW=Y,DSA=0
ICE132I 0 OPTIONS: VLSHRT=N,ZDPRINT=Y,IEXIT=N,TEXIT=N,LISTX=N,EFS=NONE    ,EXITCK=S,PARMDDN=DFSPARM ,FSZEST=N
ICE133I 0 OPTIONS: HIPRMAX=OPTIMAL,DSPSIZE=MAX ,ODMAXBF=0,SOLRF=Y,VLLONG=N,VSAMIO=N,MOSIZE=MAX
ICE235I 0 OPTIONS: NULLOUT=RC0
ICE236I 0 OPTIONS: DYNAPCT=10 ,MOWRK=Y
ICE084I 0 BSAM ACCESS METHOD USED FOR SORTOUT
ICE084I 0 BSAM ACCESS METHOD USED FOR SORTIN
ICE751I 1 EF-BASE   F0-K66717 E8-K70685
ICE090I 0 OUTPUT LRECL = 80, BLKSIZE = 80, TYPE = FB
ICE055I 0 INSERT 0, DELETE 0
ICE054I 0 RECORDS - IN: 1, OUT: 1
ICE052I 0 END OF DFSORT


Let me know if you are looking for anything specific.

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

Senior Member


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

PostPosted: Fri Aug 23, 2013 10:45 pm
Reply with quote

sudib19 wrote:

What I would need is to sum up the field which starts with 6 from position 19 to 28 (VB considered), basically sum up +000031900 , +000186300 and +005208900 and add it at position 92 of length 12 including the sign to the end of the trailer record $$ABCEOF after |0000000156| which ends at position 91(VB considered). Also add a pipe delimiter at the end.


sudib19,

From your sample data, the records which start with 6 have the amount fields start at 17 which would make them start at position 21 in a VB file. So is your data that you show correct or your description?

Also do you have multiple Trailer records $$ABCEOF or just final one?
Back to top
View user's profile Send private message
sudib19

New User


Joined: 06 Feb 2007
Posts: 29
Location: Noida

PostPosted: Fri Aug 23, 2013 10:52 pm
Reply with quote

Hi Kolusu,

That was my bad.. bad indentation... it starts at 15 which would make them start at position 19 in the VB file and has a length of 10 including the sign.

There is just one trailer record $$ABCEOF in which I want to put the sum of the amount field of the records which start with 6.

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

Senior Member


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

PostPosted: Fri Aug 23, 2013 11:36 pm
Reply with quote

sudib19 wrote:
That was my bad.. bad indentation... it starts at 15 which would make them start at position 19 in the VB file and has a length of 10 including the sign.

There is just one trailer record $$ABCEOF in which I want to put the sum of the amount field of the records which start with 6.

Thanks


sudib19,

Try this

1. use the same input file twice for Joinkeys INA and INB and match the keys we create after RDW.
Code:

  JOINKEYS F1=INA,FIELDS=(5,8,A),SORTED,NOSEQCK               
  JOINKEYS F2=INB,FIELDS=(5,8,A) 
  JOIN UNPAIRED
  REFORMAT FIELDS=(F1:1,4,F2:13,6,F1:13)


2. Code JNF1CNTL to build=(RDW,8 spaces, data record stat pos) for all the records using IFTHEN=(WHEN=INIT. Using another IFTHEN=(13,8,ch,eq,C'$$ABCEOF'),overlay=(5;13,8).

3. Code JNF2CNTL with INCLUDE COND=((5,1,CH,EQ,C'6',OR,5,8,CH,EQ,C'$$ABCEOF') and use INREC to BUILD=(rdw,C'$$ABCEOF',19,10,SFF,PD,LENGTH=6)
Code sum fields=(13,6,pd)

4.After the JOIN you have the summed value in PD format on the last record. Now using INREC IFTHEN=(WHEN=(11,8,CH,EQ,C'$$ABCEOF'),OVERLAY at position 98 the value at 5 for a length of 6 bytes using the EDIT mask EDIT=(STTTTTTTTTTT),SIGNS=(+,-),C'|')).

5. Using OUTREC BUILD remove the temp fields BUILD=(1,4,11) should give you the desired results.
Back to top
View user's profile Send private message
sudib19

New User


Joined: 06 Feb 2007
Posts: 29
Location: Noida

PostPosted: Sat Aug 24, 2013 1:14 am
Reply with quote

Thanks a lot Kolusu... It works great.
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 7
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:

Back to Top