‎2006 Dec 04 7:06 PM
Hi ,
I need to write a code like this..
I must use a FM and bring the output(file names) and check for it which comes out in a structure format. The main thing is ..I must check if the file names start with AGE or DOB with some other continuations .How do I check this?
Can anyone please help me with the code?
Thank you
‎2006 Dec 04 8:01 PM
This will not work
IF DOC_NAME = AGE_*.
xxxxxxxx
ELSEIF DOC_NAME = DOB_*.
yyyyyy
ENDIF.
You must use like this
IF <b>DOC_NAME(4) = 'AGE_'.</b>
xxxxxxxx
ELSEIF <b>DOC_NAME(4) = 'DOB_'.</b>
yyyyyy
ENDIF.
Regards
Kathirvel
‎2006 Dec 04 7:22 PM
I am not very clear how you are planning to get the file names. I assume you are selecting multiple files from system.
<b>* Here selecting multiple files from PC</b>
DATA: i_file_table TYPE filetable,
w_file_table TYPE file_table,
v_rc TYPE I.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
INITIAL_DIRECTORY = 'C:\'
multiselection = 'X'
CHANGING
file_table = i_file_table
rc = v_rc
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc <> 0.
Do some Error Handling
ENDIF.
<b>* Checking for AGE and DOB in file name</b>
LOOP AT i_file_table INTO w_file_table.
IF w_file_name-filename(3) = 'AGE' OR
w_file_name-filename(3) = 'DOB'.
Do the Processing here
ENDIF.
ENDLOOP.
Regards
Kathirvel
‎2006 Dec 04 7:28 PM
Hi,
Check this example..This will get the file names that starts with AGE.
data: FILE_TABLE TYPE STANDARD TABLE OF FILE_INFO.
data: wa_file type file_info.
data: count type i.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES
EXPORTING
DIRECTORY = 'C:\'
FILTER = <b>'AGE.'</b>
files_only = 'X'
changing
FILE_TABLE = file_table[]
count = count.
loop at file_table into wa_file.
write: / wa_file-filename.
endloop.
Thanks,
Naren
‎2006 Dec 04 7:38 PM
Hey to say exactly ..I am going to get the files ,but the name of the documents attached.The only thing I want is ..if the names are of 2 kinds...like AGE and DOB,how do we check them?
Can I do like this?
IF DOC_NAME = AGE_*.
xxxxxxxx
ELSEIF DOC_NAME = DOB_*.
yyyyyy
ENDIF.
Or is there something else I have to write to check the name?
‎2006 Dec 04 8:02 PM
Hi Bharat,
Use offset opearaion to check for the values.
Check like this.
<b>IF DOC_NAME+0(3) = 'AGE'.</b>
Write: 'Starts with AGE'.
<b>ELSEIF DOC_NAME+0(3) = 'DOB'.</b>
Write: 'Starts with DOB'.
<b>ENDIF.</b>
‎2006 Dec 04 8:01 PM
This will not work
IF DOC_NAME = AGE_*.
xxxxxxxx
ELSEIF DOC_NAME = DOB_*.
yyyyyy
ENDIF.
You must use like this
IF <b>DOC_NAME(4) = 'AGE_'.</b>
xxxxxxxx
ELSEIF <b>DOC_NAME(4) = 'DOB_'.</b>
yyyyyy
ENDIF.
Regards
Kathirvel