03-04-2009 8:25 AM
Hi,
'
I am new to ABAP. I have created a report. I want to display an error message 'No data for given selection criteria' if the entered inputs are wrong. For this, I have included the message in a message class and included the class in my report.
My problem is that, when I execute, though the error message is displayed, the control does not move back to the selection screen.
I searched the forum but did not find a relevant ans. Please help ASAP.
Regards,
Smruthi.
03-04-2009 8:30 AM
Hi,
Use like this
MESSAGE 'Valid material' TYPE 'I' DISPLAY LIKE 'E'.
03-04-2009 8:26 AM
use ABAP statrement Leave list-processing.
to return control to slection screen, chnage message type from E to I.
03-04-2009 8:29 AM
I tried call screen 1000, leave to screen 1000 ad leave list-processing. I also tried changing the message type to W, S and I. But to no avail. Please suggest a code to get back to the selection screen after displayin the error message.
03-04-2009 8:30 AM
Hi,
Use like this
MESSAGE 'Valid material' TYPE 'I' DISPLAY LIKE 'E'.
03-04-2009 8:35 AM
03-04-2009 8:40 AM
hi smrutrhi,
Try this:
MESSAGE 'message text' TYPE 'S display like 'E'.
LEAVE-LIST PROCESSING.
Regards,
Prakash
03-04-2009 8:47 AM
START-OF-SELECTION.
IF <Condition>
MESSAGE 'message text' TYPE 'S display like 'E'.
ENDIF.
03-04-2009 8:55 AM
Thanks Milind and Prakash,
But now the control goes to the ALV screen. Is there any way to get back the control to the selection screen?
Regards,
Smruthi
03-04-2009 8:58 AM
Try this.
MESSAGE 'Error message' TYPE 'I' DISPLAY LIKE 'E'.
CALL SELECTION-SCREEN 1000.
LEAVE PROGRAM.
03-04-2009 9:03 AM
START-OF-SELECTION.
IF <Condition>
MESSAGE 'message text' TYPE 'S display like 'E'.
ELSE.
ur code
ENDIF.
Edited by: Milind Mungaji on Mar 4, 2009 10:03 AM
03-04-2009 9:11 AM
Thanks a lot Gautham,
Now my code gets back to the selection screen when I enter invalid input for the first time. But when I enter it for a second time, the control comes out of the selection screen. Please can you help me to get it right?
Regards,
Smruthi.
03-04-2009 9:20 AM
Hi,
Try declaring all your checks and validations in the AT SELECTION-SCREEN event.
Like:
AT SELECTION-SCREEN ON <field you want to check>
<your checks>
Regards.
03-04-2009 9:30 AM
03-04-2009 9:48 AM
Dear Gautham and rajan,
The error occurs after the processing of the selct query is done. So I cannot write the code after AT SELECTION SCREEN. Can you suggest me any other way please?
Regards,
Smruthi.
03-04-2009 10:11 AM
Hi Smruthi,
Did you checked my code...?
Can you please copy your code here...
This will help us to resolve the issue.....
Regards,
Kittu
03-04-2009 10:38 AM
Hi,
Well my question is pretty much general..
I have a 3 inputs parameters on the selection screen. I have included validations for these inputs at AT SELECTION SCREEN event, which is working fine.
Now I want to display an error message if the user gives input that has no data to be fetched. So I display an error message when the user gives wrong input. I cannot write the code for this after AT SELECTION SCREEN event because there is a set of select query statements which are to be processed before the message is displayed. Instead I write it after the START OF SELECTION event.
The control should shift back to the selection screen after displaying the error message. This does not happen if the user enters wrong input for the second time.
When entered for the first time, the control shifts back to the selection screen. But when he gives the same or any other wrong input for the second time, the control goes back to the code.
This should not happen right? Seems to be very strange.
I hope you have understood my problem. Please give me a relevant solution for this.
Regards,
Smruthi.
Edited by: Smruthi Acharya on Mar 4, 2009 4:10 PM
03-04-2009 10:55 AM
Hi Smruthi,
Copy your code here without which it is difficult to say where you are going wrong...
03-04-2009 10:57 AM
Hi Smruthi,
First at initialization event or before the select query at start-of-selection event CLEAR or REFRESH your internal table and work area.And after the select query try to check the internal table whether it is blank or not, dont use the sy-subrc check.
CLEAR IT_TABLE.
or
REFRESH IT_TABLE.
Your SELECT Query.
If it_table is INITIAL.
Message <Message text> TYPE 'S' DISPLAY LIKE 'E'.
LEAVE TO LIST-PROCESSING.
Endif.
Hope this works.
Regards,
Qamar
03-04-2009 8:35 AM
HI,
Check this code..
Message Type E should be used in the AT Selection-screen events In START-OF-SELECTION &
END-OF-SELECTION use the I message type and Exit it takes you to selection screen.
Check by pass to corresponing parameter
PARAMETERS: p_atss TYPE char1, " AT SELECTION-SCREEN ON p_atss
p_sos TYPE char1, " START-OF-SELECTION.
p_eos TYPE char1. " END-OF-SELECTION.
AT SELECTION-SCREEN ON p_atss.
IF not p_atss IS INITIAL.
MESSAGE e016(pn) WITH 'No data for given selection screen from atss'.
ENDIF.
START-OF-SELECTION.
IF not p_sos IS INITIAL.
MESSAGE i016(pn) WITH 'No data for given selection screen from SOS'.
EXIT.
ENDIF.
END-OF-SELECTION.
IF not p_eos IS INITIAL.
MESSAGE i016(pn) WITH 'No data for given selection screen from EOS'.
EXIT.
ENDIF.
Edited by: Avinash Kodarapu on Mar 4, 2009 2:05 PM
Edited by: Avinash Kodarapu on Mar 4, 2009 2:10 PM
03-04-2009 8:37 AM
Hi,
if u r giving the error message in the event 'at selection-screen.' then it will be in the selection screen itself.
Like this:
REPORT ztest7 MESSAGE-ID sabapdocu.
PARAMETERS: date TYPE sy-datum.
AT SELECTION-SCREEN.
IF date IS INITIAL.
MESSAGE e014.
ENDIF.
Hope this will solve ur issue.
Keerthi
Edited by: Keerthy K on Mar 4, 2009 9:38 AM
03-04-2009 8:40 AM
Hi Smruti,
If you need this for screen validation then please write them in the event called
AT selection screen.
Perform validation
Form validation.
DATA : L_ATTR50A TYPE /SAPSLL/ATTRV05.
SELECT SINGLE ATTR05A
FROM /SAPSLL/PRGEN
INTO L_ATTR50A
WHERE ATTR05A IN S_ATR5A.
IF SY-SUBRC <> 0 .
MESSAGE : E009(ZMSSG) WITH 'Data not available for this entry'.
ENDIF .
*VALIDATION FOR NUMBER SCHEME
DATA : L_STCTS TYPE /SAPSLL/STCTS.
SELECT SINGLE STCTS
FROM /SAPSLL/PRCTSC
INTO L_STCTS
WHERE STCTS IN S_STCTS.
IF SY-SUBRC <> 0 .
MESSAGE : E000(ZMSSG) WITH 'Data not available for this entry'.
ENDIF .
*VALIDATION FOR SUBSTANCE ID
DATA : L_AT20A TYPE /SAPSLL/ATTRV20.
SELECT SINGLE ATTR20A
FROM /SAPSLL/PRGEN
INTO L_AT20A
WHERE ATTR20A IN S_AT20A .
IF SY-SUBRC <> 0 .
MESSAGE : E001(ZMSSG) WITH 'Invalid entry Or SubId does not exist for this entry'.
ENDIF .
Endform.
If you are writing this while selecting the data from the database then try this...
START-OF-SELECTION.
PERFORM datafetching.
Form datafetching.
*&---------------------------------------------------------&
* GET FIELDS FROM PRGEN BASED ON THE GUID_PR
*&---------------------------------------------------------&
SELECT GUID_PRGEN "Primary Key as GUID in "RAW" Format
GUID_PR "Primary Key as GUID in "RAW" Format
ATTR20A "SUBSTANCE ID
ATTR05A "Materail Type
ATTR10A "Materail Group
ATTR05B "Sub-Family
ATTR05C "SPEC BUS + DG1K902190
FROM /SAPSLL/PRGEN
INTO TABLE T_PRGEN
WHERE ATTR20A IN S_AT20A
AND ATTR05A IN S_ATR5A " +DG1K902168
AND ATTR05C IN S_ATR5C. " + DG1K902190
IF T_PRGEN IS INITIAL.
MESSAGE : I007(ZMSSG) WITH 'Data not available for this entry'.
*STOP.*
ENDIF.
endform.
Use STOP as mentioned above this will fix the issue. You can Also try with Error message
Type I. But type I will look good at the data selection level.
Try it...it will work!
Let me know if you need anything else...
Regards,
Kittu
Edited by: Kittu on Mar 4, 2009 9:41 AM
03-04-2009 10:08 AM
Hi
After your select statement write the following code
if sy-subrc ne 0.
message ' No record found' type 'E' dispaly like 'S'.
endif.
Hope this solve the issue
Regars,
Rajani
03-04-2009 10:49 AM
Hi
If YOu are displaying error message no further action will process .
Only one option use information message or warning message in At selection-screen output event .
03-04-2009 11:03 AM
HI Smruthi,
If you would paste your code then it will be very easy to understand and fix it.
However..here comes the Solution.....
*&----
&
GET CORSTA-QUAL_STA FOR STATUS CATEGORY
BESED ON THE T_CTSNUMC-GUID_MOBJ
*&----
&
*DG1K902110
SELECT GUID_CORSTA " +DG1K902110
GUID_MOBJ
QUAL_STA
FROM /SAPSLL/CORSTA
INTO TABLE T_CORSTA
FOR ALL ENTRIES IN T_PNTPR
WHERE GUID_MOBJ EQ T_PNTPR-GUID_PR
AND QUAL_STA IN S_QSTA.
IF T_CORSTA IS INITIAL.
REFRESH S_QSTA.
MESSAGE : I007(ZMSSG) WITH 'Data not available for this entry'.
STOP.
ENDIF.
This will work for sure..
Add Refresh Statement inside the If condition.....
For better understanding please copy your code....
Regards,
Kittu
03-06-2009 6:34 AM
Thanks. Using a little bit of inputs from your side, and by my seniors, my problem has been solved.
04-01-2009 4:46 PM
hi,
i am also finding the same problem that HOW TO GET BACK TO SELECTION SCREEN AFTER DISPLAYING ERROR MESSAGE (I ALSO CHECK THE FIELD VALUE FROM DATA BASE).
so if your problem is solved please help me to fix it.
thanks.
06-23-2009 6:14 AM
Hi,
I am also getting the same problem. I am not able to come to the selection screen of the Report program after I display the error message. It simply exits from the program. If I use information message, its working fine. But I want to display an error message only(after checking from data base, when data is invalid). So, can you help me with this.
Thanks and Regards,
Avinash
12-19-2013 9:46 AM
You can write the below code, it will solve the problem
after Fetching the data base table in start-of-selection event, write,
if sy-subrc <> 0.
MESSAGE ' No record found' TYPE 'S' DISPLAY LIKE 'E'.
STOP.
endif.
It will then allow user to enter the value again in selection screen and it won't exit the screen either.
07-01-2015 8:43 AM
Hi Smruthi,
Use the following statements to call the selection screen:
LEAVE LIST-PROCESSING.
SET SCREEN 1000.
Hope you find this helpful.
07-01-2015 8:46 AM
Hi Smruthi,
Make sure the message type is 'I' not 'E'.
We can achieve this using STOP but it is obsolete now.
11-02-2015 6:46 AM
Hi,
Thanks Aurobindo,
I was also facing same problem but your code is working perfectly for me.
LEAVE LIST-PROCESSING.
SET SCREEN 1000.
Thanks
vikas
07-01-2015 8:12 PM
Hello smruthi,
Aftet message statement use 'RETURN' ,it will get back to selection screen.
Thanks,Sateesh
06-15-2016 3:19 AM
Should be something like below. It's important to set as type S(uccess) and display like E(rror).
MESSAGE 'Your error message here.' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.