As Governance API but using single change request using this class cl_usmd_conv_som_gov_api.
Example to read an Account group
DATA:
lr_gov_api TYPE REF TO if_usmd_conv_som_gov_api,
lrs_data TYPE REF TO data,
ls_entity_key TYPE usmd_gov_api_s_ent_tabl,
lt_entity_key TYPE usmd_gov_api_ts_ent_tabl,
ls_entity_data TYPE usmd_gov_api_s_ent_tabl,
lt_entity_data TYPE usmd_gov_api_ts_ent_tabl,
lt_object_dg TYPE usmd_t_crequest_entity,
lr_object_dg TYPE REF TO usmd_s_crequest_entity,
lv_bp TYPE bu_businesspartner,
lwa_ktokd TYPE /mdgbpx/_s_bp_pp_bp_cusgen.
FIELD-SYMBOLS:
<lt_ent_data> TYPE ANY TABLE,
<ls_ent_data> TYPE any,
<ls_key> TYPE any,
<ls_field> TYPE any,
<bp_header> TYPE data,
<lv_ktokd> TYPE ktokd.
lr_gov_api = cl_usmd_conv_som_gov_api=>get_instance( 'BP' ).
IF lr_gov_api->mv_crequest_id IS INITIAL OR lr_gov_api->mv_crequest_id = iv_cr_number.
lr_gov_api->set_environment( iv_crequest_id = iv_cr_number ).
lr_gov_api->get_object_list( IMPORTING et_object_list_db_style = lt_object_dg[] ).
READ TABLE lt_object_dg REFERENCE INTO lr_object_dg
WITH KEY usmd_entity = 'BP_HEADER'.
IF sy-subrc = 0.
lv_bp = lr_object_dg->usmd_value.
ENDIF.
CLEAR:
ls_entity_key, ls_entity_data.
REFRESH:
lt_entity_key, lt_entity_data.
ls_entity_key-entity = 'BP_CUSGEN'.
lr_gov_api->get_entity_structure( EXPORTING iv_entity_name = ls_entity_key-entity
iv_struct_type = lr_gov_api->gc_struct_key
IMPORTING er_table = ls_entity_key-tabl ).
ASSIGN ls_entity_key-tabl->* TO <lt_ent_data>.
CREATE DATA lrs_data LIKE LINE OF <lt_ent_data>.
ASSIGN lrs_data->* TO <ls_ent_data>.
ASSIGN COMPONENT 'BP_HEADER' OF STRUCTURE <ls_ent_data> TO <bp_header>.
<bp_header> = lv_bp.
INSERT <ls_ent_data> INTO TABLE <lt_ent_data>.
INSERT ls_entity_key INTO TABLE lt_entity_key.
lt_entity_data[] = lr_gov_api->read_entity_data( it_entity_keys = lt_entity_key[] ).
READ TABLE lt_entity_data INTO ls_entity_key
WITH TABLE KEY entity = ls_entity_key-entity.
ASSIGN ls_entity_key-tabl->* TO <lt_ent_data>.
CREATE DATA lrs_data LIKE LINE OF <lt_ent_data>.
ASSIGN lrs_data->* TO <ls_ent_data>.
LOOP AT <lt_ent_data> INTO <ls_ent_data>.
ASSIGN COMPONENT 'KTOKD' OF STRUCTURE <ls_ent_data> TO <lv_ktokd>.
IF <lv_ktokd> IS ASSIGNED .
lwa_ktokd = <ls_ent_data>.
APPEND lwa_ktokd TO lt_ktokd.
ENDIF.
ENDLOOP.
ENDIF.
No comments:
Post a Comment