SAP ABAP 打开新会话新窗口的方法

2023-10-13 14:25:13 浏览数 (2)

方法一:

代码语言:javascript复制
WRITE 'This is the main ABAP program'.
DATA :
  LV_SKIP(1)  TYPE C VALUE 'X',
  LV_VBELN    LIKE VBAK-VBELN VALUE '20000190',
  L_ST_PARAM  TYPE TPARA,
  L_IT_PARAMS TYPE TABLE OF TPARA.
CLEAR L_ST_PARAM.
CLEAR L_IT_PARAMS[].
L_ST_PARAM-PARAMID = 'AUN'.
L_ST_PARAM-PARTEXT = LV_VBELN.
APPEND L_ST_PARAM TO L_IT_PARAMS.
CALL FUNCTION 'CC_CALL_TRANSACTION_NEW_TASK'
  STARTING NEW TASK 'VA03'
  DESTINATION 'NONE'
  EXPORTING
    TRANSACTION           = 'VA03'
    SKIP_FIRST_SCREEN     = 'X'
  TABLES
    PARAMTAB              = L_IT_PARAMS
  EXCEPTIONS
    COMMUNICATION_FAILURE = 97
    SYSTEM_FAILURE        = 98
    OTHERS                = 99.
IF SY-SUBRC = 0.
  " Success
ELSEIF SY-SUBRC = 97.
  " Communication Failure
  EXIT.
ELSEIF SY-SUBRC = 98.
  " System Failure
  EXIT.
ELSE.
  EXIT.
ENDIF.

方法二:

代码语言:javascript复制
WRITE 'This is the main ABAP report calling the SAP Transaction VA03 in a new session or in a new window'.
DATA :    WA_SPA   TYPE RFC_SPAGPA,
          ITAB_SPA TYPE TABLE OF RFC_SPAGPA.
WA_SPA-PARID = 'AUN'.
WA_SPA-PARVAL = '20000190'.
APPEND WA_SPA TO ITAB_SPA.
CALL FUNCTION 'ABAP4_CALL_TRANSACTION'
  STARTING NEW TASK 'VA03'
  DESTINATION 'NONE'
  EXPORTING
    TCODE                 = 'VA03'
    SKIP_SCREEN           = 'X'
  TABLES
    SPAGPA_TAB            = ITAB_SPA
  EXCEPTIONS
    COMMUNICATION_FAILURE = 1
    SYSTEM_FAILURE        = 2.
IF SY-SUBRC <> 0.
  " ERROR
ENDIF.

0 人点赞