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

Syncsort - collect records having pair numbers !


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ramas.kamal

New User


Joined: 03 Mar 2014
Posts: 22
Location: India

PostPosted: Mon Apr 21, 2014 4:47 pm
Reply with quote

Hi, in the below input file (LRECL=49,RECFM=FB) there are few records with value "2651" appearing twice in the same line. The 6 byte key starts at 4th column and is followed by 4 digit numbers till 49th column. So, I need to search for value "2651" in between 10th and 49th column and if any record has two of "2651" appearing then write such ones to output.

Code:

----+----1----+----2----+----3----+----4----+----5
@1 GTL0@192009106265149002651
@8 BAS9@878903434789326510300
@4 TULI@4901226513564090045092651
@3 KJML@3090108430651654088453379265100012651
@6 FINA@62651404023405430203419083920
@2 LON0@23901266143500120387002310241029125612661


How to pick only those into output file? I thought of using PARSE function but do not know how to collect or not collect them !!

Expecte Output:
Code:

@1 GTL0@192009106265149002651
@4 TULI@4901226513564090045092651
@3 KJML@3090108430651654088453379265100012651


Please help.
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: Mon Apr 21, 2014 5:02 pm
Reply with quote

What if there are more that two occurrences?

For two, or for the size of your record, PARSE is going to be the correct way.

Have a look at STARTAT in PARSE, and ensure you know how PARSE works. Experiment if necessary.

If the field from the second STARTAT is non-blank, then you have two (or more) of that particular value. You have fixed-length records, so extend at the end of each record. You only need one byte from the PARSEd field, as it will be just blank or non-blank.

If you arrive at an answer, please post it.

If you have difficulties, please show what you have tried, what went wrong, and what you expected to happen.
Back to top
View user's profile Send private message
ramas.kamal

New User


Joined: 03 Mar 2014
Posts: 22
Location: India

PostPosted: Mon Apr 21, 2014 5:06 pm
Reply with quote

Quote:

What if there are more that two occurrences?


there are few records with value "2651" appearing twice in the same line.

Can you please explain your idea more clearly?
Back to top
View user's profile Send private message
ramas.kamal

New User


Joined: 03 Mar 2014
Posts: 22
Location: India

PostPosted: Mon Apr 21, 2014 5:16 pm
Reply with quote

This is what I tried but it written all to output !

Sort Job:
Code:

//STEP0001 EXEC PGM=SORT                         
//SORTIN   DD *                                 
@1 GTL0@192009106265149002651                   
@8 BAS9@878903434789326510300                   
@4 TULI@4901226513564090045092651               
@3 KJML@3090108430651654088453379265100012651   
@6 FINA@62651404023405430203419083920           
@2 LON0@23901266143500120387002310241029125612661
//SYSOUT   DD SYSOUT=*                           
//SORTOUT  DD SYSOUT=*                           
//SYSIN    DD *                                 
  SORT FIELDS=COPY                               
  INREC PARSE=(%01=(STARTAT=C'2651',FIXLEN=4),   
               %02=(STARTAT=C'2651',FIXLEN=4)), 
               BUILD=(4,6,X,%01,X,%02)           


Output I got:
Code:

GTL0@1 2651 2651
BAS9@8 2651     
TULI@4 2651 2651
KJML@3 2651 2651
FINA@6 2651     
LON0@2         


Thanks.
Back to top
View user's profile Send private message
ramas.kamal

New User


Joined: 03 Mar 2014
Posts: 22
Location: India

PostPosted: Mon Apr 21, 2014 5:24 pm
Reply with quote

well.....well.......experimented it more and got results with below sort card.

Code:

//SYSIN    DD *                                   
  SORT FIELDS=COPY                               
  INREC PARSE=(%01=(STARTAT=C'2651',FIXLEN=4),   
               %02=(STARTAT=C'2651',FIXLEN=4)),   
               BUILD=(1,49,2X,%01,%02)           
  OUTFIL INCLUDE=(56,4,CH,EQ,C'2651'),BUILD=(1,49)


Thanks.
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: Mon Apr 21, 2014 5:42 pm
Reply with quote

Good you got there. Without INCLUDE= or OMIT= everything will appear on OUTFIL, so you need one of those.

Now we can tidy things a little:

Code:
  SORT FIELDS=COPY                               
  INREC PARSE=(%=(STARTAT=C'2651',FIXLEN=4),   
               %01=(STARTAT=C'2651',FIXLEN=1)),   
               BUILD=(1,49,%01)           
  OUTFIL OMIT=(50,1,CH,EQ,C' '),BUILD=(1,49)


You shouldn't need two PARSEd fields. If you are going to use a field, give it a %nn, if you are just using it for positioning, give it a simple %.

From the second PARSE, all you are interested in is when a value was found. If a value was not found, then the PARSEd result with a length of 1 will be space. If a value was found (that value being 2651) then the length of 1 will give "2", which is non-blank.

The first part of the PARSE locates 2651 if present, and advances the parse pointer by four bytes.

The second part of the PARSE locates a second 2651 if present, and allows you to reference the first byte found, by name (%01 here).

Ensure that you test with consecutive "2651"s and more than two on the same record.
Back to top
View user's profile Send private message
ramas.kamal

New User


Joined: 03 Mar 2014
Posts: 22
Location: India

PostPosted: Mon Apr 21, 2014 7:27 pm
Reply with quote

Bill, thanks for explaining the concept. Very useful.
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 -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top