Application Development 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: 

getting sy-subrc = 4

Former Member
0 Kudos

hi,

in my select statement giving sy-subrc = 4.

please tell me why? i am fetchind data from a view.

Types:begin of zv_mast_stko,

matnr type zv_mast_stko-matnr,

werks type zv_mast_stko-werks,

stlal type zv_mast_stko-stlal,

end of zv_mast_stko.

data:gt_mast type table of zv_mast_stko,

gs_mast LIKE LINE OF gt_mast.

INITIALIZATION.

gv_repid = sy-repid. "report id

r_lkenz-sign = 'I'.

r_lkenz-option = 'NE'.

r_lkenz-low = 'X'.

APPEND r_lkenz.

clear r_lkenz.

SELECT matnr

werks

STLAL

FROM zv_mast_stko

INTO TABLE gt_mast

WHERE matnr IN so_matnr

AND werks in so_werks

AND stlal EQ po_stlal

AND stlst EQ po_stlst

and lkenz IN r_lkenz.

1 ACCEPTED SOLUTION

former_member555112
Active Contributor
0 Kudos

Hi,

It means that the data was not selected.

Do you have any data matching your selection criteria?

For a parameter if nothing is passed then it will compare with blank.

So if the parameters po_stlal and po_stlst do not have any value on the selection screen then they would be compared with blank.

So check the same.

Regards,

Ankur Parab

8 REPLIES 8

Former Member
0 Kudos

Please check your Ztable whether in Select as well as in where condition same name exists.

Probelm occurs due to field mismatch.

Regards

Arbind

Former Member
0 Kudos

Hello,

Looking at you select query it seems as if you are using parameters from a selection screen. Now your select query is written in the initialization event, that means it is being triggered before the user inputs anything on the selection screen.

Before your select query write the statement start-of-selection, to ensure that your select statement is being triggered after the selection screen is input.


start -of-selection.
SELECT matnr
werks
STLAL
FROM zv_mast_stko
INTO TABLE gt_mast
WHERE matnr IN so_matnr
AND werks in so_werks
AND stlal EQ po_stlal
AND stlst EQ po_stlst
and lkenz IN r_lkenz.

Hope this helps.

Regards,

Sachin

Former Member
0 Kudos

Hello

sy-subrc = 4 - it mean that entries not found for given conditions.

former_member588853
Active Contributor
0 Kudos

hI,

Data is not found in the database table and returns subrc value = 4.

go to se11

enter the table name ZV_MAST_STKO and see if the data is available for your where condition values.

data willnot be available for your select with where condition/

regards,

Nz

Former Member
0 Kudos

Before select Query Use eventAt-Selection-Screen

One more thing do check the same input values in the table to see if any record exists or not.

Manas M.

Former Member
0 Kudos

Hi ,

Please try this code - -

r_lkenz-sign = 'E'.     " Instead 'I' use 'E'
r_lkenz-option = 'EQ'.         " Instead 'NE' use 'EQ'
r_lkenz-low = 'X'.
APPEND r_lkenz.
clear r_lkenz.

Regards

Pinaki

Former Member
0 Kudos

Hi,

it is because a result set is empty (no data was found in the database). You should use event START-OF-SELECTION or END-OF-SELECTION instead of INITIALIZATION.

Regards,

Adrian

former_member555112
Active Contributor
0 Kudos

Hi,

It means that the data was not selected.

Do you have any data matching your selection criteria?

For a parameter if nothing is passed then it will compare with blank.

So if the parameters po_stlal and po_stlst do not have any value on the selection screen then they would be compared with blank.

So check the same.

Regards,

Ankur Parab