I am aworking on a web dynpro application and the screen that Ihave created will have both header data and line item data, to let user enter multiple line items I have written the following logic in the method WDDOINIT of the main view:
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.
DATA ls_t_bseg2 TYPE wd_this->Elements_t_bseg.
* navigate from <CONTEXT> to <T_BSEG> via lead selection
lo_nd_t_bseg = wd_context->path_get_node( path = `PRELIMINARY_POSTING.CHANGING.T_BSEG` ).
DO 10 TIMES.
APPEND INITIAL LINE TO ls_t_bseg2.
CALL METHOD lo_nd_t_bseg->bind_table
new_items = ls_t_bseg2
but right now I have card coded the value upto only ten line items but I want it to be declare dynamacially, for example if user enters 2 line items then only two line items should be available and if he decides to enter more than 10 then that functionality sould also be there.
Can you please help me in this.
If you want to create line items based on user input, then create an input field and bind that to a context attribute of type I.
And create a button and an action for that button. In that action handler, read the input value entered by the user i.e. get the value of context attribute which is bound to the input field and based on that have a loop to create that many line items. Then bind the line items to the context attribute.
Hope this helps!
Let me know if you have any further doubts!