|
View previous topic :: View next topic
|
| Author |
Message |
mohammad amir ashraff
New User

Joined: 08 Feb 2008 Posts: 23 Location: Hyderabad
|
|
|
|
Hi,
I have a VB file of length 446 bytes (input file).
I need to extract a field SSN that is 9 bytes long and can occur anywhere from 40th byte onward to 110th byte onward in the file.
The SSN has to be extracted to an output file of length 9 bytes.
How can this be achieved using SORT.
Regards. |
|
| Back to top |
|
 |
vasanthz
Global Moderator

Joined: 28 Aug 2007 Posts: 1751 Location: Tirupur, India
|
|
|
|
Hello,
Show us how the input file will look like and the expected output.
Someone would be able to help you with that. |
|
| Back to top |
|
 |
mohammad amir ashraff
New User

Joined: 08 Feb 2008 Posts: 23 Location: Hyderabad
|
|
|
|
input file sample records
| Code: |
500400¦SQLLDR¦11-OCT-99¦SQLLDR¦11-OCT-99¦¦JKLMN¦M¦ABCDE¦¦¦¦13-JUN-40¦¦0¦¦¦¦7¦¦405541010¦¦KY¦¦¦¦¦
500401¦SQLLDR¦11-OCT-99¦AGL R=1203579¦15-FEB-02¦¦JKLMNO DIX¦¦ACDEF¦¦¦¦¦¦2¦¦¦¦7¦¦000000000¦¦MD¦¦¦¦¦
500402¦SQLLDR¦11-OCT-99¦SQLLDR¦11-OCT-99¦¦LMNOPQR¦S¦AEFGH¦¦¦¦04-MAR-46¦¦0¦¦¦¦7¦¦403627037¦¦KY¦¦¦¦¦
500403¦SQLLDR¦11-OCT-99¦BPSI404¦01-DEC-03¦¦STUVWX¦¦AGHIJ¦¦0¦0¦¦¦2¦0¦¦AHIJK¦7¦¦449683440¦¦CA¦¦¦¦¦
|
output file
| Code: |
405541010
000000000
403627037
449683440
|
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Looks like your data is "pipe-delimited" and you want the data after the 19th pipe?
You're going to need PARSE. Either with 18 dummy PARSE fields first, or you could FINDREP wth DO=18 to change the first 18 pipes to something else, then PARSE for the value you want. |
|
| Back to top |
|
 |
mohammad amir ashraff
New User

Joined: 08 Feb 2008 Posts: 23 Location: Hyderabad
|
|
|
|
| Yes Bill, the data is pipe-delimited and I need the SSN that occurs after the 20th pipe. |
|
| Back to top |
|
 |
mohammad amir ashraff
New User

Joined: 08 Feb 2008 Posts: 23 Location: Hyderabad
|
|
|
|
| Code: |
//SYSIN DD *
SORT FIELDS=COPY
INREC PARSE=(%00=(ENDBEFR=C'|',FIXLEN=15),
%01=(ENDBEFR=C'|',FIXLEN=30),
%02=(ENDBEFR=C'|',FIXLEN=08),
%03=(ENDBEFR=C'|',FIXLEN=30),
%04=(ENDBEFR=C'|',FIXLEN=08),
%05=(ENDBEFR=C'|',FIXLEN=15),
%06=(ENDBEFR=C'|',FIXLEN=30),
%07=(ENDBEFR=C'|',FIXLEN=30),
%08=(ENDBEFR=C'|',FIXLEN=45),
%09=(ENDBEFR=C'|',FIXLEN=30),
%10=(ENDBEFR=C'|',FIXLEN=15),
%11=(ENDBEFR=C'|',FIXLEN=15),
%12=(ENDBEFR=C'|',FIXLEN=08),
%13=(ENDBEFR=C'|',FIXLEN=100),
%14=(ENDBEFR=C'|',FIXLEN=01),
%15=(ENDBEFR=C'|',FIXLEN=17),
%16=(ENDBEFR=C'|',FIXLEN=15),
%17=(ENDBEFR=C'|',FIXLEN=50),
%18=(ENDBEFR=C'|',FIXLEN=15),
%19=(ENDBEFR=C'|',FIXLEN=02),
%20=(ENDBEFR=C'|',FIXLEN=20),
%21=(ENDBEFR=C'|',FIXLEN=40),
%22=(ENDBEFR=C'|',FIXLEN=02),
%23=(ENDBEFR=C'|',FIXLEN=02),
%24=(ENDBEFR=C'|',FIXLEN=15),
%25=(ENDBEFR=C'|',FIXLEN=15),
%26=(ENDBEFR=C'|',FIXLEN=20),
%27=(ENDBEFR=C'|',FIXLEN=08)),
BUILD=(%00,%20)
/* |
As per the suggestions received I'm using the above code for PARSING but I get an error stating:
| Code: |
WER276B SYSDIAG= 26020, 642272, 642272, 2255850
WER164B 8,876K BYTES OF VIRTUAL STORAGE AVAILABLE, MAX REQUESTED,
WER164B 0 BYTES RESERVE REQUESTED, 1,004K BYTES USED
WER146B 20K BYTES OF EMERGENCY SPACE ALLOCATED
WER108I SORTIN : RECFM=VB ; LRECL= 400; BLKSIZE= 27998
WER073I SORTIN : DSNAME=PSHAREH.OL9.TDRUN.SQ.CSTUPRX2.DASD
WER235A INREC RDW NOT INCLUDED
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
|
Please advise where do I need to ADD the 4 bytes to take into account the VB. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| First thing in your BUILD. (1,4,.....). |
|
| Back to top |
|
 |
mohammad amir ashraff
New User

Joined: 08 Feb 2008 Posts: 23 Location: Hyderabad
|
|
|
|
Thanks Bill. It worked. Appreciate your help.  |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Code: |
//SYSIN DD *
SORT FIELDS=COPY
INREC PARSE=(%00=(ENDBEFR=C'|',FIXLEN=15),
%=(ENDBEFR=C'|'),
%=(ENDBEFR=C'|'),
%=(ENDBEFR=C'|'),
%=(ENDBEFR=C'|'),
%=(ENDBEFR=C'|'),
%=(ENDBEFR=C'|'),
%=(ENDBEFR=C'|'),
%=(ENDBEFR=C'|'),
%=(ENDBEFR=C'|'),
%=(ENDBEFR=C'|'),
%=(ENDBEFR=C'|'),
%=(ENDBEFR=C'|'),
%=(ENDBEFR=C'|'),
%=(ENDBEFR=C'|'),
%=(ENDBEFR=C'|'),
%=(ENDBEFR=C'|'),
%=(ENDBEFR=C'|'),
%=(ENDBEFR=C'|'),
%=(ENDBEFR=C'|'),
%20=(ENDBEFR=C'|',FIXLEN=20)),
BUILD=(1,4,%00,%20)
/* |
Since you are not extracting data for most of your delimited columns, just skip over them with a %. Only "name" the onse you need. |
|
| Back to top |
|
 |
mohammad amir ashraff
New User

Joined: 08 Feb 2008 Posts: 23 Location: Hyderabad
|
|
|
|
| Cool, thanks for the tip, will implement it. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|