• 屏幕弹出窗口并弹出单选框范例


    REPORT  Y001.
    TYPE-POOLSSLIS.
    INCLUDE <ICONS>.

    TYPESBEGIN OF ITYPE_ALV_FLIGHT,
             RADIO1(4),                            "Radio button
             CARRID TYPE SFLIGHT-CARRID,
             CONNID TYPE SFLIGHT-CONNID,
    END OF ITYPE_ALV_FLIGHT.

    CLASS LCL_HANDLE_EVENTS DEFINITION DEFERRED.
    DATAGR_TABLE   TYPE REF TO CL_SALV_TABLE.
    DATAGR_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
    DATAGR_EVENTS TYPE REF TO LCL_HANDLE_EVENTS.
    DATAIT_ALV_FLIGHT TYPE STANDARD TABLE OF ITYPE_ALV_FLIGHT.

    *---------------------------------------------------------------------*
    *       CLASS lcl_handle_events DEFINITION
    *---------------------------------------------------------------------*
    CLASS LCL_HANDLE_EVENTS DEFINITION.
      PUBLIC SECTION.
        METHODS:
          ON_LINK_CLICK FOR EVENT LINK_CLICK OF CL_SALV_EVENTS_TABLE
            IMPORTING ROW COLUMN.
    ENDCLASS.         "lcl_handle_events DEFINITION

    *---------------------------------------------------------------------*
    *       CLASS lcl_handle_events IMPLEMENTATION
    *---------------------------------------------------------------------*
    CLASS LCL_HANDLE_EVENTS IMPLEMENTATION.
      METHOD ON_LINK_CLICK.
        PERFORM USER_COMMAND USING ROW COLUMN.
      ENDMETHOD.                    "on_single_click
    ENDCLASS.                    "lcl_handle_events IMPLEMENTATION

    SELECTION-SCREEN BEGIN OF BLOCK DSP WITH FRAME.
    SELECTION-SCREEN END OF BLOCK DSP.
    *----------------------------------------------------------------------*
    * START-OF-SELECTION                                                   *
    *----------------------------------------------------------------------*

    START-OF-SELECTION.
      FIELD-SYMBOLS<FS_GRID> TYPE ITYPE_ALV_FLIGHT.
      SELECT CARRID CONNID FROM SFLIGHT
      INTO CORRESPONDING FIELDS OF TABLE IT_ALV_FLIGHT
      UP TO 20 ROWS.

      LOOP AT IT_ALV_FLIGHT ASSIGNING <FS_GRID>.
        <FS_GRID>-RADIO1 ICON_WD_RADIO_BUTTON_EMPTY.  "Empty Radio Buttons
      ENDLOOP.

      TRY.
          CL_SALV_TABLE=>FACTORY(
            EXPORTING
              LIST_DISPLAY   'X'
            IMPORTING
              R_SALV_TABLE   GR_TABLE
            CHANGING
              T_TABLE        IT_ALV_FLIGHT ).
        CATCH CX_SALV_MSG.                                  "#EC NO_HANDLER
      ENDTRY.

      TRY.
          GR_TABLE->SET_SCREEN_POPUP(
            START_COLUMN 10
            END_COLUMN 60
            START_LINE 4
            END_LINE 15 ).
        CATCH CX_SALV_MSG.
      ENDTRY.

    *   set icon column and make it a hotspot

      DATALR_COLUMNS TYPE REF TO CL_SALV_COLUMNS,
            LR_COLUMN  TYPE REF TO CL_SALV_COLUMN_TABLE.
            LR_COLUMNS GR_TABLE->GET_COLUMNS).

      TRY.
          LR_COLUMN ?= LR_COLUMNS->GET_COLUMN'RADIO1' ).
          LR_COLUMN->SET_ICONIF_SALV_C_BOOL_SAP=>TRUE ).
          LR_COLUMN->SET_CELL_TYPEIF_SALV_C_CELL_TYPE=>HOTSPOT ).
          LR_COLUMN->SET_LONG_TEXTTEXT-001 ).
        CATCH CX_SALV_NOT_FOUND.                            "#EC NO_HANDLER
      ENDTRY.

    *  turn off front-end handler
      DATALR_SELECTIONS TYPE REF TO CL_SALV_SELECTIONS.
      LR_SELECTIONS GR_TABLE->GET_SELECTIONS).
      LR_SELECTIONS->SET_SELECTION_MODEIF_SALV_C_SELECTION_MODE=>NONE ).
    *  capture events
      DATALR_EVENTS TYPE REF TO CL_SALV_EVENTS_TABLE.
      LR_EVENTS GR_TABLE->GET_EVENT).
      CREATE OBJECT GR_EVENTS.
      SET HANDLER GR_EVENTS->ON_LINK_CLICK FOR LR_EVENTS.
    *   display the table
      GR_TABLE->DISPLAY).
    *&---------------------------------------------------------------------*
    *&      Form  user_command
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      -->ROW        text
    *      -->COLUMN     text
    *----------------------------------------------------------------------*
    FORM USER_COMMAND USING ROW TYPE I
                            COLUMN TYPE LVC_FNAME.
      DATAREFR_STABLE TYPE LVC_S_STBL.
      FIELD-SYMBOLS<FS_ITAB> LIKE LINE OF IT_ALV_FLIGHT.
      IF COLUMN 'RADIO1'.
        LOOP AT IT_ALV_FLIGHT ASSIGNING <FS_ITAB>.
          IF SY-TABIX <> ROW.
            <FS_ITAB>-RADIO1 ICON_WD_RADIO_BUTTON_EMPTY.
          ENDIF.
        ENDLOOP.

        READ TABLE IT_ALV_FLIGHT INDEX ROW ASSIGNING <FS_ITAB>.
        IF <FS_ITAB>-RADIO1 ICON_RADIOBUTTON.
        ELSE.
          <FS_ITAB>-RADIO1 ICON_RADIOBUTTON.
        ENDIF.
      ENDIF.

      REFR_STABLE-ROW ABAP_TRUE.
      GR_TABLE->REFRESHS_STABLE REFR_STABLE REFRESH_MODE IF_SALV_C_REFRESH=>FULL ).
    ENDFORM.                    "USER_COMMAND

  • 相关阅读:
    JavaEE--JNDI(下,实现)
    JavaEE--JNDI(上,简介)
    JavaSE--java是值传递还是引用传递
    Mysql--主库不停机搭建备库
    MySQL--从库启动复制报错1236
    JVM·垃圾收集器与内存分配策略之垃圾收集器!
    mysql·事务挂起
    hash·余数hash和一致性hash
    关于正则效率问题(正则导致程序卡死)
    JVM·参数配置
  • 原文地址:https://www.cnblogs.com/sanlly/p/3511041.html
Copyright © 2020-2023  润新知