Skip to Content
0
Former Member
Feb 26, 2007 at 02:46 PM

XLS from Application server in background mode to internal table

733 Views

Hi,

I need to transfer the content of an excel file in the application server to an internal table while running my program in background. My file is xls, cant use csv. For dataset bin mode, I need to know how to transfer the data to my internal table, already searched on forum but didnt find answer, at least not for background..

ow, I am using v6 here

about the ALSM_EXCEL_TO_INTERNAL_TABLE, I get the upload_ole error all the time, and with TEXT_CONVERT_XLS_TO_SAP, conversion_failed all the time too...

here is the code, just the load part and data declaration:

**********************************************************************

REPORT zbeto.

TYPE-POOLS: truxs.

TYPES:

BEGIN OF y_cot,

text1(12) TYPE c,

text2(12) TYPE c,

text3(12) TYPE c,

text4(12) TYPE c,

text5(12) TYPE c,

END OF y_cot.

DATA: it_datatab TYPE STANDARD TABLE OF y_cot,

wa_datatab TYPE y_cot,

it_raw TYPE truxs_t_text_data.

DATA:

v_file TYPE rlgrap-filename,

begin_col TYPE i VALUE '1',

begin_row TYPE i VALUE '2',

end_col TYPE i VALUE '5',

end_row TYPE i VALUE '102',

t_ctmp TYPE y_cot OCCURS 0 WITH HEADER LINE,

t_xls TYPE alsmex_tabline OCCURS 0 WITH HEADER LINE.

START-OF-SELECTION.

PERFORM f_load_xls.

**********************************************************************

  • FORM : f_load_xls

**********************************************************************

FORM f_load_xls.

v_file = '
ZSAPDEV\SAPDEVINTERF$\COTACAO\TESTE.XLS'.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = v_file

i_begin_col = begin_col

i_begin_row = begin_row

i_end_col = end_col

i_end_row = end_row

TABLES

intern = t_xls

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.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

  • I_FIELD_SEPERATOR =

  • i_line_header = 'X'

i_tab_raw_data = it_raw " WORK TABLE

i_filename = v_file

TABLES

i_tab_converted_data = it_datatab[] "ACTUAL DATA

EXCEPTIONS

conversion_failed = 1

OTHERS = 2.

IF sy-subrc <> 0.

  • MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

  • WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

t_ctmp[] = it_datatab[].

ENDFORM. "f_load_xls

**********************************************************************

both FM arent working, and when I try to execute in background mode, before anything, I recieve the following error:

Message text:

Error during import of clipboard contents

Message class:

ALSMEX

Message no.:

037

Message type:

A

and without the ASLM FM, the TEXT_CONVERT give me the conversion_failed exception...

the directories are right, that I am sure, because I just copy&paste it from CG3Z/CG3Y when I uploaded and downloaded to

check the file in the server...

am I missing something?

thanks again,

Roberto Macedo

(PS: I made another topic because none replied the other in 4 days and wasnt solved yet)