SAP Function Modules

BKK_CLOSING_GET_NEAREST_KEYDAT SAP Function module - Find Nearest Key Date







BKK_CLOSING_GET_NEAREST_KEYDAT is a standard SAP function module available within R/3 SAP systems depending on your version and release level. Below is the pattern details for this FM showing its interface including any import and export parameters, exceptions etc as well as any documentation contributions (Comments) specific to the object.

See here to view full function module documentation and code listing, simply by entering the name BKK_CLOSING_GET_NEAREST_KEYDAT into the relevant SAP transaction such as SE37 or SE80.

Associated Function Group: FBM5
Released Date: Not Released
Processing type: Normal fucntion module
Normal function module settings


Pattern for FM BKK_CLOSING_GET_NEAREST_KEYDAT - BKK CLOSING GET NEAREST KEYDAT





CALL FUNCTION 'BKK_CLOSING_GET_NEAREST_KEYDAT' "Find Nearest Key Date
  EXPORTING
    i_date =                    " bkkm2-next_date  Current Date
    i_periodunit =              " bkkm2-per_unit  Period Unit (Days, Weeks, Months)
    i_key =                     " bkkm2-key_date  Key Date
*   i_swerk =                   " vtbkond-svwerk  Working Day Shift for Value Date
*   i_bdays =                   " vtbkond-avgstage  Number of Days for Rel. Calculation of Value Date
*   i_factory_calendar1 =       " ibkk42-cal_id1  Public Holiday Calendar ID 1
*   i_factory_calendar2 =       " ibkk42-cal_id2  Public Holiday Calendar ID 2
  IMPORTING
    e_keydate =                 " bkkm2-next_date  Key Date
  EXCEPTIONS
    INVALID_PERIODUNIT = 1      "               Invalid Period Unit
    .  "  BKK_CLOSING_GET_NEAREST_KEYDAT

ABAP code example for Function Module BKK_CLOSING_GET_NEAREST_KEYDAT





The ABAP code below is a full code listing to execute function module BKK_CLOSING_GET_NEAREST_KEYDAT including all data declarations. The code uses the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the original method of declaring data variables up front. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8).

DATA:
ld_e_keydate  TYPE BKKM2-NEXT_DATE .


SELECT single NEXT_DATE
FROM BKKM2
INTO @DATA(ld_i_date).


SELECT single PER_UNIT
FROM BKKM2
INTO @DATA(ld_i_periodunit).


SELECT single KEY_DATE
FROM BKKM2
INTO @DATA(ld_i_key).


DATA(ld_i_swerk) = Check type of data required

DATA(ld_i_bdays) = 123

DATA(ld_i_factory_calendar1) = some text here

DATA(ld_i_factory_calendar2) = some text here . CALL FUNCTION 'BKK_CLOSING_GET_NEAREST_KEYDAT' EXPORTING i_date = ld_i_date i_periodunit = ld_i_periodunit i_key = ld_i_key * i_swerk = ld_i_swerk * i_bdays = ld_i_bdays * i_factory_calendar1 = ld_i_factory_calendar1 * i_factory_calendar2 = ld_i_factory_calendar2 IMPORTING e_keydate = ld_e_keydate EXCEPTIONS INVALID_PERIODUNIT = 1 . " BKK_CLOSING_GET_NEAREST_KEYDAT
IF SY-SUBRC EQ 0. "All OK ELSEIF SY-SUBRC EQ 1. "Exception "Add code for exception here ENDIF.







ABAP code to compare 7.40 inline data declaration with original syntax

The below ABAP code uses the older none in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. It may also be useful if you are using an older version of SAP as some of the newer syntax above, such as the @DATA is not available until 4.70 EHP 8.

DATA:
ld_e_keydate  TYPE BKKM2-NEXT_DATE ,
ld_i_date  TYPE BKKM2-NEXT_DATE ,
ld_i_periodunit  TYPE BKKM2-PER_UNIT ,
ld_i_key  TYPE BKKM2-KEY_DATE ,
ld_i_swerk  TYPE VTBKOND-SVWERK ,
ld_i_bdays  TYPE VTBKOND-AVGSTAGE ,
ld_i_factory_calendar1  TYPE IBKK42-CAL_ID1 ,
ld_i_factory_calendar2  TYPE IBKK42-CAL_ID2 .


SELECT single NEXT_DATE
FROM BKKM2
INTO ld_i_date.


SELECT single PER_UNIT
FROM BKKM2
INTO ld_i_periodunit.


SELECT single KEY_DATE
FROM BKKM2
INTO ld_i_key.


ld_i_swerk = Check type of data required

ld_i_bdays = 123

ld_i_factory_calendar1 = some text here

ld_i_factory_calendar2 = some text here

Contribute (Add Comments)

Please help keep this info upto date and use the comments section below to add useful hints, tips and information specific to this SAP function. This will then be available for you and other users to easily find by simply searching on the object name BKK_CLOSING_GET_NEAREST_KEYDAT or its description.