2007 Nov 01 8:34 PM
Hi,
I need a function module to which i will pass a internal table and the output should be a flat file with pipe delimeted.
Regards
Hiren K.Chitalia
Hi Hiren,
You have to use Open dataset, Transfer, Close dataset statements for transferring your data from the internal table to the application server.
While transferring you can concatenate the character '|' between the fields if a pipe delimited file is required.
See the link below for an example of Downloading a file to an application server.
(Its tab delimited)
Regards,
Abhishek
2007 Nov 01 8:36 PM
And that particular flat file i need to post on a ftp server
2007 Nov 01 9:15 PM
Hi Hiren,
You have to use Open dataset, Transfer, Close dataset statements for transferring your data from the internal table to the application server.
While transferring you can concatenate the character '|' between the fields if a pipe delimited file is required.
See the link below for an example of Downloading a file to an application server.
(Its tab delimited)
Regards,
Abhishek
2007 Nov 01 8:44 PM
Hiran,
I am not sure if you really need a function module for this task. You can directly write internal table data in application server.
Please check below code.
upload from application server.
tables : ZDEPARTMENT_TMP.
data : itab like ZDEPARTMENT_TMP occurs 0 with header line.
constants File(30) type C value '/usr/tmp/sri1111.txt'.
open dataset File for input in text mode.
do.
read dataset File into itab.
if sy-subrc <> 0.
write 😕 'No more records'.
exit.
else.
append itab.
endif.
enddo.
close dataset File.
loop at itab.
write 😕 itab-EMPID,itab-EMP_DEPT,itab-EMP_PROJ,itab-EMP_CUBE,
itab-EMP_PH_NO.
ZDEPARTMENT_TMP-EMPID = itab-EMPID.
ZDEPARTMENT_TMP-EMP_DEPT = itab-EMP_DEPT.
ZDEPARTMENT_TMP-EMP_PROJ = itab-EMP_PROJ.
ZDEPARTMENT_TMP-EMP_CUBE = itab-EMP_CUBE.
insert ZDEPARTMENT_TMP.
endloop.
2007 Nov 01 8:47 PM
2007 Nov 01 8:49 PM
You can use the field separator as 'I' pipe symbol.
Reward if it is useful.
Thanks,
Srinivas
2007 Nov 02 1:19 AM
Hi, Hiren
you can define another internal table IT_LINE which contain only one record, like CHAR300, and convert the records in original internal into the IT_LINE, convert one record into one line.
Then use the below function to transferyour data to FTP.
c_dest LIKE rfcdes-rfcdest VALUE 'SAPFTP',
c_key TYPE i VALUE 26101957.
1. Convert the password
data: g_ftp_pwd(20).
g_ftp_pwd = 'tx02ut'.
g_slen = STRLEN( g_ftp_pwd ).
CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
SOURCE = g_ftp_pwd
sourcelen = g_slen
key = g_key
IMPORTING
destination = g_ftp_pwd.
2. Connect FTP
data: g_rfcdes_rfcdest LIKE rfcdes-rfcdest VALUE 'SAPFTP'.
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = 'whqtr'
password = g_ftp_pwd
host = g_ip
rfc_destination = g_rfcdes_rfcdest
IMPORTING
handle = g_hdl
EXCEPTIONS
not_connected = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
3. Transfer file
CALL FUNCTION 'FTP_R3_TO_SERVER'
EXPORTING
handle = g_handle
fname = g_filename_tmp
blob_length = c_blob
character_mode = 'X'
TABLES
text = pt_contents
EXCEPTIONS
tcpip_error = 1
command_error = 2
data_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
p_retcd = 3. "Put file fail
RETURN.
ENDIF.
4. Close FTP Connect
CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
handle = g_hdl.
CALL FUNCTION 'RFC_CONNECTION_CLOSE'
EXPORTING
destination = g_rfcdes_rfcdest
EXCEPTIONS
OTHERS = 1.
Hope this helpful
Regards.
2007 Nov 02 3:20 AM
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |