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

Text Elements

Former Member
0 Likes
1,924

Dear all,

What would be the string search code to read the Text Literal in a report program with the Text Elements in the report. This is for a qaulity check program that has to take out the miss mached Text Element to the Text Literal.

eg : wirte :/'Element'(text-001).

Note : The text literal "Element" must be compaired with the text in text element text-001.

Regards,

Jeswin

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,327

Hi,

We can compare like this.For Example..

DATA : I_TEXTELEMENT TYPE TABLE OF TEXTPOOL WITH HEADER LINE.

DATA : I_RESULT TYPE TABLE OF TY_RESULT WITH HEADER LINE.

READ REPORT P_TEXT INTO I_data.

READ TEXTPOOL P_TEXT INTO I_TEXTELEMENT LANGUAGE SY-LANGU.

loop at i_data.

if I_data-LINE cp '''''*'.

i_program-line = i_data-line.

append i_program.

endif.

endloop.

LOOP AT I_TEXTELEMENT.

LOOP AT I_PROGRAM.

SEARCH I_PROGRAM-LINE FOR I_TEXTELEMENT-ENTRY.

IF SY-SUBRC EQ 0.

LEN = STRLEN( I_TEXTELEMENT-ENTRY ) + 1.

POS = SY-FDPOS.

STR = I_PROGRAM+POS(LEN).

SHIFT STR RIGHT DELETING TRAILING ''''.

CONDENSE STR NO-GAPS.

ACTLEN = STRLEN( I_TEXTELEMENT-ENTRY ).

COMPLEN = STRLEN( STR ).

IF ACTLEN = COMPLEN.

I_RESULT-ENTRY = I_TEXTELEMENT-ENTRY.

I_RESULT-STATUS = 'T'.

APPEND I_RESULT.

ENDIF.

ENDIF.

ENDLOOP.

ENDLOOP.

And for the result

loop at i_result.

loop at i_textelement where entry = i_result-entry or id = ''.

i_result-id = i_textelement-id.

i_result-key = i_textelement-key.

modify i_result from i_result.

endloop.

endloop

please try with this ,this string search will give you the mismatching.

Reward points are usefull.

Thanks,

Sandhya.

3 REPLIES 3
Read only

Former Member
0 Likes
1,328

Hi,

We can compare like this.For Example..

DATA : I_TEXTELEMENT TYPE TABLE OF TEXTPOOL WITH HEADER LINE.

DATA : I_RESULT TYPE TABLE OF TY_RESULT WITH HEADER LINE.

READ REPORT P_TEXT INTO I_data.

READ TEXTPOOL P_TEXT INTO I_TEXTELEMENT LANGUAGE SY-LANGU.

loop at i_data.

if I_data-LINE cp '''''*'.

i_program-line = i_data-line.

append i_program.

endif.

endloop.

LOOP AT I_TEXTELEMENT.

LOOP AT I_PROGRAM.

SEARCH I_PROGRAM-LINE FOR I_TEXTELEMENT-ENTRY.

IF SY-SUBRC EQ 0.

LEN = STRLEN( I_TEXTELEMENT-ENTRY ) + 1.

POS = SY-FDPOS.

STR = I_PROGRAM+POS(LEN).

SHIFT STR RIGHT DELETING TRAILING ''''.

CONDENSE STR NO-GAPS.

ACTLEN = STRLEN( I_TEXTELEMENT-ENTRY ).

COMPLEN = STRLEN( STR ).

IF ACTLEN = COMPLEN.

I_RESULT-ENTRY = I_TEXTELEMENT-ENTRY.

I_RESULT-STATUS = 'T'.

APPEND I_RESULT.

ENDIF.

ENDIF.

ENDLOOP.

ENDLOOP.

And for the result

loop at i_result.

loop at i_textelement where entry = i_result-entry or id = ''.

i_result-id = i_textelement-id.

i_result-key = i_textelement-key.

modify i_result from i_result.

endloop.

endloop

please try with this ,this string search will give you the mismatching.

Reward points are usefull.

Thanks,

Sandhya.

Read only

Former Member
0 Likes
1,327

Hi Jeswin,

are u looking for this to compare text element value with a literal

REPORT ychatest2.

WRITE : text-001.    " i had given text-001 as Equal

IF text-001 EQ 'Equal'.
  WRITE : 'equal'.
ENDIF.

Read only

Former Member
0 Likes
1,327

hi,

Text elements allow you to store texts without hard-coding them in your program. You can maintain text elements outside the program in which they are used (choose Goto → Text elements in the Editor). They are particularly important for texts in applications that will be translated into other languages.

All programs (including include program) have a title. Other text elemen are assigned to the associated main program.

ABAP has the following kinds of text element:

Program title

List heading

Column heading

Selection texts (for texts belonging to selection criteria and program parameters)

Text symbols (constant texts)

The construction of text elements is defined by the structure TEXTPOOL. It contains the following fields:

ID:

A single character, representing the text element type. You can use the following values:

R - Program title

T - List heading

H - Column heading

S - Selection text

I - Text symbol

KEY:

Key field, which may contain the following values, depending on the type of the text element:

H - Number of a row with columns

-headings (001 - 004)

S - max. 8 character name of a selection

criterion or program parameter

I - 3 character number for a text symbol

The field is empty for program titles and list headings.

ENTRY:

Text of the text element (maximum 255 characters)

LENGTH:

Length of the text

Example

The following table displays some typical values for text elements:

ID KEY ENTRY LENGTH

H 001 Name Age 10

I 100 Tax 10

R , Test program 12

S CUST Customer 8

T , Sales 10

Notes

LENGTH determines the total available length for the text. If the text is to be translated into other languages, you should choose a value of LENGTH that is greater than the length required in the original language, to allow for translations that are longer than the original language version.

You can address text elements in two ways, either using TEXT-xxx or using '...'(xxx). Here, xxx stands for the number, and ... for the text of the text symbol.

The first form requires that there is already a text for number xxx. If there is not, the output is empty.

The second form improves the readability of the program. The text in inverted commas should correspond to the text stored under the text symbol. If it does not, the system uses the text stored for the text symbol. Exception: If there is no text saved under number xxx, the text in inverted commas is used.

Example: Text symbol number 001 has the text 'Please enter your name'. The following commands:

WRITE: / TEXT-001,

/ 'Please enter your name'(001),

/ 'What is your name?'(001).

all have the same output: "Please enter your name".

You can compare the texts used in the program with the texts stored as text symbols by choosing "Goto → Text elements → Compare text symbols" in the Editor.

If you set a LENGTH for the text element that is longer than the text itself, this is interpreted as though the text had trailing spaces up to the specified LENGTH. This means that if you use the notation '...'(xxx), the text between the inverted commas must have trailing zeros up to the length LENGTH. Otherwise, the text stored under the text symbol will not correspond with the text in inverted commas (see note 2).

Example: Suppose text symbol number 036 has the contents 'Name', and length 10. The following statement: folgende Befehl

WRITE: / SY-VLINE, TEXT-036, SY-VLINE,

/ SY-VLINE, 'Tax '(036), SY-VLINE,

/ SY-VLINE, 'Tax'(036), SY-VLINE.

would then output "| Tax |" three times. In particular, in the third line, the text symbol number 036 is output in length 10, and not the three-character text "Tax". If you compare the text elements (see note 2), the text symbols in the second and third lines are flagged as being different.

You should not use text symbols in subroutines that have more than one main program, since this leads to redundant text and unnecessary translation.

Instead, you should store these portions of code in subroutine pools.

thanks,

reward points if helpful...