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

Copy next subsquent records based on Value


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

New User


Joined: 25 May 2012
Posts: 3
Location: india

PostPosted: Wed May 11, 2022 7:35 pm
Reply with quote

Hi Experts,
I am trying to write a sort card to copy records based on values.
For example, I have to copy records between A1 through AZ. A1 to AZ can be n times in the input file and I have to copy all those inbetween records along with those records.

Input:
A1
Record 1
Record 2
...........
...........
Record 10
AZ
B1
Record 11
Record 12
..........
Record 25
BZ
A1
Record 26
Record 27
AZ
Record 28


Output:
A1
Record 1
Record 2
...........
...........
Record 10
AZ
A1
Record 26
Record 27
AZ

Throw some light and I will catch up.

Thanks,
Srinivasan Selvam.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1492

PostPosted: Wed May 11, 2022 7:58 pm
Reply with quote

Just impossible to understand anything from this complete mess of words...

0) Learn how to use the Code button when presenting your code, and/or data

1) Please give the clear examples of your input data and (mandatory!!!) your desired output data. For instance: what is the role of your B1-BZ records? What else except A1/B1/AZ/BZ you need to consider in your input data? Etc, etc, etc...

2) Please demonstrate what did you try to do by yourself, so far?
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1492

PostPosted: Wed May 11, 2022 8:19 pm
Reply with quote

Try Grouping option

Code:
 INREC IFTHEN=(WHEN=GROUP,
               BEGIN=(1,1,SS,EQ,C'ABCDEFGHIJKLMNOPRSTUVWXYZ',
                  AND,2,1,SS,EQ,C'0123456789'),
               END=(2,1,CH,EQ,C'Z'),
               PUSH=(81:1,2))
 SORT FIELDS=(81,2,CH,A),EQUALS
 OUTREC BUILD=(1,80)
 END
Back to top
View user's profile Send private message
Srinivasan Selvam

New User


Joined: 25 May 2012
Posts: 3
Location: india

PostPosted: Wed May 11, 2022 9:52 pm
Reply with quote

Hi Sergeyken,
I have used the grouping with BEGIN and END. But outrec is writing all the records of Input file.
For example, I need only the bolded records to my output file and I don't want the remaining records .

Input file:
Rec 1
Rec 2
A1
Rec 4
Rec 5
AZ
Rec 6
B1
Rec 7
Rec 8
BZ
Rec 9
A1
Rec 10
Rec 11
Rec 12
AZ


Output file:
A1
Rec 4
Rec 5
AZ
A1
Rec 10
Rec 11
Rec 12
AZ

Code:

INREC  IFTHEN=(WHEN=GROUP,                                         
              BEGIN=(1,2,SS,EQ,C'A1'),END=(1,2,SS,EQ,C'AZ'),
              PUSH=(81:1,2))                                     
SORT FIELDS=(81,2,CH,A),EQUALS                                   
OUTREC BUILD=(1,80)                                             
Back to top
View user's profile Send private message
Srinivasan Selvam

New User


Joined: 25 May 2012
Posts: 3
Location: india

PostPosted: Wed May 11, 2022 10:38 pm
Reply with quote

Hi Sergeyken,
I got the desired output after changing the code like below.

Code:
OPTION COPY
INREC  IFTHEN=(WHEN=GROUP,                                         
              BEGIN=(1,2,CH,EQ,C'A1'),END=(1,2,CH,EQ,C'AZ'),
              PUSH=(81:1,2))                                     
OUTFIL INCLUDE=(81,2,CH,EQ,C'A1'),BUILD=(1,80)
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1492

PostPosted: Wed May 11, 2022 11:26 pm
Reply with quote

0) Learn how to use the Code button when presenting your code, and your data

1) Learn to express your ideas, and issues in such a manner and terminology, that other people to be able to understand your needs.
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 Output LREC based on specific character DFSORT/ICETOOL 22
No new posts Count Records with a crietaria in a f... DFSORT/ICETOOL 5
No new posts Splitting group records based on deta... DFSORT/ICETOOL 8
No new posts Orphaned BCDS Records JCL & VSAM 1
No new posts DB2, write report based on query outp... DB2 1
Search our Forums:

Back to Top