SAP ABAP/4学习---BDC批量输入写成内表程序
2024-07-21 02:06:46
供稿:网友
*-----------------------------------------------------------------------
* 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.