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

Separate the numeric and alphabetic fields into 2 separate f


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
dilpreet

New User


Joined: 18 Mar 2008
Posts: 34
Location: INDIA

PostPosted: Tue Apr 21, 2009 12:17 am
Reply with quote

I have one alpha numeric variable of X(50)
I want to separate the numeric and alphabetic fields into 2 separate fields.
How will i do that?

E.G. variable A has value 'a124858sdsfg5525'
So B should have asdsfg
and C should have 1248585525
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Tue Apr 21, 2009 12:19 am
Reply with quote

What was your answer?
Back to top
View user's profile Send private message
ashishsr123

New User


Joined: 06 May 2008
Posts: 33
Location: Chennai

PostPosted: Tue Apr 21, 2009 12:23 am
Reply with quote

You can code a logic for it i have done it.. do not have the code right now..
But kind of simple..

Use a loop ,,take each character..use function Is numeric ...and if answer si true put it in in a numeric field otherwise put in a alphanumeric field.

U can use decimal system for storing digits in numeric field

Regards
AShish
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: Tue Apr 21, 2009 1:35 am
Reply with quote

Hello,

Quote:
U can use decimal system for storing digits in numeric field
What is "decimal system"?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Apr 21, 2009 2:18 am
Reply with quote

Since I am bored:

Code:

ws-alpha-numeric Pic X(50).
ws-hold-alpha  pic x(50) value spaces.
ws-hold-numeric pic x(50) value spaces.
ws-count-alpha  pic s9(3) comp value zero.
ws-count-numeric  pic s9(3) comp value zero.
ws-sub-prime  pic s9(3) comp.
ws-sub-alpha  pic s9(3) comp value 1.
ws-sub-numeric pic s9(3) comp value 1.

Perform varying ws-sub-prime
                 from 1
                    by 1
                 until ws-sub-prime > 50
   If ws-alpha-numeric(ws-sub-prime:1) = 0
   or ws-alpha-numeric(ws-sub-prime:1) = 9
   or (ws-alpha-numeric(ws-sub-prime:1) > 0
        and
       ws-alpha-numeric(ws-sub-prime:1) < 9)
   then
      move ws-alpha-numeric(ws-sub-prime:1) to ws-hold-numeric(ws-sub-numeric)
      add 1 to ws-sub-numeric
   else
      move ws-alpha-numeric(ws-sub-prime:1) to ws-hold-alpha(ws-sub-alpha)
      add 1 to ws-sub-alpha
   end-if
end-perform

IF ws-sub-alpha > 1
    compute ws-count-alpha = ws-sub-alpha - 1 end-compute
end-if

IF ws-sub-numeric > 1
    compute ws-count-numeric = ws-sub-numeric - 1 end-compute
end-if
.


if there are any numeric,
you can then NUMVAL from ws-hold-numeric to a numeric field.
Back to top
View user's profile Send private message
ashishsr123

New User


Joined: 06 May 2008
Posts: 33
Location: Chennai

PostPosted: Tue Apr 21, 2009 9:38 pm
Reply with quote

Quote:

U can use decimal system for storing digits in numeric field


Sorry for the confusion...i meant u can store numbers like(in case u have issues...) num1*10 + num*10*2 + num*10*3.......and so on...
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Apr 21, 2009 10:30 pm
Reply with quote

Quote:
Sorry for the confusion...i meant u can store numbers like(in case u have issues...) num1*10 + num*10*2 + num*10*3.......and so on..


you would do this only if you extracted the numbers from back to front,
and for the
units, you would specify num1*10**0
tens, num1*10**1
hundreds, num1*10**2

and not num1*10*1 which would be the number times 10
and not num1*10*2 which would be the number times 20

please be careful with your posts;
inaccuracy will wastes time.
(* means multiplication, ** is exponentiation)

and this is not a chat room.
take the time to accurately phrase your posts (use written english)
and use the preview button
the board actually added an edit post button
(yeah I like it too, keeps my flaming to a minimum)
because so many of the computer types here can't figure out how to proof their posts,
as in your case where you could not even explain what you were thinking.

Those are the only issues I have.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Tue Apr 21, 2009 10:37 pm
Reply with quote

Quote:
the board actually added an edit post button
(yeah I like it too, keeps my flaming to a minimum)
But the entertainment value goes down ... sigh icon_sad.gif
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 -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Convert HEX to Numeric DB2 3
No new posts Find a record count/numeric is multip... COBOL Programming 1
No new posts Concatenate 2 fields (usage national)... COBOL Programming 2
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
Search our Forums:

Back to Top