通过BDC批量修改物料文档信息 MM02
*&---------------------------------------------------------------------*
*& Report ZMM_03
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZMM_03 NO STANDARD PAGE HEADING
MESSAGE-ID ZMM.
TABLES:MARA.
DATA:BEGIN OF BDCDATA OCCURS 0.
INCLUDE STRUCTURE BDCDATA.
DATA:END OF BDCDATA.
DATA: MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
*DATA: GT_UP LIKE DRAW OCCURS 100 WITH HEADER LINE.
DATA:BEGIN OF GT_UP OCCURS 0.
INCLUDE STRUCTURE DRAW.
DATA:OLD_DOKNR LIKE DRAW-DOKNR.
DATA:END OF GT_UP.
data: gt_temp like DRAD OCCURS 100 WITH HEADER LINE.
DATA: INPUT TYPE KCDE_INTERN_STRUC OCCURS 100 WITH HEADER LINE.
DATA gt_fieldcat TYPE lvc_t_fcat .
DATA:T_C(2) TYPE C,T_TEMP(20) TYPE C,T_SIGN(1) TYPE C.
DATA: L_MSTRING(480).
DATA: LS_DOKNR LIKE DRAD-DOKNR.
PARAMETERS:MATNR LIKE MARA-MATNR OBLIGATORY.
PARAMETERS:P_MODE TYPE C DEFAULT 'N' NO-DISPLAY.
PARAMETERS: P_LFILE LIKE RLGRAP-FILENAME OBLIGATORY.
PARAMETERS R_INSERT RADIOBUTTON GROUP CTU DEFAULT 'X'.
PARAMETERS R_UPDATE RADIOBUTTON GROUP CTU.
PARAMETERS R_DELETE RADIOBUTTON GROUP CTU.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_lfile.
PERFORM GET_FILENAME USING P_LFILE
CHANGING P_LFILE.
START-OF-SELECTION.
T_SIGN = '3'.
if p_lfile <> ''.
PERFORM get_file.
ENDIF.
IF GT_UP[] IS INITIAL.
ELSE.
****取记录
PERFORM get_data.
PERform PROCESS_CC02.
PERform PROCESS_CC03.
PERform PROCESS_CC04.
PERFORM PROCESS_CC06.
IF R_INSERT = 'X'. "新增
T_C = LINES( GT_TEMP ).
LOOP AT GT_UP.
T_C = T_C + 1.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = T_C
IMPORTING
OUTPUT = T_C.
perform bdc_dynpro using 'SAPLMGMM' '4300'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
CONCATENATE 'DRAW-DOKNR(' T_C ')' INTO T_TEMP.
perform bdc_field using 'BDC_CURSOR'
T_TEMP.
CONCATENATE 'DRAW-DOKAR(' T_C ')' INTO T_TEMP.
perform bdc_field using T_TEMP
GT_UP-DOKAR.
CONCATENATE 'DRAW-DOKNR(' T_C ')' INTO T_TEMP.
perform bdc_field using T_TEMP
GT_UP-DOKNR.
CONCATENATE 'DRAW-DOKTL(' T_C ')' INTO T_TEMP.
perform bdc_field using T_TEMP
GT_UP-DOKTL.
CONCATENATE 'DRAW-DOKVR(' T_C ')' INTO T_TEMP.
perform bdc_field using T_TEMP
GT_UP-DOKVR.
perform bdc_field using 'GF_ALLE'
'X'.
* perform bdc_transaction using 'MM02'.
ENDLOOP.
perform bdc_dynpro using 'SAPLMGMM' '4300'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
CONCATENATE 'DRAW-DOKVR(' T_C ')' INTO T_TEMP.
perform bdc_field using 'BDC_CURSOR'
T_TEMP.
perform bdc_field using 'GF_ALLE'
'X'.
endif.
IF R_DELETE = 'X'. "删除
LOOP AT GT_UP.
LS_DOKNR = GT_UP-DOKNR.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = LS_DOKNR
IMPORTING
OUTPUT = LS_DOKNR.
LOOP AT GT_TEMP WHERE DOKNR = LS_DOKNR.
T_C = sy-tabix.
ENDLOOP.
ENDLOOP.
* T_C = T_C + 1.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = T_C
IMPORTING
OUTPUT = T_C.
perform bdc_dynpro using 'SAPLMGMM' '4300'.
perform bdc_field using 'BDC_OKCODE'
'=CV140_DELZ'.
CONCATENATE 'DRAW-DOKAR(' T_C ')' INTO T_TEMP.
perform bdc_field using 'BDC_CURSOR'
T_TEMP.
perform bdc_field using 'GF_ALLE'
'X'.
LOOP AT GT_UP.
LS_DOKNR = GT_UP-DOKNR.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = LS_DOKNR
IMPORTING
OUTPUT = LS_DOKNR.
LOOP AT GT_TEMP WHERE DOKNR = LS_DOKNR.
T_C = sy-tabix.
ENDLOOP.
* T_C = T_C + 1.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = T_C
IMPORTING
OUTPUT = T_C.
CONCATENATE 'MARK(' T_C ')' INTO T_TEMP.
perform bdc_field using T_TEMP
'X'.
* perform bdc_dynpro using 'SAPLSPO1' '0500'.
* perform bdc_field using 'BDC_OKCODE'
* '=OPT1'.
ENDLOOP.
perform bdc_dynpro using 'SAPLMGMM' '4300'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
CONCATENATE 'DRAW-DOKVR(' T_C ')' INTO T_TEMP.
perform bdc_field using 'BDC_CURSOR'
T_TEMP.
perform bdc_field using 'GF_ALLE'
'X'.
ENDIF.
IF R_UPDATE = 'X'. "修改
LOOP AT GT_UP.
LS_DOKNR = GT_UP-OLD_DOKNR.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = LS_DOKNR
IMPORTING
OUTPUT = LS_DOKNR.
LOOP AT GT_TEMP WHERE DOKNR = LS_DOKNR.
T_C = sy-tabix.
ENDLOOP.
ENDLOOP.
* T_C = T_C + 1.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = T_C
IMPORTING
OUTPUT = T_C.
perform bdc_dynpro using 'SAPLMGMM' '4300'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
CONCATENATE 'DRAW-DOKNR(' T_C ')' INTO T_TEMP.
perform bdc_field using 'BDC_CURSOR'
T_TEMP.
perform bdc_field using 'GF_ALLE'
'X'.
LOOP AT GT_UP.
LS_DOKNR = GT_UP-OLD_DOKNR.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = LS_DOKNR
IMPORTING
OUTPUT = LS_DOKNR.
LOOP AT GT_TEMP WHERE DOKNR = LS_DOKNR.
T_C = sy-tabix.
ENDLOOP.
* T_C = T_C + 1.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = T_C
IMPORTING
OUTPUT = T_C.
CONCATENATE 'DRAW-DOKNR(' T_C ')' INTO T_TEMP.
perform bdc_field using T_TEMP
GT_UP-DOKNR.
* perform bdc_dynpro using 'SAPLSPO1' '0500'.
* perform bdc_field using 'BDC_OKCODE'
* '=OPT1'.
ENDLOOP.
LOOP AT GT_UP.
perform bdc_dynpro using 'SAPLSPO1' '0500'.
perform bdc_field using 'BDC_OKCODE'
'=OPT1'.
ENDLOOP.
ENDIF.
* PERFORM PROCESS_CC07.
REFRESH MESSTAB.
CALL TRANSACTION 'MM02' USING BDCDATA MODE P_MODE UPDATE 'S' MESSAGES INTO MESSTAB.
LOOP AT MESSTAB.
MESSAGE ID MESSTAB-MSGID
TYPE MESSTAB-MSGTYP
NUMBER MESSTAB-MSGNR
INTO L_MSTRING
WITH MESSTAB-MSGV1
MESSTAB-MSGV2
MESSTAB-MSGV3
MESSTAB-MSGV4.
IF MESSTAB-MSGTYP = 'E'.
CONCATENATE MATNR ' ' L_MSTRING INTO L_MSTRING.
ENDIF.
WRITE: / MESSTAB-MSGTYP, L_MSTRING(250).
ENDLOOP.
* CALL TRANSACTION 'MM02' USING BDCDATA MODE P_MODE UPDATE 'S'.
endif.
END-OF-SELECTION.
FORM GET_FILENAME USING P_PATH LIKE RLGRAP-FILENAME
CHANGING P_FILE LIKE RLGRAP-FILENAME.
DATA:L_WRK_FILENAME LIKE RLGRAP-FILENAME,
L_WRK_MASK LIKE LGRWO-EXP_FILE.
* mask
L_WRK_MASK = ',*.xls,*.xls.'.
* get file name
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_PATH = P_FILE
MASK = L_WRK_MASK
MODE = 'O'
IMPORTING
FILENAME = L_WRK_FILENAME
EXCEPTIONS
INV_WINSYS = 01
NO_BATCH = 02
SELECTION_CANCEL = 03
SELECTION_ERROR = 04
OTHERS = 05.
IF SY-SUBRC = 0.
P_FILE = L_WRK_FILENAME.
ELSE.
ENDIF.
ENDFORM. " get_filename
FORM get_file.
CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
EXPORTING
FILENAME = P_LFILE
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 256
I_END_ROW = 65536
TABLES
INTERN = INPUT
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE E000(zqm) WITH '文件路径有误!'.
ENDIF.
LOOP AT INPUT.
IF input-row = '0001'.
CONTINUE. "第一行是字段名,直接跳过
ELSE.
CASE INPUT-COL.
WHEN '0001'.
GT_UP-DOKAR = INPUT-VALUE.
WHEN '0002'.
GT_UP-OLD_DOKNR = INPUT-VALUE.
WHEN '0003'.
GT_UP-DOKNR = INPUT-VALUE.
WHEN '0004'.
GT_UP-DOKTL = INPUT-VALUE.
WHEN '0005'.
GT_UP-DOKVR = INPUT-VALUE.
ENDCASE.
AT END OF ROW.
APPEND GT_UP.
CLEAR GT_UP.
ENDAT.
ENDIF.
ENDLOOP.
*** 检测
loop at gt_up.
IF R_INSERT = 'X' OR R_DELETE = 'X'.
IF GT_UP-OLD_DOKNR = GT_UP-DOKNR.
ELSE.
WRITE: / '新增,删除,两列文档编号必须一致', SY-SUBRC.
STOP.
ENDIF.
ELSE.
IF GT_UP-OLD_DOKNR = GT_UP-DOKNR.
WRITE: / '修改,两列文档编号必须不一致', SY-SUBRC.
STOP.
ELSE.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM.
form PROCESS_CC02.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'ENTR'.
perform bdc_field using 'RMMG1-MATNR'
matnr.
ENDform. "process_cc02
form PROCESS_CC03.
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'.
ENDform. "process_cc03
form PROCESS_CC04.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'=ZU01'.
perform bdc_field using 'BDC_CURSOR'
'MAKT-MAKTX'.
* perform bdc_field using 'MAKT-MAKTX'
* 'X'.
* perform bdc_field using 'MARA-MEINS'
* 'X'.
* perform bdc_field using 'MARA-MATKL'
* 'X'.
* perform bdc_field using 'MARA-EXTWG'
* 'X'.
* perform bdc_field using 'MARA-SPART'
* 'X'.
* perform bdc_field using 'MARA-MTPOS_MARA'
* 'X'.
* perform bdc_field using 'MARA-BRGEW'
* 'X'.
* perform bdc_field using 'MARA-GEWEI'
* 'X'.
* perform bdc_field using 'MARA-NTGEW'
* 'X'.
* perform bdc_field using 'MARA-VOLUM'
* 'X'.
* perform bdc_field using 'MARA-VOLEH'
* 'X'.
ENDform. "process_cc04
form PROCESS_CC05.
perform bdc_dynpro using 'SAPLMGMM' '4300'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'BDC_CURSOR'
'DRAW-DOKNR(01)'.
perform bdc_field using 'DRAW-DOKAR(01)'
GT_UP-DOKAR.
perform bdc_field using 'DRAW-DOKNR(01)'
GT_UP-DOKNR.
perform bdc_field using 'DRAW-DOKTL(01)'
GT_UP-DOKTL.
perform bdc_field using 'DRAW-DOKVR(01)'
GT_UP-DOKVR.
perform bdc_field using 'GF_ALLE'
'X'.
ENDform. "process_cc05
FORM PROCESS_CC06.
perform bdc_dynpro using 'SAPLMGMM' '4300'.
perform bdc_field using 'BDC_OKCODE'
'=ZU04'.
perform bdc_field using 'BDC_CURSOR'
'SKTEXT-SPRAS(01)'.
ENDFORM.
FORM PROCESS_CC07.
perform bdc_dynpro using 'SAPLMGMM' '4300'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'BDC_CURSOR'
'DRAW-DOKNR(02)'.
perform bdc_field using 'GF_ALLE'
'X'.
ENDFORM.
form BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDform.
form BDC_FIELD USING FNAM FVAL.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDform.
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DATA .
select * into CORRESPONDING FIELDS OF TABLE gt_temp
from DRAD
where DOKOB = 'MARA' AND
OBJKY = matnr.
SORT GT_TEMP BY DOKNR.
ENDFORM. " GET_DATA
对导入的EXCEL数据批量处理物料文档信息,包括新增,修改,删除
通过BDC批量修改物料文档信息 MM02的更多相关文章
- Python之文件处理-批量修改md文档内容
目录 Python之文件处理-批量修改md文档内容 Python之文件处理-批量修改md文档内容 #!/usr/bin/env python # -*- coding:utf-8 -*- import ...
- BDC批量修改物料描述
一.定义变量 type-POOLs:TRUXS,slis. TYPES: BEGIN OF ty_input , matnr TYPE mara-matnr , " 物料号 maktx TY ...
- ERP系统上传文档信息下载(十八)
下载的公用方法: /// <summary> /// 下载文档 /// </summary> /// <param name="TableName"& ...
- Python批量创建word文档(2)- 加图片和表格
Python创建word文档,任务要求:小杨在一家公司上班,每天都需要给不同的客户发送word文档,以告知客户每日黄金价格.要求在文档开始处给出banner条,价格日期等用表格表示.最后贴上自己的联系 ...
- 批量删除wps文档里的回车符的方法!WPS使用技巧分享!
有时候整理文档的时候,如果是从网上复制的文字,可能会因为复制而产生很多的回车符.怎样能批量去掉这些个回车符呢,下面马上告诉你批量删除wps文档里的回车符的方法!WPS使用技巧分享! 想要批量删除批量删 ...
- C# 导出word文档及批量导出word文档(1)
这里用到了两个dll,一个是aspose.word.dll,另外一个是ICSharpCode.SharpZipLib.dll,ICSharpCode.SharpZipLib.dll是用于批量 ...
- Dom4j修改xml文档
1. 写出内容到xml文档 XMLWriter writer = new XMLWriter(OutputStream, OutputForamt) wirter.write(Document); 2 ...
- C# 导出word文档及批量导出word文档(4)
接下来是批量导出word文档和批量打印word文件,批量导出word文档和批量打印word文件的思路差不多,只是批量打印不用打包压缩文件,而是把所有文件合成一个word,然后通过js来调用 ...
- 怎么修改PDF文档图片内容
我们想要修改PDF文件的时候应该怎么做呢,PDF文件不同于其他的文件,PDF文件的编辑需要借助PDF编辑器才能够对文件进行编辑修改,那么要怎么修改PDF文档图片内容呢,有许多的小伙伴都想知道该怎么做, ...
随机推荐
- springmvc其他类获取request记得web.xml
<listener> <listener-class>org.springframework.web.context.request.RequestContextListene ...
- 多线程(二)Object类方法、线程的操作sleep(),join(),interrupt(),yield()
四.Object类简介 Object类是所有类的超类,之所以放在线程部分是因为其方法很多是和线程有关的.比如以下三个: wait()方法.wait(long timeout)和wait(long ti ...
- vue的组件创建和使用
首先说一下vue组件 什么是组件? 在我的理解,vue的所有页面内容都是组件. 什么是父子组件? 因为所有的页面内容都是组件,那么怎么区分父子组件呢?其实很简单,现在有一个页面,在js里面的 comp ...
- springboot pdf模板打印
1.下载Adobe Acrobat DC工具来制作pdf的模板 打开一个pdf 2.制作pdf模板 把自动生成的文本框删除 然后 拖入文本框并自定义键 导入maven 依赖 <dependenc ...
- PHP中变量声明和定义的区别
先记录一下(不知道PHP是不是一样,但是C语言是这样的):把建立空间的声明称之为“定义”,而把不需要建立存储空间的声明称之为“声明”.声明的最终目的是为了提前使用,即在定义之前使用,如果不需要提前使用 ...
- Sql Service中的分页
创建存储过程如下: CREATE PROCEDURE [dbo].[sp_GetPageList] ), --表名 ) = '*', --字段名(全部字段为*) ), --排序字段(必须!支持多字段) ...
- 51nod 1402 最大值(贪心)
原题链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1402 思路:借鉴了这篇博文http://blog.csdn.n ...
- scrapy项目5:爬取ajax形式加载的数据,并用ImagePipeline保存图片
1.目标分析: 我们想要获取的数据为如下图: 1).每本书的名称 2).每本书的价格 3).每本书的简介 2.网页分析: 网站url:http://e.dangdang.com/list-WY1-dd ...
- jQuery_复制操作
复制操作代码: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <t ...
- Map循环/迭代/遍历效率、性能问题。
项目开发完毕,为了找点事打发一下时间,于是用findBugs插件对当前完工的项目进行扫描,发现了很多问题.其中有个关于性能的问题,在这里记录一下. 提示信息为:Inefficient use of k ...