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

Convert String to QUAN, INT1, UNIT

Former Member
0 Likes
6,375

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
Read only

JackGraus
Active Contributor
3,453

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

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

6 REPLIES 6
Read only

JackGraus
Active Contributor
3,454

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

Read only

Former Member
0 Likes
3,453

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

Read only

Former Member
0 Likes
3,453

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

Read only

JackGraus
Active Contributor
0 Likes
3,453

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

Read only

Former Member
0 Likes
3,453

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

Read only

Former Member
3,453

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