05-02-2013 6:57 AM
Hello Experts,
I am developing a report with a selection screen:
on 'AT SELECTION-SCREEN', validation is performed and error message(' E ') is shown if no record is retrieved based on selection:
Question:
After i input data in the selection screen ( force input not to retrieved record ), i pressed F8 ( execute ). the error message is shown.
i corrected that data and just press 'ENTER' key. No error message was shown since a record was retrieved.. but the problem is, it now continues execution on 'START-OF-SELECTION'.
My needs is only the F8 ( execute ) key should be able to execute 'START-OF-SELECTION'.
is there a way i can 'REFRESH' the F8 whenever an Error is encountered in 'AT SELECTION-SCREEN'?
thanks a lot!
Carl
05-02-2013 10:05 AM
Hi Carl,
You can check the sy-ucomm = 'ONLI' to check if 'EXECUTE' or F8 was pressed. Please refer the below sample code:
at selection-screen on S_MATNR.
if sy-ucomm = 'ONLI'.
V_FLAG = 'X'.
IF S_matnr is initial.
message 'Error' type 'E'.
ENDIF.
ENDIF.
start-of-selection.
if V_FLAG = 'X'
select * into table it_mara from mara up to 5 rows where matnr in s_matnr.
loop at it_mara into wa_mara.
write:/ wa_mara-matnr.
endloop.
endif.
let me know if this works for you .
Regards,
Deepak.
05-15-2013 11:01 AM
First, declare the scren field structure with statement TABLES sscrfields in global data (start of report or top include)
Then before raising the error message, save current sscrfields-ucomm to a save variable (multiple values, can be ONLI, SJOB or PRIN). And when there is no longer any error, if the save variable is not initial, move it back to sscrfields-ucomm. You could clear the save variable at INITIALIZATION and/or START-OF-SELECTION.
NB: Testing SY-UCOMM is not good practice on selection screen since R3 4.5B.
Regards,
Raymond