HI Experts,
I have a scenario as below in sap mdg for bp and request to guide me on the same.
I have a CR change screen where i have a button 'disagree' and the entity involved is 'BP_SALES'.
When i disagree, previous changes should fill it in the screen, No issue on the logic in filling the data to Entity.
Issue is , I have used the below piece of code to fill the BP_SALES tab and i have used the enqueue and dequeue...still the values not modifying in the UI screen.
But, when i debug, till end of write, I could able to see updated value flows in write_entity
Kindly suggest me on the same.
sample code for reference ...where lt_sales holds the updated entity values
gr_mdg_api->get_entity_structure(
EXPORTING
iv_entity_name = 'BP_HEADER'
iv_struct_type = if_usmd_conv_som_gov_entity=>gc_struct_key
IMPORTING
er_structure = DATA(lr_header_key_str)
er_table = DATA(lr_header_key_tab) ).
* Assign the created data references for the BP_HEADER to the field symbols
FIELD-SYMBOLS : <lt_header_key> TYPE ANY TABLE .
ASSIGN lr_header_key_str->* TO FIELD-SYMBOL(<ls_header_key>).
ASSIGN lr_header_key_tab->* TO <lt_header_key>.
IF <ls_header_key> IS ASSIGNED.
* Assign Value for the Business Partner
ASSIGN COMPONENT 'BP_HEADER' OF STRUCTURE <ls_header_key> TO FIELD-SYMBOL(<ls_value>).
<ls_value> = ls_bp_header-bp_header .
INSERT <ls_header_key> INTO TABLE <lt_header_key>.
ENDIF.
* Before making changes to an object, the object needs to be enqueued.
DATA : ls_entity_lock TYPE usmd_gov_api_s_ent_tabl,
lt_entity_lock TYPE usmd_gov_api_ts_ent_tabl.
ls_entity_lock-entity = 'BP_HEADER'.
ls_entity_lock-tabl = lr_header_key_tab.
INSERT ls_entity_lock INTO TABLE lt_entity_lock.
TRY.
gr_mdg_api->enqueue_entity(
EXPORTING
it_entity_keys = lt_entity_lock
iv_lock_mode = 'E' ) .
CATCH cx_usmd_gov_api .
ENDTRY.
" writing Entity data with convenience API
ls_api_entity_data-entity = 'BP_SALES'.
gr_mdg_api->get_entity_structure(
EXPORTING
iv_entity_name = 'BP_SALES'
iv_struct_type = if_usmd_conv_som_gov_entity=>gc_struct_key_attr
IMPORTING
er_table = ls_api_entity_data-entity_data
).
ASSIGN ls_api_entity_data-entity_data->* TO <lt_entity_data>.
MOVE-CORRESPONDING lt_sales TO <lt_entity_data>.
lt_api_entity_data = VALUE #( ( ls_api_entity_data ) ).
gr_mdg_api->write_entity_data( it_entity_data = lt_api_entity_data ).
TRY.
gr_mdg_api->dequeue_entity(
EXPORTING
it_entity_keys = lt_entity_lock ) .
CATCH cx_usmd_gov_api .
ENDTRY.