Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass the Date in the Fm HOLIDAY_GET

former_member196331
Active Contributor
0 Kudos
997

hi,

I am using APO System, I may not use other FMs. To get the holidays list.
I am using FM : HOLIDAY_GET

I need to pass From and to date. in the Format of dd.mm.year.
but in the FM it is referring Dats 8 .
but if i want to convert yearmonthdate to dd.mm.year. i Need 10 length of space.
i create char also . that char i was passed to FM. It is not working.

Any suggestion how could i solve the issue.

I need to get next month first working day. . i have feature month. like 10th and 11th or 12th. it will come dynaially.

2 REPLIES 2

michael_piesche
Active Contributor
359

newb, please make yourself familar with internal ABAP data representation vs external GUI data representation. The SAP DDIC domain types define mostly the internal data representation but when necessary also the GUI data representation.

  • For example the DDIC domain DATS has internally 8 characters, but externally 10 characters.
  • The internal ABAP data type DATS, which is used for the domain DATS, has an internal Conversion EXIT that expects for internal representation date values as 'yyyyMMdd'
    For external representation, the converted and accepted value depends in general on the "Own Data" user settings in the Attribute "Date Format", eg. 'dd.MM.yyyy'
    But it can also depend on how the application handles GUI output, as CL_DEMO_OUTPUT displays a date as 'yyyy-MM-dd'

All you need to do, is use a variable that has a TYPE data element with domain DATS, or at least the TYPE d which is the internal ABAP data type DATS. When this variable is exposed to GUI input, e.g. by being a Report Selection Parameter or by being a Function Module Import Parameter and used with the Function module Test Environment, ABAP will automatically take care of the conversion between internal and external representation in both ways.

REPORT ztest_holiday_get.

PARAMETERS p_from TYPE dats DEFAULT '20200101'.
PARAMETERS p_to   TYPE dats DEFAULT '20201231'.

DATA holidays TYPE TABLE OF iscal_day.

cl_demo_output=>write_text( 'External GUI Representation of date type DATS' ).
cl_demo_output=>write( p_from ).
cl_demo_output=>write( p_to ).

cl_demo_output=>write_text( 'Internal ABAP Representation of date type DATS' ).
cl_demo_output=>write_text( 'P_FROM' ).
cl_demo_output=>write_text( p_from ).
cl_demo_output=>write_text( 'P_TO' ).
cl_demo_output=>write_text( p_to ).

CALL FUNCTION 'HOLIDAY_GET'
  EXPORTING
    holiday_calendar = '01'
    date_from        = p_from
    date_to          = p_to
  TABLES
    holidays         = holidays
  EXCEPTIONS
    OTHERS           = 5.

cl_demo_output=>write_text( 'External GUI Representation of table attributs for holidays' ).
cl_demo_output=>write( holidays ).

cl_demo_output=>write_text( 'Internal ABAP Representation of table attributs for holidays' ).
LOOP AT holidays ASSIGNING FIELD-SYMBOL(<holiday>).
  cl_demo_output=>write_text( <holiday> ).
ENDLOOP.

cl_demo_output=>display( ).

Sandra_Rossi
Active Contributor
0 Kudos
359

Why do you want to call an API with format other than the internal format YYYYMMDD ? (external format like dd.mm.yyyy, etc.)

All API use the internal format only ! (there must be some exceptions of course like language code in BAPIs, etc.)

Before and after calling an API, you may of course convert the format of a date (valid also for others types of variables):

  • Internal -> external : use WRITE variable_type_d TO char_10, or use char_10 = |{ variable_type_d DATE = USER }|.
  • External -> internal : call released function module RS_CONV_EX_2_IN with parameter TABLE_FIELD set to a date field in the DDIC like 'SFLIGHT-FLDATE'.