Application Development 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: 

Reading Excel file from Application Server into ABAP Internal Table

0 Kudos

Dear Experts,

I'm having trouble reading an Excel file from application server. I tried implementing this solution https://wiki.scn.sap.com/wiki/display/Snippets/Reading+Excel+file+from+Application+Server+into+ABAP+...

but I'm still facing some issue with the structure of I_DATA1

I'm not sure how schould I be defining it

This is my type definition :

types:begin of i_data,
A type string,
B type string,
C type string,
D type string,

end of i_data.

My Excel file has 4 columns

Please advise me .

Regards,

Houriya

1 ACCEPTED SOLUTION

0 Kudos

Dear community,

After debugging the program, I came across the things that were missing :

1 - if you plan to reproduce the same example giving by Praveen Singh, in the function module ZEXCEL_TO_ABAP,

* while loading the XML data you need to put 'c_shared_str_xml' variable instead of the variable 'c_sheet_xml'.

*while loading the sheet data you need to put 'c_sheet_xml' variable instead of the variable 'c_shared_str_xml'.

2 - When it comes to the XLST Transformation, it needs to have the same name of the internal table and its fields.

17 REPLIES 17

former_member241258
Active Participant
0 Kudos

hi

use this fm TEXT_CONVERT_XLS_TO_SAP

example:

DATA:LT_RAW TYPE TRUXS_T_TEXT_DATA,
LV_FILE TYPE RLGRAP-FILENAME.

REFRESH:CT_UPLOAD[].


CLEAR LV_FILE.
LV_FILE = PA_FILE.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR = 'X'
I_TAB_RAW_DATA = LT_RAW
I_FILENAME = LV_FILE
TABLES
I_TAB_CONVERTED_DATA = CT_UPLOAD
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2.

adv: in ur code dont use string.

use char or text with length

0 Kudos

like below.

TYPES:BEGIN OF TY_UPLOAD,
PERNR TYPE TEXT8,
SPL_ALW TYPE TEXT15,
LEV_WG TYPE TEXT15,
END OF TY_UPLOAD,
TT_UPLOAD TYPE STANDARD TABLE OF TY_UPLOAD.


DATA:GT_UPLOAD TYPE TT_UPLOAD.

0 Kudos

I've already tried this, it's not working

0 Kudos

present i am using

it is working

0 Kudos

Are you reading the file from sever or local PC?

0 Kudos

local PC (desktop)

Limitations of function module TEXT_CONVERT_XLS_TO_SAP :

  • It's only provided in SAP ECC systems, not in other ABAP-based systems (BI, SRM, CRM, etc.)
  • It works only in dialog (not in background)
  • The fields of the internal table must exactly match the columns in the Excel file (same order, don't omit columns)
  • It doesn't work with a file on the application server (only on the desktop)
  • ...

0 Kudos

use dataset coding techinics

open data set

read dataset

close dataset.

using these u can read data from application server

0 Kudos

EX:

here lv_str is application server file path in AL11.

OPEN DATASET LV_STR FOR INPUT IN BINARY MODE.

DO.

READ DATASET LV_STR INTO LS_STR.

IF SY-SUBRC = 0.

APPEND LS_STR TO LT_STR.

ELSE.
EXIT.

ENDIF.

ENDDO.

CLOSE DATASET LV_STR.

0 Kudos

I'm pretty sure OP already knows this. It's part of the code in the Wiki referenced in the original question.

Sorry but I don't see how generic information about OPEN DATASET (which is available in ABAP Help) could possibly help OP in reading Excel format.

matt
Active Contributor
0 Kudos

So... when you use that type definition, what happens?

matt
Active Contributor

Your transformation should reflect the name of your internal table and names of its fields.

0 Kudos

I used the same transformation as described in the link I shared , in fact my real strcuture is very different I'm just trying to re-do the same example but it's not working.

What would you do if you were using the same transformation?

matt
Active Contributor
0 Kudos

I'd debug it and see how the transformation handles my data.

0 Kudos

Nothing, I_DATA1 is still intial , no data

0 Kudos

Dear community,

After debugging the program, I came across the things that were missing :

1 - if you plan to reproduce the same example giving by Praveen Singh, in the function module ZEXCEL_TO_ABAP,

* while loading the XML data you need to put 'c_shared_str_xml' variable instead of the variable 'c_sheet_xml'.

*while loading the sheet data you need to put 'c_sheet_xml' variable instead of the variable 'c_shared_str_xml'.

2 - When it comes to the XLST Transformation, it needs to have the same name of the internal table and its fields.

0 Kudos

Hello Houriya MJADLI,

Could you solve your problem?