Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Selection Screen

SG141
Active Participant
0 Likes
1,017

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.

12 REPLIES 12
Read only

Former Member
0 Likes
982

Try the following ....

IF GT_REVERSAL[] IS INITIAL.

MESSAGE E062(YF).

STOP.

ENDIF.

Read only

0 Likes
982

Hi,

You can use the following statement

IF GT_REVERSAL is initial.

MESSAGE S062(YF).

endif.

it will stay on selection screen only

shylesh

Read only

Former Member
0 Likes
982

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

Read only

SG141
Active Participant
0 Likes
982

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.

Read only

0 Likes
982

Hi Karthik,

you have to write this code in start-of-selection event.

that will really work fine.

shylesh

Read only

mnicolai_77
Active Participant
0 Likes
982

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

Read only

Former Member
0 Likes
982

This is probably the easiest:

  IF gt_reversal[] IS INITIAL.
    MESSAGE ID 'YF' TYPE 'S' NUMBER '062'.
  ENDIF

Rob

Read only

Former Member
0 Likes
982

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

Read only

0 Likes
982

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

Read only

0 Likes
982

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

Read only

Former Member
0 Likes
982

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...

Read only

Former Member
0 Likes
982

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..........