11-23-2004 7:30 AM
I have a report that needs to be executed in background.It has a selection screen.The program should get executed when user presses 'ENTER' while he is inside the selection screen.At present,when 'ENTER' key is pressed,only validation is done.To execute we are either pressing 'F8' key or click execute button in screen.
Now how to trap the 'ENTER' key press in a report?
11-23-2004 8:39 AM
Hi Jayaprakash,
All PAI processing will depend on the Function Code that has been triggered at the selection screen.
The ENTER key has no function code, whereas the "Execute" button has the function code 'ONLI'. SO what can be done is, when the user hits the ENTER key, we can programmatically set the function code to 'ONLI'. I shall give you a very small peice of code to illustrate my point.
===================================
tables sscrfields.
parameters p_vblen like vbak-vbeln obligatory.
at selection-screen.
if sscrfields-ucomm eq space.
sscrfields-ucomm = 'ONLI'.
endif.
start-of-selection.
write p_vblen.
===================================
The above code will trigger the report output on hitting the ENTER key at the selection screen.
What you only have to note here is that unlike with screen processing, in selection-screen processing, the function code will be made available in the field UCOMM of the structure SSCRFIELDS. However, you will have to declare this structure in your program ( using the TABLES statement as shown above ).
Hope the explanation has been clear enough to drive the point home for you. Please get back to me otherwise.
Regards,
Anand Mandalika.
11-23-2004 7:46 AM
To my knowledge, only F8, CtrlP, F3, ShiftF3, and F12 leave selection-screen processing (i.e. the AT SELECTION-SCREEN event sequence).
But check out the following:
<b>REPORT <...>
PARAMETERS p1.
AT SELECTION-SCREEN.
IF sy-calld = ' '.
SUBMIT <...> WITH p1 = p1.
ENDIF.
START-OF-SELECTION.
BREAK-POINT.</b>
11-23-2004 8:39 AM
Hi Jayaprakash,
All PAI processing will depend on the Function Code that has been triggered at the selection screen.
The ENTER key has no function code, whereas the "Execute" button has the function code 'ONLI'. SO what can be done is, when the user hits the ENTER key, we can programmatically set the function code to 'ONLI'. I shall give you a very small peice of code to illustrate my point.
===================================
tables sscrfields.
parameters p_vblen like vbak-vbeln obligatory.
at selection-screen.
if sscrfields-ucomm eq space.
sscrfields-ucomm = 'ONLI'.
endif.
start-of-selection.
write p_vblen.
===================================
The above code will trigger the report output on hitting the ENTER key at the selection screen.
What you only have to note here is that unlike with screen processing, in selection-screen processing, the function code will be made available in the field UCOMM of the structure SSCRFIELDS. However, you will have to declare this structure in your program ( using the TABLES statement as shown above ).
Hope the explanation has been clear enough to drive the point home for you. Please get back to me otherwise.
Regards,
Anand Mandalika.
11-23-2004 9:07 AM
11-23-2004 9:08 AM
The solution given by Anand Mandalika is working fine.
Thanks for all who helped me.