An excellent usage of FIELD-SYMBOL

本文介绍如何使用字段符号技术解决MIRO流程中账单文档的文本增强需求。通过实施BADI AC_DOCUMENT的CHANGE_INITIAL方法,实现了在特定税项业务标识为'T'的情况下将供应商信息写入账单文档项文本。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Simply,we can use field symbol  to identify a specify memory area. Below is the example.

There is a requirement about the enhancement of account document that generated after saving MIRO.The user want to write invice party(Vendor) to the account document item text. Which item-buzid equal 'T' which indicate taxing.

I found the BADI:AC_DOCUMENT to implement this requirement.The method is CHANGE_INITIAL.The exporting parameter of this method is EX_DOCUMENT ,data type is ACC_DOCUMENT_SUBST.So i must use importing parameter IM_DOCUMENT to construct EX_DOCUMENT.But very unluckily,the field PRZNR of ex_document-item-prznr is RAW. And the value will always be '0000'. After executing this BADI ,the field value of prznr of internal table t_accit[]  of calling program is also set to '0000'.The MIRO throw an error message about the definition of BUSSINESS PROCESS.After several hours study i found that the field symbol can achieve my requirement by pass the exporting parameter EX_DOCUMENT.

The method CHANGE_INITIAL OF BADI AC_DOCUMENT is called in FM:AC_DOCMENT_CREATE.
The FM: AC_DOCUMENT_CREATE is called in FM:MRM_INVOICE_POST.
AND the FM:  MRM_INVOICE_POST is called in MIRO when SAVING.

The TABLES parameter T_ACCIT of FM:AC_DOCUMENT_CREATE contain the line items of account document. And this table is transfered from MRM_INVOICE_POST. The correspond global data is XACCIT in program SAPLMRMP.So we can use field symbol to access data XACCIT in program SAPLMRMP.Below is the code.

method IF_EX_AC_DOCUMENT~CHANGE_INITIAL.
  DATA: l_v_lifnr  TYPE LIFNR.
  CHECK SY
-TCODE EQ 'MIRO'.
  FIELD
-SYMBOLS <ft> TYPE ACCIT_T.
  FIELD
-SYMBOLS <fs> TYPE ACCIT.
  DATA: field TYPE CHAR18 VALUE 
'(SAPLMRMP)xaccit[]'.
  ASSIGN (field) TO 
<ft>.
  CHECK SY
-SUBRC EQ 0.
  LOOP AT 
<fT> ASSIGNING <fs>.
    IF SY
-TABIX EQ 1.
      l_v_lifnr 
= <fs>-lifnr.
    ENDIF.
    CHECK 
<fs>-buzid EQ 'T'.
    
<fs>-sgtxt = l_v_lifnr.
  ENDLOOP.
endmethod.

I think this usage of field-symbol is very useful in enhancement.But before using this way to change data , we must check the consistency of the data.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值