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 Pushbuttons in screen

Former Member
0 Likes
1,415

Hi Everyone,

How to generate pushbuttons dynamically in screen.

Example: when we select item data from table if there are 2 entires 2 pushbuttons should be generate,if 5 item entires 5 pushbuttons should be generate dynamically...

similar requirement for text fields in screen as well.

I search a lot in sdn but could not found solution for this requirement .

Regards

Anil

8 REPLIES 8
Read only

Former Member
0 Likes
949

Hi Friends,

Any help on this?

Regards

Anil

Read only

0 Likes
949

Hi,

I am afraid to say that It is not possible in Screens to create Dynamical push button

but your requirement is like that it can created in reports using ALV concept . In that at cell level we can create Buttons.

Regards,

Raghava Channooru

Read only

0 Likes
949

Hi Raghava,

Thanks for your input...

Can you plz send me any links or code on this requirement using ALV concept.

Thanks a lot.

Regards

Anil

Read only

0 Likes
949

Hi Anil,

I am thinking of one solution here. You would have to use selection screen though.

Basically lets assume you have following selection screen


PARAMETERS: pa_file TYPE ... MODIF ID ...       
SELECTION-SCREEN PUSHBUTTON (50) but_fld1 USER-COMMAND ...

By means of


  READ REPORT repid INTO it_rep_code.
...
    INSERT REPORT sy-repid FROM it_rep_code.
    SUBMIT (sy-repid) VIA SELECTION-SCREEN.

...you can first get you report code into it_rep_code , then modify it accoridngly (append new lines for next selection screen button or input field), then replace the current code with INSERT REPORT, finally submiting this one again.

This would cause that after some action on the screen we change the code of the program itself. Program would simply extend itaself. I used that option once and it worked quite well, so you can try it yourself too.

Regards

Marcin

Read only

0 Likes
949

Hi,

Using OOPS ALV(cl_gui_alv_grid) I Created in my scenario.

Just create One column as Button .


data: 

     BEGIN OF type_s_data,
           Header(10),
            Item(5),
            button(10),
       END OF type_s_data,

"In layout settings mention like this, 
  fs_layo-stylefname = 'CELL'.
"for Button Column maintain fieldcat as.
  fs_fcat-fieldname = name.
  fs_fcat-outputlen = length.
  fs_fcat-coltext = text.
  fs_fcat-style = cl_gui_alv_grid=>mc_style_button.

"now it will appear in ALV as Buttons Column( that column have full of buttons).

"To handle Button Click you have to handle Button_click event in Cl_gui_alv_grid.
class handle_event definition.
METHODS : button_click FOR EVENT button_click OF cl_gui_alv_grid
                                        IMPORTING es_col_id es_row_no.
endclass.

class handle_event implementation.
method button_click.
message 'Successfully Button created' type 'S'." Write your required code
endmethod.
endclass.

Just refer Package SLIS for Sample Programs on OOPS ALV

Regards,

Raghava Channooru.

Read only

0 Likes
949

Hi Marcin,

I am sorry i did not understand the logic you posted..

Could you make it elobrate how it works or can you send code related to it.

Thanks a lot.

Regards

Anil

Read only

0 Likes
949

Hi Anil,

Sorry for not being clear enough. Below the example report which will show you the functionality I am talking about. Just run it and press ADD button on the standard toolbar. You will see the behaviour and likely to get the basic concept.


REPORT z_test3.
TABLES: sscrfields.

PARAMETERS pa000 TYPE c.

TYPES: BEGIN OF t_line,
        line(72) TYPE c,
       END OF t_line.

DATA: it_rep_code TYPE STANDARD TABLE OF t_line
                  WITH HEADER LINE,
      wa_code  TYPE t_line.
DATA: repid LIKE sy-repid,
      g_exec_times(3) TYPE n.

SELECTION-SCREEN: FUNCTION KEY 1.

INITIALIZATION.
  IMPORT exec = g_exec_times
         FROM MEMORY ID 'EXEC'.
  IF sy-subrc <> 0.
    g_exec_times = 1.
  ELSE.
    ADD 1 TO g_exec_times.
  ENDIF.

  EXPORT exec = g_exec_times
         TO MEMORY ID 'EXEC'.

  sscrfields-functxt_01 = 'Add'.
  repid = sy-repid.

AT SELECTION-SCREEN.
  IF sscrfields-ucomm = 'FC01'.

    READ REPORT repid INTO it_rep_code.

    CONCATENATE 'PARAMETERS pa' g_exec_times INTO wa_code.
    CONCATENATE wa_code 'type c.' INTO wa_code SEPARATED BY space.
    INSERT wa_code INTO it_rep_code INDEX 3.

    INSERT REPORT repid FROM it_rep_code.
    SUBMIT (repid) VIA SELECTION-SCREEN.

  ELSEIF sscrfields-ucomm = '&BACK'.
    LEAVE PROGRAM.
  ENDIF.

Regards

Marcin

Read only

Former Member
0 Likes
949

Created Push button on screen