Page 1 of 1

Splitting the digits using COBOL

PostPosted: Fri Oct 14, 2011 11:48 am
by Santhya
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?

Re: Splitting the digits using COBOL

PostPosted: Fri Oct 14, 2011 12:04 pm
by enrico-sorichetti
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

Re: Splitting the digits using COBOL

PostPosted: Fri Oct 14, 2011 12:13 pm
by BillyBoyo
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).

Re: Splitting the digits using COBOL

PostPosted: Fri Oct 14, 2011 5:04 pm
by NicC
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.

Re: Splitting the digits using COBOL

PostPosted: Wed Oct 19, 2011 2:31 pm
by Santhya
Thanx for the reply.