Skip to Content

Introduction

The purpose of this document is to display radio buttons dynamically with dynamic texts. There may be cases where radio buttons and its corresponding text needs to be displayed based on the values being fetched from the internal table. Also the number of radio buttons to be displayed depends on the number of entries in the internal table. For those cases, this document provides a solution for implementing the same in both Module pool and Report programming.

Scenario

Consider a scenario where the screen needs to be created with the list of Purchase order numbers, selecting one option at a time to navigate to the next screen with the corresponding details of that selected purchase order number.

In this case, we require radio buttons whose texts would be decided only at runtime.

Module Pool

Create a screen with maximum number of radio buttons that would be required. Select all the radio buttons. Right click and define a group.

Instead of specifying the radio button name in the Attributes Screen, Create Input /Output fields parallel to the radio buttons to display dynamic texts.

Define the name of Input/Output fields W1, W2, W3 which would be used for populating the values at runtime. Note that ‘Output only ‘option should be checked in the Attributes Screen of the Input/Output fields.

Include the following code.

Data:  tb_ekko type standard table of ekko,
            wa_ekko type ekko,
            rad type char3,
            val type char3,     

            wf_tabix type char2,     

            wf_index type char2.

*Input/output field Declaration

Data:  w1 type char10,
            w2 type char10,
            w3 type char10,
            w4 typechar10.       

Field-symbols: <fs> type any.

                               

PBO Module:

select ebeln zbd1t

          into corresponding fields of table tb_ekko
          from ekko where zbd1t = ‘7’.
describe table tb_ekko lines sy-tfill.

wf_index  = 1.
loop at screen.
concatenate ‘R’ wf_index into rad.

*Logic for Displaying radio buttons based on the table value count.

if screen-name = rad.

if wf_index gt sy-tfill.
  screen-active = ‘0’.
  modify screen.

  wf_index = wf_index + 1.
  continue.

endif.

wf_index = wf_index + 1.
endif.

endloop.

*Logic for Assigning values from table to Input/Output Field.

loop at tb_ekko into wa_ekko.
wf_tabix = sy-tabix.
concatenate ‘W’ tabix into VAL.
assign (val) to <fs>.
move wa_ekko-ebeln to <fs>.
endloop.

unassign <fs>.

Report Program:

In case of report programming, the text of the radio button can be changed dynamically using system field %_R1_%_app_%-text,

Where R1 is the name of the radio button.


Data: tb_ekko
type standard table of ekko,
          wa_ekko
type ekko.

Define radio_but1.

  parameters :&1 radiobutton group GR1 DEFAULT ‘X’.
End-of-definition.

Define radio_but2.

  parameters :&1 radiobutton group GR1.

End-of-definition.

radio_but1:R1.
radio_but2:R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,R13,R14,R15.

Data: rad type char3,

          wf_index type char2,
          temp
type char20,
          temp1
type char2.
Field-symbols: <fs>
type any.
At selection-screen output.

select ebeln ZBD1T
         
into corresponding fields of table tb_ekko
         
from ekko where zbd1t = ‘7’.
describe table tb_ekko lines sy-tfill.

wf_index = 1.

loop at screen.

concatenate ‘R’ wf_index into rad.

*Logic for Displaying radio buttons based on the table value count.

if screen-name = rad.

if wf_index gt sy-tfill.
screen-active = ‘0’.
modify screen.

wf_index = wf_index + 1.
continue.

endif.

wf_index = wf_index + 1.
endif.

endloop.

*Logic for Assigning values from table to Input/Output Field.

loop at tb_ekko into wa_ekko.
temp1 = sy-tabix.
concatenate ‘%_r’ temp1 ‘_%_app_%-text’ into temp. 

assign (temp) to <fs>.

move wa_ekko-ebeln to <fs>.
endloop.

unassign <fs>.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply