MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DFSORT report with total and subtotal
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
balaryan
Beginner


Joined: 10 Mar 2017
Posts: 13
Topics: 2
Location: Boston

PostPosted: Mon Mar 13, 2017 2:05 pm    Post subject: DFSORT report with total and subtotal Reply with quote

Hi All,

I am trying to generate the desired report using the below-listed input.

Code:
|6003| 1|N|A|
|6003| 1|N|A|
|6003| 1|Y|A|
|6003| 1|N|A|
|6003| 2|Y|A|
|6003| 2|N|A|
|6003| 2|Y|A|
|6003| 2|N|A|
|6003| 3|N|A|
|6003| 3|Y|A|
|6003| 3|N|A|
|6003| 4|Y|A|
|6003| 4|N|A|
|6003| 5|Y|A|
|6003| 5|N|A|
|6003| 6|Y|A|
|6003| 6|N|A|
|6003| 6|Y|A|
|6003| 8|Y|A|


Desired output report looks like

Code:

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@
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Mon Mar 13, 2017 4:20 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12358
Topics: 75
Location: San Jose

PostPosted: Mon Mar 13, 2017 7:09 pm    Post subject: Reply with quote

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

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
balaryan
Beginner


Joined: 10 Mar 2017
Posts: 13
Topics: 2
Location: Boston

PostPosted: Tue Mar 14, 2017 5:45 pm    Post subject: Reply with quote

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


6003| 1|N|A|
6003| 1|N|A|
6003| 1|Y|A|
6003| 1|N|A|
6003| 2|Y|A|
6003| 2|N|A|
6003| 2|Y|A|
6003| 2|N|A|
6003| 3|N|A|
6003| 3|Y|A|
6003| 3|N|A|
6003| 4|Y|A|
6003| 4|N|A|
6003| 5|Y|A|
6003| 5|N|A|
6003| 6|Y|A|
6003| 6|N|A|
6003| 6|Y|A|
6003| 8|Y|A|
6003| 8|N|A|
6003| 9|N|A|
6003| 9|Y|A|
6003| 9|Y|A|
6003|10|Y|A|
6003|10|N|A|
6003|11|Y|A|
6003|11|Y|A|
6003|11|N|A|
6004| 1|N|A|
6004| 1|N|A|
6004| 1|Y|A|
6004| 1|N|A|
6004| 2|Y|A|
6004| 2|N|A|
6004| 2|Y|A|
6004| 2|N|A|
6004| 3|N|A|
6004| 3|Y|A|
6004| 3|N|A|
6004| 4|Y|A|
6004| 4|N|A|
6004| 5|Y|A|
6004| 5|N|A|
6004| 6|Y|A|
6004| 6|N|A|
6004| 6|Y|A|
6004| 8|Y|A|
6004| 8|N|A|
6004| 9|N|A|
6004| 9|Y|A|
6004| 9|Y|A|
6004|10|Y|A|
6004|10|N|A|
6004|11|Y|A|
6004|11|Y|A|
6004|11|N|A|



Output file: RECFM = FB; LRECL = 80
------------
Code:

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.

Mapping values for Field#2 and #3.
Field#2 Field#3
1 SUB-DIV1
2 SUB-DIV2
3 SUB-DIV3
4 SUB-DIV4
5 SUB-DIV5
6 SUB-DIV6
7 SUB-DIV7
8 SUB-DIV8
9 SUB-DIV9
10 SUB-DIV10
11 SUB-DIV11
12 SUB-DIV12

Code:

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@
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12358
Topics: 75
Location: San Jose

PostPosted: Wed Mar 15, 2017 7:52 am    Post subject: Reply with quote

balaryan wrote:
Input records hold millions of records and in sorted order. There will be several thousand records belong to every store.


Well you wanted one too many things in a single report. Smile

1. You wanted 3 different totals
a.) key+store+Flag combo
b.) key
c.) Final totals for keys

2. You also wanted populate default values if particular key+store cannot be found.

In keeping in lieu of the requirements, here is the sample untested job that would give you the desired results.

