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

COBOL MOVE from 9(10) to 9(10)


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

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Canada

PostPosted: Wed Mar 04, 2009 5:24 pm
Reply with quote

Hi,
I guess i miss something in the below issue and here goes the problem,there is a zero coming in the last digit of the move from 9(10) to 9(10).Not sure how it comes?

This is the COBOL declaration

Code:
05 WS-BULKCPY-SUBMITTED-AMT1   PIC 9(10)  VALUE ZEROS.

05 BULKCPY-SUBMITTED-AMT1      PIC 9(10)  VALUE ZEROS.



This is the programming code

Code:
DISPLAY 'QUEUE SUB AMT : ' , WS-BULKCPY-SUBMITTED-AMT1   
                                                         
 INITIALIZE BULKCPY-SUBMITTED-AMT1                       
                                                         
 DISPLAY 'SUB AMT-BM:' , BULKCPY-SUBMITTED-AMT1 
                                                         
 MOVE WS-BULKCPY-SUBMITTED-AMT1 TO                       
                    BULKCPY-SUBMITTED-AMT1               
                               
 DISPLAY 'SUB AMT:' , BULKCPY-SUBMITTED-AMT1   




Output is

Code:
QUEUE SUB AMT : 100               
SUB AMT-BM:0000000000   
SUB AMT:100      0   


HEX ON Ouptut is

Code:
QUEUE SUB AMT : 100                     
DECEC4EEC4CDE474FFF444444444444444444444
84545024201430A01000000000000000000000000

SUB AMT-BM:0000000000
EEC4CDE6CD7FFFFFFFFFF
2420143024A0000000000

SUB AMT:100      0     
EEC4CDE7FFF444444F44444
2420143A100000000000000
Back to top
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Wed Mar 04, 2009 5:44 pm
Reply with quote

Muthuvel,
Any idea why
Code:
DISPLAY 'QUEUE SUB AMT : ' , WS-BULKCPY-SUBMITTED-AMT1
is displayed as
Code:
QUEUE SUB AMT : 100
and not as
Code:
QUEUE SUB AMT : 000000100

Secondly, did you try expediting the code and moving 100 to BULKCPY-SUBMITTED-AMT1 field and displaying the same.

Not sure if this will actually help you ..just trying to open few doors.
WTF
Back to top
View user's profile Send private message
William Thompson

Global Moderator


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

PostPosted: Wed Mar 04, 2009 5:51 pm
Reply with quote

muthuvel wrote:
there is a zero coming in the last digit of the move from 9(10) to 9(10).Not sure how it comes?
Since the receiving field has no sign specified, COBOL is setting the half byte to a 'F', insuring a positive sign.
Back to top
View user's profile Send private message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Canada

PostPosted: Wed Mar 04, 2009 6:00 pm
Reply with quote

The input file to this has the number as 100 in 9(10) with right justified data and i tried previously to move 100 directly and the output that occured was

Code:
QUEUE SUB AMT : 100           
SUB AMT-BM:0000000000
SUB AMT:0000000100   


My understanding is ,when you move from a variable A to variable B provided both are of same data type and same type ,the move is similar to copy.Am I right?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


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

PostPosted: Wed Mar 04, 2009 6:12 pm
Reply with quote

muthuvel wrote:
My understanding is ,when you move from a variable A to variable B provided both are of same data type and same type ,the move is similar to copy.Am I right?
Half way.....
Packed decimal is always ZAPed (zero and add packed), but display character and numeric is MVCed (moved).
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: Wed Mar 04, 2009 6:21 pm
Reply with quote

As you've defined the code, there's no reason for the behavior that you're seeing. I ran a test with using Enterprise COBOL 3.4 of:
Code:
01  WS-VARIABLES.
    05 WS-BULKCPY-SUBMITTED-AMT1   PIC 9(10)  VALUE ZEROS.
    05 BULKCPY-SUBMITTED-AMT1      PIC 9(10)  VALUE ZEROS.
PROCEDURE DIVISION.
S1000-MAIN       SECTION.
    MOVE 100                    TO  WS-BULKCPY-SUBMITTED-AMT1.
    DISPLAY 'QUEUE SUB AMT : '  WS-BULKCPY-SUBMITTED-AMT1.

    INITIALIZE BULKCPY-SUBMITTED-AMT1.

    DISPLAY 'SUB AMT-BM:'  BULKCPY-SUBMITTED-AMT1.

    MOVE WS-BULKCPY-SUBMITTED-AMT1 TO
                    BULKCPY-SUBMITTED-AMT1.

    DISPLAY 'SUB AMT:' BULKCPY-SUBMITTED-AMT1.
and got results of
Code:
 QUEUE SUB AMT : 0000000100
 SUB AMT-BM:0000000000
 SUB AMT:0000000100
Either the variables aren't defined as you have them, or the code isn't as you have it. The behavior you posted is what I would expect if the sending variable was defined as X(03) or possibly X(10), not 9(10).
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Wed Mar 04, 2009 6:32 pm
Reply with quote

Robert wrote:
As you've defined the code, there's no reason for the behavior that you're seeing.
Not quite, since the OP has shown that WS-BULKCPY-SUBMITTED-AMT1 contains:
Code:
100                     
FFF4444444
1000000000
Which perfectly explains this behavior.....
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: Wed Mar 04, 2009 6:37 pm
Reply with quote

You're right, CICS Guy -- so I think the question becomes, why that value in WS-BULKCPY-SUBMITTED-AMT1?
Back to top
View user's profile Send private message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Canada

PostPosted: Wed Mar 04, 2009 7:00 pm
Reply with quote

As Rob and CICS guy said,though the input passed was numbers it was passed as right justified to my input part (making it to be alphanumeric format) , which caused the problem.

When I received it in alphanumeric format X(10) and moved to 9(10) ,it got solved.

Thanks Folks !!!
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top