SAP 允许我们使用SE11创建search help,search help应用广泛。
这里探讨一下search help中那几个参数的含义:
IMP: 设置了这个标志位,意味着search help在处理数据时会参考屏幕中field输入的值
EXP: 设置了这个标志位,意味着用户选择的search help list的某一行的对应的列值将填充到屏幕上对应field中去
LPOS: 这个值标示该parameter在search help list中的第几列
SPOS:这个值标示该parameter在search help list上面的选择限制对话框的次序
SDIS:设置了这个标志位,意味这该parameter在search help list上面的对话框不可输入
MODIFIED: 设置了这个标志位,允许用户输入其他data element
DEFAULT VALUE: 这个用来设置该parameter的默认值,这个默认值要生效,有一定条件,请读者F1看看。
英文版:
IMP - Import values from the screen/field to the search help
EXP - Export value back to the input field(s)
LPOS - Position on the output list the user selects from
SPOS - Position on the selection screen if your search help to have select options which the user can enter to restrict further the search help value list by.
Default - Add a default value the field is populated with
Step1 - Create Search help
Execute transaction SE11 and create a new search help called 'ZSHELP'. Please note this can be anything starting with Z that fits in the box but in some older SAP systems must be less than 5 characters long to be used as matchcode)
Select Elementary search help
Step2 - Enter basic details
Enter a short description and PA0002 into the selection method field, this is basically the table the search help gets it data from
Step3 - Enter search help parameters
The next step is to add the fields that are going to be used by this search help as parameters i.e. those that appear in the output list or selection screen. To do this click the dropdown option of the first search help parameter
Then select the appropriate field from the list (PERNR)
Repeat this for fields NCHMC and VNAMC
Step4 - Save, activate and test
Enter LPos values as follows (3,1,2) and tick the EXP column for the pernr field. This is the field who's value you want to be returned when the user selects an option/row.
Save and activate the search help and press the test button, a screen will appear showing how the search help will appear on a pernr field. Press the search help button at the end of the field
The search help output will now look like this with the fields in the order you specified then in the LPOS field
Step5 - Change output order
Now enter LPos values as follows (1,2,3)
If you save, activate and test the search help again you will see that the output order has changed
Step6 - Add selection options
Now enter 1 and 2 against parameters NCHMC and VNAME within the SPos column
Now if you save, activate and test the search help again you will see that you have the 2 parameters available on the search help to further restrict the value list. You may need to expand the view using the little arrow to see this additional options.
Enter values in the additional parameters and notice how the hit list is restricted
Step7 - Change Dialog behaviour
Just to demonstrate what this option does, ensuring you still have values within the SPos column change the dialog behaviour from 'Display values immediately' to 'Dialog with value restriction'
Now when you test it you should notice that the parameter restriction fields are display before you see the value results list. You could also add defaults to these fields using the default column. This option may be usful if the search help returns lots of values as it gives the user an option to restrict further before the data is retrieved and displayed.
Step 8 -. Assign matchcode to report parameter
If you have created your search help to be matchcode compatible (i.e. less than 5 chars long) you can add the following line of ABAP code into your program:
PARAMETER p_prog LIKE trdir-name MATCHCODE OBJECT zsh.
alternatively see other methods of adding a search help
那么建立好的search help到底用在哪些地方呢?
1,当customzied屏幕上的多个field构成一个相对统一的结构时,我们通常会在ABAP DICT里面创建一个对应的结构和该结构对应的search help,这样会有一种联动的效果。
2,当我们屏幕上的某个单独的field想做一个search help,我们可以创建一个search help并将它assign 给屏幕该field对应的data element。