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

Write file to sap server

Former Member
0 Likes
1,105

Hello

I am using the fm GUI_DOWNLOAD to create a file and i want to write it on the sap server.How can this be done?We have an sap server which is running on linux and i've tried to write in one of the directories on the server,but instead it created that whole directory structure on my harddrive and not on the server

i gave the path something like this : /home/......

I also tried to write on an remote server which is accessible through internet explorer but when trying to write it with the bapi i get access denied.

Or maybe if you have any other solutions.

Thank you

Hello

I am using the fm GUI_DOWNLOAD to create a file and i want to write it on the sap server.How can this be done?We have an sap server which is running on linux and i've tried to write in one of the directories on the server,but instead it created that whole directory structure on my harddrive and not on the server

i gave the path something like this : /home/......

I also tried to write on an remote server which is accessible through internet explorer but when trying to write it with the bapi i get access denied.

Or maybe if you have any other solutions.

Thank you

5 REPLIES 5
Read only

Former Member
0 Likes
1,034

I have found a very simple way to write to sap server, on linux of course:

PARAMETERS: P-FILE(50) TYPE C DEFAULT '/home/ftpwe/masterdata/cust_enhc.txt' LOWER CASE.

data: gv_msg(100) type c.

......

fill gt_datatab with information

.......

OPEN DATASET P-FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT MESSAGE GV_MSG.

IF SY-SUBRC NE 0.

WRITE: / 'File cannot be opened.Reason: ', GV_MSG.

ELSE.

LOOP AT GT_DATATAB INTO GS_DATATAB.

TRANSFER GS_DATATAB TO P-FILE.

ENDLOOP.

CLOSE DATASET P-FILE.

ENDIF.

Read only

Former Member
0 Likes
1,034

Now i have managed to write the file on the sap server but i cannot read it with the lsmw.

I have tried all the 3 encoding formats but none of them is working,does anyone know how i can solve this problem?

Thank you

Read only

0 Likes
1,034

Hai,

In LSMW in Assign files step, we have two options to pick the file. One is Legacy system (On PC) then one more is From application server(Second one). Check whether you have selected the second option and also check whether you have given the right path. May be this will help you.

Regards,

Prabu S.

Read only

0 Likes
1,034

It is selected to read from the server,but the file encoding is not right.

I have tried to use the unix linefeed but i get an error and i do not know why

open dataset gv_file for output in text mode encoding default with unix linefeed.

Error: Unable to interpret "with"

What am i doing wrong?

Read only

0 Likes
1,034

Now i am using it like this:

data: gv_string type string.

OPEN DATASET P-FILE FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE MESSAGE GV_MSG.

IF SY-SUBRC NE 0.

WRITE: / 'File cannot be opened.Reason: ', GV_MSG.

ELSE.

LOOP AT itab INTO wa.

CONCATENATE wa-field1 wa-field2 INTO GV_STRING SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

TRANSFER GV_STRING TO P-FILE.

ENDLOOP.

CLOSE DATASET P-FILE.

and it solved moy problem.Thank you