IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Convert a field into single character


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
essence21

New User


Joined: 05 Dec 2008
Posts: 20
Location: mumbai

PostPosted: Tue Dec 01, 2009 4:21 pm
Reply with quote

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 icon_smile.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Dec 01, 2009 4:30 pm
Reply with quote

yes
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Dec 01, 2009 4:33 pm
Reply with quote

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
View user's profile Send private message
essence21

New User


Joined: 05 Dec 2008
Posts: 20
Location: mumbai

PostPosted: Tue Dec 01, 2009 4:46 pm
Reply with quote

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
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Dec 01, 2009 4:55 pm
Reply with quote

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
View user's profile Send private message
essence21

New User


Joined: 05 Dec 2008
Posts: 20
Location: mumbai

PostPosted: Tue Dec 01, 2009 5:03 pm
Reply with quote

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
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Dec 01, 2009 5:41 pm
Reply with quote

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
View user's profile Send private message
essence21

New User


Joined: 05 Dec 2008
Posts: 20
Location: mumbai

PostPosted: Tue Dec 01, 2009 5:52 pm
Reply with quote

Absolutely brilliant Sambhaji,

Works great !! icon_biggrin.gif

But could you also show me the parse method..

It would be great if there was an alternative.
Back to top
View user's profile Send private message
essence21

New User


Joined: 05 Dec 2008
Posts: 20
Location: mumbai

PostPosted: Tue Dec 01, 2009 6:09 pm
Reply with quote

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
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Dec 01, 2009 6:26 pm
Reply with quote

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
View user's profile Send private message
essence21

New User


Joined: 05 Dec 2008
Posts: 20
Location: mumbai

PostPosted: Thu Dec 03, 2009 9:11 am
Reply with quote

Thanks a lot... It works fine this way... icon_smile.gif
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Thu Dec 03, 2009 10:27 am
Reply with quote

You are welcome.. icon_smile.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts How to append a PS file into multiple... JCL & VSAM 3
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
No new posts Submit multiple jobs from a library t... JCL & VSAM 14
Search our Forums:

Back to Top