Add New Tab to BP

Step by step explanation of how to add a new tab to BP screen.

  • Add new fields to standard structure incl_eew_kna1. incl_eew_kna1 is included in KNA1. Fields will be in KNA1 automatically.

            

  • Add same fields to incl_eew_kna1_x. Make sure that data element must be char1 for ex. bapiupdate. 
  • Create a Z function group. IN top include define varibles:

          

TABLES:
  kna1.

constants:
  table_name_kna1     type fsbp_table_name    value 'KNA1',
  false               type boole-boole        value ' '.

DATA:
  gs_kna1 TYPE kna1.
  1. Create a new screen in function group.
  2. IN PBO of sceen call function ‘BUS_PBO’ and in PAI call BUS_PAI. 
  3. MODULE status_9001 OUTPUT.
      CALL FUNCTION 'BUS_PBO'.
    ENDMODULE.
    
    user_command_9001 INPUT.
      CALL FUNCTION 'BUS_PAI'.
    ENDMODULE.

     

  4. In screen layout press F6.Get KNA1-Z fields to the screen. Activate the screen and function group.

Lets begin to customizing.

  • Go to BUPT t-code. 

           

  • Create a new application named ‘ZKNA’ with New Entries button. Bussiness Partner->Control->Applications. Define a description and active is selected. 

           

  • Create a new dataset named ‘ZKNA01’ New Entries button. Bussiness Partner->Control->Data Sets.  
  • Create a new field group named 601 New Entries button. Bussiness Partner->Control->Screen Layout->Field Groups.  Set a description and save. 

           

  • Assign fields to fields group. Table and field name should be added on screen that is created in Z function group. 
  • Create a new view named ZKNA01 New Entries button. Bussiness Partner->Control->Screen Layout->Views. Set a description.Set Application we created before, same as Data Set. Set program name and screen number. Save the view. Double click on View -> Field Groups. Set field group number we created. Now we should set fm names for before output and after entry. 
  • Create a fm for before output named zsd_kna1_pbo. Copy ‘CVIC_BUPA_PBO_CVIC03’. Assign fm to Z function group.
function ZSD_KNA1_PBO.
*"--------------------------------------------------------------------
*"*"Local Interface:
*"--------------------------------------------------------------------
  data:
    lt_kna1   type table of kna1,
    lt_knas   type table of knas.

* step 1: request data from xo for dynpro structure
  cvi_bdt_adapter=>data_pbo(
    exporting
      i_table_name = table_name_kna1
    importing
      e_data_table = lt_kna1[]
  ).
  if lt_kna1[] is initial.
    clear gs_kna1.
  else.
    read table lt_kna1 into gs_kna1 index 1.
  endif.

endfunction.
  • Create a fm for after entry named zsd_kna1_pai. Copy ‘CVIC_BUPA_PAI_CVIC03’. Assign fm to Z function group.change     
function ZSD_KNA1_PAI.
*"--------------------------------------------------------------------
*"*"Local Interface:
*"--------------------------------------------------------------------
  data:
    lt_kna1         type table of kna1.
  field-symbols:
    <kna1>          like line of lt_kna1.

  check cvi_bdt_adapter=>is_direct_input_active( ) = false.
* step 1: update xo memory from dypro structure
  cvi_bdt_adapter=>get_current_bp_data(
    exporting
      i_table_name = table_name_kna1
    importing
      e_data_table = lt_kna1[]
  ).

  if lt_kna1[] is initial.
    if gs_kna1 is not initial.
      gs_kna1-kunnr = cvi_bdt_adapter=>get_current_customer( ).
      append gs_kna1 to lt_kna1.
    endif.
  else.
    read table lt_kna1 assigning <kna1> index 1.
    <kna1>-zz_field1 = gs_kna1-zz_field1.
  endif.

  cvi_bdt_adapter=>data_pai(
    i_table_name = table_name_kna1
    i_data_new   = lt_kna1[]
    i_validate   = false
  ).

endfunction.

