I need to display a pop-up window with data from my database table field (Tab1-camp_type
).
At the moment I created a UI-Component (ZUIC_TYPES
), a table view (VWTYPES
) and added the necessary table field.
At the DO_PREPARE_OUTPUT
method of my context node, I wrote the code, which should give me all values from camp_type
field, but I get only one value repeated 37 times (there are 37 rows in my table).
How can I get all my data in the pop-up?
Here's my code:
DATA:lr_table TYPE REF TO crmc_mktpl_ctype,
lr_struct TYPE crmc_mktpl_ctype,
lt_tabledata TYPE TABLE OF crmc_mktpl_ctype,
ls_tabledata LIKE LINE OF lt_tabledata,
lr_camptype TYPE REF TO cl_bsp_wd_value_node,
lr_col TYPE REF TO cl_crm_bol_bo_col.
"fetch the data.
SELECT DISTINCT camp_type FROM crmc_mktpl_ctype INTO CORRESPONDING FIELDS OF TABLE lt_tabledata.
CHECK sy-subrc = 0.
"create collection object.
CREATE OBJECT lr_col.
CREATE DATA lr_table.
"create one empty value node with the required structure.
CREATE OBJECT lr_camptype
EXPORTING
iv_data_ref = lr_table.
"create value node for each record foound.
LOOP AT lt_tabledata INTO ls_tabledata.
"set the data into the value node.
lr_camptype->if_bol_bo_property_access~set_properties( is_attributes = ls_tabledata ).
"add node to the collection.
lr_col->if_bol_bo_col~add( lr_camptype ).
ENDLOOP.
"all records are processed. set the collection to the collection wrapper of
" context node to make it visible on web ui
me->typed_context->camptype->collection_wrapper->set_collection( lr_col ).