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

Numeric COMP-3 into Alphanumeric


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

New User


Joined: 25 Jul 2006
Posts: 23

PostPosted: Tue Apr 24, 2007 12:37 am
Reply with quote

Hi,

I have to move fieldA concatenated with field B into field C.

Field A -> S9(15)V COMP-3.
Field B -> SV9(11) COMP-3.
Field C -> X(100)

I have to add Field A and field B and move it into Field C. Please note that the sign is to be carried too. Please advise.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Apr 24, 2007 1:24 am
Reply with quote

gragha wrote:
Hi,

I have to move fieldA concatenated with field B into field C.

Field A -> S9(15)V COMP-3.
Field B -> SV9(11) COMP-3.
Field C -> X(100)

I have to add Field A and field B and move it into Field C. Please note that the sign is to be carried too. Please advise.
Which sign, field a's or field b's?
Back to top
View user's profile Send private message
gragha

New User


Joined: 25 Jul 2006
Posts: 23

PostPosted: Tue Apr 24, 2007 1:26 am
Reply with quote

Field A -> S9(15)V COMP-3.
Field B -> SV9(11) COMP-3.
Field C -> X(100)

I guess when you add it first, you will have only one sign. To make things clear, Field A to be added to Field B first and then the resultant value to be moved to Field C with the sign of the added value.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Apr 24, 2007 1:39 am
Reply with quote

Do you want to combined value to be displayable in field C? Or in COMP-3 format?
Back to top
View user's profile Send private message
gragha

New User


Joined: 25 Jul 2006
Posts: 23

PostPosted: Tue Apr 24, 2007 1:43 am
Reply with quote

Say Field A is -000000000000006
Say field B is +.12500000000

When you add WS-FIELD-ADD = Field A + Field B then the output is
-000000000000005.87500000000

I want Field C to contain -5.875 as the value. Field C is defined as X(100).
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Apr 24, 2007 1:45 am
Reply with quote

What format? Do you want to combined value to be displayable in field C? Or in COMP-3 format?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Apr 24, 2007 1:50 am
Reply with quote

Field A -> S9(15)V COMP-3.
Field B -> SV9(11) COMP-3.
Field C -> X(100).
Filler redefines Field C
Field Ad -> -9(15)V.
Filler pic x value '.'
Field Bd-> V9(11)-.
Move Field A to Field Ad
Move Field A to Field Ad
Display Field C
"-000000000000005.87500000000 "
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: Tue Apr 24, 2007 1:53 am
Reply with quote

Hello,

Please start over showing a few examples of the input fields and the desired output.

Initially concatenation is talked about, then addition is talked about.

What should happen when the first field is positive and the second field is negative?

Notice the number of digits before and after the implied decimals. It appears to me as though the result will possibly be a 26-digit number (usually 18 digits is the max for comp-3 data). When the "combined" output field is built, should there be a "real" decimal point in the field (i.e 123456789.9987654321)? Notice that my example has only 19 digits. What is to be done with this number once it is built?

If you show some example inputs and outputs, we will be better able to offer suggestions.
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: Tue Apr 24, 2007 1:58 am
Reply with quote

Hello again,

Looks like you were continuing while i was typing - sorry 'bout that, but the answers to the new questions may help. . .
Back to top
View user's profile Send private message
gragha

New User


Joined: 25 Jul 2006
Posts: 23

PostPosted: Tue Apr 24, 2007 2:02 am
Reply with quote

Sorry about the concatenation. The two fields should only be added and not concatenated. As in my example

Say Field A is -000000000000006
Say field B is +.12500000000

The combined O/P should be addition of these 2 fields which would give us an output of -000000000000005.87500000000. Then it should be reformatted so that it goes into a X(100) field with value -5.875

Please note that the sign should exist and the decimal point should be real and not assumed. If Field A is positive and field B is negative then also the process should add it and display the output.
Back to top
View user's profile Send private message
gragha

New User


Joined: 25 Jul 2006
Posts: 23

PostPosted: Tue Apr 24, 2007 2:13 am
Reply with quote

William,

I am not sure if it will work because we are not adding field A and field B and moreover we cannot have a value clause for a redefined variable in this case "Filler pic x value '.' ".

Please let me know if I am missing something.
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: Tue Apr 24, 2007 2:29 am
Reply with quote

Hello,

What is the maximum number of significant whole numbers and the maximum number of digits to the right of the decimal point that a result might have? Keep in mind that you want that number to be less than 18.

As requested earlier, please show several sets of input numbers and what the output should be from them. Importlantly, will the result ever have more than 18 total digits? From your single example, the result will only have a few digits. To give you a better answer, better data samples are needed.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Apr 24, 2007 3:18 am
Reply with quote

gragha wrote:
William,

I am not sure if it will work because we are not adding field A and field B
And what is the difference between adding and butting the two fields together where the low order byte of one is the decimal point and the high order byte of the other is the decimal point?
Quote:
and moreover we cannot have a value clause for a redefined variable in this case "Filler pic x value '.' ".
Good point:
Field A -> S9(15)V COMP-3.
Field B -> SV9(11) COMP-3.
Field C -> X(100).
Filler redefines Field C
Field Ad -> -9(15)V.
Field Bd-> .9(11)-.
Try that......BTW, if both fields could to be negative, you will have a sign at both ends of the number. Better logic would take into account where one is + and one id - or both are - or both or +....
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: Tue Apr 24, 2007 3:43 am
Reply with quote

Hello,

Concatenation with 2 signs (or even one) does not appear to be the desired solution. It will not give the required output.

The addition is "real" as the result should have one sign and be displayed as an edited result (i.e. -123.4567 or whatever).

As long as the result meets "edit" rules, it should be rather straight forward. I would think that a COMPUTE would do the trick. . .

We'll know more when the limits are posted. . .
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 COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Convert HEX to Numeric DB2 3
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Find a record count/numeric is multip... COBOL Programming 1
No new posts Interviewers are surprised with my an... Mainframe Interview Questions 6
Search our Forums:

Back to Top