maxsubrat
Active User
Joined: 27 Feb 2008 Posts: 110 Location: india
|
|
|
|
SORT a input file until some character found. suppose my input redcord is like that:
001 3456 bs road newdelhi 4000 pepsi 50000 77777 858585
Please see the above record.. and search the input record, if found the word pepsi in the input record, then write the record until pepsi to the output file. My output file would be:
001 3456 bs road newdelhi 4000 pepsi
like this we need to sort out our files. Record length is 100 and it is fixed. |
|
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
maxsubrat,
maxsubrat wrote: |
SORT a input file until some character found. suppose my input redcord is like that:
001 3456 bs road newdelhi 4000 pepsi 50000 77777 858585
Please see the above record.. and search the input record, if found the word pepsi in the input record, then write the record until pepsi to the output file.
...
Record length is 100 and it is fixed. |
I don't see SORTing requirement here. However, what if the word 'pepsi' occurs twice (or more than that) in the input record, do you want to select part of record until first occurrence? Also, what if the word 'pepsi' is not at all present in the input record?
I am not sure if below is exactly what you asked for but see if it works for you...If this is not what you want, please explain the rules in detail.
Code: |
//STEP0001 EXEC PGM=SORT
//SORTIN DD * /* YOUT INPUT FILE GOES HERE
001 3456 BS ROAD NEWDELHI 4000 PEPSI 50000 77777 858585
001 3456 BS ROAD NEWDELHI 4000 COKE 50000 77777 858585
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INCLUDE COND=(1,100,SS,EQ,C'PEPSI')
INREC IFTHEN=(WHEN=INIT,
PARSE=(%01=(ENDAT=C'PEPSI',FIXLEN=100)),
BUILD=(%01))
SORT FIELDS=COPY
/*
//SYSOUT DD SYSOUT=*
//*
|
OUTPUT-ASSUMING 100 BYTE
Code: |
001 3456 BS ROAD NEWDELHI 4000 PEPSI
|
Thanks, |
|