2011 Jan 27 2:12 PM
I am trying to change HR infotype screen.
I have added a custom listbox which has 10 entries.
What I want to do is as soon as any entry in the list is chosen by
using the mouse cursor I want to be able to execute some custom code.
At the moment this only happens when I press the 'Enter' Key.
Does anybody know if this event I am trying to capture does exist.
i.e. as soon as an entry in a list box is chosen without the need
to press the enter key
Any help would be much appreciated
Thanks
Andy
2011 Jan 28 5:21 AM
Hi Andy,
You need to set the Function code (FctCode) for the custom list box field during screen design.
For example for the list box field give the value 'SET' in the FctCode.
Write the coding in PAI which is triggered if you select any value in the list box.
MODULE USER_COMMAND_1000 INPUT.
case sy-ucomm.
when 'SET'.
.
.
.
.
endcase.
Regards,
Srini.
2011 Jan 27 2:36 PM
Andy, I think list box is one of the controls that support an OK Code. So, you can write your code under the PAI for your specific OK code for the list box.
2011 Jan 27 8:08 PM
Hi Andy,
Use "USER-COMMAND uc" addition in PARAMETERS statement for your listbox. I am able to display the popup with different messages as soon as user selects a value from the Listbox. There is no need to hit 'Enter' key.
REPORT ytest.
TYPE-POOLS: vrm.
DATA: name TYPE vrm_id,
list TYPE vrm_values,
value LIKE LINE OF list.
PARAMETERS: ps_parm AS LISTBOX VISIBLE LENGTH 10 USER-COMMAND uc.
AT SELECTION-SCREEN OUTPUT.
name = 'PS_PARM'.
value-key = '1'.
value-text = 'LINE 1'.
APPEND value TO list.
value-key = '2'.
value-text = 'LINE 2'.
APPEND value TO list.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = name
values = list.
CLEAR value.
REFRESH list[].
AT SELECTION-SCREEN.
LOOP AT SCREEN.
IF ps_parm EQ '1'.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = 'Test'
txt1 = 'Listbox'
txt2 = '1'.
ELSEIF ps_parm EQ '2'.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = 'Test'
txt1 = 'Listbox'
txt2 = '2'.
ENDIF.
ENDLOOP.
2011 Jan 27 9:17 PM
Hi Scott,
Yes the addition User command should works perfect for you requirment. I used in one of my code and it works with no glitch. I have posted the same for your reference.
SELECTION-SCREEN: SKIP 1.
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: ps_parm AS LISTBOX VISIBLE LENGTH 10 USER-COMMAND U1.
SELECTION-SCREEN: END OF BLOCK b1.
SELECTION-SCREEN: SKIP 1.
SELECTION-SCREEN: BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS: p_rad1 RADIOBUTTON GROUP g1,
p_ipath(132) TYPE c,
p_rad2 RADIOBUTTON GROUP g1,
p_afpath(132) TYPE c DEFAULT '/usr/sap/tmp',
p_apath(150) TYPE c AS LISTBOX VISIBLE LENGTH 132,
p_afile(132) TYPE c.
SELECTION-SCREEN: END OF BLOCK b2.
SELECTION-SCREEN: BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
PARAMETERS : p_opath(132) TYPE c," DEFAULT 'C:\Documents and Settings\Error.txt' ,
p_simul AS CHECKBOX DEFAULT ' '.
SELECTION-SCREEN: END OF BLOCK b3.
AT SELECTION-SCREEN OUTPUT.
name = 'PS_PARM'.
value-key = '1'.
value-text = '0077--Additional Personal Data'.
APPEND value TO list.
value-key = '2'.
value-text = '0743--Discipline'.
APPEND value TO list.
value-key = '3'.
value-text = '0094--Residence Status'.
APPEND value TO list.
value-key = '4'.
value-text = '9900--Historic tax Information'.
APPEND value TO list.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = name
values = list.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ipath .
Calling a function module which helps in giving the files in the disk
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = p_ipath
IMPORTING
file_name = g_ipath.
Moving path back to the screen parameter
p_ipath = g_ipath.
updating appropriate error file name/path depending on the infotype chosen
AT SELECTION-SCREEN ON BLOCK b1.
LOOP AT SCREEN.
CASE ps_parm.
WHEN '1'.
CONCATENATE 'C:\Documents and Settings\IT_0077_Error' sy-datum sy-uzeit '.txt'
INTO p_opath.
WHEN '2'.
CONCATENATE 'C:\Documents and Settings\IT_0743_Error' sy-datum sy-uzeit '.txt'
INTO p_opath.
WHEN '3'.
CONCATENATE 'C:\Documents and Settings\IT_0094_Error' sy-datum sy-uzeit '.txt'
INTO p_opath.
WHEN '4'.
CONCATENATE 'C:\Documents and Settings\IT_9300_Error' sy-datum sy-uzeit '.txt'
INTO p_opath.
WHEN '5'.
CONCATENATE 'C:\Documents and Settings\IT_9310_Error' sy-datum sy-uzeit '.txt'
INTO p_opath.
WHEN '6'.
CONCATENATE 'C:\Documents and Settings\IT_9150_Error' sy-datum sy-uzeit '.txt'
INTO p_opath.
ENDCASE.
REFRESH lit_dynval.
lit_dynval-name = 'p_opath'.
lit_dynval-fieldvalue = p_opath.
APPEND lit_dynval.
CALL FUNCTION 'RS_SELECTIONSCREEN_UPDATE'
EXPORTING
program = lv_prog
dynnr = lv_dynp
TABLES
updatevalues = lit_dynval
EXCEPTIONS
no_high_field = 1
OTHERS = 2.
ENDLOOP.
2011 Jan 28 5:21 AM
Hi Andy,
You need to set the Function code (FctCode) for the custom list box field during screen design.
For example for the list box field give the value 'SET' in the FctCode.
Write the coding in PAI which is triggered if you select any value in the list box.
MODULE USER_COMMAND_1000 INPUT.
case sy-ucomm.
when 'SET'.
.
.
.
.
endcase.
Regards,
Srini.
2011 Jan 28 7:57 AM
Hi Srini,
Thats the answer I was after. Thanks very much for replying and helping me out.
Cheers
Andy