‎2009 Dec 10 4:12 AM
Hi ,
My requirement is to have Commercial Documents which are not Accounted. So that I've used the following logic.
SELECT a~vbeln
a~vbtyp
a~fkdat
a~bukrs
a~kunrg
SUM( b~netwr )
FROM vbrk AS a INNER JOIN vbrp AS b
ON avbeln EQ bvbeln
INTO ls_bill WHERE a~vbtyp EQ 'M' AND
a~fkdat IN s_fkdat AND
a~bukrs IN s_bukrs AND
a~kunrg IN s_kunrg
GROUP BY a~vbeln
a~vbtyp
a~fkdat
a~bukrs
a~kunrg.
l_awkey = ls_bill-vbeln.
SELECT awkey FROM bkpf INTO l_awkey
WHERE awtyp EQ 'VBRK' AND
awkey EQ l_awkey AND
bukrs EQ ls_bill-bukrs.
ENDSELECT.
IF sy-subrc NE 0.
APPEND ls_bill TO lt_bill.
ENDIF.
CLEAR : ls_bill, l_awkey.
ENDSELECT.
Is that the above logic for getting data is correct. or First taking all the entries from VBRK and VBRP table then selecting entries from BKPF and then if any entry of VBRK is not in BKPF then taking that.
Regards,
Rajiv.V
Moderator message - Moved to the correct forum
Edited by: Rob Burbank on Dec 10, 2009 9:36 AM
‎2009 Dec 10 4:32 AM
You should have searched SDN for Performance Tuning.
Solution :
Please search SDN for Performance Tuning and then try to understand the use of various statements that you have used in terms of performance.
‎2009 Dec 10 5:18 AM
Hi,
you should not use SELECT statements for such complex business logic. I would recommend you to search some BAPI or SAP function module, which is gathering the data for you.
BR
Tobias
‎2009 Dec 10 5:25 AM
No Bapi nor FM is available. Pl tel me is that the logic is acceptable or not
‎2009 Dec 10 12:49 PM
Check if you can use tables VBUK or VBUP instead of BKPF, e.g. VBUK-BUCHK sounds relevant for your task.
Thomas
‎2009 Dec 12 5:30 AM