‎2007 Jun 14 9:31 AM
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
‎2007 Jun 14 9:42 AM
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
‎2007 Jun 14 9:43 AM
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
‎2007 Jun 14 9:44 AM
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.