SAP ABAP程序未显示使用SLVC_FULLSCREEN添加的删除操作的执行按钮

时间:2014-10-16 07:48:14

标签: sap abap

我已经从SAP ABAP BOOK SAP Press - ABAP BASICS列出5.1编写了abap程序。一切正常,但我无法显示执行删除操作的任何图标,我已使用reuse_alv_grid_display中的slvc_fullscreen添加。当我使用删除操作时,我甚至无法在屏幕上看到后退按钮。 如果有人能找到,请回复。 程序随屏幕一起附上。

*&---------------------------------------------------------------------*
*& Report  ZPTB00_HOTEL_RESERVATION_COOL
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

    REPORT  ZPTB00_HOTEL_RESERVATION_COOL.
    type-POOLS slis.

    * main menu as selection screen

    SELECTION-SCREEN BEGIN OF SCREEN 110.
      SELECTION-SCREEN BEGIN OF BLOCK b110 WITH FRAME TITLE text-001.
        PARAMETERS:
            p_add TYPE c RADIOBUTTON GROUP grp1 DEFAULT 'X',
            p_delete TYPE c RADIOBUTTON GROUP grp1,
            p_show TYPE c RADIOBUTTON GROUP grp1.
        SELECTION-SCREEN END OF BLOCK b110.
        SELECTION-SCREEN END OF SCREEN 110.

    * input new reservation
    SELECTION-SCREEN BEGIN OF SCREEN 120.
      SELECTION-SCREEN BEGIN OF BLOCK b120 WITH FRAME TITLE text-002.
        PARAMETERS:
        p_room TYPE zptb00_room_number value CHECK,
        p_chkin TYPE zptb00_check_in,
        p_chkout TYPE zptb00_check_out,
        p_name TYPE zptb00_customer_name.
    SELECTION-SCREEN END OF BLOCK b120.
        SELECTION-SCREEN END OF SCREEN 120.

    Do.
      call SELECTION-SCREEN 110.
      if sy-subrc <> 0.
        exit.
        ELSEIF p_add = 'X'.
          PERFORM zptb00_hrc_add.
          ELSEIF p_delete = 'X'.
            PERFORM zptb00_hrc_delete.
            ELSEIF p_show = 'X'.
              PERFORM zptb00_hrc_show.
              ENDIF.
              enddo.

    * FORM  zptb00_hrc_add
              FORM zptb00_hrc_add.
                data:
                     l_str_reservation type  zptb00_hreservat,
                     l_tab_reservation type STANDARD TABLE OF zptb00_hreservat.
    * call input dailog
                  call SELECTION-SCREEN 120 STARTING AT 5 5.
                  if sy-subrc = 0.
                    SELECT * from zptb00_hreservat into table l_tab_reservation
                     WHERE ( room_number = p_room )
            and ( ( checkin between p_chkin and p_chkout )
                  or ( checkout between p_chkin and p_chkout ) ).
                      if sy-dbcnt > 0.
                        MESSAGE s000(zptb00_messages_alv).
                        else.

                         call FUNCTION 'GUID_CREATE'
                    IMPORTING
                         ev_guid_32 = l_str_reservation-id.
                          l_str_reservation-room_number = p_room.
                l_str_reservation-checkin = p_chkin.
                l_str_reservation-checkout = p_chkout.
                l_str_reservation-customername = p_name.

                insert zptb00_hreservat FROM l_str_reservation.
                MESSAGE s001(zptb00_messages_alv).
                ENDIF.
                endif.
                ENDFORM.

    * form zptb00_hrc_delete
                form zptb00_hrc_delete.
                  TYPES:
                  BEGIN OF t_mark,
                    mark type c,
                    END OF t_mark,
                    BEGIN OF t_str_reservationx.
                      include STRUCTURE zptb00_hreservat.
                      INCLUDE TYPE t_mark.
                      TYPES:
                      END OF t_str_reservationx.
                      data:
                            l_dis TYPE disvariant,
                            l_str_layout TYPE slis_layout_alv,
                            l_str_exit_by_user type slis_exit_by_user,
                            l_tab_reservationx TYPE STANDARD TABLE OF t_str_reservationx,
                            l_str_reservationx type t_str_reservationx,
                            l_tab_reservation TYPE STANDARD TABLE OF zptb00_hreservat,
                            l_count type i.
                      FIELD-SYMBOLS:
                                     <l_str_reservation> type zptb00_hreservat,
                                     <l_str_reservationx> type t_str_reservationx.
                      SELECT * FROM zptb00_hreservat into TABLE l_tab_reservation.
                        LOOP AT l_tab_reservation ASSIGNING <l_str_reservation>.
                          MOVE-CORRESPONDING <l_str_reservation> to l_str_reservationx.
                          APPEND l_str_reservationx  to l_tab_reservationx.
                          ENDLOOP.
                          l_str_layout-colwidth_optimize = 'X'.
                          l_str_layout-window_titlebar = text-003.
                          l_str_layout-box_fieldname = 'MARK'.
                          l_dis-report = sy-repid.

                         CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
                         EXPORTING
                           I_CALLBACK_PROGRAM = l_dis-report
                           I_CALLBACK_PF_STATUS_SET = 'CB_ALV_PF_SET_STATUS'
                           I_CALLBACK_USER_COMMAND = 'CB_ALV_USER_COMMAND'
                           i_structure_name = 'ZPTB00_HRESERVAT'
                           is_layout = l_str_layout
                           I_DEFAULT = 'X'
                           i_save = 'A'
                           is_variant = l_dis

                           IMPORTING
                             es_exit_caused_by_user = l_str_exit_by_user
                             TABLES
                               t_outtab = l_tab_reservationx
                               EXCEPTIONS
                                 program_error = 1
                                 OTHERS = 2.
                          IF sy-subrc <> 0.
                            MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                            WITH  SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
                            ENDIF.

                            CASE 'X'.
                              WHEN  l_str_exit_by_user-exit.
                                LEAVE PROGRAM.
                                WHEN l_str_exit_by_user-back OR l_str_exit_by_user-cancel.
                                  RETURN.
                                  ENDCASE.

                                  l_count = 0.
                                  LOOP AT l_tab_reservationx ASSIGNING <l_str_reservationx>.
                                    IF  <l_str_reservationx>-mark = 'X'.
                                      DELETE FROM zptb00_hreservat WHERE id = <l_str_reservationx>-id.

                                    ENDIF.
                                    ENDLOOP.
                                    MESSAGE S002(zptb00_messages_alv) WITH l_count.
                                    ENDFORM.  " zptb00_hrc_delete

    * FORM zptb00_hrc_show
                                    FORM zptb00_hrc_show.
                                      DATA:
                                            l_dis TYPE disvariant,
                                            l_rda_table TYPE REF TO data,
                                            l_str_layout TYPE slis_layout_alv,
                                            l_tab_reservation TYPE STANDARD TABLE OF zptb00_hreservat.

                                        SELECT * FROM zptb00_hreservat INTO TABLE l_tab_reservation.
                                    l_str_layout-colwidth_optimize = 'X'.
                                    l_str_layout-window_titlebar = text-004.
                                    l_dis-report = sy-repid.
                                    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
                         EXPORTING
                           i_structure_name = 'zptb00_hreservat'
                           is_layout = l_str_layout
                           i_save = 'A'
                           is_variant = l_dis
                           TABLES
                             t_outtab = l_tab_reservation
                            EXCEPTIONS
                                 program_error = 1
                                 OTHERS = 2.
                          IF sy-subrc <> 0.
                            MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                            WITH  SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
                            ENDIF.
                            ENDFORM.

                            FORM cb_alv_user_command
                              USING
                                    r_ucomm like sy-ucomm
                              rs_selfield TYPE slis_selfield.
                              IF r_ucomm = 'EXECUTE'.
                                rs_selfield-exit = 'X'.
                                ENDIF.
                                ENDFORM.


                                FORM cb_alv_pf_status
                                  USING
                                        rt_extab TYPE slis_t_extab.
                                  SET pf-status 'STANDARD_FULLSCREEN' EXCLUDING rt_extab.

                                  ENDFORM.!

