Update content
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -53,7 +53,7 @@ Data objects:
|
|||||||
|
|
||||||
## ABAP Data Types
|
## ABAP Data Types
|
||||||
|
|
||||||
ABAP is rich in built-in data types and offers a wide range of options for defining data types and data objects in in different contexts.
|
ABAP is rich in built-in data types and offers a wide range of options for defining data types and data objects in different contexts.
|
||||||
Data types can be divided into three groups:
|
Data types can be divided into three groups:
|
||||||
- [Elementary data types](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenelementary_data_type_glosry.htm)
|
- [Elementary data types](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenelementary_data_type_glosry.htm)
|
||||||
- [Complex data types](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencomplex_data_type_glosry.htm)
|
- [Complex data types](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abencomplex_data_type_glosry.htm)
|
||||||
@@ -63,7 +63,7 @@ For an overview, see the [ABAP Type Hierarchy](https://help.sap.com/doc/abapdocu
|
|||||||
|
|
||||||
### Elementary Data Types
|
### Elementary Data Types
|
||||||
- Elementary (or scalar) data types are based directly on a set of [built-in ABAP types](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenbuiltin_abap_type_glosry.htm).
|
- Elementary (or scalar) data types are based directly on a set of [built-in ABAP types](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenbuiltin_abap_type_glosry.htm).
|
||||||
- Are not composed of of other data types.
|
- Are not composed of other data types.
|
||||||
- Are types for holding numeric values, text information, binary data and special types for date and time.
|
- Are types for holding numeric values, text information, binary data and special types for date and time.
|
||||||
- Are further divided into elementary types of fixed and variable length.
|
- Are further divided into elementary types of fixed and variable length.
|
||||||
- Note: The length and the memory requirements of data objects of fixed length data types are fixed, that is, they cannot change at runtime. The length and memory requirements of data objects of variable length data types can actually change at runtime, depending on their contents.
|
- Note: The length and the memory requirements of data objects of fixed length data types are fixed, that is, they cannot change at runtime. The length and memory requirements of data objects of variable length data types can actually change at runtime, depending on their contents.
|
||||||
|
|||||||
@@ -4,18 +4,21 @@
|
|||||||
* output in the ADT console
|
* output in the ADT console
|
||||||
*
|
*
|
||||||
* -------------------------- NOTE -------------------------------------
|
* -------------------------- NOTE -------------------------------------
|
||||||
* This class is used to display deep types contained in the cheat sheet
|
* This helper class is only used to display complex types contained in
|
||||||
* example classes in older ABAP releases.
|
* the example classes of the ABAP cheat sheets in older ABAP releases.
|
||||||
|
* In newer ABAP releases, this helper class is, in principle, not needed.
|
||||||
|
* You can use the write method of the classrun interface directly and
|
||||||
|
* display all types.
|
||||||
*
|
*
|
||||||
* The code presented in this class is intended only to support the ABAP
|
* The code presented in this class is intended only to support the ABAP
|
||||||
* cheat sheets. It is not intended for direct use in a production system
|
* cheat sheets. It is not intended for direct use in a production system
|
||||||
* environment. The code examples in the ABAP cheat sheets are primarily
|
* environment. The code examples in the ABAP cheat sheets are primarily
|
||||||
* intended to provide a better explanation and visualization of the
|
* intended to provide a better explanation and visualization of the
|
||||||
* syntax and semantics of ABAP statements, not to solve concrete
|
* syntax and semantics of ABAP statements, not to solve concrete
|
||||||
* programming tasks. For production application programs, you should
|
* programming tasks. For production application programs, you should
|
||||||
* always work out your own solution for each individual case. There is
|
* always work out your own solution for each individual case. There is
|
||||||
* no guarantee for the correctness or completeness of the code.
|
* no guarantee for the correctness or completeness of the code.
|
||||||
* Furthermore, there is no legal responsibility or liability for any
|
* Furthermore, there is no legal responsibility or liability for any
|
||||||
* errors or their consequences that may occur when using the the example
|
* errors or their consequences that may occur when using the the example
|
||||||
* code.
|
* code.
|
||||||
*
|
*
|
||||||
@@ -59,99 +62,61 @@ CLASS ZCL_DEMO_ABAP_DISPLAY IMPLEMENTATION.
|
|||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD display.
|
METHOD display.
|
||||||
|
|
||||||
"Checking data type
|
"Checking data type
|
||||||
DATA(type_descr) = cl_abap_typedescr=>describe_by_data( input ).
|
DATA(type_descr) = cl_abap_typedescr=>describe_by_data( input ).
|
||||||
|
|
||||||
CASE type_descr->kind.
|
CASE type_descr->kind.
|
||||||
|
|
||||||
WHEN cl_abap_typedescr=>kind_struct.
|
WHEN cl_abap_typedescr=>kind_struct.
|
||||||
|
|
||||||
DATA(struct_descr) = CAST cl_abap_structdescr( type_descr ).
|
DATA(struct_descr) = CAST cl_abap_structdescr( type_descr ).
|
||||||
|
|
||||||
"Checking for complex output
|
"Checking for complex output
|
||||||
IF struct_descr->struct_kind = cl_abap_structdescr=>structkind_nested
|
IF struct_descr->struct_kind = cl_abap_structdescr=>structkind_nested
|
||||||
OR line_exists( struct_descr->components[ type_kind = cl_abap_typedescr=>typekind_table ] )
|
OR line_exists( struct_descr->components[ type_kind = cl_abap_typedescr=>typekind_table ] )
|
||||||
OR line_exists( struct_descr->components[ type_kind = cl_abap_typedescr=>typekind_dref ] )
|
OR line_exists( struct_descr->components[ type_kind = cl_abap_typedescr=>typekind_dref ] )
|
||||||
OR line_exists( struct_descr->components[ type_kind = cl_abap_typedescr=>typekind_oref ] ).
|
OR line_exists( struct_descr->components[ type_kind = cl_abap_typedescr=>typekind_oref ] ).
|
||||||
|
|
||||||
DATA(to_be_serialized) = abap_true.
|
DATA(to_be_serialized) = abap_true.
|
||||||
|
|
||||||
ELSE.
|
ELSE.
|
||||||
|
|
||||||
DATA(display) = mo_out->get( data = input name = name ).
|
DATA(display) = mo_out->get( data = input name = name ).
|
||||||
|
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
WHEN cl_abap_typedescr=>kind_table.
|
WHEN cl_abap_typedescr=>kind_table.
|
||||||
|
|
||||||
DATA(table_descr) = CAST cl_abap_tabledescr( type_descr ).
|
DATA(table_descr) = CAST cl_abap_tabledescr( type_descr ).
|
||||||
|
|
||||||
TRY.
|
TRY.
|
||||||
DATA(line_type_struct_descr) = CAST cl_abap_structdescr( table_descr->get_table_line_type( ) ).
|
DATA(line_type_struct_descr) = CAST cl_abap_structdescr( table_descr->get_table_line_type( ) ).
|
||||||
|
|
||||||
"Checking for complex output
|
"Checking for complex output
|
||||||
IF line_type_struct_descr->struct_kind = cl_abap_structdescr=>structkind_nested
|
IF line_type_struct_descr->struct_kind = cl_abap_structdescr=>structkind_nested
|
||||||
OR line_exists( line_type_struct_descr->components[ type_kind = cl_abap_typedescr=>typekind_table ] )
|
OR line_exists( line_type_struct_descr->components[ type_kind = cl_abap_typedescr=>typekind_table ] )
|
||||||
OR line_exists( line_type_struct_descr->components[ type_kind = cl_abap_typedescr=>typekind_dref ] )
|
OR line_exists( line_type_struct_descr->components[ type_kind = cl_abap_typedescr=>typekind_dref ] )
|
||||||
OR line_exists( line_type_struct_descr->components[ type_kind = cl_abap_typedescr=>typekind_oref ] ).
|
OR line_exists( line_type_struct_descr->components[ type_kind = cl_abap_typedescr=>typekind_oref ] ).
|
||||||
|
|
||||||
to_be_serialized = abap_true.
|
to_be_serialized = abap_true.
|
||||||
|
|
||||||
ELSE.
|
ELSE.
|
||||||
|
|
||||||
display = mo_out->get( data = input name = name ).
|
display = mo_out->get( data = input name = name ).
|
||||||
|
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
CATCH cx_sy_move_cast_error.
|
CATCH cx_sy_move_cast_error.
|
||||||
|
|
||||||
to_be_serialized = abap_true.
|
to_be_serialized = abap_true.
|
||||||
|
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
|
||||||
WHEN cl_abap_typedescr=>kind_class.
|
WHEN cl_abap_typedescr=>kind_class.
|
||||||
|
|
||||||
to_be_serialized = abap_true.
|
to_be_serialized = abap_true.
|
||||||
|
|
||||||
WHEN cl_abap_typedescr=>kind_intf.
|
WHEN cl_abap_typedescr=>kind_intf.
|
||||||
|
|
||||||
to_be_serialized = abap_true.
|
to_be_serialized = abap_true.
|
||||||
|
|
||||||
WHEN cl_abap_typedescr=>kind_elem.
|
WHEN cl_abap_typedescr=>kind_elem.
|
||||||
|
|
||||||
display = mo_out->get( data = COND string( WHEN name IS INITIAL THEN input ELSE `"` && name && `":` && cl_abap_char_utilities=>newline && input ) ).
|
display = mo_out->get( data = COND string( WHEN name IS INITIAL THEN input ELSE `"` && name && `":` && cl_abap_char_utilities=>newline && input ) ).
|
||||||
|
|
||||||
WHEN cl_abap_typedescr=>kind_ref.
|
WHEN cl_abap_typedescr=>kind_ref.
|
||||||
|
|
||||||
"Checking for data references
|
"Checking for data references
|
||||||
IF type_descr->type_kind = cl_abap_typedescr=>typekind_dref.
|
IF type_descr->type_kind = cl_abap_typedescr=>typekind_dref.
|
||||||
|
|
||||||
"Checking type of dereferenced data object
|
"Checking type of dereferenced data object
|
||||||
DATA(type_check_dref) = cl_abap_typedescr=>describe_by_data( input->* ).
|
DATA(type_check_dref) = cl_abap_typedescr=>describe_by_data( input->* ).
|
||||||
|
|
||||||
"Processing (non-)elementary types
|
"Processing (non-)elementary types
|
||||||
IF type_check_dref->kind = type_descr->kind_elem.
|
IF type_check_dref->kind = type_descr->kind_elem.
|
||||||
|
|
||||||
display = mo_out->get( data = COND string( WHEN name IS INITIAL THEN input->* ELSE `"` && name && `":` && cl_abap_char_utilities=>newline && input->* ) ).
|
display = mo_out->get( data = COND string( WHEN name IS INITIAL THEN input->* ELSE `"` && name && `":` && cl_abap_char_utilities=>newline && input->* ) ).
|
||||||
|
|
||||||
ELSE.
|
ELSE.
|
||||||
|
|
||||||
to_be_serialized = abap_true.
|
to_be_serialized = abap_true.
|
||||||
|
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
ELSE.
|
ELSE.
|
||||||
to_be_serialized = abap_true.
|
to_be_serialized = abap_true.
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
ENDCASE.
|
ENDCASE.
|
||||||
|
|
||||||
"Processing complex output by serializiation
|
"Processing complex output by serializiation
|
||||||
FIND SUBSTRING `Data type not yet supported ...` IN display MATCH OFFSET DATA(off) MATCH LENGTH DATA(len).
|
FIND SUBSTRING `Data type not yet supported ...` IN display MATCH OFFSET DATA(off) MATCH LENGTH DATA(len).
|
||||||
|
|
||||||
IF sy-subrc = 0 OR to_be_serialized = abap_true.
|
IF sy-subrc = 0 OR to_be_serialized = abap_true.
|
||||||
|
|
||||||
"ABAP JSON serializing
|
"ABAP JSON serializing
|
||||||
DATA(json) = /ui2/cl_json=>serialize( data = input
|
DATA(json) = /ui2/cl_json=>serialize( data = input
|
||||||
pretty_name = /ui2/cl_json=>pretty_mode-low_case
|
pretty_name = /ui2/cl_json=>pretty_mode-low_case
|
||||||
@@ -160,16 +125,12 @@ CLASS ZCL_DEMO_ABAP_DISPLAY IMPLEMENTATION.
|
|||||||
format_output = abap_true
|
format_output = abap_true
|
||||||
assoc_arrays = abap_true
|
assoc_arrays = abap_true
|
||||||
assoc_arrays_opt = abap_true ).
|
assoc_arrays_opt = abap_true ).
|
||||||
|
|
||||||
IF to_be_serialized = abap_true.
|
IF to_be_serialized = abap_true.
|
||||||
|
|
||||||
IF name IS INITIAL.
|
IF name IS INITIAL.
|
||||||
REPLACE PCRE `^` IN display WITH json && cl_abap_char_utilities=>newline.
|
REPLACE PCRE `^` IN display WITH json && cl_abap_char_utilities=>newline.
|
||||||
ELSE.
|
ELSE.
|
||||||
REPLACE PCRE `^` IN display WITH `"` && name && `":` && cl_abap_char_utilities=>newline && json && cl_abap_char_utilities=>newline.
|
REPLACE PCRE `^` IN display WITH `"` && name && `":` && cl_abap_char_utilities=>newline && json && cl_abap_char_utilities=>newline.
|
||||||
|
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
"substring found
|
"substring found
|
||||||
ELSE.
|
ELSE.
|
||||||
IF name IS INITIAL.
|
IF name IS INITIAL.
|
||||||
@@ -177,26 +138,18 @@ CLASS ZCL_DEMO_ABAP_DISPLAY IMPLEMENTATION.
|
|||||||
ELSE.
|
ELSE.
|
||||||
REPLACE SECTION OFFSET off LENGTH len OF display WITH `"` && name && `":` && cl_abap_char_utilities=>newline && json && cl_abap_char_utilities=>newline.
|
REPLACE SECTION OFFSET off LENGTH len OF display WITH `"` && name && `":` && cl_abap_char_utilities=>newline && json && cl_abap_char_utilities=>newline.
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
mo_out->write( display ).
|
mo_out->write( display ).
|
||||||
|
|
||||||
ELSE.
|
ELSE.
|
||||||
|
|
||||||
mo_out->write( display ).
|
mo_out->write( display ).
|
||||||
|
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD next_section.
|
METHOD next_section.
|
||||||
|
|
||||||
mo_out->write( `_________________________________________________________________________________`
|
mo_out->write( `_________________________________________________________________________________`
|
||||||
&& cl_abap_char_utilities=>newline
|
&& cl_abap_char_utilities=>newline
|
||||||
&& cl_abap_char_utilities=>newline
|
&& cl_abap_char_utilities=>newline
|
||||||
&& heading
|
&& heading
|
||||||
&& cl_abap_char_utilities=>newline ).
|
&& cl_abap_char_utilities=>newline ).
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user