Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
moving a non-numeric string to a numeric field

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sree_sree_sree

New User


Joined: 30 Aug 2006
Posts: 13

PostPosted: Tue Dec 05, 2006 7:23 pm    Post subject: moving a non-numeric string to a numeric field
Reply with quote

Hi,

As per the below logic, will this code work...
Please let me know how many people agree with below coding..
icon_redface.gif

WORKING-STORAGE SECTION.
01 EBBA PIC X(3) VALUE 'CDE'.
01 EBB1 PIC 9(3).
01 EBB2 PIC 9(3).
PROCEDURE DIVISION.
MOVE EBBA TO EBB1.
DISPLAY 'VALUES',EBBA,EBB1,EBB2.
STOP RUN.
Back to top
View user's profile Send private message

DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Tue Dec 05, 2006 8:35 pm    Post subject: Re: cobpl code
Reply with quote

sree_sree_sree,

Whether this code works or not is determinant upon what you expect it to do.

If you mean, will this code cause the program to abend, the answer is no, it will not abend.

I don?t see a rational reason is for moving a non-numeric string to a numeric field however. What are you trying to accomplish with this move?

Dave
Back to top
View user's profile Send private message
sree_sree_sree

New User


Joined: 30 Aug 2006
Posts: 13

PostPosted: Wed Dec 06, 2006 12:39 pm    Post subject:
Reply with quote

Hi David,

Thanks for responce..

As per my knowledge on SCO7, if we move any non numeric data to numeric data then we will get this abend..I am trying to get an abend SOC7 intentionally to research on this but my code works fine.. thats what iam wondering...

the out put which i have got from the above logic is
DISPLAY 'VALUES',EBBA,EBB1,EBB2.
VALUESCDECD5

Here iam moving non- numeric to numeric and it should not work..
Please let me know once for me
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Wed Dec 06, 2006 1:28 pm    Post subject: Re: Will the following COBOL code work
Reply with quote

hi sree_sree_sree,

check out this link
http://www.csis.ul.ie/COBOL/Course/COBOLcommands.htm

search for MOVE combinations in the same page.

u will get the combinations of valid moves
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Wed Dec 06, 2006 3:12 pm    Post subject: Re: Will the following COBOL code work
Reply with quote

valid movements listed in the attachment
Back to top
View user's profile Send private message
tasneem

New User


Joined: 22 Nov 2006
Posts: 3
Location: Pune

PostPosted: Wed Dec 06, 2006 3:25 pm    Post subject: Re: Will the following COBOL code work
Reply with quote

Hi,

The code snippet written will work fine. MOVE statement will not give a SOC7 abend. If any subsequent arithmetic operation is performed on variable EBB1, this would result in a SOC7 abend.

Correct me if wrong.

Thanks,
Tasneem
Back to top
View user's profile Send private message
karthick Raja

New User


Joined: 10 Aug 2006
Posts: 8

PostPosted: Thu Dec 07, 2006 6:40 pm    Post subject: Re: Will the following COBOL code work
Reply with quote

Hi,

But this code will not abend even if you have a conditional check.
when you move spaces to numeric and then have a conditional check it will give SOC 7. In this case that 'CDE' will be dealt as 345(C3C4C5) and will be processed. I am not sure what that conversion C to C3 is?

But even when you display and check you will get CDE only and not 345.
I dont get how it is.. can any one explain?
Back to top
View user's profile Send private message
Samir H. Jibhakate

New User


Joined: 10 Nov 2006
Posts: 1
Location: Pune

PostPosted: Fri Dec 08, 2006 2:56 pm    Post subject: Re: Will the following COBOL code work
Reply with quote

Hi This is sam! this code will not work. it will give errer i.e. SOC7.
Bcz u r moving alphanumeric item to numeric and this is not possible in Cobol.
Back to top
View user's profile Send private message
cobolunni

Active User


Joined: 07 Aug 2006
Posts: 128
Location: kerala,india

PostPosted: Fri Dec 08, 2006 4:14 pm    Post subject:
Reply with quote

hello samir which version of cobol you are using
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Fri Dec 08, 2006 5:48 pm    Post subject:
Reply with quote

cobolunni,
that was good que...
b'cos i tested the prog with cobol '85 and it was working fine....
Back to top
View user's profile Send private message
Nighthawk750

New User


Joined: 04 Nov 2006
Posts: 20
Location: Amsterdam

PostPosted: Fri Dec 08, 2006 10:41 pm    Post subject: Re: Will the following COBOL code work
Reply with quote

karthick Raja wrote:
Hi,

But this code will not abend even if you have a conditional check.
when you move spaces to numeric and then have a conditional check it will give SOC 7. In this case that 'CDE' will be dealt as 345(C3C4C5) and will be processed. I am not sure what that conversion C to C3 is?

But even when you display and check you will get CDE only and not 345.
I dont get how it is.. can any one explain?


It is true that the program is not abending. However, the fact that the program seems to be working fine does not mean that everything is working correctly.
What happens is that 'CDE" is converted. If you look (for example via Xpediter) in the actual values of the numerical field, you will see that it contains
CCF
345

C3 is the EBCDIC value for C
C4 is the EBCDIC value for D
And the F5 is a non-numerical representation of the number 5. That is because the 'E' is seen as a sign. (A=1, B=2, C=3, D=4 E=5 etc).

Confusing? yeah. Even when I write this down it is confusing me. icon_biggrin.gif
But this perfectly demonstrates that you realy have to know what you are coding. Returncode zero does not always mean that everyting went as expected.

Hope this clarifies things a bit.
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 Search for a string in many PDS KARTHIGADEVI CLIST & REXX 5 Fri Sep 08, 2017 2:32 pm
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am
No new posts JES2 job size field matching Windows ... SRICOBSAS All Other Mainframe Topics 4 Tue Sep 05, 2017 5:49 pm
No new posts Return a Non Numeric value from REXX Learncoholic CLIST & REXX 3 Fri Sep 01, 2017 8:33 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us