首页 > 其他分享 >SAP MIRO MIR7

SAP MIRO MIR7

时间:2023-08-21 09:35:12浏览次数:44  
标签:MIRO itemdata wa glaccountdata MIR7 SAP TYPE headerdata materialdata

https://www.freesion.com/article/6364448776/

 

REPORT zmiro.

DATA: g_ztype    TYPE bapi_mtype,
      g_zmessage TYPE bapi_msg.

DATA: wa_headerdata TYPE bapi_incinv_create_header.

DATA: g_invoicedocnumber TYPE bapi_incinv_fld-inv_doc_no,
      g_fiscalyear       TYPE bapi_incinv_fld-fisc_year,

      wa_itemdata        TYPE bapi_incinv_create_item,
      it_itemdata        LIKE STANDARD TABLE OF wa_itemdata,

      wa_taxdata         TYPE bapi_incinv_create_tax,
      it_taxdata         LIKE STANDARD TABLE OF wa_taxdata,

      wa_accountingdata  TYPE bapi_incinv_create_account,
      it_accountingdata  LIKE STANDARD TABLE OF wa_accountingdata,

      wa_materialdata    TYPE bapi_incinv_create_material,
      it_materialdata    LIKE STANDARD TABLE OF wa_materialdata,

      wa_glaccountdata   TYPE bapi_incinv_create_gl_account,
      it_glaccountdata   LIKE STANDARD TABLE OF wa_glaccountdata.

DATA: g_rblgp TYPE rblgp.

DATA: wa_return TYPE bapiret2,
      it_return LIKE STANDARD TABLE OF wa_return.

*CLEAR: e_result.
*SELECT SINGLE
*       belnr
*       gjahr
*  FROM rbkp
*  INTO (e_result-belnr, e_result-gjahr)
* WHERE zuonr EQ iw_head-alloc_nmbr.
*IF sy-subrc = 0.
*  e_result-msgtype = 'E'.
*  CONCATENATE 'FSSC单号:'
*              iw_head-alloc_nmbr
*              '已存在对应的过账发票'
*              INTO
*              e_result-msgtext.
*ELSE.
CLEAR: wa_headerdata.
wa_headerdata-invoice_ind  = 'X'.    "记帐发票
wa_headerdata-doc_type = 'SA'.
wa_headerdata-doc_date = sy-datum.
wa_headerdata-pstng_date = sy-datum.

*wa_headerdata-ref_doc_no = iw_head-ref_doc_no.
wa_headerdata-comp_code = '8101'.
*wa_headerdata-diff_inv = 'TEST04'.
*wa_headerdata-diff_inv = |{ wa_headerdata-diff_inv ALPHA = IN }|.
wa_headerdata-gross_amount = 0.
wa_headerdata-currency = 'MXN'.
wa_headerdata-header_txt = '123456765432'.
wa_headerdata-pmnttrms = 'GA01'.
*wa_headerdata-alloc_nmbr = iw_head-alloc_nmbr.


CLEAR: it_taxdata.
CLEAR:wa_taxdata.
wa_taxdata-tax_code = 'V0'.
wa_taxdata-tax_amount = 0.
APPEND wa_taxdata TO it_taxdata.


CLEAR: it_materialdata.
*LOOP AT it_material INTO DATA(wa_material).
CLEAR: wa_materialdata.
wa_materialdata-invoice_doc_item = 1.
wa_materialdata-material = 'AC1C-CB8-A0-R6-A'.
CALL FUNCTION 'CONVERSION_EXIT_MATN5_INPUT'
  EXPORTING
    input        = wa_materialdata-material
  IMPORTING
    output       = wa_materialdata-material
  EXCEPTIONS
    length_error = 1
    OTHERS       = 2.
wa_materialdata-val_area = '8101'.
*  wa_materialdata-valuation_type = wa_material-valuation_type.
wa_materialdata-db_cr_ind = 'S'.
wa_materialdata-item_amount = 1000.
wa_materialdata-quantity = 1.
wa_materialdata-base_uom = 'PC'.
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'
  EXPORTING
    input          = wa_materialdata-base_uom
*   LANGUAGE       = SY-LANGU
  IMPORTING
    output         = wa_materialdata-base_uom
  EXCEPTIONS
    unit_not_found = 1
    OTHERS         = 2.
wa_materialdata-tax_code = 'V0'.
APPEND wa_materialdata TO it_materialdata.

*ENDLOOP.



