2007 Mar 17 1:58 PM
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
2007 Mar 17 4:28 PM
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