Skip to content

Commit 4295ca5

Browse files
committed
Update
1 parent d95fb33 commit 4295ca5

File tree

4 files changed

+95
-44
lines changed

4 files changed

+95
-44
lines changed

01_Internal_Tables.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ DATA(it_e) = VALUE it_type( ( carrid = 'XY' carrname = 'XY Airlines' )
675675
( carrid = 'YZ' carrname = 'Air YZ' ) ).
676676
677677
"Not providing any table lines means the table is initial
678-
"and has the same effect as the declaration of it_f.
678+
"and has the same effect as the declaration of it_g.
679679
DATA(it_f) = VALUE string_table( ).
680680
DATA it_g TYPE string_table.
681681

22_Released_ABAP_Classes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1915,7 +1915,7 @@ DATA(utcl2tsl) = cl_abap_tstmp=>utclong2tstmp( ts2utcl ).
19151915

19161916

19171917
<tr>
1918-
<td> <code>XCO_CP_TIME</code> </td>
1918+
<td> <code>XCO_CP_TIME</code><br><code>XCO_CP</code> </td>
19191919
<td>
19201920
Class of the XCO time library that provides abstractions for getting and working with date and time information. Find more details <a href="https://help.sap.com/docs/btp/sap-business-technology-platform/time-library">here</a>.
19211921
<br><br>

23_Date_and_Time.md

+92-41
Original file line numberDiff line numberDiff line change
@@ -139,25 +139,37 @@ DATA(utc_date) = cl_abap_context_info=>get_system_date( ).
139139
140140
"Using XCO
141141
"Notes:
142-
"- The result of the following chained statement is of type string.
142+
"- The results of the following chained statements are of type string.
143143
"- With the 'as' method, a given format (available via xco_cp_time=>format)
144-
" is applied to the time.
145-
"- The 'date' method has a parameter for specifying the time zone.
146-
" By default, the user's time zone is used. For the specification, you
147-
" can use xco_cp_time=>time_zone.
148-
"e.g. 20240101
149-
DATA(date_1) = xco_cp=>sy->date( )->as( xco_cp_time=>format->iso_8601_basic )->value.
150-
"e.g. 2024-01-01
151-
DATA(date_2) = xco_cp=>sy->date( )->as( xco_cp_time=>format->iso_8601_extended )->value.
152-
"Specifying the default time zone explicitly
144+
" is applied to the time. Several options are available.
145+
"- The 'date' method has an optional importing parameter for specifying the
146+
" time zone. By default, the user's time zone is used. For the specification,
147+
" you can use xco_cp_time=>time_zone.
148+
149+
"The following three examples:
150+
"- do not specify the optional importing parameter for the 'date' method. In
151+
" this case, the user time zone is used implicitly.
152+
"- specify an specific format in the 'as' method.
153+
154+
"e.g. 20250101
155+
DATA(date_abap) = xco_cp=>sy->date( )->as( xco_cp_time=>format->abap )->value.
156+
157+
"e.g. 20250101
158+
DATA(date_basic) = xco_cp=>sy->date( )->as( xco_cp_time=>format->iso_8601_basic )->value.
159+
160+
"e.g. 2025-01-01
161+
DATA(date_ext) = xco_cp=>sy->date( )->as( xco_cp_time=>format->iso_8601_extended )->value.
162+
163+
"Specifying the time zone explicitly in the 'date' method
153164
"The following method call retrieves the current user date.
154-
DATA(date_3) = xco_cp=>sy->date( xco_cp_time=>time_zone->user
155-
)->as( xco_cp_time=>format->iso_8601_extended
156-
)->value.
157-
"Specifying UTC
158-
DATA(date_4) = xco_cp=>sy->date( xco_cp_time=>time_zone->utc
159-
)->as( xco_cp_time=>format->iso_8601_extended
160-
)->value.
165+
DATA(date_user_tz) = xco_cp=>sy->date( xco_cp_time=>time_zone->user
166+
)->as( xco_cp_time=>format->iso_8601_basic
167+
)->value.
168+
169+
"Specifying the UTC time zone
170+
DATA(date_utc_tz) = xco_cp=>sy->date( xco_cp_time=>time_zone->utc
171+
)->as( xco_cp_time=>format->iso_8601_basic
172+
)->value.
161173
162174
"--------------------- Retrieving current date values (XCO) --------------------
163175
"e.g. 01
@@ -492,12 +504,38 @@ The code snippet below provides examples of time processing, such as retrieving
492504
DATA(utc_time) = cl_abap_context_info=>get_system_time( ).
493505
494506
"Using XCO
495-
"Note the optional time zone specification.
507+
"Notes:
508+
"- The results of the following chained statements are of type string.
509+
"- With the 'as' method, a given format (available via xco_cp_time=>format)
510+
" is applied to the time. Several options are available.
511+
"- The 'time' method has an optional importing parameter for specifying the
512+
" time zone. By default, the user's time zone is used. For the specification,
513+
" you can use xco_cp_time=>time_zone.
514+
515+
"The following three examples
516+
"- do not specify the optional importing parameter for the 'time' method. In
517+
" this case, the user time zone is used implicitly.
518+
"- specify an specific format in the 'as' method.
519+
520+
"e.g. 160907
521+
DATA(time_abap) = xco_cp=>sy->time( )->as( xco_cp_time=>format->abap )->value.
522+
523+
"e.g. 160907
524+
DATA(time_basic) = xco_cp=>sy->time( )->as( xco_cp_time=>format->iso_8601_basic )->value.
525+
526+
"e.g. 16:09:07
527+
DATA(time_ext) = xco_cp=>sy->time( )->as( xco_cp_time=>format->iso_8601_extended )->value.
528+
529+
"Specifying the time zone explicitly in the 'time' method
496530
"The following method call retrieves the current user time.
497-
"Result: e.g. 14:39:10
498-
DATA(time_w_xco) = xco_cp=>sy->time( xco_cp_time=>time_zone->user
499-
)->as( xco_cp_time=>format->iso_8601_extended
500-
)->value.
531+
DATA(time_user_tz) = xco_cp=>sy->time( xco_cp_time=>time_zone->user
532+
)->as( xco_cp_time=>format->iso_8601_basic
533+
)->value.
534+
535+
"Specifying the UTC time zone
536+
DATA(time_utc_tz) = xco_cp=>sy->time( xco_cp_time=>time_zone->utc
537+
)->as( xco_cp_time=>format->iso_8601_basic
538+
)->value.
501539
```
502540

503541
### Accessing Time Values
@@ -748,25 +786,38 @@ More information: [`utclong_current`](https://help.sap.com/doc/abapdocu_cp_index
748786
DATA(ts1) = utclong_current( ).
749787
750788
"Using XCO
751-
"In the case of XCO, the return value is of type string.
752-
"Retrieving a time stamp in the user's time zone (which is the default)
753-
"e.g. 2024-01-01T08:54:39
754-
DATA(ts2) = xco_cp=>sy->moment( xco_cp_time=>time_zone->user
755-
)->as( xco_cp_time=>format->iso_8601_extended
756-
)->value.
757-
"Current time stamp in UTC
758-
"e.g. 2024-01-01T08:54:39
759-
DATA(ts3) = xco_cp=>sy->moment( xco_cp_time=>time_zone->utc
760-
)->as( xco_cp_time=>format->iso_8601_extended
761-
)->value.
762-
"Different formatting options
763-
DATA(ts_xco) = xco_cp=>sy->moment( xco_cp_time=>time_zone->utc ).
764-
""e.g. 20240101123455
765-
DATA(ts4) = ts_xco->as( xco_cp_time=>format->abap )->value.
766-
"e.g. 20240101T123455
767-
DATA(ts5) = ts_xco->as( xco_cp_time=>format->iso_8601_basic )->value.
768-
"As used above, e.g. 2024-01-01T12:34:55
769-
DATA(ts6) = ts_xco->as( xco_cp_time=>format->iso_8601_extended )->value.
789+
"Notes:
790+
"- The results of the following chained statements are of type string.
791+
"- With the 'as' method, a given format (available via xco_cp_time=>format)
792+
" is applied to the time. Several options are available.
793+
"- The 'moment' method has an optional importing parameter for specifying the
794+
" time zone. By default, the user's time zone is used. For the specification,
795+
" you can use xco_cp_time=>time_zone.
796+
797+
"The following three examples
798+
"- do not specify the optional importing parameter for the 'moment' method. In
799+
" this case, the user time zone is used implicitly.
800+
"- specify an specific format in the 'as' method.
801+
802+
"e.g. 20250101162319
803+
DATA(ts_abap) = xco_cp=>sy->moment( )->as( xco_cp_time=>format->abap )->value.
804+
805+
"e.g. 20250310T162320
806+
DATA(ts_basic) = xco_cp=>sy->moment( )->as( xco_cp_time=>format->iso_8601_basic )->value.
807+
808+
"e.g. 2025-01-01T16:23:20
809+
DATA(ts_ext) = xco_cp=>sy->moment( )->as( xco_cp_time=>format->iso_8601_extended )->value.
810+
811+
"Specifying the time zone explicitly in the 'moment' method
812+
"The following method call retrieves the current user time stamp.
813+
DATA(ts_user_tz) = xco_cp=>sy->moment( xco_cp_time=>time_zone->user
814+
)->as( xco_cp_time=>format->iso_8601_basic
815+
)->value.
816+
817+
"Specifying the UTC time zone
818+
DATA(ts_utc_tz) = xco_cp=>sy->moment( xco_cp_time=>time_zone->utc
819+
)->as( xco_cp_time=>format->iso_8601_basic
820+
)->value.
770821
```
771822

