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: 

Withholding tax based on segments/profit center

Former Member
0 Kudos
159

Hello Friends

Iam developing withholding tax report for our FI module.I need to show report based on segments which are our different company offices.Now WITH_ITEM table does not has segment otherwise I would have directly picked data from WITH-ITEM. .Iam using this complex logic,which I have a feeling is not the right way and is taking lot of time to run.

My report logic is as follows:

First I pick from BKPF those documents which are vendor payments.

SELECT * INTO CORRESPONDING FIELDS OF TABLE ibkpf

FROM bkpf

WHERE bukrs = p_bukrs

AND gjahr = p_gjahr

AND belnr IN s_belnr

AND blart IN ('KZ')

AND budat IN s_budat.

Next I find the invoice number against that payment number.

LOOP AT ibkpf.

SELECT SINGLE belnr FROM BSak

INTO v_belnr

WHERE bukrs = p_bukrs

AND gjahr = p_gjahr

AND augbl = ibkpf-belnr

AND BLART = 'KR'.

Then I get the segment against that invoice and remove from internal table those values whose segment is different.

SELECT SINGLE segment FROM bsis

INTO v_segment

WHERE bukrs = p_bukrs

AND gjahr = p_gjahr

AND belnr = v_belnr

AND segment = p_seg.

IF sy-subrc NE 0.

DELETE ibkpf.

ENDIF.

ENDLOOP.

Now getting from with_iem data against the remaining document numbers.

SELECT * FROM with_item FOR ALL ENTRIES IN ibkpf

WHERE bukrs = p_bukrs

AND belnr = ibkpf-belnr

AND gjahr = p_gjahr

AND wt_acco IN s_lifnr

AND wt_withcd IN s_taxc

AND witht IN S_WITHT.

If some one has experience in withholding tax reports,he can check my code and suggest some other logic as our data base is not too heavy at this time still report is very slow.

Thank you

1 REPLY 1

Former Member
0 Kudos
73

Hi Nouman,

For performance related issue,please select only required entries because use of *SELECT ** will degrade its performance.

Make a structure and avoid using CORRESPONDING FIELDS OF .

Regards,

Praveen