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
 
Numeric COMP-3 into Alphanumeric

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Numeric COMP-3 into Alphanumeric
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: 3158
Location: Tucson AZ

PostPosted: Tue Apr 24, 2007 1:24 am    Post subject: Re: Numeric COMP-3 into Alphanumeric
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    Post subject: Re: Numeric COMP-3 into Alphanumeric
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: 3158
Location: Tucson AZ

PostPosted: Tue Apr 24, 2007 1:39 am    Post subject:
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    Post subject: Re: Numeric COMP-3 into Alphanumeric
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: 3158
Location: Tucson AZ

PostPosted: Tue Apr 24, 2007 1:45 am    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Tue Apr 24, 2007 1:50 am    Post subject:
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

Site Director


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

PostPosted: Tue Apr 24, 2007 1:53 am    Post subject:
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

Site Director


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

PostPosted: Tue Apr 24, 2007 1:58 am    Post subject:
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    Post subject: Re: Numeric COMP-3 into Alphanumeric
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    Post subject: Re: Numeric COMP-3 into Alphanumeric
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

Site Director


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

PostPosted: Tue Apr 24, 2007 2:29 am    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Tue Apr 24, 2007 3:18 am    Post subject: Re: Numeric COMP-3 into Alphanumeric
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

Site Director


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

PostPosted: Tue Apr 24, 2007 3:43 am    Post subject:
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    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 CONDITIONAL USING COMP-2 WITH PROBLEMS. JOSUEGENTIL COBOL Programming 7 Wed Nov 08, 2017 11:13 pm
No new posts how can i move s9(9) to s9(9) usage comp HARENDRA CHOUDHARY COBOL Programming 3 Mon Nov 06, 2017 12:10 am
This topic is locked: you cannot edit posts or make replies. Can a alphanumeric data be moved to a... nico_neoz COBOL Programming 10 Mon Oct 30, 2017 8:28 am
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am

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