2013 Jul 09 3:55 PM
Hi,
I'm required to filter the search help values based on certain parameters. I previously made the search help which would obtain all the records in associated in the table for the search help. However, it is required to filter the records that are displayed.
For example, I have the following records in a database...
A, 2013
B, 2013
C, 2012
D, 2011
I want to be able to only display in the search help records A and B, if the user inputs a value (2013) in a selection obligatory parameter before the user clicks the search help.
Please let me know if any additional information is needed. Thank you in advance
2013 Jul 10 7:46 AM
That can be easily acheived.
In the below code, there are selection screen parameters, document no and year, ztable is the dictionary table from which it fetches values.
If there is no input for year selection screen field, on clicking F4 for belnr, it will return all the document numbers.
If some year has been entered, then it will only return those document number valid in the inputted year.
DATA: it_ret TYPE ddshretval OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF value_tab OCCURS 0,
YEAR TYPE GJAHR,
BELNR TYPE BELNR,
END OF value_tab.
select-options:
s_year for ztable-year NO INTERVALS NO-EXTENSION,,
s_belnr for ztable-belnr NO INTERVALS NO-EXTENSION,.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_belnr-low.
CLEAR it_ret.
if s_year is initial.
SELECT year belnr FROM ztable INTO CORRESPONDING FIELDS OF TABLE value_tab .
else
SELECT year belnr FROM ztable INTO CORRESPONDING FIELDS OF TABLE value_tab where year in s_year.
endif .
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'BELNR' field name in your value tab
value_org = 'S'
TABLES
value_tab = value_tab[]
return_tab = it_ret[].
IF sy-subrc EQ 0.
READ TABLE it_ret INDEX 1.
s_belnr-low = it_ret-fieldval.
ENDIF.
Kindly revert in case of any doubt..
That can be easily acheived.
In the below code, there are selection screen parameters, document no and year, ztable is the dictionary table from which it fetches values.
If there is no input for year selection screen field, on clicking F4 for belnr, it will return all the document numbers.
If some year has been entered, then it will only return those document number valid in the inputted year.
DATA: it_ret TYPE ddshretval OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF value_tab OCCURS 0,
YEAR TYPE GJAHR,
BELNR TYPE BELNR,
END OF value_tab.
select-options:
s_year for ztable-year NO INTERVALS NO-EXTENSION,,
s_belnr for ztable-belnr NO INTERVALS NO-EXTENSION,.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_belnr-low.
CLEAR it_ret.
if s_year is initial.
SELECT year belnr FROM ztable INTO CORRESPONDING FIELDS OF TABLE value_tab .
else
SELECT year belnr FROM ztable INTO CORRESPONDING FIELDS OF TABLE value_tab where year in s_year.
endif .
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'BELNR' field name in your value tab
value_org = 'S'
TABLES
value_tab = value_tab[]
return_tab = it_ret[].
IF sy-subrc EQ 0.
READ TABLE it_ret INDEX 1.
s_belnr-low = it_ret-fieldval.
ENDIF.
Kindly revert in case of any doubt..
2013 Jul 10 7:45 AM
Hi Victoria,
If you have created a new search help you can set the Import parameter for the Year.
In the definition there is an option Dialog Behavior
The search help will filter it automatically.
2013 Jul 10 7:46 AM
That can be easily acheived.
In the below code, there are selection screen parameters, document no and year, ztable is the dictionary table from which it fetches values.
If there is no input for year selection screen field, on clicking F4 for belnr, it will return all the document numbers.
If some year has been entered, then it will only return those document number valid in the inputted year.
DATA: it_ret TYPE ddshretval OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF value_tab OCCURS 0,
YEAR TYPE GJAHR,
BELNR TYPE BELNR,
END OF value_tab.
select-options:
s_year for ztable-year NO INTERVALS NO-EXTENSION,,
s_belnr for ztable-belnr NO INTERVALS NO-EXTENSION,.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_belnr-low.
CLEAR it_ret.
if s_year is initial.
SELECT year belnr FROM ztable INTO CORRESPONDING FIELDS OF TABLE value_tab .
else
SELECT year belnr FROM ztable INTO CORRESPONDING FIELDS OF TABLE value_tab where year in s_year.
endif .
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'BELNR' field name in your value tab
value_org = 'S'
TABLES
value_tab = value_tab[]
return_tab = it_ret[].
IF sy-subrc EQ 0.
READ TABLE it_ret INDEX 1.
s_belnr-low = it_ret-fieldval.
ENDIF.
Kindly revert in case of any doubt..
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |