(EXIT)Copy PR header text to PO header when ME21N
作者:互联网
之前已经用badi实现了 po header text的copy
还有一种方法,exit
查找对应的出口
查看对应的Function 及include,可以看看输入参数,看看哪些值可以用到
添加测试代码
为方便管理和维护,也为了里面别太乱,我把代码封到一个include里面,
其实建议是用Function,直接copy EXIT_SAPMM06E_012 或者自己建一个。
Function 里面,你用check 用return都只是退出Function,Function之外的不受影响。
但是如果你用include ,在include里面如果return了,include后面如果有别的代码,也就不执行了。
真出了bug的时候比较麻烦
参考代码
DATA : lt_tekpo TYPE TABLE OF bekpo,
ls_tekpo TYPE bekpo,
lt_lines TYPE TABLE OF tline,
lv_tdname TYPE thead-tdname,
ls_header TYPE thead.
DATA: lv_spras TYPE thead-tdspras.
lt_tekpo[] = tekpo[].
LOOP AT lt_tekpo INTO ls_tekpo.
"for header level
lv_tdname = ls_tekpo-banfn.
SELECT SINGLE spras INTO lv_spras FROM eban WHERE banfn = ls_tekpo-banfn.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = 'B01'
language = lv_spras
name = lv_tdname
object = 'EBANH'
TABLES
lines = lt_lines
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ls_header-tdobject = 'EKKO'.
ls_header-tdid = 'F02'.
ls_header-tdspras = i_ekko-spras.
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
client = sy-mandt
header = ls_header
insert = 'X'
TABLES
lines = lt_lines
EXCEPTIONS
id = 1
language = 2
name = 3
object = 4
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDLOOP.
这里特别指出是一点是:
点击copy PR的时候,header text不会直接过来
只有点保存后,text才会生成,点保存的时候才会走那个出口。
标签:PR,sy,ME21N,lv,header,ls,tekpo,TYPE 来源: https://blog.51cto.com/15057820/2628641