View previous topic :: View next topic
|
Author |
Message |
essence21
New User
Joined: 05 Dec 2008 Posts: 20 Location: mumbai
|
|
|
|
Hi,
Is there any i can convert the below file as given
Input
AAAAA,Tom
BBBB,Bell
CCCC,Com
Ouput
AAAAA,T
BBBB,B
CCCC,D
However pls note that I am just converting the second field with some predefined values. Basically it can be an if/then structure.
Is this possible?
Thanks |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
yes |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Because the solution for sort related questions may vary from product to product, please ensure that you state clearly which sort product you are using.
If you are not sure, then by running a simple sort step shown below, you will be able to find out for yourself.
If the messages start with ICE then your product is DFSORT. Please also post the output of the complete line which has a message code ICE201I, as this will enable our DFSORT experts to determine which release of DFSORT that you have installed. This may also affect the solution offered.
If the messages start with WER or SYT then the product is SYNCSORT and should be posted in the JCL forum. Please also post the information telling which version of SYNCSORT is installed, as this may also affect the solution offered.
Thank you for taking your time to ensure that the valuable time of others is not wasted by offering inappropriate solutions which are not relevant due to the sort product being used and/or the release that is installed in you site.
Code: |
//SORTSTEP EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
ABC
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY |
You also need to provide more detail than you already have.
What is the DSORG, RECFM & LRECL of the input and output files.
This is a link to the DFSORT smart tricks documentation which has examples of doing a great many things using DFSORT and ICETOOL. I do not know if the solution you are searching is contained in here, but this is a highly useful piece of documentation which may be invaluable in the future for other requirements.
Please click HERE to access it. |
|
Back to top |
|
|
essence21
New User
Joined: 05 Dec 2008 Posts: 20 Location: mumbai
|
|
|
|
Hi Expat,
All the messages start with ICE. So DFSORT is used. Here are the mesages you asked for.
ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R10
ICE201I F RECORD TYPE IS F - DATA STARTS IN POSITION 1
RECFM will be FB and since this is just in design we could take sample LRECL of Input as 10 and that of output is also 10 |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Quote: |
However pls note that I am just converting the second field with some predefined values. |
Can you please expain the rules for this(predefine values) |
|
Back to top |
|
|
essence21
New User
Joined: 05 Dec 2008 Posts: 20 Location: mumbai
|
|
|
|
hey Sambhaji,
The values are not fixed yet but for now lets take 4 values and their corresponding 1 characters as follows;
TOMMY -> T
RICHARD -> R
TOMAS -> M
ROLAND -> N |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
if these names are not going to be there in the record anywhere else then below code will work for you.
Or else we have to use parse first. Let us know if this suffice your requirement.
NOREP will not be replaced as we haven't mentioned it in FINDREP
Code: |
//S1 EXEC PGM=SORT
//SORTIN DD *
AAAAA,TOMMY
BBBB,ROLAND
CCCC,NOREP
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTREC FINDREP=(INOUT=(C'TOMMY',C'T',C'RICHARD',C'R',
C'TOMAS',C'M',C'ROLAND',C'N'))
/*
|
|
|
Back to top |
|
|
essence21
New User
Joined: 05 Dec 2008 Posts: 20 Location: mumbai
|
|
|
|
Absolutely brilliant Sambhaji,
Works great !!
But could you also show me the parse method..
It would be great if there was an alternative. |
|
Back to top |
|
|
essence21
New User
Joined: 05 Dec 2008 Posts: 20 Location: mumbai
|
|
|
|
Sambhaji,
Small problem i just noticed
for eg if I have similar strings like TOM and TOMMY and converting them by your method
EG., TOM with T and TOMMY with X gettin incorrect output
TOM gets converted to T perfectly but for TOMMY i get output as TMY.
I feel that the first replace command does (TOM)MY into (T)MY so the later replacement does not work...
Any suggestions? |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Use C'TOMMY',C'X' first and then C'TOM',C'T' in FINDREP
Similarly C'TOMAS',C'M', is also before C'TOM',C'T'
Like
Code: |
//SYSIN DD *
OPTION COPY
OUTREC FINDREP=(INOUT=(C'TOMMY',C'X',C'RICHARD',C'R',
C'TOMAS',C'M',C'TOM',C'T',C'ROLAND',C'N'))
/*
|
|
|
Back to top |
|
|
essence21
New User
Joined: 05 Dec 2008 Posts: 20 Location: mumbai
|
|
|
|
Thanks a lot... It works fine this way... |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
You are welcome.. |
|
Back to top |
|
|
|