首页 > 其他分享 >DEMO: MIRO 根据退货PO创建贷项凭证BAPI_INCOMINGINVOICE_CREATE

DEMO: MIRO 根据退货PO创建贷项凭证BAPI_INCOMINGINVOICE_CREATE

时间:2022-10-16 17:00:58浏览次数:59  
标签:BAPI MIRO HEADER CREATE ITEM LT LS TYPE EKPO



QQ群 :SAP干货铺,  群号:775662808
所有群管理严格,严格禁止一切外来链接、招聘、广告等垃圾信息!


PO

DEMO: MIRO 根据退货PO创建贷项凭证BAPI_INCOMINGINVOICE_CREATE_微信

MIRO

DEMO: MIRO 根据退货PO创建贷项凭证BAPI_INCOMINGINVOICE_CREATE_手动输入_02

或者不勾选计算税额,手动输入税额。


demo

DEMO: MIRO 根据退货PO创建贷项凭证BAPI_INCOMINGINVOICE_CREATE_微信_03

*&---------------------------------------------------------------------*
*& Report ZLM_MIRO_2
*& SAP干货铺
*&---------------------------------------------------------------------*
*& 根据po创建贷项凭证
*&---------------------------------------------------------------------*
REPORT ZLM_MIRO_2.

TABLES EKKO.
TABLES EKPO.

PARAMETERS P_EBELN TYPE EKKO-EBELN DEFAULT '4690000030'.
PARAMETERS P_CA_TAX AS CHECKBOX DEFAULT 'X'."自动计算税费

DATA:LS_EKKO TYPE EKKO.
DATA:LT_EKPO TYPE TABLE OF EKPO.
DATA:LS_EKPO TYPE EKPO.

DATA:LT_MSEG TYPE TABLE OF MSEG.
DATA:LS_MSEG TYPE MSEG.

DATA:LS_HEADER TYPE BAPI_INCINV_CREATE_HEADER.
DATA:LT_TAXDATA TYPE TABLE OF BAPI_INCINV_CREATE_TAX.
DATA:LT_ITEM TYPE TABLE OF BAPI_INCINV_CREATE_ITEM.
DATA:LT_RETURN TYPE TABLE OF BAPIRET2.

DATA:LS_TAXDATA TYPE BAPI_INCINV_CREATE_TAX.
DATA:LS_ITEM TYPE BAPI_INCINV_CREATE_ITEM.
DATA:LS_RETURN TYPE BAPIRET2.

DATA:LV_DOC TYPE BAPI_INCINV_FLD-INV_DOC_NO.

START-OF-SELECTION.

SELECT SINGLE * FROM EKKO INTO LS_EKKO WHERE EBELN = P_EBELN.
SELECT * FROM EKPO INTO TABLE LT_EKPO WHERE EBELN = P_EBELN.
SELECT * FROM MSEG INTO TABLE LT_MSEG WHERE EBELN = P_EBELN.

CHECK SY-SUBRC = 0.


CLEAR LS_HEADER.
LS_HEADER-DOC_DATE = SY-DATUM.
LS_HEADER-PSTNG_DATE = SY-DATUM.
LS_HEADER-BLINE_DATE = SY-DATUM.
LS_HEADER-REF_DOC_NO = P_EBELN.
LS_HEADER-COMP_CODE = LS_EKKO-BUKRS.
LS_HEADER-DIFF_INV = LS_EKKO-LIFNR.
LS_HEADER-CURRENCY = LS_EKKO-WAERS.

*LS_HEADER-GROSS_AMOUNT = .
*LS_HEADER-HEADER_TXT = p_EBELN.

CLEAR LT_ITEM[].
CLEAR LT_TAXDATA[].
CLEAR LT_RETURN[].
CLEAR LS_ITEM.

LOOP AT LT_EKPO INTO LS_EKPO.

CLEAR LS_MSEG.
CLEAR LS_ITEM.
READ TABLE LT_MSEG INTO LS_MSEG
WITH KEY
EBELN = LS_EKPO-EBELN
EBELP = LS_EKPO-EBELP.

LS_ITEM-INVOICE_DOC_ITEM = SY-TABIX.
LS_ITEM-PO_NUMBER = LS_EKPO-EBELN.
LS_ITEM-PO_ITEM = LS_EKPO-EBELP.

LS_ITEM-REF_DOC = LS_MSEG-MBLNR.
LS_ITEM-REF_DOC_YEAR = LS_MSEG-MJAHR.
LS_ITEM-REF_DOC_IT = LS_MSEG-ZEILE.

LS_ITEM-TAX_CODE = LS_EKPO-MWSKZ.
LS_ITEM-ITEM_AMOUNT = LS_EKPO-NETWR.
LS_ITEM-QUANTITY = LS_EKPO-MENGE.
LS_ITEM-PO_UNIT = LS_EKPO-MEINS.


