‎2006 May 03 5:58 AM
hi all...
i have strings in the follwing form...
adf_er_t_<b>xxxx.dat</b>
ad_effr_tru_<b>xxx.dat</b>
ad_er_tr_<b>yxxx.dat</b>
adf_ff_er_tr_<b>xy.dat</b>
ttf_er_tr_<b>xy.dat</b>
i want to remove the last part of the string....and required first part which is table name...
plz help
Message was edited by: Madan Gopal Sharma
Message was edited by: Madan Gopal Sharma
‎2006 May 03 6:00 AM
Hi Madan,
Uee the FM SO_SPLIT_FILE_AND_PATH to get the file name.
Alternatively you can use SPLIT AT 'tr_' in ur case.
SPLIT w_var1 AT 'tr_' into w_var2 w_var3
Hope this helps
CHeers
VJ
Message was edited by: Vijayendra Rao
‎2006 May 03 6:13 AM
Madan,
You need to have a common character for all the file names for delimiting. In the data you have given its not like that.
SEARCH String for 'DELIM'.
IF SY-SUBRC = 0.
W_POSITION = SY-FDPOS
ELSE.
EXIT.
ENDIF.
Path = String+0(w_position).
regards,
Ravi
‎2006 May 03 6:15 AM
Hi Madan,
You can use this Function Module , which will completely satisfy your requirement.
It is CV120_SPLIT_FILE.
Check this code.
REPORT ZTEST_SHAIL3 .
data: file_name type DRAW-FILEP,
ext(4) type c.
CALL FUNCTION 'CV120_SPLIT_FILE'
EXPORTING
pf_file = 'hello.txt'
IMPORTING
PFX_FILE = file_name
PFX_EXTENSION = ext
PFX_DOTEXTENSION =
.
Regards,
SP.
‎2006 May 03 6:18 AM
Hi madan,
1. for your requirement,
i have made in independent FORM
in which we pass the string eg.adf_er_t_xxxx.dat
and it returns
<b>adf_er_t</b>
2. there is also a selection screen for testing purpose.
3. just copy paste in new program.
4.
report abc.
*----
data : tabname(30) type c.
*----
parameters : a(50) type c DEFAULT 'adf_er_t_xxxx.dat'.
*----
START-OF-SELECTION.
perform getmydata using a CHANGING TABNAME.
WRITE 😕 TABNAME.
*----
INDEPENDENT FORM
*----
form getmydata using pstr changing tabname.
DATA : N TYPE I.
DATA : M TYPE I.
data : begin of itab occurs 0,
f(15) type c,
end of itab.
split PSTR at '_' into table itab.
CLEAR TABNAME.
DESCRIBE TABLE ITAB LINES N.
M = N - 2.
LOOP AT ITAB.
IF SY-TABIX <= M.
CONCATENATE ITAB-F '_' INTO ITAB-F.
MODIFY ITAB.
ENDIF.
ENDLOOP.
LOOP AT ITAB.
IF SY-TABIX < N.
CONCATENATE TABNAME ITAB-F INTO TABNAME.
ENDIF.
ENDLOOP.
endform. "
regards,
amit m.