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

Select Query Problem

Former Member
0 Likes
459

Hi ALL,

SELECT mast~matnr

INTO gw_mat-matnr

FROM mast

INNER JOIN stko

ON maststlnr = stkostlnr

AND maststlal = stkostlal

UP TO 1 ROWS

WHERE mast~matnr = gw_mat-matnr

AND mast~werks = gw_mat-werks

AND ( maststlan = 'Y' or maststlan = '1')

AND stko~stlty = 'M'

AND stko~loekz = space.

Now this query is fetching only one row . In table MAST 2 rows are there for the field mast-stlan (i.e) for 'Y' AND '1'. So more than one rows has to be filled in gw_mat-matnr that is my requirement without using inernal table. Because gw_mat-matnr is used in many places and also this is a standard program. please suggest me to proceed.

Regards

R.vijay

3 REPLIES 3
Read only

Former Member
0 Likes
430

In the select query, when you use UP TO 1 ROWS, only one row will be fetched. Thats the reason. Also gw_mat looks like a work area and not a internal table. I dont understand how you can expect two records to be fetched into a work area or a structure.

Read only

Former Member
0 Likes
430

Dear

you have used UP TO 1 ROWS...which means it will selet only one row as you mentioned 1..

Please remove that stmt and check...

Read only

ThomasZloch
Active Contributor
0 Likes
430

As you can see from the replies, this is very basic, please try solving things yourself before asking, the learning curve will be much steeper.

For problems with SAP standard code visit the SAP Support Portal.

Thread locked.

Thomas