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
 

 

Getting data issue in Moving edited Numeric to Numeric field

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Rajeev_mainframe

New User


Joined: 21 Aug 2006
Posts: 13

PostPosted: Thu Jul 09, 2009 12:17 am    Post subject: Getting data issue in Moving edited Numeric to Numeric field
Reply with quote

Hi,
I am using enterprise cobol compiler and have a problem in moving data from edited-numeric to numeric field. The input output filed declaration is

Input
05 WS-I-AVG-COST-PER-SHARE PIC -9(08).9(07).

output
05 WS-O-AVG-COST-PER-SHARE-SIGN PIC X(01).
05 WS-O-AVG-COST-PER-SHARE PIC 9(10).9(6).

Code:
INITIALIZE WS-COUNT.
INSPECT WS-I-AVG-COST-PER-SHARE
TALLYING WS-COUNT FOR ALL '-'
IF WS-COUNT > 0
MOVE '-' TO WS-O-AVG-COST-PER-SHARE-SIGN
ELSE
MOVE '+' TO WS-O-AVG-COST-PER-SHARE-SIGN
END-IF.
DISPLAY 'WS-I-AVG-COST-PER-SHARE: ' WS-I-AVG-COST-PER-SHARE.
INSPECT WS-I-AVG-COST-PER-SHARE REPLACING ALL " " BY "0".
DISPLAY 'WS-I-AVG-COST-PER-SHARE: ' WS-I-AVG-COST-PER-SHARE.
MOVE WS-I-AVG-COST-PER-SHARE TO WS-O-AVG-COST-PER-SHARE.

The output values are coming as:
WS-I-AVG-COST-PER-SHARE: 100.000000
WS-I-AVG-COST-PER-SHARE: 0000000100.000000
WS-O-AVG-COST-PER-SHARE: 0000000010.00000

can anyone advise me on the solution to this. The value of 100 is truncated to 10 in the output.

Thanks,
Rajeev
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jul 09, 2009 12:26 am    Post subject:
Reply with quote

you are moving a numeric edit mask to a numeric edit mask. both are x type.
Back to top
View user's profile Send private message
Rajeev_mainframe

New User


Joined: 21 Aug 2006
Posts: 13

PostPosted: Thu Jul 09, 2009 1:06 am    Post subject:
Reply with quote

Yes I see that, but I am moving some other values in the same fashion and getting the data before and after decimal without truncation.
example:
05 WS-I-FX-RATE PIC -9(06).9(09).
05 WS-O-FX-RATE-SIGN PIC X(01).
05 WS-O-FX-RATE PIC 9(07).9(9).

code:
INITIALIZE WS-COUNT.
INSPECT WS-I-FX-RATE
TALLYING WS-COUNT FOR ALL '-'
IF WS-COUNT > 0
MOVE '-' TO WS-O-FX-RATE-SIGN
ELSE
MOVE '+' TO WS-O-FX-RATE-SIGN
END-IF.
INSPECT WS-I-FX-RATE REPLACING ALL " " BY "0".
MOVE WS-I-FX-RATE TO WS-O-FX-RATE.

Values:
WS-I-FX-RATE: 1.000000000
WS-O-FX-RATE: 0000001.000000000
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jul 09, 2009 1:24 am    Post subject:
Reply with quote

The output values are coming as:
Quote:
WS-I-AVG-COST-PER-SHARE: 100.000000
WS-I-AVG-COST-PER-SHARE: 0000000100.000000
WS-O-AVG-COST-PER-SHARE: 0000000010.00000

this does not jive with the definition: (actually it is BS)
Quote:
WS-I-AVG-COST-PER-SHARE PIC -9(08).9(07).


you could never have moved anything numeric to the edit-mask WS-I-AVG-COST-PER-SHARE
and have a resultant value 100.000000

Quote:
edited-numeric to numeric field

and this is incorrect. you are moving edited-numeric to edited-numeric.

had your original edit-mask display been correct,
I would have explained what is going on.

but you have an unobtainable value to start with.
you are probably redefining edit-masks (and failed to show us)
or you are not cutting and pasting but typing in your data.

I can't help you.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7933
Location: Bellevue, IA

PostPosted: Thu Jul 09, 2009 1:24 am    Post subject:
Reply with quote

Your data is not consistent with your PICTURE clauses. I tested with a value of 123.4567891 using your variable definitions and PROCEDURE DIVISION statements and do not see the results you're getting. Nor are your results in line with the COBOL Language Reference, section 6.2.24.1.1 Elementary Move Rules, which says in part
Quote:
Numeric or numeric-edited:

* Except when zeros are replaced because of editing requirements, alignment by decimal point and any necessary zero filling take place, as described under "Alignment rules" in topic 5.1.6.8.

* If the receiving item is signed, the sign of the sending item is placed in the receiving item, with any necessary sign conversion. If the sending item is unsigned, a positive operational sign is generated for the receiving item.

* If the receiving item is unsigned, no operational sign is generated for the receiving item and the absolute value of the sending item is used in the move.

* When the category of the sending item is alphanumeric, alphanumeric-edited, national, or national-edited, the data is moved as if the sending item were described as an unsigned integer.

* When the sending item is floating-point, the data is first converted to either a binary or internal decimal representation and is then moved.

* When the receiving item is numeric-edited, editing takes place as defined by the picture character string or BLANK WHEN ZERO clause associated with the receiving item.

* When the sending item is numeric-edited, the compiler de-edits the sending data to establish the unedited value of the numeric-edited item (this value can be signed). The unedited numeric value is used in the move to the receiving numeric or numeric-edited data item.
The output with input of +123.4567891 is 0000000123.456789 -- just what was expected based upon your variable definitions.
Back to top
View user's profile Send private message
Rajeev_mainframe

New User


Joined: 21 Aug 2006
Posts: 13

PostPosted: Thu Jul 09, 2009 2:39 am    Post subject:
Reply with quote

I managed to resolve it by moving the input read value to a temprory variable of PIC X(17) and then moving it to output variable through NUMVAL

COMPUTE WS-O-AVG-COST-PER-SHARE = FUNCTION NUMVAL
(WS-TEMP-SHARE-VALUE).
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 Storing huge volume of data, compare ... Pradeep K M All Other Mainframe Topics 3 Mon Jan 16, 2017 5:08 pm
No new posts how to recover an uncataloged VSAM da... archanamuthukrishnan All Other Mainframe Topics 3 Wed Jan 11, 2017 6:18 pm
No new posts INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts HALDB data refresh/copy from producti... vineetanand2007 IMS DB/DC 1 Mon Jan 02, 2017 11:16 am
No new posts JES2 JEC: Use UNIX Pipes to Pass Data... Virendra Shambharkar JCL & VSAM 21 Tue Dec 20, 2016 6:55 pm


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