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 the numeric and alphabetic fields into 2 separate f

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
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    Post subject: Separate the numeric and alphabetic fields into 2 separate f
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: 8055
Location: East Dubuque, Illinois, USA

PostPosted: Tue Apr 21, 2009 12:19 am    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Tue Apr 21, 2009 1:35 am    Post subject:
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: 6967
Location: porcelain throne

PostPosted: Tue Apr 21, 2009 2:18 am    Post subject:
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    Post subject:
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: 6967
Location: porcelain throne

PostPosted: Tue Apr 21, 2009 10:30 pm    Post subject:
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: 8055
Location: East Dubuque, Illinois, USA

PostPosted: Tue Apr 21, 2009 10:37 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions 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 Sum Fields ballaswaroop DFSORT/ICETOOL 4 Tue May 02, 2017 11:07 am
No new posts DFSORT MUL FIELDS tspr52 DFSORT/ICETOOL 16 Fri Mar 03, 2017 11:53 pm
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm
No new posts Sort two file having same field, one ... himanshu malik DFSORT/ICETOOL 7 Thu Feb 02, 2017 10:09 am


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