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: 

No records selected - SELECT clause with IN

Former Member
0 Kudos

Hello ABAP Experts

1st CASE:

When I execute program below and leave selection screen for S_VBELN and S_ERDAT blank and leave P_AUART to 'PR00", it returns SY-SUBRC = 4.

I get no lines returned.

2nd CASE:

If I comment out the last 2 lines in my "WHERE" clause of my SELECT, so now my select statement is like this:

select vbeln erdat auart knumv from vbak into table gt_vbak

where vbeln in S_VBELN.

and leave selection screen for S_VBELN and S_ERDAT blank and leave P_AUART to 'PR00",

I get lines. I can even enter a specific order and it will only return that one.

Can someone explain why my SELECT statement in CASE 1 is not working?

REPORT YTEST4.

tables: vbak.

SELECT-OPTIONS: S_VBELN for VBAK-VBELN,

S_ERDAT for VBAK-ERDAT.

PARAMETERS: P_AUART like vbak-auart default 'PR00' obligatory.

data: begin of gt_vbak occurs 0,

vbeln like vbak-vbeln,

erdat like vbak-erdat,

auart like vbak-auart,

knumv like vbak-knumv.

data: end of gt_vbak.

START-OF-SELECTION.

select vbeln erdat auart knumv from vbak into table gt_vbak

where vbeln in S_VBELN

and erdat in S_ERDAT

and auart = P_AUART.

loop at gt_vbak.

write:/ gt_vbak-vbeln, gt_vbak-erdat, gt_vbak-auart, gt_vbak-knumv.

endloop.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Leal,

There is no Sales Document Type(VBAK_AUART) with PR00 as standard one. So, you will not get any entries for 1st Case. PR00 is the condition type but not the sales document types. I think it is OR rather than PR00. You can refer V0V8 to find the list of sales document types and refer V/06 to find the list of conidition types.

You are getting records in the 2nd case because you are querying on list of sales orders.If they exist then it will give the list of sales order which exist in the select-option list.

Thanks,

Vinay

8 REPLIES 8

Former Member
0 Kudos

use this select..

  select vbeln erdat auart knumv from vbak into CORRESPONDING FIELDS OF TABLE gt_vbak where vbeln in S_VBELN
and erdat in S_ERDAT
and auart = P_AUART.

A

Former Member
0 Kudos

HI,

The data format in p_auart may be wrong..

try this way

REPORT YTEST4.

tables: vbak.

SELECT-OPTIONS: S_VBELN for VBAK-VBELN,

S_ERDAT for VBAK-ERDAT,

<b>s _AUART for vbak-auart obligatory no-extension no intervals</b>.

data: begin of gt_vbak occurs 0,

vbeln like vbak-vbeln,

erdat like vbak-erdat,

auart like vbak-auart,

knumv like vbak-knumv.

data: end of gt_vbak.

initialization.

s_auart-low = 'PA00'.

s_auart-opt = 'I'.

s_auart-sign = 'EQ'.

append s_auart.

START-OF-SELECTION.

select vbeln erdat auart knumv from vbak into table gt_vbak

where vbeln in S_VBELN

and erdat in S_ERDAT

<b>and auart in s_AUART.</b>

loop at gt_vbak.

write:/ gt_vbak-vbeln, gt_vbak-erdat, gt_vbak-auart, gt_vbak-knumv.

endloop.

Thanks

mahesh

Former Member
0 Kudos

HI,

I tested with ur code... it is working fine.

can u check the database table with the values u provided is there any records there or not?

in vbak table ma be no records present with auart = PR00 or not in the given date.

Regards

SAB

former_member194669
Active Contributor
0 Kudos

Hi,

I think it is data problem. please look into data what you are getting thru 2nd CASE.

0 Kudos

please check if the document type <b>'PR00' </b> exists in the system..

i have no problem executing the code in my system.

A

0 Kudos

I guess PR00 is the condition type (KONP-KSCHL) but not the document type (VBAK-AUART) you are supposed to use

-Kriss

Former Member
0 Kudos

Hi Leal,

There is no Sales Document Type(VBAK_AUART) with PR00 as standard one. So, you will not get any entries for 1st Case. PR00 is the condition type but not the sales document types. I think it is OR rather than PR00. You can refer V0V8 to find the list of sales document types and refer V/06 to find the list of conidition types.

You are getting records in the 2nd case because you are querying on list of sales orders.If they exist then it will give the list of sales order which exist in the select-option list.

Thanks,

Vinay

0 Kudos

My problem has been solved thanks to ALL eyes.

It was a data problem. Instead of using 'PR00', I should have been using 'SO'.

Initially I was going after the sales order, but eventually I was trying to get to table KONV using the condition type (KSCHL) 'PR00' as one of my search fields.

I gave points to as many as I could.

Orlando