Page 1 of 1

Retrieving records dynamically from dynamic position

PostPosted: Wed Oct 05, 2016 1:16 am
by ibmmf4u
Hi,

I would like to retrieve records that contains a specified keyword that will be found any where in the record. I would like to retrieve the only the part of the record that starts after it encounters the keyword till the position where it encounters first encounters a colon .

Below are the details of the file. RECFM =FB , LRECL=1000.

Input file:-


12345678901234...ABC:345RSS567890...:XYZ:7634843..:DEF:893795...
01234567...ABC:763AUD64748909...:PQR:79395:GEF:789387593...
1234567890123456789234...ABC:345CAD567890...:XYZ:763..:MNO:893795...
212345679638645...ABC:763YEN6474890945456665...:BED:793956893...:JKL:7893...
 


The keyword specified here is "ABC:" and it can start any where in the record. I would like to extract only the part of record that has tag "ABC:" i.e. starting after we encounter the keyword "ABC:" till the time where it encounters the first colon ":" as shown below.

Output file:-

The entire ABC tag.


345RSS567890...
763AUD64748909...
345CAD567890...
763YEN6474890945456665...


I tried exploring the other ways but couldn't progress mush as i'm unaware of how we can get only the specific part of the record dynamically.

Below was the piece of code i just started and couldn't progress much.


SORT FIELDS=COPY
INCLUDE COND=(1,1000,SS,EQ,C"ABC:")
 



Can someone please help me in getting it resolved?

Thanks in advance :D

Re: Retrieving records dynamically from dynamic position

PostPosted: Wed Oct 05, 2016 1:58 am
by Robert Sample
I would like to retrieve the only the part of the record that starts after it encounters the keyword till the position where it encounters first encounters a colon .
You do not understand what a record is, do you? Either that or you are not saying what you want very well. You can only "retrieve" (by which I assume you mean read) an entire record -- from first byte to last byte. You may OUTPUT only part of that data, but you have no real control over the reading -- you get the entire record, period.

This sounds like an easy task to write a program for -- why try to get a SYNCSORT solution when a program would be fairly short and pretty easy to code up?

Re: Retrieving records dynamically from dynamic position

PostPosted: Wed Oct 05, 2016 2:07 am
by enrico-sorichetti
investgiate the use of the PARSE clause using for the delimiters somenthing like


STARTAT=C'ABC:',ENDAT=C':'


quite a few examples on the forum