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

SECTION BASED ON FIELD


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

New User


Joined: 27 Aug 2008
Posts: 30
Location: USA

PostPosted: Mon Jun 17, 2019 9:41 pm
Reply with quote

I need to create a report with header and breaking happening from data off record when that record as an "E" in position 2 and when the value "W" is in that position use that as the report detail data. I was thinking maybe an IFWHEN for SECTION. Is that even possible?

Input:
Code:

1A041219133180817  File Header A <-- this is excluded completely
1E0319133180817   SectionStart
1W000006356Jackson Michael                 
1W001240857Ruth Babe               
1W001305145                             
1W001347005                             
1W001347245                             
1W001382075                             
1W001424766                             
1W001667430Chevy Chase                   
1W001685948Link Willian



I want output to be

Code:

106/17/2019   Employee Report 
0                                                                       
1MY TEST RECORD                    QUARTER = 03-19                     
       EMPID             EMPLOYEE NAME                     RETURN TYPE
 000006356            Jackson Michael           
 001240857            Ruth Babe                         
 001305145                                                   
 001347005                                                   
 001347245                                                   
 001382075                                                   
 001424766                                                   
 001667430            Chevy Chase
 


My sort card:

Code:

 SORT FIELDS=COPY                                                     
 INCLUDE COND=(2,1,CH,EQ,C'W',OR,2,1,CH,EQ,C'E')                       
 OUTFIL FNAMES=OUTDD01,                                               
 OUTREC=(5:3,9,                               --EMPID                 
         26:12,30,                            --EMPNAME               
         65:43,1,                             --RETURN TYPE           
         74:75,14,UFF,EDIT=(III,III,III,IIT.TT),                       
         96:45,14,UFF,EDIT=(III,III,III,IIT.TT),115:18X),             
   HEADER1=(1:&DATE=(MD4/),                                           
            14:C'RPS/GST ',                                           
            35:C'-1 0 9 9   T A P E   F O R    N E W    Y O R K-',     
            119:C'PAGE ',&PAGE=(EDIT=(IIT)),2/),                       
   SECTIONS(2,1,03,04,SKIP=P,                                         
   HEADER3=(1:C'MY TEST RECORD',                                       
            35:C'QUARTER = ',03,2,C'-',05,02,/,                       
            6:C' EMPID',26:C'EMPLOYEE NAME     ',                     
            60:C'RETURN TYPE',                                         
            74:C'STATE TAX ',96:C'GROSS DISTRIBUTION')),               
   TRAILER1=(5:C'TOTAL STATE TAXES   : ',28:TOT=(75,14,UFF,           
            EDIT=(III,III,III,IIT.TT)),/,                             
            5:C'TOTAL GROSS DISTRB  : ',28:TOT=(45,14,UFF,             
            EDIT=(III,III,III,IIT.TT)),/,                             
            5:C'TOTAL RECS PROCESSED: ',                               
            31:COUNT=(EDIT=(III,III,III,IIT)))                         


Output I get is
Code:

106/17/2019   Employee Report 
0                                                                       
1MY TEST RECORD                    QUARTER = 03-19                     
       EMPID             EMPLOYEE NAME                     RETURN TYPE
 31913318              SectionStart
1MY TEST RECORD                    QUARTER = 00-00                     
       EMPID             EMPLOYEE NAME                     RETURN TYPE
000006356            Jackson Michael           
 1MY TEST RECORD                    QUARTER = 00-12                     
       EMPID             EMPLOYEE NAME                     RETURN TYPE
 001240857            Ruth Babe                         
 1MY TEST RECORD                    QUARTER = 00-13                     
       EMPID             EMPLOYEE NAME                     RETURN TYPE 
001305145                                                   
 001347005                                                   
 001347245                                                   
 001382075                                                   
 1MY TEST RECORD                    QUARTER = 00-14                     
       EMPID             EMPLOYEE NAME                     RETURN TYPE
  001424766                                                   
 1MY TEST RECORD                    QUARTER = 00-16                     
       EMPID             EMPLOYEE NAME                     RETURN TYPE
  001667430            Chevy Chase
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Mon Jun 17, 2019 11:55 pm
Reply with quote

Have you looked in the manual for IFWHEN and its use with SECTION? If not, why not? If yes, what is the problem?
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2012
Location: USA

PostPosted: Tue Jun 18, 2019 12:18 am
Reply with quote

Do it step by step, not all the mess together in one shot:

    - Use only OUTFIL FNAMES= with no more parameters; analyze the output
    - Add one parameter OUTREC= (or BUILD= ?); analyze the output
    - Add HEADER1=, and/or TRAILER1= ; analyze the output
    - Add SECTIONS= (why the single field is split into two separate ones??? "2,1,03,04" must be "2,5", or it may have different meaning); first try without HEADER3=/TRAILER3=; analyze the output
    - Finally add HEADER3= and/or TRAILER3= ; analyze the output


In this way you would be able to easily find your problem yourself.
Back to top
View user's profile Send private message
speermb

New User


Joined: 27 Aug 2008
Posts: 30
Location: USA

PostPosted: Tue Jun 18, 2019 3:32 am
Reply with quote

Nic Clouston wrote:
Have you looked in the manual for IFWHEN and its use with SECTION? If not, why not? If yes, what is the problem?


Yes, I did look and couldn't find any examples or explanations. So I tried myself and got syntax areas. But I did find a way to do this.
Back to top
View user's profile Send private message
speermb

New User


Joined: 27 Aug 2008
Posts: 30
Location: USA

PostPosted: Tue Jun 18, 2019 3:34 am
Reply with quote

sergeyken wrote:
Do it step by step, not all the mess together in one shot:

    - Use only OUTFIL FNAMES= with no more parameters; analyze the output
    - Add one parameter OUTREC= (or BUILD= ?); analyze the output
    - Add HEADER1=, and/or TRAILER1= ; analyze the output
    - Add SECTIONS= (why the single field is split into two separate ones??? "2,1,03,04" must be "2,5", or it may have different meaning); first try without HEADER3=/TRAILER3=; analyze the output
    - Finally add HEADER3= and/or TRAILER3= ; analyze the output


In this way you would be able to easily find your problem yourself.


I did it step by step. 1 by 1 to get to this point. This was last block.
Back to top
View user's profile Send private message
speermb

New User


Joined: 27 Aug 2008
Posts: 30
Location: USA

PostPosted: Tue Jun 18, 2019 3:43 am
Reply with quote

I added an INREC IFTHEN=(WHEN=GROUP) to push wanted data from record 1 and used that data in the SECTIONS.

Here's the card. Not sure this is the best method, but only one I have.

Code:


SORT FIELDS=COPY                                                     
  INCLUDE COND=(2,1,CH,EQ,C'W',OR,2,1,CH,EQ,C'E')             
INREC IFTHEN=(WHEN=GROUP,BEGIN=(2,1,CH,EQ,C'E'),
              PUSH(129:3,4))                               
  OUTFIL FNAMES=OUTDD01,             
  INCLUDE=(2,1,CH,EQ,C'W'),                                           
  OUTREC=(5:3,9,                               --EMPID                 
          26:12,30,                            --EMPNAME               
          65:43,1,                             --RETURN TYPE           
          74:75,14,UFF,EDIT=(III,III,III,IIT.TT),                       
          96:45,14,UFF,EDIT=(III,III,III,IIT.TT),115:18X),             
    HEADER1=(1:&DATE=(MD4/),                                           
             14:C'RPS/GST ',                                           
             35:C'-1 0 9 9   T A P E   F O R    N E W    Y O R K-',     
             119:C'PAGE ',&PAGE=(EDIT=(IIT)),2/),                       
    SECTIONS(129,04,SKIP=P,                                         
    HEADER3=(1:C'MY TEST RECORD',                                       
             35:C'QUARTER = ',03,2,C'-',05,02,/,                       
             6:C' EMPID',26:C'EMPLOYEE NAME     ',                     
             60:C'RETURN TYPE',                                         
             74:C'STATE TAX ',96:C'GROSS DISTRIBUTION')),               
    TRAILER1=(5:C'TOTAL STATE TAXES   : ',28:TOT=(75,14,UFF,           
             EDIT=(III,III,III,IIT.TT)),/,                             
             5:C'TOTAL GROSS DISTRB  : ',28:TOT=(45,14,UFF,             
             EDIT=(III,III,III,IIT.TT)),/,                             
             5:C'TOTAL RECS PROCESSED: ',                               
             31:COUNT=(EDIT=(III,III,III,IIT)))                 
   

Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2012
Location: USA

PostPosted: Tue Jun 18, 2019 7:48 am
Reply with quote

speermb wrote:
sergeyken wrote:
Do it step by step, not all the mess together in one shot:

    - Use only OUTFIL FNAMES= with no more parameters; analyze the output
    - Add one parameter OUTREC= (or BUILD= ?); analyze the output
    - Add HEADER1=, and/or TRAILER1= ; analyze the output
    - Add SECTIONS= (why the single field is split into two separate ones??? "2,1,03,04" must be "2,5", or it may have different meaning); first try without HEADER3=/TRAILER3=; analyze the output
    - Finally add HEADER3= and/or TRAILER3= ; analyze the output


In this way you would be able to easily find your problem yourself.


I did it step by step. 1 by 1 to get to this point. This was last block.

That proves to me that you did not analyze each step's results properly.
Back to top
View user's profile Send private message
speermb

New User


Joined: 27 Aug 2008
Posts: 30
Location: USA

PostPosted: Tue Jun 18, 2019 5:12 pm
Reply with quote

sergeyken wrote:
speermb wrote:
sergeyken wrote:
Do it step by step, not all the mess together in one shot:

    - Use only OUTFIL FNAMES= with no more parameters; analyze the output
    - Add one parameter OUTREC= (or BUILD= ?); analyze the output
    - Add HEADER1=, and/or TRAILER1= ; analyze the output
    - Add SECTIONS= (why the single field is split into two separate ones??? "2,1,03,04" must be "2,5", or it may have different meaning); first try without HEADER3=/TRAILER3=; analyze the output
    - Finally add HEADER3= and/or TRAILER3= ; analyze the output


In this way you would be able to easily find your problem yourself.


I did it step by step. 1 by 1 to get to this point. This was last block.

That proves to me that you did not analyze each step's results properly.


My code and results were exactly how they should be and I wanted up until the SECTIONS/CONTROL. This was my final step and an issue because I needed to break on data from 1 record type and only report the data from 2nd record type. In order to do that I had to push the break control data from record 1 onto record 2 and then use this new data as the section control.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2012
Location: USA

PostPosted: Tue Jun 18, 2019 7:59 pm
Reply with quote

speermb wrote:
My code and results were exactly how they should be and I wanted up until the SECTIONS/CONTROL. This was my final step and an issue because I needed to break on data from 1 record type and only report the data from 2nd record type. In order to do that I had to push the break control data from record 1 onto record 2 and then use this new data as the section control.

This is what I recommended you to do before asking for help.

There are still minor bugs in your last example, as I can see. Try to test it carefully; I guess you will find the bugs.

Good luck.
Back to top
View user's profile Send private message
speermb

New User


Joined: 27 Aug 2008
Posts: 30
Location: USA

PostPosted: Wed Jun 19, 2019 7:29 pm
Reply with quote

Yes there were minor bugs in previous code as the section header wasn't using the new section break fields and file must be sorted in the order of new push fields in order to break correctly.

The latest code:

Code:
                           
INCLUDE COND=(2,1,CH,EQ,C'W',OR,2,1,CH,EQ,C'E')                     
INREC IFTHEN=(WHEN=GROUP,BEGIN=(2,1,CH,EQ,C'E'),                   
              PUSH(129:3,4))                                       
SORT FIELDS=(129,4,CH,A,3,9,CH,A)
OUTFIL FNAMES=OUTDD01,                                                 
  INCLUDE=(2,1,CH,EQ,C'W'),                                         
  OUTREC=(5:3,9,                               --EMPID             
          26:12,30,                            --EMPNAME           
          65:43,1,                             --RETURN TYPE       
          74:75,14,UFF,EDIT=(III,III,III,IIT.TT),                   
          96:45,14,UFF,EDIT=(III,III,III,IIT.TT),115:18X),         
    HEADER1=(1:&DATE=(MD4/),                                       
             14:C'RPS/GST ',                                       
             35:C'- T A P E   F O R    N E W    Y O R K-',
             119:C'PAGE ',&PAGE=(EDIT=(IIT)),2/),                   
    SECTIONS(129,04,SKIP=2L,                                         
   HEADER3=(1:C'MY TEST RECORD',                               
              35:C'QUARTER = ',129,2,C'-',131,02,/,         
              6:C' EMPID',26:C'EMPLOYEE NAME     ',         
              60:C'RETURN TYPE',                           
              74:C'STATE TAX ',96:C'GROSS DISTRIBUTION'),   
              PAGEHEAD),                                   
TRAILER1=(5:C'TOTAL STATE TAXES   : ',28:TOT=(75,14,UFF,   
           EDIT=(III,III,III,IIT.TT)),/,                   
          5:C'TOTAL GROSS DISTRB  : ',28:TOT=(45,14,UFF,   
           EDIT=(III,III,III,IIT.TT)),/,                   
          5:C'TOTAL RECS PROCESSED: ',                     
           31:COUNT=(EDIT=(III,III,III,IIT)))               
 
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2012
Location: USA

PostPosted: Thu Jun 20, 2019 10:12 pm
Reply with quote

Minor simplification:

This statement
Code:
INCLUDE COND=(2,1,CH,EQ,C'W',OR,2,1,CH,EQ,C'E')

It is equivalent to
Code:
INCLUDE COND=(2,1,CH,EQ,L(C'W',C'E'))

And also to
Code:
INCLUDE COND=(2,1,SS,EQ,C'WE'))
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
Search our Forums:

Back to Top