Monday, June 3, 2024

VF02 Header Level Enhancement

 We want to save the waybill details in our header data of an invoice. So we can create a tab (tabstrip) with our specified name at the header level. The approach is that we need to create two fields of waybill number & date which will be saved when we click on the save button at VF02 or VF01.


Following are the steps by which we can conclude:
1.       Create two custom fields at VBRK table since we want to add details at header level. In our example we have created YY_WAYBIL (char20) & YY_WB_DATE (date field).


Give the Append name and save it in a package & TR. In our case we have created ZVF02_ENH. Enter the fields required and then save->check->activate.



2.       Our next approach is to create a sub screen which will be populated at a new tab at VF02 header. To achieve this create a program (ZENH_VF02) in SE38 and then go to SE51. Enter the program name and screen 0001 and create. Since we are entering this screen into the TAB of invoice header, mention SUBSCREEN is mandatory.




3.       Now create the LAYOUT as follows. Here we can go to dictionary button and then select the created custom fields (input fields).


4.       After designing the screen create the required modules of PBO & PAI and then activate the program.
5.       Now we have to create the TAB into the header of invoice. To achieve this go to VF02 t-code and then enter a valid number. Go to System->program name and the go to the program SAPMV60A for this case of VF02. Go to screen 6001 and then go to a specific module (CUST_HEAD_ACTIVATE). Now there is a subroutine (CUST_HEAD_ACTIVATE). Go there and then we need to create implicit enhancement point to activate the custom TAB.


6.       Click on the coin button to see the enhancement section and then go to edit->enhancement operation->show implicit enhancement option. Now in the screen we can the sign of “”””””” where we can create by right click->enhancement operation->create implementation.
7.       In our case we have created the TAB head name WAYBILL, mention the program name which has been created for the sub screen and screen number. Here the screen name will be (TABSTRIP_TAB06).
8.       The mentioned code will have to be entered into the implicit enhancement point.

LOOP AT SCREEN.
  
IF screen-name 'TABSTRIP_TAB06'.
    gs_cust_tab
-head_caption 'Waybill'.
    gs_cust_tab
-head_program 'ZENH_VF02'.
    gs_cust_tab
-head_dynpro '0001'.

    
IF gs_cust_tab-head_dynpro IS NOT INITIAL.
      
screen-active 1.
      
screen-invisible 0.
      
MODIFY SCREEN.
      tabstrip_tab06 
gs_cust_tab-head_caption.
    
ENDIF.
  
ENDIF.
ENDLOOP.

9.       Activate the enhancement and then go to VF02 header details.












10.   When we click on the Waybill TAB then it will be like this. If date field is blank then it will be populated with current date. Now we have to enter the waybill number and the save this invoice document.
11.   After saving this we can see in again in VF02 & VF03. When we use VF03 then the input will be disabled.



We can add our specific logic inside the modules as follows:

=========================================================
PROCESS BEFORE OUTPUT.
  MODULE status_0001.

PROCESS AFTER INPUT.
  MODULE user_command_0001.
=========================================================
MODULE status_0001 OUTPUT.

  IF sy-tcode 'VF01' OR
     sy-tcode 'VF02'.
    IF sy-ucomm 'KFCU'.
      PERFORM display_waybill.
    ENDIF.
  ENDIF.

  IF sy-tcode 'VF03'.
    PERFORM vf03_enhancement.
  ENDIF.

ENDMODULE.
=========================================================
FORM display_waybill .

  IF vbrk-yy_wb_date IS INITIAL.
    vbrk-yy_wb_date sy-datum.
  ENDIF.

ENDFORM.

FORM vf03_enhancement .

  LOOP AT SCREEN.
    IF screen-name CP '*VBRK-YY_*'.
      screen-input 0.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.

ENDFORM.

=========================================================
MODULE user_command_0001 INPUT.

  IF sy-ucomm 'SICH'.
""We can add our custom logic when it will be SAVED
  ENDIF.

ENDMODULE.

source: 


No comments:

Post a Comment