From f61dc0e8561f7f8872a8184e4a3206ce590c1716 Mon Sep 17 00:00:00 2001 From: danrega <16720986+danrega@users.noreply.github.com> Date: Thu, 24 Apr 2025 17:17:07 +0200 Subject: [PATCH] Update --- 01_Internal_Tables.md | 15 +- 08_EML_ABAP_for_RAP.md | 419 +++++++++++++++++++++++++------ 19_ABAP_for_Cloud_Development.md | 2 +- 3 files changed, 350 insertions(+), 86 deletions(-) diff --git a/01_Internal_Tables.md b/01_Internal_Tables.md index 9cbc86d..2c30dc5 100644 --- a/01_Internal_Tables.md +++ b/01_Internal_Tables.md @@ -167,7 +167,7 @@ Internal Tables ... - It can be declared either explicitly or implicitly. - Standard key of an internal table with a ... - structured line type: The primary table key consists of all fields with character-like and byte-like data types. - - non-structured/elementary line type: The entire table is the key (`table_line`). + - non-structured/elementary line type: The entire table line is the key (`table_line`). - An internal table with no explicit key specification implicitly has the standard table key as the primary table key. - Why respecting standard keys is important: - Sorting of a table can produce unexpected results. @@ -3143,7 +3143,7 @@ DATA(line_ref) = REF #( itab[ 3 ] ).
| Component | Notes | Code Snippet | +
|---|---|---|
| + +[`%cid`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapderived_types_cid.htm), +[`%cid_ref`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapderived_types_cid_ref.htm) + + | + ++ +- [`%cid`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapderived_types_cid.htm) is a string to define a content ID. +- Content IDs are used as a unique and preliminary identifier for +RAP BO operations in which instances are created and especially +in cases where the key values of RAP BO instances are not yet +determined +- Assume that you create a RAP BO instance with an EML create +request and the key value has not yet been determined. In the +same request - a save has not yet been triggered - an update is +requested for this RAP BO instance. Using the content ID, it is +guaranteed that the update operation happens for the desired +instance. For this purpose, derived types for operations like +update or delete include the component +[`%cid_ref`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapderived_types_cid_ref.htm) +to refer to the content ID `%cid` as the name implies. +- Note: You should always fill `%cid` even if not +needed. The specified content ID is only valid within one ABAP +EML request. You can use the optional addition [`AUTO FILL CID`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapmodify_entity_entities_fields.htm#!ABAP_ONE_ADD@1@) in EML modify operations to create `%cid` automatically. However, if you use this addition, you cannot refer to `%cid` in subsequent operations. + + | + ++ +``` abap +MODIFY ENTITIES OF zdemo_abap_rap_ro_m + ENTITY root + CREATE FROM VALUE #( + %control-key_field = if_abap_behv=>mk-on + %control-field1 = if_abap_behv=>mk-on + %control-field2 = if_abap_behv=>mk-on + %control-field3 = if_abap_behv=>mk-on + %control-field4 = if_abap_behv=>mk-on + ( %cid = 'cid5' + key_field = 5 + field1 = 'iii' + field2 = 'jjj' + field3 = 50 + field4 = 51 ) ) + UPDATE FIELDS ( field1 field3 field4 ) + WITH VALUE #( ( %cid_ref = 'cid5' + field1 = 'up_kkk' + field2 = 'up_lll' "Value not considered + field3 = 500 + field4 = 501 ) ) + MAPPED FINAL(mapped) + FAILED FINAL(failed) + REPORTED FINAL(reported). +``` + + | +
| + +[`%key`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapderived_types_key.htm), [`%tky`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapderived_types_tky.htm) + + | + ++ +- Both are component groups summarizing all primary keys of a RAP + BO instance. +- Where possible, it is recommended that you use `%tky` + instead of `%key`. `%tky` includes + `%key` and also the draft indicator + `%is_draft`. When using `%tky` in non-draft + scenarios, you are prepared for a potential, later switch to a + draft scenario. In doing so, you can avoid lots of adaptations + in your code by manually adding the indicator. + + | + ++ +The code snippet visualizes various specification options regarding `%key` and `%tky` as component groups, emphasizing how contained component may be accessed and that these component groups can contain further component groups. + +``` abap +MODIFY ENTITY zdemo_abap_rap_ro_m + CREATE FROM VALUE #( + %control = VALUE #( key_field = if_abap_behv=>mk-on + field1 = if_abap_behv=>mk-on + field2 = if_abap_behv=>mk-on + field3 = if_abap_behv=>mk-on + field4 = if_abap_behv=>mk-on ) + ( %cid = 'cid1' %key-key_field = 1 + field1 = 'aaa' field2 = 'bbb' field3 = 10 field4 = 11 ) + ( %cid = 'cid2' %key = VALUE #( key_field = 2 ) + field1 = 'ccc' field2 = 'ddd' field3 = 20 field4 = 21 ) + ( %cid = 'cid3' key_field = 3 + field1 = 'eee' field2 = 'fff' field3 = 30 field4 = 31 ) + ( %cid = 'cid4' %data-%key-key_field = 4 + field1 = 'ggg' field2 = 'hhh' field3 = 40 field4 = 41 ) + ( %cid = 'cid5' %data-key_field = 5 + field1 = 'iii' field2 = 'jjj' field3 = 50 field4 = 51 ) ) + "Other options for referring to the key besides using %key + "are demonstrated. + UPDATE FIELDS ( field2 ) WITH VALUE #( + ( %key-key_field = 1 field2 = 'up1' ) + ( key_field = 2 field2 = 'up2' ) + ( %tky-%key-key_field = 3 field2 = 'up3' ) + ( %tky-key_field = 4 field2 = 'up4' ) + ( %tky-%pky-%key-key_field = 5 field2 = 'up5' ) + ( %tky-%pky-key_field = 6 field2 = 'up6' ) + ( %pky-key_field = 7 field2 = 'up7' ) + ( %pky-%key-key_field = 8 field2 = 'up8' ) + ( %data-%key-key_field = 9 field2 = 'up9' ) + ( %data-key_field = 10 field2 = 'up10' ) ) + MAPPED FINAL(mapped) + FAILED FINAL(failed) + REPORTED FINAL(reported). +``` + + | +
| + +[`%control`](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapderived_types_control.htm) + + | + ++ +- Structured component that is a component of many BDEF derived types. It contains the names of all key +and data fields of a RAP BO instance, which indicate flags. +- For example, it is used to get information on which fields are provided or set a +flag for which fields are requested by RAP BO providers or RAP +BO consumers respectively during the current EML request. +- For this purpose, the value of each field in the +`%control` structure is of type +`ABP_BEHV_FLAG`. For the value setting, +you can use the structured constant `mk` of interface +`IF_ABAP_BEHV`. Note that the technical +type is `x length 1`. +- Example: If you want to read data from a RAP BO instance and +particular non-key fields in `%control` are set to +`if_abap_behv=>mk-off`, the values of these fields +are not returned in the result. + + | + ++ +``` abap +MODIFY ENTITY zdemo_abap_rap_ro_m + CREATE FROM VALUE #( %control-key_field = if_abap_behv=>mk-on + %control-field1 = if_abap_behv=>mk-on + %control-field2 = if_abap_behv=>mk-on + %control-field3 = if_abap_behv=>mk-on + %control-field4 = if_abap_behv=>mk-on + ( %cid = 'cid1' + key_field = 1 + field1 = 'aaa' + field2 = 'bbb' + field3 = 10 + field4 = 11 ) + ( %cid = 'cid2' + key_field = 2 + field1 = 'ccc' + field2 = 'ddd' + field3 = 20 + field4 = 21 ) ) + MAPPED FINAL(mapped) + FAILED FINAL(failed) + REPORTED FINAL(reported). +``` + + | +
| + +[%is_draft](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapderived_types_is_draft.htm) + + | + ++ +- Represents the draft indicator +- Used in [RAP draft handling](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/ABENRAP_DRAFT_HANDLING_GLOSRY.html) and indicates whether a RAP BO instance is active or not. A RAP BO instance with the draft indicator set to true represents a [RAP draft instance](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abenrap_draft_instance_glosry.htm), e.g. created by a create operation. A commit triggers the saving of the instance to a [draft table](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abendraft_table_glosry.htm). +- Is contained in `%tky` +- Is of type `ABP_BEHV_FLAG` + + | + ++ +``` abap +MODIFY ENTITY zdemo_abap_rap_draft_m + CREATE AUTO FILL CID + FIELDS ( num1 arithm_op num2 ) + WITH VALUE #( ( %is_draft = if_abap_behv=>mk-on + num1 = 1 arithm_op = '+' num2 = 2 ) + ( %is_draft = if_abap_behv=>mk-on + num1 = 2 arithm_op = '*' num2 = 4 ) + ( %is_draft = if_abap_behv=>mk-on + num1 = 3 arithm_op = '-' num2 = 5 ) + ( %is_draft = if_abap_behv=>mk-on + num1 = 1 arithm_op = '/' num2 = 4 ) + ( %is_draft = if_abap_behv=>mk-on + num1 = 2 arithm_op = 'P' num2 = 5 ) ) + FAILED FINAL(f) + REPORTED FINAL(r) + MAPPED FINAL(m). +``` + + | +
| + +[%target](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abapderived_types_target.htm) + + | + ++ +- Used to address compositions such as child entities in create operations. +- Includes the target's primary key and data fields. + + | + ++ +``` abap +MODIFY ENTITIES OF zdemo_abap_rap_ro_m + ENTITY root + CREATE FIELDS ( key_field field1 field2 field3 field4 ) + WITH VALUE #( ( %cid = 'cid_cba' + key_field = 9 + field1 = 'qqq' + field2 = 'rrr' + field3 = 90 + field4 = 91 ) ) + CREATE BY \_child + FIELDS ( key_ch field_ch1 field_ch2 ) WITH VALUE #( + ( %cid_ref = 'cid_cba' + %target = VALUE #( ( %cid = 'cid_ch1' + key_ch = 9 + field_ch1 = 'aaa_ch' + field_ch2 = 99 ) + ( %cid = 'cid_ch2' + key_ch = 10 + field_ch1 = 'bbb_ch' + field_ch2 = 100 ) ) ) ) + MAPPED FINAL(mapped) + FAILED FINAL(failed) + REPORTED FINAL(reported). +``` + + | +