Wednesday, 22 June 2011

Enhancement example

Purchase Req. Header Long Text using Badi - ME_PROCESS_REQ_CUST

Purchase Requisition Header Long Text using Badi - ME_PROCESS_REQ_CUST.

Link to Content's target Space :

http://wiki.sdn.sap.com/wiki/display/ABAP/ABAP+Development+and+Programming.

Applies to:

Sample code developed in ECC 5.0

Summary

This post narrates the use of BADI - ME_PROCESS_REQ_CUST, Method - PROCESS_HEADER for populating Purchase Requisition Header Text.

Author(s):  Rajeshvadde

 
Company:     Mourisoft
Created on:    22.06.2011

Processing Steps.


* 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

01.METHOD if_ex_me_process_req_cust~process_header.
02.*    SET purchase requisition text
03.*    text object : ebanh (customer order header texts)
04.*    text id : b01       (header note)
05. 
06.DATA : lt_textlines TYPE mmpur_t_textlines,
07.ls_textlines TYPE mmpur_textlines.
08. 
09.DATA : lv_obj       TYPE REF TO object,
10.lv_attr      TYPE string,
11.lv_trtyp     TYPE trtyp.
12. 
13.FIELD-SYMBOLS: <fs_lcl> TYPE ANY.
14. 
15.** Get transaction State 'H' - New **
16.lv_obj ?= im_header.
17.MOVE 'MY_STATE->TRTYP' TO lv_attr.
18.ASSIGN lv_obj->(lv_attr) TO <fs_lcl>.
19.lv_trtyp = <fs_lcl>.
20. 
21.IF lv_trtyp EQ 'H'.   "New Purchase Requisition"
22.REFRESH : lt_textlines.
23.CLEAR   : ls_textlines.
24.MOVE 'EBANH' TO ls_textlines-tdobject.
25.MOVE 'B01'   TO ls_textlines-tdid.
26.MOVE '*'     TO ls_textlines-tdformat.
27.MOVE 'Test Header Note - Line 1' TO ls_textlines-tdline.
28.APPEND ls_textlines TO lt_textlines.
29. 
30.MOVE 'EBANH' TO ls_textlines-tdobject.
31.MOVE 'B01'   TO ls_textlines-tdid.
32.MOVE '*'     TO ls_textlines-tdformat.
33.MOVE 'Test Header Note - Line 2' TO ls_textlines-tdline.
34.APPEND ls_textlines TO lt_textlines.
35. 
36.* Call method to Update header text **
37.* im_count is be checked, otherwise this method will be
38.* called again after calling below method.
39.IF im_count LE 1.
40.CALL METHOD im_header->if_longtexts_mm~set_text(
41.EXPORTING
42.im_tdid      = 'B01'
43.im_textlines = lt_textlines ).
44.ENDIF.
45.ENDIF.
46.ENDMETHOD.

2 comments:

  1. Dear Rajesh Vadde,

    I want to create new text ID for Purchase Requisition header. I used tcode SE75 to add new text ID to text object EBANH, for example ID = ZB02, and content = Other Note. So on header of Purchase Requisition, text ID "Other Note" appears, but i cannot processing data on this text editor note. Can you show me how to implement it.

    Thanks and regards!
    Longnd.

    ReplyDelete
  2. Sen varya adamın dibisin dibi !

    ReplyDelete