We have requirement to copy portion of report data into another file. We have LRECL as 80. target file will also be length as 80.
we want to find string "TOTAL VALUE:" in file and traverse in reverse order to find "PAGE:", so we need to copy the records in between them(include record contains "TOTAL VALUE:" and "PAGE:" as well).
Output should be like as below. Attached screen shot of input records for your reference.
Code:
REPORT# N4 PAGE: 5
COL FIELD NAME BEFORE
-----------------------------------------------------------------------
AAAAADBD
------------
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
TOTAL VALUE: NNNNNNNNNNNNNNNNNNNNN
We would like to do using sort, ICETOOL, etc. Please let me know solution for that
Moderator: deleted screenshot - pleases repost as a cut and paste using the code tags. I have provided code tags for the report sample above
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
Wow - desired ouput not achieved with Rexx? And yet it is such a simple program - read data into stem;traverse stem until string found;note position;traverse back until 'page' found;traverse forward copying data until noted position found. Repeat until EOF.
Joined: 15 Aug 2015 Posts: 1246 Location: Bamberg, Germany
Code:
//TOTAL EXEC PGM=ICEMAN
//F1 DD *
REPORT# N1 PAGE: 1
COL FIELD NAME BEFORE
----------------------------------------------------------------------
AAAAADBD
------------
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
REPORT# N4 PAGE: 5
COL FIELD NAME BEFORE
----------------------------------------------------------------------
AAAAADBD
------------
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
TOTAL VALUE: NNNNNNNNNNNNNNNNNNNNN
/*
//F2 DD .. <* exactly the same Input as for F1
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=F1,FIELDS=(83,18,A),TYPE=F
JOINKEYS F2=F2,FIELDS=(83,18,A),TYPE=F
REFORMAT FIELDS=(F1:1,80,F2:81,2)
OUTFIL FNAMES=(SORTOUT),
INCLUDE=(81,2,CH,EQ,C'ZZ'),
REMOVECC,
BUILD=(1,80)
END
/*
//JNF1CNTL DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(63,6,CH,EQ,C'PAGE:'),PUSH=(83:63,18))
END
/*
//JNF2CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:2Z)),
IFTHEN=(WHEN=GROUP,BEGIN=(63,6,CH,EQ,C'PAGE:'),PUSH=(83:63,18)),
IFTHEN=(WHEN=(2,13,CH,EQ,C'TOTAL VALUE:'),OVERLAY=(81:C'ZZ'))
SUM FIELDS=(81,2,BI)
END
/*
Output:
Code:
****** **************************** Datenanfang *******************************
000001 REPORT# N4 PAGE: 5
000002 COL FIELD NAME BEFORE
000003 -----------------------------------------------------------------------
000004 AAAAADBD
000005 ------------
000006 RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
000007 TOTAL VALUE: NNNNNNNNNNNNNNNNNNNNN
****** **************************** Datenende *********************************
Yes, am trying using REXX. no desired output. And also, i thought of doing it from SORT.
At this forum, it sounds like
Quote:
I'm trying using a microscope to hammer nails, but no desired output. And also, I thought of doing this with a BULLDOZER.
True.
Isn't it this simple and straight forward needed? I mean why go reverse when we know Start and End points of the Group to include.
Code:
//S1 EXEC PGM=SORT
//SORTLIST DD SYSOUT=*
//SORTIN DD *
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
REPORT# N4 PAGE: 5
COL FIELD NAME BEFORE
-----------------------------------------------------------------------
AAAAADBD
------------
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
TOTAL VALUE: NNNNNNNNNNNNNNNNNNNNN
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
REPORT# N4 PAGE: 6
COL FIELD NAME BEFORE
-----------------------------------------------------------------------
BBBBBBBD
------------
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
TOTAL VALUE: NNNNNNNNNNNNNNNNNNNNN
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,80,SS,EQ,C'PAGE'),
END=(1,80,SS,EQ,C'TOTAL VALUE'),PUSH=(81:ID=4))
OUTFIL FNAMES=(SORTOUT),
INCLUDE=(81,4,CH,NE,C' '),
REMOVECC,
BUILD=(1,80)
END
/*
Output-
Code:
********************************* TOP OF DATA **********************************
REPORT# N4 PAGE: 5
COL FIELD NAME BEFORE
-----------------------------------------------------------------------
AAAAADBD
------------
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
TOTAL VALUE: NNNNNNNNNNNNNNNNNNNNN
REPORT# N4 PAGE: 6
COL FIELD NAME BEFORE
-----------------------------------------------------------------------
BBBBBBBD
------------
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
TOTAL VALUE: NNNNNNNNNNNNNNNNNNNNN
******************************** BOTTOM OF DATA ********************************
Joined: 15 Aug 2015 Posts: 1246 Location: Bamberg, Germany
Rohit Umarjikar wrote:
Isn't it this simple and straight forward needed? I mean why go reverse when we know Start and End points of the Group to include.
As by original TS request (the replaced screenshot from first post) the End point was a can be there option. That's why a reverse solution has been chosen instead of a straight forward one.
Isn't it this simple and straight forward needed? I mean why go reverse when we know Start and End points of the Group to include.
As by original TS request (the replaced screenshot from first post) the End point was a can be there option. That's why a reverse solution has been chosen instead of a straight forward one.
Got it, That completes the missing piece of the original post.