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 File from Application Server using Read Dataset

Former Member
0 Likes
3,136

Hi,

i am trying to read excel file from Application Server and has multiple records in that based on structure below. but when i execute its giving me error message.here is the code, can sumone suggest me on this please ??

-


FORM f_data_upload .

DATA:

l_filename TYPE string, "file name

l_wa_string TYPE string. "file record

l_filename = p_inp_as. "File path from Application Server

OPEN DATASET l_filename FOR INPUT IN TEXT MODE ENCODING DEFAULT.

DO.

IF sy-subrc <> 0.

EXIT.

ENDIF.

  • Read the data from the file in Application server.

READ DATASET l_filename INTO l_wa_string.

IF sy-subrc = 0.

SPLIT l_wa_string AT cl_abap_char_utilities=>horizontal_tab

INTO w_data-tcode

w_data-matnr

w_data-mtart

w_data-werks

w_data-vkorg

w_data-vtweg

w_data-lgort

w_data-meins

w_data-maktx

w_data-spart

w_data-kosch

w_data-mstae

w_data-brgew

w_data-ntgew

w_data-groes

w_data-matkl

w_data-prdha

w_data-mstde

w_data-mtpos_mara

w_data-gewei

w_data-spart

w_data-mstav

w_data-mstdv

w_data-dwerk

w_data-taxkm

w_data-versg

w_data-kondm

w_data-ktgrm

w_data-mtpos

w_data-mtvfp

w_data-tragr

w_data-ladgr

w_data-herkl

w_data-ekgrp

w_data-webaz

w_data-dismm

w_data-beskz

w_data-prctr

w_data-bklas

w_data-bwtty

w_data-vprsv

w_data-verpr

IN CHARACTER MODE.

APPEND w_data TO i_data.

CLEAR w_data.

ENDIF.

ENDDO.

CLOSE DATASET l_filename.

-


Error Message while executing

What happened?

At the conversion of a text from codepage '4110' to codepage '4102':

- a character was found that cannot be displayed in one of the two

codepages;

- or it was detected that this conversion is not supported

The running ABAP program 'ZHDI_LOMM_VEHI_MAT_MASS_CREATE' had to be terminated

as the conversion

would have produced incorrect data.

The number of characters that could not be displayed (and therefore not

be converted), is 449. If this number is 0, the second error case, as

mentioned above, has occurred.

Error analysis

An exception occurred that is explained in detail below.

The exception, which is assigned to class 'CX_SY_CONVERSION_CODEPAGE', was not

caught in

procedure "F_DATA_UPLOAD" "(FORM)", nor was it propagated by a RAISING clause.

Since the caller of the procedure could not have anticipated that the

exception would occur, the current program is terminated.

The reason for the exception is:

Characters are always displayed in only a certain codepage. Many

codepages only define a limited set of characters. If a text from a

codepage should be converted into another codepage, and if this text

contains characters that are not defined in one of the two codepages, a

conversion error occurs.

Moreover, a conversion error can occur if one of the needed codepages

'4110' or '4102' is not known to the system.

If the conversion error occurred at read or write of screen, the file

name was '/usr/sap/interfaces/conversion/pioneer/ddm/data/test_data1.xls'.

(further information about the file: "X 549

24064rw-rw----200812232135082008122307293120081223072931")

Please help me

Thank You

6 REPLIES 6
Read only

former_member194669
Active Contributor
0 Likes
1,003

Try to change this way


  OPEN DATASET l_filename FOR INPUT IN TEXT MODE ENCODING NON-UNICODE.

a®

Read only

0 Likes
1,003

Woah ... perfect guru

but data looks like all junk characters ? its filling with special characters, hashes # and other characters but not with Excel data.. any idea ??

Temesh

Edited by: New2Sap Abap on Dec 24, 2008 6:42 AM

Read only

former_member194669
Active Contributor
0 Likes
1,003

you want to read EXCEL files from application server is not possible, you need to create the file as CSV

(coma delimited) or TXT file. But you can read EXCEL file from you local system(presebtation server)

a®

Read only

0 Likes
1,003

Oh so from Presentations Server its possible, but NOT from Application Server. Which FM should i use to convert Excel to CSV/TEXT to do that ??

Read only

0 Likes
1,003

check this

https://forums.sdn.sap.com/search.jspa?threadID=&q=uploadANDexcel+&objID=f50&dateRange=thisyear&numResults=15

a®

Read only

Former Member
0 Likes
1,003

changes done.