cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic programming

Former Member
0 Kudos

Hi,

I am trying to create dynamically a text view but I get an error stating that:

"first child element in a container with "MatrixLayout" must be of type "MatrixHeadData"

This is my code:

       lo_text = cl_wd_text_view=>new_text_view( bind_text = 'ORG_DATA.ORG_NAME'
                                                        id = lv_viewid ).

       CALL METHOD cl_wd_matrix_head_data=>new_matrix_head_data
         EXPORTING
           element = lo_text
         RECEIVING
           control = lo_matrix.

       CALL METHOD cl_wd_matrix_data=>new_matrix_data
         EXPORTING
           element = lo_text
         RECEIVING
           control = lo_matrixd.

       lo_text->set_layout_data( the_layout_data = lo_matrixd  ).

       lo_new_group->add_child(
         EXPORTING
*           index     =     " INDEX
           the_child =     lo_text
       ).

Any help is appreciated.

Thanks,

Tim

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

   CALL METHOD cl_wd_matrix_head_data=>new_matrix_head_data
         EXPORTING
           element = lo_text
         RECEIVING
           control = lo_matrix.

       CALL METHOD cl_wd_matrix_data=>new_matrix_data
         EXPORTING
           element = lo_text
         RECEIVING
           control = lo_matrixd.


lo_matrixd is your matrix data not head one because you have created it by     CALL METHOD cl_wd_matrix_data=>new_matrix_data but  lo_matrix is your header data.


Now you are using your normal Lo_matrixd for adding in below code.

       lo_text->set_layout_data( the_layout_data = lo_matrixd  ).


Change it by,
lo_matrix
       lo_text->set_layout_data( the_layout_data = lo_matrix  ).

This will work.

Former Member
0 Kudos

Thanks for your help. It works now!

Former Member
0 Kudos

You can mark some Answer as Correct or helpful, So that if someone having same problem can get the correct solution easily.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello issue is you are creating a new UI element that should be head data for your TC.

Remove:

    CALL METHOD cl_wd_matrix_data=>new_matrix_data
         EXPORTING
           element = lo_text
         RECEIVING
           control = lo_matrixd.

       lo_text->set_layout_data( the_layout_data = lo_matrixd  ).


and add:

cl_wd_matrix_head_data=>new_matrix_head_data( lo_text ).

For more Info : read the this document , it have some code for dynamic programing: 



ChandraMahajan
Active Contributor
0 Kudos

Hi,

Yes matrixheaddata should be the 1st element.

Refer http://paperstreetenterprises.com/web-dynpro-dynamically-adding-screen-elements/ for example on how to use matrix layout.

Regards,

Chandra