‎2008 Jan 15 10:10 PM
In my program logic start-of-selection i am retrieving data from DB tables based on selection parameters. How if the data is not found then i am displayed a error message. The problem is after the error message is displayed instead of going back to selection screen it is goin to sap main screen. how to fix this issue.
SELECT BUKRS
BELNR
GJAHR
BLDAT
BLART
WAERS
KURSF
BKTXT
STODT
STGRD
FROM BKPF INTO TABLE GT_REVERSAL
WHERE BUKRS IN S_BUKRS AND
BELNR IN S_BELNR AND
GJAHR IN S_GJAHR AND
STODT IN S_RBDAT AND
XSTOV EQ 'X' AND
STBLG EQ ''.
IF GT_REVERSAL[] IS INITIAL.
MESSAGE E062(YF).
ENDIF.
‎2008 Jan 15 10:12 PM
Try the following ....
IF GT_REVERSAL[] IS INITIAL.
MESSAGE E062(YF).
STOP.
ENDIF.
‎2008 Jan 15 10:16 PM
Hi,
You can use the following statement
IF GT_REVERSAL is initial.
MESSAGE S062(YF).
endif.
it will stay on selection screen only
shylesh
‎2008 Jan 15 10:14 PM
Probably better ....
SELECT BUKRS
BELNR
GJAHR
BLDAT
BLART
WAERS
KURSF
BKTXT
STODT
STGRD
FROM BKPF INTO TABLE GT_REVERSAL
WHERE BUKRS IN S_BUKRS AND
BELNR IN S_BELNR AND
GJAHR IN S_GJAHR AND
STODT IN S_RBDAT AND
XSTOV EQ 'X' AND
STBLG EQ ''.
If sy-subrc <> 0.
message ......
stop.
endif.
Best!
Jim
‎2008 Jan 15 10:18 PM
It's working fine when is put my logic in at selection-screen event
however i am not sure that block of code can be put in the at selection screen event.
‎2008 Jan 15 10:21 PM
Hi Karthik,
you have to write this code in start-of-selection event.
that will really work fine.
shylesh
‎2008 Jan 15 10:27 PM
hi,
try this way,
>report zprogram.
>SELECT BUKRS BELNR GJAHR BLDAT BLART WAERS KURSF BKTXT STODT STGRD
>FROM BKPF INTO TABLE GT_REVERSAL
>WHERE BUKRS IN S_BUKRS AND
>BELNR IN S_BELNR AND
>GJAHR IN S_GJAHR AND
>STODT IN S_RBDAT AND
>XSTOV EQ 'X' AND
>STBLG EQ ''.
>
>IF GT_REVERSAL[] IS INITIAL.
>MESSAGE W062(YF).
>submit zprogram with S_BUKRS in S_BUKRS
> with S_BELNR in S_BELNR
> with S_GJAHR in S_GJAHR
> with S_RBDAT in S_RBDAT
>ENDIF.
If you prefer an error message instead of warning message use a pop-up to send the error message.
Regards
Marco
‎2008 Jan 15 10:39 PM
This is probably the easiest:
IF gt_reversal[] IS INITIAL.
MESSAGE ID 'YF' TYPE 'S' NUMBER '062'.
ENDIFRob
‎2008 Jan 15 10:53 PM
Hi Karthik,
The right place to check the selection data and any subsequent data is AT SELECTION-SCREEN event block as you are still on the selection screen and can show error messages here. Once you leave the selection screen and enter the START-OF-SELECTION event, there is no coming back to selection screen and its events.
If you don't get any data based on user data, there is no processing needed for the data and no report output will be generated.
I would suggest that you keep your code in AT SELECTION-SCREEN event block.
Hope this helps.
Thanks
Sanjeev
‎2008 Jan 15 10:59 PM
Hi Sanjeev,
But I think AT SELECTION-SCREEN is mainly used to validate the selection screen inputs from check tables or any validations.
Let me know if i am wrong?
shylesh
‎2008 Jan 15 11:05 PM
Sanjeev - the SELECT being used could take a while to execute. I generally try to avoid having a lot of processing done in the AT SELECTION-SCREEN event.
Rob
‎2008 Jan 15 11:08 PM
hi
as we know at selection screen event is for selection of inputs from the user ..so after the selection of input...we give start-of-selection event..so with this event based upon the inputs selected we start processing in this event...so there is no question of going back to selection screen again...after start-of-selection event or during this event...may u r going to main screen of some runtime error or short dump....just check it out...
rewards if helpful.........
urs prashanth...
‎2008 Jan 16 1:10 AM
Hi
You should not code error message in the Start-of-selection event. If code the event it will come out of the program.
If you want message, you could write message type 'I' ie infomation.
for example :
if sy-subrc ne 0.
message 'No data found' type 'I'.
exit.
endif.
procede with the further code..........