码迷,mamicode.com
首页 > Windows程序 > 详细

BAPI修改采购订单描述

时间:2020-03-06 23:31:54      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:范围   loop   count   table   tables   fda   ret   系统表   数据   

*&---------------------------------------------------------------------*
*& Report ZGER_1910LK_030505
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZGER_1910LK_030505.
*&---------------------------------------------------------------------*
*& Report ZBAPI_NZF_CGSQ1
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
TABLES:EBAN,EBKN. "EBAN采购申请数据 EBKN采购申请账户设置
DATA: LT_ITEMS_OLD LIKE TABLE OF BAPIEBANV WITH HEADER LINE."旧数据
DATA: LT_ITEMS_NEW LIKE TABLE OF BAPIEBANV WITH HEADER LINE."采购申请创建好后,从系统表EBAN取出新数据,放这
DATA: LT_ACCOUNT_OLD LIKE TABLE OF BAPIEBKNV WITH HEADER LINE."旧数据
DATA: LT_ACCOUNT_NEW LIKE TABLE OF BAPIEBKNV WITH HEADER LINE."采购申请创建好后,从系统表EBKN取出新数据,放这
DATA: LT_ITEMS LIKE TABLE OF BAPIEBAN WITH HEADER LINE."传输结构:显示/内部需求条目
DATA: LT_ACCOUNT LIKE TABLE OF BAPIEBKN WITH HEADER LINE.
DATA: LT_BAPIRETURN LIKE TABLE OF BAPIRETURN WITH HEADER LINE."返回参数
DATA: T_EBAN LIKE TABLE OF EBAN WITH HEADER LINE.
DATA: T_EBKN LIKE TABLE OF EBKN WITH HEADER LINE.

PARAMETERS I_BANFN TYPE BANFN. "采购申请号 。

START-OF-SELECTION.
T_EBAN-BNFPO = ‘00010‘."采购申请的项目编号
T_EBAN-TXZ01 = ‘最强‘."短文本
T_EBAN-MENGE = ‘520‘."采购订单数量
T_EBAN-LFDAT = ‘20200301‘."项目交货日期
APPEND T_EBAN.


CALL FUNCTION ‘BAPI_REQUISITION_GETDETAIL‘ "采购申请数据获取
EXPORTING
NUMBER = I_BANFN "BAPIEBAN-PREQ_NO采购申请号
ACCOUNT_ASSIGNMENT = ‘X‘ "类型BAPIMMPARA-SELECTION 。采购申请项目的账户分配数据(如成本中心)
TABLES
REQUISITION_ITEMS = LT_ITEMS "行项目数据
REQUISITION_ACCOUNT_ASSIGNMENT = LT_ACCOUNT. "账户分配数据


LOOP AT LT_ITEMS.
MOVE-CORRESPONDING LT_ITEMS TO LT_ITEMS_OLD.
APPEND LT_ITEMS_OLD.
CLEAR LT_ITEMS_OLD.
MOVE-CORRESPONDING LT_ITEMS TO LT_ITEMS_NEW.
READ TABLE T_EBAN WITH KEY BNFPO = LT_ITEMS-PREQ_ITEM."采购申请的项目编号
IF SY-SUBRC = 0.
LT_ITEMS_NEW-SHORT_TEXT = T_EBAN-TXZ01. "短文本
* LT_ITEMS_NEW-STORE_LOC = T_EBAN-LGORT. "库存地点
LT_ITEMS_NEW-QUANTITY = T_EBAN-MENGE. "采购申请数量
* LT_ITEMS_NEW-UNIT = T_EBAN-MEINS. "采购申请计量单位
LT_ITEMS_NEW-DELIV_DATE = T_EBAN-LFDAT. "项目交货日期
* LT_ITEMS_NEW-MAT_GRP = T_EBAN-MATKL. "物料组
* LT_ITEMS_NEW-PUR_GROUP = T_EBAN-EKGRP. "采购组
* LT_ITEMS_NEW-C_AMT_BAPI = T_EBAN-PREIS. "采购需求中的价格
* LT_ITEMS_NEW-TRACKINGNO = T_EBAN-BEDNR. "需求跟踪号
* LT_ITEMS_NEW-CURRENCY = T_EBAN-WAERS. "货币码
* LT_ITEMS_NEW-PRICE_UNIT = T_EBAN-PEINH. "价格单位
ENDIF.
APPEND LT_ITEMS_NEW.
CLEAR LT_ITEMS_NEW.
ENDLOOP.

LOOP AT LT_ACCOUNT.
MOVE-CORRESPONDING LT_ACCOUNT TO LT_ACCOUNT_OLD.
APPEND LT_ACCOUNT_OLD.
CLEAR LT_ACCOUNT_OLD.
MOVE-CORRESPONDING LT_ACCOUNT TO LT_ACCOUNT_NEW.
READ TABLE T_EBKN WITH KEY BNFPO = LT_ACCOUNT-PREQ_ITEM.
IF SY-SUBRC = 0.
LT_ACCOUNT_NEW-WBS_ELEM_E = T_EBKN-PS_PSP_PNR. "工厂分解结构元素
LT_ACCOUNT_NEW-G_L_ACCT = T_EBKN-SAKTO. "G/L科目号
LT_ACCOUNT_NEW-COST_CTR = T_EBKN-KOSTL. "成本中心
LT_ACCOUNT_NEW-ASSET_NO = T_EBKN-ANLN1. "主资产号
LT_ACCOUNT_NEW-ORDER_NO = T_EBKN-AUFNR. "订单号
LT_ACCOUNT_NEW-CO_AREA = T_EBKN-KOKRS. "控制范围
ENDIF.
APPEND LT_ACCOUNT_NEW.
CLEAR LT_ACCOUNT_NEW.
ENDLOOP.

CALL FUNCTION ‘BAPI_REQUISITION_CHANGE‘ "采购申请修改
EXPORTING
NUMBER = I_BANFN "采购申请号
TABLES
REQUISITION_ITEMS_OLD = LT_ITEMS_OLD "旧数据
REQUISITION_ITEMS_NEW = LT_ITEMS_NEW "新数据
REQUISITION_ACCOUNT_OLD = LT_ACCOUNT_OLD
REQUISITION_ACCOUNT_NEW = LT_ACCOUNT_NEW
RETURN = LT_BAPIRETURN. "返回消息
write:LT_BAPIRETURN.
BREAK-POINT.

BAPI修改采购订单描述

标签:范围   loop   count   table   tables   fda   ret   系统表   数据   

原文地址:https://www.cnblogs.com/lvdong18847870057/p/12431531.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!