SAP Function Modules

F4_DATE_CONTROL SAP Function module - Display factory calendar or Gregor. calendar and choose a day







F4_DATE_CONTROL 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 F4_DATE_CONTROL into the relevant SAP transaction such as SE37 or SE80.

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


Pattern for FM F4_DATE_CONTROL - F4 DATE CONTROL





CALL FUNCTION 'F4_DATE_CONTROL' "Display factory calendar or Gregor. calendar and choose a day
* EXPORTING
*   date_for_first_month = SY-DATUM  " workflds-gkday  For determining the first month to be displayed
*   display = SPACE             " workflds-displ  X = no selection option
*   factory_calendar_id = SPACE  " workflds-calid  Factory Calendar
*   gregorian_calendar_flag = SPACE  "          Display Gregorian calendar
*   holiday_calendar_id = SPACE  " workflds-hident  Public Holiday Calendar
*   holiday_style = '6'         " i
*   progname_for_first_month = SPACE  " sy-repid  to determine the date at the cursor position
*   week_begin_day = 1          " t246-wotnr
*   select_option_week = SPACE  " workflds-displ
*   select_option_month = SPACE  " workflds-displ
  IMPORTING
    select_date =               " workflds-gkday  selected date
    select_week =               " scal-week
    select_begin =              " sy-datum
    select_end =                " sy-datum
    select_month =              " scal-week     Selected month
  EXCEPTIONS
    CALENDAR_BUFFER_NOT_LOADABLE = 1  "         Factory calendar read error
    DATE_AFTER_RANGE = 2        "               Date is later than factory calendar
    DATE_BEFORE_RANGE = 3       "               Date is earlier than factory calendar's
    DATE_INVALID = 4            "               Date in invalid format
    FACTORY_CALENDAR_NOT_FOUND = 5  "           Factory calendar is not available
    HOLIDAY_CALENDAR_NOT_FOUND = 6  "           Holiday calendar is not available
    PARAMETER_CONFLICT = 7      "               Pass Factory calendar and Holiday calendar
    .  "  F4_DATE_CONTROL

ABAP code example for Function Module F4_DATE_CONTROL





The ABAP code below is a full code listing to execute function module F4_DATE_CONTROL 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_select_date  TYPE WORKFLDS-GKDAY ,
ld_select_week  TYPE SCAL-WEEK ,
ld_select_begin  TYPE SY-DATUM ,
ld_select_end  TYPE SY-DATUM ,
ld_select_month  TYPE SCAL-WEEK .


DATA(ld_date_for_first_month) = 20210129

DATA(ld_display) = some text here

DATA(ld_factory_calendar_id) = some text here
DATA(ld_gregorian_calendar_flag) = 'some text here'.

DATA(ld_holiday_calendar_id) = some text here
DATA(ld_holiday_style) = 'Check type of data required'.
DATA(ld_progname_for_first_month) = 'some text here'.

SELECT single WOTNR
FROM T246
INTO @DATA(ld_week_begin_day).


DATA(ld_select_option_week) = some text here

DATA(ld_select_option_month) = some text here . CALL FUNCTION 'F4_DATE_CONTROL' * EXPORTING * date_for_first_month = ld_date_for_first_month * display = ld_display * factory_calendar_id = ld_factory_calendar_id * gregorian_calendar_flag = ld_gregorian_calendar_flag * holiday_calendar_id = ld_holiday_calendar_id * holiday_style = ld_holiday_style * progname_for_first_month = ld_progname_for_first_month * week_begin_day = ld_week_begin_day * select_option_week = ld_select_option_week * select_option_month = ld_select_option_month IMPORTING select_date = ld_select_date select_week = ld_select_week select_begin = ld_select_begin select_end = ld_select_end select_month = ld_select_month EXCEPTIONS CALENDAR_BUFFER_NOT_LOADABLE = 1 DATE_AFTER_RANGE = 2 DATE_BEFORE_RANGE = 3 DATE_INVALID = 4 FACTORY_CALENDAR_NOT_FOUND = 5 HOLIDAY_CALENDAR_NOT_FOUND = 6 PARAMETER_CONFLICT = 7 . " F4_DATE_CONTROL
IF SY-SUBRC EQ 0. "All OK ELSEIF SY-SUBRC EQ 1. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 2. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 3. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 4. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 5. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 6. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 7. "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_select_date  TYPE WORKFLDS-GKDAY ,
ld_date_for_first_month  TYPE WORKFLDS-GKDAY ,
ld_select_week  TYPE SCAL-WEEK ,
ld_display  TYPE WORKFLDS-DISPL ,
ld_select_begin  TYPE SY-DATUM ,
ld_factory_calendar_id  TYPE WORKFLDS-CALID ,
ld_select_end  TYPE SY-DATUM ,
ld_gregorian_calendar_flag  TYPE STRING ,
ld_select_month  TYPE SCAL-WEEK ,
ld_holiday_calendar_id  TYPE WORKFLDS-HIDENT ,
ld_holiday_style  TYPE I ,
ld_progname_for_first_month  TYPE SY-REPID ,
ld_week_begin_day  TYPE T246-WOTNR ,
ld_select_option_week  TYPE WORKFLDS-DISPL ,
ld_select_option_month  TYPE WORKFLDS-DISPL .


ld_date_for_first_month = 20210129

ld_display = some text here

ld_factory_calendar_id = some text here
ld_gregorian_calendar_flag = 'some text here'.

ld_holiday_calendar_id = some text here
ld_holiday_style = 'some text here'.
ld_progname_for_first_month = 'some text here'.

SELECT single WOTNR
FROM T246
INTO ld_week_begin_day.


ld_select_option_week = some text here

ld_select_option_month = 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 F4_DATE_CONTROL or its description.