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

Button on screen

Former Member
0 Likes
508

How can I put a button on a screen after a list that have been displayed?. The idea is have a button that the user could click to confirm the deleting of the data shown in the list.

4 REPLIES 4
Read only

Former Member
0 Likes
471

Use:

PF-STATUS 'NAMEOFYOURSTATUS'. then you can add more buttons.

Read only

nablan_umar
Product and Topic Expert
Product and Topic Expert
0 Likes
471

If you want to make the icon or symbol displayed on the list screen so that when you click on that icon/symbol, it will trigger an action, try looking at sample program DEMO_LIST_FORMAT_HOTSPOT.

This program display a text as hotspot. When you click at that hotspot, it will trigger event at line-selection. You can instead display an icon/symbol as hotspot, then during at line-selection event, check fields sy-lisel, sy-cucol and sy-curow to find out whether that icon/symbol has been clicked. Then you can proceed with whatever action you want based on user clicked.

Read only

Former Member
0 Likes
471

Hi Ruben,

Following is a small piece of code to demo the use of interactive lists. This is very rudimentary example. But there are other newest ways to achieve this, ALV lists in particular, are easier to use and control.


DATA: BEGIN OF itab OCCURS 0,
        select TYPE c,
        vbeln  LIKE vbak-vbeln.
DATA: END OF itab.

DATA: v_pages        TYPE i,
      v_current_page TYPE i,
      v_vbeln        LIKE vbak-vbeln.

*------------------
START-OF-SELECTION.
*------------------

  SELECT vbeln FROM vbak
               INTO CORRESPONDING FIELDS OF TABLE itab
              WHERE vkorg = '2500' .

*----------------
END-OF-SELECTION.
*----------------

  SET PF-STATUS 'MAIN'.
  APPEND LINES OF itab TO itab.
  APPEND LINES OF itab TO itab.
  LOOP AT itab.
    WRITE:/ itab-select AS CHECKBOX,
            itab-vbeln.
  ENDLOOP.
  v_pages = sy-pagno.

*---------------
AT USER-COMMAND.
*---------------

  CASE sy-ucomm.

    WHEN 'SEL'.
*-- Select all
*-- Include logic for selection of all the lines of the list, may be by
*   having  a checkbox in front of each line
      DO v_pages TIMES.
        v_current_page = sy-index.
        DO.
          READ LINE sy-index OF PAGE v_current_page.
          IF sy-subrc <> 0.
            EXIT.
          ENDIF.
          sy-lisel+0(1) ='X'.
          MODIFY CURRENT LINE.
        ENDDO.
      ENDDO.
    WHEN 'DSEL'.
*-- Deselect all
*-- Include logic for de-selection of all the lines of the list
      DO v_pages TIMES.
        v_current_page = sy-index.
        DO.
          READ LINE sy-index OF PAGE v_current_page.
          IF sy-subrc <> 0.
            EXIT.
          ENDIF.
          sy-lisel+0(1) = space.
          MODIFY CURRENT LINE.
        ENDDO.
      ENDDO.

    WHEN 'DEL'.
*-- Delete selected lines
      DO v_pages TIMES.
        v_current_page = sy-index.
        DO.
          READ LINE sy-index OF PAGE v_current_page.
          IF sy-subrc <> 0.
            EXIT.
          ENDIF.
          IF sy-lisel+0(1) = 'X'.
*-- this line is selected,
*-- your logic for deletion.
            v_vbeln = sy-lisel+1(10).
*-- delete the selected sales order
          ENDIF.
        ENDDO.
      ENDDO.

    WHEN OTHERS.
*-- Issue message to choose the correct function
  ENDCASE.

If you need any further clarifications, please let me know.

Srinivas

Read only

Former Member
0 Likes
471

Adding some detail to Carlos' suggestion. Define a status with a button, icon and function code. Use the SET PF-STATUS.. command somewhere before the list is displayed. Use the AT USER-COMMAND event to respond and determine if your button was hit as shown in an earlier posting.

I am assuming that hitting the button means delete all. If you want the user to select what should be deleted, then consider the checkbox option mentioned earlier or switch to an ALV Grid and allow multiple selection.

Let us know how it goes!