How to Use F4 in ABAP?
When we focus on a field on the SAP interface, press F4 to display the selection or search interface. This is the help of F4 in ABAP.
There are a variety of methods to implement F4 help. Now let's talk a little bit about my guidance:
1, fixed value. We can define the value range in the domain. The value defined in The value range can appear in the F4. This is the simplest way to implement F4 help.
2. Data Type Association. When we define a DATs type parameter on the selection screen, she automatically calls the date type F4.
3. Create F4.
(
When you attach the search help created by SE11 to a table, there are three types:
Use checklists for input help
Field external search help attachment
Clear search help attachment for data elements
I don't know the differences between them. I will try again later.
)
The F4 help created with SE11 can be divided into two types:
Basic Search Help
Centralized search help
Basic Search Help is the smallest unit of search help. Centralized search help can also include centralized search help or Basic Search Help.
You can define the data source in the Basic Search Help, but the centralized search help cannot define the data source.
Both basic and centralized search help include output field definitions, and you can define search help exit to call a remote function module to filter and process data.
If the search help and table are attached, the search help will automatically appear when we use it.
In the synpro program. You can also use the property (the property name is "Search Help") to re-specify the Custom Search Help for the field.
You can also re-specify the search help in the selection screen or screen. The following examples illustrate how to use
1. Specify the search help according to the search help name
1. Select Screen
Report z_ljc_078 line-size 200.
Parameters: Mama (18) type C.
Initialization.
At selection-screen on value-request for Mama.
Data: v_mama like help_info-dynprofld.
V_mama = 'Mama '.
Call function 'f4if _ field_value_request'
Exporting
Tabname =''
Fieldname =''
Searchhelp = 'zfi _ crc_001'
Dynpprog = SY-REPID
Dynpnr = SY-DYNNR
Dynprofield = v_mama
.
Start-of-selection.
Write Mama.
2 dynpro Screen
Stream logic:
Process before output.
Module init.
Process after input.
Process on value-request.
Field matnr module value_matnr.
Report:
Module init output.
Progname = sy-repid.
Dynnum = sy-dynnr.
Endmodule.
Module value_matnr input.
Call function 'f4if _ field_value_request'
Exporting
Tabname =''
Fieldname =''
Searchhelp = 'mat1'
Dynpprog = SY-REPID
Dynpnr = SY-DYNNR
Dynprofield = 'matnr'
Endmodule.
Whether on the selection screen or dynpro, if the searchhelp attribute is specified, the tabname and fieldname attributes do not work.
If the tabname and fieldname attributes are defined without specifying the searchhelp attribute, the search assistant help attached to tabname-fieldname is called.
Call function 'f4if _ field_value_request'
Exporting
Tabname = 'mara'
Fieldname = 'matnr'
* Searchhelp =''
Dynpprog = SY-REPID
Dynpnr = SY-DYNNR
Dynprofield = 'matnr'
Ii. Generate F4 help using an internal table
1. Select Screen
Types: Begin of ty_aenr,
Aennr type aenr-aennr,
Datuv type aenr-datuv,
Aenam type aenr-aenam,
Aegru type aenr-aegru,
Ccart type aenr-ccart,
Aetxt type aenr-aetxt,
End of ty_aenr.
Data: gt_aenr type table of ty_aenr,
Gs_aenr type ty_aenr.
Initialization.
Perform frm_read_aenr.
* Get the F4 help of the Image Frame
At selection-screen on value-request for so_aennr-low.
Perform frm_search_help_file.
Form frm_read_aenr.
Data l_objnr type jest-objnr.
Data l_line type bsvx-sttxt. "order status
Select ~ Aennr ~ Datuv ~ Aenam ~ Aegru ~ Ccart ~ Aetxt
Into Table gt_aenr
From aenr as
Inner join usgrp_user as C
On ~ Annam = C ~ Bname
Where C ~ Usergroup = 'cccar '.
Loop at gt_aenr into gs_aenr.
Clear: l_objnr, l_line.
*** Create and change the ID object number
Concatenate 'CD 'gs_aenr-aennr into l_objnr.
*** Obtain the system status and call the Function
Call function 'status _ text_edit'
Exporting
Objnr = l_objnr
Spras = sy-Langu
Importing
Line = l_line
Exceptions
Object_not_found = 1
Others = 2.
*** Determine whether the change form is approved
If sy-subrc = 0.
Search l_line for 'ecor '.
If sy-subrc <> 0.
Delete gt_aenr. "delete a file if it is not released.
Endif.
Endif.
Endloop.
.
Endform. "frm_read_proj
Form frm_search_help_file.
Data: v_aennr like help_info-dynprofld.
V_aennr = 'so _ aennr '.
Call function 'f4if _ int_table_value_request'
Exporting
Retfield = 'aennr'
Value_org = 'S'
Dynprofield = v_aennr
Dynpprog = sy-repid
Dynpnr = sy-dynnr
Tables
Value_tab = gt_aenr
Exceptions
Parameter_error = 1
No_values_found = 2
Others = 3.
* If sy-subrc <> 0.
* Write: 'error '.
* Endif.
Endform. "frm_search_help_file
2 dynpro screen:
Stream logic:
Process before output.
Module init.
Process after input.
Process on value-request.
Field aenam module value_aenam.
Report:
Types: Begin of values,
Aenam type Mara-aenam,
Matnr type Mara-matnr,
End of values.
Data: matnr (18) type C,
Aenam (12) type C.
Data: progname type sy-repid,
Dynnum type sy-dynnr
.
Call screen 100.
Module init output.
Progname = sy-repid.
Dynnum = sy-dynnr.
Endmodule.
Module value_aenam input.
Select aenam matnr into Table values_tab from Mara where matnr between '000000' and '000000 '.
Call function 'f4if _ int_table_value_request'
Exporting
Retfield = 'aenam'
Dynpprog = progname
Dynpnr = dynnum
Dynprofield = 'aenam'
Value_org = 'S'
Tables
Value_tab = values_tab.
Endmodule.
Of course, you can also filter the F4 help data of another field based on the selection of one field. The following is an example of dynpro screen.
No example is provided on the selection screen. The implementation methods are similar. Or even simpler.
Stream logic:
Process before output.
* Module status_0100.
*
Module init.
Process after input.
* Module user_command_0100.
Module cancel at exit-command.
Process on value-request.
Field matnr module value_matnr.
Field aenam module value_aenam.
Report:
*&
Types: Begin of values,
Aenam type Mara-aenam,
Matnr type Mara-matnr,
End of values.
Data: matnr (18) type C,
Aenam (12) type C.
Data: progname type sy-repid,
Dynnum type sy-dynnr,
Dynpro_values type table of dynpread,
Field_value like line of dynpro_values,
Values_tab type table of values.
Call screen 100.
Module init output.
Progname = sy-repid.
Dynnum = sy-dynnr.
Clear: field_value, dynpro_values.
Field_value-fieldname = 'aenam '.
Append field_value to dynpro_values.
Endmodule.
Module cancel input.
Leave program.
Endmodule.
Module value_aenam input.
Select aenam matnr into Table values_tab from Mara where matnr between '000000' and '000000 '.
Call function 'f4if _ int_table_value_request'
Exporting
Retfield = 'aenam'
Dynpprog = progname
Dynpnr = dynnum
Dynprofield = 'aenam'
Value_org = 'S'
Tables
Value_tab = values_tab.
Endmodule.
Module value_matnr input.
Call function 'dynp _ values_read'
Exporting
Dyname = progname
Dynumb = dynnum
Translate_to_upper = 'X'
Tables
Dynpfields = dynpro_values.
Read Table dynpro_values Index 1 into field_value.
Select aenam matnr
From Mara
Into corresponding fields of table values_tab
Where aenam = field_value-fieldvalue.
Call function 'f4if _ int_table_value_request'
Exporting
Retfield = 'aenam'
Dynpprog = progname
Dynpnr = dynnum
Dynprofield = 'matnr'
Value_org = 'S'
Tables
Value_tab = values_tab.
Endmodule.
Well, I know a little bit about F4. So much.
F4 help has nothing to do with check. It is only used to search data and does not check data!