ABAP-复制采购订单行项目到新的行
FUNCTION zmm_fm_copy2new.
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" VALUE(IN_EBELN) TYPE EBELN
*" VALUE(IN_EBELP) TYPE EBELP
*" VALUE(IN_QUANTITY) TYPE BSTMG
*" VALUE(IN_PRICE) TYPE BPREI
*" EXPORTING
*" VALUE(STATUS) TYPE C
*" VALUE(OUT_EBELP) TYPE EBELP
*"----------------------------------------------------------------------
DATA:gs_poheader TYPE bapimepoheader,
gs_poheaderx TYPE bapimepoheaderx,
gt_return TYPE STANDARD TABLE OF bapiret2,
gwa_return TYPE bapiret2,
gt_item TYPE STANDARD TABLE OF bapimepoitem,
gwa_item TYPE bapimepoitem,
lwa_item TYPE bapimepoitem,
gt_itemx TYPE STANDARD TABLE OF bapimepoitemx,
gwa_itemx TYPE bapimepoitemx,
gt_poschedule TYPE STANDARD TABLE OF bapimeposchedule,
gwa_poschedule TYPE bapimeposchedule,
lwa_poschedule TYPE bapimeposchedule,
gt_poschedulex TYPE STANDARD TABLE OF bapimeposchedulx,
gwa_poschedulex TYPE bapimeposchedulx,
gt_pocond TYPE STANDARD TABLE OF bapimepocond,
gwa_pocond TYPE bapimepocond,
lwa_pocond TYPE bapimepocond,
gt_pocondx TYPE STANDARD TABLE OF bapimepocondx,
gwa_pocondx TYPE bapimepocondx,
gt_pocomponents TYPE STANDARD TABLE OF bapimepocomponent,
gwa_pocomponents TYPE bapimepocomponent,
gwa_pocomponents_temp TYPE bapimepocomponent,
gt_pocomponentsx TYPE STANDARD TABLE OF bapimepocomponentx,
gwa_pocomponentsx TYPE bapimepocomponentx.
DATA:lv_num TYPE bapimepoheader-po_number.
CALL FUNCTION 'BAPI_PO_GETDETAIL1'
EXPORTING
purchaseorder = in_ebeln
IMPORTING
poheader = gs_poheader
TABLES
poitem = gt_item
poschedule = gt_poschedule
pocond = gt_pocond
return = gt_return.
gs_poheaderx-doc_type = 'X'.
gs_poheaderx-vendor = 'X'.
gs_poheaderx-purch_org = 'X'.
gs_poheaderx-pur_group = 'X'.
gs_poheaderx-comp_code = 'X'.
gs_poheaderx-doc_date = 'X'.
gs_poheaderx-langu = 'X'.
gs_poheaderx-currency = 'X'."货币
gs_poheaderx-status = 'X'."货币
SORT gt_item BY po_item DESCENDING."按行项目从高到低排序
DATA:new_po_item TYPE ebelp.
READ TABLE gt_item INTO DATA(wa) INDEX 1."获取最大行项目值
IF sy-subrc EQ 0.
new_po_item = wa-po_item + 10."产生新行号
ENDIF.
LOOP AT gt_item INTO gwa_item WHERE po_item EQ in_ebelp.
MOVE-CORRESPONDING gwa_item TO lwa_item.
lwa_item-po_item = new_po_item.
lwa_item-net_price = in_price.
lwa_item-quantity = in_quantity.
APPEND lwa_item TO gt_item.
gwa_item-quantity = gwa_item-quantity - in_quantity.
MODIFY TABLE gt_item FROM gwa_item.
gwa_itemx-po_item = new_po_item. "采购凭证的项目编号
gwa_itemx-material = 'X'.
gwa_itemx-net_price = 'X'.
gwa_itemx-short_text = 'X'."短文本
gwa_itemx-quantity = 'X'."采购订单数量
gwa_itemx-po_unit = 'X' ."采购订单的计量单位
gwa_itemx-plant = 'X'."工厂
gwa_itemx-stge_loc = 'X'. "库存地点
gwa_itemx-item_cat = 'X'.
gwa_itemx-tax_code = 'X'.
gwa_itemx-date_qty_fixed = 'X'.
APPEND gwa_itemx TO gt_itemx.
READ TABLE gt_itemx INTO DATA(wax) WITH KEY po_item = in_ebelp.
IF sy-subrc EQ 0.
wax-quantity = 'X'.
MODIFY TABLE gt_itemx FROM wax.
FREE wax.
ELSE.
wax-po_item = in_ebelp.
wax-quantity = 'X'.
APPEND wax TO gt_itemx.
FREE wax.
ENDIF.
ENDLOOP.
LOOP AT gt_poschedule INTO gwa_poschedule WHERE po_item EQ in_ebelp.
MOVE-CORRESPONDING gwa_poschedule TO lwa_poschedule.
lwa_poschedule-po_item = new_po_item.
lwa_poschedule-quantity = in_quantity.
APPEND lwa_poschedule TO gt_poschedule.
gwa_poschedule-quantity = gwa_poschedule-quantity - in_quantity.
MODIFY TABLE gt_poschedule FROM gwa_poschedule.
gwa_poschedulex-po_item = new_po_item. "采购凭证的项目编号
gwa_poschedulex-sched_line = 0001. "采购凭证的项目编号
gwa_poschedulex-del_datcat_ext = 'X'."交货日期的类别
gwa_poschedulex-delivery_date = 'X'."交货日期
gwa_poschedulex-quantity = 'X'."采购订单数量
APPEND gwa_poschedulex TO gt_poschedulex.
READ TABLE gt_poschedulex INTO DATA(wax1) WITH KEY po_item = in_ebelp.
IF sy-subrc EQ 0.
wax-quantity = 'X'.
MODIFY TABLE gt_poschedulex FROM wax1.
FREE wax1.
ELSE.
wax1-quantity = 'X'.
wax1-po_item = in_ebelp.
wax1-sched_line = 0001.
APPEND wax1 TO gt_poschedulex.
ENDIF.
ENDLOOP.
LOOP AT gt_pocond INTO gwa_pocond WHERE itm_number EQ in_ebelp.
MOVE-CORRESPONDING gwa_pocond TO lwa_pocond.
lwa_pocond-itm_number = new_po_item.
lwa_pocond-cond_p_unt = 1.
lwa_pocond-cond_value = in_price.
lwa_pocond-change_id = 'I'.
APPEND lwa_pocond TO gt_pocond.
gwa_pocondx-itm_number = new_po_item.
gwa_pocondx-cond_type = 'X'.
gwa_pocondx-cond_value = 'X'.
gwa_pocondx-cond_unit = 'X'. "条件单位
gwa_pocondx-cond_p_unt = 'X'. "价格单位
gwa_pocondx-currency = 'X'.
gwa_pocondx-change_id = 'X'.
APPEND gwa_pocondx TO gt_pocondx.
ENDLOOP.
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = gs_poheader-po_number
poheader = gs_poheader
poheaderx = gs_poheaderx
* POADDRVENDOR =
* TESTRUN =
* MEMORY_UNCOMPLETE =
* MEMORY_COMPLETE =
* POEXPIMPHEADER =
* POEXPIMPHEADERX =
* VERSIONS =
* NO_MESSAGING =
* NO_MESSAGE_REQ =
* NO_AUTHORITY =
* NO_PRICE_FROM_PO =
* PARK_COMPLETE =
* PARK_UNCOMPLETE =
* IMPORTING
* exppurchaseorder = lv_num
* EXPHEADER =
* EXPPOEXPIMPHEADER =
TABLES
return = gt_return
poitem = gt_item
poitemx = gt_itemx
* POADDRDELIVERY =
poschedule = gt_poschedule
poschedulex = gt_poschedulex
* POACCOUNT =
* POACCOUNTPROFITSEGMENT =
* POACCOUNTX =
* POCONDHEADER =
* POCONDHEADERX =
pocond = gt_pocond
pocondx = gt_pocondx
* POLIMITS =
* POCONTRACTLIMITS =
* POSERVICES =
* POSRVACCESSVALUES =
* POSERVICESTEXT =
* EXTENSIONIN =
* EXTENSIONOUT =
* POEXPIMPITEM =
* POEXPIMPITEMX =
* POTEXTHEADER =
* POTEXTITEM =
* ALLVERSIONS =
* POPARTNER =
* POCOMPONENTS = GT_POCOMPONENTS
* POCOMPONENTSX = GT_POCOMPONENTSX .
.
READ TABLE gt_return INTO gwa_return WITH KEY type = 'E'.
IF sy-subrc <> 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
out_ebelp
= new_po_item.
status
= 'S'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
status
= 'E'.
ENDIF.
ENDFUNCTION.
ABAP-复制采购订单行项目到新的行的更多相关文章
- ABAP 查看采购订单行项目已开票金额和已清金额
FUNCTION zmm_fm_po_invence. *"----------------------------------------------------------------- ...
- 002 MIRO发票校验采购订单项目科目分配类别检查增强-20150819
BADI SE19:ZINVOICE_UPDATE MIRO发票检验过账好模拟时,检查采购订单line 是否有固定资产的行项目,如果有固定资产项目,则弹出提示框,提示消息:存在规定资产采购项目! ...
- ME_PROCESS_PO_CUST 实现采购订单行项目增强
用户希望创建采购订单时,输入行项目时,能根据采购订单类型,自动带出科目分类类别. 业务顾问看了一下配置,不能实现这个功能,所以用增强实现. 采购订单BADI增强:ME_PROCESS_PO_CUST. ...
- SAP MM 有了采购订单历史的PO行项目里的采购附加费不允许再改了?
SAP MM 有了采购订单历史的PO行项目里的采购附加费不允许再改了? 正确答案是: 不允许,这是SAP标准逻辑. 那么问题来了!今日收到业务人员报说采购订单4300013979,完成了收货和IV, ...
- 【ABAP系列】SAP 销售订单的行项目里条件的增强
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP 销售订单的行项目里条件的 ...
- 【MM系列】SAP MM模块-控制采购订单中某些项目的输出显示
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP MM模块-控制采购订单中某些 ...
- 如何用代码填充S/4HANA销售订单行项目的数量字段
我的任务是用代码生成S/4HANA销售订单(Sales Order)的行项目,并且填充对应的quantity(数量)值. 最开始我用了下面的代码,把quantity的值写入item字段target_q ...
- 采购订单限价(包含阶梯价)ME_PROCESS_PO_CUST
为了能管控到钱财的每个环节,公司要求采购订单需要使用物料限价,当有报价低于先前的价格时,在采购订单保存时,更新最低限价 BADI:ME_PROCESS_PO_CUST process~item里做限价 ...
- SAP MM 按采购订单查询付款信息的报表?
SAP MM 按采购订单查询付款信息的报表? 上午给P3项目采购部门用户做了一个采购相关的报表的培训.培训过程中,客户的采购部门经理提出了一个问题:有没有报表能查询到各个采购订单的付款情况,显示采购订 ...
随机推荐
- python PEP8常用规范
python 常用PEP8规范 一 代码编排 1 缩进.4个空格的缩进(编辑器都可以完成此功能),不使用Tap,更不能混合使用Tap和空格.2 每行最大长度79,换行可以使用反斜杠,最好使用圆括号 ...
- SQL Server Update 链接修改和when的应用
一.自链接方式 update b1 set b1.money = b1.money + b2.money from (select * from wallet where type='余额') b1 ...
- 有趣的PHP一句话
今天看到如下图所示的PHP一句话,觉得挺有意思. 代码如下: <?=~$_='$<>/'^'{{{{';echo $_;@${$_}[_](@${$_}[__]);?> 效果图 ...
- linux应用程序设计--Makefile工程管理
Makefile文件描述了整个工程的编译.链接等规则.包括:工程中哪些源文件需要编译以及如何编译:需要创建哪些库文件以及如何创建这些库文件.如何产生最终的可执行文件. Makefile相关术语 1.规 ...
- C# ExcelAddIn 开发笔记
好久都没有写博客了,最近真的是太忙了,接手公司要做的一个小的新的项目,从接触认识到一个新东西,再到自己琢磨研究,最终结合公司业务把整个excel插件项目完成,还是有一点点成就感.以下是项目中基本上大致 ...
- py+selenium 老是定位不到文本内容【已解决】
问题:定位不到文本内容,路径也正确,该加frame也有加,等待时间也够长 测试: 上图看不出差异,但是测试1就定位得到,测试2就定位不到,为什么? 看下图就知道了 区别就在于,测试2后面多了个空格!! ...
- 数据结构-二叉树(1)以及前序、中序、后序遍历(python实现)
上篇文章我们介绍了树的概念,今天我们来介绍一种特殊的树--二叉树,二叉树的应用很广,有很多特性.今天我们一一来为大家介绍. 二叉树 顾名思义,二叉树就是只有两个节点的树,两个节点分别为左节点和右节点, ...
- SpringBoot学习笔记3
十六:自定义拦截器 参考文档 16.1 编写拦截器类 extends WebMvcConfigurerAdapter 并重写WebMvcConfigurerAdapter,如下: package co ...
- C#8.0 新增功能
连载目录 [已更新最新开发文章,点击查看详细] C#8.0提供了许多增强功能 01 Readonly 成员 可将 readonly 修饰符应用于结构的任何成员. 它指示该成员不会修改状态. 这比 ...
- 我狠起来连自己都打---如何简单实现Azure resource自动打标签
你是否还在为花费大量Azure Resource打标签而烦恼呢?你是否还在因为这样低效的重复劳动而痛苦呢? 在很长一段时间内,笔者既要做云架构调整,又要做日常系统维护,还要参与各种各样的项目,在这种情 ...