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

move statemnt (overflow)


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sjiraga

New User


Joined: 20 Apr 2009
Posts: 14
Location: Bangalore

PostPosted: Tue May 26, 2009 11:14 am
Reply with quote

Hi I have question with COBOL move statement (TRUNCATE PROBLEM)

VAR1 PIC X (10)
VAR2 PIC X (07)

In my Program I am moving VAR1 TO VAR2 while moving truncation will happen. Now I want to know how to add the logic for data truncation in my COBOL program.
If I move VAR1 TO VAR2 program should run but it should display only error message so please let me know what is the logic. One more thing I don't want to use string option or I cant change size of PIC. Please if anyone know the logic let me know....
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 355
Location: New York

PostPosted: Tue May 26, 2009 11:42 am
Reply with quote

Count the number of characters in VAR1 and VAR2 using inline perform as you don't want to use string.

If VAR1 is greater than VAR2, display the error message. Otherwise move the contents.
Back to top
View user's profile Send private message
sjiraga

New User


Joined: 20 Apr 2009
Posts: 14
Location: Bangalore

PostPosted: Tue May 26, 2009 2:12 pm
Reply with quote

Thanks a lot ksk
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue May 26, 2009 5:01 pm
Reply with quote

Sounds like class work, since the STRING option is out.
Back to top
View user's profile Send private message
Succor

New User


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

PostPosted: Tue May 26, 2009 7:28 pm
Reply with quote

sjiraga, In case you dont wish to use the STRING statement you might try the following logic :
Code:
 IF VAR1(8:3) = SPACES
         MOVE THE VARIBALES
 ELSE
         DISPLAY THE ERROR
 END-IF.

WTH
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 -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts Assembler: Set Program Mask for decim... PL/I & Assembler 4
No new posts How to move DB2 Installation HLQ DB2 4
No new posts How to move values from single dimens... COBOL Programming 1
Search our Forums:

Back to Top