cancel
Showing results for 
Search instead for 
Did you mean: 

How to declare multiple line items

Former Member
0 Kudos

Hi all,

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.
  ENDDO.

  CALL METHOD lo_nd_t_bseg->bind_table
    EXPORTING
      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.

Thanks,

Rajat

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Rajat,

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!

Regards,

Srilatha M

Sharathmg
Active Contributor
0 Kudos

In addition to previous reply, bind the user input to the table number of rows property. This will result on user viewing only the number of line items he wishes to add.

Regards,

Sharath

Former Member
0 Kudos

Hi ,

Thanks for your reply, we don;t need a second button on the application as we already have a button that will submit the document . Actually I am very new to web dynpro and still trying to learn it ,so can you please explain me in detail what do I need to do.

Thanks,

Rajat

Former Member
0 Kudos

Hi rajat,

Then you can do that in the event handler of your SUBMIT button.

1. create an input field for number of items and bind that to a context attribute of type I.

2. in the event handler of SUBMIT button, read that context attribute.

3. Then create line items looping n(user input read in step 2) number of items and add them to an internal table.

4. Bind the internal table to the context node.

Hope this helps!

REgards,

Srilatha

Answers (0)