772823
<p align="right"><a href="#top">⬆️ back to top</a></p>

REUSE.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version = 1
22
SPDX-PackageName = "abap-cheat-sheets"
3-
SPDX-PackageSupplier = "Daniel Reger <daniel.reger@sap.com>"
3+
SPDX-PackageSupplier = "<ospo@sap.com>"
44
SPDX-PackageDownloadLocation = "https://github.com/SAP-samples/abap-cheat-sheets"
55
SPDX-PackageComment = "The code in this project may include calls to APIs (\"API Calls\") of\n SAP or third-party products or services developed outside of this project\n (\"External Products\").\n \"APIs\" means application programming interfaces, as well as their respective\n specifications and implementing code that allows software to communicate with\n other software.\n API Calls to External Products are not licensed under the open source license\n that governs this project. The use of such API Calls and related External\n Products are subject to applicable additional agreements with the relevant\n provider of the External Products. In no event shall the open source license\n that governs this project grant any rights in or to any External Products,or\n alter, expand or supersede any terms of the applicable additional agreements.\n If you have a valid license agreement with SAP for the use of a particular SAP\n External Product, then you may make use of any API Calls included in this\n project's code for that SAP External Product, subject to the terms of such\n license agreement. If you do not have a valid license agreement for the use of\n a particular SAP External Product, then you may only make use of any API Calls\n in this project for that SAP External Product for your internal, non-productive\n and non-commercial test and evaluation of such API Calls. Nothing herein grants\n you any rights to use or access any SAP External Product, or provide any third\n parties the right to use of access any SAP External Product, through API Calls."
66

0 commit comments

Comments
 (0)