2019 Feb 04 9:54 AM
Hi Expert,
I have developed a Programm to upload data from the desktop to an internal table and it is working very good.
now I need to make sure that the excel is closed before starting the upload process..so if the file still opens the user will receive an Error message to close it first....
can some help regarding this..
Best Regards
Jenie
Hi Expert,
I have developed a Programm to upload data from the desktop to an internal table and it is working very good.
now I need to make sure that the excel is closed before starting the upload process..so if the file still opens the user will receive an Error message to close it first....
can some help regarding this..
Best Regards
Jenie
2019 Feb 04 10:15 AM
Can you explain what happens as of now when such a situation occurs?
2019 Feb 04 10:57 AM
2019 Feb 04 12:19 PM
2019 Feb 04 1:02 PM
2019 Feb 05 2:47 AM
I dont see the meaning of the check. it already checked and return an error message, what would you do if you check out that file is open? if user somehow want to process upload even that file is opened mean there is a risk to lost data they editing...anw i think it make no sense.
2019 Feb 06 9:17 AM
you exactly say the meaning and same time you don't see the meaning.
the reason for that as you mentioned . 🙂
it is to make sure that the user will not lose the data by uploading.. so first close then upload
'here is a risk to lost data they editing'
2019 Feb 06 10:49 AM
raymond.giuseppi
I have written the code below using OLE2 this code just blocking the files which I am selecting and testing as this File is became for reading only.
I just want to recive an Error massege
The folder is locked by another user if the foldser is already opened.START-OF-SELECTION.
DATA: h_excel TYPE ole2_object,
h_book TYPE ole2_object,
sheet TYPE ole2_object,
cells TYPE ole2_object.
DATA locked_flag TYPE abap_bool.
DATA p_spalte TYPE char255.
INCLUDE ole2incl.
CREATE OBJECT h_excel 'Excel.Application'.
SET PROPERTY OF h_excel 'Visible' = 0.
CALL METHOD OF
h_excel
'Workbooks' = h_book.
CALL METHOD OF
h_book
'OPEN'
EXPORTING
#1 = p_fname.
*free_object h_book. :!:
GET PROPERTY OF h_excel 'ACTIVEWORKBOOK' = h_book.
GET PROPERTY OF h_book 'ReadOnly' = locked_flag.
IF locked_flag = '0'.
*if locked_flag-header(1) = '0'.
CALL METHOD OF
h_excel
'CELLS' = cells
EXPORTING
#1 = cells
#2 = p_spalte.
SET PROPERTY OF cells 'VALUE' = '1'.
FREE OBJECT cells .
WRITE ' The folder is not locked ' .
*call method of h_book 'Save' = h_save.
* FREE OBJECT h_save.
ELSE.
WRITE 'The folder is locked by another user' .
ENDIF.could please help me to achive this..
Thanks
Jenie
2019 Feb 07 2:37 AM
OK, sorry i missunderstood your question. the easiest way i could tell is using gui_upload method to open that file first, if there is any error that method will raise an exception including file already opened check. within OLE, i think there already have that check (when you call open method it should be return sy-subrc = 2 if file opened) but in my system its not happended, maybe it changed with office version, anw OLE just the way you call VBA method, you can check the VBA if there is anyway to check file opened. one more way, but not suggested, is using SM69 to call external command...
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |