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

Syntax for Replace All Occurance in unicode environment

Former Member
0 Likes
2,296

Hi All,

Need some help here. As below is my syntax. However after i tried to activate it, it will give an error message: "In CHAR MODE a character-type, or in BYTE MODE a byte-type field is expected as the row type for the table "GT_FG" ". Please advice.

Syntax:

REPLACE ALL OCCURRENCES OF '--'
         IN TABLE gt_fg WITH `? ` IN CHARACTER MODE.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,797

Hi Shawn,

The table gt_fg nust be character type for this to work.

Replace the declaration of gt_fg with this.

DATA gt_fg type standard table of string.

Thanks,

Shambu

Hi All,

Need some help here. As below is my syntax. However after i tried to activate it, it will give an error message: "In CHAR MODE a character-type, or in BYTE MODE a byte-type field is expected as the row type for the table "GT_FG" ". Please advice.

Syntax:

REPLACE ALL OCCURRENCES OF '--'
         IN TABLE gt_fg WITH `? ` IN CHARACTER MODE.

10 REPLIES 10
Read only

Former Member
0 Likes
1,798

Hi Shawn,

The table gt_fg nust be character type for this to work.

Replace the declaration of gt_fg with this.

DATA gt_fg type standard table of string.

Thanks,

Shambu

Read only

0 Likes
1,797

Hi Shambu,

Thanks for your reply. Here is my declaration for my table as below. I am not sure whether can i change it into string. Please advice me.

DATA: BEGIN OF gt_fg OCCURS 0,
         matnr TYPE mchb-matnr,
         maktx LIKE makt-maktx,
         bklas LIKE mbew-bklas,                              " MOD4.4
         bismt LIKE mara-bismt,                              " MOD4.4
         lgort(4),
         lumi1(30),
         lumi2(30),
         lumi3(30),
         ctor1(30),
         ctor2(30),
         ctor3(30),
         fovo1(30),
         fovo2(30),
         fovo3(30),
         datcd(30),
         bestq(6),
         sgtxt(50),                                          "mod5
         gesme LIKE lqua-gesme,
       END OF gt_fg.

Read only

0 Likes
1,797

Do you want to replace the value '--' in all these fields?

Please check my reply below.

Thanks,

Shambu

Read only

0 Likes
1,797

Hi Shambu,

Yes, i would like to replace the value '--' in all of the fields. Please advice me. Thanks.

Read only

0 Likes
1,797

Did you try TRANSLATE keyword

Read only

0 Likes
1,797

Hi Karthik,

Perhaps could you give me an example on how to use the keyword TRANSLATE on my syntax?

Read only

0 Likes
1,797

Use this.

   FIELD-SYMBOLS : <wa>       TYPE ANY,
                 <field>   TYPE ANY.
DATA str TYPE string.
LOOP AT  gt_fg.
  ASSIGN gt_fg TO <wa>.
  DO.
    ASSIGN COMPONENT sy-index OF STRUCTURE <wa> TO <field>.
    IF sy-subrc = 0.
      str = <field>.
      REPLACE ALL OCCURRENCES OF '--'
               IN str WITH `? ` IN CHARACTER MODE.
      <field> = str.
    ELSE.
      EXIT.
    ENDIF.
  ENDDO.
  MODIFY gt_fg.
ENDLOOP.

Read only

0 Likes
1,797

Hi Shambu,

Appreciate your guidance very much and now i am able to run my report program. Thank so much.. Have a nice day..:)

Read only

Former Member
0 Likes
1,797

IF your table cannot be converted to TYPE TABLE OFstring, then you need to loop at the field and use REPLACE like below.

DATA: str type string.

Loop at gt_fg INTO wa_fg.

str  = wa_fg-field. " Field to be replaced

REPLACE ALL OCCURRENCES OF '--'
         IN str WITH `? ` IN CHARACTER MODE.

wa_fg-field = str.

MODIFY gt_fg FROM wa.

ENDLOOP.

Thanks,

Shambu

Read only

Former Member
0 Likes
1,797

Hi,

First loop at the itab into a work area and use Replace all for the work area.Otherwise try TRANSLATE

Karthik.R