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: 

How to link BSEG item to its corresponding BSET items?

Former Member
0 Kudos

Hi All,

I want to associate BSEG line item to its tax amount (which exist as multiple line items in BSET). I sum up the amount for each BSET-TXGRP but cannot associate to which BSEG-BUZEI does a BSET-TXGRP belong to.

Is there any way to get the tax line items (in BSET) of an existing tax document for a particular line item of accounting document (BSEG).

I know that,

BSEG-BUKRS = BSET-BUKRS

BSEG-BELNR = BSET-BELNR

BSEG-GJAHR = BSET-GJAHR,

but

BSEG-BUZEI <> BSET-BUZEI

also,

BSEG-TXGRP may not correspond to correct BSET-BUZEI.

I found 'CALCULATGE_TAX_DOCUMENT' FM which calculates tax amount as required. But the reason I cannot rely on this is because possible tax code changes could lead to different calculated amount than that of in the tax document.

I have been searching several posts and links but no where did I get any solution. Can anyone suggest any function modules to fetch tax data of a bseg line item instead of newly calculating it using calculation function modules?

Regards,

Priyanka S.

1 ACCEPTED SOLUTION

Former Member

Hi

But why you need to link BSET with BSEG?

Max

15 REPLIES 15

former_member188724
Contributor
0 Kudos

Hi,

Can you pls try using FM's

* bseg fill

CREATE_BSET_ITEM &

* bseg fill (tax line)

CREATE_TAX_ITEM 

whether it helps your requirement.

Regards,

K.S.

0 Kudos

Hi K.S.,

Thanks, but this does not help my requirement.

Regards,

Priyanka S.

VenkatRamesh_V
Active Contributor
0 Kudos

Hi,

Hope it help full.

Check the table WITH_ITEM

Regards,

Venkat.

0 Kudos

Hi Venkat,

Thanks. I want the tax calculated using the tax code and not withholding tax codes.

Regards,

Priyanka Salvi

Former Member

Hi

But why you need to link BSET with BSEG?

Max

0 Kudos

Hi Max,

The reporting requirement is to show tax amount against each invoice item with tax code.

Regards,

Priyanka S.

0 Kudos

Ok

There's no a particular link between BSEG item and BSET item, if a tax code is used in an accounting document, the tax data will be saved in BSET table.

So you should explain how you need to arrange your program

If tax amount is not zero, the item with BSEG-BUZID = 'T' should be created, so perhaps it's the link you're looking for, but if the tax amount is zero no item will be saved in BSEG, but tax data will be in BSET.

I believe the only good link is the TAX CODE

Max

0 Kudos

Hi Max,

Thanks a lot. Using this field I can get those items in BSEG for which tax item is available in BSET.

Rest I think for those items, I will have to match using amount and tax code. I hope that should work out.

Regards,

Priyanka S.

0 Kudos

Hi

You can try to use TXGRP: BSET-TXGRP = BSEG-TXGRP


In this way you should have the reference between BSET and BSEG


Max

0 Kudos

Hi Max,

Thanks again. I had check this linkage but unfortunately our development system did not have value in it so I had discarded that option. Now I checked our production system has values in BSEG-TXGRP.

So the solution would be,

1.  From EKBE table, get invoice line items where EKBE-VGABE = '2'.

2. concatenate (EKBE-LFGJA  EKBE-LFBNR EKBE-LFPOS) into WA_INV_XREF3.

3. From BSEG table, get corresponding line item of invoice item using,

               BSEG-XREF3 = WA_INV_XREF3.

4. Get BSET items using, BSET-BELNR =  BSEG-BELNR and same fiscal yr and company code.

5. Sum up tax amounts in BSET for each TXGRP.

6. Finally, associate BSET and BSET as : BSEG-TXGRP = BSET-TXGRP.

(note that, other clauses like company code, fiscal yr, etc are to be included in queries)

Thanks for the help.

Regards,

Priyanka S.

0 Kudos

Hi

If you need to start from Purchase Order:


1.  From EKBE table, get invoice line items where EKBE-VGABE = '2'.

2. concatenate (EKBE-LFGJA  EKBE-LFBNR EKBE-LFPOS) into WA_INV_XREF3.

3. From BSEG table, get corresponding line item of invoice item using,

               BSEG-XREF3 = WA_INV_XREF3.

No you should use the right link:


1.  From EKBE table, get invoice line items where EKBE-VGABE = '2'.

This steo is ok


2. concatenate (EKBE-LFGJA  EKBE-LFBNR EKBE-LFPOS) into WA_INV_XREF3.

It's not good solution, if you want to get vendor invoice:


2. concatenate EKBE-BELNR EKBE-GJAHR into WA_AWKEY

so


3. SELECT * UP TO 1 ROWS

       FROM BKPF

          WHERE AWTYP  = 'RMRP'

                AND AWKEY = WA_AWKEY.

    ENSELECT.                     

Now you have Accounting document (Vendor Invoice), probably (if you want to Tax data only) you don't need to read BSEG, but BSET only:


4. So read BSET where

    BSET-BUKRS = BKPF-BUKRS

   BSET-BELNR = BKPF-BELNR 

   BSET-GJAHR = BKPF-GJAHR

Max

0 Kudos

Hi Max,

This solution I have used since I am also fetching the accounting header document using AWKEY whereas I used XREF3 to fetch the exact GR/IR line item from accounting document to map it against the invoice.

Thanks again.

Regards,

Priyanka Salvi

Former Member
0 Kudos

hi,

   For tax detail select fields from BSET table with reference of acc Document Number which you got from BKPF table. follow the below example

SELECT BELNR GJAHR BUZEI TXGRP SHKZG HWBAS HWSTE KSCHL FROM BSET

CLIENT SPECIFIED INTO CORRESPONDING FIELDS OF TABLE IST_BSET

FOR ALL ENTRIES IN IST_BKPF

WHERE MANDT   = SY-MANDT

AND       BELNR   = IST_BKPF-BELNR .

then use the internal table IST_BSET in the loop . then which tax you wants show using the condition type you got value of the tax like the below example.

READ TABLE IST_BSET INTO WA_BSET WITH KEY BELNR = WA_BKPF-BELNR

                                                                                       TXGRP = TXGRP

                                                                                        KSCHL = 'JMOP'.

       IF SY-SUBRC = 0 .

         WA_OUTPUT-BED = WA_BSET-HWSTE.

       ENDIF.

Regards,

Mukesh

0 Kudos

Hi Mukesh,

Thanks, but I do not have the value of condition type before hand. There is condition type in RSEG but the value differs in BSET.

Regards,

Priyanka S.

former_member388312
Discoverer
0 Kudos

Hi Priyanka,

You mapped BSEG-TXGRP with BSET-TXGRP where you can get tax with line items

Regards

Sandip