Pages

Wednesday, 13 April 2016

BADI: Add Item Tab Custom Fields in VA01,VA02,VA03( Sales Order ) with BAPI Extension

BADI                                                :  BADI_SLS_ITEM_SCR_CUS
Add field in following Table          :  VBAP
Add field in following structures :  (used for extension and Communication structure)

           BAPE_VBAP, BAPE_VBAPX, VBAPKOZ, VBAPKOZX
Append Structure Demo:


VBAP:
BADI Implementation:

T-Code : SE18
Enter the BADI name  and click display


Expand BADI_SLS_ITEM_SCR_CUS
Right Click implementation
Below popup will be appeared and click create button.


Enter the enhancement name, description and press enter .
Enter the package name and create the Transport request.

Double click on your enhancement name, below screen will be appeared. Enter the implementation name , description and class name, then press enter or click tick mark.
Below Screen will be appeared 

Expand BADI implementation and double click on implementation class which one highlighted on below screen short.

Double click on methods and start writing on code like below.


method if_ex_sls_item_scr_cus~activate_tab_page.
  data:ls_item_tab like line of ct_cus_item_tab.

    ls_item_tab-item_caption 'Planing Details'.                                             "Tab Description
    ls_item_tab-item_program 'ZDPL_CUS_TAB_SALES_ITEM'.           "Program name
    ls_item_tab-item_dynpro '9100'.                                                               "Subscreen No
    append ls_item_tab to ct_cus_item_tab.

endmethod.




Note:  1. No need to write any code for data transfer.
            2. Screen should be sub screen.
Sub Screen Details:

Result:

Using BAPI to Update the filed:

BAPE_VBAPX:
Note:  Use data element as CHAR1 , don’t use BAPIUPDATE .

 BAPE_VBAP:


 VBAPKOZ:


 VBAPKOZX:

Note:  Use data element as CHAR1 , don’t use BAPIUPDATE .

Extension Structure Code:

While updating custom fields through BAPI, need to use below code.


data: bape_vbap  type bape_vbap ,
     bape_vbapx 
type bape_vbapx .
data: extensionin type table of bapiparex with header line.
  bape_vbap-vbeln    vbeln.      “For creation make it blank (vbeln)
  bape_vbap
-posnr    = posnr.
  bape_vbap
-zzrunno  runno .
  bape_vbap
-zzryear  ryear .

  bape_vbapx
-vbeln   = vbeln.     “For creation make it blank (vbeln)
  bape_vbapx
-posnr   = posnr.
  bape_vbapx
-zzrunno 'X' .
  bape_vbapx
-zzryear 'X' .

  
move 'BAPE_VBAP' to extensionin-structure.

  
call method cl_abap_container_utilities=>fill_container_c
    
exporting
      im_value     
i_bape_vbap
    
importing
      ex_container 
extensionin-valuepart1.
  
append extensionin to extensionin.

  
move 'BAPE_VBAPX' to extensionin-structure.
  
move bape_vbapx to extensionin-valuepart1.
  
append extensionin to extensionin .











5 comments:

  1. is this possible to add in the table control? TCTRL_U_ERF_AUFTRAG

    ReplyDelete
  2. Thank you very much for very interesting tutorial
    Please describe in detail "Extension Structure Code". Where must it be implemented? How to read the order number and the data of additional fields to pass to the structures bape_vbap and bape_vbapx?

    Best regards

    Yuriy
    (ABAP beginners)

    ReplyDelete
  3. Dear Vaigunda raja,

    Good Tutorial with clear explanation, it helped a lot.

    Thanks
    Karthe

    ReplyDelete
  4. Is it possible to add one more tab by using above activity.

    ReplyDelete