Skip to Content
avatar image
Former Member

No records selected - SELECT clause with IN

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    Aug 17, 2007 at 07:05 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • Aug 17, 2007 at 06:53 PM

    Hi,

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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 17, 2007 at 06:46 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 17, 2007 at 06:48 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 17, 2007 at 06:52 PM

    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

    Add comment
    10|10000 characters needed characters exceeded