In this topic I will mention about how to calculate working days for Business Objects layers using SAP ERP calendar by creating a Universe on top of an ABAP Function Module, including ABAP development. Number of working days will be very necessary primarily in HR related reporting.

First, we will need a Function Module which imports “date_from” and “date_to” and exports number of working “days”. The logic of the Function Module will be calculating total number of days and than substracting holiday days which will return by the standart “HOLIDAY_GET” function module.

In R/3, create the function module “ZBO_WORKING_DAYS” with the following parameters that you can find in the ABAP code. Additively, Function Module will export an E_TABLE returning record based holiday days.

Since we will connect to function outside of R/3, Don’t miss to mark the Function Module as Remote-Enabled and flag import and export parameters as “Pass Value”.

Here is the ABAP code:

FUNCTION ZBO_WORKING_DAYS.

*”———————————————————————-

*”*”Local Interface:

*”  IMPORTING

*”    VALUE(DATE_FROM) TYPE  DATS

*”    VALUE(DATE_TO) TYPE  DATS

*”  EXPORTING

*”    VALUE(DAYS) TYPE  INT4

*”  TABLES

*”      E_TABLE STRUCTURE  ISCAL_DAY

*”———————————————————————-

DATA: lv_lines type sytabix.

*calculate number of total days between two days

DAYS = DATE_TO DATE_FROM + 1.

*get holidays from the standart “HOLIDAY_GET” function module

*Go to SCAL t-code to find the technical name of your calendars

CALL FUNCTION ‘HOLIDAY_GET’

EXPORTING

  HOLIDAY_CALENDAR                = ‘Z1’ “Technical name of holiday calendar

  FACTORY_CALENDAR                = ‘Z1’ “Technical name of factory calendar

  DATE_FROM                        = DATE_FROM

  DATE_TO                          = DATE_TO

* IMPORTING

*  YEAR_OF_VALID_FROM              =

*  YEAR_OF_VALID_TO                =

*  RETURNCODE                      =

  TABLES

    HOLIDAYS                        = E_TABLE[]

* EXCEPTIONS

*  FACTORY_CALENDAR_NOT_FOUND      = 1

*  HOLIDAY_CALENDAR_NOT_FOUND      = 2

*  DATE_HAS_INVALID_FORMAT          = 3

*  DATE_INCONSISTENCY              = 4

*  OTHERS                          = 5

          .

IF SYSUBRC <> 0.

* Implement suitable error handling here

ENDIF.

“get the total number of holiday “days from the record count of the holidays internal table

DESCRIBE TABLE E_TABLE[] LINES lv_lines.

“subtract holiday days from total number of days and find number of working days

DAYS = DAYS lv_lines.

ENDFUNCTION.

Open Information Design Tool and insert an Relational SAP R/3 connection to access the “ZBO_WORKING_DAYS” Function Module we just created.

/wp-content/uploads/2016/03/image001_912122.png

When you select “SAP” from the list, two drivers will appear for R/3 connection. To decide which one to use, in ERP go on the menu System –> Status and check “Component Version”. In my case, since the component version is SAP ECC 6.0, I am using SAP ERP 6 Java Connector.


/wp-content/uploads/2016/03/image003_912123.png

Insert SAP ERP system parameters and create the connection shortcut for your IDT project.

/wp-content/uploads/2016/03/image005_912124.png

Create Data Foundation “DF_ERPDEMO”. Since “ZBO_WORKING_DAYS” asks for two obligatory date parameters, on Data Foundation layer we will insert two date prompts. We will make it on “Parameters and List of Values” section. The prompts will be named as “date_from” and “date_to”. Uncheck “Allow multiple values.”

/wp-content/uploads/2016/03/image006_912125.png

Go to “Connections” section and find “ZBO_WORKING_DAYS”. In the list under “ABAPFunction” node , Functions Modules are divided into groups according to Function Group names. Here it is contained in “ZBWFG” Function Group.

/wp-content/uploads/2016/03/2_blur_912126.png

You will see two function objects under ZBWFG, because “ZBO_WORKING_DAYS” function module has two outputs. For “Tables” parameter of the Function Module, one more function object appears in IDT with the name “ZBO_WORKING_DAYS-EXPORT_CH_E_TABLE”.

After drag and drop “ZBO_WORKING_DAYS”, a pop up comes for mapping Function Module parameters with  the Data Foundation parameters. We map parameters with each other. After that, do the same for “ZBO_WORKING_DAYS-EXPORT_CH_E_TABLE”.

/wp-content/uploads/2016/03/image009_912127.png

Create a Business Layer “BL_ERPDEMO” and assign the Data Foundation. I have created two folders for each output of the function, drag and drop the fields under each folder. Turn “Days” field with the name “Natural Number” into a Measure with aggreate function “Sum”.


/wp-content/uploads/2016/03/3_blur_912128.png

You can see the final structure of the Business Layer as in the following. I have unchecked “Limit size of resut set to” option, though we won’t exceed the limit in this case. We can now publish the Universe to the BI Platform.

/wp-content/uploads/2016/03/image014_912129.jpg

Create a new Web Intelligence document and select the regarding Universe. Create two queries to get both “Days” and “E_Table”.

/wp-content/uploads/2016/03/image015_912130.png

Answer the prompts with the following date values or anything you need.

/wp-content/uploads/2016/03/image017_912131.png

The output will be number of working days as one record and calendar based holiday days table.

/wp-content/uploads/2016/03/image019_912132.png

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply