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: 

Excel file on Application server

former_member200874
Participant
0 Kudos
84

Hi All,

Can an Excel file be put on application server, I mean in 'AL11' directory path?

If yes, please let me knoe how it can be done.

Thanks in advance for all your time to resolve the query.

Regards

-Jawahar

1 REPLY 1

former_member194669
Active Contributor
0 Kudos
50

Hi,

Following is some sample code I put together that will convert internal tables to a delimited format and write to the server. This is something that comes up frequently and this is the easiest way I've found to do it yet. Coding it into a function module is a good idea for easy re-use. This is very basic functionality and, of course, custom improvements, error-checking, etc., could and should be added as needed.


REPORT Z_DELIM_DEMO. 

DATA: BEGIN OF ITAB OCCURS 0, 
FIELD1(10) TYPE C, 
FIELD2(10) TYPE C, 
FIELD3(10) TYPE C, 
END OF ITAB. 
* ITAB = any internal table - fields should all be type c. 

data: EXCEL_STRING(2000) type c, 
comma(1) type c value ',', 
unixpath(80) type c. 

constants: ascii_tab type x value '09'. 

field-symbols: <f>, <delim>. 

*Assign delimiter field such as tab or comma. 
assign ASCII_tab to <delim>. 


*Assign a valid Unix path and filename. 
unixpath = '/INTERFACES/DV2/out/delimiter_test.xls'. 

*fill itab with some text. Normally, you'd pass real data. 
move 'THIS IS A TEST' TO ITAB. 
APPEND ITAB. 
MOVE 'OUTPUT WILL BE DELIMITED' TO ITAB. 
APPEND ITAB. 

*Open the dataset so we can transfer the data. 
open dataset unixpath for output in text mode. 

LOOP AT ITAB. 
DO. 
* assigns the next field in the current header to <f>. 
ASSIGN COMPONENT sy-index OF STRUCTURE ITAB TO <f>. 
IF sy-subrc <> 0. "no fields left in the header structure. 
EXIT. "exits do loop and process next record in itab 
ENDIF. 

IF sy-index = 1. "if first field in header, assign to string 
excel_string = <f>. 
ELSE. "concatenate string, delimter, next field 
CONCATENATE excel_string <delim> <f> INTO excel_string. 
ENDIF. 
ENDDO. 
* string is now delimited. Transfer to server. 
TRANSFER excel_string TO unixpath. 
ENDLOOP. 

close dataset unixpath.

aRs