View previous topic :: View next topic
|
Author |
Message |
prudhvikumar
New User
Joined: 20 Mar 2007 Posts: 8 Location: hyderabad
|
|
|
|
Hi! i need your help
how to separate numeric data from alphanumeric data in cobol program |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
what do you mean by 'separate', please post an example. |
|
Back to top |
|
|
prudhvikumar
New User
Joined: 20 Mar 2007 Posts: 8 Location: hyderabad
|
|
|
|
example
suppose there is a pic x(20) in yhat we can enter both numeric and non numeric data.in this i need to separate numeric and non numeric |
|
Back to top |
|
|
anand_sundaramurthy
New User
Joined: 07 May 2007 Posts: 12 Location: Chennai
|
|
|
|
Hi,
i would like to help you.
can tell me whether you know the exact position where the numeric portion is gonna come? |
|
Back to top |
|
|
prudhvikumar
New User
Joined: 20 Mar 2007 Posts: 8 Location: hyderabad
|
|
|
|
[quote="anand_sundaramurthy"]Hi,
i would like to help you.
can tell me whether you know the exact position where the numeric portion is gonna come?
in the output i want to get the numeric data separately |
|
Back to top |
|
|
anand_sundaramurthy
New User
Joined: 07 May 2007 Posts: 12 Location: Chennai
|
|
|
|
no i mean to say...say for ex u hav pic x(10) in these ten positions is it like you know the exact positions where you know the numeric part is gonna come?or it is entered by the user? |
|
Back to top |
|
|
prudhvikumar
New User
Joined: 20 Mar 2007 Posts: 8 Location: hyderabad
|
|
|
|
no its is going to entred by the user |
|
Back to top |
|
|
anand_sundaramurthy
New User
Joined: 07 May 2007 Posts: 12 Location: Chennai
|
|
|
|
if this is the case then am not sure about the solution for this... |
|
Back to top |
|
|
prudhvikumar
New User
Joined: 20 Mar 2007 Posts: 8 Location: hyderabad
|
|
|
|
suppose it use to come in the sixth place then what will be the solution |
|
Back to top |
|
|
anand_sundaramurthy
New User
Joined: 07 May 2007 Posts: 12 Location: Chennai
|
|
|
|
the u can use the move command..
for ex
MOVE WS-PAY-DATE (1:4) TO WS-YEAR1
here 1 is the starting position from the ws variable and 4 is the no of char to be moved...its similar to a substring in our java |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Quote: |
suppose it use to come in the sixth place then what will be the solution |
By" Sixth place" you mean 6th byte of variable or sixth time when you get data in your variable? |
|
Back to top |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
Hi !
In case, that you can enter Char and Num Data in one Field in any order, you have to test each byte separatly from the beginning to the end of that field to separate chars from numerical data.
For ex, Field looks like: AB12CDE45F9Z
Separation -> Field-CAR: ABCDEFZ & Field-NUM: 12459
Move that field to an other field, which is one-byte-indexed.
01 Input-Area
05 Input-Field-01 pic x(20)
05 Input-Field-02 pic x(10)
05 Field-Car-Num redefines Input-Field-02
10 Byte-Car-Num occurs 10 indexed by Byte-Ind
15 Byte pic x(01)
Then test teh string byte by byte with a littel lazy loop.
perform until byte-ind > 10
if byte(byte-ind) numeric
move byte(byte-ind) to Num-Field
else
move byte(byte-ind) to Car-Field
end-if
set byte-ind up by 1
end-perform
Regards, UmeySan |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Please post some samples of data that a user might enter and what you want the code to do with that input.
Your request as posted is unclear.
Quote: |
how to separate numeric data from alphanumeric data in cobol program
|
If the field contains both numeric and non-numeric data (say 12cv4n4ff5) do you want something done with both the numerals and the letters? What should the output from that "input value" look like? |
|
Back to top |
|
|
|