Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Dynamic checkbox creation on selection screen

Former Member
0 Likes
8,196

Hi,

I want to create dynamic checkboxs on selection screen with dynamic name which needs to be fetched from database table.

On selection screen I am having 1 option button (to display employee data manager wise) after clicking on that option button dynamic checkboxes should appear with name of the managers stored in database table.

There are so many threads available on SCN on this topic but I didnt found the answer to my question.

Please help me with this.

Thanks,

Sneha.

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
4,709

Either (as already suggested) prepare a bunch of checkbox, and hide/display those in a classic LOOP AT SCREEN/MODIFY SCREEN in the PBO, AT SELECTION-SCREEN OUTPUT event. Add a SELECTION-SCREEN COMMENT text field (same rule for display/hide) and fill it with manager names.

Or create a small ALV grid and display it in a docking container just under the selection-screen.

Or don't use a SELECTION-SCREEN but create a dynpro with a small table control.

Or use your own imagination...

Regards,

Raymond

Hi,

I want to create dynamic checkboxs on selection screen with dynamic name which needs to be fetched from database table.

On selection screen I am having 1 option button (to display employee data manager wise) after clicking on that option button dynamic checkboxes should appear with name of the managers stored in database table.

There are so many threads available on SCN on this topic but I didnt found the answer to my question.

Please help me with this.

Thanks,

Sneha.

13 REPLIES 13
Read only

Former Member
0 Likes
4,709

Hi;

You can use

cl_ci_query_attributes=>generic

method.

Following document can be helpful:

http://scn.sap.com/community/abap/blog/2015/01/27/simple-generic-selection-screen-for-quick-input-or...

Read only

0 Likes
4,709

Hi Erdem,

It sound good but in my requirement I need to do it using normal ABAP not in OOPS.

Read only

kumar_sp
Explorer
0 Likes
4,709

Hi,

you can try the below mentioned code hope this is help full.

Selection-screen begin of block b1 with frame title text 001.

Parameter p_ch1 as check box.

selection-screen end of block b1.

selection-screen begin of block b2 with frame title text 002.

parameter: p_ch2 as checkbox modify id AA,

                  p_ch3 as checkbox modify id  AA,

                    -----

                    ---

selection-screen end of block b2.

At selection screen.

if p_ch1 = 'X'.

  loop at screen.

  if screen-group = 'AA'.

    screen-active = 1.

  modify-screen.

end if.

endloop.

endif.

Regards,

kumar.

Read only

Former Member
0 Likes
4,709

Hi Sneha,

You can have a popup containing table control with all the checkboxes to select managers. 

Table control with fields as Select (Character 1, checkbox ), then Manager name.

Regards,

Shailesh Nagaonkar.

Read only

0 Likes
4,709

Hi Shailesh,

I want to do it on selection screen only.

Thanks for your reply.

Read only

0 Likes
4,709

Hi Sneha,

You can not achieve this dynamic behaviour on selection-screen itself, you need to have table control/ALV kind of selection wherein, multiple rows of checkboxes can be displayed for selection.

Regards,

Shailesh Nagaonkar.

Read only

former_member302911
Active Participant
0 Likes
4,709

Hi Sneha,

see this example:


REPORT  ZTEST.


TYPE-POOLS icon.


SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION   2.

SELECTION-SCREEN COMMENT    3(15)   text1 MODIF ID aaa.

PARAMETER check1  AS CHECKBOX                MODIF ID aaa.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN POSITION   2.

SELECTION-SCREEN COMMENT    3(15)   text2 MODIF ID aaa.

PARAMETER check2  AS CHECKBOX                MODIF ID aaa.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN PUSHBUTTON 1(4)   button  USER-COMMAND but.

INITIALIZATION.

   LOOP AT SCREEN.

     IF screen-group1 = 'AAA'.

       screen-invisible = 1.

       MODIFY SCREEN.

     ENDIF.

   ENDLOOP.

   MOVE icon_change  TO  button.

AT SELECTION-SCREEN.

   CASE sy-ucomm.

     WHEN 'BUT'.

       LOOP AT SCREEN.

         IF screen-group1 = 'AAA'.

           screen-invisible = 0.

           MODIFY SCREEN.

         ENDIF.

       ENDLOOP.

       MOVE 'Text1' TO  text1.

       MOVE 'Text2' TO  text2.

   ENDCASE.

Best Regards,

Angelo.

Read only

Former Member
0 Likes
4,709

Hello Sneha Jadhav

You can use this way for having List in the output as -

SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-000.
PARAMETERS: month(15) AS LISTBOX VISIBLE LENGTH 10.
SELECTION-SCREEN END OF BLOCK b1.

