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 ALL OCCURRENCIES

Former Member
0 Likes
630

Hello

Can somebody explain me the logic of ALL OCCURRENCIES in the the example below :

I think that this operator should replace A , ! with ' ' but the real output is different.

The real output is AA!A. It replaces all small characters with ' '. Why

DATA : l_PD(10) TYPE C.

*

l_pd = 'AbbA!A'.

*

*

replace all OCCURRENCES OF REGEX

'[^!"%&''()*+,-./:;<=>?_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ]' in

l_pd with ' '.

*

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
586

Example

LOOP AT it_otfdata1 INTO wotfdata .

REPLACE FIRST OCCURRENCE OF 'ORIGINAL' IN wotfdata-tdprintpar WITH 'DUPLICATE'.

IF sy-subrc = 0.

MODIFY it_otfdata1 FROM wotfdata INDEX sy-tabix TRANSPORTING tdprintpar.

*exit.

ENDIF.

ENDLOOP.

APPEND LINES OF it_otfdata1 TO it_otfdata.

3 REPLIES 3
Read only

Clemenss
Active Contributor
0 Likes
586

Hi commander,

please paste code as

 code 

, thanks.

Regards,

Clemens

Read only

Clemenss
Active Contributor
0 Likes
586

... and put search (patterns) characters in square brackets [[ and ]].

See also [Regular Expressions in Routines|http://help.sap.com/saphelp_nw70/helpdata/en/42/9d6ceabb211d73e10000000a1553f6/frameset.htm]

Regards,

Clemens

Read only

Former Member
0 Likes
587

Example

LOOP AT it_otfdata1 INTO wotfdata .

REPLACE FIRST OCCURRENCE OF 'ORIGINAL' IN wotfdata-tdprintpar WITH 'DUPLICATE'.

IF sy-subrc = 0.

MODIFY it_otfdata1 FROM wotfdata INDEX sy-tabix TRANSPORTING tdprintpar.

*exit.

ENDIF.

ENDLOOP.

APPEND LINES OF it_otfdata1 TO it_otfdata.