实现效果:销售订单明细表,双击单元格进入 va03 事务代码
1.alv 显示报表调用函数 i_callback_user_command 加上方法名
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'EXPORTINGi_callback_program = sy-repid
* i_callback_pf_status_set = 'FRM_PF_STATUS'i_callback_user_command = 'FRM_USER_COMMAND'is_layout_lvc = gs_layout_lvcit_fieldcat_lvc = gt_fcat_lvci_save = 'A'TABLESt_outtab = it_mainEXCEPTIONSprogram_error = 1OTHERS = 2.IF sy-subrc <> 0.MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgnoWITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.ENDIF.
2.用户处理命令方法如下:
*&---------------------------------------------------------------------*
*& Form FRM_USER_COMMAND
*&---------------------------------------------------------------------*
* 自定义的用户命令处理
*----------------------------------------------------------------------*
* -->PV_UCOMM 用户命令类型
* -->PS_SELFIELD 用户命令信息
*----------------------------------------------------------------------*
FORM frm_user_command USING pv_ucomm TYPE sy-ucommps_selfield TYPE slis_selfield.CASE pv_ucomm.WHEN '&IC1'. " "双击事件READ TABLE it_main INDEX ps_selfield-tabindex.IF sy-subrc = 0 ."AND it_main-color = 'C610'.PERFORM frm_set_bdc_data.CALL TRANSACTION 'VA03' USING bdcdataMODE 'E'MESSAGES INTO messtab.ENDIF.ENDCASE.ENDFORM.
3.调用bdc
*&---------------------------------------------------------------------*
*& Form FRM_SET_BDC_DATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_set_bdc_data .DATA:lv_etenr LIKE vbep-etenr.REFRESH:bdcdata,messtab.PERFORM bdc_dynpro USING 'SAPMV45A' '0102'.PERFORM bdc_field USING 'VBAK-VBELN' it_main-vbeln.PERFORM bdc_field USING 'BDC_OKCODE' '=ENT2'.SELECT SINGLE etenr INTO lv_etenr FROM vbepWHERE vbeln = it_main-vbeln AND posnr = it_main-posnr.IF lv_etenr IS NOT INITIAL .PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.PERFORM bdc_field USING 'BDC_OKCODE' '=POPO'.PERFORM bdc_dynpro USING 'SAPMV45A' '0251'.PERFORM bdc_field USING 'RV45A-POSNR' it_main-posnr.PERFORM bdc_field USING 'BDC_OKCODE' '=POSI'.PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.PERFORM bdc_field USING 'RV45A-VBAP_SELKZ(01)' 'X'.PERFORM bdc_field USING 'BDC_OKCODE' '=PEIN'.ENDIF.
ENDFORM.*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PROGRAM text
* -->DYNPRO text
*----------------------------------------------------------------------*
FORM bdc_dynpro USING program dynpro.CLEAR bdcdata.bdcdata-program = program.bdcdata-dynpro = dynpro.bdcdata-dynbegin = 'X'.APPEND bdcdata.
ENDFORM. "BDC_DYNPRO*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM bdc_field USING fnam fval.DATA: lv_fval TYPE string.lv_fval = fval.CONDENSE lv_fval.CLEAR bdcdata.bdcdata-fnam = fnam.bdcdata-fval = lv_fval.APPEND bdcdata.
ENDFORM. "BDC_FIELD
SAP BDC 录屏及 ABAP 调用 BDC 参见此链接