Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Syncsort - collect records having pair numbers !

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT
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    Post subject: Syncsort - collect records having pair numbers !
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Apr 21, 2014 5:02 pm    Post subject: Reply to: Syncsort - collect records having pair numbers !
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    Post subject: Reply to: Syncsort - collect records having pair numbers !
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    Post subject: Reply to: Syncsort - collect records having pair numbers !
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    Post subject: Reply to: Syncsort - collect records having pair numbers !
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Apr 21, 2014 5:42 pm    Post subject: Reply to: Syncsort - collect records having pair numbers !
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    Post subject: Reply to: Syncsort - collect records having pair numbers !
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    IBMMAINFRAMES.com Support Forums -> SYNCSORT All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 1 Fri Dec 02, 2016 9:47 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts Syncsort - Hard coded Value in output PORYES SYNCSORT 1 Thu Nov 03, 2016 9:23 am
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Row-Numbers of distinct rows? Auryn DB2 1 Thu Oct 20, 2016 4:38 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us