LS_HEADER-GROSS_AMOUNT = LS_HEADER-GROSS_AMOUNT + LS_EKPO-NETWR.

APPEND LS_ITEM TO LT_ITEM.

CLEAR LS_TAXDATA.

LS_TAXDATA-TAX_CODE = LS_EKPO-MWSKZ.
LS_TAXDATA-TAX_AMOUNT = LS_EKPO-NETWR * 17 / 100." demo 默认17%,
LS_TAXDATA-ITEMNO_TAX = LS_ITEM-INVOICE_DOC_ITEM.

LS_HEADER-GROSS_AMOUNT = LS_HEADER-GROSS_AMOUNT +
LS_TAXDATA-TAX_AMOUNT .

APPEND LS_TAXDATA TO LT_TAXDATA.

CLEAR LS_EKPO.
ENDLOOP.



IF P_CA_TAX IS NOT INITIAL.
LS_HEADER-CALC_TAX_IND = 'X'.
CLEAR LT_TAXDATA[].
ENDIF.


CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'
EXPORTING
HEADERDATA = LS_HEADER
IMPORTING
INVOICEDOCNUMBER = LV_DOC
TABLES
ITEMDATA = LT_ITEM
TAXDATA = LT_TAXDATA
RETURN = LT_RETURN.

LOOP AT LT_RETURN INTO LS_RETURN WHERE TYPE = 'E'.
WRITE LS_RETURN-MESSAGE.
SKIP.
ENDLOOP.

WRITE LV_DOC.
ROLLBACK WORK.

DEMO: MIRO 根据退货PO创建贷项凭证BAPI_INCOMINGINVOICE_CREATE_微信_04


标签:BAPI,MIRO,HEADER,CREATE,ITEM,LT,LS,TYPE,EKPO
From: https://blog.51cto.com/u_15680210/5760451

相关文章

  • DEMO:F-02固定资产 BAPI_ACC_DOCUMENT_POST 完整demo
    下面开始干货:之前发了一篇文章:《​​DEMO:F-02固定资产 BAPI_ACC_DOCUMENT_POST​​》有读者留言说最重要的增强部分没有写。最初以为这个增强是最常规的增强,FICO项目机会......
  • MIRO 凭证拆分 增强
    群里有人问MIRO拆分凭证怎么实现,找出来之前的资料看了下。整理之前的文章,当时也是朋友看的需求。MIRO发票校验,生成的财务发票凭证中,标准逻辑应付是一条,现在的需求是要根据......
  • 测试BAPI ,执行test sequence
    ​同行问了个问题,说执行BAPI后显示成功,但是前台去查看值并没有变化。其实BAPI都是RFC,updatetask模式更新,需要显示的commit,不会隐士提交。所以在SE37下,执行testsequence,把......
  • 修改文本CREATE_TEXT/SAVE_TEXT/READ_TEXT
    之前项目上在修改交货单文本,遇到一个问题:发现用SAVE_TEXT修改后,文本没有变.但是READ_TEXT文本,发现能读出来.只是显示的没修改.后来想起,有时候表里有个字段,是控制是否去显示......
  • DEMO:ME31L 创建计划协议 BAPI_SAG_CREATE
    前台:ME31L程序执行:*&---------------------------------------------------------------------**&ReportZLM_ME31L*&*&-----------------------------------------------......
  • DEMO: BAPI_SALESORDER_CREATEFROMDAT2 创建订单
    REPORTzdemo_va01.PARAMETERSp_kunnrTYPEkunnrDEFAULT'1004615'.PARAMETERSp_vkorgTYPEvkorgDEFAULT'S600'.PARAMETERSp_vtwegTYPEvtwegDEFAULT'10'.PARAM......
  • BAPI_ACC_DOCUMENT_POST更新BSED数据增强
    FB03查看凭证对于特殊总账类型为W的,双击进入可见出票人出票行票据号等信息这些数据是保存在bsed表的。而BAPI_ACC_DOCUMENT_POST 并没有提供这些字段。所以需要走增强。......
  • DEMO:MB1B 311 移库 BAPI_GOODSMVT_CREATE
    *&---------------------------------------------------------------------**&ReportZDEMO_MB1B*&*&---------------------------------------------------------------......
  • WDA DEMO 11 根据BAPI/Function创建WDA
    货铺QQ群号:834508274进群统一修改群名片,例如BJ_ABAP_森林木。群内禁止发广告及其他一切无关链接,小程序等,进群看公告,谢谢配合不修改昵称会被不定期踢除,谢谢配合事先声明下,本......
  • 增强Demo 03 销售订单屏幕增强后BAPI增强
    干货:前面两篇文章分别介绍了销售订单抬头和行项目上屏幕增强的案例。屏幕上增加了俩字段,那BAPI创建修改的时候怎么处理?怎么把增强字段值写进去?使用BAPI的EXTENSIONIN参数可......