Go to Tcode AL11
Find the available sap directories.
FORM SAP_TO_FTP_SERVER .
types: begin of t_file,
text(1000) type c,
end of t_file.
DATA: gt_file type table of t_file,
gs_file type t_file.
*DATA: FILE TYPE STRING VALUE 'TEST.CSV'.
DATA: e_file like rlgrap-filename value '/tmp/mnt_test_nfs/file.xls'.
*DATA: l_user(30) type c value 'testftp',
* l_pwd(30) type c value 'S@pc$$fTp15#',
* l_host(64) type c value '10.2.52.144',
* l_dest like rfcdes-rfcdest value 'SAPFTPA'.
*
*DATA:
* w_hdl type i,
* c_key type i value 26101957,
* l_slen type i.
*
clear gs_final1.
loop at gt_final1 into gs_final1.
*
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = gs_final1-g1
IMPORTING
OUTPUT = gs_final1-g1
.
*
CONDENSE: gs_final1-g1, gs_final1-g2, gs_final1-g3, gs_final1-g4, gs_final1-g5, gs_final1-g6, gs_final1-g7, gs_final1-g8,
gs_final1-g9, gs_final1-g10, gs_final1-g11, gs_final1-g12, gs_final1-g13, gs_final1-g14, gs_final1-g15, gs_final1-g16, gs_final1-g17, gs_final1-g18,
gs_final1-g19, gs_final1-g20, gs_final1-g21, gs_final1-g22, gs_final1-g23, gs_final1-g24, gs_final1-g25, gs_final1-g26,
gs_final1-g27, gs_final1-g28, gs_final1-g29, gs_final1-g30, gs_final1-g31, gs_final1-g32, gs_final1-g33, gs_final1-g34,
gs_final1-g35, gs_final1-g36, gs_final1-g37, gs_final1-g38, gs_final1-g39, gs_final1-g40, gs_final1-g41, gs_final1-g42, gs_final1-g43,
gs_final1-g44, gs_final1-g45, gs_final1-g46, gs_final1-g47 no-gaps.
concatenate gs_final1-g1 gs_final1-g2 gs_final1-g3 gs_final1-g4 gs_final1-g5 gs_final1-g6 gs_final1-g7 gs_final1-g8
gs_final1-g9 gs_final1-g10 gs_final1-g11 gs_final1-g12 gs_final1-g13 gs_final1-g14 gs_final1-g15 gs_final1-g16 gs_final1-g17 gs_final1-g18
gs_final1-g19 gs_final1-g20 gs_final1-g21 gs_final1-g22 gs_final1-g23 gs_final1-g24 gs_final1-g25 gs_final1-g26
gs_final1-g27 gs_final1-g28 gs_final1-g29 gs_final1-g30 gs_final1-g31 gs_final1-g32 gs_final1-g33 gs_final1-g34
gs_final1-g35 gs_final1-g36 gs_final1-g37 gs_final1-g38 gs_final1-g39 gs_final1-g40 gs_final1-g41 gs_final1-g42 gs_final1-g43
gs_final1-g44 gs_final1-g45 gs_final1-g46 gs_final1-g47 into gs_file separated by ','.
append gs_file to gt_file.
clear: gs_file, gs_final1.
endloop.
*concatenate '/tmp/mnt_test_nfs/test_' so_org-low '.csv' into e_file.
open dataset e_file for output in text mode encoding default.
if sy-subrc ne 0.
write: 'error opening file'.
endif.
loop at gt_file into gs_file.
transfer gs_file to e_file.
endloop.
*endloop.
close dataset e_file.
refresh gt_file.
*endif.
*
*set extended check off.
*
*l_slen = strlen( l_pwd ).
*
*CALL FUNCTION 'HTTP_SCRAMBLE'
* EXPORTING
* SOURCE = l_pwd
* SOURCELEN = l_slen
* KEY = c_key
* IMPORTING
* DESTINATION = l_pwd
* .
*
*CALL FUNCTION 'FTP_CONNECT'
* EXPORTING
* USER = l_user
* PASSWORD = l_pwd
** ACCOUNT =
* HOST = l_host
* RFC_DESTINATION = l_dest
** GATEWAY_USER =
** GATEWAY_PASSWORD =
** GATEWAY_HOST =
* IMPORTING
* HANDLE = w_hdl
** EXCEPTIONS
** NOT_CONNECTED = 1
** OTHERS = 2
* .
*IF SY-SUBRC <> 0.
** Implement suitable error handling here
*ENDIF.
*
*CALL FUNCTION 'FTP_R3_TO_SERVER'
* EXPORTING
* HANDLE = w_hdl
* FNAME = '/Remedy'
** BLOB_LENGTH =
** CHARACTER_MODE =
* TABLES
** BLOB =
* TEXT = gt_file
* EXCEPTIONS
* TCPIP_ERROR = 1
* COMMAND_ERROR = 2
* DATA_ERROR = 3
* OTHERS = 4
* .
*IF SY-SUBRC <> 0.
** Implement suitable error handling here
*
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4 RAISING invalid_output_file.
*ENDIF.
*
*CALL FUNCTION 'FTP_DISCONNECT'
* EXPORTING
* HANDLE = w_hdl
* .
*
*CALL FUNCTION 'RFC_CONNECTION_CLOSE'
* EXPORTING
* DESTINATION = l_dest
** TASKNAME =
* EXCEPTIONS
* DESTINATION_NOT_OPEN = 1
* OTHERS = 2
* .
*IF SY-SUBRC <> 0.
** Implement suitable error handling here
*ENDIF.
*
ENDFORM.
No comments:
Post a Comment