Update
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
- [String Processing](#string-processing)
|
||||
- [Regular Expressions](#regular-expressions)
|
||||
- [Time and Date](#time-and-date)
|
||||
- [Calendar-Related Information](#calendar-related-information)
|
||||
- [Runtime Type Services (RTTS)](#runtime-type-services-rtts)
|
||||
- [Assignments](#assignments)
|
||||
- [Information about Non-Initial Structure Components](#information-about-non-initial-structure-components)
|
||||
@@ -1097,6 +1098,80 @@ DATA(repl_result_not_extended) = matcher_not_extended->text.
|
||||
<tr>
|
||||
<td> Class </td> <td> Details/Code Snippet </td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td> <code>CL_ABAP_DATFM</code> </td>
|
||||
<td>
|
||||
For conversions between the external and the internal representation of a date specification
|
||||
|
||||
<br><br>
|
||||
|
||||
``` abap
|
||||
DATA(date4conversion) = CONV d( '20240202' ).
|
||||
DATA conv_date_str TYPE string.
|
||||
DATA conv_date_d TYPE d.
|
||||
DATA date_format TYPE cl_abap_datfm=>ty_datfm.
|
||||
|
||||
"Conversion of d (internal) to string (external time format)
|
||||
TRY.
|
||||
cl_abap_datfm=>conv_date_int_to_ext(
|
||||
EXPORTING im_datint = date4conversion
|
||||
im_datfmdes = cl_abap_datfm=>get_datfm( )
|
||||
IMPORTING ex_datext = conv_date_str
|
||||
ex_datfmused = date_format ).
|
||||
CATCH cx_abap_datfm_format_unknown.
|
||||
ENDTRY.
|
||||
|
||||
"Conversion of string (external) to d (internal time format)
|
||||
TRY.
|
||||
cl_abap_datfm=>conv_date_ext_to_int(
|
||||
EXPORTING im_datext = conv_date_str
|
||||
im_datfmdes = date_format
|
||||
IMPORTING ex_datint = conv_date_d
|
||||
ex_datfmused = date_format ).
|
||||
CATCH cx_abap_datfm_no_date cx_abap_datfm_invalid_date
|
||||
cx_abap_datfm_format_unknown cx_abap_datfm_ambiguous.
|
||||
ENDTRY.
|
||||
```
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td> <code>CL_ABAP_TIMEFM</code> </td>
|
||||
<td>
|
||||
For conversions between the external and the internal representation of a time specification
|
||||
|
||||
<br><br>
|
||||
|
||||
``` abap
|
||||
DATA(time4conversion) = CONV t( '123456' ).
|
||||
DATA conv_time_str TYPE string.
|
||||
DATA conv_time_t TYPE t.
|
||||
|
||||
"Conversion of t (internal) to string (external time format)
|
||||
TRY.
|
||||
cl_abap_timefm=>conv_time_int_to_ext(
|
||||
EXPORTING time_int = time4conversion
|
||||
without_seconds = abap_false
|
||||
format_according_to = cl_abap_timefm=>iso
|
||||
IMPORTING time_ext = conv_time_str ).
|
||||
CATCH cx_parameter_invalid_range.
|
||||
ENDTRY.
|
||||
|
||||
"Conversion of string (external) to t (internal time format)
|
||||
TRY.
|
||||
cl_abap_timefm=>conv_time_ext_to_int(
|
||||
EXPORTING time_ext = conv_time_str
|
||||
IMPORTING time_int = conv_time_t ).
|
||||
CATCH cx_abap_timefm_invalid.
|
||||
ENDTRY.
|
||||
```
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td> <code>CL_ABAP_UTCLONG</code> </td>
|
||||
<td>
|
||||
@@ -1272,6 +1347,158 @@ DATA(m19_subtract_date) = xco_cp=>sy->date( )->subtract( iv_day = 1 iv_month = 1
|
||||
|
||||
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||
|
||||
## Calendar-Related Information
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td> Class </td> <td> Details/Code Snippet </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> <code>CL_FHC_CALENDAR_RUNTIME</code> </td>
|
||||
<td>
|
||||
|
||||
The following example explores accessing calendar-related information (factory and holiday calendars). Find more information in the [SAP Help Portal documentation](https://help.sap.com/docs/BTP/65de2977205c403bbc107264b8eccf4b/f7cbd3c336f84dc09c85639c55b4309f.html?version=Cloud). Note the [released CDS views](https://help.sap.com/docs/BTP/65de2977205c403bbc107264b8eccf4b/cc36b142349f40c499155b65e812c3ac.html?version=Cloud) in that context.
|
||||
|
||||
|
||||
``` abap
|
||||
SELECT FactoryCalendarID
|
||||
FROM I_FactoryCalendarBasic
|
||||
ORDER BY FactoryCalendarID
|
||||
INTO TABLE @DATA(factory_cal_ids).
|
||||
|
||||
SELECT PublicHolidayCalendarID
|
||||
FROM I_PublicHolidayCalendarBasic
|
||||
ORDER BY PublicHolidayCalendarID
|
||||
INTO TABLE @DATA(public_holiday_cal_ids).
|
||||
|
||||
DATA(example_cal_ids) = VALUE string_table( ( `SAP_US` ) ( `SAP_IN` ) ( `SAP_QA` ) ( `SAP_SA` ) ( `SAP_DE_BW` ) ).
|
||||
|
||||
LOOP AT example_cal_ids INTO DATA(example_cal_id).
|
||||
|
||||
IF line_exists( factory_cal_ids[ table_line = example_cal_id ] ).
|
||||
DATA(factory_calendar_id) = CONV cl_fhc_calendar_runtime=>ty_fcal_id( example_cal_id ).
|
||||
ENDIF.
|
||||
|
||||
IF line_exists( public_holiday_cal_ids[ table_line = example_cal_id ] ).
|
||||
DATA(holiday_calendar_id) = CONV cl_fhc_calendar_runtime=>ty_hcal_id( example_cal_id ).
|
||||
ENDIF.
|
||||
|
||||
"---------------------- Factory calendar-related information ----------------------
|
||||
TRY.
|
||||
DATA(factory_cal) = cl_fhc_calendar_runtime=>create_factorycalendar_runtime( iv_factorycalendar_id = factory_calendar_id ).
|
||||
DATA(fc_date_conv) = factory_cal->convert_date_to_factorydate( CONV d( '20241115' ) ).
|
||||
DATA(fc_factory_date_conv) = factory_cal->convert_factorydate_to_date( 7219 ).
|
||||
DATA(fc_last_factory_date) = factory_cal->get_last_factorydate( ).
|
||||
DATA(fc_days_between) = factory_cal->calc_workingdays_between_dates( iv_start = '20241201' iv_end = '20250101' ).
|
||||
DATA(fc_days_add) = factory_cal->add_workingdays_to_date( iv_start = '20241220' iv_number_of_workingdays = 5 ).
|
||||
DATA(fc_days_subtract) = factory_cal->subtract_workingdays_from_date( iv_start = '20250101' iv_number_of_workingdays = 5 ).
|
||||
DATA(fc_is_working_date_1) = factory_cal->is_date_workingday( '20250101' ).
|
||||
DATA(fc_is_working_date_2) = factory_cal->is_date_workingday( '20241231' ).
|
||||
DATA(fc_description) = factory_cal->get_description( ).
|
||||
DATA(fc_id) = factory_cal->get_id( ).
|
||||
CATCH cx_fhc_runtime INTO DATA(error_factory_cal).
|
||||
DATA(error_msg_factory_cal) = error_factory_cal->get_text( ).
|
||||
ENDTRY.
|
||||
|
||||
"---------------------- Holiday calendar-related information ----------------------
|
||||
TRY.
|
||||
DATA(holiday_cal) = cl_fhc_calendar_runtime=>create_holidaycalendar_runtime( iv_holidaycalendar_id = holiday_calendar_id ).
|
||||
DATA(hc_is_holiday) = holiday_cal->is_holiday( CONV d( '20250101' ) ).
|
||||
holiday_cal->calc_holidays_between_dates(
|
||||
EXPORTING
|
||||
iv_start = '20240101'
|
||||
iv_end = '20250101'
|
||||
IMPORTING
|
||||
et_holidays = DATA(hc_holidays_between)
|
||||
).
|
||||
DATA(hc_val_start) = holiday_cal->get_validity_start( ).
|
||||
DATA(hc_val_end) = holiday_cal->get_validity_end( ).
|
||||
DATA(hc_description) = holiday_cal->get_description( ).
|
||||
DATA(hc_id) = holiday_cal->get_id( ).
|
||||
DATA(hc_holiday_assignm) = holiday_cal->get_holiday_assignments( ).
|
||||
|
||||
DATA holidays TYPE string_table.
|
||||
LOOP AT hc_holiday_assignm INTO DATA(holiday_wa).
|
||||
APPEND |Holiday ID: "{ holiday_wa->get_holiday_id( ) }", "{ holiday_wa->get_text( )-description }"| TO holidays.
|
||||
ENDLOOP.
|
||||
|
||||
DATA holidays_in_time_frame TYPE string_table.
|
||||
LOOP AT hc_holidays_between INTO DATA(holiday_info_wa).
|
||||
DATA(hc_get_holiday) = holiday_cal->get_holiday( holiday_info_wa-date ).
|
||||
DATA(hc_holiday_text) = hc_get_holiday->get_text( ).
|
||||
DATA(hc_holiday_class) = hc_get_holiday->get_class( ).
|
||||
DATA(hc_holiday_conf) = hc_get_holiday->get_confession( ).
|
||||
DATA(hc_holiday_type) = hc_get_holiday->get_type( ).
|
||||
DATA(hc_holiday_id) = hc_get_holiday->get_holiday_id( ).
|
||||
APPEND |Date "{ holiday_info_wa-date }", Title "{ hc_holiday_text-description }"| TO holidays_in_time_frame.
|
||||
ENDLOOP.
|
||||
CATCH cx_fhc_runtime INTO DATA(error_holiday_cal).
|
||||
DATA(error_msg_holidays_cal) = error_holiday_cal->get_text( ).
|
||||
ENDTRY.
|
||||
CLEAR: holidays, holidays_in_time_frame.
|
||||
ENDLOOP.
|
||||
```
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> <code>CL_SCAL_UTILS</code> </td>
|
||||
<td>
|
||||
Calendar utilities for getting month names, year and week of a date, first day of a week, name and number of the weekday for a specified date
|
||||
|
||||
|
||||
``` abap
|
||||
TRY.
|
||||
"Getting month names
|
||||
cl_scal_utils=>month_names_get(
|
||||
EXPORTING
|
||||
iv_language = sy-langu
|
||||
IMPORTING
|
||||
et_month_names = DATA(months)
|
||||
ev_returncode = DATA(return_code)
|
||||
).
|
||||
|
||||
DATA(month_names) = VALUE string_table( FOR wa IN months ( CONV string( wa-ltx ) ) ).
|
||||
|
||||
"Getting year and week of a date
|
||||
cl_scal_utils=>date_get_week(
|
||||
EXPORTING
|
||||
iv_date = '20251201'
|
||||
IMPORTING
|
||||
ev_year = DATA(year)
|
||||
ev_week = DATA(week) ).
|
||||
|
||||
"Getting the first day of a week
|
||||
"Note the class documentation
|
||||
cl_scal_utils=>week_get_first_day(
|
||||
EXPORTING
|
||||
iv_year_week = 0
|
||||
iv_year = 2025
|
||||
iv_week = 48
|
||||
IMPORTING
|
||||
ev_date = DATA(date)
|
||||
).
|
||||
|
||||
"Getting the name and number of the weekday for a specified date
|
||||
cl_scal_utils=>date_compute_day(
|
||||
EXPORTING
|
||||
iv_date = '20251201'
|
||||
IMPORTING
|
||||
ev_weekday_number = DATA(day_number)
|
||||
ev_weekday_name = DATA(day_name)
|
||||
).
|
||||
|
||||
CATCH cx_scal INTO DATA(error_scal).
|
||||
DATA(error_msg_scal) = error_scal->get_text( ).
|
||||
ENDTRY.
|
||||
```
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||
|
||||
## Runtime Type Services (RTTS)
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
- [Excursions](#excursions)
|
||||
- [Date, Time, and Time Stamps in String Templates](#date-time-and-time-stamps-in-string-templates)
|
||||
- [Date and Time Functions in ABAP SQL and ABAP CDS](#date-and-time-functions-in-abap-sql-and-abap-cds)
|
||||
- [Calendar-Related Information](#calendar-related-information)
|
||||
- [More Information](#more-information)
|
||||
- [Executable Example](#executable-example)
|
||||
|
||||
@@ -1260,6 +1261,12 @@ INTO @DATA(wa).
|
||||
|
||||
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||
|
||||
### Calendar-Related Information
|
||||
|
||||
Find examples with classes for accessing calendar-related information in [this section](22_Released_ABAP_Classes.md#calendar-related-information) of the *Released ABAP Classes* cheat sheet.
|
||||
|
||||
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||
|
||||
## More Information
|
||||
|
||||
[Date and Time Processing](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abendate_time_processing.htm) in the ABAP Keyword Documentation.
|
||||
|
||||
@@ -77,7 +77,7 @@ ABAP cheat sheets[^1] ...
|
||||
|[ABAP Object Orientation](04_ABAP_Object_Orientation.md)| Working with objects and components, concepts such as inheritance, interfaces, and more | [zcl_demo_abap_objects](./src/zcl_demo_abap_objects.clas.abap) |
|
||||
|[Constructor Expressions](05_Constructor_Expressions.md)| Covers constructor expressions with operators such as `VALUE`, `CORRESPONDING`, `NEW`, `CONV`, `EXACT`, `REF`, `CAST`, `COND`, `SWITCH`, `FILTER`, `REDUCE`, iteration expressions with `FOR`, `LET` expressions | [zcl_demo_abap_constructor_expr](./src/zcl_demo_abap_constructor_expr.clas.abap) |
|
||||
|[Dynamic Programming](06_Dynamic_Programming.md)| Covers field symbols and data references as supporting elements for dynamic programming, dynamic ABAP syntax components, runtime type services (RTTS), i. e. runtime type identification (RTTI) and runtime type creation (RTTC) | [zcl_demo_abap_dynamic_prog](./src/zcl_demo_abap_dynamic_prog.clas.abap) |
|
||||
|[String Processing](07_String_Processing.md)| Creating strings and assigning values, chaining strings, string templates, concatenating, splitting, modifying strings, searching and replacing, regular expressions | [zcl_demo_abap_string_proc](./src/zcl_demo_abap_string_proc.clas.abap) |
|
||||
|[String Processing](07_String_Processing.md)| Creating strings and assigning values, chaining strings, string templates, concatenating, splitting, modifying strings, searching and replacing | [zcl_demo_abap_string_proc](./src/zcl_demo_abap_string_proc.clas.abap) |
|
||||
|[ABAP for RAP: Entity Manipulation Language (ABAP EML)](08_EML_ABAP_for_RAP.md)| Setting EML in the context of RAP, standard (create, read, update, delete) and non-standard operations (actions) | <ul><li>[Demo RAP scenario with a managed RAP BO, external numbering (zcl_demo_abap_rap_ext_num_m)](./src/zcl_demo_abap_rap_ext_num_m.clas.abap)</li><br><li>[Demo RAP scenario with an unmanaged RAP BO, external numbering (zcl_demo_abap_rap_ext_num_u)](./src/zcl_demo_abap_rap_ext_num_u.clas.abap)</li><br><li>[Demo RAP scenario ("RAP calculator") with a managed, draft-enabled RAP BO, late numbering (zcl_demo_abap_rap_draft_ln_m)](./src/zcl_demo_abap_rap_draft_ln_m.clas.abap) <br>Note that this example can also be checked out using the preview version of an SAP Fiori UI. Check the comments in the class for the steps.</li><br><li>[Demonstrating the local consumption of RAP business events in the context of a RAP demo scenario, managed RAP BO with managed internal numbering and additional save (zcl_demo_abap_rap_m_as)](./src/zcl_demo_abap_rap_m_as.clas.abap)</li></ul> |
|
||||
|[Excursion Down to Bits and Bytes](09_Bits_and_Bytes.md)|Covers the technical background of data types and data objects|-|
|
||||
|[ABAP SQL: Working with Hierarchies](10_ABAP_SQL_Hierarchies.md)|Summarizes the functions ABAP SQL offers together with ABAP CDS for working with hierarchical data that is stored in database tables|-|
|
||||
|
||||
Reference in New Issue
Block a user