|
View previous topic :: View next topic
|
| Author |
Message |
speermb
New User
Joined: 27 Aug 2008 Posts: 30 Location: USA
|
|
|
|
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 |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
| 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 |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2288 Location: USA
|
|
|
|
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 |
|
 |
speermb
New User
Joined: 27 Aug 2008 Posts: 30 Location: USA
|
|
|
|
| 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 |
|
 |
speermb
New User
Joined: 27 Aug 2008 Posts: 30 Location: USA
|
|
|
|
| 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 |
|
 |
speermb
New User
Joined: 27 Aug 2008 Posts: 30 Location: USA
|
|
|
|
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 |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2288 Location: USA
|
|
|
|
| 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 |
|
 |
speermb
New User
Joined: 27 Aug 2008 Posts: 30 Location: USA
|
|
|
|
| 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 |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2288 Location: USA
|
|
|
|
| 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 |
|
 |
speermb
New User
Joined: 27 Aug 2008 Posts: 30 Location: USA
|
|
|
|
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 |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2288 Location: USA
|
|
|
|
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 |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|