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

handle separator in string variable

Former Member
0 Likes
1,839

hi everyone

Im receiving lines containing quantity fields and amount fields.

Both fields can have dot and comma as separator

and space as thousand separator

like

249 522,99

149,637.81

145,89,56

Im trying to use a TRANSLATE, but the comma , space and dot are getting interchanged

can anybody help please?

14 REPLIES 14
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
1,713

What is the requirement..? If you want to format "," or "." then go for write to and move to statment.

Nabheet

Read only

0 Likes
1,713

hi

there should be comma as decimal separator and dot as thousand separator

Read only

0 Likes
1,713

This can be handled via user setting default also..or use write to statment press f1 and you will be able to find..

Nabheet

Read only

0 Likes
1,713

Hi Prema,

What is the purpose of using the TRANSLATE? Are you using it to convert to the correct separator format or for some other purpose.

Regards,

Immanuel.

Read only

0 Likes
1,713

im using it to convert to he correct format

Read only

0 Likes
1,713

I tried this code andit works.

 DATA:lv_char TYPE dmbtr.

DATA:lv_char1 TYPE char10.

lv_char = '1210.10'.
  set country 'DE'.

WRITE lv_char TO lv_char1.

WRITE lv_char1.

Nabheet

Read only

Former Member
0 Likes
1,713

HI,

U can set the user profile.

Goto System->User Profile->Own Data--->Defaults.

Here u can set the "Decimal Notation" field.

Read only

0 Likes
1,713

hi

it should not be based on user notation

Read only

0 Likes
1,713

use write to with edit mast....or u can use set county command before write

nabheet

Read only

Former Member
0 Likes
1,713

Hi,

try this:


DATA: STR1 TYPE STRING.
DATA: DMBT TYPE DMBTR.
STR1 = '149,637.81'.
TRANSLATE STR1 USING ', . '.
CONDENSE STR1 NO-GAPS.
DMBT = STR1 / 100.
WRITE: / DMBT.

Regards, Dieter

Read only

matt
Active Contributor
0 Likes
1,713

My telepathy skills are week today. How have your tried using translate? What is your input, and what output do you expect?

It's really important to state your questions clearly, with relevant information. Otherwise the answers you get will be just guesses.

Read only

UmaArjunan
Active Participant
0 Likes
1,713

You are trying to Translate the workarea / variable containing the amount and quantity filed.

What is the output format you require in those fields for translation. ?

Give example of your output which is needed after translate ?

Thanks

ABAP Dev

Read only

Former Member
0 Likes
1,713

Maybe show us a piece of your code? Field definitions?

Read only

0 Likes
1,713

thanks evryone

I used if conditions and translate and its working nw