SAP ABAP/4學習---BDC批量輸入寫成內表程式

來源:互聯網
上載者:User
程式
*-----------------------------------------------------------------------
* Program ID    :ZTEST904_BDC
* Program Name  :ZTEST904_BDC
*-----------------------------------------------------------------------
* CREATED DATE  :2004/09/04
* CREATED BY    :LiuGang
* DESCRIPTION   :這個程式是學習如何通過程式來調用
*                BDC自動匯入資料的。
*-----------------------------------------------------------------------
* MODIFICATION  :
* DATE MODIFIED       MODIFIED BY     TRANSPORT REQUEST    DESCRIPTION
* 2004/09/04          LiuGang         VERSION:01/01            學習
*-----------------------------------------------------------------------
REPORT ZTEST904_BDC.


* 定義個BDC格式的內表
**************************************************
DATA : BEGIN OF I_BDCDATA OCCURS 0,
*BDC的程式名字,比如事物碼MM01的程式名字為SAPLMGMM(sap標準程式)
         PROGRAM LIKE BDCDATA-PROGRAM,
*BDC Dynpro 號碼
         DYNPRO LIKE BDCDATA-DYNPRO,
*BDC BDC Dynpro 開始
         DYNBEGIN LIKE BDCDATA-DYNBEGIN,
*BDC 項目名字
         FNAM LIKE BDCDATA-FNAM,
*BDC 項目名字的附加值
         FVAL LIKE BDCDATA-FVAL,
       END OF I_BDCDATA.

DATA: BEGIN OF ITAB OCCURS 0,
         A(9),
      END   OF ITAB.

ITAB-A = 'A0010'.
APPEND ITAB.
ITAB-A = 'A0011'.
APPEND ITAB.

 


* START-OF-SELECTION
START-OF-SELECTION.
LOOP AT ITAB.
   PERFORM APPEND_MM01 USING ITAB-A.
   PERFORM RUN_BDC.
ENDLOOP.


*---------------------------------------------------------------------*
*       FORM APPEND_DATA_MM01                                         *
*---------------------------------------------------------------------*
*       定義一個子程式裡面,用來存放操作的各個步驟                     *
*---------------------------------------------------------------------*
FORM APPEND_MM01 USING FVAL LIKE ITAB-A.

  CLEAR I_BDCDATA.
  CLEAR I_BDCDATA[].


*開始新的畫面事件
*0173畫面
*把程式名字和 BDC DYnpro號碼,開始標誌 寫入內表表頭,
  I_BDCDATA-PROGRAM = 'SAPLMGMM'.
  I_BDCDATA-DYNPRO = '0060'.
  I_BDCDATA-DYNBEGIN = 'X'.
  APPEND I_BDCDATA.
  CLEAR I_BDCDATA.

  I_BDCDATA-FNAM = 'BDC_CURSOR'.
  I_BDCDATA-FVAL = 'RMMG1-MATNR'.
  APPEND I_BDCDATA.
  CLEAR I_BDCDATA.

  I_BDCDATA-FNAM = 'BDC_OKCODE'.
  I_BDCDATA-FVAL = '/00'.
  APPEND I_BDCDATA.
  CLEAR I_BDCDATA.

  I_BDCDATA-FNAM = 'RMMG1-MATNR'.
*建立立的物料憑證號碼
* I_BDCDATA-FVAL = 'A004'.
  I_BDCDATA-FVAL = FVAL.
  APPEND I_BDCDATA.
  CLEAR I_BDCDATA.

  I_BDCDATA-FNAM = 'RMMG1-MBRSH'.
  I_BDCDATA-FVAL = 'C'.
  APPEND I_BDCDATA.
  CLEAR I_BDCDATA.

  I_BDCDATA-FNAM = 'RMMG1-MTART'.
  I_BDCDATA-FVAL = 'WERB'.
  APPEND I_BDCDATA.
  CLEAR I_BDCDATA.


*開始新的畫面事件
  I_BDCDATA-PROGRAM = 'SAPLMGMM'.
  I_BDCDATA-DYNPRO = '0070'.
  I_BDCDATA-DYNBEGIN = 'X'.
  APPEND I_BDCDATA.
  CLEAR I_BDCDATA.

  I_BDCDATA-FNAM = 'BDC_CURSOR'.
  I_BDCDATA-FVAL = 'MSICHTAUSW-DYTXT(01)'.
  APPEND I_BDCDATA.
  CLEAR I_BDCDATA.

  I_BDCDATA-FNAM = 'BDC_OKCODE'.
  I_BDCDATA-FVAL = '=ENTR'.
  APPEND I_BDCDATA.
  CLEAR I_BDCDATA.

  I_BDCDATA-FNAM = 'MSICHTAUSW-KZSEL(01)'.
  I_BDCDATA-FVAL = 'X'.
  APPEND I_BDCDATA.
  CLEAR I_BDCDATA.

*開始新的畫面事件
  I_BDCDATA-PROGRAM = 'SAPLMGMM'.
  I_BDCDATA-DYNPRO = '4004'.
  I_BDCDATA-DYNBEGIN = 'X'.
  APPEND I_BDCDATA.
  CLEAR I_BDCDATA.

  I_BDCDATA-FNAM = 'BDC_OKCODE'.
  I_BDCDATA-FVAL = '=BU'.
  APPEND I_BDCDATA.
  CLEAR I_BDCDATA.

  I_BDCDATA-FNAM = 'BDC_CURSOR'.
  I_BDCDATA-FVAL = 'MAKT-MAKTX'.
  APPEND I_BDCDATA.
  CLEAR I_BDCDATA.

  I_BDCDATA-FNAM = 'MAKT-MAKTX'.
  I_BDCDATA-FVAL = '測試BDC匯入資料'.
  APPEND I_BDCDATA.
  CLEAR I_BDCDATA.

  I_BDCDATA-FNAM = 'MARA-MEINS'.
  I_BDCDATA-FVAL = '000'.
  APPEND I_BDCDATA.
  CLEAR I_BDCDATA.

  I_BDCDATA-FNAM = 'MARA-MTPOS_MARA'.
  I_BDCDATA-FVAL = 'NORM'.
  APPEND I_BDCDATA.
  CLEAR I_BDCDATA.


ENDFORM.


*---------------------------------------------------------------------*
*       FORM RUN_BDC                                                  *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM RUN_BDC.
*開始調用事務MM01,把做好的bdc對象傳遞過去,然後把模式設定為A,
*就是說所有視窗,均可以看見.
* N 表示不看見吧
  CALL TRANSACTION 'MM01' USING I_BDCDATA MODE 'N'.

ENDFORM.



相關文章

Cloud Intelligence Leading the Digital Future

Alibaba Cloud ACtivate Online Conference, Nov. 20th & 21st, 2019 (UTC+08)

Register Now >

11.11 Big Sale for Cloud

Get Unbeatable Offers with up to 90% Off,Oct.24-Nov.13 (UTC+8)

Get It Now >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。