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
681

I m using inner join.

I have to join 3 tables.

i m having 2 select-options.

In my where condition i will check that select-option condition using WHERE IN

Now my problem is i have to fetch records having order type either PP01,PP02 , PP03 which is available in one table.(Using OR condition)

both the select-option condition must be satisfied so i used AND condition.

So i want to use both OR & AND condition in my inner join after WHERE.How to write query now.

Thanks in advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
648

Hi,

You can do this by filling a range table of order type.

Check this code. Let me know if you have any question.

*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
*"--- MACRO - Fill Order type
DEFINE fill_auart.
  r_auart-sign     = 'I'.
  r_auart-low      =  &1.
  r_auart-option  = 'EQ'.
  append r_auart.
END-OF-DEFINITION.

TABLES: vbak.

SELECT-OPTIONS: s_vbeln FOR vbak-vbeln.

DATA: lit_vbak LIKE STANDARD TABLE OF vbak.

RANGES: r_auart FOR vbak-auart.

*" Fill order types
fill_auart 'PP01'.
fill_auart 'PP02'.
fill_auart 'PP03'.

*" Get data based on Selection criteria and Order type
SELECT *
        FROM vbak
        INTO TABLE lit_vbak
        WHERE vbeln IN s_vbeln AND
              auart IN r_auart.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*

Regards,

RS

6 REPLIES 6
Read only

Former Member
0 Likes
649

Hi,

You can do this by filling a range table of order type.

Check this code. Let me know if you have any question.

*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
*"--- MACRO - Fill Order type
DEFINE fill_auart.
  r_auart-sign     = 'I'.
  r_auart-low      =  &1.
  r_auart-option  = 'EQ'.
  append r_auart.
END-OF-DEFINITION.

TABLES: vbak.

SELECT-OPTIONS: s_vbeln FOR vbak-vbeln.

DATA: lit_vbak LIKE STANDARD TABLE OF vbak.

RANGES: r_auart FOR vbak-auart.

*" Fill order types
fill_auart 'PP01'.
fill_auart 'PP02'.
fill_auart 'PP03'.

*" Get data based on Selection criteria and Order type
SELECT *
        FROM vbak
        INTO TABLE lit_vbak
        WHERE vbeln IN s_vbeln AND
              auart IN r_auart.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*

Regards,

RS

Read only

0 Likes
648

i used macros as u told but i m getting the same output.

I enter the vbeln the result must be single record but my output is 3 its fetching the record based on PP01,PP02 & PP03 .

How to solve this.

Thenks in advance.

Read only

0 Likes
648

You have these values PP01,PP02 & PP03 in a range. They act as an 'OR'.

That is why you are reading all 3.

Post your code. It is still unclear what you require.

Read only

0 Likes
648

can you please send that piece of code...

Read only

Former Member
0 Likes
648

hi kalpana,

u can use inner join for the first two tables and use for all entries for the next table.

try this one.

Regards.....

Arun.

Reward points if useful.

Read only

Former Member
0 Likes
648

Hi,

you can use it this way...



SELECT .............
..................
..................

WHERE AB IN S_AB AND
             CD IN S_CD AND
             (ORD_TY = 'PP01' OR
              ORD_TY = 'PP02' OR
              ORD_TY = 'PP03').

Thanks and Regards,

Kunjal Patel