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: 

Custom field - Local Net Value Billing

antonio_bruno
Participant
0 Kudos

Hello,

Could you please help me to understand how calculate correctly, in a query, the net value of billing in the system currency?

I've created the custom field Local-Net Value = VBRP-NETWR * VBRK-KURRF.

But, when i executed the query i had the following situations:

- The correct value when the exchange rate is from EUR to another currency.

- The value incorrectly when the exchange rate is from another currency to EUR, (the exchange rate, VBRK-KURRF, is expressed as a dividend).

Thank you in advance.

Best regards.

Antonio

11 REPLIES 11

former_member222709
Contributor
0 Kudos

Hi Anotnio,

The following should help you.

Link: [;

Regards,

Pranav.

0 Kudos

Hi Pranav,

thanks for your help.

I'm not an expert of ABAP. What's the code that can i use to convert the values from other currency to EUR? Where i can insert this code in the infoset (SQ02)?

Thanks.

Best regards.

Antonio

0 Kudos

Hi Antonio ,



DATA: V_LA  type vbrk-netwr,
      V_FA type vbrk-netwr,
      rate type vbrk-kurrf.



 
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
  EXPORTING
  CLIENT                         = SY-MANDT
    date                         = SY-DATUM
    foreign_amount               = V_FA              " Foreign Amount 
    foreign_currency             = 'USD'             " Foreign Currency Key
    local_currency               = 'EUR'             " Local Currency Key 
    RATE                         = Rate              " Exchange Rate 
 IMPORTING
   LOCAL_AMOUNT                  = V_LA              " Local Amount 

IF sy-subrc = 0.
  

*Map this V_LA  value to your final field .

ENDIF.

Regards,

Maruthi

Edited by: maruthi kona on Oct 25, 2011 10:27 PM

Edited by: maruthi kona on Oct 25, 2011 10:28 PM

0 Kudos

Hi Maruthi,

i've added the code in the infoset (SQ02), but i can't generate the infoset because there's the error "SY-SUBRC" is not expected.

Thanks.

Antonio

0 Kudos

HI ,

Remove the below Lines and check .

IF SY-SUBRC = 0.

ENDIF.

Regards ,

Maruthi

0 Kudos

Hi,

i've removed the two lines in the infoset (SQ02) and all is ok.

But when i tried to add the additional field V_LA (SQ02), SAP shown me "The DATA coding already contains a field with that name".

So, i've:

- modified the code:

DATA: V_FA type vbrk-netwr,

rate type vbrk-kurrf.

- add the field V_LA (Extras) and assigned it to a group, so the log advised me that "No code exists for additional field V_LA".

Now how can i add the LOCAL AMOUNT to my query?

Thanks.

Antonio

Edited by: Antonio Bruno on Oct 27, 2011 2:41 PM

0 Kudos

Hi Antonio,

Please go through the below link you will get some idea about query writing .

http://jelajahsap.files.wordpress.com/2008/01/abap-query.pdf

Regards,

Maruthi

0 Kudos

Hi,

now the infoset has no inconsitencies. I've add the code directly in "CodingForAddition" (Extras) in relation to the new field V_LA.

But when i executed the query, the local amounts (V_LA) are always equal to 0?

Thanks.

Antonio

0 Kudos

I've tried another solution, i've used the billing date as data. Now with thw following code:

DATA: V_DA type vbrk-fkdat,

V_FA type vbrk-netwr,

V_FC type vbrk-waerk,

rate type vbrk-kurrf.

CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'

EXPORTING

CLIENT = SY-MANDT

date = V_DA

foreign_amount = V_FA

foreign_currency = 'USD'

local_currency = 'EUR'

RATE = rate

IMPORTING

local_amount = V_LA.

When i executed the query, SAP shown me Message no. SG105 - the Enter rate USD / EUR rate type M for 00.00.0000 in the system settings.

The currency in the billing came from the table TCURR:

KURST - FCURR - TCURR - GDATU - UKURS - FFACT - TFACT

EURX - USD - EUR - 07.06.2010 - /1,15000 - 0 - 0

How can i fix the code?

Thank you.

Antonio

eduardo_hinojosa
Active Contributor
0 Kudos

Hi Antonio,

I suggest to see these notes:

SAP Note 155012 - Further subtotal fields in pricing

SAP Note 1022966 - FAQ for the 'Subto' column (KZWIW) in the pricing procedure

I think that perhaps they could suggest other way to solve it.

I hope this helps you

Regards

Eduardo

PD: Sorry, I understood it wrongly. Write


 IF sy-subrc = 0.
 ENDIF.                       "you don't have this line

Edited by: E_Hinojosa on Oct 26, 2011 3:07 PM

antonio_bruno
Participant
0 Kudos

Hi,

i've solved with the following code (options of field V_LA):

DATA: v_da TYPE vbrk-fkdat,

v_fa TYPE vbrk-netwr,

v_fc TYPE vbrk-waerk,

rate TYPE vbrk-kurrf.

CLEAR: v_fa, v_fc, v_la.

v_da = vbrk-fkdat.

v_fa = vbrp-netwr.

v_fc = vbrk-waerk.

CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'

EXPORTING

date = v_da

foreign_amount = v_fa

foreign_currency = v_fc

local_currency = v_lc

  • RATE = rate

  • TYPE_OF_RATE = 'EURX'

IMPORTING

local_amount = v_la.

and the following delimitation of the field V_LC (obligatory parameter) = VBRK-WAERK.

Best regards.

Antonio