Set these fm’s to view by Bussiness Partner->Control->Screen Layout->Views.  

  • Create a new section named ZKNA1 New Entries button. Bussiness Partner->Control->Screen Layout->Sections. Set a description and title. 

            

  • Select the section we created and double click on Section -> Views. Set item number and view name we created. Save changes. 
  • Create a new screen named ZKNA1 New Entries button. Bussiness Partner->Control->Screen Layout->Screens. Set a description and screen title. Save changes. 
  • Select the screen we created and double click on Screen -> Sections. Set first item section as BUP009 and second number will be section we created. Save changes. 
  • Create a new screen sequence named ZKNA1 New Entries button. Bussiness Partner->Control->Screen Sequenes. Set a description and save changes. 
  • Select the screen seq. we created and double click on Screen Sequence -> Screens. Set item number as screen name that we created. Save changes. 

            

  • Double click on Screen Sequence Categories. Create a new category named ZKNA1 New Entries button. Divisibility is selected. 
  • Select the screen seq. cat. we created and double click on Screen Sequence Category -> Screens Sequence. Set screen seq that we created. Standard is selected. Save changes. 
  • Go back to screen sequences. Select BUP001 and double click on Screen Sequence -> Screens. Set item number like 9000000 and set screen we created. Save changes. 
  • In my example I will create a new tab in FI Customer role(FLCU00).  Go to Bussiness Partner->Control->Divisibility->BP Views.
  • Select FLCU00. Assing Data Sets with BP View -> Data Sets. Set Data Set name we created. Save changes.  
  • Double click BP View -> Calling Applications. Set Application we created..Save changes. 

Now we can see additional tab in BP under FLCU00. Events must be defined for this app.

  •  Go to Bussiness Partner->Control->Events->Bussiness Data Toolset. To set first data we should use ISDAT event. Select ISDAT and double click on Events -> Function Modules. Here we should create a new function in the same fg.  ZSD_KNA1_EVENT_ISDAT. Set Call as ‘X’. And set app name. Save changes.
FUNCTION zsd_kna_event_isdat.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"----------------------------------------------------------------------

  CALL FUNCTION 'CVIC_BUPA_KNA1_GET'
    IMPORTING
      e_kna1 = gs_kna1.

  kna1-zz_field1 = gs_kna1-zz_field1.

ENDFUNCTION.

 

  1. Turn back to Events. Now we should check if anything is changed in the screen with XCHNG event. Double click on fms. Here we should create a new function in the same fg.  ZSD_KNA1_EVENT_XCHNG. Set Call as ‘X’. And set app name. Save changes. 
    FUNCTION zsd_kna_event_xchng.
    *"----------------------------------------------------------------------
    *"*"Local Interface:
    *"  EXPORTING
    *"     REFERENCE(E_XCHNG) TYPE  BOOLE_D
    *"----------------------------------------------------------------------
    
      IF gs_kna1-zz_field1 NE kna1-zz_field1.
        e_xchng = 'X'.
      ENDIF.
    
    ENDFUNCTION.
     
  2. Turn back to Events. Now we should set changed values with DSAVB event. Double click on fms. Here we should create a new function in the same fg.  ZSD_KNA1_EVENT_DSAVB. Z Structure is created with Z fields. Set Call as ‘X’. And set app name. Save changes.
  3. FUNCTION zsd_kna_event_dsavb.
    *"--------------------------------------------------------------------
    *"*"Local Interface:
    *"--------------------------------------------------------------------
    
      DATA : ls_kna1 TYPE kna1.
      ls_kna1 = kna1.
      MOVE-CORRESPONDING gs_kna1 TO kna1.
      kna1-zz_field1 = ls_kna1-zz_field1.
    
    
      CALL FUNCTION 'CVIC_BUPA_KNA1_COLLECT'
        EXPORTING
          i_subname = 'ZSD_KNA1_S001'
          i_kna1    = kna1.
    
    ENDFUNCTION.
                                                    

Now everything looks fine. Lets test it.

             

Now we can get current value and change it. With the same solution we can display/update fields in LFA1, KNB1 etc. We only need to find the right fm's for them.  Hopefully it will be useful for you.

ABOUT Ekrem Güngörmez

https://tr.linkedin.com/in/ekremgungormez

RELATED POSTS

COMMENTS

comments powered by Disqus