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

Display Pushbuttons in Table Control Dynamically

Former Member
0 Likes
5,194

Hi experts ,

I have a requirement where i display a table control with coloum heading and pushbuttons only.

For example.

monday tuesday wednesday

[pushbutton] [pushbutton] [pushbutton]

This is nothing but column number changes based on day.

But main doubt is how to display a pushbutton on a table container(not manually as my code has to be dynamic).

Thanks in advance

SSK

13 REPLIES 13
Read only

Juwin
Active Contributor
0 Likes
4,727

Do you really need a table control for this? If there are only weekday names and pushbuttons, can't you create just 7 separate pushbuttons on the screen?

Thanks,

Juwin Thomas

Read only

Former Member
0 Likes
4,727

My requirement is completly different, just cannot post the whole of it so i tried to explain with an example.

In my table control i need to populate push-buttons and i want to know how can i achieve this.



Regards,

SSK

Read only

Former Member
0 Likes
4,727

They're just screen fields. You can hide them during the LOOP AT SCREEN.

Rob

Read only

0 Likes
4,727

Hi Rob,

Thanks for the reply and your time.

We can hide them or make them inactive ... that's fine , but i would like to populate push-buttons on table control first.

Can you please explain me how can i do this.

Regards

SSK

Read only

0 Likes
4,727

Like I said when you LOOP AT SCREEN XXXX WITH CONTROL myctl.

Rob

Read only

0 Likes
4,727

HI Rob,

My be i did not explain it clearly.

My internal table consists of 3 fields A,B and C and say 5 rows.

When i display the table i need output something like this

Read only

0 Likes
4,727

Hi

I don't know if you're looking something like this, but I hope it can help you


DATA: BEGIN OF ITAB OCCURS 0,

         BUTTON_A(60),

         BUTTON_B(60),

         BUTTON_C(60),

       END OF ITAB.

DATA: ICON_NAME(30) TYPE C,

           ICON_TEXT(30) TYPE C.

DATA: ICON_CHECK    TYPE FLAG.

CONTROLS T_CTRL TYPE TABLEVIEW USING SCREEN 100.

The field of internal table ITAB are assigned to a field of a table control, every field of table control is a pushbutton, so I can decide which icon a text assigned to every button:


DO 5 TIMES.

     IF ICON_CHECK IS INITIAL.

       ICON_NAME = 'ICON_PRINT'.

     ELSE.

       ICON_NAME = 'ICON_CHECKED'.

     ENDIF.

     ICON_TEXT = 'Button A'.

     WRITE SY-INDEX TO ICON_TEXT+9 LEFT-JUSTIFIED.

     CALL FUNCTION 'ICON_CREATE'

       EXPORTING

         NAME   = ICON_NAME

         TEXT   = ICON_TEXT

       IMPORTING

         RESULT = ITAB-BUTTON_A.

     IF ICON_CHECK IS INITIAL.

       ICON_NAME = 'ICON_BOOKING_OK'.

     ELSE.

       ICON_NAME = 'ICON_LOCKED'.

     ENDIF.

     ICON_TEXT = 'Button B'.

     WRITE SY-INDEX TO ICON_TEXT+9 LEFT-JUSTIFIED.

     CALL FUNCTION 'ICON_CREATE'

       EXPORTING

         NAME   = ICON_NAME

         TEXT   = ICON_TEXT

       IMPORTING

         RESULT = ITAB-BUTTON_B.

     IF ICON_CHECK IS INITIAL.

       ICON_NAME = 'ICON_CAR'.

     ELSE.

       ICON_NAME = 'ICON_CALCULATION'.

     ENDIF.

     ICON_TEXT = 'Button C'.

     WRITE SY-INDEX TO ICON_TEXT+9 LEFT-JUSTIFIED.

     CALL FUNCTION 'ICON_CREATE'

       EXPORTING

         NAME   = ICON_NAME

         TEXT   = ICON_TEXT

       IMPORTING

         RESULT = ITAB-BUTTON_C.

     APPEND ITAB.

     IF ICON_CHECK IS INITIAL.

       ICON_CHECK = 'X'.

     ELSE.

       CLEAR ICON_CHECK .

     ENDIF.

   ENDDO.

   CALL SCREEN 100.

The result will be this:

Read only

0 Likes
4,727

Hi Max,

Good morning. Hope you are doing good.

Thanks for the answer , i have done the same procedure as described and get the following result

May be i have missed something in the layout like field attributes or table control element.

I cannot even display images even though itab contains records.

Thanks and regards

SSK

Read only

0 Likes
4,727

Hi

You need to insert a pushbutton as colunm of your internal table as following images:

and then you need to change the attribute:

- The Name has to be the same of your internal table field (red circle)

- Field for Output has to be checked (blue circle)

- With Icon has to be checked (green circle)

In PBO you can move the data from internal table to table control


PROCESS BEFORE OUTPUT.

* MODULE STATUS_0100.

  LOOP WITH CONTROL T_CTRL.

    MODULE READ_ITAB.

  ENDLOOP.

*

PROCESS AFTER INPUT.

* MODULE USER_COMMAND_0100.

  LOOP WITH CONTROL T_CTRL.

  ENDLOOP.


MODULE READ_ITAB OUTPUT.

  READ TABLE ITAB INDEX T_CTRL-CURRENT_LINE.

  IF SY-SUBRC <> 0.

    CLEAR ITAB.

  ENDIF.

ENDMODULE.                 " READ_ITAB  OUTPUT

Max

Read only

0 Likes
4,727

HI Max,

Thank you for the reply and your valuable time.

In layout , we can insert push-buttons and convert it into radio buttons or even check-boxes.

I am aware of this process. This can be done when we know the number of columns i need to display.

In my requirement i do not know how many columns i will display , so i cannot insert push-buttons or i cant even do anything manually.

Thanks once again Max for the descriptive answers and the help.

SSK

Read only

0 Likes
4,727

Uhm

Why don't use an ALV grid?

Max

Read only

0 Likes
4,727

It is just right in the middle of cockpit development so i think i cannot just introduce an alv , creating disturbances in existing code

Regards

SSK

Read only

0 Likes
4,727

Hi

I don't know if it's possible to do it with a table control, probably you can create a "big" table control having a large number of colunms for pushbuttom, radiobuttom, checkbox in order to satisfy all your situations and you active only what you need

Max