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
 

 

Data Move ment problem

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Data Move ment problem
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    Post subject: Reply to: Data Move ment problem
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

Site Director


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

PostPosted: Fri Apr 10, 2009 9:47 am    Post subject:
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    Post subject:
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    Post subject: Reply to: Data Move ment problem
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

Site Director


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

PostPosted: Fri Apr 10, 2009 10:21 am    Post subject:
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    Post subject:
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: 7935
Location: Bellevue, IA

PostPosted: Fri Apr 10, 2009 4:46 pm    Post subject:
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    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 Sorting group data rajella DFSORT/ICETOOL 3 Sun Jan 22, 2017 11:32 pm
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 HALDB data refresh/copy from producti... vineetanand2007 IMS DB/DC 1 Mon Jan 02, 2017 11:16 am
No new posts SYMNAMES problem jacobdng DFSORT/ICETOOL 7 Thu Dec 22, 2016 7:47 am


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