Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

excel download at given path

Former Member
0 Likes
2,052

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

9 REPLIES 9
Read only

Former Member
0 Likes
1,441

Hi,

Check this link

reagrds,

anirban

Read only

Former Member
0 Likes
1,441

Hi

In file selection u use this Fm:F4_filename

Excel Upload:TEXT_CONVERT_XLS_TO_SAP

Regards:

Prabu

Read only

Former Member
0 Likes
1,441

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.

Read only

former_member195383
Active Contributor
0 Likes
1,441

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

Read only

0 Likes
1,441

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

Read only

Former Member
0 Likes
1,441

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

Read only

Former Member
0 Likes
1,441

Hi ,

Try to handle the exceptions

INVALID_FILENAME and

FILE_NOT_EXIST.

Regards,

Arun

Read only

Former Member
0 Likes
1,441

Hi Natasha,

Check this one, which will give you an idea.

[Excel Download|;

Regards,

Chandra Sekhar

Read only

Former Member
0 Likes
1,441

Hi ,

Handel manually exception and give status message not error message .