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

How to massage out unwanted lines


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

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Wed Jan 06, 2016 2:31 am
Reply with quote

Thanks guys, I will look at this later, not before the weekend. Just shut down my z/OS system as I will busy with more pressing matters tomorrow, and on Thursday/Friday I will be hitchhiking back to Vilnius, where our car will hopefully be back in a drivable state.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jan 06, 2016 4:46 am
Reply with quote

Rahul,

Consider the effect of each report being preceded by a blank line. The first report has no blank line, so you make one (single-record file, concatenate the real data to it).

Then you should be able to identify start/end of the heading group, the data group, and footer group if present.

Don't forget the bit about ignoring lines with only | and - on them (once the TRAN=ALTSEQ has done some cleaning). But get the main part up-and-running first.

Oh, reminds me. Prino, you have a typo in your ALTSEQ.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Jan 08, 2016 5:33 pm
Reply with quote

This is the code I sent to Prino at the time.
Code:

 ALTSEQ CODE=(F040,F140,F240,F340,F440,
              F540,F640,F740,F840,F940,
              4B40,7A40)
 INREC IFTHEN=(WHEN=GROUP,
            BEGIN=(1,1,CH,EQ,C' '),
            PUSH=(1:1,1),
            RECORDS=2),
       IFTHEN=(WHEN=GROUP,
            BEGIN=(1,2,CH,EQ,C' -'),
            END=(1,2,CH,EQ,C'+-'),
            PUSH=(81:2,1)),
       IFTHEN=(WHEN=GROUP,
            BEGIN=(81,1,CH,EQ,C'-',
                    AND,
                   1,2,CH,EQ,C'+-'),
            END=(81,1,CH,EQ,C' ',
                    AND,
                   1,2,CH,EQ,C'+-'),
            PUSH=(82:1,1)),
       IFTHEN=(WHEN=INIT,
               OVERLAY=(1:1,80,TRAN=ALTSEQ)),
       IFTHEN=(WHEN=INIT,
               PARSE=(%01=(FIXLEN=80))),
       IFTHEN=(WHEN=INIT,
             FINDREP=(IN=(C'|',C'-'),
                      OUT=C' ',
                      ENDPOS=80)),
       IFTHEN=(WHEN=(1,80,CH,NE,C' '),
             BUILD=(%01,81,2))
 SORT FIELDS=(1,80,CH,A)
 SUM  FIELDS=NONE
 OUTFIL INCLUDE=(1,1,CH,NE,C' ',
                 AND,
                 1,1,CH,NE,C'+',
                 AND,
                  (81,1,CH,EQ,C'-',
                   OR,
                  (82,1,CH,EQ,C' ',
                   AND,
                   81,1,CH,EQ,C' ')))


The problem for WHEN=GROUP is that the logical start and end of the group has the same data (the +- lines) which means the the group ends immediately (both the BEGIN and END are satisfied by the same line.

So you need to change one of those lines before you can do the WHEN=GROUP.

All reports except the first are prefixed by a blank line, which could be used to amend the first line of the group.

So make, by concatenating to a single-record file which contains a blank line, a blank line precede the first report as well.

Then use WHEN=GROUP for the blank line to clobber part of the first line of the logical group.

Identifying the footer-group is then also possible.

The detritus lines, containing only vertical bars and dashes, are removed by first saving the line (with PARSE, into a PARSEd field) and then FINDREPing the characters to blank.

If the resultant line is not blank, put the PARSEd field back onto the record.

It is then a case of arranging the INCLUDE on OUTFIL to only get the records which are actually required.

I suspect there is a requirement for the multi-line headings to remain together, but we'll see.

I also suspect the SORT and SUM FIELDS=NONE is not required, but the answer to that lies in the data - is there more than one copy of the same report, so that headings which are duplicate are not logically contiguous.

Tested with 80-byte lines, adjust for actual lengths.

In detail:

Identify blank lines with WHEN=GROUP and PUSH the blank identified onto the first +- line for a report, giving blank-then-dash.

Code:
 INREC IFTHEN=(WHEN=GROUP,
            BEGIN=(1,1,CH,EQ,C' '),
            PUSH=(1:1,1),
            RECORDS=2),


Define the group for the headings.

Code:

       IFTHEN=(WHEN=GROUP,
            BEGIN=(1,2,CH,EQ,C' -'),
            END=(1,2,CH,EQ,C'+-'),
            PUSH=(81:2,1)),


Define the group for the footer, if present, relying on the heading group identification.

Code:

       IFTHEN=(WHEN=GROUP,
            BEGIN=(81,1,CH,EQ,C'-',
                    AND,
                   1,2,CH,EQ,C'+-'),
            END=(81,1,CH,EQ,C' ',
                    AND,
                   1,2,CH,EQ,C'+-'),
            PUSH=(82:1,1)),


Do Prino's required translation to get various things in heading lines to blank (does not matter one jot that it affects data lines as well, as they are not required in the output) with presumed typos fixed.

Code:
       IFTHEN=(WHEN=INIT,
               OVERLAY=(1:1,80,TRAN=ALTSEQ)),


Save the current state of the record in a PARSEd field (ignoring the extensions to the record from PUSH).

Code:
       IFTHEN=(WHEN=INIT,
               PARSE=(%01=(FIXLEN=80))),


Use FINDREP to get rid of the characters that would be unwanted if there is no other data on the line.

Code:
       IFTHEN=(WHEN=INIT,
             FINDREP=(IN=(C'|',C'-'),
                      OUT=C' ',
                      ENDPOS=80)),


If, having got rid of the unwanted characters, the line is not blank, restore the original data from the PARSEd field.

Code:
       IFTHEN=(WHEN=(1,80,CH,NE,C' '),
             BUILD=(%01,81,2)) 


The SORT and SUM as per Prino's original code.

Code:
 SORT FIELDS=(1,80,CH,A)
 SUM  FIELDS=NONE


Ignore blank lines and otherwise use the flags set from the second two GROUPs to identify the header content and footer content that is required. Probably don't need to ignore the blank lines because all the GROUPs are limited (by RECORDS or by END) but I had that there whilst developing it.

Code:
 OUTFIL INCLUDE=(1,1,CH,NE,C' ',
                 AND,
                 1,1,CH,NE,C'+',
                 AND,
                  (81,1,CH,EQ,C'-',
                   OR,
                  (82,1,CH,EQ,C' ',
                   AND,
                   81,1,CH,EQ,C' ')))


With SORT solutions, concentrate thought on the data. When you think "if only the data were like that, I could do this", work out how to get the data like that.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Jan 08, 2016 9:56 pm
Reply with quote

And add one to all positions for the A in the RECFM (so ignore it for the PARSE, and on the FINDREP have a STARTPOS=2 (and adjust the ENDPOS for the last byte of data) :-)

To create the single-record file with a blank line:

Code:

 OPTION COPY,STOPAFT=1
 INCLUDE COND=(2,1,CH,EQ,C' ')


In a separate step.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Tue Jan 19, 2016 5:10 pm
Reply with quote

Thanks guys, this works nicely. As for the blank line at the top issue, there actually is one, every page starts with a line just containing a '1' ASA control character.
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 I need a 4 lines block where substrin... DFSORT/ICETOOL 12
No new posts Copy few lines from SYSOUT of 10 mill... All Other Mainframe Topics 5
No new posts Generate output lines (SYSIN card for... DFSORT/ICETOOL 4
No new posts Merge 2 lines based on Space from a S... DFSORT/ICETOOL 5
No new posts JCL - To repeat a string in same colu... JCL & VSAM 2
Search our Forums:

Back to Top