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

Efficient Select Query

Former Member
0 Likes
705

Hi,

I want to have an effective select query with inner join for retrieving the fields

LIKP~LFDAT

VBRK~FKDAT

VBRP~FKIMG

VBEP~BMENG

with the common field VBELN that is there in all these tables...

If inner join is used four joins will come. Is it acceptable?

Thanks

Dinesh

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
659

Hi,

See using joins are acceptable becoz of the fast access than writing more than one query...So you can work with the same format...

Plz try to check with the se30 runtime analysis...Try the two form of the queries..you can see the difference

<b>TRY TO REWARD IF USEFUL</b>

6 REPLIES 6
Read only

Former Member
0 Likes
659

hi,

here we have to have use inner join and that is acceotable.

Jogdand M B

Read only

Former Member
0 Likes
660

Hi,

See using joins are acceptable becoz of the fast access than writing more than one query...So you can work with the same format...

Plz try to check with the se30 runtime analysis...Try the two form of the queries..you can see the difference

<b>TRY TO REWARD IF USEFUL</b>

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
659

Hi,

ANother option would be splitting it into two queries and then working on the Internal tables instead.

Check both approaches and see which ones performance is better.

Regards,

Sesh

Read only

Former Member
0 Likes
659

Hi,

plz go through the following example------

----


  • TABLE DECLERATION

----


TABLES : MARA ,

MARC ,

MARD ,

MAKT.

----


  • DATA DECLERATION

----


TYPES : BEGIN OF STRUCT_MAT,

MATNR TYPE MATNR,

MEINS TYPE MEINS,

WERKS TYPE WERKS_D,

LGORT TYPE LGORT_D,

MAKTX TYPE MAKTX,

END OF STRUCT_MAT.

----


  • INTERNAL TABLE

----


DATA : ITAB TYPE STANDARD TABLE OF STRUCT_MAT WITH HEADER LINE.

----


  • SELECTION SCREEN

----


SELECT-OPTIONS : S_MATNR FOR MARA-MATNR.

----


  • S T A R T - O F - S E L E C T I O N

----


START-OF-SELECTION.

SELECT

A~MATNR

A~MEINS

B~WERKS

C~LGORT

D~MAKTX

INTO CORRESPONDING FIELDS OF TABLE ITAB

FROM MARA AS A

INNER JOIN MARC AS B ON

AMATNR = BMATNR

LEFT OUTER JOIN MARD AS C ON

BMATNR = CMATNR AND

BWERKS = CWERKS

INNER JOIN MAKT AS D ON

AMATNR = DMATNR

WHERE A~MATNR IN S_MATNR .

IF SY-SUBRC <> 0.

EXIT.

ENDIF.

----


  • W R I T E

----


WRITE :5 'MATERIAL NO' COLOR 3,

25 'PLANT' COLOR 3,

40 'STORAGE LOC' COLOR 3,

60 'DESCRIPTION' COLOR 3,

120 'UOM' COLOR 3.

ULINE.

LOOP AT ITAB.

WRITE :/5 ITAB-MATNR COLOR 6 INVERSE,

25 ITAB-WERKS COLOR 6,

40 ITAB-LGORT COLOR 6,

60 ITAB-MAKTX COLOR 6,

120 ITAB-MEINS COLOR 6.

ENDLOOP.

*****do rewards if usefull

vijay

Read only

Former Member
0 Likes
659

Hi,

Use JOIN condition and check the performance. If it is good then continue otherwise comment some table and do some trial and error method.

then detach the tables with more time and delete the duplicate entries from the first table and move it to a temp table

the use for all entries

this will work faster

Regards

Shiva

Read only

Former Member
0 Likes
659

THANKS GUYS