View previous topic :: View next topic
|
Author |
Message |
sjiraga
New User
Joined: 20 Apr 2009 Posts: 14 Location: Bangalore
|
|
|
|
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 |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
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 |
|
|
sjiraga
New User
Joined: 20 Apr 2009 Posts: 14 Location: Bangalore
|
|
|
|
Thanks a lot ksk |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Sounds like class work, since the STRING option is out. |
|
Back to top |
|
|
Succor
New User
Joined: 20 Feb 2009 Posts: 96 Location: Bangalore :)
|
|
|
|
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 |
|
|
|