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
 
Extract part of data from file and write into another file

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

New User


Joined: 02 Mar 2006
Posts: 32
Location: Chennai

PostPosted: Thu Jul 16, 2020 10:49 am    Post subject: Extract part of data from file and write into another file
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

Active User


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

PostPosted: Thu Jul 16, 2020 11:12 am    Post subject:
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: 32
Location: Chennai

PostPosted: Thu Jul 16, 2020 12:21 pm    Post subject:
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: 2378
Location: Hampshire, UK

PostPosted: Thu Jul 16, 2020 12:57 pm    Post subject: Reply to: Extract part of data from file and write into another file
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

Active User


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

PostPosted: Thu Jul 16, 2020 1:08 pm    Post subject:
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: 32
Location: Chennai

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

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

Active Member


Joined: 29 Apr 2008
Posts: 811
Location: Maryland

PostPosted: Fri Jul 17, 2020 12:00 am    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 2443
Location: NY,USA

PostPosted: Tue Jul 21, 2020 2:39 am    Post subject:
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

Active User


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

PostPosted: Tue Jul 21, 2020 1:14 pm    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 2443
Location: NY,USA

PostPosted: Thu Jul 23, 2020 11:45 pm    Post subject:
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    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 CA Sysview - JCL or Rexx - Read or Ex... Jasi CA Products 4 Wed Aug 05, 2020 9:19 pm
No new posts Multiple Sums in one File Rick Ryan SYNCSORT 2 Wed Jul 29, 2020 1:30 am
No new posts REXX tool to extract all files starti... KeshavKunal CLIST & REXX 4 Tue Jul 21, 2020 3:43 pm
No new posts Extract SRCOM with PIF (IWSz) jhonatan1090 IBM Tools 0 Mon Jul 20, 2020 7:23 pm
No new posts Identify the count from two diffrent ... UmashankarSubramani DFSORT/ICETOOL 19 Sat Jul 11, 2020 4:35 am

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