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

Problem with REPLACE ALL OCCURRENCES in Smartform

Former Member
0 Likes
1,686

Dear All,

I am having a problem with REPLACE ALL OCCURRENCES when using it in Smartform.

The code from my Smartfom is as below :

LOOP AT zline INTO lwa_zline.
  REPLACE ALL OCCURRENCES OF '#' IN lwa_zline-tdline WITH space
              IN CHARACTER MODE.    
  MODIFY zline FROM lwa_zline.
ENDLOOP.

This code works fine if written in a report but does not replace character # when written in Smartform.

Pls help.

regards,

Jinson.

1 ACCEPTED SOLUTION
Read only

Former Member
1,218

Hello,

Use Modify keyword with TRANSPORTING.

Modify zline FROM lwa_zline index sy-tabix TRANSPORTING tdline.

8 REPLIES 8
Read only

Former Member
1,219

Hello,

Use Modify keyword with TRANSPORTING.

Modify zline FROM lwa_zline index sy-tabix TRANSPORTING tdline.

Read only

0 Likes
1,218

Dear Santhosh,

REPLACE is not working.

Its not replacing the '#' char from the string.

Thanks,

Jinson.

Read only

0 Likes
1,218

Hi,

try this way it will work...


replace all occurances of  CL_ABAP_CHAR_UTILITIES=>newline   "use this in place of '#'
                                        in string with space.

or


LOOP AT zline INTO lwa_zline.
  REPLACE ALL OCCURRENCES OFcl_abap_char_utilities=>NEWLINE   "try to use class
                  IN lwa_zline-tdline WITH space
              IN CHARACTER MODE.    
  MODIFY zline FROM lwa_zline.
ENDLOOP.

see the link[link for rplace # or ##|]

Prabhu

Read only

0 Likes
1,218

Hi Prabhu,

Using CL_ABAP_CHAR_UTILITIES=>newline didnt work.

I checked the hex values also...

The value from which I want to remove is

YAEM2#HINGE and its hex value is 5941454D320948494E4745

and the hex value for CL_ABAP_CHAR_UTILITIES=>newline is 0A

Thanks,

Read only

0 Likes
1,218

Hi Jinson,

try to comment IN CHARACTER MODE and check ..


LOOP AT zline INTO lwa_zline.
  REPLACE ALL OCCURRENCES OFcl_abap_char_utilities=>NEWLINE   "try to use class
                  IN lwa_zline-tdline WITH space.
              IN CHARACTER MODE.                           "comment this and check 
  MODIFY zline FROM lwa_zline.
ENDLOOP.

Prabhu

Read only

0 Likes
1,218

>

> Hi Jinson,

>

> try to comment IN CHARACTER MODE and check ..

>

>

>


> LOOP AT zline INTO lwa_zline.
>   REPLACE ALL OCCURRENCES OFcl_abap_char_utilities=>NEWLINE   "try to use class
>                   IN lwa_zline-tdline WITH space.
>               IN CHARACTER MODE.                           "comment this and check 
>   MODIFY zline FROM lwa_zline.
> ENDLOOP.
> 

>

> Prabhu

Prabhu,

Tried using

REPLACE ALL OCCURRENCES OF CL_ABAP_CHAR_UTILITIES=>newline IN lwa_zline-tdline WITH space.

Didnt work.

thanks

Read only

1,218

Dear Prabhu,

Resolved.

Used CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB instead of NEWLINE.

Thanks Prabhu for the help.

regards,

Jinson.

Read only

Former Member
0 Likes
1,218

See the follwoing example

LOOP AT it_otfdata1 INTO wotfdata .

REPLACE ALL OCCURRENCE OF '#' IN wotfdata-tdprintpar WITH ' '.

IF sy-subrc = 0.

MODIFY it_otfdata1 FROM wotfdata INDEX sy-tabix TRANSPORTING tdprintpar.

endif.

endloop