2008 Apr 23 12:59 PM
Hi all,
I want to upload internal table records to Application server in a text file with the column text( header text ).
how can i do this.
thanks .
2008 Apr 23 1:03 PM
Hi,
Before passing output data from internal table to function module, append column headings to the internal table.
Hope this solves ur issue.
regards,
Ramya
Hi all,
I want to upload internal table records to Application server in a text file with the column text( header text ).
how can i do this.
thanks .
2008 Apr 23 1:03 PM
Hi,
Before passing output data from internal table to function module, append column headings to the internal table.
Hope this solves ur issue.
regards,
Ramya
2008 Apr 23 1:36 PM
@ ramya.
But, my internal table contains fields of one character, so i cant append the column heading of 10-15 characters.
is there any other solution.
2008 Apr 23 1:44 PM
If you are outputting with a delimited file, it won't make a difference when they import.
If you are not using delimited tags, then you will need to format the lines before you output them to be underneath the headings.
2008 Apr 23 1:56 PM
Here's an example
DATA:
BEGIN OF out_rec,
col1(20),
col2(20),
col3(20),
END OF out_rec,
itlines LIKE STANDARD TABLE OF out_rec.
out_rec-col1 = 'Head1'.
out_rec-col2 = 'Head2'.
out_rec-col3 = 'Head3'.
SHIFT out_rec-col1 RIGHT DELETING TRAILING space.
SHIFT out_rec-col2 RIGHT DELETING TRAILING space.
SHIFT out_rec-col3 RIGHT DELETING TRAILING space.
APPEND out_rec TO itlines.
out_rec-col1 = 'A'.
out_rec-col2 = 'B'.
out_rec-col3 = 'C'.
SHIFT out_rec-col1 RIGHT DELETING TRAILING space.
SHIFT out_rec-col2 RIGHT DELETING TRAILING space.
SHIFT out_rec-col3 RIGHT DELETING TRAILING space.
APPEND out_rec TO itlines.
LOOP AT itlines INTO out_rec.
WRITE:/ out_rec. " do your TRANSFER here instead of the write.
ENDLOOP.
2008 Apr 23 2:05 PM
@ Paul
Thanks for explaining me with the example...
i got the logic.
but i hw can i give tab delimeter .
2008 Apr 23 2:14 PM
Here's an example.
CONSTANTS:
c_tab TYPE x VALUE '09'.
DATA:
out_rec(132),
itlines LIKE STANDARD TABLE OF out_rec.
CONCATENATE 'Head1' 'Head1' 'Head3' INTO out_rec
SEPARATED BY c_tab.
* Do TRANSFER to OUTFILE.
* loop thru your table.
CONCATENATE table-field1
table-field2
table-field3
INTO out_rec
SEPARATED BY c_tab.
* Do TRANSFER to OUTFILE.
* endloop here
2008 Apr 24 8:59 AM
Thanks Paul, it solved my problem.
i have given points for ur help.
2008 Apr 23 1:05 PM
Please have a look at below link:
http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3c7f358411d1829f0000e829fbfe/frameset.htm
Example
The binary data from database table SPFLI is transferred to a binary file flights.dat. The structure of the table rows transferred contains both character-type and numerical fields. Since the type-specific storage of mixed structures in files is not possible, the binary content of the structure is directly accessed using a typed field symbol . To attain the same result, you can directly transfer the structure wa, the recommended procedure is to use the field symbol, however, because it explicitly transfers a binary data type to a binary file. This type of storage is only recommended for short-term storage within the same system, because the byte-type content depends on the byte sequence and the current system code page. For long-term storage or for exchanging between systems, the data should be converted to character-type containers and stored as a text file.
DATA: file TYPE string VALUE `flights.dat`,
wa TYPE spfli.
FIELD-SYMBOLS TYPE x.
OPEN DATASET file FOR OUTPUT IN BINARY MODE.
SELECT *
FROM spfli
INTO wa.
ASSIGN wa TO CASTING.
TRANSFER TO file.
ENDSELECT.
CLOSE DATASET file.
Thanks,
Vibha
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Apr 23, 2008 12:38 PM
2008 Apr 23 1:10 PM
2008 Apr 23 1:11 PM
Before you begin the DO..READ..ENDDO to process the table, and after you've opened the dataset, write your heading line that you
would build containing just the headings.
2008 Apr 23 1:12 PM
hi,,,,
refer this program.....hope it will be useful
REPORT ZEXAMPLE.
DATA: BEGIN OF ITAB OCCURS 0,
COLA(10),
COLB(10),
END OF ITAB.
DATA: V_DIR LIKE RLGRAP-FILENAME,
V_FNAME LIKE RLGRAP-FILENAME,
V_DEST LIKE RLGRAP-FILENAME.
PARAMETERS: P_DIR LIKE RLGRAP-FILENAME,
P_FNAME LIKE RLGRAP-FILENAME.
CALL FUNCTION 'GUI_CREATE_DIRECTORY'
EXPORTING
DIRNAME = P_DIR
EXCEPTIONS
FAILED = 1
OTHERS = 2.
IF SY-SUBRC NE 0.
WRITE:/ 'DIRECTORY', P_DIR, 'NOT CREATED'.
ELSE.
WRITE:/ 'DIRECTORY CREATED:', P_DIR.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = P_FNAME
FILETYPE = 'ASC'
TABLES
DATA_TAB = ITAB
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
OTHERS = 6.
IF SY-SUBRC NE 0.
WRITE:/ 'COULD NOT UPLOAD', P_FNAME.
ELSE.
CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
EXPORTING
FULL_NAME = P_FNAME
IMPORTING
STRIPPED_NAME = V_FNAME
FILE_PATH = V_DIR
EXCEPTIONS
X_ERROR = 1
OTHERS = 2.
IF SY-SUBRC NE 0.
WRITE:/ 'COULD NOT SPLIT', P_FNAME, 'INTO DIRECTORY AND FILENAME'.
ELSE.
CONCATENATE P_DIR V_FNAME INTO V_DEST.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = V_DEST
FILETYPE = 'ASC'
TABLES
DATA_TAB = ITAB
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
OTHERS = 5.
IF SY-SUBRC NE 0.
WRITE:/ 'COULD NOT DOWNLOAD', V_DEST, 'INTO', P_DIR.
ELSE.
WRITE:/ 'FILE', V_FNAME, 'MOVED FROM', V_DIR, 'TO', P_DIR.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
<REMOVED BY MODERATOR>
regards,
rekha
Edited by: Alvaro Tejada Galindo on Apr 23, 2008 12:39 PM
2008 Apr 23 1:12 PM
hi,
You can use opendataset concept.
data : l_line type string.
open dataset p_filename for output in text mode.
If sy-subrc = 0.
loop at i_output into w_output.
concatenate w_output-field1
w_output-field2
into l_line seperated by ','.
transfer l_line to p_filename.
endloop.
endif.
close dataset p_filename.
Now your internal table records will be uploaded in p_filename.
If you want to see it in application server , go to transaction AL11 and double click on your filename .
2008 Apr 23 1:32 PM
thanks for the reply,
but my requirement is to have column heading in the text file on the application server after download.
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |