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. Hibernate+Struts2+jsp 修改用户信息

    在用户列表页面点击修改,进入修改页面 修改薪酬为555,点击提交,重新跳回该页面 修改成功 关键代码如下 基层的代码,这里增加了一个根据用户id查询的方法 dao层 //修改 public USer ...

  2. jQuery 中的children()和 find() 的区别

    <!DOCTYPE html> <html> <head> <script type="text/javascript" src=&quo ...

  3. maven使用入门(pom)

    mvn clean complie mvn clean test mvn clean package mvn clean install(该任务将该项目输出的jar安装到了Maven本地仓库中) 各个 ...

  4. iOS - Swift SingleClass 单例类

    前言 单例对象能够被整个程序所操作.对于一个单例类,无论初始化单例对象多少次,也只能有一个单例对象存在,并且该对象是全局的,能够被整个系统访问到. 单例类的创建 1.1 单例类的创建 1 单例类的创建 ...

  5. 对sizeof的思考

    一.sizeof的特点(与strlen比较) 1.sizeof是运算符,strlen是函数,这意味着编译程序在编译的时候就把sizeof计算过了,所以sizeof(x)可以用来定义数组维数. 例如 i ...

  6. 搭建Mono for Android开发环境(用离线版)

    上面为我现在的离线版的安装包内容(不知道为什么上传的图名字显示不出来,郁闷),这些文件可以到http://pan.baidu.com/s/1ntM8U4T这里去下载: 安装步骤如下: 1)jdk-6u ...

  7. Python学习(4)运算符

    目录 Python 算术运算符 Python 比较运算符 Python 赋值运算符 Python 位运算符 Python 逻辑运算符 Python 成员运算符 Python 身份运算符 Python  ...

  8. (四)C语言柔性数组、指针赋值

    一.柔性数组 今天看了公司的代码,发现一个很奇怪的问题,后来自己写了类似代码,我先把代码贴出来吧. #include<stdio.h> #include<string.h> # ...

  9. Java Date与SimpleDateFormat

    最近在弄一些涉及到时间处理的项目.本来自己写了一个时间转换函数,虽然能用但是过于麻烦而且不够规范,于是学习了下java自带的时间处理的类. public class Timechg { public ...

  10. jQuery中$.post()的使用

    $.post()方法是jquery本身对ajax的一个简单封装,其效果等价于: $.ajax({ url:url, type:"POST", data:data, dataType ...