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: 

Convert String to QUAN, INT1, UNIT

Former Member
0 Kudos

Hello,

Can anyone help me out with conversion String to QUAN, INT1 and UNIT?

Are there FMs available for this standard conversion?

Thanks.

Regards,

Chris Bogers

1 ACCEPTED SOLUTION

jack_graus2
Active Contributor

For QUAN fields like MARA-NTGEW that have a unit like MARA-GEWEI assigned you can use:

WRITE mara-ntgew TO s UNIT mara-gewei.

This formats the number in the correct formatting as defined in unit customizing and user settings.

Same for integer (here i):

WRITE i TO s.

Regards Jack

6 REPLIES 6

jack_graus2
Active Contributor

For QUAN fields like MARA-NTGEW that have a unit like MARA-GEWEI assigned you can use:

WRITE mara-ntgew TO s UNIT mara-gewei.

This formats the number in the correct formatting as defined in unit customizing and user settings.

Same for integer (here i):

WRITE i TO s.

Regards Jack

0 Kudos

Hi Jack,

When I write the string to QUAN field I got the following message:

Field "UNIT" is unknown. It is neither in one of the specified tables

nor defined by a "DATA" statement. "DATA" statement.

CODE:

WRITE str2 TO UNIT lw_zchapter-arbei.

Thanks & Regards,

Chris

0 Kudos

Hello Chris,

Just insert a local data before the reserved word "UNIT". (data:lv_temp type mara-gewei).

CODE should be :

data:lv_temp type mara-gewei

WRITE str2 TO lv_temp UNIT lw_zchapter-arbei.

Syntax:

[UNIT unit]

Good Luck,

Boaz

0 Kudos

Sorry for reading your question not correctly. When I read it better a solution might be:

DATA tabfield TYPE tabfield.

tabfield-tabname    = 'MARA'.
tabfield-fieldname  = 'NTGEW'.

CALL FUNCTION 'RS_CONV_EX_2_IN'
  EXPORTING
    input_external                     = '1.222,333'
    table_field                        = tabfield
  IMPORTING
    output_internal                    = mara-ntgew.

My user number format is set to 1.234.567,89

Regards Jack

0 Kudos

Hello guys,

Both instructions are not working.

Table: /IDEO/ZCHAPTER

Field: ARBEI

Data Element: ARBEIT

Data Type: QUAN

Length: 7

Decimal: 1

Any other ideas because ít's not working.

Thanks & Regard,

Chris Bogers

I solved the issue by using the following code:

SELECT SINGLE dcpfm "Decimal notaion

FROM usr01 "User master record (runtime data)

INTO l_user_decimal

WHERE bname EQ sy-uname.

CASE l_user_decimal.

WHEN ' '. " Decimal point is comma: N.NNN,NN

TRANSLATE str USING '. '.

TRANSLATE str USING ',.'.

WHEN 'X'. " Decimal point is period: N,NNN.NN

TRANSLATE str USING ', '.

WHEN 'Y'. " Decimal point is N NNN NNN,NN

TRANSLATE str USING ',.'.

ENDCASE.

CONDENSE str NO-GAPS.

amount = str.

Thanks & Regards,

Chris