IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Separate numeric data from alphanumeric data


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
prudhvikumar

New User


Joined: 20 Mar 2007
Posts: 8
Location: hyderabad

PostPosted: Mon May 07, 2007 11:02 am
Reply with quote

Hi! i need your help
how to separate numeric data from alphanumeric data in cobol program
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Mon May 07, 2007 11:05 am
Reply with quote

what do you mean by 'separate', please post an example.
Back to top
View user's profile Send private message
prudhvikumar

New User


Joined: 20 Mar 2007
Posts: 8
Location: hyderabad

PostPosted: Mon May 07, 2007 11:54 am
Reply with quote

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
View user's profile Send private message
anand_sundaramurthy

New User


Joined: 07 May 2007
Posts: 12
Location: Chennai

PostPosted: Mon May 07, 2007 12:00 pm
Reply with quote

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
View user's profile Send private message
prudhvikumar

New User


Joined: 20 Mar 2007
Posts: 8
Location: hyderabad

PostPosted: Mon May 07, 2007 12:04 pm
Reply with quote

[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
View user's profile Send private message
anand_sundaramurthy

New User


Joined: 07 May 2007
Posts: 12
Location: Chennai

PostPosted: Mon May 07, 2007 12:11 pm
Reply with quote

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
View user's profile Send private message
prudhvikumar

New User


Joined: 20 Mar 2007
Posts: 8
Location: hyderabad

PostPosted: Mon May 07, 2007 12:13 pm
Reply with quote

no its is going to entred by the user
Back to top
View user's profile Send private message
anand_sundaramurthy

New User


Joined: 07 May 2007
Posts: 12
Location: Chennai

PostPosted: Mon May 07, 2007 12:23 pm
Reply with quote

if this is the case then am not sure about the solution for this...
Back to top
View user's profile Send private message
prudhvikumar

New User


Joined: 20 Mar 2007
Posts: 8
Location: hyderabad

PostPosted: Mon May 07, 2007 12:25 pm
Reply with quote

suppose it use to come in the sixth place then what will be the solution
Back to top
View user's profile Send private message
anand_sundaramurthy

New User


Joined: 07 May 2007
Posts: 12
Location: Chennai

PostPosted: Mon May 07, 2007 12:31 pm
Reply with quote

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
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Mon May 07, 2007 1:28 pm
Reply with quote

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
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Mon May 07, 2007 2:04 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon May 07, 2007 10:12 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to save SYSLOG as text data via P... All Other Mainframe Topics 2
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Store the data for fixed length COBOL Programming 1
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
Search our Forums:

Back to Top