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

Data selection from Table

Former Member
0 Likes
695

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

5 REPLIES 5
Read only

Former Member
0 Likes
659

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.

Read only

tobiaskugelmann
Explorer
0 Likes
659

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

Read only

0 Likes
659

No Bapi nor FM is available. Pl tel me is that the logic is acceptable or not

Read only

ThomasZloch
Active Contributor
0 Likes
659

Check if you can use tables VBUK or VBUP instead of BKPF, e.g. VBUK-BUCHK sounds relevant for your task.

Thomas

Read only

0 Likes
659

Hi Thomos,

That BUCHK field is not relevent for me

-Rajiv