Get Example source ABAP code based on a different SAP table
• %pid ABAP_BDEF_DER_TYP_COMP
%pid>
ABAP_USE %pid> is a component of BDEF derived types> and of type ABP_BEHV_PID>>. It is used as a preliminary ID for RAP BO instances> and only available if late numbering> is defined in the BDEF>. In the RAP save sequence>, %pid> is transformed to the final key values. Regarding %pid> in the ...
RAP interaction phase>:
%pid> is assigned as a temporary identifier for RAP BO instances> in the RAP handler methods> for create operations>.
In these methods, %cid>> must be mapped to %pid > in the RAP response parameter> mapped>.
RAP save sequence>:
To assign the final key values to the instances, the method adjust_numbers>> is called before the actual saving happens with the save>> method. The adjust_numbers> method transforms %pid> into the final key values. Regarding the RAP BO instance identification in late numbering scenarios:
In contrast to %pid>, %cid> and %cid_ref>> are only available on a short-term basis for the current ABAP_EML request within the RAP interaction phase. They are no longer available in the RAP save sequence whereas %pid> is indeed available there as the unique identifier for an instance. %pid> is then transformed into the final keys in the RAP saver method adjust_numbers>. Hence, %pid> serves as a long-term and stable ID until the final key creation which can happen at a later point in time after the instance has been created. For example, in case of a draft> scenario, the final key value creation can be days or weeks after the creation of an instance.
Apart from using %cid> or %cid_ref> , the instance identification from a RAP consumer's point of view can also be done using %pid> or, as it is recommended, the component group> %tky>> which includes %pid> and more (for example, %key>> if %key > is to be used for containing the preliminary key instead of %pid >). Where used>
%pid> occurs in late numbering scenarios only. It is not available in static actions and functions, TYPE TABLE FOR KEY OF> or TYPE STRUCTURE FOR KEY OF>. In case of create operations, %cid> must be mapped to a created %pid >. Both must be inserted in the mapped >> response parameter.
A RAP BO instance must always be identifiable uniquely by its transactional key (%tky>) for internal processing during the RAP interaction phase>. However, in case of late numbering scenarios, instances are identified using preliminary keys in the interaction phase and the early phase of the RAP save sequence> before the save>> method is called. The final key value assignment only takes place in the adjust_numbers>> method. Therefore, the transactional key %tky> also includes the preliminary ID %pid> in late numbering scenarios to ensure the uniqueness also during more than one ABAP session, for example, in draft scenarios. Apart from %pid>, %tky> also includes %key >. Depending on your use case, %key> can also be used as a preliminary identifier by filling the key values with values that are only temporarily valid and transformed into the final keys not until the adjust_numbers> method. That means you can either use %pid> or %key> as preliminary identifiers and leave the other one initial, or you use both of them in combination for uniquely identifying RAP BO instances. In any case, the component group %tky> must in total uniquely identify the instance.
Latest notes:
If late numbering> is specified in the RAP BO root entity>, then late numbering> is inherited by the composition tree. Consequently, %pid> components must also be reflected in the hierarchy of RAP BO instances and non-composition associations before finally setting the keys.
%pid> is contained in the component groups %tky> and %pky>> (while %pky> itself is a component of %tky>). NON_V5_HINTS ABAP_HINT_END
ABAP_FURTHER_INFO Using Keys and Identifying RAP BO Instances in a Nutshell>
ABAP_EXAMPLE_VX5 The following source code section taken from the BP_DEMO_UMANAGED_ROOT_LATE_NUMCCIMP>> of the global class of the behavior pool> BP_DEMO_UMANAGED_ROOT_LATE_NUM>> demonstrates the component %pid> in the context of a create> method that is responsible for creating %pid> and mapping it to %cid>> in an unmanaged scenario. See the executable program for this example in the topic Using %pid>>. METH BP_DEMO_UMANAGED_ROOT_LATE_NUM(CCIMP)=>CREATE ABAP_EXAMPLE_END
ABAP_EXAMPLES_ABEXA
The example Using %pid >> demonstrates the use of %pid> with an unmanaged RAP BO in a late numbering scenario.
The example Using %pre> / %tmp>> also touches upon the use of %pid>. ABAP_EXAMPLE_END