Hello.
What I am trying to do is to grab everything that's in the ui table into an internal table, then loop at it checking for each record in the db. If the record exists, I would possibly like to modify it, if not - I want to add new record in the db.
Can anybody explain what I am doing wrong please?
* create local data variable to access context information
Data: context_node type ref to if_wd_context_node.
TYPES: BEGIN OF ty_zdest,
mandtid type zdest-mandtid,
zclid TYPE zdest-zclid,
zsid TYPE zdest-zsid,
rfcdest TYPE zdest-rfcdest,
active TYPE zdest-active,
END OF ty_zdest.
DATA: it_zdest TYPE STANDARD TABLE OF ty_zdest,
it_insert TYPE STANDARD TABLE OF ty_zdest,
wa_zdest TYPE ty_zdest,
wa_use TYPE ty_zdest,
wa_test TYPE ty_zdest.
DATA: index type i.
context_node = wd_context->get_child_node( name = 'TEST_NODE').
refresh: it_zdest.
* Get data contained within ABAP web dynpro table
context_node->get_static_attributes_table(
importing
table = it_zdest ).
LOOP AT it_zdest INTO wa_test.
SELECT SINGLE zclid zsid rfcdest active FROM zdest INTO wa_use WHERE zclid = wa_test-zclid AND
zsid = wa_test-zsid.
IF wa_use IS INITIAL.
wa_use-zclid = wa_test-ZCLID.
wa_use-zsid = wa_test-ZSID.
wa_use-rfcdest = wa_test-RFCDEST.
wa_use-active = wa_test-ACTIVE.
APPEND wa_use TO it_insert.
MODIFY zdest FROM TABLE it_insert.
CLEAR wa_use.
ELSE.
UPDATE zdest SET
zclid = wa_use-zclid
zsid = wa_use-zsid
rfcdest = wa_use-rfcdest
active = wa_use-active
WHERE
zclid = wa_test-zclid AND
zsid = wa_test-zsid.
ENDIF.
ENDLOOP.
The code above is contained within on click action of a button.
Any help would be appreciated.
Regards,
Hubert Legowski