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 

Creating formatted report using SECTIONS

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
Aki88
Beginner


Joined: 26 Oct 2016
Posts: 8
Topics: 3

PostPosted: Wed May 31, 2017 7:43 am    Post subject: Creating formatted report using SECTIONS Reply with quote

Hello,

This is a relatively simple requirement, but I am unable to figure out a solution.

Representational data looks as below; actual data content is very different, but Structurally it follows similar rules.

Input dataset:

Code:

Report header 1
Report header 2
Report header 3
Report header 4
Report header 5
Report header 6
<Actual data line1 with data up to column 134><identifier value1><rest of record data>
<Actual data line2 with data up to column 134><identifier value1><rest of record data>
<Actual data line3 with data up to column 134><identifier value2><rest of record data>
<Actual data line4 with data up to column 134><identifier value3><rest of record data>
<Actual data line5 with data up to column 134><identifier value2><rest of record data>
<Actual data line6 with data up to column 134><identifier value4><rest of record data>
---
---
<Actual data line 'n' with data up to column 134><identifier value 'n'><rest of record data>
<Tail Record>


The LRECL of this input dataset is 200, RECFM=FB. The input data records are not sorted on 'identifier values'.
The Tail record contains the count of all the detail records.

Requirement is to have the count of all unique identifier groups as well, written as separate tail records, right at the end of the dataset (the original content of the dataset remaining as-is).

All the logic that I could think of needed at least two passes of data; first pass to SORT and use SECTIONS to build the individual counts; second pass to append this data to the dataset.

Any guidance on this is really appreciated.

Thank you.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Wed May 31, 2017 10:43 am    Post subject: Reply with quote

Aki88,

Hmm looks like you are missing the simple trick of using joinkeys to match to itself in your arsenal of solutions to common problems. Here is the job that will give you the desired results.

I used a omit condition to eliminate the header/trailer records checking the position 135 for spaces. If you have a better way of identifying the header/trailer records , then use that conditions to eliminate the header/trailer records from being counted.

Code:

//STEP0200 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//INA      DD DSN=Your Input Fb 200 byte file
//INB      DD DSN=Same file FB 200 byte file
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                   
  OPTION COPY                                                     
  JOINKEYS F1=INA,FIELDS=(201,18,A),SORTED,NOSEQCK                 
  JOINKEYS F2=INB,FIELDS=(001,18,A)                               
  JOIN UNPAIRED                                                   
  REFORMAT FIELDS=(F1:1,200,?,F2:2,25)     
                       
  INREC IFOUTLEN=200,                                             
  IFTHEN=(WHEN=(201,1,CH,EQ,C'2'),                                 
  BUILD=(C' THE COUNT OF IDENTIFIER ',202,17,C' IS : ',           
          219,8))                                                 
//*                                                               
//JNF1CNTL DD *                                                   
  INREC OVERLAY=(201:C'1',17X)                                     
//*                                                               
//JNF2CNTL DD *                                                   
  OMIT COND=(135,17,CH,EQ,C' ')      <<HDR/TLR omit                           
  INREC BUILD=(C'2',135,17,C'00000001')                           
  SUM FIELDS=(19,8,ZD)                                             
//*

_________________
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
Aki88
Beginner


Joined: 26 Oct 2016
Posts: 8
Topics: 3

PostPosted: Wed May 31, 2017 12:03 pm    Post subject: Reply with quote

Hello Kolusu,

kolusu wrote:

Hmm looks like you are missing the simple trick of using joinkeys to match to itself in your arsenal of solutions to common problems.


I humbly accept; for this and the other thread I'd posted, JOINKEYS didn't strike me EVEN ONCE. Embarassed

I do not have access to the site at this moment; will fire this code piece first thing in morning; will share the results once it is done.

One of the other reasons why I think JOINKEYS didn't strike me for this one was because the amount of data we are looking at was close to over a couple of million records, and the only thing at the back of my mind from the word go was - no two passes of data. I remember telling my colleague that all the solutions that I can think of need two passes of data - first to prepare the totals for all the identifiers, second to append them.
I could've done this in the source COBOL program itself, but the challenge was number of identifiers is not fixed, and we do not know the upper limit, which would've meant defining a very large table to hold the values one by one; SECTIONS gave me a workaround for that, hence it took precedence over everything else in my head. Sigh!

Thank you once again, this is like a konk to my head; lemme run this against the load; though I'm still tad bit skeptical about the passes of data.

Best regards.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Wed May 31, 2017 12:30 pm    Post subject: Reply with quote

Aki88 wrote:
One of the other reasons why I think JOINKEYS didn't strike me for this one was because the amount of data we are looking at was close to over a couple of million records, and the only thing at the back of my mind from the word go was - no two passes of data.


Aki88,

If you look at the job, I used a SORTED, NOSEQCK for the JNF1 file 1, so it is a mere copy operation

And for JNF2, I actually reduced the LRECL to just 26 bytes. By doing so we are reducing the resources required to sort the data.

Code:

POSITION          VALUE      DESCRIPTION                         
--------          ------     ------------                       
 01                '2'        FILE-IND SO THAT IT WOULDN'T MATCH
 02 THRU 18        KEY-ID     17 BYTE KEY IDENTIFIER             
 19 THRU 26       00000001    8 byte STATIC VALUE OF '1'               


The main task once again is using a COPY operation and all we are doing is setting the lrecl 200 by adding the contents from file 2.
_________________
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
Aki88
Beginner


Joined: 26 Oct 2016
Posts: 8
Topics: 3

PostPosted: Wed May 31, 2017 12:37 pm    Post subject: Reply with quote

kolusu wrote:
.... I used a SORTED, NOSEQCK for the JNF1 file 1, so it is a mere copy operation
.... By doing so we are reducing the resources required to sort the data.....

The main task once again is using a COPY operation and all we are doing is setting the lrecl 200 by adding the contents from file 2.


I agree with your point; both ways the operation is more in-line with COPY; thank you Kolusu.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
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