BELOW IS A MODULE I FOUND THAT PERFORMS TWO DATE CALCULATIONS THAT I NEED. DAY OF WEEK AND WEEK OF YEAR.
I CREATED THE MODULE AND THEN CREATED A SERVICE PROGRAM AND INCLUDED THE MODULE. I THEN CREATED A BIND DIRECTORY AND ADDED THE SERVICE PROGRAM TO THIS DIRECTORY. I UNDERSTAND THAT I NEED TO BIND ANY PROGRAM THAT I WANT TO USE THE SERVICE PROGRAMS TO THAT DIRECTORY. THERE ARE TWO PROCEDURES WITHIN THE MODULE RTVDAYOFWEEK & RTVWEEKOFYEAR
QUESTION: How do I call the module and pass the parameter "DATEIN"? Does anyone have an example of calling a procedure or module and how to pass the parm.
Thank you very much.
H*******************************************************************************
H*** Service Program . . . . . . . CalDates
H*** Description . . . . . . . . . Calculate from a given
H*** ISO Date the Day of week and Week of Year
H*******************************************************************************
HNOMAIN
D*** Prototypes
D RtvDayOfWeek PR 5I 0
D D Value
D RtvWeekOfYear PR 5I 0
D D Value
P*** Calculate Day-Of-Week
P RtvDayOfWeek B Export
D RtvDayOfWeek PI 5I 0
D DateIn D Value
D BaseMonday S D Inz(D'2001-05-21')
D NbrDays S 10I 0
C
C DateIn subdur BaseMonday NbrDays:*D
C return (%rem(%rem(NbrDays:7)+7:7))
P RtvDayOfWeek E
P
P*** Calculate Week-Of-Year
P RtvWeekOfYear B Export
D RtvWeekOfYear PI 5I 0
D DateIn D Value
D
D*** Data Definitions
D DS
D Jan4Date D Inz(D'0001-01-04')
D Jan4Year 4S 0 Overlay(Jan4Date)
D
D MondayDate S D
D Jan4Day S 5I 0
D NbrOfDays S 10I 0
D SundayDate S D
D ISOWeek S 5I 0
C
C eval NbrOfDays = 6 - RtvDayOfWeek(DateIn)
C DateIn adddur NbrOfDays:*D SundayDate
C*** Set date to January 4 of the calculated year and use to derive the date
C*** of that year's first Monday
C
C extrct SundayDate:*Y Jan4Year
C eval Jan4Day = RtvDayOfWeek(Jan4Date)
C Jan4Date subdur Jan4Day:*D MondayDate
C*** Calculate the week of the year and return the value
C SundayDate subdur MondayDate NbrOfDays:*D
C
C if NbrOfDays <0
C eval Jan4Year = Jan4Year - 1
C eval Jan4Day = RtvDayOfWeek(Jan4Date)
C Jan4Date subdur Jan4Day:*D MondayDate
C SundayDate subdur MondayDate NbrOfDays:*D
C endif
C
C eval ISOWeek = NbrOfDays/7
C if ISOWeek >= *Zero
C eval ISOWeek = ISOWeek + 1
C else
C eval ISOWeek = 53
C endif
C
C return ISOWeek
P RtvWeekOfYear E
I CREATED THE MODULE AND THEN CREATED A SERVICE PROGRAM AND INCLUDED THE MODULE. I THEN CREATED A BIND DIRECTORY AND ADDED THE SERVICE PROGRAM TO THIS DIRECTORY. I UNDERSTAND THAT I NEED TO BIND ANY PROGRAM THAT I WANT TO USE THE SERVICE PROGRAMS TO THAT DIRECTORY. THERE ARE TWO PROCEDURES WITHIN THE MODULE RTVDAYOFWEEK & RTVWEEKOFYEAR
QUESTION: How do I call the module and pass the parameter "DATEIN"? Does anyone have an example of calling a procedure or module and how to pass the parm.
Thank you very much.
H*******************************************************************************
H*** Service Program . . . . . . . CalDates
H*** Description . . . . . . . . . Calculate from a given
H*** ISO Date the Day of week and Week of Year
H*******************************************************************************
HNOMAIN
D*** Prototypes
D RtvDayOfWeek PR 5I 0
D D Value
D RtvWeekOfYear PR 5I 0
D D Value
P*** Calculate Day-Of-Week
P RtvDayOfWeek B Export
D RtvDayOfWeek PI 5I 0
D DateIn D Value
D BaseMonday S D Inz(D'2001-05-21')
D NbrDays S 10I 0
C
C DateIn subdur BaseMonday NbrDays:*D
C return (%rem(%rem(NbrDays:7)+7:7))
P RtvDayOfWeek E
P
P*** Calculate Week-Of-Year
P RtvWeekOfYear B Export
D RtvWeekOfYear PI 5I 0
D DateIn D Value
D
D*** Data Definitions
D DS
D Jan4Date D Inz(D'0001-01-04')
D Jan4Year 4S 0 Overlay(Jan4Date)
D
D MondayDate S D
D Jan4Day S 5I 0
D NbrOfDays S 10I 0
D SundayDate S D
D ISOWeek S 5I 0
C
C eval NbrOfDays = 6 - RtvDayOfWeek(DateIn)
C DateIn adddur NbrOfDays:*D SundayDate
C*** Set date to January 4 of the calculated year and use to derive the date
C*** of that year's first Monday
C
C extrct SundayDate:*Y Jan4Year
C eval Jan4Day = RtvDayOfWeek(Jan4Date)
C Jan4Date subdur Jan4Day:*D MondayDate
C*** Calculate the week of the year and return the value
C SundayDate subdur MondayDate NbrOfDays:*D
C
C if NbrOfDays <0
C eval Jan4Year = Jan4Year - 1
C eval Jan4Day = RtvDayOfWeek(Jan4Date)
C Jan4Date subdur Jan4Day:*D MondayDate
C SundayDate subdur MondayDate NbrOfDays:*D
C endif
C
C eval ISOWeek = NbrOfDays/7
C if ISOWeek >= *Zero
C eval ISOWeek = ISOWeek + 1
C else
C eval ISOWeek = 53
C endif
C
C return ISOWeek
P RtvWeekOfYear E