REPORT TOTAL REPORT PGM-NAME
RUN DATE - 01/13/17 Page 1
Field#1 Field#2 Field#3 Field#4 Field#5
6003 001 SUB-DIV1 Y 15
001 SUB-DIV1 N 1,058
002 SUB-DIV2 Y 2,526
002 SUB-DIV2 N 2,689
003 SUB-DIV3 Y 130
003 SUB-DIV3 N 1,283
004 SUB-DIV4 N 2,652
005 SUB-DIV5 N 1,920
006 SUB-DIV6 Y 269
006 SUB-DIV6 N 3,740
008 SUB-DIV8 N 3,061
TOTAL STORE 6003 INBOUND ITEMS 7,789
TOTAL STORE 6003 OUTBOUND ITEMS 1,190
TOTAL STORE 6003 ITEMS 8,979
...
other stores as well..
..
...
.
INVENTORY GRAND TOTAL = 38,415,086
INVENTORY INBOUND GRAND TOTAL = 12,853,600
INVENTORY OUTBOUND GRAND TOTAL = 25,561,486
Input records hold millions of records and in sorted order of the first field (store #). Fifth column (Field #5) in output report is the total count of either 'Y' or 'N' value belong to Field #1 and field 2 respectively.
I tried with DFSORT and got something like below.
Code:
6003 | 1 | 1 | N | 30,588
6003 | 1 | 1 | Y | 4,262
6003 | 2 | 2 | N | 48,284
6003 | 2 | 2 | Y | 62,343
6003 | 4 | 4 | N | 9,967
6003 | 4 | 4 | Y | 8
6003 | 6 | 6 | N | 7,590
6003 | 6 | 6 | Y | 285
6003 | 8 | 8 | N | 2,864
6003 | 8 | 8 | Y | 77
6003 | 9 | 9 | N | 18,538
6003 | 9 | 9 | Y | 410
6003 | 11 | 11 | N | 2,706
6003 | 11 | 11 | Y | 5
6003 | 12 | 12 | N | 947
6003 | 12 | 12 | Y | 334
6003 | 17 | 17 | N | 2,575
6003 | 17 | 17 | Y | 55
6003 | 21 | 21 | N | 1,964
6003 | 21 | 21 | Y | 9
6003 | 28 | 28 | N | 5,491
6003 | 28 | 28 | Y | 42
6004 | 1 | 1 | N | 30,696
By using the jcl code
Code:
SORT FIELDS=(3,7,CH,A,64,01,CH,A)
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(3,4,64,1,TRAILER3=(1:3,4,6:'|',8:8,2,11:'|',13:8,2,16:'|',
18:64,1,20:'|',
22:COUNT=(EDIT=(III,III,IIT),LENGTH=11))),
TRAILER1=(2/,6:'TOTAL COUNT OF THE FILE IS:', 2/,
COUNT=(EDIT=(II,III,III,IIT),LENGTH=14))
I did not use HEADER for testing. I am not allowed to use FINDREP or CHANGE to replace the third column value with hard coded description in TRAILER3. Also i have no clue how to keep value of store # for only first record set alone and provide sub total for each stores. I am getting the GRAND Total and the total count of 'Y' or 'N' belong to Field 1 and 2.
Kindly advice how to achieve the desire result. Thanks in advance for any help you can provide. _________________ B@L@
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
Posted: Mon Mar 13, 2017 4:20 pm Post subject:
Note: posted last week on another forum where the solution did not provde the required output. I have locked that topic.
I will unlock it when Balaryan has a working solution so that it can be posted there. _________________ Utility and Program control cards are NOT, repeat NOT, JCL.
Joined: 26 Nov 2002 Posts: 12360 Topics: 75 Location: San Jose
Posted: Mon Mar 13, 2017 7:09 pm Post subject:
balaryan,
Your input does not have a numeric field to be summarized, but your output shows that. How did you calculate that?
How is Inbound status calculated?
How is outbound status calculated?
You say your input is already sorted, then why do you need to sort it once again?
It is quite simple to achieve the desired results, if you provide the following details.
1. What is the LRECL and RECFM of the input file?
2. What is the position and length of the key field#1 (6003,6004... ) ?
3. What is the position and length of key Field#2 ? It seems you have leading zeros suppressed for this but on the report you want it as 3 byte field with leading zeros?
4. What is the position and length of key Field#3 ? It seems you want to have a leading string (Sub-DIV) appended to it and attach the field#2 value to it without the leading spaces?
5. What is the position and length of key Field#4? I guess it is a simple Y or N flag.
6. What is the position and length of key Field#5 ? It seems it is a numeric value with leading zeroes suppressed, Is that true?
If Field # 4 = 'Y' then count the FIELDS#5 as Inbound
If Field # 4 = 'N' then count the FIELDS#5 as OUTbound
Or is there some other flag to determine the Inbound vs outbound?
7. About the headers in the report.
a) Do you want the below line on every page of the report or just on the first page?
Code:
REPORT TOTAL REPORT PGM-NAME
RUN DATE - 01/13/17 Page 1
b.) Do you want the field headings on every key break or just once per page?
Code:
Field#1 Field#2 Field#3 Field#4 Field#5
Last but not least, Post a Sample of Input data with all the fields and the desired output. _________________ Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 10 Mar 2017 Posts: 13 Topics: 2 Location: Boston
Posted: Tue Mar 14, 2017 5:45 pm Post subject:
Hi Kolusu,
Apologies for not providing suffice information. I had provided the required information below.
Input records hold millions of records and in sorted order. There will be several thousand records belong to every store. For sample input file, I had listed few records
Input file: RECFM = FB; LRECL = 40
-----------
Code:
Description : start pos - length
Store #: 1 - 4
Region : 6 - 2
Flag : 9 - 1
Status :11 - 1
Description : start pos - length
Field #1: 03 - 04
Field #2: 16 - 03
Field #3: 28 - 20
Field #4: 52 - 01
Field #5: 62 - 06
REPORT TOTAL REPORT PGM-NAME
RUN DATE - 01/13/17 Page 1
Field#1 Field#2 Field#3 Field#4 Field#5
6003 001 SUB-DIV1 Y 15
001 SUB-DIV1 N 58
002 SUB-DIV2 Y 26
002 SUB-DIV2 N 9
003 SUB-DIV3 Y 30
003 SUB-DIV3 N 3
004 SUB-DIV4 0
005 SUB-DIV5 0
006 SUB-DIV6 Y 9
006 SUB-DIV6 N 4
008 SUB-DIV8 N 1
TOTAL STORE 6003 INBOUND ITEMS 81
TOTAL STORE 6003 OUTBOUND ITEMS 74
TOTAL STORE 6003 ITEMS 155
6004 001 SUB-DIV1 Y 15
001 SUB-DIV1 N 58
002 SUB-DIV2 Y 26
002 SUB-DIV2 N 9
003 SUB-DIV3 Y 30
003 SUB-DIV3 N 3
004 SUB-DIV4 Y 10
005 SUB-DIV5 0
006 SUB-DIV6 Y 9
006 SUB-DIV6 N 4
008 SUB-DIV8 N 1
TOTAL STORE 6004 INBOUND ITEMS 91
TOTAL STORE 6004 OUTBOUND ITEMS 74
TOTAL STORE 6004 ITEMS 165
REPORT TOTAL REPORT PGM-NAME
RUN DATE - 01/13/17 Page 2
Field#1 Field#2 Field#3 Field#4 Field#5
6005 001 SUB-DIV1 Y 25
001 SUB-DIV1 N 58
002 SUB-DIV2 Y 26
002 SUB-DIV2 N 19
003 SUB-DIV3 Y 30
003 SUB-DIV3 N 13
004 SUB-DIV4 Y 10
005 SUB-DIV5 N 10
006 SUB-DIV6 Y 19
006 SUB-DIV6 N 24
008 SUB-DIV8 N 11
TOTAL STORE 6004 INBOUND ITEMS 191
TOTAL STORE 6004 OUTBOUND ITEMS 174
TOTAL STORE 6004 ITEMS 365
INVENTORY GRAND TOTAL = 5,086
INVENTORY INBOUND GRAND TOTAL = 3,600
INVENTORY OUTBOUND GRAND TOTAL = 8,686
Note: Its just sample input and output records as there wont be accurate value in count.
I just calculated the count field (output field #5) matching the condition -
How is Inbound status calculated?
Total number of records having 'Y' (input field #3) for every store as Inbound status.
How is outbound status calculated?
Total number of records having 'N' (input field #3) for every store as Outbound status.
You say your input is already sorted, then why do you need to sort it once again?
Yes. It's sorted. I should have removed that condition.
1. What is the LRECL and RECFM of the input file?
Input file: RECFM = FB; LRECL = 40
Output file: RECFM = FB; LRECL = 80
2. What is the position and length of the key field#1 (6003,6004... ) ?
Its the first field in the input file. Starting position is 1. Length is 4.
Output file Field #1: starting pos - 03; Length - 04.
3. What is the position and length of key Field#2 ? It seems you have leading zeros suppressed for this but on the report you want it as 3 byte field with leading zeros?
Input field #2 - position is 6. Length is 2.
Output report Field #2 hold 3 bytes with leading zeros and starting position is 16 with length 03.
4. What is the position and length of key Field#3 ? It seems you want to have a leading string (Sub-DIV) appended to it and attach the field#2 value to it without the leading spaces?
Output field (Field#3) with starting position 28 and length as 20. It was derived based on the value of input field #2. If we could not spot any inbound or outbound records (Neither Y nor N flag records) for that particular field#02, then we will populate the output record with the predefined value of Field#03 corresponding to Field#02 and blank value in Fld#4 and count as '0' in Fld#5.
Fld#1 Fld#2 Fld#3 Fld#4 Fld#5
6004 001 SUB-DIV1 Y 2
001 SUB-DIV1 N 3
002 SUB-DIV2 0
003 SUB-DIV3 N 1
5. What is the position and length of key Field#4? I guess it is a simple Y or N flag.
Yes. It was from the input field#3 Flag with starting position 52 and length of 1.
6. What is the position and length of key Field#5 ? It seems it is a numeric value with leading zeroes suppressed, Is that true?
Yes. your absolutely right.
If Field # 4 = 'Y' then count the FIELDS#5 as Inbound
If Field # 4 = 'N' then count the FIELDS#5 as OUTbound
Starting position 62 and length of 6.
Or is there some other flag to determine the Inbound vs outbound? No
7. About the headers in the report.
a) Do you want the below line on every page of the report or just on the first page?
Code:
REPORT TOTAL REPORT PGM-NAME
RUN DATE - 01/13/17 Page 1
I need this header in every page of the report.
b.) Do you want the field headings on every key break or just once per page?
Code:
Field#1 Field#2 Field#3 Field#4 Field#5
I need this field heading in every page of the report after the header. _________________ B@L@
HEADER2=(/,'REPORT TOTAL REPORT',
' PGM-NAME : DFSORT',/,
'RUN DATE - ',DATE,60:'PAGE ',PAGE,/,/,
'FIELD#1 FIELD#2 FIELD#3',
' FIELD#4 FIELD#5',/),
BUILD=(003:01,4, $ STORE #
016:05,3, $ REGION
028:36,3,JFY=(SHIFT=LEFT,
LEAD=C'SUB-DIV',
LENGTH=20),
053:08,1,
062:09,6,
80:X),
SECTIONS=(23,4,
TRAILER3=(/,
17:'TOTAL STORE ',23,4,' INBOUND ITEMS = ',
TOT=(17,1,ZD,EDIT=(III,IIT)),/,
17:'TOTAL STORE ',23,4,' OUTBOUND ITEMS = ',
TOT=(18,1,ZD,EDIT=(III,IIT)),/,
17:'TOTAL STORE ',23,4,' ITEMS = ',
TOT=(21,1,ZD,EDIT=(III,IIT)),/)),
TRAILER1=(/,
02:'INVENTORY INBOUND GRAND TOTAL =',
TOT=(21,1,ZD,EDIT=(III,III,IIT)),/,
02:'INVENTORY OUTBOUND GRAND TOTAL =',
TOT=(19,1,ZD,EDIT=(III,III,IIT)),/,
02:'INVENTORY GRAND TOTAL =',
TOT=(20,1,ZD,EDIT=(III,III,IIT)))
Joined: 26 Nov 2002 Posts: 12360 Topics: 75 Location: San Jose
Posted: Wed Mar 15, 2017 7:59 am Post subject:
Nic Clouston wrote:
Note: posted last week on another forum where the solution did not provde the required output. I have locked that topic.
I will unlock it when Balaryan has a working solution so that it can be posted there.
If Op is the same person seeking help , then why does he need to post the solution on the other board which basically makes money selling the solutions? I for one am against it.
Balaryan,
I would really appreciate if you do NOT post ,my solutions else where. _________________ Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 10 Mar 2017 Posts: 13 Topics: 2 Location: Boston
Posted: Wed Mar 15, 2017 8:26 am Post subject:
Hi Kolusu,
I always respect the help and information you provided here. I would like to inform that this is purely for my understanding of DFSORT and ICETOOL and won't be misusing the information you provided anywhere else. Primarily, I created COBOL Program to generate this report. But just wanted to know if this can be achieved by the SORT as you too mentioned it was too much content in one report using DFSORT.
Thanks for this code. HIT=NEXT and MERGE are new things I learned today. I will test this code and update you. _________________ B@L@
Joined: 26 Nov 2002 Posts: 12360 Topics: 75 Location: San Jose
Posted: Wed Mar 15, 2017 11:24 am Post subject:
balaryan wrote:
Primarily, I created COBOL Program to generate this report. But just wanted to know if this can be achieved by the SORT as you too mentioned it was too much content in one report using DFSORT.
Thanks for this code. HIT=NEXT and MERGE are new things I learned today. I will test this code and update you.
balaryan,
Even though there are too many counts/totals to be done, DFSORT is using a COPY operation in both steps which does not need any resources apart from the tiny storage for edit control blocks.
Since you already had a COBOL program , I would love to see the run times of it and compare it against DFSORT run times (total from the 2 steps) _________________ Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
Posted: Wed Mar 15, 2017 12:44 pm Post subject:
OK, Kolusu. I understand your viewpoint and will not unlock it. I don't get the adverts because I use an ad blocker but I understand that that may not be an option for you. _________________ Utility and Program control cards are NOT, repeat NOT, JCL.
Joined: 26 Nov 2002 Posts: 12360 Topics: 75 Location: San Jose
Posted: Thu Mar 16, 2017 12:59 pm Post subject:
balaryan,
Finally I got around testing my code. Turns out that I did have a few bugs
1. The Store # is NOT spaced out if the store had a missing Y or Missing N record.
2. It would add an additional default record for the store+region when all the store+region had just either Y or N records.
3. If the store+region did not begin with a 001 region record, it would be tagged to the earlier store.
IFTHEN=(WHEN=INIT,
BUILD=(03:01,4, $ STORE #
16:05,3, $ REGION
28:81,3,JFY=(SHIFT=LEFT,
LEAD=C'SUB-DIV',
LENGTH=20),
53:08,1,
62:09,6,
90:SEQNUM,6,ZD,RESTART=(1,4))),
IFTHEN=(WHEN=(90,6,ZD,GT,1),
OVERLAY=(03:4X)),
HEADER2=(/,'REPORT TOTAL REPORT',
' PGM-NAME : DFSORT',/,
'RUN DATE - ',DATE,60:'PAGE ',PAGE,/,/,
'FIELD#1 FIELD#2 FIELD#3',
' FIELD#4 FIELD#5',/),
SECTIONS=(85,4,
TRAILER3=(/,
17:'TOTAL STORE ',85,4,' INBOUND ITEMS = ',
TOT=(47,1,UFF,EDIT=(III,IIT)),/,
17:'TOTAL STORE ',85,4,' OUTBOUND ITEMS = ',
TOT=(48,1,UFF,EDIT=(III,IIT)),/,
17:'TOTAL STORE ',85,4,' ITEMS = ',
TOT=(51,1,UFF,EDIT=(III,IIT)),/)),
TRAILER1=(/,
02:'INVENTORY INBOUND GRAND TOTAL =',
TOT=(51,1,ZD,EDIT=(III,III,IIT)),/,
02:'INVENTORY OUTBOUND GRAND TOTAL =',
TOT=(49,1,ZD,EDIT=(III,III,IIT)),/,
02:'INVENTORY GRAND TOTAL =',
TOT=(50,1,ZD,EDIT=(III,III,IIT)))
//*
_________________ Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 10 Mar 2017 Posts: 13 Topics: 2 Location: Boston
Posted: Thu Mar 16, 2017 2:48 pm Post subject:
Hi Kolusu,
Existing program takes 180 secs approx to generate the report from the 40 millions record of an input file. I tried your solution and each record getting repeated several times (dups) say 32000 times approx it was repeated before showing 002 (field #2). It displayed only for the first store only and the grand totals. It did not display the subtotal as well.
Code:
TRAILER1=(/,
02:'INVENTORY INBOUND GRAND TOTAL =',
TOT=(51,1,ZD,EDIT=(III,III,IIT)),/,
02:'INVENTORY OUTBOUND GRAND TOTAL =',
TOT=(49,1,ZD,EDIT=(III,III,IIT)),/,
02:'INVENTORY GRAND TOTAL =',
TOT=(50,1,ZD,EDIT=(III,III,IIT)))
Can you please let me know how it's calculating the total for INBOUND, OUTBOUND and BOTH. What is that position "51,1", "50,1", "49,1" indicates and does it refers field position in any file?
Also, I am just referring the initial code to count for every store based on the flag field.
This will provide the records with store, dept, flag, total count (based on key+store+Flag combo)
In the second step, I can replace the third field (dept code with description) using OUTREC with CHANGE and I can also calculate the subtotals and totals.
Code:
6003 001 FISHES N 30,617
6003 001 FISHES Y 4,266
6003 002 GENERAL STUFF N 48,312
6003 002 GENERAL STUFF Y 62,229
6003 004 PRODUCE N 10,005
6003 004 PRODUCE Y 8
6003 006 FROZEN N 7,609
6003 006 FROZEN Y 285
6003 008 DAIRY N 2,892
6003 008 DAIRY Y 78
6003 009 NO MATCH N 18,536
6003 009 NO MATCH Y 410
6003 012 COMMERCIAL N 3,656
6003 012 COMMERCIAL Y 334
6003 017 CHEESE N 2,575
6003 017 CHEESE Y 55
6003 021 SEA FOOD N 1,964
6003 021 SEA FOOD Y 9
6003 028 NATURAL FOODS N 5,519
6003 028 NATURAL FOODS Y 42
TOTAL STORE 6003 INBOUND ITEMS = 0
TOTAL STORE 6003 OUTBOUND ITEMS = 0
TOTAL STORE 6003 ITEMS = 0
Also if there any possibility to calculate the total based on the condition in TRAILER3 and TRAILER1 respectively?
For eg. For every stores and flag,
Code:
SECTIONS(3,4,
(48,1,CH,EQ,C'Y', TOT=(48,1,ZD,EDIT=(III,IIT))), /* Inbound
(48,1,CH,EQ,C'N', TOT=(48,1,ZD,EDIT=(III,IIT))), /* outboud
(48,1,CH,NE,C' ', TOT=(48,1,ZD,EDIT=(III,IIT))), /* BOTH 'Y' and 'N'
In order to display the store value ONLY for every first record of store and supress for other records, could it be achieved using the INREC IFTHEN =(WHEN=GROUP) and PUSH in STEP001.
Joined: 26 Nov 2002 Posts: 12360 Topics: 75 Location: San Jose
Posted: Thu Mar 16, 2017 3:25 pm Post subject:
balaryan wrote:
Hi Kolusu,
Existing program takes 180 secs approx to generate the report from the 40 millions record of an input file. I tried your solution and each record getting repeated several times (dups) say 32000 times approx it was repeated before showing 002 (field #2).
balaryan,
First of all you did NOT run the control cards as is by me, as you added your own formatting with pipe delimited stuff and you cannot to expect it to work the same as it is designed.
Rule of thumb, keep the length to bare minimum and write out only the impotant fields you require. The formatting and beautification of the report can be done in the last phase. There is NO point in generating the pipe delimiters in step0100 itself.
It seems you have more regions then you showed earlier. In the initial mail you mentioned that you only have 12 regions and we need to generate a default record if it doesn't exist. However your latest sample shows region of 017, 021, 028 and so on.
So please keep in mind to list all the requirements as we cannot read your mind nor look over your shoulder and understand your requirement.
I suggest you run the job with SAMPLE INPUT you have shown which is just 9 bytes of data, once you have a better understanding of the job then you can go back adding your unplanned changes like adding the "(dept code with description) using OUTREC with CHANGE and I can also calculate the subtotals and totals. "
balaryan wrote:
Can you please let me know how it's calculating the total for INBOUND, OUTBOUND and BOTH. What is that position "51,1", "50,1", "49,1" indicates and does it refers field position in any file?
I only take 9 bytes (store+region+flag) from your original input file, rest all fields are my temporary fields that I need for generating the report. step0100 generates 15 bytes file which has 9 bytes + 6 byte total + merge indicator = 15 bytes.
Look at the IFTHEN statement and the Position 47. For the detail records with "Y" flag then it will put a value of "1" at position 47
so
Code:
pos - counter
--- -------
47 - Y flag count for store+region
48 - N flag count for store+region
49 - Y flag count for store
50 - N flag count for store
Also if there any possibility to calculate the total based on the condition in TRAILER3 and TRAILER1 respectively?
In order to display the store value ONLY for every first record of store and supress for other records, could it be achieved using the INREC IFTHEN =(WHEN=GROUP) and PUSH in STEP001.
Not sure as to why you need it but it is already handled. So please do NOT add your own logic and think it would work.
If you are looking for something that you can just copy and paste then you need to provide the complete details, rather than bits and pieces as most of my solutions are designed to be optimal and use less resources. _________________ Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 26 Nov 2002 Posts: 12360 Topics: 75 Location: San Jose
Posted: Fri Mar 17, 2017 11:12 am Post subject:
balaryan,
A good wise friend of mine pointed out that I was writing out all the detail records with summary totals. However the original requirement is to just write the SUMMARIZED records. My bad My sincere apologies.
This makes it much more easier and we no longer need the DTLRECD file at all.
So if you want to add description to the job, you need to do it on the OUTFIL IFTHEN statements and NOT on OUTREC IFTHEN
Here is the input I used. ( no space records in between , I just added them to distinguish the various keys)
IFTHEN=(WHEN=INIT,
BUILD=(03:01,4, $ STORE #
16:05,3, $ REGION
28:81,3,JFY=(SHIFT=LEFT,
LEAD=C'SUB-DIV',
LENGTH=20),
53:08,1,
62:09,6,
90:SEQNUM,6,ZD,RESTART=(1,4))),
IFTHEN=(WHEN=(90,6,ZD,GT,1),
OVERLAY=(03:4X)),
HEADER2=(/,'REPORT TOTAL REPORT',
' PGM-NAME : DFSORT',/,
'RUN DATE - ',DATE,60:'PAGE ',PAGE,/,/,
'FIELD#1 FIELD#2 FIELD#3',
' FIELD#4 FIELD#5',/),
SECTIONS=(85,4,
TRAILER3=(/,
17:'TOTAL STORE ',85,4,' INBOUND ITEMS = ',
TOT=(35,6,UFF,EDIT=(III,III,IIT)),/,
17:'TOTAL STORE ',85,4,' OUTBOUND ITEMS = ',
TOT=(42,6,UFF,EDIT=(III,III,IIT)),/,
17:'TOTAL STORE ',85,4,' ITEMS = ',
TOT=(49,6,UFF,EDIT=(III,III,IIT)),/)),
TRAILER1=(/,
02:'INVENTORY INBOUND GRAND TOTAL =',
TOT=(35,6,UFF,EDIT=(III,III,IIT)),/,
02:'INVENTORY OUTBOUND GRAND TOTAL =',
TOT=(42,6,UFF,EDIT=(III,III,IIT)),/,
02:'INVENTORY GRAND TOTAL =',
TOT=(49,6,UFF,EDIT=(III,III,IIT)))
//*
This will produce a report like this
Code:
REPORT TOTAL REPORT PGM-NAME : DFSORT
RUN DATE - 03/17/17 PAGE 1
FIELD#1 FIELD#2 FIELD#3 FIELD#4 FIELD#5
6003 001 SUB-DIV1 Y 1
001 SUB-DIV1 N 3
002 SUB-DIV2 Y 1
002 SUB-DIV2 N 2
003 SUB-DIV3 Y 1
003 SUB-DIV3 N 2
004 SUB-DIV4 Y 1
004 SUB-DIV4 N 1
005 SUB-DIV5 Y 1
005 SUB-DIV5 N 1
006 SUB-DIV6 Y 2
006 SUB-DIV6 N 1
007 SUB-DIV7 0
008 SUB-DIV8 Y 1
008 SUB-DIV8 N 1
009 SUB-DIV9 Y 2
009 SUB-DIV9 N 1
010 SUB-DIV10 Y 1
010 SUB-DIV10 N 1
011 SUB-DIV11 Y 2
011 SUB-DIV11 N 1
012 SUB-DIV12 0
TOTAL STORE 6003 INBOUND ITEMS = 13
TOTAL STORE 6003 OUTBOUND ITEMS = 14
TOTAL STORE 6003 ITEMS = 27
6004 001 SUB-DIV1 Y 1
001 SUB-DIV1 N 3
002 SUB-DIV2 Y 2
002 SUB-DIV2 N 2
003 SUB-DIV3 Y 1
003 SUB-DIV3 N 2
004 SUB-DIV4 Y 1
004 SUB-DIV4 N 1
005 SUB-DIV5 Y 1
005 SUB-DIV5 N 1
006 SUB-DIV6 Y 2
006 SUB-DIV6 N 1
007 SUB-DIV7 0
008 SUB-DIV8 Y 1
008 SUB-DIV8 N 1
009 SUB-DIV9 Y 2
009 SUB-DIV9 N 1
010 SUB-DIV10 Y 1
010 SUB-DIV10 N 1
011 SUB-DIV11 Y 2
011 SUB-DIV11 N 1
012 SUB-DIV12 0
TOTAL STORE 6004 INBOUND ITEMS = 14
TOTAL STORE 6004 OUTBOUND ITEMS = 14
TOTAL STORE 6004 ITEMS = 28
REPORT TOTAL REPORT PGM-NAME : DFSORT
RUN DATE - 03/17/17 PAGE 2
Joined: 10 Mar 2017 Posts: 13 Topics: 2 Location: Boston
Posted: Fri Mar 17, 2017 1:59 pm Post subject:
Hi Kolusu,
Your latest solution works very well as expected. Thanks a lot for your time and magnanimity in sharing your knowledge with me. Also, I am trying to understand the solution you provided.
Code:
MERGE FIELDS=(01,7,CH,A,
15,1,CH,A),EQUALS
This will combine the three datasets with same order sequence.
This reformatting applies to all of the merged records where masking the dept code field with three bytes at the 81st position and store # in 85th position. What is the use of 35th position having zeros?
Reformatting the count field to position 09 for both flag 'Y' and 'N'. You placed the count field again at 49th position to calculate the total of both INBOUND and OUTBOUND for every store.
IFTHEN=(WHEN=INIT,
BUILD=(03:01,4, $ STORE #
16:05,3, $ REGION
28:81,3,JFY=(SHIFT=LEFT,
LEAD=C'SUB-DIV',
LENGTH=20),
53:08,1,
62:09,6,
90:SEQNUM,6,ZD,RESTART=(1,4))),
IFTHEN=(WHEN=(90,6,ZD,GT,1),
OVERLAY=(03:4X)),
Building the final report with the sequence number at position 90. Then except for 1st record of each store, rest will be filled with spaces.
Kindly correct me if my understanding is wrong anywhere.
It seems you have more regions then you showed earlier. In the initial mail, you mentioned that you only have 12 regions and we need to generate a default record if it doesn't exist. However your latest sample shows the region of 017, 021, 028 and so on.
Yes kolusu. My input file has some more regions. But for sample input, I restricted up to 012. If I have more region, I should change the step0100 for the file PADRECD by including appropriate changes in TRAILER3.
Also for dept code description, i gave the description 'SUB-DIV[1,2,...]' as a sample. I made necessary changes to it by CHANGE the dept code with the corresponding description and now it works completely fine. Kudos. _________________ B@L@
Joined: 26 Nov 2002 Posts: 12360 Topics: 75 Location: San Jose
Posted: Fri Mar 17, 2017 2:23 pm Post subject:
balaryan wrote:
This reformatting applies only to the merged records whose 15th position is 1 and 2 respectively (for Flag 'Y' and 'N').
Balaryan,
The two WHEN=GROUP statements are used to removed the padded records if they already existed. Look at the OUTFIL OMIT statement and see how we eilminate them.
balaryan wrote:
This reformatting applies to all of the merged records where masking the dept code field with three bytes at the 81st position and store # in 85th position. What is the use of 35th position having zeros?
The WHEN=INIT statement initializes the 3 counts(Y/N/total) counts to zeros with this statement.
35:3C'000000 ',
I Initialized the counter for 'y' and 'n' and for the total of both Y and N
These values will be used in Trailer3 and trailer1 respectively to get the counts for inbound and outbound and grand total
balaryan wrote:
now it works completely fine.
Now I would like to check the CPU times for COBOL solution and SORT solution _________________ Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum