Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
SECTION BASED ON FIELD

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
speermb

New User


Joined: 27 Aug 2008
Posts: 28
Location: USA

PostPosted: Mon Jun 17, 2019 9:41 pm    Post subject: SECTION BASED ON FIELD
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: 2230
Location: Hampshire, UK

PostPosted: Mon Jun 17, 2019 11:55 pm    Post subject: Reply to: SECTION BASED ON FIELD
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

Active Member


Joined: 29 Apr 2008
Posts: 549
Location: Maryland

PostPosted: Tue Jun 18, 2019 12:18 am    Post subject:
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: 28
Location: USA

PostPosted: Tue Jun 18, 2019 3:32 am    Post subject: Re: Reply to: SECTION BASED ON FIELD
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: 28
Location: USA

PostPosted: Tue Jun 18, 2019 3:34 am    Post subject:
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: 28
Location: USA

PostPosted: Tue Jun 18, 2019 3:43 am    Post subject: Found the way to get this done.
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

Active Member


Joined: 29 Apr 2008
Posts: 549
Location: Maryland

PostPosted: Tue Jun 18, 2019 7:48 am    Post subject:
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: 28
Location: USA

PostPosted: Tue Jun 18, 2019 5:12 pm    Post subject:
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

Active Member


Joined: 29 Apr 2008
Posts: 549
Location: Maryland

PostPosted: Tue Jun 18, 2019 7:59 pm    Post subject:
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: 28
Location: USA

PostPosted: Wed Jun 19, 2019 7:29 pm    Post subject:
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

Active Member


Joined: 29 Apr 2008
Posts: 549
Location: Maryland

PostPosted: Thu Jun 20, 2019 10:12 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Need to fetch data from database base... Satandale COBOL Programming 8 Sun Sep 08, 2019 12:01 am
No new posts Select based on a range from a differ... sergeyken SYNCSORT 2 Fri Aug 16, 2019 12:37 am
This topic is locked: you cannot edit posts or make replies. Select based on a range from a differ... vamsimul SYNCSORT 13 Tue Aug 13, 2019 12:36 pm
This topic is locked: you cannot edit posts or make replies. Removing duplicate record based on th... Nilanjan Sikdar DFSORT/ICETOOL 4 Mon Jul 22, 2019 8:29 pm
No new posts Procedure Division Section socker_dad COBOL Programming 2 Wed Jun 12, 2019 12:21 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us