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

Issue in replacing values

Former Member
0 Likes
422

Hi ,

I have on small problem in coding.

i have value in ITAB for field 1.

itab--

1.MHIYYYYMMDD.TXT

2.SCMDYYYYMMDD.TXT

3.SCMEYYYYMMDD.TXT.

4.REVYYYYMMDD.TXT.

(A) I want to replace yyyymmdd by sy-datum always .ok iam spliting and CONCATENATE and it is working fine .

The issue is ,

some time for me 3 char is comming and some time 4 char is comming .

if i use ,

L_TEXT9 = GS_MISC-Z_VALUE_2+0(3).( issue is heer)<----


L_TEXT10 = GS_MISC-Z_VALUE_2+12(15).

l_text5 = sy-datum.

CONCATENATE L_TEXT9 L_TEXT5 L_TEXT10 INTO G_TEXT_2 .

if i use

1.L_TEXT9 = GS_MISC-Z_VALUE_2+0(3).

it will take first 3 char

2.L_TEXT9 = GS_MISC-Z_VALUE_2+0(4).

if i use this would take first 4 char.

But i could not decide the internal table values .

how can i proceed , is there any command to replace..

reagrds

veera

3 REPLIES 3
Read only

dev_parbutteea
Active Contributor
0 Likes
402

Hi,

replace 'YYYYMMDD' into <b>source_field</b> with <b>target</b>

e.g.

DATA: test_str(100) TYPE c VALUE 'This is a test string'.

REPLACE 'This is a test' INTO test_str with 'TEST'.

write:/ test_str.

Regards,

Sooness

Read only

Former Member
0 Likes
402

do like this..

data : text(16) value 'MHIYYYYMMDD.TXT'

prev(12),

last(4),

len type i,

result(16).

split text at '.' into prev last.

compute len = strlen( prev ).

if len gt 8.

len = len - 8.

endif.

result = text+0(len).

here you can get whether it is 3 or 4 in len.

regards

shiba dutta

Read only

Former Member
0 Likes
402
better take the last 8 characters before .TXT

loop at itab.
 search itab-field for '.'.
 if sy-subrc eq 0.
   sy-fdpos = sy-fdpos - 8.
   itab-field+sy-fdpos(8) = sy-datum.
   modify itab index sy-tabix.
 endif.
endloop.