CLEAR: it_glaccountdata.
*LOOP AT it_glaccount INTO DATA(wa_glaccount).
CLEAR: wa_glaccountdata.
wa_glaccountdata-invoice_doc_item = 1.
wa_glaccountdata-comp_code = '8101'.
wa_glaccountdata-gl_account = '2221010001'.
wa_glaccountdata-gl_account = |{ wa_glaccountdata-gl_account ALPHA = IN }|.
wa_glaccountdata-item_amount = 600.
wa_glaccountdata-db_cr_ind = 'H'.
*  wa_glaccountdata-costcenter = wa_glaccount-costcenter.
*  wa_glaccountdata-costcenter = |{ wa_glaccountdata-costcenter ALPHA = IN }|.
*  wa_glaccountdata-func_area = wa_glaccount-func_area.
*  wa_glaccountdata-profit_ctr = wa_glaccount-profit_ctr.
*  wa_glaccountdata-profit_ctr = |{ wa_glaccountdata-profit_ctr ALPHA = IN }|.
wa_glaccountdata-plant = '8101'.
*wa_glaccountdata-tax_code = 'V0'.
APPEND wa_glaccountdata TO it_glaccountdata.

CLEAR: wa_glaccountdata.
wa_glaccountdata-invoice_doc_item = 2.
wa_glaccountdata-comp_code = '8101'.
wa_glaccountdata-gl_account = '2221130000'.
wa_glaccountdata-gl_account = |{ wa_glaccountdata-gl_account ALPHA = IN }|.
wa_glaccountdata-item_amount =  400.
wa_glaccountdata-db_cr_ind = 'H'.
*  wa_glaccountdata-costcenter = wa_glaccount-costcenter.
*  wa_glaccountdata-costcenter = |{ wa_glaccountdata-costcenter ALPHA = IN }|.
*  wa_glaccountdata-func_area = wa_glaccount-func_area.
*  wa_glaccountdata-profit_ctr = wa_glaccount-profit_ctr.
*  wa_glaccountdata-profit_ctr = |{ wa_glaccountdata-profit_ctr ALPHA = IN }|.
wa_glaccountdata-plant = '8101'.
*wa_glaccountdata-tax_code = 'V0'.
APPEND wa_glaccountdata TO it_glaccountdata.


*ENDLOOP.
SELECT *  INTO TABLE @DATA(ut_out) FROM ekpo WHERE ebeln EQ '8500000187'.
LOOP AT ut_out INTO DATA(ls_out).
  wa_itemdata-invoice_doc_item = sy-tabix.
  wa_itemdata-po_number = ls_out-ebeln.    "ENTER THE PO NUMBER
  wa_itemdata-po_item = ls_out-ebelp.           "ENTER THE PO ITEM NUMBER
  wa_itemdata-tax_code = 'V0'. "税码
*  wa_itemdata-item_amount = '1000'. "不含税金额
*  wa_itemdata-quantity = ls_out-menge. "数量
*  wa_itemdata-po_unit = ls_out-meins. "单位
  wa_itemdata-de_cre_ind = 'X'.
*IF ls_alv-zdoc055 IS NOT INITIAL.
  SELECT SINGLE matdoc~lfbnr matdoc~lfbja matdoc~lfpos  INTO
  ( wa_itemdata-ref_doc, wa_itemdata-ref_doc_year, wa_itemdata-ref_doc_it  )  FROM matdoc
    WHERE ebeln EQ ls_out-ebeln AND ebelp EQ ls_out-ebelp .

*wa_itemdata-item_text = p_sh. "税号
  APPEND wa_itemdata TO it_itemdata.
ENDLOOP.




CLEAR: g_ztype, g_zmessage.
CLEAR: g_invoicedocnumber, g_fiscalyear, it_return.

CALL FUNCTION 'MESSAGES_INITIALIZE'.
CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'
  EXPORTING
    headerdata       = wa_headerdata
*   ADDRESSDATA      =
  IMPORTING
    invoicedocnumber = g_invoicedocnumber
    fiscalyear       = g_fiscalyear
  TABLES
  itemdata         = it_itemdata
*   ACCOUNTINGDATA   =
    glaccountdata    = it_glaccountdata
    materialdata     = it_materialdata
    taxdata          = it_taxdata
*   WITHTAXDATA      =
*   VENDORITEMSPLITDATA       =
    return           = it_return
*   EXTENSIONIN      =
*   TM_ITEMDATA      =
*   NFMETALLITMS     =
*   ASSETDATA        =
  .
LOOP AT it_return INTO wa_return WHERE type = 'A' OR type = 'E'.
  EXIT.
ENDLOOP.
IF sy-subrc = 0.
  CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK' .
  LOOP AT it_return INTO wa_return WHERE type = 'A' OR type = 'E'.
    CONCATENATE g_zmessage wa_return-message INTO g_zmessage.
  ENDLOOP.
  g_ztype = 'E'.
ELSE.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      wait = 'X'
*     IMPORTING
*     RETURN        =
    .
  g_ztype = 'S'.
  CONCATENATE '预制发票'
              g_invoicedocnumber
              '年度'
              g_fiscalyear
              ',创建成功!'
              INTO
              g_zmessage.
*  e_result-belnr = g_invoicedocnumber.
*  e_result-gjahr = g_fiscalyear.
ENDIF.
*e_result-msgtype = g_ztype.
*e_result-msgtext = g_zmessage.
*ENDIF.

 

标签:MIRO,itemdata,wa,glaccountdata,MIR7,SAP,TYPE,headerdata,materialdata
From: https://www.cnblogs.com/ZJY-1314/p/17645141.html

相关文章

  • Could not find a generator for route RouteSettings("search", null) in the _Widge
    遇到这个错误消息意味着在您的Flutter应用程序中没有为名为"search"的路由定义路由生成器。要解决此问题,您需要定义一个路由生成器来处理名为"search"的路由。以下是如何在Flutter应用程序中定义路由生成器的示例:首先,定义一个路由生成器函数,该函数接受 RouteSettings 对象并返回......
  • SAP EWM 模块中的 pick 和 Pack 功能
    SAPEWM操作用户可以使用Pick和Pack功能在仓库的不同活动区域中协调选货、打包和产品的运输。例如,你可以使用传送带将产品从一个活动区域运输到另一个活动区域。从组织的角度来看,一个活动区域可以对应一个货道,由仓库工人负责。一旦仓库工人在他的区域里完成了一个仓库订单的......
  • 关于 SAP S/4HANA 的版本号机制
    SAPS/4HANA是一款全面的企业资源计划(ERP)软件,是SAP的下一代ERP系统,具有许多创新特性和增强功能。其版本号规则涉及到版本类型、主版本、支持包等,我将逐步解释并举例说明。SAPS/4HANA版本号规则:SAPS/4HANA的版本号由多个部分组成,每个部分都传达了特定信息,如版本类型、主版本、......
  • SAP CRM One Order 锁定模式用的是 Exclusive Lock
    在SAPCRMWebClientUI上点击Edit按钮后,界面进入可编辑状态:后台SM12事务码观察到锁类型为E,即Exclusivelock,也就是排他锁。其中PRCD_HEAD是Pricing模块抬头级别的数据:CRMOneOrder对应的lockobject名称为:E_CRM_ORDER关于这个叫做prospect的必填......
  • SAP ABAP 系统支持的锁操作类型和各自使用场景的详细讲解试读版
    本教程前一篇文章,我们已经通过浏览器和SAPGUI里两个具体的例子,介绍了SAP应用程序中锁机制的工作原理。109.SAPABAP应用程序中的锁机制和工作原理介绍上面的文章提到,SAPABAP系统中加锁和解锁的函数都是ABAPDDIC即事务码SE11自动生成的,到目前为止我们都只是在学习S......
  • 关于 SAP ABAP 里的锁类型 Lock Type
    在SAP帮助文档里有关于ABAPlock支持的全部类型和说明,总共支持四种类型的锁:S,E,X和O.注意E锁和X锁的区别是,E锁可以在同一个事务里多次被请求,但X锁即使在同一个事务里,也只能被请求一次。我在SAPCRM系统里看到OneOrder页面点击Edit按钮时,背后使用的Lock......
  • 关于 SAP ABAP Enqueue Function Module 的输入参数 _wait
    我们查看ABAP系统根据LockObject自动生成的EnqueueFunctionModule,可以发现它有一个名叫_wait的输入参数,默认值为space:该参数决定了发生锁冲突时的锁行为。开发人员有以下选择:初始值:如果由于存在竞争锁而导致锁定尝试失败,则会触发异常FOREIGN_LOCK。X:如果由......
  • 什么是 SAP ABAP Lock Mode 的 cumulative 特性
    SAP官网提到:Ifthename,argument,andlockmodeoftheelementarylockareidentical,andifalockisnotexclusiveandnon-cumulative,itcanbesetmorethanonce(acumulation).Thecumulationcounterisincrementedbyonewitheachsuccessivecumulat......
  • 什么是 SAP CDS view 的 join on demand 技术
    SAPCDSview里借助pathexpression技术,我们可以实现joinondemand的场景。如下图所示:Joinondemand是SAPCDS(CoreDataServices)视图的一个重要特性,它允许您在CDS视图中实现延迟连接,从而优化查询性能。通过在需要时执行连接操作,而不是在每次查询时都执行连接,可以减......
  • 关于 SAP ABAP 锁机制的一些疑问和解答
    Locktable的位置LockTable位于EnqueueServer的主内存(共享内存)中。如果enqueue服务器作为enqueue工作进程安装,则该实例的所有工作进程都可以访问锁表。外部应用服务器在enqueue服务器上的入队过程中执行其锁定操作。二者的通信,通过相关调度程序(dispatcher)和消息......