cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic table & More No of buttons addition to the form...

Former Member
0 Kudos

Hi Friends,

I have following issues with my form in webdynpro abap.

1. I have created a main node called ZKPS_TEST and under that I have included three nodes and two attributes.

the three nodes are as follows:

TIME_DATA With cardinality 1..1 --> to upload a row

TIME_SHEET_DATA with cardinality 1..n --> Dynamic Internal table rows

TIME_COST_DATA with cardinality 1..n --> Dynamic Internal table rows.

I have created an interface and mapped to the form.

When I click on Insert Row Button i am getting a dump saying "Number of Elements of the Collection of Node MAIN.1.ZKPS_TEST Violates the Cardinality.". Please guide me how to solve this error.

2. I have to create three more buttons onto the form as follows:

a. Save button to save the entered data

b. Submit button to submit for approval.

c. Total button to validate the total hrs entered on the form.

As the submit action is already used for Insert Row button. How can i create these three buttons and where should write code for the same.

Please do the needful at the earliest.

Thanks in advance.

Regards,

Phani Shankar.K

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Surya,

Thanks for the reply.

Root Node properties: ZKPS_TEST_1

Cardinality: 1..1

selection: 0..1

Child Node properties: TIMESHEET_DATA

Cardinality: 1..n

Selection: 1..1

Yes you are correct, its an dynamic internal table.

As per your suggestion, I changed the code. Now its not giving dump but not adding a new entry.

Please correct me at the earliest.

Thanks a lot in advance.

Final Query: Can we have one root node and many sub nodes in the webdynpro context?

Regards,

Phani Shankar.K

Former Member
0 Kudos

Hi Phani Shankar,

*For ur final query* : U can have any number of sub nodes in a root node... No problem in that..

and for dynamic table, r u sure that u hv given the flowed property for subform in ur Form.. try to debug the code whether rows are appending to the context...?.. whether lt_el_table gets all the rows..? whether ls_table is filled with data in the form...?

regards,

*Surya*

Former Member
0 Kudos

HI Phani,

Try this one...

In ur form keep two buttons.. ADD and SUBMIT..

in the *ADD* button's javascript code add the following,


subformname.tablename.rowname.addInstance(1);
status.rawValue = "ADD";

in *SUBMIT* button's javascript code,


status.rawValue = "SUBMIT";

then, in ur *onactionsubmit*, add the following with ur code (hope u r following my previously posted code..


data:  lt_eban type wd_this->elements_table,
          wa_eban like line of lt_table.
* get single attribute
  lo_el_main->get_attribute(
    exporting
      name =  `STATUS`
    importing
      value = lv_status ).

call method lo_nd_table->get_static_attributes_table
   importing
     table = lt_table.

if lv_status = 'ADD'.
   append wa_table to lt_table.
   clear: wa_table.

call method lo_nd_table->bind_table
   exporting
     new_items = lt_table.

clear lv_status.

elseif lv_status = 'SUBMIT'.

lo_el_table = lo_nd_eban->get_element(  ).

 loop at lt_el_table into lo_el_table.
   lo_el_table->get_static_attributes(
      importing
       static_attributes = ls_table ).
       append ls_table to lt_table.
 endloop.

endif.

regards,

*Surya*

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks a lot for responding Surya.

Yes in debugging i am able to see the dynamically added entries but where as the same is not getting displayed in the form.

Subforms I set them as Flow layout and western text.

Please let me know how to solve this.

Thanks & Regards,

Phani.

Former Member
0 Kudos

Hi Surya,

Thanks a lot for reply.

It will be great if you guide me how to go ahead with first problem too.

Thanks again.

Regards,

Phani Shankar.K

Former Member
0 Kudos

Hi,

I assume that u r adding the rows to a table dynamically and trying to bind that to the context. If it is so,

I too got this dump. So i changed the code.

Add this piece of code in your eventhandler and try...Assume that u hv one root node(1:1) and one subnode- table (1:n)



  data lt_el_table type wdr_context_element_set.

  lt_el_table = lo_nd_table->get_elements(  ).

    loop at lt_el_eban into lo_el_eban.

    lo_el_table->get_static_attributes(
      IMPORTING
      static_attributes = ls_table ).     "fetch the data from existing row
      append ls_table to lt_table.

    endloop.

  append ls_table to lt_table.           " adding a row
  lo_nd_table->bind_table( lt_table ).  " Binding the added row

Regards,

Surya.

Former Member
0 Kudos

Hi Phani Shankar,

For ur Second question,

Include an attribute, say Status (type String), in ur context..

In the Form Builder, Drag and drop that attribute as text field and make that as *Invisible*.

Then in each button, in the javascript coding,

(first for save button)


Status.RawValue = "Save";

(for submit button)


Status.RawValue = "Submit";

(for total button)


Status.RawValue = "Total";

Now in the onactionsubmit event ( in which u hv already written the code ) have a *if else* code.



if lv_status = 'Save'.

"code for save

elseif lv_status = 'Submit'.

" code for submit

else.

"code for total.

endif.

.

Hope tis helps you,..

Regards,

Surya.