I am trying to create an API allowing user to change certain fields of a notification. The changes will be written using a BAPI BAPI_ALM_NOTIF_DATA_MODIFY
.
I have ls_struc1
that contains all fields I am publishing in the API. Is there a way to set the value in ls_struc2
to X
if ls_struc1
contains a field with the same name?
types: begin of api_struc,
short_text type qmtxt,
priority type priok,
desstdate type strmn,
desenddate type ltrmn,
end of api_struc.
data: ls_struc1 type api_struc,
ls_struc2 type bapi2080_nothdri_x.
Based on some other posts I tried the following solution but could not get it to work.
data: lr_struc1 type ref to cl_abap_structdescr,
lr_struc2 type ref to cl_abap_structdescr,
lt_comp_s1 type cl_abap_structdescr=>component_table,
ls_comp_s1 like line of lt_comp_s1,
lt_comp_s2 type cl_abap_structdescr=>component_table,
ls_comp_s2 like line of lt_comp_s2.
lr_struc1 ?= cl_abap_structdescr=>describe_by_data( ls_struc1 ). " Get the description of the data
lt_comp_s1 = lr_struc1->get_components( ). "Get the fields of the structure
lr_struc2 ?= cl_abap_structdescr=>describe_by_data( ls_struc2 ). " Get the description of the data
lt_comp_s2 = lr_struc2->get_components( ). "Get the fields of the structure
loop at lt_comp_s1 into ls_comp_s1.
loop at lt_comp_s2 into ls_comp_s2.
if ls_comp_s1-name eq ls_comp_s2-name.
ls_comp_s1-value = 'X'. " Here I get an error
endif.
endloop.
Thank you for your help.