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: 

Is it correct quires?

Former Member
0 Kudos

Hi,

I write some quires,any one tell me is it correct quires.Because some quires i have used workarea and some for i_vbeln.

types : begin of ty_vbeln,

vbeln type vbfa-vbeln,

end of ty_vbeln.

data : i_vbeln type standard table of ty_vbeln,

wa_vbeln type ty_vbeln.

SELECT VBELn FROM VBFA into table i_vbeln

where vbelv = CE0_M200-kaufn

and VBTYP_V eq 'M'.

if sy-subrc = 0.

Describe table i_vbeln lines ws_lines .

select single budat into ws_budat

from bkpf where awtyp = 'VBRK'

and awkey = wa_vbeln-vbeln.

loop at i_vbeln into wa_vbeln.

select single matnr from vbrp into ws_c_matnr

where vbeln = wa_vbeln-vbeln

and matnr = CE0_M200-artnr.

Thanks & Regards,

sudhakar

1 ACCEPTED SOLUTION

Former Member
0 Kudos

please used for all enties.

Use of FOR ALL Entries

Outer join can be created using this addition to the where clause in a select statement. It speeds up the performance tremendously, but the cons of using this variation are listed below

Duplicates are automatically removed from the resulting data set. Hence care should be taken that the unique key of the detail line items should be given in the select statement.

If the table on which the For All Entries IN clause is based is empty, all rows are selected into the destination table. Hence it is advisable to check before-hand that the first table is not empty.

If the table on which the For All Entries IN clause is based is very large, the performance will go down instead of improving. Hence attempt should be made to keep the table size to a moderate level.

Not Recommended

Loop at int_cntry.

Select single * from zfligh into int_fligh

where cntry = int_cntry-cntry.

Append int_fligh.

Endloop.

Recommended

Select * from zfligh appending table int_fligh

For all entries in int_cntry

Where cntry = int_cntry-cntry.

6 REPLIES 6

former_member194669
Active Contributor
0 Kudos

Hi,


types : begin of ty_vbeln,
vbeln type vbfa-vbeln,
end of ty_vbeln.

data : i_vbeln type standard table of ty_vbeln,
wa_vbeln type ty_vbeln.


SELECT VBELn FROM VBFA into table i_vbeln
where vbelv = CE0_M200-kaufn
and VBTYP_V eq 'M'.
if sy-subrc = 0.

Describe table i_vbeln lines ws_lines .

select single budat into ws_budat
from bkpf where awtyp = 'VBRK'
and awkey = wa_vbeln-vbeln.
"<<- This select will be fail becuase wa_vbeln is blank


loop at i_vbeln into wa_vbeln.

select single matnr from vbrp into ws_c_matnr
where vbeln = wa_vbeln-vbeln
and matnr = CE0_M200-artnr.

Points are always welcome

aRs

0 Kudos

Hi,

you specified this select queire is fail,because wa_vbeln is blank.Is there any alternative?Is it correct remaining part?

Sudha

0 Kudos

Thanks for ur suggestions.I will try ur code.If it work definetly i will assign points.

Thanks,

sudha

former_member194669
Active Contributor
0 Kudos

Hi,

Put the select statement inside the loop. otherwise assign value to wa_vbeln-vbeln, which suit according to your needs



loop at i_vbeln into wa_vbeln.

select single budat into ws_budat
from bkpf where awtyp = 'VBRK'
and awkey = wa_vbeln-vbeln.

 
select single matnr from vbrp into ws_c_matnr
where vbeln = wa_vbeln-vbeln
and matnr = CE0_M200-artnr.

if useful please assign points

aRs

Message was edited by:

0 Kudos

But we are checking the condition for if more than one record found

Ex:

If there are multiple preceding document with category M(invoice) are found,use the material number in the credit memo to find the invoice with matched material number.If the first invoice found with the matched material number will be used to derive the reporting date.

That why we write the select statement in the loop.Is there any suggestions>

Thanks & Regards,

sudhakar

Former Member
0 Kudos

please used for all enties.

Use of FOR ALL Entries

Outer join can be created using this addition to the where clause in a select statement. It speeds up the performance tremendously, but the cons of using this variation are listed below

Duplicates are automatically removed from the resulting data set. Hence care should be taken that the unique key of the detail line items should be given in the select statement.

If the table on which the For All Entries IN clause is based is empty, all rows are selected into the destination table. Hence it is advisable to check before-hand that the first table is not empty.

If the table on which the For All Entries IN clause is based is very large, the performance will go down instead of improving. Hence attempt should be made to keep the table size to a moderate level.

Not Recommended

Loop at int_cntry.

Select single * from zfligh into int_fligh

where cntry = int_cntry-cntry.

Append int_fligh.

Endloop.

Recommended

Select * from zfligh appending table int_fligh

For all entries in int_cntry

Where cntry = int_cntry-cntry.