As the data is already sorted, we will use the Merge technique.

Here is a brief explanation of the job

Step0100 : will create 4 different files

File1: YFLGTOT - will create a file with totals based Key+Store for records with 'Y' flag and will have merge key = '1'

File2: NFLGTOT - will create a file with totals based Key+Store for records with 'N' flag and will have merge key = '2'

File3 : DTLRECD - copies the records as is and will have merge key = '3'

File4 : PADRECD - Creates default records for all the possible 12 stores and will have merge key = '4

Step0200 : Now will merge these 4 files into a single file and generate the report we want.

Code:

//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD DISP=SHR,DSN=&&IN                                 
//YFLGTOT  DD DSN=&&YFLGTOT,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE) 
//NFLGTOT  DD DSN=&&NFLGTOT,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE) 
//DTLRECD  DD DSN=&&DTLRECD,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//PADRECD  DD DSN=&&PADRECD,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE) 
//SYSIN    DD *                                         
  OPTION COPY                                                 
  INREC BUILD=(1,4,                      $ STORE #             
               6,2,UFF,EDIT=(TTT),       $ REGION             
               9,1)                      $ FLAG               
                                                               
  OUTFIL FNAMES=YFLGTOT,                                       
  INCLUDE=(8,1,CH,EQ,C'Y'),                                   
  BUILD=(15X),                                                 
  REMOVECC,NODETAIL,                                           
  SECTIONS=(1,7,                                               
  TRAILER3=(1,8,                                               
           COUNT=(M10,LENGTH=6),                               
           15:C'1'))                                           
                                                               
  OUTFIL FNAMES=NFLGTOT,                                       
  INCLUDE=(8,1,CH,EQ,C'N'),                                   
  BUILD=(15X),                                                 
  REMOVECC,NODETAIL,                                           
  SECTIONS=(1,7,                                               
  TRAILER3=(1,8,                                               
           COUNT=(M10,LENGTH=6),                               
           15:C'2'))                                           
                                                               
  OUTFIL FNAMES=DTLRECD,             
  BUILD=(1,8,15:C'3')

  OUTFIL FNAMES=PADRECD,                                       
  REMOVECC,NODETAIL,BUILD=(15X),                               
  SECTIONS=(1,4,                                               
  TRAILER3=(1,4,C'001',X,C'     0',C'4',/,                     
            1,4,C'002',X,C'     0',C'4',/,                     
            1,4,C'003',X,C'     0',C'4',/,                     
            1,4,C'004',X,C'     0',C'4',/,                     
            1,4,C'005',X,C'     0',C'4',/,                     
            1,4,C'006',X,C'     0',C'4',/,                     
            1,4,C'007',X,C'     0',C'4',/,                     
            1,4,C'008',X,C'     0',C'4',/,                     
            1,4,C'009',X,C'     0',C'4',/,                     
            1,4,C'010',X,C'     0',C'4',/,                     
            1,4,C'011',X,C'     0',C'4',/,                     
            1,4,C'012',X,C'     0',C'4'))                     

