An excellent usage of FIELD-SYMBOL

原创 2007年10月04日 19:49:00

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.

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

Quota Project: An effective way to manage the usage of your Swift-based storage cloud

Quota Project: An effective way to manage the usage of your Swift-based storage cloud During the ...

OGNL, JSTL, STRUTS2 symbol #,$,% tag usage examples

最近用OGNL,JSTL,STRUTS2标签用的有些晕。遂想着认真对比学习下,免得总玩混淆啥的。故做此整理备忘。   Take the value of Session ...

Field Symbol使用总结

Field-Symbols(以下简称FS)大致类似于C语言里的指针,主要作用是程序更加灵活,有时可以实现一般无法实现的功能(比如之前那篇关于动态内表的),合理使用FS还可以提高程序效率,但是FS也有缺...
  • Raffin
  • Raffin
  • 2013-11-09 00:42
  • 3198
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)