• 销售订单的批量审批/反审


    FUNCTION zsd_rfc_sofs.
    *"----------------------------------------------------------------------
    *"*"Local interface:
    *"  IMPORTING
    *"     VALUE(VBELNS) TYPE  STRING
    *"     VALUE(CHECKNUM) TYPE  CHAR01 OPTIONAL
    *"  EXPORTING
    *"     VALUE(MESSAGE) TYPE  STRING
    *"----------------------------------------------------------------------
      DATA:split_vbeln TYPE TABLE OF string,
            vbeln_str TYPE vbeln_va,
            vbelnstr TYPE vbeln_va.
      SPLIT vbelns AT ',' INTO TABLE split_vbeln.
    
      DATA:num TYPE i.
    
    
      IF checknum = 'X'.
        LOOP AT split_vbeln INTO vbeln_str.
          CLEAR vbelnstr.
          CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
            EXPORTING
              input  = vbeln_str
            IMPORTING
              output = vbeln_str.
          SELECT SINGLE vbeln INTO vbelnstr FROM vbak WHERE vbeln = vbeln_str.
          IF sy-subrc <> 0.
            CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
              EXPORTING
                input  = vbeln_str
              IMPORTING
                output = vbeln_str.
            CONCATENATE  message  ',' vbeln_str INTO message.
          ENDIF.
        ENDLOOP.
        IF NOT message IS INITIAL.
          num = STRLEN( message ) - 1.
          message = message+1(num).
        ELSE.
          message = 'success'.
        ENDIF.
        EXIT.
      ENDIF.
    
      LOOP AT split_vbeln INTO vbeln_str.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = vbeln_str
          IMPORTING
            output = vbeln_str.
    
        PERFORM bdc_dynpro USING 'SAPMV45A' '0102'.
        PERFORM bdc_field  USING 'BDC_CURSOR'  'VBAK-VBELN'.
        PERFORM bdc_field  USING 'BDC_OKCODE' '/00'.
        PERFORM bdc_field  USING 'VBAK-VBELN' vbeln_str.
    
        PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.
        PERFORM bdc_field  USING 'BDC_OKCODE' '=HEAD'.
        PERFORM bdc_field  USING 'BDC_SUBSCR'  'SAPMV45A                                4021SUBSCREEN_HEADER'.
        PERFORM bdc_field  USING 'BDC_SUBSCR'  'SAPMV45A                                4701PART-SUB'.
        PERFORM bdc_field  USING 'BDC_SUBSCR'  'SAPMV45A                                4400SUBSCREEN_BODY'.
        PERFORM bdc_field  USING 'BDC_SUBSCR'  'SAPMV45A                                4440HEADER_FRAME'.
        PERFORM bdc_field  USING 'BDC_SUBSCR'  'SAPMV45A                                8310HEAD_USER'.
        PERFORM bdc_field  USING 'BDC_SUBSCR'  'SAPLV45W                                0400SUBSCREEN_VERTRAG'.
        PERFORM bdc_field  USING 'BDC_SUBSCR'  'SAPMV45A                                4900SUBSCREEN_TC'.
        PERFORM bdc_field  USING 'BDC_CURSOR'  'RV45A-MABNR(01)'.
        PERFORM bdc_field  USING 'BDC_SUBSCR'  'SAPMV45A                                4050SUBSCREEN_BUTTONS'.
    
        PERFORM bdc_dynpro USING 'SAPMV45A' '4002'.
        PERFORM bdc_field  USING 'BDC_OKCODE' '=T10'.
        PERFORM bdc_field  USING 'BDC_SUBSCR'  'SAPMV45A                                4012SUBSCREEN_HEADER'.
        PERFORM bdc_field  USING 'BDC_CURSOR'  'RV45A-TXT_VBELN'.
        PERFORM bdc_field  USING 'BDC_SUBSCR'  'SAPMV45A                                4301SUBSCREEN_BODY'.
    
        PERFORM bdc_dynpro USING 'SAPMV45A' '4002'.
        PERFORM bdc_field  USING 'BDC_OKCODE' '=KSTC'.
        PERFORM bdc_field  USING 'BDC_SUBSCR'  'SAPMV45A                                4012SUBSCREEN_HEADER'.
        PERFORM bdc_field  USING 'BDC_CURSOR'  'RV45A-TXT_VBELN'.
        PERFORM bdc_field  USING 'BDC_SUBSCR'  'SAPMV45A                                4301SUBSCREEN_BODY'.
    
    
        PERFORM bdc_dynpro USING 'SAPLBSVA' '0300'.
        PERFORM bdc_field  USING 'BDC_OKCODE' '=BACK'.
        PERFORM bdc_field  USING 'BDC_SUBSCR'  'SAPLBSVA                                0800HEADER'.
        PERFORM bdc_field  USING 'BDC_SUBSCR'  'SAPLBSVA                                0302SUBSCREEN'.
        PERFORM bdc_field  USING 'BDC_CURSOR'  'J_STMAINT-ANWS(01)'.
    
          IF p_qx 'X'. "审批
            PERFORM bdc_field  USING 'J_STMAINT-ANWS(01)' 'X'.
            PERFORM bdc_field  USING 'J_STMAINT-ANWS(02)' ''.
          ELSE.      "反审
            PERFORM bdc_field  USING 'J_STMAINT-ANWS(01)' ''.
            PERFORM bdc_field  USING 'J_STMAINT-ANWS(02)' 'X'.
          ENDIF.
    PERFORM bdc_dynpro USING 'SAPMV45A' '4002'. PERFORM bdc_field USING 'BDC_OKCODE' '=SICH'. PERFORM bdc_field USING 'BDC_SUBSCR' 'SAPMV45A 4012SUBSCREEN_HEADER'. PERFORM bdc_field USING 'BDC_CURSOR' 'RV45A-TXT_VBELN'. PERFORM bdc_field USING 'BDC_SUBSCR' 'SAPMV45A 4301SUBSCREEN_BODY'. CALL TRANSACTION 'VA02' USING bdcdata MODE 'N' UPDATE 'E' MESSAGES INTO messtab. WAIT UP TO '0.1' SECONDS. READ TABLE messtab WITH KEY msgtyp = 'E'. IF sy-subrc = 0. * LOOP AT messtab WHERE msgtyp = 'E'. * CALL FUNCTION 'MESSAGE_TEXT_BUILD' "消息编号及变量使用函数转换为消息内容输出 * EXPORTING * msgid = messtab-msgid * msgnr = messtab-msgnr * msgv1 = messtab-msgv1 * msgv2 = messtab-msgv2 * msgv3 = messtab-msgv3 * msgv4 = messtab-msgv4 * IMPORTING * message_text_output = message. * ENDLOOP. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = vbeln_str IMPORTING output = vbeln_str. CONCATENATE message ',' vbeln_str INTO message. ENDIF. CLEAR bdcdata[]. ENDLOOP. IF message IS INITIAL. message = 'success'. ELSE. num = STRLEN( message ) - 1. message = message+1(num). ENDIF. ENDFUNCTION.
    FORM bdc_dynpro USING value(program) value(dynpro).
      CLEAR bdcdata.
      bdcdata-program  = program.
      bdcdata-dynpro   = dynpro.
      bdcdata-dynbegin = 'X'.
      APPEND bdcdata.
    ENDFORM.                    "BDC_DYNPRO
    
    *&---------------------------------------------------------------------*
    *&      Form  bdc_field
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      -->VALUE(FNAM)  text
    *      -->VALUE(FVAL)  text
    *----------------------------------------------------------------------*
    FORM bdc_field USING value(fnam) value(fval).
      CLEAR bdcdata.
      bdcdata-fnam = fnam.
      bdcdata-fval = fval.
      APPEND bdcdata.
    ENDFORM.                    "bdc_field
    abap菜鸟,记录学习笔记。才疏学浅,如有错误,请直接在评论区留言。
  • 相关阅读:
    三、Python基础(5)
    三、Python基础(4)
    三、Python基础(3)
    三、Python基础(2)
    mysql 索引的使用
    Java 泛型T
    vueJS
    集群 分布式 负载均衡的区别
    nodeJS vue elementUI mock学习过程笔记,仅用于个人记录巩固
    MAP
  • 原文地址:https://www.cnblogs.com/freeandeasy/p/13690957.html
Copyright © 2020-2023  润新知