以前已經用badi實現了 po header text的copyide
還有一種方法,exit測試
查找對應的出口spa
查看對應的Function 及include,能夠看看輸入參數,看看哪些值能夠用到
添加測試代碼
3d
爲方便管理和維護,也爲了裏面別太亂,我把代碼封到一個include裏面,blog
其實建議是用Function,直接copy EXIT_SAPMM06E_012 或者本身建一個。圖片
Function 裏面,你用check 用return都只是退出Function,Function以外的不受影響。it
可是若是你用include ,在include裏面若是return了,include後面若是有別的代碼,也就不執行了。io
真出了bug的時候比較麻煩class
參考代碼cli
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纔會生成,點保存的時候纔會走那個出口。