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

BDC problem with decimal (Amount field)

Former Member
0 Likes
3,278

Hi experts,

I have a problem with decimal when recording BDC for TCode VK11 as following (Unit of measure EA):

1. I recorded the BDC with Unit = 'USD' (has 2 decimals)

2. It worked fine with Unit USD or like USD (means have 2 decimals)

3. But it had problem with Unit which does not allow decimal (like JPY - Japan...)

Do we have a function module with input is Unit and output is the format of the Amount field?

Thanks,

Khanh

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,010

Hi,

This is very common problem faced in BDC programming.

What you should do is:

1Create a variable l_curr type char15.

2. Select the currency type. I assume it'sa company code currency in your case, so select the currency type from t001 based on company code.

3 Write for eg l_tab-wrbtr ( your currency field in BDC ) to l_curr CURRENCY l_ too1-werks.

This will automatically place correct currency decimals in l_curr and then pass this field in BDC currency field

Hi experts,

I have a problem with decimal when recording BDC for TCode VK11 as following (Unit of measure EA):

1. I recorded the BDC with Unit = 'USD' (has 2 decimals)

2. It worked fine with Unit USD or like USD (means have 2 decimals)

3. But it had problem with Unit which does not allow decimal (like JPY - Japan...)

Do we have a function module with input is Unit and output is the format of the Amount field?

Thanks,

Khanh

8 REPLIES 8
Read only

Former Member
0 Likes
2,011

Hi,

This is very common problem faced in BDC programming.

What you should do is:

1Create a variable l_curr type char15.

2. Select the currency type. I assume it'sa company code currency in your case, so select the currency type from t001 based on company code.

3 Write for eg l_tab-wrbtr ( your currency field in BDC ) to l_curr CURRENCY l_ too1-werks.

This will automatically place correct currency decimals in l_curr and then pass this field in BDC currency field

Read only

0 Likes
2,010

Hi Anurag_n,

Your solution sounds good.

Could you please give me more detail or some sample code?

Thanks,

Khanh

Read only

0 Likes
2,010

I think it's kind of pseudo code only :)... Try it and ask me if face any problem

Read only

0 Likes
2,010

Hi Anurag_n,

I tried with a z program as following.

But the output is still 152 in this case because as my undestanding, the output is 152.00

Please advise:

REPORT Z_TEST.
DATA: l_curr type char15.
DATA: l_betr(132) type c.

l_betr = '152'.
Write l_betr to l_curr CURRENCY 'USD'.

WRITE l_curr.

Thanks,

Khanh

Read only

0 Likes
2,010

My guess here is l_betr you have defined as character field. Move currency field to l_curr.

Read only

Clemenss
Active Contributor
0 Likes
2,010

Hi Khan,

what is the data source?

If you do have Japanese Yen in the input, they probably won't have decimals. You did not tell us what kind of problem you have.

As said, you will always get correct format with WRITE TO and option CURRENCY,

anurag probably intended to suggest

WRITE tab-wrbtr  TO l_curr CURRENCY l_ too1-WAERS. "WAERS is currency unit, Not WERKS, thats plant

Regards,

Clemens

Read only

Former Member
2,010

Hi,

You two are correct.

DATA: l_curr type char15.
DATA: lv_rate TYPE waers VALUE 'JPY'.
DATA: lv_kbetr TYPE konp-kbetr VALUE '152.12'.

Write lv_kbetr to l_curr CURRENCY lv_rate.

WRITE l_curr.

The output is now 15,212

But this is not my problem, I need to clarify it once again.

In VK11, I can create more than 2 price conditions at once time.

I recorded a BDC with 2 price conditions at a time

--> the first one used USD with 2 decimals

--> the second one used JPY with 0 decimals

BUT when I call the BDC to save price conditions which has 0 decimals, it always through error 'Decimal places are not permitted'.

Could you please help me how to resolve this problem?

Thanks,

Khanh

Read only

Former Member
0 Likes
2,010

Hi all,

I resolved my issue.

The reason: When recording BDC, I moved the cursor to Amount field first, key in then I moved the cursor to Unit field --> The amount field automatically added decimals into the amount field.

Change the position of these two fields in BDC can resolve the problem.

Thank you all for your support.

Thanks,

Khanh