Skip to Content
0
Former Member
Aug 15, 2012 at 10:22 PM

Copying files from BPC to App.Server (AL11)

501 Views

Hi Gurus,

I have a request to automate the copy of files from BPC into the App.Server (AL11).

I had found class CL_UJF_FILE_SERVICE_MGR, where I'm using the below code to retrieve the file content:

LO_FILE_MGR = CL_UJF_FILE_SERVICE_MGR=>FACTORY(

IS_USER = LO_CONTEXT->DS_USER

I_APPSET = P_APPSET ).

move p_file to l_log_file.

TRY.
LO_FILE_MGR->CHECK_DOCUMENT_EXIST(
EXPORTING I_DOCNAME = L_LOG_FILE
IMPORTING E_RESULT = LF_EXISTS ).
CATCH CX_UJF_FILE_SERVICE_ERROR.
RETURN.
ENDTRY.

IF LF_EXISTS = ABAP_TRUE.
LO_FILE_MGR->GET_DOCUMENT(
EXPORTING I_DOCNAME = L_LOG_FILE
I_RETZIP = ABAP_FALSE
IMPORTING E_DOCUMENT_CONTENT = L_LOG_XCONTENT ).

Which seems to be working fine. I also looked into UJBR code, where files can be backed up. I can successfully use the code below to download it to my desktop, but if I choose App Server copy, the open dataset command with transfer saves rubbish into AL11.

* convert to binary table
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = L_LOG_XCONTENT
IMPORTING
output_length = lv_size
TABLES
binary_tab = lt_data.

if p_back = 'X'.
* to application sever.
open dataset filename for output in binary mode.
if sy-subrc <> 0.
raise exception type cx_ujt_backup_restore_error
exporting
textid = cx_ujt_backup_restore_error=>ex_download_file_error.
endif.
loop at lt_data into ls_data.
transfer ls_data to filename.
endloop.
close dataset filename.

elseif p_front = 'X'.
* to PC
call method cl_gui_frontend_services=>gui_download
exporting
bin_filesize = lv_size
filename = filename
filetype = 'BIN'
changing
data_tab = lt_data
exceptions
others = 24.
if sy-subrc <> 0.
* raise exception type cx_ujt_backup_restore_error
* exporting
* textid = cx_ujt_backup_restore_error=>ex_download_file_error.
endif.

It seems that something is missing in the data transformation to binary prior the copy to App.Server, but I can't see what since the GUI_DOWNLOAD is working fine.

Any ideas?

Thanks,

Julio.