SAP ABAP - Adopt Purchase Requisition Header Note to Purchase Order Header Text
Adopt purchase requisition header note to purchase order header text when creating purchase order with purchase requisition reference using BADI ME_PROCESS_PO_CUST
Copy this source code to Method : IF_EX_ME_PROCESS_PO_CUST~PROCESS_ITEM
DATA : LS_MEPOITEM TYPE MEPOITEM.
DATA : L_HEADER TYPE REF TO IF_PURCHASE_ORDER_MM,
LS_HEADER TYPE MEPOHEADER.
DATA : IM_TDID TYPE TDID,
IM_TEXTLINES TYPE MMPUR_T_TEXTLINES,
MMPUR_TEXTLINES TYPE MMPUR_TEXTLINES,
LT_LINES TYPE TABLE OF TLINE,
LS_LINES TYPE TLINE,
LV_TDNAME TYPE THEAD-TDNAME.
LS_HEADER TYPE MEPOHEADER.
DATA : IM_TDID TYPE TDID,
IM_TEXTLINES TYPE MMPUR_T_TEXTLINES,
MMPUR_TEXTLINES TYPE MMPUR_TEXTLINES,
LT_LINES TYPE TABLE OF TLINE,
LS_LINES TYPE TLINE,
LV_TDNAME TYPE THEAD-TDNAME.
LS_MEPOITEM = IM_ITEM->GET_DATA( ).
CALL METHOD IM_ITEM->GET_HEADER
RECEIVING
RE_HEADER = L_HEADER.
CALL METHOD L_HEADER->GET_DATA
RECEIVING
RE_DATA = LS_HEADER.
"Get Purchase Order Header Note
IF LS_MEPOITEM-BANFN IS NOT INITIAL AND SY-TCODE = 'ME21N'.
CLEAR : LV_TDNAME, LS_LINES, IM_TEXTLINES.
REFRESH LT_LINES.
LV_TDNAME = LS_MEPOITEM-BANFN.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = 'B01'
LANGUAGE = SY-LANGU
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.
LOOP AT LT_LINES INTO LS_LINES.
CLEAR MMPUR_TEXTLINES.
MMPUR_TEXTLINES-TDID = 'F01'.
MMPUR_TEXTLINES-TDOBJECT = 'EKKO'.
MMPUR_TEXTLINES-TDFORMAT = LS_LINES-TDFORMAT.
MMPUR_TEXTLINES-TDLINE = LS_LINES-TDLINE.
APPEND MMPUR_TEXTLINES TO IM_TEXTLINES.
CLEAR LS_LINES.
ENDLOOP.
ENDIF.
IM_TDID = 'F01'.
CALL METHOD L_HEADER->IF_LONGTEXTS_MM~SET_TEXT(
EXPORTING
IM_TDID = IM_TDID
IM_TEXTLINES = IM_TEXTLINES ).
ENDIF.
Comments
Post a Comment