2014 Jun 19 10:23 AM
What is the ABAP code to find characters of a string after the forward slash(/) ?
For eg : USER/SAP/ABC.CSV
How to retrive ABC.CSV which is after /.
2014 Jun 19 10:37 AM
Hi Saikanth,
1.Use FM PC_SPLIT_COMPLETE_FILENAME
2. By giving the full path to the FM,
we get
a) file name (only file name)
b) also we can get the extension separately in other parameter
2014 Jun 19 10:32 AM
Hello Saikanth,
you can use FM SO_SPLIT_FILE_AND_PATH.
But this FM works with \ only so first you can replace / with \ in string using REPLACE ALL
then that FM.
2014 Jun 19 10:33 AM
Please first search for related post before posting, very basic question.
v_str = 'USER/SAP/ABC.CSV'.
split v_str AT '\' into table it_result.
loop at it_result into wa_result.
if wa_result CS '.'.
v_mystr = wa_result.
endif.
2014 Jun 19 10:36 AM
Hi Saikanth,
DATA: str1 TYPE string,
str2 TYPE string,
str3 TYPE string,
itab TYPE TABLE OF string,
text TYPE string.
text = 'USER/SAP/ABC.CSV'.
SPLIT text AT '/' INTO: str1 str2 str3,
TABLE itab.
Regards,
Pavan
2014 Jun 19 10:37 AM
Hi Saikanth,
1.Use FM PC_SPLIT_COMPLETE_FILENAME
2. By giving the full path to the FM,
we get
a) file name (only file name)
b) also we can get the extension separately in other parameter
2014 Jun 19 10:42 AM
Hi Saikanth,
Use this FM: SPLIT_FILENAME
This FM takes care of both the '\' and '/'.
SAP has provided most of these utility functionalities our of box, so reuse those rather than doing string operation on your own.
Regards,
Tashi
2014 Jun 19 10:46 AM
2014 Jun 19 10:50 AM
HI Sai,
Use the Following Code:
DATA : G_FILE TYPE STRING,
G_EXTENSION TYPE STRING,
G_FILE_EXT TYPE CHAR255.
CALL FUNCTION 'CH_SPLIT_FILENAME'
EXPORTING
complete_filename = g_file " Your File Name
IMPORTING
extension = g_extension
name_with_ext = g_file_ext
EXCEPTIONS
invalid_drive = 1
invalid_path = 2
OTHERS = 3.
Thanks And Regards
Mohit