【轉載】BP增強 新增自定義螢幕 KNA1 通用資料(英文)
測試通過。
其他參考(中文):https://blog.csdn.net/guangcong2009/article/details/80569877
英文:http://www.saptechnical.com/Tutorials/ExitsBADIs/BP/Page6.htm
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.
Click on images to see with original size.
- Add same fields to incl_eew_kna1_x. Make sure that data element must be char1 for ex. bapiupdate. Click on images to see with original size.
- Create a Z function group. IN top include define varibles:
Click on images to see with original size.
TABLES:
kna1.
constants:
table_name_kna1 type fsbp_table_name value 'KNA1',
false type boole-boole value ' '.
DATA:
gs_kna1 TYPE kna1.
- Create a new screen in function group.
- IN PBO of sceen call function ‘BUS_PBO’ and in PAI call BUS_PAI.
-
MODULE status_9001 OUTPUT. CALL FUNCTION 'BUS_PBO'. ENDMODULE. user_command_9001 INPUT. CALL FUNCTION 'BUS_PAI'. ENDMODULE.
- 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.
Click on images to see with original size.
- Create a new application named ‘ZKNA’ with New Entries button. Bussiness Partner->Control->Applications. Define a description and active is selected.
Click on images to see with original size.
- Create a new dataset named ‘ZKNA01’ New Entries button. Bussiness Partner->Control->Data Sets. Click on images to see with original size.
- Create a new field group named 601 New Entries button. Bussiness Partner->Control->Screen Layout->Field Groups. Set a description and save.
Click on images to see with original size.
- Assign fields to fields group. Table and field name should be added on screen that is created in Z function group. Click on images to see with original size.
- 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. Click on images to see with original size.Click on images to see with original size.
- 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.Click on images to see with original size.
- Create a new section named ZKNA1 New Entries button. Bussiness Partner->Control->Screen Layout->Sections. Set a description and title.
Click on images to see with original size.
- Select the section we created and double click on Section -> Views. Set item number and view name we created. Save changes. Click on images to see with original size.
- Create a new screen named ZKNA1 New Entries button. Bussiness Partner->Control->Screen Layout->Screens. Set a description and screen title. Save changes. Click on images to see with original size.
- 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. Click on images to see with original size.
- Create a new screen sequence named ZKNA1 New Entries button. Bussiness Partner->Control->Screen Sequenes. Set a description and save changes. Click on images to see with original size.
- Select the screen seq. we created and double click on Screen Sequence -> Screens. Set item number as screen name that we created. Save changes.
Click on images to see with original size.
- Double click on Screen Sequence Categories. Create a new category named ZKNA1 New Entries button. Divisibility is selected. Click on images to see with original size.
- 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. Click on images to see with original size.
- 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. Click on images to see with original size.
- 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. Click on images to see with original size. Click on images to see with original size.
- Double click BP View -> Calling Applications. Set Application we created..Save changes. Click on images to see with original size.
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.
Click on images to see with original size.
- 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.
Click on images to see with original size.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.
- 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.
-
Click on images to see with original size. Click on images to see with original size.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.
Click on images to see with original size.
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.