Page 1 of 1

Splitting the Numbers alone from a given variable

Posted: Tue Sep 13, 2011 5:51 am
by karthik1681
I have a task in which we have to spilt the Variable into two .

The length of the address 2 variable is X(32)

in this case its starting position is 42 .

i have an input file which looks like this

Code: Select all

Account number        address line 1              address line 2 

123456789              velan nagar               chennai12345

123456453              mahalakshmi st          delhi5678

012345653              brindhavan nagar        mumbai45678

I have to spilt the Address line 2 into two . say that the numbers in the adress line 2 represents pincode. I have to spilt that from the above scenario and should be displayed after two blanks.

The desired output will look like this

Code: Select all

Account number        address line 1              address line 2 

123456789                veloan nagar               chennai              12345

123456453                 mahalakshmi st          delhi                   5678

012345653                 brindhavan nagar        mumbai                  45678
I tried in cobol by calculating the length of the variable and using inspect just want to know is there a way to figure this out in DFSORT or SYNCSORT.

Thanks in advance.

Karthik. G

Posted: Tue Sep 13, 2011 10:12 pm
by Frank Yaeger
You can use a DFSORT job like the following to do what you asked for. Adjust FIXLEN accordingly for the maximum length of the two fields to be split.

Code: Select all

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
123456789              velan nagar       chennai12345
123456453              mahalakshmi st    delhi5678
012345653              brindhavan nagar  mumbai45678
//SORTOUT DD SYSOUT=*
//SYSIN DD *
  OPTION COPY
  INREC PARSE=(%01=(ABSPOS=42,
     ENDBEFR=C'0',ENDBEFR=C'1',ENDBEFR=C'2',
     ENDBEFR=C'3',ENDBEFR=C'4',ENDBEFR=C'5',ENDBEFR=C'6',
     ENDBEFR=C'7',ENDBEFR=C'8',ENDBEFR=C'9',FIXLEN=25),
       %02=(FIXLEN=10)),
     BUILD=(1,41,%01,%02)
/*