SAP-ABAP-选择屏幕加按钮-submit运行跳转

将用户需要的一系列操作合并到一个TECODE,使用SUBMIT跳转,代码简单,但是对用户非常方便

 

*&---------------------------------------------------------------------*
*& Report ZLQT_JUMP
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZRPP039.


TABLES: sscrfields,stxftxt,AFPO,AUFK,ZTPP024.                 "定义工作区
DATA   GV_AUFNR TYPE AFRU-AUFNR .
DATA : GV_WERKS TYPE AFPO-DWERK .


PARAMETERS P_DWERK TYPE WERKS_D MODIF ID WRK  DEFAULT '2110'      .
PARAMETERS P_UNAME TYPE SY-UNAME DEFAULT SY-UNAME   .
SELECT-OPTIONS S_UNAME FOR  AUFK-ERNAM NO-DISPLAY   .
SELECT-OPTIONS:  S_AUFNR FOR AFPO-AUFNR MODIF ID ANR.
PARAMETERS S_ZTYPE TYPE ZTPP024-ZSLIP_TYPE NO-DISPLAY.
SELECTION-SCREEN: FUNCTION KEY 1,   "激活按钮
                  FUNCTION KEY 2,
                  FUNCTION KEY 3,
                  FUNCTION KEY 4,
                  FUNCTION KEY 5 .

INITIALIZATION.
  sscrfields-functxt_01 = '@O6@ ZPP006壓批     '      . "设置按钮
  sscrfields-functxt_02 = '@5Y@ ZCO02A核發     '      .
  sscrfields-functxt_03 = '@0X@ ZPP006A工單列印'      .
  sscrfields-functxt_04 = '@XP@ ZPP012發料     '      .
  sscrfields-functxt_05 = '@0X@ ZPP012A發料列印'      .

  CLEAR :GV_AUFNR,S_AUFNR[],S_AUFNR .
*  GET PARAMETER ID 'ANR' FIELD GV_AUFNR .
*  S_AUFNR-SIGN = 'I' .
*  S_AUFNR-OPTION = 'EQ' .
*  S_AUFNR-LOW = GV_AUFNR .
*  APPEND S_AUFNR .
AT SELECTION-SCREEN.

 CLEAR S_UNAME[] .
   S_UNAME-SIGN = 'I' .
   S_UNAME-OPTION = 'EQ' .
   S_UNAME-LOW = P_UNAME .
   APPEND S_UNAME .

  CASE sscrfields-ucomm.          "处理按钮命令
      WHEN 'FC01'.
        IF S_AUFNR-LOW IS NOT INITIAL.
          SET PARAMETER ID 'ANR' FIELD S_AUFNR-LOW .
        ENDIF.
        CALL TRANSACTION 'ZPP006' AND SKIP FIRST SCREEN.
      WHEN 'FC02'.
        IF S_AUFNR-LOW IS NOT INITIAL.
          SET PARAMETER ID 'ANR' FIELD S_AUFNR-LOW .
        ENDIF.
        CALL TRANSACTION 'ZCO02A' AND SKIP FIRST SCREEN.
      WHEN 'FC03'.
*        SET PARAMETER ID 'ANR' FIELD S_AUFNR-LOW .
*        S_AUFNR-SIGN = 'I' .
*        S_AUFNR-OPTION = 'EQ' .
*        S_AUFNR-LOW = S_AUFNR-LOW .
*        APPEND S_AUFNR .
        SUBMIT ZRPP009 USING SELECTION-SCREEN '1000'
                          WITH   P_WERKS     = P_DWERK
                          WITH   P_UNAME-LOW = P_UNAME
                          WITH   S_AUFNR    IN S_AUFNR
                          AND RETURN .

      WHEN 'FC04'.
*        SET PARAMETER ID 'ANR' FIELD S_AUFNR-LOW .
*        S_AUFNR-SIGN = 'I' .
*        S_AUFNR-OPTION = 'EQ' .
*        S_AUFNR-LOW = S_AUFNR-LOW .

        CLEAR : S_UNAME[] .
        SUBMIT ZBPP012_A01 USING SELECTION-SCREEN '1000'
                          WITH   PCWERKS = P_DWERK
                          WITH   PCMAKER = P_UNAME
                          WITH   SCUNAME IN S_UNAME
                          WITH   SCAUFNR IN S_AUFNR
                          AND RETURN .

      WHEN'FC05' .
*        S_AUFNR-SIGN = 'I' .
*        S_AUFNR-OPTION = 'EQ' .
*        S_AUFNR-LOW = S_AUFNR-LOW .
*        APPEND S_AUFNR .
        IF P_UNAME IS NOT INITIAL.
        S_UNAME-SIGN = 'I' .
        S_UNAME-OPTION = 'EQ' .
        S_UNAME-LOW = P_UNAME .
        APPEND S_UNAME .
        ENDIF.

        SUBMIT ZBPP012A USING SELECTION-SCREEN '1000'
                          WITH   SCUNAME     IN S_UNAME
                          WITH   PCZTYPE     = 'A'
                          WITH   SCAUFNR     IN S_AUFNR
                          VIA SELECTION-SCREEN
                          AND RETURN .
        CLEAR:S_UNAME,S_UNAME[].

  ENDCASE.

START-OF-SELECTION.
 SET PARAMETER ID 'WRK' FIELD P_DWERK .
 CALL TRANSACTION 'CO01' .
 GET PARAMETER ID 'ANR' FIELD GV_AUFNR .
 IF GV_AUFNR IS NOT INITIAL.
   CLEAR : S_AUFNR ,S_AUFNR[] .
   S_AUFNR-LOW = GV_AUFNR .
   S_AUFNR-SIGN = 'I' .
   S_AUFNR-OPTION = 'EQ' .
   APPEND S_AUFNR .
*   CALL TRANSACTION 'CO01' .
   SUBMIT ZRPP039 USING SELECTION-SCREEN '1000'
                     WITH   P_DWERK = P_DWERK
                     WITH   P_UNAME = P_UNAME
                     WITH   S_AUFNR IN S_AUFNR
                     VIA SELECTION-SCREEN.  "VIA SELECTION-SCREEN 表示显示被调用的屏幕
 ENDIF.
* LEAVE TO TRANSACTION 'ZPP039' .

你可能感兴趣的:(SAP,abap,选择屏幕加按钮,submit跳转)