View previous topic :: View next topic
|
Author |
Message |
DEBALINA GHATAK
New User
Joined: 04 Dec 2006 Posts: 4 Location: India
|
|
|
|
Hi All,
I would greet everyone if anybody can help me giving a solution to the problem given below.
The requirement is to eliminate one or more than one particular record(s) i.e. the whole row, from a single flat file.
For example, the file contains the records are
01SK0Zhkgkg987998kj
02SG0Vuiy68768970-9
03SF0Quguighuoho908kjbhklj
04SD0Ai8768934klnm
The o/p file will not contain the SK0Z and SD0A (these are the record identifiers from 3rd byte thru 6th byte) records and rest of the records will be resequenced, i.e. the o/p file will contain
01SG0Vuiy68768970-9
02SF0Quguighuoho908kjbhklj
Here we can assume that these two records SK0Z and SD0A will not be repeated.
Thanks |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Use sort and its omit function. |
|
Back to top |
|
|
justaprogrammer
New User
Joined: 30 Nov 2006 Posts: 1 Location: Zeroland
|
|
|
|
Are 01 & 02 part of the records present in the file? |
|
Back to top |
|
|
DEBALINA GHATAK
New User
Joined: 04 Dec 2006 Posts: 4 Location: India
|
|
|
|
Thanks Williams ... I will try this out. But will this resequence my output?
I mean will the serial numbers go out of sequence ? |
|
Back to top |
|
|
DEBALINA GHATAK
New User
Joined: 04 Dec 2006 Posts: 4 Location: India
|
|
|
|
justaprogrammer wrote: |
Are 01 & 02 part of the records present in the file? |
Yep.. Serial number comprise the first two bytes of the record length. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
justaprogrammer was concerned that your expected output did not exactally match your sample input....
Quote: |
But will this resequence my output? |
If you provide sort fields, yes, but if you specify COPY, no. |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi Debalina,
Give this as sort card
Code: |
SORT FIELDS=COPY
OMIT COND=(3,4,CH,EQ,C'SK0Z',OR,3,4,CH,EQ,C'SD0A')
OUTFIL OUTREC=(SEQNUM,2,ZD,3,78)
|
Hope it will helpful |
|
Back to top |
|
|
DEBALINA GHATAK
New User
Joined: 04 Dec 2006 Posts: 4 Location: India
|
|
|
|
Hi Ekta,
Thanks a lot. It worked successfully. |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi There,
Glad I could help. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
guptae wrote: |
Code: |
SORT FIELDS=COPY
OMIT COND=(3,4,CH,EQ,C'SK0Z',OR,3,4,CH,EQ,C'SD0A')
OUTFIL OUTREC=(SEQNUM,2,ZD,3,78) |
|
Why "SEQNUM"? |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi William,
I put SEQNUM because debalina wants the record count (serial number ) as first two byte. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
guptae wrote: |
I put SEQNUM because debalina wants the record count (serial number ) as first two byte. |
I'm sorry, but I still don't see where that requirement was made, could you please point it out to me? It's probably my male vision blinding me...grin....
(male vision: the ability to not see the obvious) |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
William,
The input is:
Code: |
01SK0Zhkgkg987998kj
02SG0Vuiy68768970-9
03SF0Quguighuoho908kjbhklj
04SD0Ai8768934klnm
|
The expected output is:
Code: |
01SG0Vuiy68768970-9
02SF0Quguighuoho908kjbhklj
|
Note that in the input the SK0Z record has 01, the SG0V record has 02, the SF0Q record has 03 and the SD0A record has 04, whereas in the output the SG0V record has 01 and the SF0Q record has 02. Records have been omitted and the remaining records have been resequenced. So SEQNUM is needed on the OUTFIL statement or OUTREC statement to get the new sequence numbers.
I'd suggest that you actually test your "solutions" and compare your output to the stated output before you post. Throwing out "solutions" without verifying that they work just confuses people. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
You are right Frank, I really shouldn't post before my second cup of coffee I missed that sequence reference totally |
|
Back to top |
|
|
|