注册 登录
赛跑网 返回首页

SAPOK_ABAP的个人空间 https://www.saipao.cn/?9408 [收藏] [复制] [分享] [RSS]

日志

ALV实现双击事件例子

已有 1450 次阅读2012-5-10 14:18 | ALV, 双击

TABLES:
marav. "Table MARA and table MAKT
*---------------------------------------------------------------------*
DATA:
BEGIN OF imat OCCURS 100,
matnr LIKE marav-matnr, "Material number
maktx LIKE marav-maktx, "Material short text
matkl LIKE marav-matkl, "Material group (so you can test to make
ntgew LIKE marav-ntgew, "Net weight, numeric field (so you can test to
gewei LIKE marav-gewei, "weight unit (just to be complete)
END OF imat.

*---------------------------------------------------------------------*
* Other data needed
* field to store report name
DATA i_repid LIKE sy-repid.
* field to check table length
DATA i_lines LIKE sy-tabix.

*---------------------------------------------------------------------*
* Data for ALV display
TYPE-POOLS: slis.
DATA int_fcat TYPE slis_t_fieldcat_alv.

*---------------------------------------------------------------------*
SELECT-OPTIONS:
s_matnr FOR marav-matnr MATCHCODE OBJECT mat1.

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

  SELECT * FROM marav
  INTO CORRESPONDING FIELDS OF TABLE imat
  WHERE
  matnr IN s_matnr.

* Check if material was found
  CLEAR i_lines.
  DESCRIBE TABLE imat LINES i_lines.
  IF i_lines LT 1.
*   Using hardcoded write here for easy upload
    WRITE: /
    'No materials found.'.
    EXIT.    "
  ENDIF.

END-OF-SELECTION.
  i_repid = sy-repid.
* Create Fieldcatalogue from internal table
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_program_name         = i_repid
      i_internal_tabname     = 'IMAT'  "capital letters!
      i_inclname             = i_repid
    CHANGING
      ct_fieldcat            = int_fcat
    EXCEPTIONS
      inconsistent_interface = 1
      program_error          = 2
      OTHERS                 = 3.
  IF sy-subrc <> 0.
  ENDIF.
* Call for ALV list display
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
  i_callback_program = i_repid
  it_fieldcat        = int_fcat
  i_save             = 'A'
  i_callback_user_command = 'FRM_UCOMM'  "实现双击事件
  TABLES
  t_outtab           = imat
  EXCEPTIONS
  program_error      = 1
  OTHERS             = 2.
  IF sy-subrc <> 0.

  ENDIF.

***实现双击事件
*----------------------------------------------------------------------*
*      -->F_UCOMM    text
*      -->F_SELFIELD text
*----------------------------------------------------------------------*
FORM frm_ucomm USING f_ucomm    LIKE sy-ucomm"双击
                     f_selfield TYPE slis_selfield."行数

  READ TABLE imat  INDEX f_selfield-tabindex.
  IF f_ucomm = '&IC1'."双击
    IF f_selfield-fieldname = 'MATNR'.
      SET PARAMETER ID 'MAT' FIELD f_selfield-value .
      SET PARAMETER ID 'MM5' FIELD ' '.
*      SET PARAMETER ID 'MXX' FIELD 'K'.
      CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN."跳过第一个屏幕
    ENDIF.
  ENDIF.

ENDFORM.                    "FRM_UCOMM

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册

小黑屋|联系我们|赛跑网 ( 苏ICP备14021163号-4 ) QQfsq|网站地图

GMT+8, 2026-11-20 16:40 , Processed in 0.186973 second(s), 19 queries .

Powered by 91SAP X3.4

© 2001-2023 91sap Team.

返回顶部