SAP ABAP/4学习---BDC批量输入写成内表程序

类别:数据库 点击:0 评论:0 推荐:

*-----------------------------------------------------------------------
* 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.

本文地址:http://com.8s8s.com/it/it20217.htm