Update
This commit is contained in:
@@ -566,7 +566,7 @@ Due to the rich variety of options, the cheat sheet covers a selection.
|
||||
reasons: Using untyped literals means extra cost in terms of
|
||||
performance since they must be converted by the compiler. Plus,
|
||||
their use can result in errors at runtime whereas typed literals
|
||||
guarantee type compatibility at once.
|
||||
guarantee type compatibility at once. For more information on [typed literals](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abentyped_literal_glosry.htm), refer to the [ABAP Keyword Documentation](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenabap_sql_typed_literals.htm) and the [Typed Literals in ABAP SQL](/16_Data_Types_and_Objects.md#typed-literals-in-abap-sql) section of the *Data Types and Data Objects* cheat sheet.
|
||||
- Regarding host expressions: Structures and internal tables are
|
||||
possible as host expressions for statements modifying the
|
||||
content of database tables as shown further down.
|
||||
@@ -1278,7 +1278,7 @@ SELECT id FROM @itab AS tab WHERE
|
||||
"type-dependent initial values. For more information, refer to the ABAP Keyword Documentation.
|
||||
"The following example uses a left outer join to intentionally create null values. For
|
||||
"this purpose, two demo database tables of the cheat sheet repository are cleared and
|
||||
"populated with specific values to visulaize null values.
|
||||
"populated with specific values to visualize null values.
|
||||
DELETE FROM zdemo_abap_tab1.
|
||||
DELETE FROM zdemo_abap_tab2.
|
||||
MODIFY zdemo_abap_tab1 FROM TABLE @( VALUE #( ( key_field = 1 char1 = 'a' char2 = 'y' )
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
- [Dynamic Specifications in Statements for Processing Internal Tables](#dynamic-specifications-in-statements-for-processing-internal-tables)
|
||||
- [Dynamic ABAP SQL Statements](#dynamic-abap-sql-statements)
|
||||
- [Dynamic Invoke](#dynamic-invoke)
|
||||
- [Dynamic Formatting Option Specifications in String Templates](#dynamic-formatting-option-specifications-in-string-templates)
|
||||
- [Validating Input for Dynamic Specifications (CL\_ABAP\_DYN\_PRG)](#validating-input-for-dynamic-specifications-cl_abap_dyn_prg)
|
||||
- [Runtime Type Services (RTTS)](#runtime-type-services-rtts)
|
||||
- [Getting Type Information at Runtime](#getting-type-information-at-runtime)
|
||||
@@ -1619,6 +1620,43 @@ CALL METHOD oref2->('TRIPLE') PARAMETER-TABLE ptab.
|
||||
result = ptab[ name = 'R_TRIPLE' ]-('VALUE')->*. "9
|
||||
```
|
||||
|
||||
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||
|
||||
### Dynamic Formatting Option Specifications in String Templates
|
||||
|
||||
The following code snippet demonstrates a small selection of dynamic formatting option specifications in string templates.
|
||||
For more details and a complete list of options, refer to the [ABAP Keyword Documentation](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/abapcompute_string_format_options.htm), especially regarding the expected and supported input (attributes of the `CL_ABAP_FORMAT` class). General information on string templates can also be found there and in the [String Processing](/07_String_Processing.md#string-templates) cheat sheet.
|
||||
|
||||
```abap
|
||||
"ALIGN
|
||||
"Only to be used with WIDTH; only the associated values of the following attributes of the
|
||||
"class CL_ABAP_FORMAT can be used (they are of type i): A_LEFT (1), A_RIGHT (2), A_CENTER (3)
|
||||
DATA(some_string) = `##`.
|
||||
DATA(s1) = |{ some_string WIDTH = 10 ALIGN = (1) }<---|. "'## <---'
|
||||
DATA(right) = 2.
|
||||
DATA(s2) = |{ some_string WIDTH = 10 ALIGN = (right) }<---|. "' ##<---'
|
||||
|
||||
|
||||
"The following example uses method chaining with methods of the class
|
||||
"cl_abap_random_int to get a random integer value (in the range of 1 - 3).
|
||||
"The get_next method has a returning parameter, and returns and integer value.
|
||||
DO 5 TIMES.
|
||||
DATA(s3) = |{ some_string WIDTH = 10 ALIGN = cl_abap_random_int=>create( seed = cl_abap_random=>seed( )
|
||||
min = 1 max = 3 )->get_next( ) }<---|.
|
||||
ENDDO.
|
||||
|
||||
"CASE
|
||||
"Values to be used: CL_ABAP_FORMAT=>C_RAW (for not changing the case; 0),
|
||||
"CL_ABAP_FORMAT=>C_UPPER (1), CL_ABAP_FORMAT=>C_LOWER (2)
|
||||
some_string = `AbAp`.
|
||||
DATA(s4) = |{ some_string CASE = (1) }|. "ABAP
|
||||
DATA(s5) = |{ some_string CASE = CONV i( '2' ) }|. "abap
|
||||
DATA int_tab TYPE TABLE OF i WITH EMPTY KEY.
|
||||
int_tab = VALUE #( ( 0 ) ( 1 ) ( 2 ) ).
|
||||
DATA(s6) = |{ some_string CASE = int_tab[ 1 ] }|. "AbAp
|
||||
```
|
||||
|
||||
|
||||
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||
|
||||
### Validating Input for Dynamic Specifications (CL_ABAP_DYN_PRG)
|
||||
|
||||
@@ -260,10 +260,11 @@ within a pair of delimiters (`|...|`) if these expressions can be converted to `
|
||||
- To embed expressions, you enclose them in curly brackets: `{ ... }`.
|
||||
|
||||
> **💡 Note**<br>
|
||||
> String templates form a [string
|
||||
> - String templates form a [string
|
||||
expression](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenstring_expression_glosry.htm "Glossary Entry")
|
||||
that is compiled at runtime. Therefore, a string template that contains only
|
||||
literal text is treated as an expression, which has a performance impact. In such a case, it is preferable to use a text string literal with backquotes.
|
||||
> - It is possible to dynamically specify formatting options. For more information, refer to the [Dynamic Formatting Option Specifications in String Templates](/06_Dynamic_Programming.md#dynamic-formatting-option-specifications-in-string-templates) section of the *Dynamic Programming* cheat sheet.
|
||||
|
||||
Syntax examples:
|
||||
``` abap
|
||||
@@ -893,7 +894,7 @@ Built-in functions:
|
||||
DATA(str) = `Pieces of cakes.`.
|
||||
DATA res TYPE i.
|
||||
|
||||
"find_end returns the sum of the offset of the occurrence
|
||||
"find_end returns the sum of the offset of the occurrence plus the length of the match
|
||||
res = find_end( val = str sub = `of` ). "9
|
||||
|
||||
"find_any_of returns the offset of the occurrence of any character contained in substring
|
||||
|
||||
@@ -82,7 +82,7 @@ ENDIF.
|
||||
- The components of such relational expressions can be [comparisons](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencomparison_glosry.htm) or [predicates](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenpredicate_glosry.htm). Note that for [comparison expressions](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencomparison_expression_glosry.htm),
|
||||
the comparisons are carried out according to [comparison rules](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenlogexp_rules.htm).
|
||||
|
||||
The following code snippet shows a selection of possible expressions and operands of such expressions using a big `IF` statement. Certainly, such a huge statement is far from ideal. Here, the intention is to just cover many syntax options in one go for demonstration purposes.
|
||||
The following code snippet shows a selection of possible expressions and operands of such expressions using a big `IF` statement. Certainly, such a huge statement is far from ideal. Here, the intention is to just cover many syntax options in one go for demonstration purposes. For more information on built-in functions, you can refer to the [Misc Built-In Functions](/24_Misc_Builtin_Functions.md) cheat sheet.
|
||||
|
||||
```abap
|
||||
"Some declarations to be used in the IF statement below
|
||||
@@ -180,7 +180,7 @@ AND check_is_supplied( ) IS NOT INITIAL
|
||||
"expression is false, the result of boolc does not meet the condition IS INITIAL since
|
||||
"a blank and no empty string is returned. If this is desired, the function xsdbool
|
||||
"can be used instead of boolc.
|
||||
AND boolc( check_is_supplied( ) ) = abap_true
|
||||
AND boolc( check_is_supplied( ) ) = `X`
|
||||
|
||||
"Result has the same ABAP type as abap_bool.
|
||||
AND xsdbool( check_is_supplied( ) ) = abap_true
|
||||
|
||||
@@ -1474,33 +1474,31 @@ Typed literal:
|
||||
- More information: Typed literals in [ABAP SQL](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenabap_sql_typed_literals.htm) ([cast expressions in ABAP SQL](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abensql_cast.htm)) and [ABAP CDS](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencds_typed_literal_v2.htm)
|
||||
|
||||
```abap
|
||||
"Specifying a built-in ABAP Dictionary type instead of an
|
||||
"untyped literal as in the example below to foster readibility.
|
||||
SELECT SINGLE
|
||||
FROM i_timezone
|
||||
FROM zdemo_abap_fli
|
||||
FIELDS *
|
||||
WHERE TimeZoneID = char`EST`
|
||||
INTO @DATA(wa_typed_literal).
|
||||
WHERE fldate = dats`20240102`
|
||||
INTO @DATA(wa_typed_literals).
|
||||
|
||||
"Cast with a typed literal to cover a specification true to the
|
||||
"actually expected type. In the case of the example, the data type
|
||||
"char(6) is expected.
|
||||
"Specifying an untyped literal
|
||||
SELECT SINGLE
|
||||
FROM i_timezone
|
||||
FROM zdemo_abap_fli
|
||||
FIELDS *
|
||||
WHERE TimeZoneID = CAST( char`EST` AS CHAR( 6 ) )
|
||||
INTO @DATA(wa_typed_literal_cast).
|
||||
WHERE fldate = '20240102'
|
||||
INTO @DATA(wa_untyped_literals).
|
||||
|
||||
"Untyped literal
|
||||
SELECT SINGLE
|
||||
FROM i_timezone
|
||||
FIELDS *
|
||||
WHERE TimeZoneID = 'EST'
|
||||
INTO @DATA(wa_untyped_literal).
|
||||
|
||||
"Various typed literals
|
||||
"Miscellaneous typed literals in an ABAP SQL statement
|
||||
"Note that typed literals can be specified in in read
|
||||
"positions where host variables are possible.
|
||||
DATA(tmstamp) = CONV timestamp( '20240808112517' ).
|
||||
DATA(some_string) = `Some string`.
|
||||
SELECT SINGLE
|
||||
FROM i_timezone
|
||||
FROM zdemo_abap_fli
|
||||
FIELDS
|
||||
carrid,
|
||||
@some_string AS host_var,
|
||||
char`X` AS flag,
|
||||
int8`32984723948723` AS int8,
|
||||
raw`11` AS raw,
|
||||
@@ -1511,9 +1509,10 @@ SELECT SINGLE
|
||||
"Multiple cast expressions splitting a time stamp into date and time parts
|
||||
CAST( CAST( div( @tmstamp, 1000000 ) AS CHAR ) AS DATS ) AS date,
|
||||
CAST( substring( CAST( @tmstamp AS CHAR ), 9, 6 ) AS TIMS ) AS time,
|
||||
'ABAP' AS txt "Untyped literal
|
||||
WHERE TimeZoneID = CAST( char`EST` AS CHAR( 6 ) )
|
||||
INTO @DATA(wa_some_typed_literal).
|
||||
"Untyped literal
|
||||
'ABAP' AS txt
|
||||
WHERE fldate = dats`20240102`
|
||||
INTO @DATA(wa_misc_typed_literal).
|
||||
```
|
||||
|
||||
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||
|
||||
@@ -647,7 +647,7 @@ xco_cp_json=>data->from_string( json_created_xco )->apply( VALUE #(
|
||||
### Converting string <-> xstring
|
||||
In the code snippets above and in the executable example, many operations are performed using binary data.
|
||||
This excursion shows the conversion of string <-> xstring using a codepage. The examples use UTF-8.
|
||||
For example, you can use the `cl_abap_conv_codepage` class and the [XCO library](https://help.sap.com/docs/btp/sap-business-technology-platform/xco-library?version=Cloud).
|
||||
For example, you can use the `cl_abap_conv_codepage` class and the [XCO library](https://help.sap.com/docs/btp/sap-business-technology-platform/xco-library?version=Cloud). Using the `xco_cp` class of the XCO library, you can also process Base64 representations of raw binary data (see the snippet for `xco_cp` in the [String Processing](/22_Misc_ABAP_Classes.md#string-processing) section of the Misc ABAP Classes cheat sheet).
|
||||
|
||||
```abap
|
||||
DATA(xml_string) = `<TXT>ABAP</TXT>`.
|
||||
|
||||
@@ -788,6 +788,29 @@ DATA(comp) = xco_cp=>string( `some_value` )->split( `_` )->compose( xco_cp_strin
|
||||
"some_value
|
||||
DATA(decomp) = xco_cp=>string( `someValue` )->decompose( xco_cp_string=>decomposition->camel_case )->join( `_` )->value.
|
||||
|
||||
"------ Processing Base64 Representations of Raw Binary Data ------
|
||||
DATA(a_string) = `Hello world`.
|
||||
"string -> xstring
|
||||
"Result: 48656C6C6F20776F726C64
|
||||
DATA(conv_xstring) = xco_cp=>string( a_string
|
||||
)->as_xstring( xco_cp_character=>code_page->utf_8
|
||||
)->value.
|
||||
"Encoding of raw binary data into its Base64 representation
|
||||
"Result: SGVsbG8gd29ybGQ=
|
||||
DATA(raw2base64) = xco_cp=>xstring( conv_xstring
|
||||
)->as_string( xco_cp_binary=>text_encoding->base64
|
||||
)->value.
|
||||
"Decoding of a Base64 representation into raw binary data
|
||||
"Result: 48656C6C6F20776F726C64
|
||||
DATA(base642raw) = xco_cp=>string( raw2base64
|
||||
)->as_xstring( xco_cp_binary=>text_encoding->base64
|
||||
)->value.
|
||||
"xstring -> string
|
||||
"Result: Hello world
|
||||
DATA(conv_string_xco) = xco_cp=>xstring( base642raw
|
||||
)->as_string( xco_cp_character=>code_page->utf_8
|
||||
)->value.
|
||||
|
||||
"--------- Matching string against regular expression ---------
|
||||
DATA match TYPE string.
|
||||
|
||||
|
||||
@@ -1155,56 +1155,7 @@ tz_str = |{ utclong_current( ) TIMEZONE = 'EST' COUNTRY = 'US ' }|. "12/30/2024
|
||||
## Excursions
|
||||
### Typed Literals in ABAP SQL
|
||||
|
||||
Typed literal:
|
||||
- Literal whose data types is defined by specifying a [built-in dictionary type](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenddic_builtin_types.htm) explicitly.
|
||||
- Available for most but not all ABAP Dictionary data types.
|
||||
- Can be used in ABAP SQL and in ABAP CDS.
|
||||
- More information: Typed literals in [ABAP SQL](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenabap_sql_typed_literals.htm) ([cast expressions in ABAP SQL](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abensql_cast.htm)) and [ABAP CDS](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencds_typed_literal_v2.htm)
|
||||
|
||||
```abap
|
||||
SELECT SINGLE
|
||||
FROM i_timezone
|
||||
FIELDS *
|
||||
WHERE TimeZoneID = char`EST`
|
||||
INTO @DATA(wa_typed_literal).
|
||||
|
||||
"Cast with a typed literal to cover a specification true to the
|
||||
"actually expected type. In the case of the example, the data type
|
||||
"char(6) is expected.
|
||||
SELECT SINGLE
|
||||
FROM i_timezone
|
||||
FIELDS *
|
||||
WHERE TimeZoneID = CAST( char`EST` AS CHAR( 6 ) )
|
||||
INTO @DATA(wa_typed_literal_cast).
|
||||
|
||||
"Untyped literal
|
||||
SELECT SINGLE
|
||||
FROM i_timezone
|
||||
FIELDS *
|
||||
WHERE TimeZoneID = 'EST'
|
||||
INTO @DATA(wa_untyped_literal).
|
||||
|
||||
"Various typed literals
|
||||
DATA(tmstamp) = CONV timestamp( '20240808112517' ).
|
||||
SELECT SINGLE
|
||||
FROM i_timezone
|
||||
FIELDS
|
||||
char`X` AS flag,
|
||||
int8`32984723948723` AS int8,
|
||||
raw`11` AS raw,
|
||||
numc`1234` AS numc,
|
||||
utclong`2024-01-01T10:01:02,2` AS utc,
|
||||
tims`101507` AS tims,
|
||||
curr`173.95` AS curr,
|
||||
"Multiple cast expressions splitting a time stamp into date and time parts
|
||||
CAST( CAST( div( @tmstamp, 1000000 ) AS CHAR ) AS DATS ) AS date,
|
||||
CAST( substring( CAST( @tmstamp AS CHAR ), 9, 6 ) AS TIMS ) AS time,
|
||||
'ABAP' AS txt "Untyped literal
|
||||
WHERE TimeZoneID = CAST( char`EST` AS CHAR( 6 ) )
|
||||
INTO @DATA(wa_some_typed_literals).
|
||||
```
|
||||
|
||||
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||
The following code snippets use [typed literals](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abentyped_literal_glosry.htm). For more information, refer to the [ABAP Keyword Documentation](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenabap_sql_typed_literals.htm) and the [Typed Literals in ABAP SQL](/16_Data_Types_and_Objects.md#typed-literals-in-abap-sql) section of the *Data Types and Data Objects* cheat sheet.
|
||||
|
||||
### Date and Time Functions in ABAP SQL
|
||||
|
||||
@@ -1324,6 +1275,6 @@ Find examples in the ABAP Keyword Documentation and a small selection of functio
|
||||
[zcl_demo_abap_date_time](./src/zcl_demo_abap_date_time.clas.abap)
|
||||
|
||||
> **💡 Note**<br>
|
||||
> - The executable example covers the handling and processing of date, time, and time stamps. The snippets of this cheat sheets are included, as well as an excursion (*ABAP stopwatch*).
|
||||
> - The executable example covers the handling and processing of date, time, and time stamps. The snippets of this cheat sheets and more are included.
|
||||
> - The steps to import and run the code are outlined [here](README.md#-getting-started-with-the-examples).
|
||||
> - [Disclaimer](README.md#%EF%B8%8F-disclaimer)
|
||||
@@ -13,7 +13,7 @@
|
||||
- [Functions for Numeric Values](#functions-for-numeric-values)
|
||||
- [Functions for Strings](#functions-for-strings)
|
||||
- [Functions for Date, Time, and Time Stamps](#functions-for-date-time-and-time-stamps)
|
||||
- [More Functions](#more-functions)
|
||||
- [More (Special) Functions](#more-special-functions)
|
||||
- [coalesce Function](#coalesce-function)
|
||||
- [More Information](#more-information)
|
||||
|
||||
@@ -170,7 +170,7 @@ DATA(cont5) = xsdbool( contains( val = `123` start = `2` ) ).
|
||||
|
||||
"off/len can also be specified individually
|
||||
"Not specifying off means 0 by default
|
||||
"abap_false
|
||||
"abap_false
|
||||
DATA(cont6) = xsdbool( contains( val = `##ab## ##cd##` sub = `cd` len = 5 ) ).
|
||||
|
||||
"abap_true
|
||||
@@ -189,7 +189,7 @@ ENDDO.
|
||||
DATA(cont9) = xsdbool( contains( val = `Hallo world` pcre = `\s` ) ).
|
||||
|
||||
"-------------------- contains_any_of --------------------
|
||||
"abap_true
|
||||
"abap_true
|
||||
DATA(cont10) = xsdbool( contains_any_of( val = `abcdefg` sub = `xyza` ) ).
|
||||
|
||||
"abap_false
|
||||
@@ -207,7 +207,7 @@ DATA(cont13) = xsdbool( contains_any_of( val = hi end = abc ) ).
|
||||
"abap_true
|
||||
DATA(cont14) = xsdbool( contains_any_not_of( val = hi start = abc ) ).
|
||||
|
||||
"abap_false
|
||||
"abap_false
|
||||
DATA(cont15) = xsdbool( contains_any_not_of( val = hi end = abc ) ).
|
||||
```
|
||||
|
||||
@@ -256,7 +256,7 @@ DATA(line_exists3) = xsdbool( line_exists( itab[ comp1 = 2 ] ) ).
|
||||
"abap_true
|
||||
DATA(line_exists4) = xsdbool( line_exists( str_tab[ 2 ] ) ).
|
||||
|
||||
"abap_false
|
||||
"abap_false
|
||||
DATA(line_exists5) = xsdbool( line_exists( str_tab[ table_line = `xxx` ] ) ).
|
||||
```
|
||||
|
||||
@@ -314,7 +314,7 @@ DATA(ceil4) = ceil( CONV decfloat34( '-4.001' ) ).
|
||||
"4
|
||||
DATA(floor1) = floor( CONV decfloat34( '4.999' ) ).
|
||||
|
||||
"4
|
||||
"4
|
||||
DATA(floor2) = floor( CONV decfloat34( '4.001' ) ).
|
||||
|
||||
"-5
|
||||
@@ -376,13 +376,13 @@ Numeric extremum functions that return the value of the largest or smallest of t
|
||||
"A minimum of two, and a maximum of 9 arguments can be specified.
|
||||
"Numeric data objects and numeric expressions are possible
|
||||
"0.999
|
||||
DATA(nmin1) = nmin( val1 = CONV decfloat34( '1.34' )
|
||||
DATA(nmin) = nmin( val1 = CONV decfloat34( '1.34' )
|
||||
val2 = CONV decfloat34( '56.7' )
|
||||
val3 = CONV decfloat34( '890.123' )
|
||||
val4 = CONV decfloat34( '0.999' ) ).
|
||||
|
||||
"890.123
|
||||
DATA(nmax2) = nmax( val1 = CONV decfloat34( '1.34' )
|
||||
DATA(nmax) = nmax( val1 = CONV decfloat34( '1.34' )
|
||||
val2 = CONV decfloat34( '56.7' )
|
||||
val3 = CONV decfloat34( '890.123' )
|
||||
val4 = CONV decfloat34( '0.999' ) ).
|
||||
@@ -394,7 +394,7 @@ DATA(nmax2) = nmax( val1 = CONV decfloat34( '1.34' )
|
||||
<tr>
|
||||
<td> <code>acos</code><br><code>asin</code><br><code>atan</code><br><code>cos</code><br><code>sin</code><br><code>tan</code><br><code>cosh</code><br><code>sinh</code><br><code>tanh</code><br><code>exp</code><br><code>log</code><br><code>log10</code><br><code>sqrt</code> </td>
|
||||
<td>
|
||||
Regarding the details of result and type conversion of floating point functions, refer to the ABAP Keyword Documentation. The following snippet shows a small selection.
|
||||
Regarding the details of the result and type conversion of floating point functions, refer to the ABAP Keyword Documentation. The following snippet shows a small selection.
|
||||
<br><br>
|
||||
|
||||
``` abap
|
||||
@@ -508,7 +508,7 @@ DATA(conv_str) = cl_abap_conv_codepage=>create_in( )->convert( xstr ).
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td> <code>nmax</code><br><code>nmin</code> </td>
|
||||
<td> <code>cmin</code><br><code>cmax</code> </td>
|
||||
<td>
|
||||
Character-like extremum value functions return a string that contains the content of the smallest or biggest of a set of character-like arguments.
|
||||
<br><br>
|
||||
@@ -924,13 +924,11 @@ DO.
|
||||
ENDDO.
|
||||
|
||||
*Content of segment_tab
|
||||
*Row TABLE_LINE
|
||||
*===============
|
||||
*1 a
|
||||
*2 b
|
||||
*3 c
|
||||
*4 d
|
||||
*5 e
|
||||
*a
|
||||
*b
|
||||
*c
|
||||
*d
|
||||
*e
|
||||
```
|
||||
|
||||
</td>
|
||||
@@ -1080,7 +1078,7 @@ DATA(from_mixed2) = from_mixed( val = `AbaP` sep = `#` ).
|
||||
"ABA_P
|
||||
DATA(from_mixed3) = from_mixed( val = `AbaP` ).
|
||||
|
||||
"ABA#P (same as previous example)
|
||||
"ABA#P (same as previous example)
|
||||
DATA(from_mixed4) = from_mixed( val = `AbaP` sep = `#` case = 'X' ).
|
||||
|
||||
"aba#p
|
||||
@@ -1238,7 +1236,7 @@ DATA(ts_diff2) = utclong_diff( high = ts5
|
||||
## Table Functions
|
||||
|
||||
> **💡 Note**<br>
|
||||
> See the `line_exists` functions in the [Logical Functions](#logical-functions) section.
|
||||
> See the `line_exists` function in the [Logical Functions](#logical-functions) section.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
@@ -1377,6 +1375,8 @@ SELECT SINGLE
|
||||
INTO @DATA(numeric_functions).
|
||||
```
|
||||
|
||||
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||
|
||||
### Functions for Strings
|
||||
|
||||
```abap
|
||||
@@ -1434,7 +1434,7 @@ SELECT SINGLE
|
||||
|
||||
"Searches a PCRE pattern, returns offset of match + 1;
|
||||
"many optional parameters: occurrence, case_sensitive, start, group
|
||||
"2
|
||||
"2
|
||||
locate_regexpr_after( pcre = '.', "Any character
|
||||
value = url,
|
||||
occurrence = 1 ) AS locate_regexpr_after,
|
||||
@@ -1455,7 +1455,7 @@ SELECT SINGLE
|
||||
|
||||
"Replaces a found PCRE expression;
|
||||
"more parameters possible: occurrence, case_sensitive, start
|
||||
"http://www#ufthansa#om
|
||||
"http://www#ufthansa#om
|
||||
replace_regexpr( pcre = '\..', "Period that is followed by any character
|
||||
value = url,
|
||||
with = '#' ) AS replace_regex,
|
||||
@@ -1496,6 +1496,7 @@ SELECT SINGLE
|
||||
INTO @DATA(string_functions).
|
||||
```
|
||||
|
||||
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||
|
||||
### Functions for Date, Time, and Time Stamps
|
||||
|
||||
@@ -1652,7 +1653,9 @@ WHERE TimeZoneID = char`EST`
|
||||
INTO @DATA(time_and_date_functions).
|
||||
```
|
||||
|
||||
### More Functions
|
||||
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||
|
||||
### More (Special) Functions
|
||||
|
||||
```abap
|
||||
SELECT SINGLE
|
||||
@@ -1662,7 +1665,7 @@ SELECT SINGLE
|
||||
"length string of type string
|
||||
to_clob( carrid ) AS clob,
|
||||
|
||||
"Byte string -> character string
|
||||
"Byte string -> character string
|
||||
bintohex( raw`1234` ) AS bintohex,
|
||||
|
||||
"Character string -> byte string
|
||||
@@ -1694,6 +1697,8 @@ SELECT SINGLE
|
||||
INTO @DATA(special_functions).
|
||||
```
|
||||
|
||||
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||
|
||||
### coalesce Function
|
||||
|
||||
```abap
|
||||
@@ -1736,6 +1741,8 @@ SELECT tab2~key_field,
|
||||
*4 - #
|
||||
```
|
||||
|
||||
<p align="right"><a href="#top">⬆️ back to top</a></p>
|
||||
|
||||
## More Information
|
||||
|
||||
- [Built-in functions in ABAP](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenbuilt_in_functions.htm)
|
||||
|
||||
Reference in New Issue
Block a user