SO修改
FUNCTION Z_SD_SALESORDER_CHANGE1.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(IM_VBELN) TYPE VBELN
*" REFERENCE(IM_TYPE) TYPE CHAR4
*" REFERENCE(IM_BUDAT) TYPE BUDAT DEFAULT IM_BUDAT
*" TABLES
*" IT_ITEM STRUCTURE ZSDS0025
*" IT_RETURN STRUCTURE BAPIRET2
*"----------------------------------------------------------------------
***********************************************************************
* Function <Z_SD_SALESORDER_CHANGE1>
************************************************************************
*
* 作者: DZHANGHUI
* 完成日期: 2014/12/31
* 描述: 发货返写修改销售订单
************************************************************************
* 版本号 日期 作者 修改描述 功能更改说明书
************************************************************************
* 1. YYYY/MM/DD author Read dataset from app. Server @001
************************************************************************
DATA : LV_VBELN TYPE BAPIVBELN-VBELN,
LS_ITEM TYPE ZSDS0025,
LV_WERKS TYPE VBAP-WERKS,
LV_ETENR TYPE VBEP-ETENR,
LV_MATNR TYPE MATNR,
LV_MATNR_OLD TYPE MATNR,
LV_UPDATEFLAGE,
LV_INDEX TYPE I,
LV_POSNR TYPE POSNR,
LV_BWTTY TYPE MARC-BWTTY. DATA : BEGIN OF IT_VBAP OCCURS ,
VBELN TYPE VBAP-VBELN,
POSNR TYPE VBAP-POSNR,
MATNR TYPE VBAP-MATNR,
CHARG TYPE VBAP-CHARG,
WERKS TYPE VBAP-WERKS,
BWTAR TYPE VBAP-BWTAR, "评估类型
END OF IT_VBAP. LV_VBELN = IM_VBELN.
* 获取原有的行项目
SELECT VBELN POSNR MATNR CHARG WERKS BWTAR
FROM VBAP
INTO TABLE IT_VBAP
WHERE VBELN = LV_VBELN. REFRESH: IT_RETURN,
GT_SALESORDER_ITEM,
GT_SALESORDER_ITEMX,
GT_SALESORDER_SCHLINE,
GT_SALESORDER_SCHLINEX,
GT_SALESORDER_CONDITIONS,
GT_SALESORDER_CONDITIONX. IF IM_TYPE = 'SJ'.
* 删除原有的不带批次的行项目
LV_UPDATEFLAGE = 'D'. LOOP AT IT_VBAP WHERE CHARG = ''.
CLEAR GS_SALESORDER_ITEM.
GS_SALESORDER_ITEM-ITM_NUMBER = IT_VBAP-POSNR.
APPEND GS_SALESORDER_ITEM TO GT_SALESORDER_ITEM. CLEAR GS_SALESORDER_ITEMX.
GS_SALESORDER_ITEMX-UPDATEFLAG = LV_UPDATEFLAGE.
GS_SALESORDER_ITEMX-ITM_NUMBER = IT_VBAP-POSNR.
APPEND GS_SALESORDER_ITEMX TO GT_SALESORDER_ITEMX. LV_POSNR = IT_VBAP-POSNR.
ENDLOOP. IF SY-SUBRC NE .
READ TABLE IT_VBAP INDEX .
ENDIF. * 新增行项目
LV_UPDATEFLAGE = 'I'. LOOP AT IT_ITEM.
* 确保不存在相同的物料和批次的行项目
READ TABLE IT_VBAP WITH KEY MATNR = IT_ITEM-ZSPKH CHARG = IT_ITEM-ZSPPC.
CHECK SY-SUBRC NE . ADD TO LV_POSNR.
* Item
CLEAR GS_SALESORDER_ITEM.
GS_SALESORDER_ITEM-ITM_NUMBER = LV_POSNR.
GS_SALESORDER_ITEM-MATERIAL = IT_ITEM-ZSPKH.
GS_SALESORDER_ITEM-PLANT = IT_VBAP-WERKS.
GS_SALESORDER_ITEM-BATCH = IT_ITEM-ZSPPC.
GS_SALESORDER_ITEM-TARGET_QTY = IT_ITEM-ZSPJH. * 检查是否启用评估类别
PERFORM FRM_CHECK_VALUE_TYPE USING IT_VBAP-WERKS IT_ITEM-ZSPKH
CHANGING LV_BWTTY. IF LV_BWTTY EQ 'X'.
GS_SALESORDER_ITEM-VAL_TYPE = IT_ITEM-ZSPPC.
ENDIF. APPEND GS_SALESORDER_ITEM TO GT_SALESORDER_ITEM. CLEAR GS_SALESORDER_ITEMX.
GS_SALESORDER_ITEMX-UPDATEFLAG = LV_UPDATEFLAGE.
GS_SALESORDER_ITEMX-ITM_NUMBER = LV_POSNR.
GS_SALESORDER_ITEMX-MATERIAL = 'X'.
GS_SALESORDER_ITEMX-BATCH = 'X'.
GS_SALESORDER_ITEMX-PLANT = 'X'.
GS_SALESORDER_ITEMX-TARGET_QTY = 'X'.
IF LV_BWTTY EQ 'X'.
GS_SALESORDER_ITEMX-VAL_TYPE = 'X'.
ENDIF.
APPEND GS_SALESORDER_ITEMX TO GT_SALESORDER_ITEMX. * Schedule Line
CLEAR GS_SALESORDER_SCHLINE.
GS_SALESORDER_SCHLINE-ITM_NUMBER = LV_POSNR.
GS_SALESORDER_SCHLINE-SCHED_LINE = ''.
GS_SALESORDER_SCHLINE-REQ_QTY = IT_ITEM-ZSPJH.
GS_SALESORDER_SCHLINE-REQ_DATE = IM_BUDAT.
APPEND GS_SALESORDER_SCHLINE TO GT_SALESORDER_SCHLINE. CLEAR GS_SALESORDER_SCHLINEX.
GS_SALESORDER_SCHLINEX-ITM_NUMBER = LV_POSNR.
GS_SALESORDER_SCHLINEX-SCHED_LINE = ''.
GS_SALESORDER_SCHLINEX-UPDATEFLAG = LV_UPDATEFLAGE.
GS_SALESORDER_SCHLINEX-REQ_QTY = 'X'.
GS_SALESORDER_SCHLINEX-REQ_DATE = 'X'.
APPEND GS_SALESORDER_SCHLINEX TO GT_SALESORDER_SCHLINEX. * Condtions
CLEAR GS_SALESORDER_CONDITIONS.
GS_SALESORDER_CONDITIONS-ITM_NUMBER = LV_POSNR.
GS_SALESORDER_CONDITIONS-COND_TYPE = 'ZPR4'.
GS_SALESORDER_CONDITIONS-COND_VALUE = .
GS_SALESORDER_CONDITIONS-CURRENCY = 'CNY'.
APPEND GS_SALESORDER_CONDITIONS TO GT_SALESORDER_CONDITIONS. CLEAR GS_SALESORDER_CONDITIONX.
GS_SALESORDER_CONDITIONX-ITM_NUMBER = LV_POSNR.
GS_SALESORDER_CONDITIONX-COND_TYPE = 'ZPR4'.
GS_SALESORDER_CONDITIONX-UPDATEFLAG = 'I'.
GS_SALESORDER_CONDITIONX-COND_VALUE = 'X'.
GS_SALESORDER_CONDITIONX-CURRENCY = 'X'.
APPEND GS_SALESORDER_CONDITIONX TO GT_SALESORDER_CONDITIONX. CLEAR GS_SALESORDER_CONDITIONS.
GS_SALESORDER_CONDITIONS-ITM_NUMBER = LV_POSNR.
GS_SALESORDER_CONDITIONS-COND_TYPE = 'ZPR5'.
GS_SALESORDER_CONDITIONS-COND_VALUE = .
GS_SALESORDER_CONDITIONS-CURRENCY = 'CNY'.
APPEND GS_SALESORDER_CONDITIONS TO GT_SALESORDER_CONDITIONS. CLEAR GS_SALESORDER_CONDITIONX.
GS_SALESORDER_CONDITIONX-ITM_NUMBER = LV_POSNR.
GS_SALESORDER_CONDITIONX-COND_TYPE = 'ZPR5'.
GS_SALESORDER_CONDITIONX-UPDATEFLAG = 'I'.
GS_SALESORDER_CONDITIONX-COND_VALUE = 'X'.
GS_SALESORDER_CONDITIONX-CURRENCY = 'X'.
APPEND GS_SALESORDER_CONDITIONX TO GT_SALESORDER_CONDITIONX. ENDLOOP.
ELSEIF IM_TYPE = 'XQ'.
* 获取销售订单的最大行项目数
SORT IT_VBAP BY POSNR DESCENDING.
READ TABLE IT_VBAP INDEX .
IF SY-SUBRC EQ .
LV_POSNR = IT_VBAP-POSNR.
ELSE.
CLEAR LV_POSNR.
ENDIF. LOOP AT IT_ITEM.
* 物料和批次已存在 跳过
READ TABLE IT_VBAP WITH KEY MATNR = IT_ITEM-ZSPKH CHARG = IT_ITEM-ZSPPC.
IF SY-SUBRC EQ .
CONTINUE.
ENDIF. READ TABLE IT_VBAP WITH KEY MATNR = IT_ITEM-ZSPKH CHARG = ''.
IF SY-SUBRC EQ . LV_INDEX = SY-TABIX. * 修改行项目
LV_UPDATEFLAGE = 'U'. * Item
CLEAR GS_SALESORDER_ITEM.
GS_SALESORDER_ITEM-ITM_NUMBER = IT_VBAP-POSNR.
GS_SALESORDER_ITEM-BATCH = IT_ITEM-ZSPPC.
GS_SALESORDER_ITEM-TARGET_QTY = IT_ITEM-ZSPJH.
* 检查是否启用评估类别
PERFORM FRM_CHECK_VALUE_TYPE USING IT_VBAP-WERKS IT_ITEM-ZSPKH
CHANGING LV_BWTTY. IF LV_BWTTY EQ 'X'.
GS_SALESORDER_ITEM-VAL_TYPE = IT_ITEM-ZSPPC.
ENDIF.
APPEND GS_SALESORDER_ITEM TO GT_SALESORDER_ITEM. CLEAR GS_SALESORDER_ITEMX.
GS_SALESORDER_ITEMX-UPDATEFLAG = LV_UPDATEFLAGE.
GS_SALESORDER_ITEMX-ITM_NUMBER = IT_VBAP-POSNR.
GS_SALESORDER_ITEMX-BATCH = 'X'.
GS_SALESORDER_ITEMX-TARGET_QTY = 'X'.
IF LV_BWTTY EQ 'X'.
GS_SALESORDER_ITEMX-VAL_TYPE = 'X'.
ENDIF.
APPEND GS_SALESORDER_ITEMX TO GT_SALESORDER_ITEMX. * Schedule Line
CLEAR GS_SALESORDER_SCHLINE.
GS_SALESORDER_SCHLINE-ITM_NUMBER = IT_VBAP-POSNR.
GS_SALESORDER_SCHLINE-SCHED_LINE = ''.
GS_SALESORDER_SCHLINE-REQ_QTY = IT_ITEM-ZSPJH.
GS_SALESORDER_SCHLINE-REQ_DATE = IM_BUDAT.
APPEND GS_SALESORDER_SCHLINE TO GT_SALESORDER_SCHLINE. CLEAR GS_SALESORDER_SCHLINEX.
GS_SALESORDER_SCHLINEX-ITM_NUMBER = IT_VBAP-POSNR.
GS_SALESORDER_SCHLINEX-SCHED_LINE = ''.
GS_SALESORDER_SCHLINEX-UPDATEFLAG = LV_UPDATEFLAGE.
GS_SALESORDER_SCHLINEX-REQ_QTY = 'X'.
GS_SALESORDER_SCHLINEX-REQ_DATE = 'X'.
APPEND GS_SALESORDER_SCHLINEX TO GT_SALESORDER_SCHLINEX. IT_VBAP-CHARG = IT_ITEM-ZSPPC.
MODIFY IT_VBAP INDEX LV_INDEX TRANSPORTING CHARG.
ELSE.
* ---> 镶嵌订单 新增行 20150420
LV_INDEX = SY-TABIX. * 新增行项目
LV_UPDATEFLAGE = 'I'. ADD TO LV_POSNR. * Item
CLEAR GS_SALESORDER_ITEM.
GS_SALESORDER_ITEM-ITM_NUMBER = LV_POSNR.
GS_SALESORDER_ITEM-MATERIAL = IT_ITEM-ZSPKH.
GS_SALESORDER_ITEM-PLANT = IT_VBAP-WERKS.
GS_SALESORDER_ITEM-BATCH = IT_ITEM-ZSPPC.
GS_SALESORDER_ITEM-TARGET_QTY = IT_ITEM-ZSPJH.
* 检查是否启用评估类别
PERFORM FRM_CHECK_VALUE_TYPE USING IT_VBAP-WERKS IT_ITEM-ZSPKH
CHANGING LV_BWTTY. IF LV_BWTTY EQ 'X'.
GS_SALESORDER_ITEM-VAL_TYPE = IT_ITEM-ZSPPC.
ENDIF.
APPEND GS_SALESORDER_ITEM TO GT_SALESORDER_ITEM. CLEAR GS_SALESORDER_ITEMX.
GS_SALESORDER_ITEMX-UPDATEFLAG = LV_UPDATEFLAGE.
GS_SALESORDER_ITEMX-ITM_NUMBER = LV_POSNR.
GS_SALESORDER_ITEMX-BATCH = 'X'.
GS_SALESORDER_ITEMX-MATERIAL = 'X'.
GS_SALESORDER_ITEMX-PLANT = 'X'.
GS_SALESORDER_ITEMX-TARGET_QTY = 'X'.
IF LV_BWTTY EQ 'X'.
GS_SALESORDER_ITEMX-VAL_TYPE = 'X'.
ENDIF.
APPEND GS_SALESORDER_ITEMX TO GT_SALESORDER_ITEMX. * Schedule Line
CLEAR GS_SALESORDER_SCHLINE.
GS_SALESORDER_SCHLINE-ITM_NUMBER = LV_POSNR.
GS_SALESORDER_SCHLINE-SCHED_LINE = ''.
GS_SALESORDER_SCHLINE-REQ_QTY = IT_ITEM-ZSPJH.
GS_SALESORDER_SCHLINE-REQ_DATE = IM_BUDAT.
APPEND GS_SALESORDER_SCHLINE TO GT_SALESORDER_SCHLINE. CLEAR GS_SALESORDER_SCHLINEX.
GS_SALESORDER_SCHLINEX-ITM_NUMBER = LV_POSNR.
GS_SALESORDER_SCHLINEX-SCHED_LINE = ''.
GS_SALESORDER_SCHLINEX-UPDATEFLAG = LV_UPDATEFLAGE.
GS_SALESORDER_SCHLINEX-REQ_QTY = 'X'.
GS_SALESORDER_SCHLINEX-REQ_DATE = 'X'.
APPEND GS_SALESORDER_SCHLINEX TO GT_SALESORDER_SCHLINEX. * Condtions
CLEAR GS_SALESORDER_CONDITIONS.
GS_SALESORDER_CONDITIONS-ITM_NUMBER = LV_POSNR.
GS_SALESORDER_CONDITIONS-COND_TYPE = 'ZPR4'.
GS_SALESORDER_CONDITIONS-COND_VALUE = .
GS_SALESORDER_CONDITIONS-CURRENCY = 'CNY'.
APPEND GS_SALESORDER_CONDITIONS TO GT_SALESORDER_CONDITIONS. CLEAR GS_SALESORDER_CONDITIONX.
GS_SALESORDER_CONDITIONX-ITM_NUMBER = LV_POSNR.
GS_SALESORDER_CONDITIONX-COND_TYPE = 'ZPR4'.
GS_SALESORDER_CONDITIONX-UPDATEFLAG = 'I'.
GS_SALESORDER_CONDITIONX-COND_VALUE = 'X'.
GS_SALESORDER_CONDITIONX-CURRENCY = 'X'.
APPEND GS_SALESORDER_CONDITIONX TO GT_SALESORDER_CONDITIONX. CLEAR GS_SALESORDER_CONDITIONS.
GS_SALESORDER_CONDITIONS-ITM_NUMBER = LV_POSNR.
GS_SALESORDER_CONDITIONS-COND_TYPE = 'ZPR5'.
GS_SALESORDER_CONDITIONS-COND_VALUE = .
GS_SALESORDER_CONDITIONS-CURRENCY = 'CNY'.
APPEND GS_SALESORDER_CONDITIONS TO GT_SALESORDER_CONDITIONS. CLEAR GS_SALESORDER_CONDITIONX.
GS_SALESORDER_CONDITIONX-ITM_NUMBER = LV_POSNR.
GS_SALESORDER_CONDITIONX-COND_TYPE = 'ZPR5'.
GS_SALESORDER_CONDITIONX-UPDATEFLAG = 'I'.
GS_SALESORDER_CONDITIONX-COND_VALUE = 'X'.
GS_SALESORDER_CONDITIONX-CURRENCY = 'X'.
APPEND GS_SALESORDER_CONDITIONX TO GT_SALESORDER_CONDITIONX.
* <--- 镶嵌订单 新增行 20150420
ENDIF.
ENDLOOP.
ENDIF. CHECK GT_SALESORDER_ITEM IS NOT INITIAL. GS_SALESORDER_HEADER1X-UPDATEFLAG = 'U'.
GS_LOGIC_SWITCH-PRICING = 'G'.
* 修改订单
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
SALESDOCUMENT = LV_VBELN
ORDER_HEADER_INX = GS_SALESORDER_HEADER1X
LOGIC_SWITCH = GS_LOGIC_SWITCH
TABLES
RETURN = GT_RETURN
ORDER_ITEM_IN = GT_SALESORDER_ITEM
ORDER_ITEM_INX = GT_SALESORDER_ITEMX
SCHEDULE_LINES = GT_SALESORDER_SCHLINE
SCHEDULE_LINESX = GT_SALESORDER_SCHLINEX
CONDITIONS_IN = GT_SALESORDER_CONDITIONS
CONDITIONS_INX = GT_SALESORDER_CONDITIONX. LOOP AT GT_RETURN INTO GS_RETURN WHERE TYPE = 'E' OR
TYPE = 'X' OR
TYPE = 'A'.
EXIT.
ENDLOOP. IF SY-SUBRC EQ .
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
ENDIF. IT_RETURN[] = GT_RETURN[]. REFRESH: GT_SALESORDER_ITEM,
GT_SALESORDER_ITEMX,
GT_SALESORDER_SCHLINE,
GT_SALESORDER_SCHLINEX,
GT_SALESORDER_CONDITIONS,
GT_SALESORDER_CONDITIONX.
ENDFUNCTION.
FORM FRM_CHECK_VALUE_TYPE USING P_WERKS
P_MATNR
CHANGING P_BWTTY.
CLEAR P_BWTTY. SELECT SINGLE BWTTY INTO P_BWTTY
FROM MARC
WHERE WERKS = P_WERKS
AND MATNR = P_MATNR.
ENDFORM. " FRM_CHECK_VALUE_TYPE
SO修改的更多相关文章
- 一步步开发自己的博客 .NET版(11、Web.config文件的读取和修改)
Web.config的读取 对于Web.config的读取大家都很属性了.平时我们用得比较多的就是appSettings节点下配置.如: 我们对应的代码是: = ConfigurationManage ...
- 一次修改闭源 Entity Provider 程序集以兼容新 EntityFramework 的过程
读完本文你会知道,如何在没有源码的情况下,直接修改一个 DLL 以去除 DLL 上的强命名限制,并在该程序集上直接添加你的“友元程序集(一种特殊的 Attribute,将它应用在程序集上,使得程序集内 ...
- 当忘记mysql数据库密码时如何进行修改
因为长时间没有使用数据库了,或者把密码改完之后就忘了数据库密码,不能正常进入数据库,也无法修改密码,有一个简单的常用修改密码方式: 1.首先找到和打开mysql.exe和mysqld.exe所在的文件 ...
- DB1:数据库的创建和文件的修改
在SQL Server中,使用Create Database创建数据库,使用Alter Database命令,能够修改数据库的数据文件和日志文件. 一,创建数据库 1,在创建数据库时,最佳实践是: 创 ...
- ExtJS 4.2 业务开发(三)数据添加和修改
接上面的船舶管理业务,这里介绍添加和修改操作. 目录 1. 添加操作 2. 修改操作 3. 在线演示 1. 添加操作 1.1 创建AddShipWindow.js 在业务中的view目录下创建一个Ad ...
- 修改eclipse皮肤
习惯了vim黑色背景的程序猿们想必用eclipse时会倍感的不适应吧,不过没关系,因为eclipse的皮肤是可以自己定制的! 下面是我电脑上的eclipse界面,看到这个是不是找回了vim的感觉呢? ...
- ubuntu系统下如何修改host
Ubuntu系统的Hosts只需修改/etc/hosts文件,在目录中还有一个hosts.conf文件,刚开始还以为只需要修改这个就可以了,结果发现是需要修改hosts.修改完之后要重启网络.具体过程 ...
- linux centos中添加删除修改环境变量,设置java环境变量
前言 安装完软件必要添加环境变量.指令很少,然而长时间不写就会不自信:我写的对吗?于是百度开始,于是发现又是各有千秋.好吧,好记星不如烂笔头.当然,最重要的是,百度出来的都他妈的是如何添加环境变量,只 ...
- 修改session垃圾回收几率
<?php //修改session垃圾回收几率 ini_set('session.gc_probability','1'); ini_set('session.gc_divisor','2'); ...
- Android中开发工具Android Studio修改created用户(windows环境)
最近经常有朋友反馈说我的安卓项目中,在一些类中会出现Created by panchengjia on 2016/12/30的字样,是如何自动实现的(默认一般为Administrator),如下图: ...
随机推荐
- mysql获得自增字段下一个值
初次研究: 表: sql: show table status from carsale_db LIKE 'tb_car' 结果: 想办法取得这其中的值.... 在Internet上找到这个资料: M ...
- 转 cocos2dx内存优化
cocos2dx里面,sprite本身不消耗多少内存,只是关联的材质文件消耗内存.假设有10个sprite关联同一个材质,也不会有10倍消耗. 关于图片占用的材质内存,我觉得还有好几种优化手段:1.对 ...
- linux终端vi同时显示多个文件的分屏操作及切换操作
以前看到那边分屏操作的觉得很高端,现在初步整理了一下. 这里不是那个用代码实现的分屏,完全属于linux的操作命令 一.打开并显示文件 1.打开 这个不用说了,就是vi xx.c,或者vi xx1.c ...
- Linux vi 中移动光标 命令
移动光标 上:k nk:向上移动n行 9999k或gg可以移到第一行 G移到最后一行下:j nj:向下移动n行左:h nh:向左移动n列右:l nl:向右移动n列 w:光标以单词向前移动 nw:光标向 ...
- [转载] C++11中的右值引用
C++11中的右值引用 May 18, 2015 移动构造函数 C++98中的左值和右值 C++11右值引用和移动语义 强制移动语义std::move() 右值引用和右值的关系 完美转发 引用折叠推导 ...
- Html.Listbox的用法(实例)
homecontroller控制器中的index动作代码如下: public actionresult index() { list<selectlistitem& ...
- JSP连接数据库的两种方式:Jdbc-Odbc桥和Jdbc直连(转)
学JSP的同学都要知道怎么连数据库,网上的示例各有各的做法,弄得都不知道用谁的好.其实方法千变万化,本质上就两种:Jdbc-Odbc桥和Jdbc直连. 下面先以MySQL为例说说这两种方式各是怎么连的 ...
- Java中的数学运算BigDecimal
Math类 package ch7; /** * Created by Jiqing on 2016/11/24. */ public class MathDemo { public static v ...
- 关于boost的thread的mutex与lock的问题
妈的,看了好久的相关的知识,感觉终于自己有点明白了,我一定要记下来啊,相关的知识呀.... 1, 也可以看一下boost的线程指南:http://wenku.baidu.com/link?url=E_ ...
- embed object以及video标签的区别以及使用
embed object以及video标签的区别以及使用?