Wednesday, 13 April 2016

BADI: Add Item Custom Fields Tab in VL01N,VL02N,VL03N ( Delivery )

BADI : LE_SHP_TAB_CUST_ITEM
Table  : LIPS
Append Structure Demo:

LIPS:
BADI Implementation:

T-Code : SE18
Select the menu Enhancement Implementation->Create 

Double click the method and start writing code like below.
        method if_ex_le_shp_tab_cust_item~activate_tab_page.

             ef_caption text-000.                                                     "Tab Description
            ef_program 'SAPLZSDVL01_ITEM'."                    "Program Name
            ef_position 4.                                                                "Tab Position                             
           ef_dynpro  '9000'.                                                        " Sub Screen Number
           cs_v50agl_cust 'X'.

        endmethod.


Result:








BADI: Add Header Custom Fields Tab in VL01N,VL02N,VL03N ( Delivery )

BADI     : LE_SHP_TAB_CUST_HEAD
Table      : LIKP

Add filed in LIKP Table: 

BADI Implementation:

Select the menu Enhancement Implementation->Create 
Enter the enhancement name and press enter

Double click the method and start writing code like below.


method if_ex_le_shp_tab_cust_head~activate_tab_page.

    ef_caption text-100"Container Details                      "Tab Description
    ef_position 5.                                                                  "Tab Display Position
    ef_program 'ZDPL_CUS_TAB_DELIVERY'.           "Program Name 
    ef_dynpro  '9000'.                                                          "SubScreen Number
    cs_v50agl_cust 'X'.

endmethod.





Sub screen Details:

Result:






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 .











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

BADI                                                :  BADI_SLS_HEAD_SCR_CUS
Add field in following Table          :  VBAK
Add field in following structures :  (used for extension and Communication structure)
           BAPE_VBAK, BAPE_VBAKX, VBAKKOZ, VBAKKOZX

VBAK: 


BADI Implementation:

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


Expand BADI_SLS_HEAD_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_head_scr_cus~activate_tab_page.
  
data:ls_head_tab like line of ct_cus_head_tab.

    ls_head_tab
-head_caption 'DPL Custom Fields'.        “Tab Description
    ls_head_tab
-head_program 'ZDPL_CUS_TAB_SALES_ORDER'. “Program name
    ls_head_tab
-head_dynpro '9000'.                      “Sub Screen Name
    
append ls_head_tab to ct_cus_head_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_VBAK:

VBAKKOZ:

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

VBAKKOZX:
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_vbak  type bape_vbak ,
     bape_vbakx 
type bape_vbakx .
data: extensionin type table of bapiparex with header line.
  bape_vbak-vbeln        vbeln.  “For creation make it blank (vbeln)
  bape_vbak
-posnr        posnr .
  bape_vbak
-zzpo_number  ponum .
  bape_vbak
-zzgrpid      grpid .

  bape_vbakx
-vbeln       vbeln.  “For creation make it blank (vbeln)
  bape_vbakx
-posnr       posnr.
  bape_vbakx
-zzpo_number 'X' .
  bape_vbakx
-zzgrpid     'X' .

  
move 'BAPE_VBAK' to extensionin-structure.

  
call method cl_abap_container_utilities=>fill_container_c
    
exporting
      im_value     
i_bape_vbak
    
importing
      ex_container 
extensionin-valuepart1.
  
append extensionin to extensionin.
 
  move 'BAPE_VBAKX' to extensionin-structure.
  
move bape_vbakx to extensionin-valuepart1.
  
append extensionin to extensionin .