zoukankan      html  css  js  c++  java
  • SAP data migration: Create billing plan for sales

    引用:翱翔云天

    report ZUP2
           no standard page heading line-size 255.

    *include bdcrecx1.
    parameters: dataset LIKE RLGRAP-FILENAME.
    PARAMETERS: P_MODE LIKE CTU_PARAMS-DISMODE DEFAULT 'E'.
    *       Batchinputdata of single transaction
    DATA:   BDCDATA LIKE BDCDATA    OCCURS 0 WITH HEADER LINE.
    *       messages of call transaction
    DATA:   MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
    *
    *** Generated data section with specific formatting - DO NOT CHANGE  ***
    data: begin of record,
            VBELN(030),
            POSNR(006),
            MLBEZ(005),
            WAERS(005),
            FAKSP(002),
            FAREG(001),
            FKSAF(001),
            FPTTP(002),
            FKARV(004),
            MLSTN(012),
            FPFIX(001),
            AFDAT(010),
            FPROZ(010),
            FAKWR(025),
          end of record.
    DATA: ITAB LIKE STANDARD TABLE OF RECORD WITH HEADER LINE.
    DATA: TEMP LIKE STANDARD TABLE OF RECORD WITH HEADER LINE.
    *** End generated data section ***
    start-of-selection.
    perform UPLOAD_FILE.
    CHECK NOT ITAB[] IS INITIAL.
    SORT ITAB BY VBELN POSNR.
    LOOP AT ITAB .
      RECORD = ITAB.
      TEMP = RECORD.
      APPEND TEMP.
    * The first sales document, step into the first screen
      AT NEW VBELN.
        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'
                                      record-VBELN.
      ENDAT.
    * A new item input, follow the second screen
      AT END OF POSNR.
        perform bdc_dynpro      using 'SAPMV45A' '4001'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '=POPO'.
        perform bdc_dynpro      using 'SAPMV45A' '0251'.
        perform bdc_field       using 'BDC_CURSOR'
                                      'RV45A-POSNR'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '=POSI'.
        perform bdc_field       using 'RV45A-POSNR'
                                      RECORD-POSNR.
        perform bdc_dynpro      using 'SAPMV45A' '4001'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '=ITEM'.
        perform bdc_field       using 'BDC_CURSOR'
                                      'VBAP-POSNR(01)'.
        perform bdc_dynpro      using 'SAPMV45A' '4003'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '=T\05'.
    *   Process the billing plan
        LOOP AT TEMP.
          perform bdc_dynpro      using 'SAPLV60F' '4001'.
          perform bdc_field       using 'BDC_OKCODE'
                                        '=ANLE'.
          perform bdc_field       using 'BDC_CURSOR'
                                        'FPLT-AFDAT(02)'.
          perform bdc_field       using 'FPLT-AFDAT(02)'
                                        TEMP-AFDAT.
          perform bdc_field       using 'FPLT-MLBEZ(02)'
                                        TEMP-MLBEZ.
    *      perform bdc_field       using 'FPLT-WAERS(02)'
    *                                    TEMP-WAERS.
          perform bdc_field       using 'FPLT-FAKSP(02)'
                                        TEMP-FAKSP.
          perform bdc_field       using 'FPLT-FAREG(02)'
                                        TEMP-FAREG.
    *      perform bdc_field       using 'FPLT-FKSAF(02)'
    *                                    TEMP-FKSAF.
          perform bdc_field       using 'FPLT-FPTTP(02)'
                                        TEMP-FPTTP.
          perform bdc_field       using 'FPLT-FKARV(02)'
                                        TEMP-FKARV.
    *      perform bdc_field       using 'FPLT-MLSTN(02)'
    *                                    TEMP-MLSTN.
          perform bdc_field       using 'FPLT-FPFIX(02)'
                                        TEMP-FPFIX.
          perform bdc_field       using 'FPLT-FPROZ(02)'
                                        TEMP-FPROZ.
          perform bdc_field       using 'FPLT-FAKWR(02)'
                                        TEMP-FAKWR.
        ENDLOOP.
    *   Leave to item screen
        perform bdc_dynpro      using 'SAPLV60F' '4001'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '=T\01'.
        perform bdc_dynpro      using 'SAPMV45A' '4003'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '/EBACK'.
        CLEAR: TEMP,TEMP[].
      ENDAT.
    * A sales docu end, save the changes
      AT END OF VBELN.
        perform bdc_dynpro      using 'SAPMV45A' '4001'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '=SICH'.
        perform bdc_dynpro      using 'SAPLSPO2' '0101'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '=OPT1'.
        CALL TRANSACTION 'VA02' USING BDCDATA
                         MODE   P_MODE
                         UPDATE 'S'
                         MESSAGES INTO MESSTAB.
        read table messtab with key MSGTYP = 'E'.
        IF SY-SUBRC = 0.
          WRITE: / record-VBELN.
        ENDIF.
        CLEAR: BDCDATA,BDCDATA[].
      ENDAT.
    ENDLOOP.
    *&---------------------------------------------------------------------*
    *&      Form  UPLOAD_FILE
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      -->P_DATASET  text
    *----------------------------------------------------------------------*
    FORM UPLOAD_FILE.
      CALL FUNCTION 'WS_UPLOAD'
       EXPORTING
         FILENAME                      = DATASET
         FILETYPE                      = 'DAT'
        TABLES
          DATA_TAB                      = ITAB
       EXCEPTIONS
         CONVERSION_ERROR              = 1
         FILE_OPEN_ERROR               = 2
         FILE_READ_ERROR               = 3
         INVALID_TYPE                  = 4
         NO_BATCH                      = 5
         UNKNOWN_ERROR                 = 6
         INVALID_TABLE_WIDTH           = 7
         GUI_REFUSE_FILETRANSFER       = 8
         CUSTOMER_ERROR                = 9
         OTHERS                        = 10
                .
    ENDFORM.                    " UPLOAD_FILE
    *----------------------------------------------------------------------*
    *        Start new screen                                              *
    *----------------------------------------------------------------------*
    FORM BDC_DYNPRO USING PROGRAM DYNPRO.
      CLEAR BDCDATA.
      BDCDATA-PROGRAM  = PROGRAM.
      BDCDATA-DYNPRO   = DYNPRO.
      BDCDATA-DYNBEGIN = 'X'.
      APPEND BDCDATA.
    ENDFORM.
    *----------------------------------------------------------------------*
    *        Insert field                                                  *
    *----------------------------------------------------------------------*
    FORM BDC_FIELD USING FNAM FVAL.
      IF FVAL <> SPACE.
        CLEAR BDCDATA.
        BDCDATA-FNAM = FNAM.
        BDCDATA-FVAL = FVAL.
        APPEND BDCDATA.
      ENDIF.
    ENDFORM.

  • 相关阅读:
    C++线程池实现-代码分析
    TortoiseGit如何更换用户名和密码
    go 访问apollo配置
    go 操作redis遇到的坑
    java类加载过程
    了解Python
    Java线程
    百度搜索引擎和谷歌搜索引擎的区别
    设置swiper容器同时显示的slide数量
    CSS last-child不起作用
  • 原文地址:https://www.cnblogs.com/wequst/p/1513744.html
Copyright © 2011-2022 走看看