Hi all,
I am working on a Web Dynpro application, I have created this applicaion for an accounting document so it has header data and multiple line item data. As per the requirement I have to put the following logic:
1. When a user enters a value in the field KBLNR on the line item, all the other fields like cost centerm fund, functional area should populate from a database table based on the value of the KBLNR. to get this I have put the following code:
TYPES: BEGIN OF t_kblp, fipos TYPE kblp-fipos, kostl TYPE kostl, END OF t_kblp. DATA lv_kblnr TYPE wd_this->element_t_bseg-kblnr. DATA: lt_kblp TYPE STANDARD TABLE OF t_kblp, wa_kblp LIKE LINE OF lt_kblp, lt_bseg TYPE STANDARD TABLE OF bseg, wa_bseg TYPE bseg. DATA lo_nd_t_bseg TYPE REF TO if_wd_context_node. DATA lo_el_t_bseg TYPE REF TO if_wd_context_element. DATA: ls_t_bseg TYPE wd_this->element_t_bseg, lo_api_controller TYPE REF TO if_wd_controller, lo_message_manager TYPE REF TO if_wd_message_manager, lo_nd_tbseg TYPE REF TO if_wd_context_node, lo_el_tbseg TYPE REF TO if_wd_context_element, lt_el_tbseg TYPE wdr_context_element_set, lv_bseg TYPE bseg. * lo_nd_t_bseg = wd_context->path_get_node( path = `ZDATA.CHANGING.T_BSEG` ). lo_api_controller ?= wd_this->wd_get_api( ). CALL METHOD lo_api_controller->get_message_manager RECEIVING message_manager = lo_message_manager. lo_nd_tbseg = wd_context->path_get_node( path = `ZDATA.CHANGING.T_BSEG` ). lt_el_tbseg = lo_nd_tbseg->get_elements( ). LOOP AT lt_el_tbseg INTO lo_el_tbseg. lo_el_tbseg->get_static_attributes( IMPORTING static_attributes = lv_bseg ). IF lv_bseg-kblnr NE ' '. SELECT fipos kostl pspnr saknr geber grant_nbr gsber fkber FROM kblp INTO CORRESPONDING FIELDS OF wa_kblp WHERE belnr = lv_bseg-kblnr. * navigate from <CONTEXT> to <T_BSEG> via lead selection lo_nd_t_bseg = wd_context->path_get_node( path = `ZDATA.CHANGING.T_BSEG` ). * get element via lead selection lo_el_t_bseg = lo_nd_t_bseg->get_element( ). * set single attribute lo_el_t_bseg->set_attribute( name = `KOSTL` value = wa_kblp-kostl ). lo_el_t_bseg->set_attribute( name = 'FIPOS' value = wa_kblp-fipos ). ENDSELECT. CLEAR: lv_bseg, wa_kblp. ENDLOOP.
now the problem that I am facing is if a user enter two line items ... my code is only brining in the value for KOSTL and FIPOS for the first line item and doing nothing for the second. I debugged and found that loop is working fine and it's going to the second line item successfully but not settting the values of KOSTL and FIPOS for the second line item.
Can you please help me with what I am doing it wrong here.