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

Upload Excel File

Former Member
0 Likes
1,850

Hi Expert.

I need to Upload Excel file on Application server. So I can Use  fm GUI_DOWNLOAD but by using this function module i got Error

'Access Denied'. Please help me....

Said Answer is with Example.

My Step  :  1 ) Read all data from Database table in Internal table.

                  2) Try to Upload File to Application server Like   

P_L_FILENAME = application server parth.

CALL FUNCTION 'GUI_DOWNLOAD'

     EXPORTING

       FILENAME                = P_L_FILENAME

       FILETYPE                = 'DAT'

       APPEND                  = P_L_APPEND

       WRITE_FIELD_SEPARATOR   = 'X'

     TABLES

       DATA_TAB                = P_I_DATATAB

     EXCEPTIONS

       FILE_WRITE_ERROR        = 1

       NO_BATCH                = 2

       GUI_REFUSE_FILETRANSFER = 3

       INVALID_TYPE            = 4

       NO_AUTHORITY            = 5

       UNKNOWN_ERROR           = 6

       HEADER_NOT_ALLOWED      = 7

       SEPARATOR_NOT_ALLOWED   = 8

       FILESIZE_NOT_ALLOWED    = 9

       HEADER_TOO_LONG         = 10

       DP_ERROR_CREATE         = 11

       DP_ERROR_SEND           = 12

       DP_ERROR_WRITE          = 13

       UNKNOWN_DP_ERROR        = 14

       ACCESS_DENIED           = 15

       DP_OUT_OF_MEMORY        = 16

       DISK_FULL               = 17

       DP_TIMEOUT              = 18

       FILE_NOT_FOUND          = 19

       DATAPROVIDER_EXCEPTION  = 20

       CONTROL_FLUSH_ERROR     = 21

       OTHERS                  = 22.

   IF SY-SUBRC NE 0.

     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

     WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

   ENDIF.



Thanks & Regards.


Pradip Patel.

1 ACCEPTED SOLUTION
Read only

ThangaPrakash
Active Contributor
0 Likes
1,783

Hello Pradip,

Use like below.

*- Open the files in Application server

OPEN DATASET p_afile FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

*Move the Internal table data to the file

    LOOP AT itab INTO str.

      TRANSFER str TO p_afile.

    ENDLOOP.

*- Close the Opened File in the Application Server

    CLOSE DATASET p_afile.

Regards,

Thanga

14 REPLIES 14
Read only

former_member226419
Contributor
0 Likes
1,783

Hi,

Perhaps you don't have authorization to access and write a file to the presentation server directory.

Sumeet

Read only

0 Likes
1,783

Hi Sumeet.

Thanks for Reply. I know I have not authorization for Upload File. But I want to Upload.

Now at Development stage I have map network and upload file to Application server.

But I will not map All user local to to SAP Production Server when my Project Live.

anybody answer ?

Thanks.

Pradip Patel.

Read only

0 Likes
1,783

Hi Pradip

In case you want to write file to application server then you should use Open/Close dataset. GUI_DOWNLOAD is for presentation server.

Nabheet

Read only

0 Likes
1,783

Hello Sumeet,

GUI_DOWNLOAD is to Download an Internal Table to the PC.

You have to use OPEN DATASET, TRANSFER and CLOSE DATASET to create files in the application server.

Regards,

Thanga

Read only

ThangaPrakash
Active Contributor
0 Likes
1,784

Hello Pradip,

Use like below.

*- Open the files in Application server

OPEN DATASET p_afile FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

*Move the Internal table data to the file

    LOOP AT itab INTO str.

      TRANSFER str TO p_afile.

    ENDLOOP.

*- Close the Opened File in the Application Server

    CLOSE DATASET p_afile.

Regards,

Thanga

Read only

0 Likes
1,783

hello Thanga.

Thanks for Reply.

Please tell me the Type of str.

data : str type ????????

Thanks.

Pradip Patel.

Read only

0 Likes
1,783

here 'str' refers to the work area of the internal table itab.

Read only

0 Likes
1,783

str should be of the type as like the itab.

Regards,

Thanga

Read only

0 Likes
1,783

hI Thanga.

Thanks for Reply.   Problem Solve....

thanks.

Pradip Patel.

Read only

0 Likes
1,783

Hello Pradip,

You are welcome

Please raise a discussion in SCN whenever any help required.

Regards,

Thanga

Read only

mayur_priyan
Active Participant
0 Likes
1,783

Hi,

I need to Upload Excel file on Application server. So I can Use  fm GUI_DOWNLOAD but by using this function module i got Error

'Access Denied'. Please help me...

GUI_DOWNLOAD is used to download the Data of an internal table to LOCAL File on to the Presentation server.

Inorder to update the internal table values on to the Application server you need to use OPEN DATASET statement.

Regards,

Mayur Priyan. S

Read only

0 Likes
1,783

U can try FM TEXT_CONVERT_XLS_TO_SAP...

Read only

ThangaPrakash
Active Contributor
0 Likes
1,783

There are plenty of posts available in SCN regarding this. Also refer to the below link

Upload Internal table to Application Server and Presntation Server - Contributor Corner - SCN Wiki

Regards,

Thanga

Read only

Former Member
0 Likes
1,783

Hi Pradip,

First of all you have to Upload your file from PC to Internal table in your report using GUI_UPLOAD.

After you get the records in your internal table use

1) OPEN DATASET <Application filepath> FOR OUTPUT IN TEXT MODE ENCODING <Code page>

2) Then use TRANSFER to transfer records from Internal table to application server.

3) CLOSE DATASET.

Thanks & Regards

Akshay