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

code-

Former Member
0 Likes
891

Hi,

Anybody can give me any two or three line code on TRANSLATE. I want to check and execute that.

regards....

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
860

Hi

Data: v1(10) type c value 'ABCDEFGHIJ'.

<b>TRANSLATE v1 to lowercase.</b>

output is 'abcdefghij'.

Reward points if useful

Regards

Anji

7 REPLIES 7
Read only

Former Member
0 Likes
861

Hi

Data: v1(10) type c value 'ABCDEFGHIJ'.

<b>TRANSLATE v1 to lowercase.</b>

output is 'abcdefghij'.

Reward points if useful

Regards

Anji

Read only

Former Member
0 Likes
860

Hi Abhay,

go through the following code.

DATA: T(10) VALUE 'AbCdEfGhIj',

STRING LIKE T,

RULE(20) VALUE 'AxbXCydYEzfZ'.

STRING = T.

WRITE STRING.

TRANSLATE STRING TO UPPER CASE.

WRITE / STRING.

STRING = T.

TRANSLATE STRING TO LOWER CASE.

WRITE / STRING.

STRING = T.

TRANSLATE STRING USING RULE.

WRITE / STRING.

Read only

Former Member
0 Likes
860

Hello,

DATA: t(10) TYPE c VALUE 'AbCdEfGhIj',

string LIKE t,

rule(20) TYPE c VALUE 'AxbXCydYEzfZ'.

string = t.

WRITE string.

TRANSLATE string TO UPPER CASE.

WRITE / string.

string = t.

TRANSLATE string TO LOWER CASE.

WRITE / string.

string = t.

TRANSLATE string USING rule.

WRITE / string.

Regards,

Neelambari

Read only

Former Member
0 Likes
860

Hi Abhay,

Check this.

The TRANSLATE statement converts characters into upper or lower case, or uses substitution rules to convert all occurrences of one character to another character.

Converting to Upper or Lower Case

TRANSLATE <c> TO UPPER CASE.

TRANSLATE <c> TO LOWER CASE.

These statements convert all lower case letters in the field <c> to upper case or vice versa.

Substituting Characters

TRANSLATE <c> USING <r>.

This statement replaces all characters in field <c> according to the substitution rule stored in field <r> . <r> contains pairs of letters, where the first letter of each pair is replaced by the second letter. <r> can be a variable.

For more variants of the TRANSLATE statement with more complex substitution rules, see the keyword documentation in the ABAP Editor.

DATA: T(10) VALUE 'AbCdEfGhIj',

STRING LIKE T,

RULE(20) VALUE 'AxbXCydYEzfZ'.

STRING = T.

WRITE STRING.

TRANSLATE STRING TO UPPER CASE.

WRITE / STRING.

STRING = T.

TRANSLATE STRING TO LOWER CASE.

WRITE / STRING.

STRING = T.

TRANSLATE STRING USING RULE.

WRITE / STRING.

Output:

AbCdEfGhIj

ABCDEFGHIJ

abcdefghij

xXyYzZGhIj

TRANSLATE ... TO UPPER/LOWER CASE

TRANSLATE ... USING

The arguments of these instructions must be single fields of type C, N, D, T or STRING or structures of character-type only. There is a syntax or runtime error if arguments of a different type are passed. A subset of this function is provided with the addition IN BYTE MODE for processing byte strings – that is, operands of type X or XSTRING. A statement such as CONCATENATE a x b INTO c is thus no longer possible when a,b, and c are all character-type, but x is of type X.

TRANSLATE ... CODEPAGE ...

TRANSLATE ... NUMBER FORMAT ...

The above statements are not allowed in Unicode programs. Instead, you can use the new conversion classes, which are described in more detail in Converting Data.

These classes are used to convert ABAP data from the system format to external formats and vice versa. During this conversion process, character-type data may be converted to another character set, while numeric-type data may be converted to another byte order (or endian format). You must use a container of type X or XSTRING for data in an external format.

Character sets and endian formats are also converted by the file interface (OPEN DATASET with new additions), RFCs, and the function modules GUI_DOWNLOAD and GUI_UPLOAD. The classes described below are available for those special cases where the possibilities offered by conversion are insufficient. Since these classes work with containers of types X and XSTRING, these containers can be copied unconverted by the file interface (OPEN DATASET with new additions), RFCs, and the function modules GUI_DOWNLOAD and GUI_UPLOAD. These classes replace the following two statements:

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

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

For a detailed description, see the class documentation in the Class Builder. The following classes are available:

CL_ABAP_CONV_IN_CE

Reads data from a container and converts it to the system format. You can also fill structures with data.

CL_ABAP_CONV_OUT_CE

Converts data from the system format to an external format and writes it to a container.

CL_ABAP_CONV_X2X_CE

Converts data from one external format to another.

Thanks.

Reward if it helps.

Read only

Former Member
0 Likes
860

hi

good

Converting to Upper or Lower Case

TRANSLATE text TO UPPER CASE.

TRANSLATE text TO LOWER CASE.

These statements convert all lower case letters in the field <c> to upper case or vice versa.

Substituting Characters

TRANSLATE text USING pattern.

This statement replaces all characters in the text field according to the substitution rule stored in pattern. pattern contains letter pairs where the first letter of each pair is replaced by the second. pattern can be a variable.

For more variants of the TRANSLATE statement with more complex substitution rules (obsolete variants!), refer to the keyword documentation.

DATA: t(10) TYPE c VALUE 'AbCdEfGhIj',

string LIKE t,

rule(20) TYPE c VALUE 'AxbXCydYEzfZ'.

string = t.

WRITE string.

TRANSLATE string TO UPPER CASE.

WRITE / string.

string = t.

TRANSLATE string TO LOWER CASE.

WRITE / string.

string = t.

TRANSLATE string USING rule.

WRITE / string.

thanks

mrutyun^

Read only

Former Member
0 Likes
860

Hi,

TRANSLATE Converts characters in strings.

Syntax

TRANSLATE <c> TO UPPER|LOWER CASE

|USING <r>.

The characters of the string <c> are converted into upper- or lowercase, or according to a

substitution rule specified in <r>.

DATA: T(10) VALUE 'AbCdEfGhIj',

STRING LIKE T,

RULE(20) VALUE 'AxbXCydYEzfZ'.

STRING = T.

WRITE STRING.

TRANSLATE STRING TO UPPER CASE.

WRITE / STRING.

STRING = T.

TRANSLATE STRING TO LOWER CASE.

WRITE / STRING.

STRING = T.

TRANSLATE STRING USING RULE.

WRITE / STRING.

Output:

AbCdEfGhIj

ABCDEFGHIJ

abcdefghij

xXyYzZGhIj

Regards,

Bhaskar

Read only

Former Member
0 Likes
860

my question has been answered by some great people of sdn.

Thanks