Skip to Content
0

Reading Excel file from Application Server into ABAP Internal Table

Oct 24, 2017 at 11:28 PM

406

avatar image
Former Member

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+Internal+Table

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

10 |10000 characters needed characters left characters exceeded

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

0
Former Member
Matthew Billingham

Nothing, I_DATA1 is still intial , no data

0
Former Member

Hello Houriya MJADLI,

Could you solve your problem?

0
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
avatar image
Former Member Nov 22, 2017 at 03:59 PM
0

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.

Share
10 |10000 characters needed characters left characters exceeded
Matthew Billingham
Oct 25, 2017 at 05:32 AM
1

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

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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?

0

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

0
Krishna Murthy Oct 25, 2017 at 03:37 AM
-4

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

Show 9 Share
10 |10000 characters needed characters left characters exceeded

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
Former Member

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

0

present i am using

it is working

0
Former Member

Are you reading the file from sever or local PC?

0

local PC (desktop)

0

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)
  • ...
2

use dataset coding techinics

open data set

read dataset

close dataset.

using these u can read data from application server

0

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

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.

0