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

moving a non-numeric string to a numeric field


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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
Reply with quote

hi sree_sree_sree,

check out this link
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
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
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
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
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: 127
Location: kerala,india

PostPosted: Fri Dec 08, 2006 4:14 pm
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top