cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Creation in WD

nishantbansal91
Active Contributor
0 Kudos

Dear Team,

I want to create Dynamic Group in Web Dynpro under ROOTUIELEMENTCONTAINER.

Below is the code i have written.

  root ?= view->get_element('ROOTUIELEMENTCONTAINER').



cl_wd_matrix_layout=>new_matrix_layout( root ) .

    cl_wd_group=>new_group(

     EXPORTING

         id                       = 'G1'

         view                     = view

     RECEIVING

          control                 = lr_group ).

     root->add_child( lr_group ).


     lr_matrix cl_wd_matrix_layout=>new_matrix_layout( lr_group ).

If i commented below line i got exception.

        cl_wd_matrix_layout=>new_matrix_layout( root ) .


So my question is it mandatory to set the matrix layout of the parent element, in my case parent element it is 'ROOTUIELEMENTCONTAINER'.


Because in my case i have used the flow layout attribute under ROOTUIELEMENTCONTAINER.


Manually it's possible but dynamically its not possible.



Thanks

Nishant




Accepted Solutions (1)

Accepted Solutions (1)

ramakrishnappa
Active Contributor
0 Kudos

Hi Nishant,

While generating container elements dynamically, the layout & Layout data information needs to be set and its mandatory and layout data depends on parents layout information.

Regards,

Rama

nishantbansal91
Active Contributor
0 Kudos

Dear Ramakrishnappa,

I have created one page header using FLOW DATA Layout and the Layout of the ROOTUIELEMENTCONTAINER is also flow data. it's working fine.

Now i have to add Group using MATRIX layout under the ROOTUIELEMENTCONTAINER.

   CL_WD_GROUP=>NEW_GROUP(

     EXPORTING

         ID                       = 'G1'

         VIEW                     = VIEW

     RECEIVING

          CONTROL                 = LR_GROUP ).

     ROOT->ADD_CHILD( LR_GROUP ).

     DATA LR_MATRIX TYPE REF TO CL_WD_MATRIX_LAYOUT.

     DATA LR_MAT_H_DATA TYPE REF TO CL_WD_MATRIX_HEAD_DATA.

     LR_MAT_H_DATA  = CL_WD_MATRIX_HEAD_DATA=>NEW_MATRIX_HEAD_DATA( LR_GROUP ).

     LR_MATRIX CL_WD_MATRIX_LAYOUT=>NEW_MATRIX_LAYOUT( LR_GROUP ).


I have written above code.

and the exception is

ERROR: Error in FLOW_LAYOUT "_02" of view "ZKD_BOOKING.MAIN": LayoutData type "MATRIX_HEAD_DATA" for child element "G1" is not permitted (termination: RABAX_STATE)

Thanks

Nishant

ramakrishnappa
Active Contributor
0 Kudos

Hi Nishant,

As I said earlier, the layout data of group is depending on the parent ui element.

Here the parent ROOTUIELEMENTCONTAINER has FLOW layout and you are trying to set MATRIX HEAD DATA as layout data for group. Hence the error.

Instead, you need to set the FLOW DATA as layout data for group.

      cl_wd_flow_data=>new_flow_data( element = lr_group ).

    

Hope this helps you.

Regards,

Rama

nishantbansal91
Active Contributor
0 Kudos

Hi Ramakrishnappa,

I  agreed with your point, but manually it's possible to create the Matrix layout type GRP under ROOTUIELEMENT that type is Matrix layout.

Please correct me if i m wrong in below understanding.

But if it's not possible in dynamic, it means that it's not possible to  create different layout element under one ROOTUIELEMENT.

And suppose my ROOTUIELEMENT layout type is Flowlayout, so all the elements defined under Rootuielement or inside any container have the same layout type.

Thanks

Nishant

ramakrishnappa
Active Contributor
0 Kudos

Hi Nishant,

No, you have understood the concept in other way.

Even using class, methods, It is possible to create a group with layout - matrix  under the parent container ( ROOTUIELEMENTCONTAINER ) which has  flow layout.

There are two points to understand here:

Layout: 

     This is the new layout which child element is going to have ( like flow layout, matrix layout, .. )

Layout Data:

     This is depending on parent's layout information i.e. if parent is having flow layout, child should have flow data as layout data

To make work your scenario, you just need to do as below


CL_WD_GROUP=>NEW_GROUP(

     EXPORTING

         ID                       = 'G1'

         VIEW                     = VIEW

     RECEIVING

          CONTROL                 = LR_GROUP ).

     ROOT->ADD_CHILD( LR_GROUP ).

    

     " Layout

     CL_WD_MATRIX_LAYOUT=>NEW_MATRIX_LAYOUT( LR_GROUP ).

     " Layout data depends on parents layout and position

      cl_wd_flow_data=>new_flow_data( element = lr_group ).

Regards,

Rama

nishantbansal91
Active Contributor
0 Kudos

Dear Ramankrishappa,

Perfect.

Now i got point that if we need to add the new element under UI ELEMENTCONTAINER we have to perform two step.

1, Set the layout of the element.

2. Set the layout data of the element which is depended on the parent element.

Thanks a lot Sir !!!


Nishant

ramakrishnappa
Active Contributor
0 Kudos

You are welcome!!!

Answers (0)