Splitting the digits using COBOL

Santhya
Posts: 7
Joined: Tue Oct 04, 2011 12:20 pm
Skillset: Cobol
Referer: Internet

Splitting the digits using COBOL

Postby Santhya » Fri Oct 14, 2011 11:48 am

I have set of 10-digit numbers as input and i need to check only the first 2 digits of it whether it has changed or not. Rest will be unchnged. How can i split-up the digits using COBOL?
Regards,
Santhya

enrico-sorichetti
Global moderator
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Skillset: tso,rexx,assembler,pl/i,storage,mvs,os/390,z/os,
Referer: www.ibmmainframes.com

Re: Splitting the digits using COBOL

Postby enrico-sorichetti » Fri Oct 14, 2011 12:04 pm

using COBOL or anything programmable ( even a hand calculator ) the logic would be the same

isnt' that a pretty basic arithmetic question ?...
did You ever hear of something called division/dividend/divisor/quotients/reminder :D
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

BillyBoyo
Global moderator
Posts: 3805
Joined: Tue Jan 25, 2011 12:02 am
Skillset: Easytrieve Plus, Cobol, Utilities, that sort of stuff
Referer: Google

Re: Splitting the digits using COBOL

Postby BillyBoyo » Fri Oct 14, 2011 12:13 pm

If I understand correctly:

Code: Select all

01  TEN-DIGIT-NUMBER.
    05  TDN-FIRST-TWO PIC XX.
    05  TDN-LAST-EIGHT PIC X(8).


Study the manuals about how to define data, REDEFINES can also be very useful for this sort of task (and could be used for your requirement).

Code: Select all

01  TEN-DIGIT-NUMBER PIC X(10).
01  FILLER REDEFINES TEN-DIGIT-NUMBER.
    05  FIRST-TWO-OF-TEN-DIGIT-NUMBER PIC XX.
    05  FILLER PIC X(8).

NicC
Global moderator
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Skillset: JCL, PL/1, Rexx, Utilities and to a lesser extent (i.e. I have programmed using them) COBOL,DB2,IMS
Referer: Google
Location: Pushing up the daisies (almost)

Re: Splitting the digits using COBOL

Postby NicC » Fri Oct 14, 2011 5:04 pm

Do not look at it as though you have a 10 digit number but rather as a 2 digit number followed immediately by an 8 digit number or any other combination that meets your requirement.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic

Santhya
Posts: 7
Joined: Tue Oct 04, 2011 12:20 pm
Skillset: Cobol
Referer: Internet

Re: Splitting the digits using COBOL

Postby Santhya » Wed Oct 19, 2011 2:31 pm

Thanx for the reply.
Regards,
Santhya