screenshot of delete operation

2 个答案:

答案 0 :(得分:1)

我不知道我是否正确,但在您设置的' REUSE_ALV_GRID_DISPLAY '功能中的' zptb00_hrc_delete '表单中:

I_CALLBACK_PF_STATUS_SET = 'CB_ALV_PF_SET_STATUS'

然而,“ CB_ALV_PF_SET_STATUS ”表单不存在。我认为你错误拼写了表单的名称,因为有一个名为“ CB_ALV_PF_STATUS ”的表单似乎适合:

FORM cb_alv_pf_status USING rt_extab TYPE slis_t_extab.
  SET pf-status 'STANDARD_FULLSCREEN' EXCLUDING rt_extab.
ENDFORM.

让我们尝试更改“ REUSE_ALV_GRID_DISPLAY ”调用中的内容,如下所示:

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_CALLBACK_PROGRAM       = l_dis-report

      I_CALLBACK_PF_STATUS_SET = 'CB_ALV_PF_STATUS' " ---> 'CB_ALV_PF_SET_STATUS' replaced by 'CB_ALV_PF_STATUS'

      I_CALLBACK_USER_COMMAND  = 'CB_ALV_USER_COMMAND'
      I_STRUCTURE_NAME         = 'ZPTB00_HRESERVAT'
      IS_LAYOUT                = l_str_layout
      I_DEFAULT                = 'X'
      I_SAVE                   = 'A'
      IS_VARIANT               = l_dis
    IMPORTING
      ES_EXIT_CAUSED_BY_USER   = l_str_exit_by_user
    TABLES
      T_OUTTAB                 = l_tab_reservationx
    EXCEPTIONS
      PROGRAM_ERROR            = 1
      OTHERS                   = 2.
  

我假设存在“ STANDARD_FULLSCREEN ”GUI状态。校验   那请。

另一个观察是,在“ zptb00_hrc_show ”形式中,您在函数“ REUSE_ALV_GRID_DISPLAY ”的“ i_structure_name ”参数中使用小写字母但它应该是大写的。

而不是:

i_structure_name = 'zptb00_hreservat'

应该是:

i_structure_name = 'ZPTB00_HRESERVAT'

希望有所帮助

答案 1 :(得分:1)

在第161行中设置:

SET pf-status 'STANDARD_FULLSCREEN' EXCLUDING rt_extab.

nmiranda认为&#39; STANDARD_FULLSCREEN&#39;存在GUI状态。我认为它不存在。

您可以使用SE38打开报告,在STANDARD_FULLSCREEN上双击显示代码广告。如果您收到警告,表明状态不存在,则表明存在问题。

如果状态存在:您是否定义了删除按钮?

如果没有 - &gt;定义一个。如果您不知道该怎么做,请发表评论。我将检查是否可以制作屏幕截图(抱歉,实际上我没有可用的SAP)。

如果您定义了一个按钮,请检查我调试表rt_extab的内容。如果它包含delete-action的用户命令,则该按钮被禁止。 (我的代码中没有找到任何内容,只是为了确定)。