2009 May 08 2:46 PM
Hi,
I have a report that displays a lot of unnecessary information and it looks like the correct information is on the last 9 lines. I am reading data from likp and vbuk.
select likplfdat likpkunnr likpbtgew likpvbeln likpvoleh likpvolum likpbtgew as btge likpinco2
likpvstel likplfart vbukkostk vbukvbtyp
from likp join vbuk on likpmandt = vbukmandt
and likpvbeln = vbukvbeln
into corresponding fields of itab
where likp~vstel in s_vstel
and vbuk~kostk = 'A'
and vbukvbtyp = 'J' or vbukvbtyp = 'T'.
check itab-vstel in s_vstel.
check itab-lfart in s_lfart.
check itab-kostk = ' ' or itab-kostk = 'A'.
check itab-vbtyp = 'J' or itab-vbtyp = 'T'.
append itab.
clear itab.
endselect.
May somebody check this select and let me know what I can do in order to make it display only the 9 values and to make the report run faster.
Best regards,
Fred
Hi,
I have a report that displays a lot of unnecessary information and it looks like the correct information is on the last 9 lines. I am reading data from likp and vbuk.
select likplfdat likpkunnr likpbtgew likpvbeln likpvoleh likpvolum likpbtgew as btge likpinco2
likpvstel likplfart vbukkostk vbukvbtyp
from likp join vbuk on likpmandt = vbukmandt
and likpvbeln = vbukvbeln
into corresponding fields of itab
where likp~vstel in s_vstel
and vbuk~kostk = 'A'
and vbukvbtyp = 'J' or vbukvbtyp = 'T'.
check itab-vstel in s_vstel.
check itab-lfart in s_lfart.
check itab-kostk = ' ' or itab-kostk = 'A'.
check itab-vbtyp = 'J' or itab-vbtyp = 'T'.
append itab.
clear itab.
endselect.
May somebody check this select and let me know what I can do in order to make it display only the 9 values and to make the report run faster.
Best regards,
Fred
2009 May 08 3:41 PM
Please try the below code:-
data: begin of itab occurs 0,
vbeln like likp-vbeln,
vstel like likp-vstel,
lfart like likp-lfart,
lfdat like likp-lfdat,
inco2 like likp-inco2,
kunnr like likp-kunnr,
btgew like likp-btgew,
volum like likp-volum,
voleh like likp-voleh,
kostk like vbuk-kostk,
vbtyp like vbuk-vbtyp,
end of itab.
select avbeln avstel alfart alfdat ainco2 akunnr a~btgew
avolum avoleh
bkostk bvbtyp
from likp as a
inner join vbuk as b
on bmandt = amandt
and bvbeln = avbeln
into table itab
where a~vstel in s_vstel
and a~lfart in s_lfart
and ( ( bkostk = 'A' ) or ( bkostk = ' ' ) )
and ( ( bvbtyp = 'J' ) or ( bvbtyp = 'T' ) ).
Please try to avoid CORRESPONDING FIELDS . Also please select the fields in the order of their occurance in the table.
Regards,
Mamta Gupta.
2009 May 11 6:53 AM
Hi Mumta,
I have tried the coding you sent me but when I include kostk = ' ' on the where it does not display the right values (no difference to the old problem that I had ). When I don't include kostk = ' ' on the where clause it does displays the correct values.
May you advice, please!
Regards,
Fred.
2009 May 08 3:45 PM
Hi ,
First of all you need to remove the SELECT and ENDSELECT , because it is
a costly statement.
Use SELECT directly into internal table by array fetch .
Use another two three select-option and populate them according to value required
and use them in where clause.
Check this code - -
select likp~lfdat likp~kunnr likp~btgew likp~vbeln likp~voleh likp~volum
likp~btgew as btge likp~inco2
likp~vstel likp~lfart vbuk~kostk vbuk~vbtyp
from likp join vbuk on likp~mandt = vbuk~mandt
and likp~vbeln = vbuk~vbeln
into corresponding fields of table itab
where
likp~vstel in s_vstel and
vbuk~kostk = 'A'
and vbuk~vbtyp in s_vbtyp and "Populate select-option s_vbtyp by J and T likp~vstel in s_vstel and
likp~lfart in s_lfart and
vbuk~kostk in s_kostk and " Populate s_kostk by ' ' and A
vbuk~vbtyp in s_vbtyp . " Populate s_vbtyp
Regards
Pinaki
2009 May 08 4:45 PM
Hi Fred,
1. Remove the ENDSELECT and Use INTO TABLE Internal Table.
2. While you selecting the fields from the DB tables, you also select all the Key fields though its not required for further processing, but a mandatory trick we need to follow otherwise you get abnormal results.
Regards,
Balaji
2009 May 11 7:01 AM
Hi in your select query u have given the following
likpvbeln = vbukvbeln
LIKP~VBELN is Delivery doc number,
VBUK~VBELN is Sales doc number.
you should not compare those 2.
Regards,
Ajay
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |