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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a service program. 1

Status
Not open for further replies.

rstitzel

MIS
Apr 24, 2002
286
US
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
 
In the calling program insert the following:

Code:
     D***  Prototypes
     D RtvDayOfWeek    PR             5I 0
     D                                 D   Value

     D RtvWeekOfYear   PR             5I 0
     D                                 D   Value
...
     D DayOfWeek       S             5I 0
     D WeekOfYear      S             5I 0
     D MyDate          S              D    Inz(D'2003-04-29')


...
      *** The day of the week (5=Thursday) is returned in DayOfWeek
C                   Eval      DayOfWeek = RtvDayOfWeek(MyDate)
...
      *** The week of the year (18) is returned in WeekOfYear
C                   Eval      WeekOfYear = RtvWeekOfYear   (MyDate)
...

Philippe
 
TallTurkey,

That's EXACTLY what I was looking for. Thank you very much and have a star!

Rstitzel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top