2008 Aug 29 7:39 AM
Hi all,
I have a query. Actually i am working on a BDC.
In a selection screen, I am giving an input field where user can give the path from where he wants to upload the data from an excel file. I have given F4 help at this field. But the user can enter manually also.
I have given the provision of downloading an excel file template also on click of a pushbutton
so that he can enter the data to be uploaded in that if he dont know the structure. For this I am using FM 'MS_EXCEL_OLE_STANDARD_DAT'.
So when he'll give the path and click on pushbutton, an excel file will be created at the given path.
My problem is if I am giving wrong path, and clicking on pushbutton, its giving a dump. May be some exception is getting raised in the FM MS_EXCEL_OLE_STANDARD_DAT.
Please help me in this.
Regards
Natasha Garg
Hi all,
I have a query. Actually i am working on a BDC.
In a selection screen, I am giving an input field where user can give the path from where he wants to upload the data from an excel file. I have given F4 help at this field. But the user can enter manually also.
I have given the provision of downloading an excel file template also on click of a pushbutton
so that he can enter the data to be uploaded in that if he dont know the structure. For this I am using FM 'MS_EXCEL_OLE_STANDARD_DAT'.
So when he'll give the path and click on pushbutton, an excel file will be created at the given path.
My problem is if I am giving wrong path, and clicking on pushbutton, its giving a dump. May be some exception is getting raised in the FM MS_EXCEL_OLE_STANDARD_DAT.
Please help me in this.
Regards
Natasha Garg
2008 Aug 29 7:41 AM
2008 Aug 29 7:42 AM
Hi
In file selection u use this Fm:F4_filename
Excel Upload:TEXT_CONVERT_XLS_TO_SAP
Regards:
Prabu
2008 Aug 29 7:44 AM
Hi,
can u check this beloqw code this is helpful.
Parameters: P_file like RLGRAP-FILENAME.
data : begin of int_head occurs 0,
Filed1(20) type c, " Header Data
end of int_head.
data : begin of int_data occurs 0,
Field1(20) type c, " Data
Field2(20) type c,
Field3(20) type c,
Field4(20) type c,
end of int_data.
int_head-Filed1 = 'Sales Ord'.
APPEND int_head.
CLEAR int_head.
int_head-Filed1 = 'Sold-to-Party'.
APPEND int_head.
CLEAR int_head.
int_head-Filed1 = 'Purchase Ord'.
APPEND int_head.
CLEAR int_head.
int_head-Filed1 = 'Ship-to-Party'.
APPEND int_head.
CLEAR int_head.
int_data-field1 = '1JOHN'.
int_data-field2 = '2TOM'.
int_data-field3 = '3BRAD'.
int_data-field4 = '4PETER'.
Append int_data.
Clear int_data.
CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
EXPORTING
file_name = p_file " path offile where u need to download
CREATE_PIVOT = 0
DATA_SHEET_NAME = ' '
PIVOT_SHEET_NAME = ' '
PASSWORD = ' '
PASSWORD_OPTION = 0
TABLES
PIVOT_FIELD_TAB =
data_tab = int_data "internal table with data
fieldnames = int_head "internal table with header
EXCEPTIONS
file_not_exist = 1
filename_expected = 2
communication_error = 3
ole_object_method_error = 4
ole_object_property_error = 5
invalid_filename = 6
invalid_pivot_fields = 7
download_problem = 8
OTHERS = 9
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
2008 Aug 29 7:44 AM
Hi...just giv a break point b4 this perticular FM. Then execute the FM and see wat is the value of sy-subrc.
Then u have to handle the exception manually..Like..belo...
after the FM write the below syntax....
IF sy-subrc EQ 1.
MESSAGE i999 WITH 'File cant be opened'.
LEAVE LIST-processing.
ELSEIF sy-subrc EQ 2.
MESSAGE i999 WITH 'File already exists;Delete the file and try again'.
LEAVE LIST-processing.
ELSEIF sy-subrc EQ 3.
MESSAGE i999 WITH 'File write error'.
:
:
:
:
ENDIF.
then u can avoid the dump
Edited by: Rudra Prasanna Mohapatra on Aug 29, 2008 8:44 AM
2008 Aug 29 8:00 AM
Hi
Yes I tried doing that only.
Below was the FM that I had called.
CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
EXPORTING
file_name = lv_file
data_sheet_name = 'DATA'
TABLES
data_tab = li_data
fieldnames = gi_header
EXCEPTIONS
file_not_exist = 1
filename_expected = 2
communication_error = 3
ole_object_method_error = 4
ole_object_property_error = 5
invalid_pivot_fields = 6
download_problem = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
It was was creating the file and giving runtime error as Message_type_unkown. SY_SUBRC for this was coming as 4. So i tried displaying message under the check for SY_SUBRC = 4.
I was displaying the message 'Path Not Found' but it is giving the message as 'Vendor not specified'. I dont knw the reason. I tried debugging it also but didn't get it.
Do you have clue for this?
Regards
Natasha Garg
2008 Aug 29 7:45 AM
May be you are getting exception FILE_NOT_EXIST in dump.
its a fm bahaviour you must need to provide correct file name.else handle this exception by giving message.
Edited by: Amit Gujargoud on Aug 29, 2008 8:45 AM
2008 Aug 29 7:46 AM
Hi ,
Try to handle the exceptions
INVALID_FILENAME and
FILE_NOT_EXIST.
Regards,
Arun
2008 Aug 29 7:50 AM
2008 Aug 29 8:12 AM
Hi ,
Handel manually exception and give status message not error message .
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |