SAP RAP
By - desarkardeborshi2020@[Link]
What is Covert Key ? – When we are using standard BDEF for our development, some time
we can see standard BDEF using “Late Numbering” for creating preliminary key %pid.
For example, for PO Creation we use BDEF I_PurchaseOrderTP_2 , for Purchase Contract
BDEF is I_PurchaseContractTP and for Service Entry Sheet BDEF r_serviceentrysheettp.
During CREATE operation using EML, in MAPPED parameter will only return a preliminary
key %pid. Then to retrieve the final key in our application from this preliminary key we must
use the CONVERT KEY key word.
This conversion will call in SAVE Sequence in SAVE_MODIFIED method. And for this we
need to use either Unmanaged Save or Additional Save.
Note:- If we want to save this convert key into the persistence of our own RAP business
object, then we must use the unmanaged save approach.
For Example, here I am using BDEF r_serviceentrysheettp.
Scenario 1- When we are call EML inside our BDEF.
I have created an app where Service Entry Sheet will create when user click on Action
Button.
I have used managed with unmanaged save implementation.
In Behaviour Implementation class (Global Section) I have defined a variable that will hold
the response of my API call.
Page 1 of 4
SAP RAP
By - desarkardeborshi2020@[Link]
In Action “createses” method
METHOD createses.
ENDMETHOD
Here in variable mapped_serviceentry_sheet we will hold the response of our API call i.e.
MAPPED data.
Here we can see EML is returning only preliminary key, that we need to convert in
SAVE_MODIFIED method.
In Method “SAVE_MODIFIED”
METHOD save_modified.
IF update IS NOT INITIAL.
IF zbp_test_r_timesheet=>mapped_serviceentry_sheet IS NOT INITIAL.
LOOP AT zbp_test_r_timesheet=>mapped_serviceentry_sheet-ServiceEntrySheet
ASSIGNING FIELD-SYMBOL(<lfs_ses>).
CONVERT KEY OF r_serviceentrysheettp FROM <lfs_ses>-%pid TO
DATA(ls_ses_key).
ENDLOOP.
ENDIF.
ENDIF.
ENDMETHOD.
Page 2 of 4
SAP RAP
By - desarkardeborshi2020@[Link]
In debugging
Scenario 2 – Call EML outside BDEF or normal class.
MODIFY ENTITIES OF r_serviceentrysheettp
ENTITY serviceentrysheet
CREATE AUTO FILL CID FIELDS (
createdbyuser lastchangedbyuser purchaseorder serviceentrysheetname )
WITH VALUE #( (
CreatedByUser = cl_abap_context_info=>get_user_technical_name( )
LastChangedByUser = cl_abap_context_info=>get_user_technical_name( )
PurchaseOrder = <ls_po>-PurchaseOrder
ServiceEntrySheetName = 'SES Name' ) )
CREATE BY \_serviceentrysheetitem
AUTO FILL CID
FIELDS (
confirmedquantity createdbyuser purchaseorderitem serviceentrysheetitemdesc
serviceperformancedate serviceperformanceenddate ) WITH VALUE #(
( %target = VALUE #( (
ConfirmedQuantity = lv_sum_hrs
CreatedByUser = cl_abap_context_info=>get_user_technical_name( )
PurchaseOrderItem = <ls_podetails>-PurchaseOrderItem
ServicePerformanceDate = <ls_podetails>-ScheduleLineDeliveryDate
ServicePerformanceEndDate = <ls_podetails>-ScheduleLineDeliveryDate ) ) ) )
MAPPED FINAL(lt_mapped)
FAILED FINAL(lt_failed)
REPORTED FINAL(lt_reported).
COMMIT ENTITIES BEGIN
RESPONSE OF r_serviceentrysheettp
FAILED FINAL(failed1)
REPORTED FINAL(reported1).
LOOP AT ls_mapped-serviceentrysheet ASSIGNING FIELD-SYMBOL(<lfs_ses>).
CONVERT KEY OF r_serviceentrysheettp FROM <lfs_ses>-%pid TO DATA(ls_ses).
ENDLOOP.
COMMIT ENTITIES END.
Page 3 of 4
SAP RAP
By - desarkardeborshi2020@[Link]
In debugging
Page 4 of 4