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

Moving an alphanumeric value and numeric value to 9(4)comp-5


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
kamesh20

New User


Joined: 07 Mar 2007
Posts: 2
Location: Mumbai

PostPosted: Thu Jun 04, 2009 6:12 am
Reply with quote

Hi,

We have a calling program that has the variable declared as x(5) - say it is 'A'.

we move the value of this variable to a 9(4) comp-5 variable - say it is 'B'.

We pass the variable 'B' to the called program and move it to a variable x(4)- say it is 'C'.

The problem is coming for the below cases:
For example -
'A' has two values - 1)T020
2)58132

When we are moving these values to the variable B it has the value E314 for the above two values of A also.

In the called program when we are moving this B (E314) to the variable C, the C(1:1) has the value 'T' (equal to char form of 'E3') for both the values of A (T020, 58132).

But we want to know what is the actual value came in (whether it is T020 or 58132)

Please let me know if there is a way..

Constarints:
Pass area to the called program can not be increased or changed.
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: Thu Jun 04, 2009 6:42 am
Reply with quote

Hello,

Quote:
we move the value of this variable to a 9(4) comp-5 variable - say it is 'B'.
Why?

Quote:
We pass the variable 'B' to the called program and move it to a variable x(4)- say it is 'C'.
Again, why. . .?

Quote:
For example -
'A' has two values - 1)T020
2)58132
Valu one is missing one byte. . . the field is x(5).

What you are trying to do is confusing - at best. A value is a value is a value.
Each byte have a hex pattern from x'00' to x'ff'. How you choose to use them is your choice. An x'e3' is an x'e3' or a decimal 227. An x'e314' is decimal 58132.

From the data there is no way to know the "intent".

Suggest someone concern them self with cleaning up this code.

You might consider multiple entry points into the called module - one for each "use" of the data. . .

If you explain what the process is supposed to accomplish, someone may have a suggestion.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Thu Jun 04, 2009 6:42 am
Reply with quote

Although your explanation is not entirely clear to me, I do not believe that what you want to know can be determined. x'E314' is a COMP-5 variable that can also be represented as character 'T?' where the ? is a hex 14 (decimal 20) value. The power of COMP-5 is that any pattern of bits represents a valid number. The downside of COMP-5 is that you cannot tell if the variable started as a number such as 58132 or as a character string 'T?' without recourse to external data telling you which format to use.
Back to top
View user's profile Send private message
kamesh20

New User


Joined: 07 Mar 2007
Posts: 2
Location: Mumbai

PostPosted: Thu Jun 04, 2009 8:13 pm
Reply with quote

Hi Dick and Robert,

Yes i know it is very confusing and bit difficult to put on a paper.

The code was written a way back and the issue came up now. May be we have to change the design now..

Thanks for your time and sorry for trouble if any.
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: Fri Jun 05, 2009 1:10 am
Reply with quote

You're welcome - and no trouble icon_smile.gif

Given the constraints, not much more we could offer.

If there are questions, do post them - we can work on making them more understandable if needed icon_wink.gif

d
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Fri Jun 05, 2009 3:53 am
Reply with quote

Have you considered using EXTERNAL WORKING-STORAGE (introduced with VS/COBOL II some 20+ years ago), which must be defined exactly the same in both the Calling program and the Called program (in fact, all programs within the run-unit) and is addressable by all programs within the run-unit?

Then, the parmlist doesn't need to be changed and the sub-program can address this EXTERNAL WS directly, after being populated by the calling-program. Just a little bit of logic change here and there, in both programs and you're done! No conversion required or any type of value "subtlety" to consider.

Although some may perceive this approach as merely a "bandaid", using EXTERNAL WS has saved my A$$ several times.... icon_biggrin.gif

Regards,
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 COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts Convert HEX to Numeric DB2 3
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
Search our Forums:

Back to Top