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

Prob in Select stmt

Former Member
0 Likes
1,041

I have wrote the following select query

Already my final Internal table contains Material number

SELECT matnr

FROM ekpo

INTO TABLE t_ekpo

FOR ALL ENTRIES IN t_final

WHERE konnr IN s_konnr

AND matnr EQ t_final-number

AND matkl IN s_matkl

AND meins IN s_meins

AND bstyp = c_k.

IF sy-subrc EQ 0.

SORT t_ekpo BY matnr.

ENDIF.

In select option i have entered a valid Konnr which have material number(in t_final) I am not getting any Material numbers.

Sy-subrc =4

Can anyone tell me where is the problem?

I have wrote the following select query

Already my final Internal table contains Material number

SELECT matnr

FROM ekpo

INTO TABLE t_ekpo

FOR ALL ENTRIES IN t_final

WHERE konnr IN s_konnr

AND matnr EQ t_final-number

AND matkl IN s_matkl

AND meins IN s_meins

AND bstyp = c_k.

IF sy-subrc EQ 0.

SORT t_ekpo BY matnr.

ENDIF.

In select option i have entered a valid Konnr which have material number(in t_final) I am not getting any Material numbers.

Sy-subrc =4

Can anyone tell me where is the problem?

8 REPLIES 8
Read only

Former Member
0 Likes
1,006

Madan,

just modify your query like this:

SELECT matnr
FROM ekpo
INTO TABLE t_ekpo
FOR ALL ENTRIES IN t_final
WHERE konnr IN s_konnr
AND matnr EQ t_final-number
AND matkl IN s_matkl
AND meins IN s_meins
AND bstyp = 'C_K'."should be in caps
IF sy-subrc EQ 0.
SORT t_ekpo BY matnr.
ENDIF.

Amit.

Read only

Former Member
0 Likes
1,006

hi,

Since you say u have matching konnr for the s_konnr you enter :

Check if you have any matnr from ekpo matching the values in t_final-number. If there is no matching matnr in ekpo when compared to the matnr in internal table then there is a possibility of select to have sy-subrc = 4.

regards,

madhu

Read only

Former Member
0 Likes
1,006

hiiii

check before this select statement that t_final is initial or not then use this select query..also check with the table taht wether that particular data exist with the same data you are entering on selection screen..check with following code

SELECT matnr                         " Material Number
    FROM mara
    INTO TABLE t_final
   WHERE matnr IN s_matnr.

  IF t_final[] IS NOT INITIAL.
    SELECT matnr
FROM ekpo
INTO TABLE t_ekpo
FOR ALL ENTRIES IN t_final
WHERE matnr EQ t_final-number
AND matkl IN s_matkl
AND konnr IN s_konnr
AND meins IN s_meins
AND bstyp = c_k.
ENDIF.

IF sy-subrc EQ 0.
SORT t_ekpo BY matnr.
ENDIF.

  ENDIF.

regards

twinkal

Edited by: twinkal patel on Jul 23, 2008 8:29 AM

Edited by: twinkal patel on Jul 23, 2008 8:30 AM

Read only

0 Likes
1,006

Twinkel,

thanks for replying and giving time to SDNers.

but i would suggest you that pls once you sure than only put your thoughts in forum you wrote:

check before this select statement that t_final is initial or not then use this select query

if the internal table is blank on which you are using for all entries than no data is suppose to fetch or all data will be fetch pls confirm than reply.

because in future from this thread some other person may also can take help so pls donot create misleads.

hope you dont hurt.

Amit.

Read only

Former Member
0 Likes
1,006

Hi,

when you are using for all entries in select statement.. either select fields should contain all the key fields or in where clause it should contain all the key fields where as u r select query on table EKPO either in select clause or in where clause u have not mentioned any key fields rectify it.

regards,

Sunil Kumar Mutyala

Read only

Former Member
0 Likes
1,006

Hi,

you have to mention bstyp in CAPSLOCK.

any Types i.e., Document type ,Material type ,BOM type has to be mentioned in CAPSLOCK.

Hope this will solve your problem.

Regards,

sharmishta.

Read only

sukhbold_altanbat
Active Participant
0 Likes
1,006

Hi,

Please check wether c_k = 'K'. - Capital K. If you see domain BSTYP, there will be value ranges which are A,B,F,I,K,L,Q,W.

Regards,

Sukhbold

Read only

Former Member
0 Likes
1,006

Hi Madan,

i think the problem is with ekpo just check whether the same Konnr is availble in ekpo also or not. ithink c_k is constant so no need to have it in capital only pretty printer will do it for u if necessary. also check the Matkl, meins and Bstyp = c_k are their in ekpo corresponds to Konnr you are entering in the screen.

hope this will help

Thanks

Ankur