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

Copy file on application server with codepage changed

Martin_Kuma
Active Contributor
0 Likes
716

Hello Gurus,

I need to copy an existing *.csv file on the application server to a different location as a *.txt file with the code page UTF-8 /8400/ in the background.

Example:

I have a file with the name is: 'new.csv' in the DIR: '/SERVER/NEW'.

I need to convert the file to 'UTF-8' and copy to DIR: '/SERVER/ARCHIVE' with the name: 'archive.txt'

I was able to get the file via FM: DX_FILE_READ into an internal table. Now I tried to use GUI_UPLOAD, but failed due to the fact the GUI_UPLOAD will just upload a file from PC to an internal table. Additionally I need to run the report in background. So the FG: SFES will not do.

Could you please give me a hint on this?

I am running in a circle

Any help will be rewarded.

Thank you!

Martin

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
550

Hi Martin,

As you know any presentation server upload FM's will not work in background.

But there is a workaround. Check below may help you

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/9831750a-0801-0010-1d9e-f8c64efb...

Regards,

Atish

3 REPLIES 3
Read only

Former Member
0 Likes
551

Hi Martin,

As you know any presentation server upload FM's will not work in background.

But there is a workaround. Check below may help you

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/9831750a-0801-0010-1d9e-f8c64efb...

Regards,

Atish

Read only

Former Member
0 Likes
550

Hi Martin,

While reading from the directory use OPEN DATASET FOR INPUT and read the data to internal table.

Now you got data in you internal table, move data from internal table to APP SERVER to the necessary directory using OPEN DATASET FOR OUTPUT.

Hope your problem will get resolved.

Reward points if it helps,

Satish

Read only

Martin_Kuma
Active Contributor
0 Likes
550

Hello Atish, Satish

Thank you for the quick answer!

@Atish,

Your guide is very helpful and I have downloaded it for further use, however I do not need to make any uploads/downloads from and to PC in the background.

@Satish

The OPEN DATASET helped. This works in the background as well.

I have allotted points to both of you as promised.

Thanks again!

Sample of the code I used:

OPEN DATASET g_out_file FOR OUTPUT IN TEXT MODE ENCODING UTF-8.

LOOP AT lt_file INTO ll_file.

TRANSFER ll_file TO g_out_file.

ENDLOOP.

CLOSE DATASET g_out_file.

Where g_out_file is the path and file name and lt_file and ll_file are internal tables I retrieve by FM: DX_FILE_READ /type: dxrawdata/