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: 

download from background

Former Member
0 Kudos

hi,

i have a program running background. how can i download to local as xls file from internal table. is there any way?

thanks

4 REPLIES 4

Former Member
0 Kudos

eI,

If you want to down load the output through excel from your back ground program it is very tuff.You need to use FTP Function modules for this .

================================================

FTP Using SAP Functions

Here is an example of how to FTP a file from the Application server to a remote server using standard SAP functions.

Source Code Listing

REPORT ZKBTST32 LINE-SIZE 132.

*----


  • Test SAP FTP functions

*----


DATA: BEGIN OF MTAB_DATA OCCURS 0,

LINE(132) TYPE C,

END OF MTAB_DATA.

DATA: MC_PASSWORD(20) TYPE C,

MI_KEY TYPE I VALUE 26101957,

MI_PWD_LEN TYPE I,

MI_HANDLE TYPE I.

START-OF-SELECTION.

MC_PASSWORD = 'password'.

DESCRIBE FIELD MC_PASSWORD LENGTH MI_PWD_LEN.

*-- FTP_CONNECT requires an encrypted password to work

CALL 'AB_RFC_X_SCRAMBLE_STRING'

ID 'SOURCE' FIELD MC_PASSWORD ID 'KEY' FIELD MI_KEY

ID 'SCR' FIELD 'X' ID 'DESTINATION' FIELD MC_PASSWORD

ID 'DSTLEN' FIELD MI_PWD_LEN.

CALL FUNCTION 'FTP_CONNECT'

EXPORTING

USER = 'userid'

PASSWORD = MC_PASSWORD

HOST = 'servername'

RFC_DESTINATION = 'SAPFTP'

IMPORTING

HANDLE = MI_HANDLE

EXCEPTIONS

NOT_CONNECTED = 1

OTHERS = 2.

CHECK SY-SUBRC = 0.

CALL FUNCTION 'FTP_COMMAND'

EXPORTING

HANDLE = MI_HANDLE

COMMAND = 'dir'

TABLES

DATA = MTAB_DATA

EXCEPTIONS

TCPIP_ERROR = 1

COMMAND_ERROR = 2

DATA_ERROR = 3

OTHERS = 4.

IF SY-SUBRC = 0.

LOOP AT MTAB_DATA.

WRITE: / MTAB_DATA.

ENDLOOP.

ELSE.

  • do some error checking.

ENDIF.

CALL FUNCTION 'FTP_DISCONNECT'

EXPORTING

HANDLE = MI_HANDLE

EXCEPTIONS

OTHERS = 1.

================================================

If you want to download it from other program you have to use the concept

OPEN DATASETS.

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

for uploading you have to use TRANSFER command

DAta FNAME(20) value 'AMIT'

TYPES: Begin of line,

col1 type I,

col2 type I,

end of line.

TYpES ITAB type LIN occurs 10.

DAta: lin type line,

tab type itab.

OPEN DATASET FNAME FOR OUTPUT.

LOOP AT ITAB.

TRNASFER LIN TO FNAME.

ENDLoop.

OPEN DATASET FNAME for Input.

DO.

READ DATASET FNAME into LIN.

if sy-subrc <> o.

exit.

endif.

write: / lin-col1, lin-col2.

enddo.

close dataset FNAME.

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

OR you can use tcode "CG3Y" to download.To upload "CG3Z".

Don't forget to reward if useful....

Former Member
0 Kudos

hi

you can make use of user-exits to dowload the pragram running in background ti xls file.

regards

ravish

reward if helpful

vimal_kumar4
Explorer
0 Kudos

Hi,

One option is use write statement and o/p all the values in the internal table. When the program is run in the background it will generate a spool. Go to the spool and in the menu use Spool Request -> Forward -> Save to local file. Here u can save it using .xls format.

Another option is using OPEN DATASET and TRANSFER statement move the file to an unix location /a/b/c and go to AL11 transaction go the directory /a/b/c and double click on the filename. Use the menu option System -> List -> Save -> Local File. Here u can save it using .xls format.

Regards

Vimal

Former Member
0 Kudos

Hi,

I suggest you create a tab delimited text file as a background job and save it on an external server that is accessible to the PC user. The user can then open this file using Excel. To save the tab delimited file on the external server, you can use the function module FTP_CONNECT and the FTP command PUT in the function module FTP_COMMAND.

Regards

Sudheer