Hi All,
I need to save text in PO during PO creation. I am using the BADI ME_PROCESS_PO_CUST method:PROCESS_ITEM. My EBELN is blank here. I do have other required fields like text id, text name to use in SAVE_TEXT.
Text needs to be saved before the PO is saved.. User can edit the text. So BADI during PO save is not an option.
How do i save the text in my PO header during creation and during the line item is entered?
Do have any other procedure to add the text in the text editor?
This is my code:
Please suggest, if we have any alternate procedure to show the text in PO.
METHOD if_ex_me_process_po_cust~process_item.
DATA : ls_mepoitem TYPE mepoitem,
ls_mepoaccount TYPE purchase_order_accountings,
ls_mepoacc TYPE purchase_order_accounting,
ls_mepoaccountdata TYPE mepoaccounting,
ls_mepoheader TYPE REF TO if_purchase_order_mm,
ls_mepoheaderdata TYPE mepoheader.
DATA: gt_lines TYPE STANDARD TABLE OF tline,
gwa_line TYPE tline,
g_tdname TYPE thead-tdname,
g_poname TYPE thead-tdname.
DATA: header TYPE STANDARD TABLE OF thead,
wa_header TYPE thead.
DATA: lines TYPE STANDARD TABLE OF tline.
CONSTANTS : gc_z056(4) TYPE c VALUE 'Z056',
gc_f06(4) TYPE c VALUE 'F06',
gc_ekko(4) TYPE c VALUE 'EKKO'.
ls_mepoheader = im_item->get_header( ).
ls_mepoheaderdata = ls_mepoheader->get_data( ).
ls_mepoitem = im_item->get_data( ). "Table
ls_mepoaccount = im_item->get_accountings( ). "Table
LOOP AT ls_mepoaccount INTO ls_mepoacc.
CLEAR ls_mepoaccountdata.
* Get the newly updated PO item data
CALL METHOD ls_mepoacc-accounting->get_data
RECEIVING
re_data = ls_mepoaccountdata.
ENDLOOP.
IF ls_mepoheaderdata-bstyp = 'F' AND ls_mepoitem-knttp = 'M'
AND ls_mepoitem-matnr <> ' ' AND
( ( ls_mepoheaderdata-bsart = 'UB' OR ls_mepoheaderdata-bsart = 'NB' ) AND ls_mepoheaderdata-lifnr <> ' ' ).
REFRESH gt_lines.
g_tdname = ls_mepoaccountdata-vbeln.
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = gc_z056
language = sy-langu
name = g_tdname
object = 'VBBK'
TABLES
lines = gt_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 IS INITIAL.
DELETE gt_lines WHERE tdline = space.
ENDIF.
* g_poname = ls_mepoitem-ebeln. *"ls_mepoitem-ebeln is blank here*
wa_header-tdobject = gc_ekko.
wa_header-tdname = g_poname.
wa_header-tdid = gc_f06.
APPEND wa_header TO header.
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
client = sy-mandt
header = header
insert = 'X'
savemode_direct = 'X'
TABLES
lines = gt_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.
ENDIF.
ENDIF.
Thanks,
Senthil.
Edited by: senthil kumar on Jun 11, 2009 3:02 PM