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

currency issue

Former Member
0 Likes
1,579

Guy's

i created BDC for tcode:ko01 ,it was working

fine ,but recently they discovered very strange issue

,when they run this BDC in background value of one

of the field which hold currency value get changed

for example 23.78 will become 23,78 and this result

in program failure ,while if they run program

in foreground ,it remain same,it's strange as issue

is only in one client ,it's working fine in other client

of same server,i check user profile also,but no use.

pls help as this is urgent

15 REPLIES 15
Read only

Former Member
0 Likes
1,500

hi

u need to ssee usr01 tabl to find the default deciaml notation

select single dcpfm

from usr01

into (v_decformat)

where bname = sy-uname.

case v_decformat.

when 'X'.

when ' '.

when 'Y'.

endcase.

handle the decimals as per ur req.

Read only

Former Member
0 Likes
1,500

Sanju,

Can you check this? While populating the currency value in your BDC tab, are you using this command?

WRITE <value> to BCDTAB-fval

CURRENCY <currency field WAERS>.

Read only

0 Likes
1,500

no i am not using any write command

Read only

0 Likes
1,500

guy's

issue is on what basis currency value got

changed to comma in background but not in foreground

Read only

0 Likes
1,500

guy's

i got the hint ,system is changing currency value

based on profile given while executing program in background ,now question is how to change decimal

value into value specified as per user profile,

i want all the value of my internal table for currency field to get changed based on user profile, like

select dcpfm from usr01 where bname = 'ZZBATCH'

IF dcpfm = ''

i want all my value of internal table to get changed

to this profile

Read only

0 Likes
1,500

Sanju,

Use that WRITE coomand then instead of just assigning with '=' sign. That will solve your problem (will take care of the decimal separator thing itself).

Read only

0 Likes
1,500

Have you tried WRITE? Is it not working in background? As far as I know it should take care of the decimal format based on user-profile.

Read only

Former Member
0 Likes
1,500

Hi Sanju,

Currency and Date formats are displayed based on the user record. tcode SU01.

So, if you dont change the format in your BDC, it will always problem with the default formats. So, try to use SAP internal formats rather than external display format.

Regards,

Ram

Read only

Former Member
0 Likes
1,500

Hi Sanju,

You always face such issues in BDC programs hence its better to take care of user profile issues.

Please take a reference from the following piece of code to determine the profile of the user.

FORM CONVERT-DEC.

tables : usr01.

data : field_num(10) type c value '123,456',

VAR_DCPFM type usr01-dcpfm.

SELECT SINGLE DCPFM FROM USR01

INTO VAR_DCPFM WHERE BNAME EQ SY-UNAME.

IF VAR_DCPFM EQ 'X'.

REPLACE ',' WITH '' INTO FIELD_NUM .

condense FIELD_NUM no-gaps.

ELSEIF VAR_DCPFM EQ ''.

REPLACE '.' WITH '' INto FIELD_NUM.

TRANSLATE FIELD_NUM USING ',.'.

ELSEIF VAR_DCPFM EQ 'Y'.

TRANSLATE FIELD_NUM USING ',.'.

ENDIF.

Cheers,

Vikram

Pls reward for helpful replies!!

Read only

0 Likes
1,500

HI Vikram

that was a nice program but try this thing in your system

report zuser01_curr .

tables : usr01.

data : field_num(20) type c value '123456333.556',

var_dcpfm type usr01-dcpfm.

select single dcpfm from usr01

into var_dcpfm where bname eq sy-uname.

if var_dcpfm eq 'X'.

replace ',' with '' into field_num .

condense field_num no-gaps.

elseif var_dcpfm eq ''.

replace '.' with '' into field_num.

translate field_num using ',.'.

elseif var_dcpfm eq 'Y'.

translate field_num using ',.'.

endif.

write field_num.

copy value of filed_num to coas-user4 ,check some of the

cases your program will not help me,i hope u got what

exactly i am trying to tell u

Read only

0 Likes
1,500

Sanju,

I am interested to know if WRITE doesnot solve your problem. Did you give it a try?

Read only

0 Likes
1,500

HI vikram

sorry your program work's fine , i kept decimal

to size of 3 ,u got ur point

Read only

Former Member
0 Likes
1,500

Hi Sanju,

There is an issue of 3 decimal places. Its hould be kept as 2 to retrieve data from COAS table based on field USER4.

What you can do is to move the your field into a another field of the data type USER4.

e.g.

data : field_num(20) type c value '123456333.556',

VAR_DCPFM type usr01-dcpfm,

field_num1 like coas-user4.

SELECT SINGLE DCPFM FROM USR01

INTO VAR_DCPFM WHERE BNAME EQ SY-UNAME.

IF VAR_DCPFM EQ 'X'.

REPLACE ',' WITH '' INTO FIELD_NUM .

condense FIELD_NUM no-gaps.

  • TRANSLATE FIELD_NUM USING ','.

ELSEIF VAR_DCPFM EQ ''.

REPLACE '.' WITH '' INto FIELD_NUM.

  • TRANSLATE FIELD_NUM USING '.'.

TRANSLATE FIELD_NUM USING ',.'.

ELSEIF VAR_DCPFM EQ 'Y'.

TRANSLATE FIELD_NUM USING ',.'.

ENDIF.

field_num1 = field_num.

write : FIELD_NUM1.

Cheers,

Vikram

Pls reward for helpful replies!!

Read only

Former Member
0 Likes
1,500

Hi Sanju,

I am seeing that you have assigned and then unassigned the points. Please do let me know if there is any concern. Tx.

Cheers,

Vikram

Please reward for helpful replies!!

Read only

0 Likes
1,500

hi vikram

program work fine,but i will tell u the cases where

it got failed .will send u test cases immediatly,

pls don't take it wrong,i don't won't to close this

thread ,until and unless my issue is not solved