## Splitting the digits using COBOL

### Splitting the digits using COBOL

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
Santhya

Posts: 7
Joined: Tue Oct 04, 2011 12:20 pm
Has thanked: 0 time
Been thanked: 0 time

### Re: Splitting the digits using COBOL

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
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: 2790
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 148 times

### Re: Splitting the digits using COBOL

If I understand correctly:

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).

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).
BillyBoyo
Global moderator

Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

### Re: Splitting the digits using COBOL

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
NicC
Global moderator

Posts: 2820
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 118 times

### Re: Splitting the digits using COBOL

Regards,
Santhya
Santhya

Posts: 7
Joined: Tue Oct 04, 2011 12:20 pm
Has thanked: 0 time
Been thanked: 0 time