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

Extract part of data from file and write into another file


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

New User


Joined: 02 Mar 2006
Posts: 35
Location: Chennai

PostPosted: Thu Jul 16, 2020 10:49 am
Reply with quote

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
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1222
Location: Bamberg, Germany

PostPosted: Thu Jul 16, 2020 11:12 am
Reply with quote

Please use code tags when presenting data and NOT screenshots.

As this is a help forum, what have you tried to achieve your requirement so far?
Back to top
View user's profile Send private message
sathyajes

New User


Joined: 02 Mar 2006
Posts: 35
Location: Chennai

PostPosted: Thu Jul 16, 2020 12:21 pm
Reply with quote

Yes, am trying using REXX. no desired output. And also, i thought of doing it from SORT.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


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

PostPosted: Thu Jul 16, 2020 12:57 pm
Reply with quote

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.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1222
Location: Bamberg, Germany

PostPosted: Thu Jul 16, 2020 1:08 pm
Reply with quote

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 *********************************
Back to top
View user's profile Send private message
sathyajes

New User


Joined: 02 Mar 2006
Posts: 35
Location: Chennai

PostPosted: Thu Jul 16, 2020 1:34 pm
Reply with quote

Thanks lot for your help. it is working fine
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2010
Location: USA

PostPosted: Fri Jul 17, 2020 12:00 am
Reply with quote

sathyajes wrote:
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.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Tue Jul 21, 2020 2:39 am
Reply with quote

sergeyken wrote:
sathyajes wrote:
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 ********************************
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1222
Location: Bamberg, Germany

PostPosted: Tue Jul 21, 2020 1:14 pm
Reply with quote

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.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Thu Jul 23, 2020 11:45 pm
Reply with quote

Joerg.Findeisen wrote:
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.
Got it, That completes the missing piece of the original post.
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
Search our Forums:

Back to Top