Ansicht
Dokumentation

ABAPDERIVED_TYPES_KEYS_IDENTIFIERS - DERIVED TYPES KEYS IDENTIFIERS

ABAPDERIVED_TYPES_KEYS_IDENTIFIERS - DERIVED TYPES KEYS IDENTIFIERS

rdisp/max_wprun_time - Maximum work process run time   PERFORM Short Reference  
This documentation is copyright by SAP AG.
SAP E-Book

Use of Keys and RAP BO Instance Identifiers in a Nutshell

The use of keys and RAP BO instance identifiers within RAP BO providers and consumers can be versatile and dependent on the scenario and context, i. e. whether the scenario is a late numbering scenario or not - also considering drafts - and whether the context is the RAP interaction phase or the RAP save sequence. The following bullet points outline the most important aspects.

Non-late numbering scenarios:

  • RAP interaction phase
  • %cid: RAP BO consumer specifies the content ID %cid in RAP create operations for a RAP BO instance, i. e. in requests using CREATE, CREATE BY or RAP factory actions; %cid should be provided even if there are no other operations referring to it with %cid_ref; there are also RAP create operations with the addition AUTO FILL CID in which the %cid specification for the instances is done automatically

  • %cid_ref: Has the same value as %cid; used to refer to a RAP BO instance that has been created with %cid as identifier; however, this %cid must exist in the same MODIFY request so that the reference works

  • %key: Contains the primary key values; since there is no late assignment of key values, %key contains the final key values in both interaction phase and save sequence; If in draft scenarios %key is used instead of %tky, you must ensure to also handle %is_draft for the RAP BO instances as well

  • %tky: The component group includes %key and %is_draft, hence, it is predominantly used in draft scenarios; but it is recommended that %tky is used also in non-draft scenarios for the keys so as to be prepared for a potential later switch to draft

  • %pky: Another option to refer to the keys; in non-late numbering scenarios %key is, in principal, the same as %pky since %pid is not available; in scenarios without late numbering and without draft, %pky is, in principal, %tky since %is_draft is not available

  • The keys might be referred to with as follows (assuming there is one key field whose name is key_field). All options have the same effect and are shown below to visualize the component groups and various options to refer to the key:

      MODIFY ENTITY bdef
       UPDATE SET FIELDS WITH VALUE #(
              "key references
              "( %pky-%key-key_field = ... )
              "( %pky-key_field = ... )
              "( %tky-%pky-%key-key_field = ... )
              "( %tky-%pky-key_field = ... )
              "( %tky-%key-key_field = ... )
              "( %tky-key_field = ... )
              "( %key-key_field = ... )
              "( key_field = ... )
              "even more options are possible with BDEF derived types
              "that include the component group %data
              "( %data-%key-key_field = ... )
              "( %data-key_field = ... )
              ).
  • RAP save sequence
  • No change in key handling.

Late numbering scenarios:

  • RAP interaction phase
  • %cid and %cid_ref are also available in late numbering scenarios fulfilling the same purpose as in non-late numbering scenarios, however, %pid and %key are the most relevant components in the interaction phase to identify instances since they are used for the final key mapping

  • %pid: Preliminary ID for RAP BO instances; usually created for RAP BO instances in the course of create operations

  • %key: might be used to include preliminary keys as RAP BO instance identifiers; it must be ensured that the adjust_numbers method in the RAP save sequence maps the final key values to %key

  • %pky: This component group contains both %pid and %key and might therefore be used to summarize them

  • %tky: In late numbering scenarios, the use is very convenient because %tky contains both %pid and %key as well as %pky (the extra reference to %pid and %key via %pky is redundant); in case of drafts, it also contains %is_draft

  • %pid and %key can both be filled and used in late numbering scenarios to identify a RAP BO instance or just one of them, however, you must ensure that the combination of %pid and %key is unique

  • As an example, there might be the following options for preliminary identifiers to be used with (assuming there is one key field whose name is key_field). All options have the same effect (for %pid or preliminary key values) and are shown below to visualize the component groups and various reference options:

      MODIFY ENTITY bdef
       UPDATE SET FIELDS WITH VALUE #(
              "%pid references
              "( %pid = ... )
              "( %pky-%pid = ... )
              "( %tky-%pid = ... )
              "( %tky-%pky-%pid = ... )
              "key references
              "( %pky-%key-key_field = ... )
              "( %pky-key_field = ... )
              "( %tky-%pky-%key-key_field = ... )
              "( %tky-%pky-key_field = ... )
              "( %tky-%key-key_field = ... )
              "( %tky-key_field = ... )
              "( %key-key_field = ... )
              "( key_field = ... )
              "even more options are possible with BDEF derived types
              "that include the component group %data
              "( %data-%key-key_field = ... )
              "( %data-key_field = ... )
              ).
  • RAP save sequence
  • The focus is here on the adjust_numbers method since it is the method that deals with the final key mapping.

  • Depending on the choice of RAP BO instance identifiers, the following must be mapped to final keys that must be stored in %key: %pid or preliminary key values that have been assigned to %key during the interaction phase

  • %pid and the key values in %key from the interaction phase are automatically assigned to the following component groups when reaching the adjust_numbers method:

The component group %tmp gets assigned the preliminary key values contained in %key; in principal, %tmp takes over the role that %key has had in the interaction phase to hold the preliminary key values
%pre: This component group includes %pid and %tmp and, thus, all possible preliminary identifiers
  • In a nutshell: %pid and %tmp must be mapped to %key in the adjust_numbers method; however, in applications, typically only %pid or %tmp are mapped to %key

  • As an example, there might be the following options how to refer to instances with preliminary identifiers and the final keys within the adjust_numbers method (assuming there is one key field whose name is key_field):

          ...
          APPEND VALUE #( "%pid  = ...
                          "%pre-%pid  = ...
                          "%tmp-key_field  = ...
                          "%pre-%tmp-key_field  = ...
                          "%key-key_field = ...
                          "key_field = ...
                    ) TO mapped-bdef.
          ...

Note

Using %tky is the most convenient choice for referring to keys in whatever context. It always contains all relevant components for the chosen scenario.

See some simple examples on using the various components in the topic Examples for BDEF Derived Type Components.






CL_GUI_FRONTEND_SERVICES - Frontend Services   TXBHW - Original Tax Base Amount in Local Currency  
This documentation is copyright by SAP AG.

Length: 14652 Date: 20240416 Time: 152133     sap01-206 ( 145 ms )