Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

move s9(4) to s9(4) comp problem

Status
Not open for further replies.

dr74

Programmer
Aug 11, 2002
4
IL
Hi folks,

I have a program that calls a data layer with parameter
that was received from thge JCL by ACCEPT statement:
Code:
01 WS01-TMP PIC 9(4).
01 WS02-INPUT.
   03 WS02-D PIC S9(4) COMP.      (SMALLINT IN THE DB TABLE)
01 WS03-OUTPUT.
   03 ...

ACCEPT WS01-TMP.

DISPLAY 'WS01-TMP: ' WS01-TMP  [COLOR=red]WS01-TMP: 12[/color]

MOVE WS01-TMP TO WS02-D

DISPLAY 'WS02-D: ' WS02-D  [COLOR=red]WS02-D: 12[/color]

CALL 'DL' USING WS02-INPUT
                WS03-OUTPUT

The select statement in the data layer returns empty.
The same select statement in SPUFI returns the expected records.

I guess that the problem is in the MOVE statement.

What you think ?

Thanks in advance.


 
If you can use a debugger, what was in WS01-TMP and what is in WS02-D after this statement:
MOVE WS01-TMP TO WS02-D
 
In the displays I see 12 in both formats.

I removed the IEFCOPY statement that expanded the variable from DB smallint
to COBOL PIC S9(4) COMP and declared the variable as PIC S9(4) USAGE COMP.
Now it shows me other values.

Before that if I moved value 123 to this variable in the display I saw only two digits - "12".

After the change the results are different - "01200", but still not good.
The data layer still returns empty.

I tried with debugger. When I type "monitor list WS01-TMP" I receive:
"Invalid data for 02 XTOJBTST:>WS01-TMP is found"

I tried as follows:
Code:
IF WS01-TMP NUMERIC
THEN
    DISPLAY 'NUMERIC'
END-IF
but the condition is false so there is no display.
 
It appears that the problem is in the ACCEPT statement mechanism.

To isolate the problem, try hardcoding the value you need:
01 WS01-TMP PIC 9(4) VALUE 123.

If that works, then you may want to review how the JCL passes values to ACCEPT.

Dimandja
 
I found why it copied only two digits:

The definition of WS02-D was:
Code:
01 WS02-INPUT.
   03 WS02-D.
      05 WS02-COMP PIC S9(4) COMP.
So the destination in the move statement was a group level variable that similar to text.

About the second problem I tried to compare the comp
variable after the move:
Code:
           IF WS02-COMP = 12
           THEN
      D        DISPLAY 'WS02-COMP = 12'
           ELSE
      D        DISPLAY 'WS02-COMP NOT = 12'
           END-IF
           IF WS02-COMP = 1200
           THEN
      D        DISPLAY 'WS02-COMP = 1200'
           ELSE
      D        DISPLAY 'WS02-COMP NOT = 1200'
           END-IF
The result is:
WS02-COMP NOT = 12
WS02-COMP = 1200

Any ideas ?
 
I don't know how your code looks like at this moment. But, lets try this.

01 WS01-TMP PIC 9(4).
01 WS02-INPUT.
03 WS02-D.
05 WS02-COMP PIC S9(4) COMP.

ACCEPT WS01-TMP.
MOVE WS01-TMP TO WS02-COMP.

I ACCEPTed 12 and the results were as expected (my ACCEPT right justified the value of WS01-TMP:
WS01-TMP = 12
WS02-INPUT.WS02-D.WS02-COMP = 12

I also tried:
01 WS01-TMP PIC ZZZ9.
01 WS02-INPUT.
03 WS02-D.
05 WS02-COMP PIC S9(4) COMP.

ACCEPT WS01-TMP.
MOVE WS01-TMP TO WS02-COMP.

WS01-TMP = " 12"
WS02-INPUT.WS02-D.WS02-COMP = 12

The results were good. But, notice how WS01-TMP is rigth justified. Understand how your ACCEPT deals with various PICTUREs clauses and code accordingly.

My compiler seems to be quite forgiving/intuitive - it lets me get away with this too:
01 WS01-TMP PIC X(04).
01 WS02-INPUT.
03 WS02-D.
05 WS02-COMP PIC S9(4) COMP.

ACCEPT WS01-TMP.
MOVE WS01-TMP TO WS02-COMP.

WS01-TMP = "12 "
WS02-INPUT.WS02-D.WS02-COMP = 12

Dimandja
 
You are welcome. But, were you able to solve the problem?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top