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

Reading ecxel file from Application server

Former Member
0 Likes
1,676

Hi,

I want to know, which is the FM - we can use to read the excel file from the application server and load the data from the excel file to the int table.

I tried with FM - FILE_READ_AND_CONVERT_SAP_DATA and FILE_READ_AND_GET_TAB

These FM's I tried with the help of SDN.

Do you have any idea ?

Cheers,

dinesh

Hi,

I want to know, which is the FM - we can use to read the excel file from the application server and load the data from the excel file to the int table.

I tried with FM - FILE_READ_AND_CONVERT_SAP_DATA and FILE_READ_AND_GET_TAB

These FM's I tried with the help of SDN.

Do you have any idea ?

Cheers,

dinesh

8 REPLIES 8
Read only

former_member770378
Active Participant
0 Likes
1,300

I think you can't read an excel on application server.

If you want to read an excel file you need to convert it into .csv et .txt file, separator or tab (#) and to send it on your application server.

After that you'll have to do an "open dataset" to populate your internal tab.

Edited by: julien schneerberger on Mar 2, 2010 2:32 PM

Edited by: julien schneerberger on Mar 2, 2010 2:32 PM

Read only

vinod_vemuru2
Active Contributor
0 Likes
1,300

Hi Dinesh,

Please search the forum with your subject line and see the magic:-)

Small typo error in subject. It is Excel.

http://www.sdn.sap.com/irj/scn/advancedsearch?query=readingexcelfilefromApplication+server

Thanks,

Vinod.

Read only

Former Member
0 Likes
1,300

Hi,

You can get excel sheet data from Application server to internal table by using OPEN DATASET PHYSICAL FILE INTO TEMP FILE FOR INPUT ENCODING DEFAULT.

Regards,

Venkat.

Read only

0 Likes
1,300

The data that exists in the file comes with TAB delimitor and in ONE line, so you SPLIT the data using the horizontal TAB

data: TAB(2) type c.

TAB = CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

now split the data using TAB field.......

Read only

Clemenss
Active Contributor
0 Likes
1,300

Hi Dinesh,

if you really have an excel file on your application server, that means where SAP is running, you can read the file using open/read dataset into an xstring.

If the excel is in proprietary ms excel format you can only extract the table data using excel program on your presentation server, this is your PC where the SAPGUI is running.

In this case, you can convert the xstring into an internal table, make a GUI download to a local directory (i.e. SAP work directory) and then open the excel using SAP desktop office integration.

If the excel file has been saved as tab-delimited text, you can open/read as TEXT file and split the records at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB into a useful structure to be appended to an internal table.

Regards,

Clemens

Read only

Former Member
0 Likes
1,300

Hi,

Use the following code it will solve your problem....

data: begin of itaba occurs 0,
      name(20) type c,
      addre(20) type c,
      end of itaba.

DATA:itab like table of itaba with header line.

DATA : ITAB1 LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.

DATA : B1 TYPE I VALUE 1,
       C1 TYPE I VALUE 1,
       B2 TYPE I VALUE 100,
       C2 TYPE I VALUE 9999.

DATA: ROW LIKE ALSMEX_TABLINE-ROW VALUE 1,
      COL LIKE ALSMEX_TABLINE-ROW VALUE 1.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
  EXPORTING
    FILENAME                   = 'D:\EMPLOYE.XLS'
    I_BEGIN_COL                   = B1
    I_BEGIN_ROW                   = C1
    I_END_COL                     = B2
    I_END_ROW                     = C2
  TABLES
    INTERN                        = itab1
 EXCEPTIONS
   INCONSISTENT_PARAMETERS       = 1
   UPLOAD_OLE                    = 2
   OTHERS                        = 3.

IF SY-SUBRC <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

loop at itab1.
IF ITAB1-ROW EQ ROW.
WRITE:/ ITAB1-VALUE(15).
ROW = ROW + 1.
ELSE.
WRITE:ITAB1-VALUE(15).
ENDIF.
EndloOp.

Regards,

Shankar.

Read only

0 Likes
1,300

yes, ALSM_EXCEL_TO_INTERNAL_TABLE can be used for single-sheet local excel files if you have excel installed on your desktop. The function ALSM_EXCEL_TO_INTERNAL_TABLE uses SAP desktop office integration technique which will not work on application server.

Regards,

Clemens

Read only

0 Likes
1,300

>

> Use the following code it will solve your problem....

>

> CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

> EXPORTING

> FILENAME = 'D:\EMPLOYE.XLS'

> I_BEGIN_COL = B1

> Shankar.

Please read the requirements first. Your solution will not solve the problem cause its oinly working on presentation server, not on application server as requested.