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

Question reg. 'replace'

Former Member
0 Likes
438

I have an internal table with a record with fields:

Text: Change delivery &1 , customer &2 (of type char 73)

msgv1: 5678 (of char 50)

msgv2: 457890 (of char 50)

Now I want to replace &1 with msgv1 and &2 with msgv2 values. I tried the following code:

LOOP AT itab.

IF itab-msgv1 NE space.

REPLACE '&1' WITH itab-msgv1 INTO itab-text.

CONDENSE itab-text.

MODIFY itab.

ENDIF.

IF itab-msgv2 NE space.

REPLACE '&2' WITH itab-msgv2 INTO itab-text.

CONDENSE itab-text.

MODIFY itab.

ENDIF.

endloop.

Now when I set breakpoint and see after the loop, that record in itab-text contains value:

Change delivery 5678

(where as I could nt find any replacement for customer &2 and not even the original text customer &2). Am I doing anything wrong?

Can you please suggest/correct the code here reg. correct complete replacements?

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
412

Hi,

If you know the message ID and number..

Use the function module MESSAGE_PREPARE with the parameters MSGID, MSGNO, MSGV1 , MSGV2 , MSGV3, MSGV4.

I will also check your code..

Thanks,

Naren

2 REPLIES 2
Read only

Former Member
0 Likes
413

Hi,

If you know the message ID and number..

Use the function module MESSAGE_PREPARE with the parameters MSGID, MSGNO, MSGV1 , MSGV2 , MSGV3, MSGV4.

I will also check your code..

Thanks,

Naren

Read only

Former Member
0 Likes
412

Hi,

Try to condense the field itab-msgv1, itab-msgv2 before doing the concatenate..

LOOP AT itab.

IF itab-msgv1 NE space.

<b>CONDENSE itab-msgv1.</b>

REPLACE '&1' WITH itab-msgv1 INTO itab-text.

CONDENSE itab-text.

MODIFY itab.

ENDIF.

IF itab-msgv2 NE space.

<b>CONDENSE itab-msgv2.</b>

REPLACE '&2' WITH itab-msgv2 INTO itab-text.

CONDENSE itab-text.

MODIFY itab.

ENDIF.

endloop.

Thanks,

Naren