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
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Moving an alphanumeric value and numeric value to 9(4)comp-5
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

Site Director


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

PostPosted: Thu Jun 04, 2009 6:42 am    Post subject:
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: 8055
Location: East Dubuque, Illinois, USA

PostPosted: Thu Jun 04, 2009 6:42 am    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Fri Jun 05, 2009 1:10 am    Post subject: Reply to: Moving an alphanumeric value and numeric value to
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri Jun 05, 2009 3:53 am    Post subject: Reply to: Moving an alphanumeric value and numeric value to
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    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 Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm


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