‎2008 Jan 31 3:59 PM
Hi Experts,
I need to take a document from sapia and attach it under a specified audit component in plmd_audit transaction.
I tried using this function module "BDS_BUSINESSDOCUMENT_CREATEF" ,but it gives "Transfer Error".
In the Files table under directory i passed the sapia path.
Please give some suggestions.
Thanks !
Keerthi vasan.M
‎2008 Feb 01 5:32 AM
uploading into BW Docs after reading the files from application server . Check it so as to get some idea.
REPORT ZMAST_BWDOC_IMPORT.
TEXT ELEMENTS
001 Error reading file/directory
002 Error uploading file
003 Successfully Loaded
DATA: l_s_chavl TYPE rsod_s_chanm_chavl.
DATA: l_t_chavl TYPE TABLE OF rsod_s_chanm_chavl.
DATA: l_s_excpt(5) TYPE c.
DATA: l_t_data_tab_asc TYPE sdokcntascs.
DATA: l_t_data_tab_bin TYPE sdokcntbins.
DATA: rc TYPE sy-subrc.
DATA: wa_dir(100). " like file_info.
DATA: day(2) TYPE c.
DATA: l_s_content_info TYPE rsod_s_content_info.
DATA: dir_tab TYPE STANDARD TABLE OF file_info.
DATA: dir_entry(100).
*DATA: p_path(40) type C .
DATA: l_s_peri LIKE t009b-poper.
DATA: l_s_per(2) TYPE c.
TYPES: BEGIN OF fileinfostruc,
zcustomer(18),
END OF fileinfostruc.
TYPES: date TYPE sy-datum.
DATA: l_s_year LIKE t009b-bdatj.
DATA: fileinfo TYPE fileinfostruc.
DATA: date TYPE date.
DATA: count TYPE i.
DATA: len TYPE i.
DATA: offset TYPE i.
DATA: id TYPE i.
DATA: filename TYPE string.
DATA: thema TYPE string.
DATA: pfad TYPE c.
DATA: dir TYPE string.
DATA: descr TYPE sdok_descr.
DATA: name TYPE skwf_urlp.
DATA: l_t_return TYPE bapiret2.
DATA: l_filelength TYPE i.
DATA: file_tab TYPE filetable,
single_file TYPE filetable.
DATA: file_line LIKE LINE OF file_tab.
DATA: ls_path TYPE string.
INTERFACE IF_RSOD_CONST LOAD.
PARAMETER p_path(40) OBLIGATORY DEFAULT 'C:\'.
Display file selection dialog
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
PERFORM get_files.
START-OF-SELECTION.
PERFORM section_main.
&----
*& Form get_files
&----
text
-
FORM get_files.
dir = p_path.
DATA: folder TYPE string.
CALL METHOD cl_gui_frontend_services=>directory_browse
EXPORTING
WINDOW_TITLE =
initial_folder = 'C:\'
CHANGING
selected_folder = folder.
EXCEPTION
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
others = 4
IF sy-subrc 0.
add your error message here
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
p_path = folder.
*fetch all files from directory, use *.doc as mask
CALL METHOD cl_gui_frontend_services=>directory_list_files
EXPORTING
directory = folder
filter = '*.doc'
files_only = 'X'
DIRECTORIES_ONLY =
CHANGING
file_table = dir_tab
count = count
EXCEPTIONS
cntl_error = 1
directory_list_files_failed = 2
wrong_parameter = 3
error_no_gui = 4
not_supported_by_gui = 5
OTHERS = 6.
ENDFORM. "get_files
&----
*& Form section_main
&----
text
-
FORM section_main.
LOOP AT dir_tab INTO dir_entry.
Build filename
TRANSLATE dir_entry TO UPPER CASE.
CLEAR: filename.
CONCATENATE p_path '\' dir_entry INTO filename.
call upload
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = filename
filetype = 'BIN'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
IMPORTING
filelength = l_filelength
TABLES
data_tab = l_t_data_tab_bin
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc 0.
WRITE: / text-002, sy-subrc, dir_entry. "Error in uploading File
EXIT.
ENDIF.
fill assignments for Customer
len = strlen( dir_entry ) - 4.
REFRESH l_t_chavl.
l_s_chavl-chanm = 'ZCUSTOMER'.
l_s_chavl-chavl = dir_entry+0(len).
APPEND l_s_chavl TO l_t_chavl.
set mime-type
l_s_content_info-mimetype = 'application/msword'.
l_s_content_info-file_name = dir_entry.
l_s_content_info-file_size = l_filelength.
set name and title
name = dir_entry.
CLEAR l_t_return.
upload document
CALL FUNCTION 'RSOD_DOC_MAST_CHANGE'
EXPORTING
i_chanm = l_s_chavl-chanm
i_chavl = l_s_chavl-chavl
I_DOC_TYPE =
i_description = descr
i_name = name
I_LANGU = SY-LANGU
i_overwrite_mode = if_rsod_const=>mode_replace_phio
i_with_content = 'X'
i_s_content_info = l_s_content_info
I_WITH_URL =
I_URL =
I_COPY_URL_CONTENT =
IMPORTING
E_NAME =
e_s_return = l_t_return
TABLES
i_t_file_content_ascii = l_t_data_tab_asc
i_t_file_content_binary = l_t_data_tab_bin.
IF l_t_return-type = 'E' OR
l_t_return-type = 'W' OR
l_t_return-type = 'A'.
error
WRITE: / dir_entry(25), text-004, l_t_return-type,
l_t_return-id, l_t_return-number.
ELSE.
successfuly loaded
WRITE: / dir_entry(25), text-003.
ENDIF.
ENDLOOP.
ENDFORM. "section_main
kindly reward if found helpful
‎2010 Oct 20 5:16 AM