INITIALIZATION.

    DATA:name TYPE vrm_id,
      list TYPE vrm_values,
      value LIKE LINE OF list.

   name = 'MONTH'.

   value-key = '1'.
   value-text = 'JANUARY'.
   APPEND value TO list.

   value-key = '2'.
   value-text = 'FEBRUARY'.
   APPEND value TO list.

   value-key = '3'.
   value-text = 'MARCH'.
   APPEND value TO list.

   value-key = '4'.
   value-text = 'APRIL'.
   APPEND value TO list.

   value-key = '5'.
   value-text = 'MAY'.
   APPEND value TO list.

   value-key = '6'.
   value-text = 'JUNE'.
   APPEND value TO list.

   value-key = '7'.
   value-text = 'JULY'.
   APPEND value TO list.

   value-key = '8'.
   value-text = 'AUGUST'.
   APPEND value TO list.

   value-key = '9'.
   value-text = 'SEPTEMBER'.
   APPEND value TO list.

   value-key = '10'.
   value-text = 'OCTOBER'.
   APPEND value TO list.

   value-key = '11'.
   value-text = 'NOVEMBER'.
   APPEND value TO list.

   value-key = '12'.
   value-text = 'DECEMBER'.
   APPEND value TO list.

   CALL FUNCTION 'VRM_SET_VALUES'
     EXPORTING
       id              = name
       values          = list
     EXCEPTIONS
       id_illegal_name = 1
       OTHERS          = 2.

Output as -


It displays the list from jan to dec.

Hope , it serves your purpose.

Regards

Karan Kanotra

Read only

0 Likes
4,709

Hi Karan,

I have to use checkbox not listbox.

Thanks

Read only

RaymondGiuseppi
Active Contributor
0 Likes
4,710

Either (as already suggested) prepare a bunch of checkbox, and hide/display those in a classic LOOP AT SCREEN/MODIFY SCREEN in the PBO, AT SELECTION-SCREEN OUTPUT event. Add a SELECTION-SCREEN COMMENT text field (same rule for display/hide) and fill it with manager names.

Or create a small ALV grid and display it in a docking container just under the selection-screen.

Or don't use a SELECTION-SCREEN but create a dynpro with a small table control.

Or use your own imagination...

Regards,

Raymond

Read only

0 Likes
4,709

Hi Raymond,

It sound good. I think using this I can achieve my task. Can you please elaborate a bit.

Thanks,

Sneha.

Read only

0 Likes
4,709

Namaskar Sneha,

you can use hide/unhide, active/ inactive properties of checkboxes as per the input in your selection screen.

If you wish to display the Managers and the checkboxes according to yor input in the option button in your selection scree. you can read the value using FM 'DYNP_VALUES_READ'. and you can get the managers as per your input.

You can use standard abap code for modifying screens, like Loop at screen and modify screen syntax, & also for managers name, you can use selection screen comment.

Regards,

Ashish Patil

Read only

rosenberg_eitan
Active Contributor
0 Likes
4,709

Hi,

Have a look at   FUNCTION 'SELECTION_TEXTS_MODIFY' .

Code fragment:

PARAMETERS: p_so  TYPE radiob RADIOBUTTON GROUP rd1 DEFAULT 'X' USER-COMMAND usr1 .

PARAMETERS: p_cre TYPE radiob RADIOBUTTON GROUP rd1 .

PARAMETERS: p_deb TYPE radiob RADIOBUTTON GROUP rd1 .

PARAMETERS: p_date TYPE datum.

*----------------------------------------------------------------------*

*----------------------------------------------------------------------*

AT SELECTION-SCREEN OUTPUT.

  PERFORM at_selection_screen_output .

*----------------------------------------------------------------------*

*----------------------------------------------------------------------*

FORM at_selection_screen_output .

  DATA: text TYPE rsseltexts-text .

  PERFORM set_text USING 'P_SO'    'P' 'Sales Order' .

  PERFORM set_text USING 'P_CRE'   'P' 'Credit memo' .

  PERFORM set_text USING 'P_DEB'   'P' 'Debit memo' .

  CASE abap_true .

    WHEN p_so.    text = 'Sales Order Entry Date'.

    WHEN p_cre.   text = 'Credit Memo Entry Date'.

    WHEN p_deb.   text = 'Debit Memo Entry Date'.

  ENDCASE.

  PERFORM set_text USING 'P_DATE' 'P' text .

 

*----------------------------------------------------------------------*

FORM set_text

  USING

    name TYPE rsseltexts-name

    kind TYPE rsseltexts-kind

    text ."TYPE rsseltexts-text .

  DATA: it_seltexts TYPE TABLE OF rsseltexts WITH HEADER LINE .

  it_seltexts-name = name .

  it_seltexts-kind = kind .

  it_seltexts-text = text .

  APPEND it_seltexts .

  CALL FUNCTION 'SELECTION_TEXTS_MODIFY'

    EXPORTING

      program  = sy-cprog

    TABLES

      seltexts = it_seltexts.

ENDFORM .                    "set_text

*----------------------------------------------------------------------*

Regards.