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

Precompiler errors - Passing host varibale to dayofweek


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
neelusoni

New User


Joined: 13 Nov 2010
Posts: 2
Location: Boston MA

PostPosted: Wed Nov 17, 2010 10:52 pm
Reply with quote

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
View user's profile Send private message
Raghu navaikulam

Active User


Joined: 27 Sep 2008
Posts: 193
Location: chennai

PostPosted: Wed Nov 17, 2010 11:28 pm
Reply with quote

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
View user's profile Send private message
neelusoni

New User


Joined: 13 Nov 2010
Posts: 2
Location: Boston MA

PostPosted: Thu Nov 18, 2010 1:36 am
Reply with quote

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
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Thu Nov 18, 2010 12:55 pm
Reply with quote

All date-HV must be elementary pic x(10).
integers must be s9(9) comp
This is basic DB2 knowledge.
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 -> DB2

 


Similar Topics
Topic Forum Replies
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Passing Parameters to Programs Invoke... PL/I & Assembler 5
No new posts access the last host command CLIST & REXX 2
No new posts Passing SYSPRINT to Invoked Program PL/I & Assembler 9
No new posts Passing parm from JCL to Assembler, b... PL/I & Assembler 2
Search our Forums:

Back to Top