匯入物料主檔基本資料的BDC程式
Report zbdc_mm_w_test no standard page heading line-size 255.
include .
tables:mara,makt.
data : bdcdata_itab like bdcdata occurs 0 with header line.
data : messtab like bdcmsgcoll occurs 0 with header line.
data: s_mode(1) type c.
data : size type i.
data: begin of wa_tab,
matnr like mara-matnr, "物料碼
mtart like mara-mtart, "物料型別
maktx like makt-maktx, "物料描述
maktxen like makt-maktx, "物料英文名
meins like mara-meins, " 物料單位
bismt like mara-bismt, "舊物產碼
matkl like mara-matkl, "物料群組
spart like mara-spart, "部門
brgew(10) type c, "毛重
ntgew(10) type c, "淨重
gewei like mara-gewei, "重量單位
volum(10) type c, "容量
voleh like mara-voleh, "數量單位
magrv like mara-magrv, "物料群組﹕包裝物料
end of wa_tab.
data: it_tab like wa_tab occurs 0 with header line.
data: begin of wa_tabtemp,
matnr type char50, "物料碼
mtart type char50, "物料型別
maktx type char50, "物料描述
maktxen type char50, "物料英文名
meins type char50, " 物料單位
bismt type char50, "舊物產碼
matkl type char50, "物料群組
spart type char50, "部門
brgew type char50, "毛重
ntgew type char50, "淨重
gewei type char50, "重量單位
volum type char50, "容量
voleh type char50, "數量單位
magrv type char50, "物料群組﹕包裝物料
end of wa_tabtemp.
data: temp_tab like wa_tabtemp occurs 0 with header line.
*** END GENERATED DATA SECTION ***
[@more@]selection-screen: skip 1.
selection-screen begin of block b1 with frame title t1.
selection-screen : skip 1.
parameters : s_fname like rlgrap-filename obligatory.
selection-screen : skip 1.
parameters : rad_a radiobutton group rad type c,
rad_n radiobutton group rad type c,
rad_e radiobutton group rad type c.
selection-screen end of block b1.
at selection-screen on value-request for s_fname.
perform get_s_fname.
at selection-screen on radiobutton group rad.
if rad_a = 'X'.
s_mode = 'A'.
endif.
if rad_n = 'X'.
s_mode = 'N'.
endif.
if rad_e = 'X'.
s_mode = 'E'.
endif.
initialization.
t1 = '選擇匯入檔案'.
start-of-selection.
perform upload_to_itab.
loop at it_tab into wa_tab.
perform call_mm01.
call transaction 'MM01' using bdcdata_itab
mode s_mode
update 'S'
messages into messtab.
endloop.
end-of-selection.
*&---------------------------------------------------------------------*
*& FORM CALL_CT01
*&---------------------------------------------------------------------*
* 設定螢幕欄位值
*----------------------------------------------------------------------*
form call_mm01.
data: cname(16) type c.
clear bdcdata_itab.
refresh bdcdata_itab.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR' 'RMMG1-MTART'.
perform bdc_field using 'BDC_OKCODE' '=AUSW'.
perform bdc_field using 'RMMG1-MATNR' wa_tab-matnr.
perform bdc_field using 'RMMG1-MBRSH' 'M'.
perform bdc_field using 'RMMG1-MTART' wa_tab-mtart.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR' 'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE' '=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)' 'X'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE' '=BU'.
perform bdc_field using 'MAKT-MAKTX' wa_tab-maktx.
perform bdc_field using 'MARA-MEINS' wa_tab-meins.
perform bdc_field using 'MARA-MATKL' wa_tab-matkl.
perform bdc_field using 'MARA-BISMT' wa_tab-bismt.
perform bdc_field using 'MARA-SPART' wa_tab-spart.
perform bdc_field using 'MARA-BRGEW' wa_tab-brgew.
perform bdc_field using 'MARA-GEWEI' wa_tab-gewei.
perform bdc_field using 'MARA-NTGEW' wa_tab-ntgew.
perform bdc_field using 'MARA-VOLUM' wa_tab-volum.
perform bdc_field using 'MARA-VOLEH' wa_tab-voleh.
perform bdc_field using 'MARA-MAGRV' wa_tab-magrv.
perform bdc_field using 'BDC_CURSOR' 'MARA-MAGRV'.
endform. "CALL_CT01
*&---------------------------------------------------------------------*
*& FORM GET_S_FNAME
*&---------------------------------------------------------------------*
* 選擇檔案資料來源
*----------------------------------------------------------------------*
form get_s_fname.
call function 'WS_FILENAME_GET'
exporting
def_filename = '*.txt'
def_path = 'd:'
mask = ',*.txt.'
mode = 'O'
title = 'FIND THE TEXT FILE FOR OUTPUT'
importing
filename = s_fname
* RC =
exceptions
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
others = 5
.
endform. "GET_S_FNAME
*&---------------------------------------------------------------------*
*& Form UPLOAD_TO_ITAB
*&---------------------------------------------------------------------*
* 讀檔案資料到內表
*----------------------------------------------------------------------*
form upload_to_itab.
call function 'WS_UPLOAD'
exporting
filename = s_fname
filetype = 'DAT'
importing
filelength = size
tables
data_tab = temp_tab
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.
loop at temp_tab from 2.
move-corresponding temp_tab to it_tab.
append it_tab.
clear it_tab.
endloop.
endform. "UPLOAD_TO_ITAB
*----------------------------------------------------------------------*
* START NEW SCREEN *
*----------------------------------------------------------------------*
form bdc_dynpro using program dynpro.
clear bdcdata_itab.
bdcdata_itab-program = program.
bdcdata_itab-dynpro = dynpro.
bdcdata_itab-dynbegin = 'X'.
append bdcdata_itab.
endform. "BDC_DYNPRO
*----------------------------------------------------------------------*
* INSERT FIELD *
*----------------------------------------------------------------------*
form bdc_field using fnam fval.
if fval <> ''.
clear bdcdata_itab.
bdcdata_itab-fnam = fnam.
bdcdata_itab-fval = fval.
append bdcdata_itab.
endif.
endform. "BDC_FIELD
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9437124/viewspace-915243/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 物料資料檔
- bp主資料匯入功能
- 匯入大容量資料的基本原則
- SAP MM 物料主資料的Document Data
- 物料主資料的維護狀態
- 物料主記錄的資料結構資料結構
- SAP 物料主資料裡的commodity code
- MYSQL資料檔案匯入MySql
- mysqlimport 資料匯入程式MySqlImport
- java程式碼實現excel檔案資料匯入JavaExcel
- 使用xml檔案,做資料的匯入,匯出 (轉)XML
- [Docker核心之容器、資料庫檔案的匯入匯出、容器映象的匯入匯出]Docker資料庫
- Marketing Cloud contact主資料的csv匯入Cloud
- SAP物料主資料價格修改專題
- SAP 徹底刪除物料主資料操作
- material master物料主資料field selection配置AST
- php讀取excel檔案資料的匯入和匯出PHPExcel
- PHP 匯入資料庫 sql 檔案PHP資料庫SQL
- 資料庫遠端檔案匯入資料庫
- TP5.1excel匯入資料庫的程式碼?php excel如何匯入資料庫?Excel資料庫PHP
- SAP MM 物料主資料分類檢視的資料會帶入批次分類檢視裡?
- 資料庫的匯入匯出資料庫
- 資料泵的匯入匯出
- BDC程式示例C程式
- 把csv檔案的資料匯入到oracle資料庫中Oracle資料庫
- 資料匯入終章:如何將HBase的資料匯入HDFS?
- Net.Core匯入EXCel檔案裡的資料Excel
- Oracle:從SQL檔案批量匯入資料OracleSQL
- SAP徹底刪除物料主檔操作
- MySQL資料的匯入MySql
- Mongodb資料的匯出與匯入MongoDB
- EasyPoi, Excel資料的匯入匯出Excel
- 匯入和匯出AWR的資料
- BCP 資料的匯入和匯出
- AWR資料的匯出與匯入
- ITDS資料匯入匯出的方法
- NDS的資料匯入和匯出
- Progress資料表的匯入匯出