How to Create a Business Function to display Date Requested and the Week Number?

11794541 978729448825149 5640765919872836789 oGarfield Hyatt, Senior Developer

Question

I received a request from a client to display Date Requested and the week number of the year this date falls-in. I was surprise to find out that there is not a Business Function in JDE that provides this calculation so we had to create our own BF to this. So how do you create group of tasks to accomplish this?

Answer

Below are the data structure and the text code used to return the Week Number of a "Given Date".

/** D5900007
* TYPEDEF for Data Structure
* D5900007 : Get Week of the Year from Calendar date
typedef struct tagDSD5900007
{
JDEDATE jdDate;
JCHAR szBranch[13];
int nWeekNumber;
} DSD5900007 , *LPDSD5900007;
#define IDERRjdDate_1 1L
#define IDERRszBranch_2 2L
#define IDERRnWeekNumber_3 3L
#endif /* DATASTRUCTURE_D5900007 */

Listing of ER for Named ER: N5900007
=======================================================================
NAMED ER: Get Week of the Year from Calendar date
=======================================================================
evt_jdFirstDayOfYear_Date01
evt_mnDayOfWeek1st_INT01
evt_cDayType_EV01
evt_mnWeekNumber_INT01
evt_mnDayNumber_INT01
OPT: Using Defaults
0001 //
0002 VA evt_cDayType_EV01 = " "
0003 VA evt_jdFirstDayOfYear_Date01 = " "
0004 VA evt_mnDayNumber_INT01 = " "
0005 VA evt_mnDayOfWeek1st_INT01 = " "
0006 VA evt_mnWeekNumber_INT01 = ""
0007 //
0008 // Calculate the week number of the year from a given date.
0009 //
0010 VA evt_jdFirstDayOfYear_Date01 = add_months([BF jdDate],(date_month([BF jdDate])*-1))
0011 VA evt_jdFirstDayOfYear_Date01 = add_days(last_day([VA evt_jdFirstDayOfYear_Date01]),1)
0012 //
0013 F0007 Get Day of the Week
BF szBranch -> BF szBranch
VA evt_jdFirstDayOfYear_Date01 -> BF jdDate
VA evt_mnDayOfWeek1st_INT01 <- BF nDayOfWeek
VA evt_cDayType_EV01 <- BF cTypeOfDay
0014 //
0015 If VA evt_mnDayOfWeek1st_INT01 is equal to
0016 VA evt_mnDayOfWeek1st_INT01 = "7"
0017 End If
0018 //
0019 F0007 Get Day of the Week
BF szBranch -> BF szBranch
BF jdDate -> BF jdDate
VA evt_mnDayNumber_INT01 <- BF nDayOfWeek
VA evt_cDayType_EV01 <- BF cTypeOfDay
0020 //
0021 If VA evt_mnDayNumber_INT01 is equal to
0022 VA evt_mnDayNumber_INT01 = "7"
0023 End If
0024 //
0025 VA evt_mnWeekNumber_INT01 = days_between([VA evt_jdFirstDayOfYear_Date01],[BF jdDate])
0026 VA evt_mnWeekNumber_INT01 = ([VA evt_mnWeekNumber_INT01]+[VA evt_mnDayOfWeek1st_INT01])+(6-[VA evt_mnDayNumber_INT01])
0027 VA evt_mnWeekNumber_INT01 = [VA evt_mnWeekNumber_INT01]/7
0028 BF nWeekNumber = VA evt_mnWeekNumber_INT01
Friday March 25, 2016 10:31

Have a question about JD Edwards Business Functions, please contact us at inquiries@GetGSI.com