How can I include headder information in the details



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

How can I include headder information in the details

Postby gdchipi » Sat Sep 08, 2012 1:14 am

Hi everyone:

I have to find the way to make a report with the following information:

Input file

       BH0125JO29
       PT220010731120000001000
       PT220010731120000001000     
       BH0125JO30
       PT220020831120000001000
       PT220020831120000001000   
       PT220020831120000001000         


Output file should be

 JO29  22001  07/31/12        2,000.00
 JO30  22002  08/31/12        3,000.00


I need to include this info from the header JO29,JO30 and 22001-22002 , 07/31/12- 08/31/12 from the details. Also need to sum the amounts in the detail (2 records with 1000 in the first group and 3 records with 1000 in the second one). Key is in the header (JO29-JO30) and match with the field from 3-7 in the details (22001 in the first group and 22002 in the second one).


Is there a way to build the output using SORT instruction? I tried but I couldn't.

Code'd
gdchipi
 
Posts: 14
Joined: Sat Sep 08, 2012 12:56 am
Has thanked: 0 time
Been thanked: 0 time

Re: How can I include headder information in the details

 

Re: How can I include headder information in the details

Postby BillyBoyo » Sat Sep 08, 2012 1:21 am

Have a look at WHEN=GROUP with BEGIN, assuming your DFSORT is up-to-date. PUSH on the GROUP allows you to copy data from the record defining the group to all the records that are part of the group.

Search here and in the manuals for examples. Let us know how it goes. Someone will be here if you get stuck.

Edit: KEYBEGIN corrected to BEGIN.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: How can I include headder information in the details

Postby dick scherrer » Sat Sep 08, 2012 1:21 am

Hello and welcome to the forum,

Suggest you post what you tried and what happened.

Post any diagnostic or error information that was presented. If the results were other than what you wanted, show what you wanted and what was actually generated.

Mention the recfm and lrecl of the input and output files.

Use the "Code" tag to preserve alignment and improve readability.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: How can I include headder information in the details

Postby gdchipi » Sat Sep 08, 2012 1:27 am

input file RECFM=FB,LRECL=180
output file RECFM=FB,LRECL=72


I tried usign IFWHEN, PARSE but I cant get any result.
gdchipi
 
Posts: 14
Joined: Sat Sep 08, 2012 12:56 am
Has thanked: 0 time
Been thanked: 0 time

Re: How can I include headder information in the details

Postby skolusu » Sat Sep 08, 2012 3:12 am

gdchipi,

Use the following DFSORT JCL which will give you the desired results.

//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD *                                                   
BH0125JO29                                                       
PT220010731120000001000                                           
PT220010731120000001000                                           
----+----1----+----2----+----3----+----4----+----5----+----6----+-
BH0125JO30                                                       
PT220020831120000001000                                           
PT220020831120000001000                                           
PT220020831120000001000                                           
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                   
  SORT FIELDS=COPY                                               
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,2,CH,EQ,C'BH'),PUSH=(181:7,4))
  OUTFIL REMOVECC,NODETAIL,BUILD=(72X),                           
  SECTIONS=(181,4,                                               
  TRAILER3=(181,4,X,3,5,X,8,2,'/',10,2,'/',12,2,X,               
            TOT=(20,4,ZD,EDIT=(III,IIT)),'.00'))                 
//*
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: How can I include headder information in the details

Postby gdchipi » Mon Sep 10, 2012 9:40 pm

Thanks a lot. It works

I forgot to include another thing so my case was incomplete. What I really need is to sum the mount in the details and not include the header. Below is what I have:

BH0125JO30      4   1   1000                                                 
PT220020831120000001000                                           
PT220020831120000001000                                           
PT220020831120000001000 



The amount should sum 3,000 and not what is in the header.

In there a way to do that?

Code'd
gdchipi
 
Posts: 14
Joined: Sat Sep 08, 2012 12:56 am
Has thanked: 0 time
Been thanked: 0 time

Re: How can I include headder information in the details

Postby skolusu » Mon Sep 10, 2012 10:46 pm

gdchipi wrote:Thanks a lot. It works The amount should sum 3,000 and not what is in the header.


gdchipi,

Did you even run the job I gave you? You say it works and then again you say it is NOT summing. If you had run the job as is you would have seen that I am indeed summing the detail records.
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: How can I include headder information in the details

Postby gdchipi » Mon Sep 10, 2012 11:00 pm

I tried to run using
BH0125JO29           4   1000
PT220010731120000001000
PT220010731120000001000
BH0125JO30           4   1000
PT220020831120000001000
PT220020831120000001000
PT220020831120000001000



and I get

JO29 22001 07/31/12   3,000.00
JO30 22002 08/31/12   4,000.00



So was summing the header too

Code'd
gdchipi
 
Posts: 14
Joined: Sat Sep 08, 2012 12:56 am
Has thanked: 0 time
Been thanked: 0 time

Re: How can I include headder information in the details

Postby skolusu » Mon Sep 10, 2012 11:46 pm

When posting Data, please use CODE tags , so that it is easy to understand. If you look at my example, the header record BH is having spaces at position 20 and hence I only got the summed value of detail records.

Use the following DFSORT JCL which will give you the desired results
//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD *                                             
BH0125JO29         1000                                     
PT220010731120000001000                                     
PT220010731120000001000                                     
BH0125JO30         1000                                     
PT220020831120000001000                                     
PT220020831120000001000                                     
PT220020831120000001000                                     
//SORTOUT  DD SYSOUT=*                                       
//SYSIN    DD *                                             
  SORT FIELDS=COPY                                           
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(185:20,4)),               
  IFTHEN=(WHEN=GROUP,BEGIN=(1,2,CH,EQ,C'BH'),PUSH=(181:7,4)),
  IFTHEN=(WHEN=(1,2,CH,EQ,C'BH'),OVERLAY=(185:4C'0'))       
                                                             
  OUTFIL REMOVECC,NODETAIL,BUILD=(72X),                     
  SECTIONS=(181,4,                                           
  TRAILER3=(181,4,X,3,5,X,8,2,'/',10,2,'/',12,2,X,           
            TOT=(185,4,ZD,EDIT=(III,IIT)),'.00'))           
//*


The output from this is
JO29 22001 07/31/12   2,000.00
JO30 22002 08/31/12   3,000.00
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: How can I include headder information in the details

Postby gdchipi » Tue Sep 11, 2012 3:16 am

Thanks a lot:
Works perfecly. Its what I wanted.
Thanks a lot again.
gdchipi
 
Posts: 14
Joined: Sat Sep 08, 2012 12:56 am
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post