Skip to Content
avatar image
Former Member

Dynamic programming for textview with Radio Buttons in WebDynPro

Hi Guys,

I got a requirement on Dynamic programming in webdynpro.

My requirement is-> online exam pattern and its like the following:

1. Question number - 1

         

  • A. Answer
  • B. Answer
  • C. Answer
  • D. Answer

2. Question number - 2

         

  • A. Answer
  • B. Answer
  • C. Answer
  • D. Answer

3. Question number - 3

         

  • A. Answer
  • B. Answer
  • C. Answer
  • D. Answer

4. Question number - 4

         

  • A. Answer
  • B. Answer
  • C. Answer
  • D. Answer

and so on....

All the records retrieving from the database tables. I have created a one questions related table.

To display as above...I went to dynamic programming in webdynpro.

I'm fetching the table and displaying the User Interface using with TextView UI element along with the displaying the Radio Buttons also. But it is not

displaying as I have shown above. It is displaying as below.

1. Question number - 1

2. Question number - 2

3. Question number - 3

4. Question number - 4

  • A. Answer
  • B. Answer
  • C. Answer
  • D. Answer
  • A. Answer
  • B. Answer
  • C. Answer
  • D. Answer
  • A. Answer
  • B. Answer
  • C. Answer
  • D. Answer
  • A. Answer
  • B. Answer
  • C. Answer
  • D. Answer

and so on......

But I want to display as starting shown manner.

and this is my code which I have used to implement the above please check following code:

data : lr_textview type ref to cl_wd_text_view.
Data:lr_container type ref to cl_wd_uielement_container.
DATA: LR_RADIOBUTTON1  type ref to CL_WD_RADIOBUTTON.
data lr_matrix    type ref to cl_wd_matrix_head_data.


data:
      Node_Ques type ref to If_Wd_Context_Node,
      Elem_Ques type ref to If_Wd_Context_Element,
      Stru_Ques type If_Main_View=>Element_Ques ,
      it_ques TYPE  If_Main_View=>Elements_Ques .
   Node_Ques = wd_Context->get_Child_Node( Name = IF_MAIN_VIEW=>wdctx_Ques ).

select * FROM ZQUESTIONS_TBL INTO CORRESPONDING FIELDS OF TABLE it_ques.

LOOP AT it_ques INTO Stru_Ques .
     
     lr_textview = cl_wd_text_view=>new_text_view( view = view
                                                  text = Stru_Ques-QNAME ) .

               lr_matrix = cl_wd_matrix_head_data=>new_matrix_head_data(  lr_textview ).

               lr_textview->set_layout_data( lr_matrix ).
       
               CALL METHOD lr_container->add_child
                  EXPORTING
                    index     = 1
                    the_child = lr_textview.
  
           
            DO 4 TIMES.
                
                 CALL METHOD cl_wd_radiobutton=>new_radiobutton
                             EXPORTING
*                             BIND_KEY_TO_SELECT = 'SFLIGHT.CONNID '
                              bind_selected_key   =  'SFLIGHT.CONNID '
*                             BIND_TEXT           =  'SFLIGHT.QID'
                             receiving
                               control             = LR_RADIOBUTTON1.

                            lr_matrix = cl_wd_matrix_head_data=>new_matrix_head_data(  LR_RADIOBUTTON1 ).
 
                           LR_CONTAINER->ADD_CHILD( LR_RADIOBUTTON1  ). 
 

 
              ENDDO.                                                                      
  ENDLOOP.

Please let me give me a way to reach my target. Looking forward your answers.

Thanks and Regards

Venkatesh

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Apr 09, 2013 at 11:34 AM

    Hi Venkatesh,

    Try to use row repeater. That will be more suitable for this kind of layout.

    http://wiki.sdn.sap.com/wiki/display/WDABAP/steps+to+create+row+repeater+ui+element

    -Manish

    Add comment
    10|10000 characters needed characters exceeded