Splitting the Numbers alone from a given variable

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
karthik1681
Member
Posts: 1
Joined: Tue Aug 30, 2011 3:11 pm
Location: India

Splitting the Numbers alone from a given variable

Post by karthik1681 » Tue Sep 13, 2011 5:51 am

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
Thanks and Regards,

Karthikeyan Gunasekaran

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Tue Sep 13, 2011 10:12 pm

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)
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others