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

Replace a string

Former Member
0 Likes
1,426

Hi ,

I need to replace a string as per the example below.

w_string = ' Varenr800294TC59 ROSINER! Mål/Vægt '.

In this string mentioned above , i need to replace the 2 character 'a' to different color.

Can some one help me with this.

15 REPLIES 15
Read only

Former Member
0 Likes
1,393

Hi Vijay,

Not clear to your question. Do you want to REPLACE a string with some other character? What do you mean by

 i need to replace the 2 character 'a' to different color.

Please explain.

Thanks,

Amol

Read only

0 Likes
1,393

Hi

Thanks for your reply.

For example.

I have a string w_string = ' Varenr800294TC59 ROSINER!Mål/Vægt'.

In this string , i have to highlight the 2 character wstring+0(2) with a different color .

How can i do this.

Read only

0 Likes
1,393

This string is shown in the pop up screen

Read only

0 Likes
1,393

Hi,

I dont think it is possible in a pop-up screen..

Read only

0 Likes
1,393

It is not necessary that i must highlight with different color.

Any highlight options in the pop up is fine for that character.

Read only

0 Likes
1,393

Hi,

When you are saying its a pop-up do you mean that its an information box or a window that you are displaying..

Read only

0 Likes
1,393

This is only possible during list processing using options like

FORMAT COLOR COL_BACKGROUND or COL_NEGATIVE or COL_POSITIVE etc.

Do F1 help on FORMAT.

Read only

0 Likes
1,393

It is not an information window.This is a normal window.

I am calling this FM COPO_POPUP_TO_DISPLAY_TEXTLIST to display the string.

Read only

0 Likes
1,393

Hi,

Please try this to highlight the code:

WRITE: / listtab+6(lv_len) COLOR COL_NEGATIVE<----- You may also use COL_POSITIVE

Read only

0 Likes
1,393

Even you can try below options for different colors.

WRITE  w_string+6(2) COLOR COL_TOTAL. " COL_NORMAL." COL_GROUP." COL_POSITIVE.

Thanks,

Amol

Read only

0 Likes
1,393

Hi ,

Thanks all for the replies.

If i use this ,

Then i only see the colored character as output.

But i need the full string as output with the formatted character colored.

Read only

0 Likes
1,393

What you can do is you can read the entire string and find the position of the character you want to color... Then color it accordingly...



 LOOP AT so_name.
      lv_len = strlen( so_name-low ).
      CLEAR lv_pos.
      WHILE lv_pos LT lv_len.
        lv_c = so_name-low+lv_pos(c_no).
        lv_pos = lv_pos +  1.
        IF c_wild CA lv_c.  <--- Check for your character here
set the color here 

           REFRESH so_name.
          CLEAR so_name.
          EXIT.
        ENDIF.
      ENDWHILE.
    ENDLOOP.

Amol: Whatever you mentioned has been written earlier...

Read only

0 Likes
1,393

I think below code will be useful to you.

WRITE :/ w_string+0(6) COLOR COL_POSITIVE, w_string+6(1) COLOR COL_GROUP, w_string+6(27) COLOR COL_TOTAL.

Thanks,

Amol

Read only

Former Member
0 Likes
1,393

Hi,

Is this a text which is displayed in your ALV cell... I mean you want to change the a's to a different COLOR.... If you want to do this ..

Read only

Former Member
0 Likes
1,393

DATA col TYPE i VALUE 0.

data : string(100) type c value 'abcdefghijkl'.

col = 1.

WRITE: / string+0(5).

FORMAT COLOR = col.

write: string+5(3).

format color off.

write: string+8(92).