I have two Drop down lists in module pool programming.
One is GV_FROMEMP and other is GV_TOEMP.
I am populating both programmatically.
My requirement is.
1. GV_TOEMP should be populated by records with respect to the selected value in GV_FROMEMP.
2. Default the GV_TOEMP for the first value in the list
Req.1. is working fine. I have provided the FCODE to GV_FROMEMP and populated the GV_TOEMP accordingly.
Req.2. I am using function module 'VRM_SET_VALUES' for populating the GV_TOEMP drop down list.
Please look at the code below.
DATA: gv_vrmid TYPE vrm_id ,
gt_vrm_values TYPE vrm_values ,
wa_value LIKE LINE OF gt_vrm_values .
LOOP AT lt_tab ASSIGNING <fs_tab>.
wa_value-key = <fs_tab>-pernr.
wa_value-text = <fs_tab>-name.
GV_TOEMP = <fs_tab>-pernr.
INSERT wa_value INTO gt_vrm_values INDEX 1.
IF gt_vrm_values IS NOT INITIAL.
gv_vrmid = 'GV_TOEMP'.
CALL FUNCTION 'VRM_SET_VALUES'
id = gv_vrmid
values = gt_vrm_values.
GV_TOEMP = <fs_pernr>-pernr.
I am using this statement to set the default value in GV_TOEMP.
The above code is inside a method. I am calling this method two times.
1. First time while populating the GV_FROMEMP to make initial data load and set default value
2. Second time when user selects a value in GV_FROMEMP on screen ( using FCODE in PAI)
Problem: It is not working when I am populating the GV_TOEMP for the first time after populating the GV_FROMEMP which has value defaulted initially and I have to fetch the respective values for GV_TOEMP and set the default value.
The same statement is working when I am selecting value in GV_FROMEMP on screen and FCODE triggers the PAI event and the value is defaulted for GV_TOEMP.
I think I am placing the statement at wrong place to default the GV_TOEMP.