//*
//STEP0200 EXEC PGM=SORT                         
//SYSOUT   DD SYSOUT=*                           
//SORTIN01 DD DSN=&&YFLGTOT,DISP=SHR             
//SORTIN02 DD DSN=&&NFLGTOT,DISP=SHR             
//SORTIN03 DD DSN=&&DTLRECD,DISP=SHR             
//SORTIN04 DD DSN=&&PADRECD,DISP=SHR             
//SORTOUT  DD SYSOUT=*                           
//SYSIN    DD * 
  MERGE FIELDS=(01,7,CH,A,                                       
                15,1,CH,A),EQUALS                               
                                                                 
  OUTREC IFTHEN=(WHEN=INIT,                                     
        OVERLAY=(17:5C'0',                                       
                 23:01,04,                                       
                 28:SEQNUM,6,ZD,RESTART=(1,4),                   
                 36:05,3,UFF,EDIT=(IIT))),                       
                                                                 
  IFTHEN=(WHEN=GROUP,BEGIN=(15,1,ZD,EQ,1),                       
           PUSH=(39:09,06,                                       
                 46:05,03)),                                     
                                                                 
  IFTHEN=(WHEN=GROUP,BEGIN=(15,1,ZD,EQ,2),                       
           PUSH=(50:09,06)),                                     
                                                                 
  IFTHEN=(WHEN=(08,01,CH,EQ,C'Y',AND,                           
                15,01,ZD,EQ,3),                                 
       OVERLAY=(09:39,06,                                       
                17:C'10101'),HIT=NEXT),                         
                                                                 
  IFTHEN=(WHEN=(08,01,CH,EQ,C'N',AND,                           
                15,01,ZD,EQ,3),                                 
       OVERLAY=(09:50,06,                                       
                17:C'01011'),HIT=NEXT),                         
                                                                 
  IFTHEN=(WHEN=(28,6,ZD,GT,3),                                   
       OVERLAY=(01:4X))                     
                     
  OUTFIL REMOVECC,                                             
  OMIT=(15,1,ZD,LE,2,OR,                                       
       (15,1,ZD,EQ,4,AND,(05,3,CH,EQ,46,3,CH))), 
             
  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)))               
                                                               
//*
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12358
Topics: 75
Location: San Jose

PostPosted: Wed Mar 15, 2017 7:59 am    Post subject: Reply with quote

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

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
balaryan
Beginner


Joined: 10 Mar 2017
Posts: 13
Topics: 2
Location: Boston

PostPosted: Wed Mar 15, 2017 8:26 am    Post subject: Reply with quote

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@
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12358
Topics: 75
Location: San Jose

PostPosted: Wed Mar 15, 2017 11:24 am    Post subject: Reply with quote

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

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Wed Mar 15, 2017 12:44 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12358
Topics: 75
Location: San Jose

PostPosted: Thu Mar 16, 2017 12:59 pm    Post subject: Reply with quote

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.

ex: for the above scenarios test data

No 'y' flag records just all records have 'n'

Code:

6005| 1|N|A|
6005| 1|N|A|
6005| 1|N|A|
6005| 1|N|A|


region does not start with 001
Code:

6006| 8|Y|A|
6006| 8|Y|A|


So I had to re-arrange the data a bit and I think I finally covered all the scenarios. Here is the updated job. Only STEP0200 needs to be changed.
Code:

//STEP0200 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTIN01 DD DSN=&&YFLGTOT,DISP=SHR                           
//SORTIN02 DD DSN=&&NFLGTOT,DISP=SHR                           
//SORTIN03 DD DSN=&&DTLRECD,DISP=SHR                           
//SORTIN04 DD DSN=&&PADRECD,DISP=SHR                           
//SORTOUT  DD SYSOUT=*                                         
//SYSIN    DD *                                               
  MERGE FIELDS=(01,7,CH,A,                                     
                15,1,CH,A),EQUALS                             
                                                               
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(15,1,ZD,EQ,1),             
                 PUSH=(17:09,06,                               
                       31:01,07)),                             
                                                               
         IFTHEN=(WHEN=GROUP,BEGIN=(15,1,ZD,EQ,2),             
                 PUSH=(24:09,06,                               
                       39:01,07)),                             
                                                               
         IFTHEN=(WHEN=INIT,                                   
              OVERLAY=(81:05,3,UFF,EDIT=(IIT),                 
                       85:01,4)),                             
                                                               
         IFTHEN=(WHEN=(08,01,CH,EQ,C'Y',AND,15,1,ZD,EQ,3),     
              OVERLAY=(09:17,06,                               
                       47:C'10101')),                         
                                                               
         IFTHEN=(WHEN=(08,01,CH,EQ,C'N',AND,15,1,ZD,EQ,3),     
              OVERLAY=(09:24,06,                               
                       47:C'01011'))                           
                                               
  OUTFIL REMOVECC,IFOUTLEN=80,                             
  OMIT=(15,1,ZD,LE,2,OR,                                   
       (15,1,ZD,EQ,4,AND,(01,7,CH,EQ,31,7,CH)),OR,         
       (15,1,ZD,EQ,4,AND,(01,7,CH,EQ,39,7,CH))),           
                                                           
  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

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
balaryan
Beginner


