String manupulation in JCL



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

String manupulation in JCL

Postby nikesh_rai » Fri Mar 08, 2013 4:30 pm

Hi,

I have a file with inputs like:

BIT-STRD-INFO
BIT-SEQ-NBR
TEL-LINE-NBR

and needs to process the input and output should be:

B-S-I
B-S-N
T-L-N


Can wo do this using Sort JCL or better to go with REXX...
Please suggest..

Thanks
Nikesh
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 205
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time

Re: String manupulation in JCL

Postby BillyBoyo » Fri Mar 08, 2013 4:39 pm

If you use PARSE with "-" to delimit the fields, you can then
  BUILD=(%00,2:C'-',%01,4:C'-',%03,6:75X)


That is for 80-byte records. If you want five bytes for your LRECL, then you might be able to use IFOUTLEN or another BUILD of 1,5.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: String manupulation in JCL

Postby nikesh_rai » Fri Mar 08, 2013 4:44 pm

Thanks Billy,

But the problem is variable string length, like

RATE-STRUC-ST-DT
PBE-INSTNC
BILG-ELMT-CAT-CODE


Which shoud be processed as

R-S-S-D
P-I
B-E-C-C
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 205
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time

Re: String manupulation in JCL

Postby enrico-sorichetti » Fri Mar 08, 2013 5:13 pm

did You care to read the <sort> manuals or search the forum for examples of the PARSE clause ???
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: String manupulation in JCL

Postby BillyBoyo » Fri Mar 08, 2013 5:31 pm

Well, you need enough PARSEd fields for your maximum number of elements, and only to put the "-" if the "next" PARSEd field is not equal to spaces.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: String manupulation in JCL

Postby nikesh_rai » Fri Mar 08, 2013 5:33 pm

I have already checked with PARSE and some manuals as well, but was not able to resolve my problem.
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 205
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time

Re: String manupulation in JCL

Postby enrico-sorichetti » Fri Mar 08, 2013 5:40 pm

You will need a two stage approach ...
PARSE to split the single tokens
<BUILD> to extract the first char
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: String manupulation in JCL

Postby BillyBoyo » Fri Mar 08, 2013 6:18 pm

Something like this, which is for "four-element" names, so note what happened to the last test data.

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,
                PARSE=(%00=(ENDBEFR=C'-',FIXLEN=1),
                       %01=(ENDBEFR=C'-',FIXLEN=1),
                       %02=(ENDBEFR=C'-',FIXLEN=1),
                       %03=(ENDBEFR=C'-',FIXLEN=1))),
        IFTHEN=(WHEN=INIT,
                BUILD=(%00,C'-',%01,C'-',%02,C'-',%03)),
        IFTHEN=(WHEN=(1,1,CH,EQ,C' '),
                OVERLAY=(2:79X)),
        IFTHEN=(WHEN=(3,1,CH,EQ,C' '),
                OVERLAY=(2:79X)),
        IFTHEN=(WHEN=(5,1,CH,EQ,C' '),
                OVERLAY=(4:77X)),
        IFTHEN=(WHEN=(7,1,CH,EQ,C' '),
                OVERLAY=(6:75X))
                                                       
//SORTIN   DD *
RATE-STRUC-ST-DT
PBE-INSTNC
BILG-ELMT-CAT-CODE
                                                       
TEST
TEST-TOST-TIST
1-2-3-4-5


Gives:

R-S-S-D
P-I   
B-E-C-C
       
T     
T-T-T 
1-2-3-4
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: String manupulation in JCL

Postby skolusu » Fri Mar 08, 2013 11:13 pm

BillyBoyo,

You can simplify the job using the parm "STARTAT" instead of "ENDBEFR" on PARSE and then pick the values. Makes it quite easy. :D Something like this

//STEP0100 EXEC PGM=SORT                               
//SYSOUT   DD SYSOUT=*                                 
//SORTIN   DD *                                       
RATE-STRUC-ST-DT                                       
PBE-INSTNC                                             
BILG-ELMT-CAT-CODE                                     
                                                       
TEST                                                   
TEST-TOST-TIST                                         
1-2-3-4-5                                             
//SORTOUT  DD SYSOUT=*                                 
//SYSIN    DD *                                       
  OPTION COPY                                         
  INREC PARSE=(%01=(ABSPOS=2,STARTAT=C'-',FIXLEN=2),   
               %02=(STARTAT=C'-',FIXLEN=2),           
               %03=(STARTAT=C'-',FIXLEN=2)),           
  BUILD=(1,1,%01,%02,%03)                             
//*


The output
R-S-S-D 
P-I     
B-E-C-C 
         
T       
T-T-T   
1-2-3-4 


You can use an OMIT condition to remove all spaces records.
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

These users thanked the author skolusu for the post:
BillyBoyo (Sat Mar 09, 2013 12:32 am)
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: String manupulation in JCL

Postby BillyBoyo » Sat Mar 09, 2013 12:06 am

Yes, that's much neater!
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Next

Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post