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

Data Move ment problem


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Debasis Misra
Warnings : 1

New User


Joined: 16 Sep 2008
Posts: 72
Location: Bangalore

PostPosted: Fri Apr 10, 2009 9:34 am
Reply with quote

A PIC 9(05).
B PIC 9(3).

Case1
-----------
Move A to B

Then, if A = 12345
B = 345
So, my first 2 MSB is truncating.

Case 2
-------------
A temporary variable : C PIC X(3).

Move A to C
Move C to B

Then, if A = 12345
B = 123
Its correct.

But if A = 00009
then B =000

Which is incorrect.
-----------------------
A and C declaration we cant change.

Please help me out.
Back to top
View user's profile Send private message
anandinmainframe

Active User


Joined: 31 May 2007
Posts: 171
Location: India

PostPosted: Fri Apr 10, 2009 9:41 am
Reply with quote

Debasis Misra,
Why dont you declare
B PIC 9(3) as
B PIC 9(5).
if you have a input which can be a 5 Digit number.
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: Fri Apr 10, 2009 9:47 am
Reply with quote

Hello,

Quote:
Which is incorrect.
No, it is correct (per cobol rules) - it is just not what you want.

Simply said it is extremely poor design to try to put 5 digits into 3.

You will change something or run the risk of something important being processed incorrectly.

If a value is 12345 why would 123 be an acceptable result for a numeric move?
Back to top
View user's profile Send private message
Debasis Misra
Warnings : 1

New User


Joined: 16 Sep 2008
Posts: 72
Location: Bangalore

PostPosted: Fri Apr 10, 2009 9:48 am
Reply with quote

Sorry ANAND, its my mistake.

'A and C declaration we cant change' -- wrong
'A and B declaration we cant change' -- correct one.
Back to top
View user's profile Send private message
anandinmainframe

Active User


Joined: 31 May 2007
Posts: 171
Location: India

PostPosted: Fri Apr 10, 2009 10:10 am
Reply with quote

Debasis Misra,
Quote:

'A and B declaration we cant change' -- correct one.

if your declaration is like this then i guess you can never resolve this problem.
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: Fri Apr 10, 2009 10:21 am
Reply with quote

Hello,

Without regard to the specific lines of code and variable definitions, it would be a good idea to show all possible patterns of input that may arrive for processing and what the output should be for each different type of input.

Once the rules are understood by those of us involved with this topic, more useful suggestions will result.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Fri Apr 10, 2009 4:03 pm
Reply with quote

If you desire 123 in B, try MOVE A(1:) to B(1:).

But, as Dick has hinted, you may be surprised by the results with some A values, e.g. A=12; result of MOVE: B=000.
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: Fri Apr 10, 2009 4:46 pm
Reply with quote

You could use EVALUATE to determine which bytes of A to move to B, but as was said earlier this is a bad design -- moving 5 bytes to 3 bytes means something is going to get lost.
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 Store the data for fixed length COBOL Programming 1
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top