Joined: 10 Mar 2017
Posts: 13
Topics: 2
Location: Boston

PostPosted: Thu Mar 16, 2017 2:48 pm    Post subject: Reply with quote

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.

Code:
//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD DISP=SHR,DSN=&&IN                                 
//SORTOUT  DD DSN=&&YFLGTOT,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE) 
//SYSIN    DD *                                         
  OPTION COPY                                                 
  OUTFIL REMOVECC,NODETAIL,                                           
  SECTIONS=(1,4,9,1,TRAILER3=(1:1,4,6:'|',8:6,2,11:'|',13:6,2,
                     46:'|',48:9,1,50:'|',                 
                 X,COUNT=(EDIT=(III,III,IIT),LENGTH=11)))
 


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.

Kindly advice.
_________________
B@L@
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12358
Topics: 75
Location: San Jose

PostPosted: Thu Mar 16, 2017 3:25 pm    Post subject: Reply with quote

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

51      - Count for all stores




Code:

                                                                     
       IFTHEN=(WHEN=(08,01,CH,EQ,C'Y',AND,15,1,ZD,EQ,3),             
            OVERLAY=(09:17,06,                                       
                     47:C'10101')),                                   
                                                                     
       IFTHEN=(WHEN=(08,01,CH,EQ,C'N',AND,15,1,ZD,EQ,3),             
            OVERLAY=(09:24,06,                                       
                     47:C'01011'))                                   
                                                                     
                                                                     


balryan wrote:

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

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12358
Topics: 75
Location: San Jose

PostPosted: Fri Mar 17, 2017 11:12 am    Post subject: Reply with quote

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. bonk 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)
Code:

6003| 1|N|A|
6003| 1|N|A|
6003| 1|Y|A|
6003| 1|N|A|
6003| 2|Y|A|
6003| 2|N|A|
6003| 2|N|A|
6003| 3|N|A|
6003| 3|Y|A|
6003| 3|N|A|
6003| 4|Y|A|
6003| 4|N|A|
6003| 5|Y|A|
6003| 5|N|A|
6003| 6|Y|A|
6003| 6|N|A|
6003| 6|Y|A|
6003| 8|Y|A|
6003| 8|N|A|
6003| 9|N|A|
6003| 9|Y|A|
6003| 9|Y|A|
6003|10|Y|A|
6003|10|N|A|
6003|11|Y|A|
6003|11|Y|A|
6003|11|N|A|

6004| 1|N|A|   
6004| 1|N|A|   
6004| 1|Y|A|   
6004| 1|N|A|   
6004| 2|Y|A|   
6004| 2|N|A|   
6004| 2|Y|A|   
6004| 2|N|A|   
6004| 3|N|A|   
6004| 3|Y|A|   
6004| 3|N|A|   
6004| 4|Y|A|   
6004| 4|N|A|   
6004| 5|Y|A|   
6004| 5|N|A|   
6004| 6|Y|A|   
6004| 6|N|A|   
6004| 6|Y|A|   
6004| 8|Y|A|   
6004| 8|N|A|   
6004| 9|N|A|   
6004| 9|Y|A|   
6004| 9|Y|A|   
6004|10|Y|A|   
6004|10|N|A|   
6004|11|Y|A|   
6004|11|Y|A|   
6004|11|N|A|   

6005| 1|N|A|   
6005| 1|N|A|   
6005| 1|N|A|   
6005| 1|N|A|   

6006| 8|Y|A|   
6006| 8|Y|A|   


For the above and using this 2 step job

Code:

