‎2013 Feb 05 9:42 AM
Dear developers, I need your help
I have an internal table (TYPE TIHTTPNVP) with some records in it. See below for details...
I need to get the values into a structure from the sflight model:
How do I get the values from the table into the strucutre? Like the value from the row with the name mndt to the component MANDT in the structure...
‎2013 Feb 05 9:50 AM
Hi Fabian,
You can use ASSIGN COMPONENT OF STRUCTURE for this requirement. You can check the syntax in keyword help.
Something like this:
LOOP AT itab INTO struc.
lv_fieldname = struc-name.
ASSIGN COMPONENT lv_fieldname OF STRUCTURE wa_sflight INTO <fs_field>.
<fs_field> = struc-value.
ENDLOOP.
‎2013 Feb 05 10:11 AM
Kumar Akshat wrote:
Hi Fabian,
You can use ASSIGN COMPONENT OF STRUCTURE for this requirement. You can check the syntax in keyword help.
Dear Kumar,
This ain't work... because I need the components from a table and not from the structure... Or am I wrong?
‎2013 Feb 05 10:16 AM
That was a hint. It was supposed to be built upon. Please check the pseudocode I added in my last response.
‎2013 Feb 05 10:44 AM
Hi,
I think we have two ways to do this
1. as explained above by another user using
DATA : it_data TYPE tihttpnvp,
it TYPE STANDARD TABLE OF sflight,
wa_data TYPE ihttpnvp,
wa TYPE sflight.
DATA: lv_field TYPE text30,
lv_structure_name TYPE text30.
FIELD-SYMBOLS: <fs_value> TYPE any.
FIELD-SYMBOLS: <fs_struc> TYPE any.
lv_structure_name = 'wa_data'.
wa_data-name = 'mandt'.
wa_data-value = '600'.
APPEND wa_data TO it_data.
CLEAR wa_data.
wa_data-name = 'carrid'.
wa_data-value = 'LH'.
APPEND wa_data TO it_data.
CLEAR wa_data.
LOOP AT it_data INTO wa_data.
lv_field = 'VALUE'.
ASSIGN (lv_structure_name) TO <fs_struc>.
ASSIGN COMPONENT lv_field OF STRUCTURE <fs_struc> TO <fs_value>.
IF sy-subrc EQ 0 .
CASE sy-tabix.
WHEN '1'.
MOVE <fs_value> TO wa-mandt.
WHEN '2'.
MOVE <fs_value> TO wa-carrid.
ENDCASE.
ENDIF.
ENDLOOP.
as above its just an example for your understanding.
or
2. as per your method by comparing filed names and pass the values into the corresponding fields.
Thanks
Mani