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修改的更多相关文章

  1. 一步步开发自己的博客 .NET版(11、Web.config文件的读取和修改)

    Web.config的读取 对于Web.config的读取大家都很属性了.平时我们用得比较多的就是appSettings节点下配置.如: 我们对应的代码是: = ConfigurationManage ...

  2. 一次修改闭源 Entity Provider 程序集以兼容新 EntityFramework 的过程

    读完本文你会知道,如何在没有源码的情况下,直接修改一个 DLL 以去除 DLL 上的强命名限制,并在该程序集上直接添加你的“友元程序集(一种特殊的 Attribute,将它应用在程序集上,使得程序集内 ...

  3. 当忘记mysql数据库密码时如何进行修改

    因为长时间没有使用数据库了,或者把密码改完之后就忘了数据库密码,不能正常进入数据库,也无法修改密码,有一个简单的常用修改密码方式: 1.首先找到和打开mysql.exe和mysqld.exe所在的文件 ...

  4. DB1:数据库的创建和文件的修改

    在SQL Server中,使用Create Database创建数据库,使用Alter Database命令,能够修改数据库的数据文件和日志文件. 一,创建数据库 1,在创建数据库时,最佳实践是: 创 ...

  5. ExtJS 4.2 业务开发(三)数据添加和修改

    接上面的船舶管理业务,这里介绍添加和修改操作. 目录 1. 添加操作 2. 修改操作 3. 在线演示 1. 添加操作 1.1 创建AddShipWindow.js 在业务中的view目录下创建一个Ad ...

  6. 修改eclipse皮肤

    习惯了vim黑色背景的程序猿们想必用eclipse时会倍感的不适应吧,不过没关系,因为eclipse的皮肤是可以自己定制的! 下面是我电脑上的eclipse界面,看到这个是不是找回了vim的感觉呢? ...

  7. ubuntu系统下如何修改host

    Ubuntu系统的Hosts只需修改/etc/hosts文件,在目录中还有一个hosts.conf文件,刚开始还以为只需要修改这个就可以了,结果发现是需要修改hosts.修改完之后要重启网络.具体过程 ...

  8. linux centos中添加删除修改环境变量,设置java环境变量

    前言 安装完软件必要添加环境变量.指令很少,然而长时间不写就会不自信:我写的对吗?于是百度开始,于是发现又是各有千秋.好吧,好记星不如烂笔头.当然,最重要的是,百度出来的都他妈的是如何添加环境变量,只 ...

  9. 修改session垃圾回收几率

    <?php //修改session垃圾回收几率 ini_set('session.gc_probability','1'); ini_set('session.gc_divisor','2'); ...

  10. Android中开发工具Android Studio修改created用户(windows环境)

    最近经常有朋友反馈说我的安卓项目中,在一些类中会出现Created by panchengjia on 2016/12/30的字样,是如何自动实现的(默认一般为Administrator),如下图: ...

随机推荐

  1. 不小心删除数据--利用MySQL的binlog恢复数据

    MySQL Binary Log也就是常说的bin-log, ,是mysql执行改动产生的二进制日志文件,其主要作用有两个: * 数据回复 * 主从数据库.用于slave端执行增删改,保持与maste ...

  2. [HDOJ1232]畅通工程

    畅通工程 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  3. bzoj 1588: [HNOI2002]营业额统计 treap

    1588: [HNOI2002]营业额统计 Time Limit: 5 Sec  Memory Limit: 162 MBSubmit: 13902  Solved: 5225[Submit][Sta ...

  4. 面向对象的JavaScript系列一,创建对象

    1.最简单的创建对象方法 var person = new Object(); person.name = "sam wu"; person.age = 25; person.jo ...

  5. iOS - UITextField

    前言 NS_CLASS_AVAILABLE_IOS(2_0) @interface UITextField : UIControl <UITextInput, NSCoding> @ava ...

  6. ORACLE 查询日志

    SQL>select * from v$sql (#查看最近所作的操作) SQL>select * fromv $sqlarea(#查看最近所作的操作)

  7. [转载] leveldb日知录

    原文: http://www.cnblogs.com/haippy/archive/2011/12/04/2276064.html 对leveldb非常好的一篇学习总结文章 郑重声明:本篇博客是自己学 ...

  8. 线程高级应用-心得8-java5线程并发库中同步集合Collections工具类的应用及案例分析

    1.  HashSet与HashMap的联系与区别? 区别:前者是单列后者是双列,就是hashmap有键有值,hashset只有键: 联系:HashSet的底层就是HashMap,可以参考HashSe ...

  9. 【Todo】LR-逻辑回归

    因为逻辑回归对于计算广告学非常重要.也是我们平时广告推荐.CTR预估最常用到的算法.所以单独开一篇文章讨论. 参考这篇文章:http://www.cnblogs.com/sparkwen/p/3441 ...

  10. linux 跨IP拷贝命令 scp

    原文:http://blog.csdn.net/mexican_jacky/article/details/52847094 scp -r ROOT/ tms2api@10.230.4.215:/Ja ...