//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD DISP=SHR,DSN=&&IN                                   
//YFLGTOT  DD DSN=&&YFLGTOT,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)   
//NFLGTOT  DD DSN=&&NFLGTOT,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)   
//PADRECD  DD DSN=&&PADRECD,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)   
//SYSIN    DD *                                                   
  OPTION COPY                                                     
  INREC BUILD=(1,4,                      $ STORE #                 
               6,2,UFF,EDIT=(TTT),       $ REGION                 
               9,1)                      $ FLAG                   
                                                                   
  OUTFIL FNAMES=YFLGTOT,                                           
  INCLUDE=(8,1,CH,EQ,C'Y'),                                       
  BUILD=(15X),                                                     
  REMOVECC,NODETAIL,                                               
  SECTIONS=(1,7,                                                   
  TRAILER3=(1,8,                                                   
           COUNT=(M10,LENGTH=6),                                   
           15:C'1'))                                               
                                                                   
  OUTFIL FNAMES=NFLGTOT,                                           
  INCLUDE=(8,1,CH,EQ,C'N'),                                       
  BUILD=(15X),                                                     
  REMOVECC,NODETAIL,                                               
  SECTIONS=(1,8,                                                   
  TRAILER3=(1,8,                                                   
           COUNT=(M10,LENGTH=6),                                   
           15:C'2'))                                               
                                                                   
  OUTFIL FNAMES=PADRECD,                         
  REMOVECC,NODETAIL,BUILD=(15X),                 
  SECTIONS=(1,4,                                 
  TRAILER3=(1,4,C'001',X,C'     0',C'3',/,       
            1,4,C'002',X,C'     0',C'3',/,       
            1,4,C'003',X,C'     0',C'3',/,       
            1,4,C'004',X,C'     0',C'3',/,       
            1,4,C'005',X,C'     0',C'3',/,       
            1,4,C'006',X,C'     0',C'3',/,       
            1,4,C'007',X,C'     0',C'3',/,       
            1,4,C'008',X,C'     0',C'3',/,       
            1,4,C'009',X,C'     0',C'3',/,       
            1,4,C'010',X,C'     0',C'3',/,       
            1,4,C'011',X,C'     0',C'3',/,       
            1,4,C'012',X,C'     0',C'3'))       
                                                 
//*                                             
//STEP0200 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN01 DD DSN=&&YFLGTOT,DISP=SHR                       
//SORTIN02 DD DSN=&&NFLGTOT,DISP=SHR                       
//SORTIN04 DD DSN=&&PADRECD,DISP=SHR                       
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                             
  MERGE FIELDS=(01,7,CH,A,                                 
                15,1,CH,A),EQUALS                           
                                                           
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(15,1,ZD,EQ,1),           
                 PUSH=(17:01,07)),                         
                                                           
         IFTHEN=(WHEN=GROUP,BEGIN=(15,1,ZD,EQ,2),           
                 PUSH=(26:01,07)),                         
                                                           
         IFTHEN=(WHEN=INIT,                                 
              OVERLAY=(35:3C'000000 ',                     
                       81:05,3,UFF,EDIT=(IIT),             
                       85:01,4)),                           
                                                           
         IFTHEN=(WHEN=(08,01,CH,EQ,C'Y'),                   
              OVERLAY=(35:9,6,                             
                       49:9,6)),                           
                                                           
         IFTHEN=(WHEN=(08,01,CH,EQ,C'N'),                   
              OVERLAY=(42:9,6,                             
                       49:9,6))                             
                                                           
  OUTFIL REMOVECC,IFOUTLEN=80,                                 
  OMIT=((15,1,ZD,EQ,3,AND,(01,7,CH,EQ,17,7,CH)),OR,           
        (15,1,ZD,EQ,3,AND,(01,7,CH,EQ,26,7,CH))),             
                                                               
  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

 FIELD#1     FIELD#2        FIELD#3                FIELD#4      FIELD#5

   6005         001         SUB-DIV1                 N             4
                002         SUB-DIV2                               0
                003         SUB-DIV3                               0
                004         SUB-DIV4                               0
                005         SUB-DIV5                               0
                006         SUB-DIV6                               0
                007         SUB-DIV7                               0
                008         SUB-DIV8                               0
                009         SUB-DIV9                               0
                010         SUB-DIV10                              0
                011         SUB-DIV11                              0
                012         SUB-DIV12                              0

                 TOTAL STORE 6005 INBOUND ITEMS  =           0
                 TOTAL STORE 6005 OUTBOUND ITEMS =           4
                 TOTAL STORE 6005 ITEMS          =           4

   6006         001         SUB-DIV1                               0
                002         SUB-DIV2                               0
                003         SUB-DIV3                               0
                004         SUB-DIV4                               0
                005         SUB-DIV5                               0
                006         SUB-DIV6                               0
                007         SUB-DIV7                               0
                008         SUB-DIV8                 Y             2
                009         SUB-DIV9                               0
                010         SUB-DIV10                              0
                011         SUB-DIV11                              0
                012         SUB-DIV12                              0

                 TOTAL STORE 6006 INBOUND ITEMS  =           2
                 TOTAL STORE 6006 OUTBOUND ITEMS =           0
                 TOTAL STORE 6006 ITEMS          =           2


  INVENTORY INBOUND GRAND TOTAL    =         29
  INVENTORY OUTBOUND GRAND TOTAL   =         32
  INVENTORY GRAND TOTAL            =         61

