Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Separate numeric data from alphanumeric data

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Separate numeric data from alphanumeric data
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: 686
Location: Earth

PostPosted: Mon May 07, 2007 11:05 am    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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: 686
Location: Earth

PostPosted: Mon May 07, 2007 1:28 pm    Post subject:
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: 755
Location: Germany

PostPosted: Mon May 07, 2007 2:04 pm    Post subject:
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

Site Director


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

PostPosted: Mon May 07, 2007 10:12 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Group Data based on a key Arun Raj DFSORT/ICETOOL 7 Thu Apr 27, 2017 11:29 pm
No new posts unload data from table with lob columns farhad_evan DB2 0 Sat Apr 22, 2017 1:32 pm
No new posts SORT JSON type of data maxsubrat DFSORT/ICETOOL 8 Wed Apr 19, 2017 6:01 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us