View previous topic :: View next topic
|
Author |
Message |
neelusoni
New User
Joined: 13 Nov 2010 Posts: 2 Location: Boston MA
|
|
|
|
Hi All,
In my program it is required to find last working day of the year. For which I have created the following code. I am getting precompilation errors for this. Am I doing something wrong here? Please help
Working storage
Code: |
01 WS-LAST-DATE.
05 WS-LAST-MM PIC X(02).
05 FILLER PIC X(01) VALUE '/'.
05 WS-LAST-DD PIC X(02).
05 FILLER PIC X(01) VALUE '/'.
05 WS-LAST-YYYY PIC X(04).
01 WS-LAST-WORK-DAY PIC 9(02) COMP. |
Procedure division
Code: |
MOVE WSC-CURR-DTE(1:4) TO WS-LAST-YYYY
MOVE 12 TO WS-LAST-MM
MOVE 31 TO WS-LAST-DD
EXEC SQL
SELECT CASE DAYOFWEEK(DATE(:WS-LAST-DATE))
WHEN 1 THEN 29
WHEN 7 THEN 30
ELSE 31
END
INTO :WS-LAST-WORK-DAY
FROM SYSIBM.SYSDUMMY1
END-EXEC |
where WSC-CURR-DTE is current julian date.
Precomiler errors
Code: |
UNDEFINED OR UNUSABLE HOST VARIABLE "WS-LAST-DATE"
UNDEFINED OR UNUSABLE HOST VARIABLE "WS-LAST-WORK-DAY" |
Regards,
Neelu Soni |
|
Back to top |
|
|
Raghu navaikulam
Active User
Joined: 27 Sep 2008 Posts: 193 Location: chennai
|
|
|
|
Hi Neelu Soni
Quote: |
Am I doing something wrong here? |
I suggest you 2 changes in the variable declaration.
1. 01 WS-LAST-DATE PIC X(10).
The variable must be PIC X(10).
2. 01 WS-LAST-WORK-DAY PIC S9(9) COMP.
Because the result of the function DAYOFWEEK is a large integer.
Hope this will help you
Regards
Raghu |
|
Back to top |
|
|
neelusoni
New User
Joined: 13 Nov 2010 Posts: 2 Location: Boston MA
|
|
|
|
Thanks Raghu.
That works. So would that mean that Dayofweek function (for that matter any scalar function) requires an elementary level host variable as the input parameter, Group variables would not work? |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
All date-HV must be elementary pic x(10).
integers must be s9(9) comp
This is basic DB2 knowledge. |
|
Back to top |
|
|
|