_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
balaryan
Beginner


Joined: 10 Mar 2017
Posts: 13
Topics: 2
Location: Boston

PostPosted: Fri Mar 17, 2017 1:59 pm    Post subject: Reply with quote

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.

Code:
OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(15,1,ZD,EQ,1),           
                 PUSH=(17:01,07)),                         
                                                           
         IFTHEN=(WHEN=GROUP,BEGIN=(15,1,ZD,EQ,2),           
                 PUSH=(26:01,07)),
This reformatting applies only to the merged records whose 15th position is 1 and 2 respectively (for Flag 'Y' and 'N').

Code:
IFTHEN=(WHEN=INIT,                                 
              OVERLAY=(35:3C'000000 ',                     
                       81:05,3,UFF,EDIT=(IIT),             
                       85:01,4)),
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?

Code:
         IFTHEN=(WHEN=(08,01,CH,EQ,C'Y'),                   
              OVERLAY=(35:9,6,                             
                       49:9,6)),                           
                                                           
         IFTHEN=(WHEN=(08,01,CH,EQ,C'N'),                   
              OVERLAY=(42:9,6,                             
                       49:9,6))                             
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.

Code:
  OUTFIL REMOVECC,IFOUTLEN=80,                             
  OMIT=(15,1,ZD,EQ,3,AND,(01,7,CH,EQ,31,7,CH)),OR,         
       (15,1,ZD,EQ,3,AND,(01,7,CH,EQ,39,7,CH))),           
This code is to achieve the below listed scenario when there is no count present for flag 'Y' or 'N', space in place of flag field and '0' as count.


Code:
Output:
004         SUB-DIV4                               0
005         SUB-DIV5                 N             2
006         SUB-DIV6                               0


Code:
  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@
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12358
Topics: 75
Location: San Jose

PostPosted: Fri Mar 17, 2017 2:23 pm    Post subject: Reply with quote

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

Code:

----+----1----+----2----+----3----+----4----+----5----+----6
                                  000000 000000 000000   


So the Y total is at 35 and N total is at 42 and full total is at 49.

Position 81 and 85 are self explanatory as they have the store and region for reporting purposes. (spacing out and appending the names)


Now all we need to do is overlay the counts checking the flag

Code:

         IFTHEN=(WHEN=(08,01,CH,EQ,C'Y'),                   
              OVERLAY=(35:9,6,                             
                       49:9,6)),                           




Since the Y count is 35 for keybreak, we overlay the contents from 9 to 35 and similary at 49 for full total

Lets say the Y count is 3, you would have the following values

Code:

----+----1----+----2----+----3----+----4----+----5----+----6
                                       3 000000      3   


Since we had the leading zeroes suppressed for the counts in step0100. If you want you can M11 edit mask to have the zeros.

Similary we check for Flag N and update the same way we did for Y flag

Lets say the N count is 2, you would have the following values

Code:

----+----1----+----2----+----3----+----4----+----5----+----6
                                  000000      2      2     


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

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group