1. 程式人生 > >BADI Purchase Requisition Header Long Text using Badi ME

BADI Purchase Requisition Header Long Text using Badi ME

               

* Create Implementation for BADI using Transaction code SE19

  • Click on Method - PROCESS_HEADER
  • Check the Process mode using the LOCAL class parameter TRTYP
  • Populate the Text only if TRTYP is eqal to H (Creation)
  • Use the interface method IF_LONGTEXTS_MM~SET_TEXT of importing parameter IM_HEADER to create long text.
  • Use Text Object EBANH, Text ID B01 as parameters for above step.

Purchase Requisition Screen

Sample Code

METHOD if_ex_me_process_req_cust~process_header. *    SET purchase requisition text *    text object : ebanh (customer order header texts) *    text id : b01       (header note) DATA : lt_textlines TYPE mmpur_t_textlines,        ls_textlines TYPE mmpur_textlines. DATA : lv_obj       TYPE REF TO object,        lv_attr      TYPE string,        lv_trtyp     TYPE trtyp.        FIELD-SYMBOLS: <fs_lcl> TYPE ANY. ** Get transaction State 'H' - New **    lv_obj ?= im_header.    MOVE 'MY_STATE->TRTYP' TO lv_attr.    ASSIGN lv_obj->(lv_attr) TO <fs_lcl>.    lv_trtyp = <fs_lcl>.    IF lv_trtyp EQ 'H'.   "New Purchase Requisition"     REFRESH : lt_textlines.      CLEAR   : ls_textlines.      MOVE 'EBANH' TO ls_textlines-tdobject.      MOVE 'B01'   TO ls_textlines-tdid.      MOVE '*'     TO ls_textlines-tdformat.      MOVE 'Test Header Note - Line 1' TO ls_textlines-tdline.      APPEND ls_textlines TO lt_textlines.      MOVE 'EBANH' TO ls_textlines-tdobject.      MOVE 'B01'   TO ls_textlines-tdid.      MOVE '*'     TO ls_textlines-tdformat.      MOVE 'Test Header Note - Line 2' TO ls_textlines-tdline.      APPEND ls_textlines TO lt_textlines. * Call method to Update header text ** * im_count is be checked, otherwise this method will be * called again after calling below method.     IF im_count LE 1.       CALL METHOD im_header->if_longtexts_mm~set_text(         EXPORTING           im_tdid      = 'B01'          im_textlines = lt_textlines ).     ENDIF.   ENDIF. ENDMETHOD.

Source link:http://wiki.sdn.sap.com/wiki/display/stage/Purchase+Req.+Header+Long+Text+using+Badi+-+ME_PROCESS_REQ_CUST