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: 

upper to lower case

Former Member
0 Kudos

is there any function module to manage upper case and lower cases

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Rasheed,

Try this FM to convert from lower case to upper case .

TERM_TRANSLATE_TO_UPPER_CASE

regards,

Raghav

7 REPLIES 7

Former Member
0 Kudos

make use of keyword

TRANSLATE Character conversion incharacter fields

Regards

Prabhu

Former Member
0 Kudos

Hi,

Use translate command:

Translate f1 into lowercase/uppercase.

Jogdand M B

Former Member
0 Kudos

Hi,

DATA letters(3) TYPE C.

MOVE 'abc' TO letters.

TRANSLATE letters TO LOWER CASE.

For more infromation...

TRANSLATE

Variants:

1. TRANSLATE c TO UPPER CASE.

2. TRANSLATE c TO LOWER CASE.

3. TRANSLATE c USING c1.

4. TRANSLATE c ...FROM CODE PAGE g1... TO CODE PAGE g2.

5. TRANSLATE f ...FROM NUMBER FORMAT n1... TO NUMBER FORMAT n2.

Note

Like all string processsing statements, you can only use character-type operands here.

If the type of an operand is not STRING, the operand is treated like a type C field, regardless of its actual type, even though no actual conversion takes place.

In an ABAP Objects context, a more severe syntax check is performed that in other ABAP areas. See Only character fields allowed in string processing.

Variant 1

TRANSLATE c TO UPPER CASE.

Variant 2

TRANSLATE c TO LOWER CASE.

Effect

The first variant converts all lowercase letters in c to uppercase. The second variant converts all uppercase letters to lowercase.

Example

DATA letters(3) TYPE C.

MOVE 'abc' TO letters.

TRANSLATE letters TO UPPER CASE.

letters now has the contents 'ABC'.

Note

The classification of upper- and lowercase, and the actual characters used are determined by the current text environment (see SET LOCALE LANGUAGE).

Variant 3

TRANSLATE c USING c1.

Effect

Translates the contents of c according to the rule in field c1.

When a character from c corresponds to a character from c1, it is replaced by the next character that occurs in c1. If the character appears more than once in c1, its first occurrence is used in the replacement. If a character from c does not occur in c1, it remains unchanged.

Example

DATA: letters(20) TYPE C VALUE 'abcabcabcXabc',

change(15) TYPE C VALUE 'aXbaYBabZacZB'.

TRANSLATE letters USING change.

letters now contains 'XaZXaZXaZXXaZ'.

Variant 4

TRANSLATE c ...FROM CODE PAGE g1 ...TO CODE PAGE g2.

Parts marked with " ..." are interchangeable

TRANSLATE c TO CODE PAGE g2.

TRANSLATE c FROM CODE PAGE g1.

Effect

Converts the contents of the field c from character set g1 to character set g2. This variant uses the conversion table g1 to determine the SAP character, which is then used to determine the new character from g2.

Transaction SPAD allows you to display and maintain character sets. If one of the conversion tables does not exist, the runtime error CONVERSION_CODEPAGE_UNKNOWN occurs. Conversion combinations that are maintained as part of the runtime system for performance reasons do not trigger runtime errors, and you cannot change them using Transaction SPAD.

Example

DATA c(72) TYPE C.

TRANSLATE c FROM CODE PAGE '1110' TO CODE PAGE '0100'.

This statement converts the contents of field c from the HP-UX character set to IBM EBCDIC.

Note

Fields with types I, P, F, and X remain unchanged by the conversion. The syntax check only allows character fields for specifying the codepage. However, since the codepage is maintained in table TCP00 as a type N field with length 4, you should use this type.

Variant 5

TRANSLATE f ...FROM NUMBER FORMAT n1 ...TO NUMBER FORMAT n2.

Parts marked with " ..." are interchangeable

TRANSLATE f TO NUMBER FORMAT n1.

TRANSLATE f FROM NUMBER FORMAT n1.

Effect

Converts the number formats in f. Currently, the number formats '0000' (HP, SINIX, IBM) and '0101' (DEC-alpha OSF) are supported. Other formats trigger the runtime error TRANSLATE_WRONG_NUM_FORMAT . If you omit FROM NUMBER FORMAT or TO NUMBER FORMAT, the system uses the system number format.

Example

DATA: f TYPE F,

hex(2) TYPE X,

nform LIKE tcp00-cpcodepage.

...

  • The contents of fields hex and f are stored in /ARCHIV

  • from another platform. hex is stored in a valid number

  • form when it is saved, and can therefore be read on

  • all platforms.

READ DATASET '/ARCHIV' INTO hex.

READ DATASET '/ARCHIV' INTO f.

nform = hex. "Conversion from non-host-specific. HEX into N(4)

TRANSLATE f FROM NUMBER FORMAT nform.

Effect

Converts the contents of f from the nform format of a given platform into the system representation.

Note

This converts fields with types I and F. As in variant 4, you should define the number formats with type N and length 4.

You can display system codepage and number formats using the function module SYSTEM_FORMAT. This allows you to store additional information for archiving purposes.

Note

Performance:

Converting lowercase letters to uppercase (or the other way round) in a 10 byte character field requires around 7 msn (standardized microseconds).

If you use ... c USING c1... to replace two characters of a 10 byte character field,the runtime is around 9 msn.

Note

Runtime errors:

TRANSLATE_WRONG_NUM_FORMAT: Invalid number format.

Don't forget to reward

Faaiez
Advisor
Advisor
0 Kudos

You can use the ABAP command TRANSLATE as follows:

DATA text TYPE string. 
text = `Careful with that Axe, Eugene`. 
TRANSLATE text TO UPPER CASE.  or TRANLATE text TO LOWER CASE.

Regards

Former Member
0 Kudos

Hi rasheed,

Check this Function Module,

HR_P06I_CONVERT_TO_LOWERCASE.

Thanks.

Reward If Helpful.

kiran_k8
Active Contributor
0 Kudos

Rasheed,

CALL FUNCTION 'STRING_UPPER_LOWER_CASE

K.Kiran.

Former Member
0 Kudos

Hi Rasheed,

Try this FM to convert from lower case to upper case .

TERM_TRANSLATE_TO_UPPER_CASE

regards,

Raghav