03-18-2010 10:03 PM
I am creating an abap report and have several fields on the selection screen.
I would like to know if it is possible to populate one of the fields according to what I have put in another field.
For example, I have a field for Manager Name and then another field for Employee Name. I would like the user to be able to enter a name in Manager Name and then the possible values for Employee Name are the people that report to this person.
03-19-2010 3:10 AM
Hi SImon,
Please chekc the following.
[Populating one Drop down based on another Dropdown|;
DATA : BEGIN OF f4_tab OCCURS 0,
carrid TYPE sflight-carrid,
connid TYPE sflight-connid,
END OF f4_tab.
CLEAR lin.
" adjust this as per your requirement
DATA : dynpread TYPE TABLE OF dynpread WITH HEADER LINE.
REFRESH dynpread.
CLEAR dynpread.
dynpread-fieldname = 'ITAB-CARRID'.
* dynpread-stepl = lin.
APPEND dynpread.
CLEAR dynpread.
at selection-screen on value-request for YOUR_FIELD " Your Second Field here
CALL FUNCTION 'DYNP_VALUES_READ'
" This FM gives the First field value before u press Enter/ PAI is triggered
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
TABLES
dynpfields = dynpread
EXCEPTIONS
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
invalid_parameter = 7
undefind_error = 8
double_conversion = 9
stepl_not_found = 10
OTHERS = 11
.
IF sy-subrc IS INITIAL.
READ TABLE dynpread WITH KEY fieldname = 'ITAB-CARRID'.
IF sy-subrc IS INITIAL.
SELECT carrid connid FROM sflight
INTO TABLE f4_tab
WHERE carrid = dynpread-fieldvalue.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'CONNID'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'ITAB-CONNID'
value_org = 'S'
TABLES
value_tab = f4_tab
ENDIF.
ENDIF.
Cheer
Ram
03-18-2010 10:49 PM
use the FM 'F4IF_INT_TABLE_VALUE_REQUEST' for value request.
read the manager as entered by the User. use the relation B002 from Manager to employees to find the list of employees whose manager is this person. pull them in one internal table and pass the table in aboev FM. It'll display the employees on the selection screen event ON VALUE-REQUEST FOR <employees>
03-19-2010 3:10 AM
Hi SImon,
Please chekc the following.
[Populating one Drop down based on another Dropdown|;
DATA : BEGIN OF f4_tab OCCURS 0,
carrid TYPE sflight-carrid,
connid TYPE sflight-connid,
END OF f4_tab.
CLEAR lin.
" adjust this as per your requirement
DATA : dynpread TYPE TABLE OF dynpread WITH HEADER LINE.
REFRESH dynpread.
CLEAR dynpread.
dynpread-fieldname = 'ITAB-CARRID'.
* dynpread-stepl = lin.
APPEND dynpread.
CLEAR dynpread.
at selection-screen on value-request for YOUR_FIELD " Your Second Field here
CALL FUNCTION 'DYNP_VALUES_READ'
" This FM gives the First field value before u press Enter/ PAI is triggered
EXPORTING
dyname = sy-repid
dynumb = sy-dynnr
TABLES
dynpfields = dynpread
EXCEPTIONS
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
invalid_parameter = 7
undefind_error = 8
double_conversion = 9
stepl_not_found = 10
OTHERS = 11
.
IF sy-subrc IS INITIAL.
READ TABLE dynpread WITH KEY fieldname = 'ITAB-CARRID'.
IF sy-subrc IS INITIAL.
SELECT carrid connid FROM sflight
INTO TABLE f4_tab
WHERE carrid = dynpread-fieldvalue.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'CONNID'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'ITAB-CONNID'
value_org = 'S'
TABLES
value_tab = f4_tab
ENDIF.
ENDIF.
Cheer
Ram
03-19-2010 3:24 AM
Hi,
Refer to the below link which has code snippet helpful for your requirement.
[Chain F4 help implementation|http://www.divulgesap.com/blog.php?p=Njk=]
Cheers,
Ravi
03-22-2010 5:36 AM