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

Regarding sql query

Former Member
0 Likes
324

Hi Guriji,

I want to fetch the data from Mseg and mkpf table based on condion but it will take time. but are the condion we are written it will take lot of time .Plz tell what we are doing for this.

TABLES: mseg, mkpf.

DATA: BEGIN OF T_ITAB OCCURS 0,

MATNR TYPE mseg-MATNR,

WERKS TYPE mseg-WERKS,

BWART TYPE mseg-BWART,

BUDAT TYPE mkpf-BUDAT,

END OF T_ITAB.

START-OF-SELECTION.

SELECT-OPTIONS: plant FOR mseg-WERKS OBLIGATORY.

select amatnr awerks abwart bbudat into t_itab from mseg as a inner join mkpf as b

on amblnr = bmblnr

where awerks in plant and abwart = '201' or a~bwart = '261' .

COLLECT t_itab INTO t_itab.

endselect.

loop at t_itab.

WRITE:/ t_itab-matnr, t_itab-bwart, t_itab-budat,t_itab-werks.

endloop.

thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
291

Hi Sachin

Avoid SELECT - END SELECT and select records into an internal table.

This will improve performance.

After this you can loop on the resultant internal table and can COLLECT records.

As per my understanding there is not need to use the collect statement. Please check this at your end.

Also , in place of abwart = '201' or abwart = '261' use

a~bwart in ( 201, 261 ).

Hope this help you

1 REPLY 1
Read only

Former Member
0 Likes
292

Hi Sachin

Avoid SELECT - END SELECT and select records into an internal table.

This will improve performance.

After this you can loop on the resultant internal table and can COLLECT records.

As per my understanding there is not need to use the collect statement. Please check this at your end.

Also , in place of abwart = '201' or abwart = '261' use

a~bwart in ( 201, 261 ).

Hope this help you