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: 

how can i upload XML from server

Former Member
0 Kudos

Hi

i want to upload XML file from application server

so i don't want to use gui_upload (all the threads i saw in forum use the gui_upload or fronted)

i used

could you say me how i can do it ?

thanks a lot

serge

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

If you have the XML file on application server,

you can use OPEN DATASET statement.

eg.

DATA: line TYPE string,

file(20) TYPE C value '/usr/test.dat'.

OPEN DATASET file IN TEXT MODE ENCODING DEFAULT FOR INPUT.

DO.

READ DATASET file INTO line.

IF sy-subrc <> 0.

EXIT.

ENDIF.

WRITE: / line.

ENDDO.

CLOSE DATASET file.

Regards,

Shashank

5 REPLIES 5

Former Member
0 Kudos

Hi serge,

1. we have to use OPEN DATASET, READ, CLOSE DATASET,

to upload file from application server.

2. It does not matter whether its an xml file,

or text file.

regards,

amit m.

0 Kudos

But you need to remove the XML tags.

Former Member
0 Kudos

Hi again,

1. After using DATASET,

and getting the raw xml text file,

into an internal table (eg. UPL)

2. just use this logic.

3.

*----


DATA : BEGIN OF upl OCCURS 0,

f(255) TYPE c,

END OF upl.

DATA: xmlupl TYPE string .

DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.

*----


LOOP AT upl.

CONCATENATE xmlupl upl-f INTO xmlupl.

ENDLOOP.

*----


XML

CALL TRANSFORMATION ('ID')

SOURCE XML xmlupl

RESULT tab = t001[]

.

BREAK-POINT.

regards,

amit m.

Former Member
0 Kudos

Hi,

If you have the XML file on application server,

you can use OPEN DATASET statement.

eg.

DATA: line TYPE string,

file(20) TYPE C value '/usr/test.dat'.

OPEN DATASET file IN TEXT MODE ENCODING DEFAULT FOR INPUT.

DO.

READ DATASET file INTO line.

IF sy-subrc <> 0.

EXIT.

ENDIF.

WRITE: / line.

ENDDO.

CLOSE DATASET file.

Regards,

Shashank

Former Member
0 Kudos

Hi,

You can use OPEN DATASET for this purpose.

Try this code:

<b>****************************************</b>

Data:

A_FILE TYPE RLGRAP-FILENAME, "Application server

P_FILE TYPE RLGRAP-FILENAME. "Presentation server

DATA: BEGIN OF ITAB OCCURS 0,

LINE TYPE STRING,

END OF ITAB.

DATA: FILENAME TYPE STRING.

FILENAME = P_FILE.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = FILENAME

TABLES

DATA_TAB = ITAB[]

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

OPEN DATASET A_FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

LOOP AT ITAB.

TRANSFER ITAB-LINE TO A_FILE.

ENDLOOP.

<b>*****************************************</b>

Hope this helps,

Regards,

Pragya