Downloading file from application server to presentation server
Hi,
We have a requirment to download file from application server to presentation server. The problem is while down loading, some of the filds showing some junk values. Instead of that junk values we have some Russian texts there. These Russian texts only coming as junk all other data is correct. The file in the appplication server is in .dbf format. We are downloading using WS_DOWNLOAD. file type is BIN and code page we didn't specified.
Thanks in Advance
Jijeesh.P.G
Message was edited by: Jijeesh.P.G
Jijeesh P G
hi jijeesh,
Welcome to SDN.
u can use to download file from application server to presentation server using the t/c CG3Y. in that it will ask the source file path and the target file path.
if u want to find the source file path in the application server, u can use the transaction AL11 to find that one.
Regards....
Arun.
Reward points if useful.
Similar Messages
-
How to download file from application server
Hi Experts,
I developed report and execute in background mode. for this i used Open dataset transfer and close dataset . i got the requried output . But in this case user want downloaded file on presentation server so can anyone tell me How to download file from application server?
i know it is possible through Tcode CG3Y. but i want code in program.This code will download a file to your Client package by package, so it will also work for huge files.
*& Report ZBI_DOWNLOAD_APPSERVER_FILE
REPORT zbi_download_appserver_file.
PARAMETERS: lv_as_fn TYPE sapb-sappfad
DEFAULT '/usr/sap/WBP/DVEBMGS00/work/ZBSPL_R01.CSV'.
PARAMETERS: lv_cl_fn TYPE string
DEFAULT 'C:\Users\atsvioli\Desktop\Budget Backups\ZBSPL_R01.CSV'.
START-OF-SELECTION.
CONSTANTS blocksize TYPE i VALUE 524287.
CONSTANTS packagesize TYPE i VALUE 8.
TYPES ty_datablock(blocksize) TYPE x.
DATA lv_fil TYPE epsf-epsfilnam.
DATA lv_dir TYPE epsf-epsdirnam.
DATA ls_data TYPE ty_datablock.
DATA lt_data TYPE STANDARD TABLE OF ty_datablock.
DATA lv_block_len TYPE i.
DATA lv_package_len TYPE i.
DATA lv_subrc TYPE sy-subrc.
DATA lv_msgv1 LIKE sy-msgv1.
DATA lv_processed_so_far TYPE p.
DATA lv_append TYPE c.
DATA lv_status TYPE string.
DATA lv_filesize TYPE p.
DATA lv_percent TYPE i.
"Determine size
SPLIT lv_as_fn AT '/' INTO lv_dir lv_fil.
CALL FUNCTION 'EPS_GET_FILE_ATTRIBUTES'
EXPORTING
file_name = lv_fil
dir_name = lv_dir
IMPORTING
file_size_long = lv_filesize.
"Open the file on application server
OPEN DATASET lv_as_fn FOR INPUT IN BINARY MODE MESSAGE lv_msgv1.
IF sy-subrc <> 0.
MESSAGE e048(cms) WITH lv_as_fn lv_msgv1 RAISING file_read_error.
EXIT.
ENDIF.
lv_processed_so_far = 0.
DO.
REFRESH lt_data.
lv_package_len = 0.
DO packagesize TIMES.
CLEAR ls_data.
CLEAR lv_block_len.
READ DATASET lv_as_fn INTO ls_data MAXIMUM LENGTH blocksize LENGTH lv_block_len.
lv_subrc = sy-subrc.
IF lv_block_len > 0.
lv_package_len = lv_package_len + lv_block_len.
APPEND ls_data TO lt_data.
ENDIF.
"End of file
IF lv_subrc <> 0.
EXIT.
ENDIF.
ENDDO.
IF lv_package_len > 0.
"Put file to client
IF lv_processed_so_far = 0.
lv_append = ' '.
ELSE.
lv_append = 'X'.
ENDIF.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = lv_package_len
filename = lv_cl_fn
filetype = 'BIN'
append = lv_append
show_transfer_status = abap_false
TABLES
data_tab = lt_data.
lv_processed_so_far = lv_processed_so_far + lv_package_len.
"Status display
lv_percent = lv_processed_so_far * 100 / lv_filesize.
lv_status = |{ lv_percent }% - { lv_processed_so_far } bytes downloaded of { lv_filesize }|.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING "percentage = lv_percent - will make it fash
text = lv_status.
ENDIF.
"End of file
IF lv_subrc <> 0.
EXIT.
ENDIF.
ENDDO.
"Close the file on application server
CLOSE DATASET lv_as_fn. -
Error in PDF Conversion while downloading file from application server
Hi,
I am facing a problem in which i have to download file from application server which is a PDF file (output of SAP Script). I am downloading this file using following code in BSP technology:
* event handler for data retrieval
EMPCD = REQUEST->GET_FORM_FIELD( 'emp' ).
MONTH = REQUEST->GET_FORM_FIELD( 'mn' ).
YEAR = REQUEST->GET_FORM_FIELD( 'yr' ).
W_IND = 'N' .
DATA : wa_zform16 type zform16.
DATA : file_path type string.
DATA : l_pdf_len type string.
DATA STR TYPE STRING.
DATA: OUTPUT TYPE STRING ,
L_XSTRING TYPE XSTRING ,
APP_TYPE TYPE STRING.
DATA: PDF_TABLE TYPE RCL_BAG_TLINE.
DATA PHY_NAME_OUT TYPE SAPB-SAPPFAD.
concatenate '/usr/sap/put/form16/' EMPCD '_' YEAR '.PDF' into file_path
*PHY_NAME_OUT = '/usr/sap/put/form16/01000200_2007.PDF'.
PHY_NAME_OUT = file_path.
OPEN DATASET PHY_NAME_OUT FOR INPUT IN TEXT MODE ENCODING default.
IF SY-SUBRC IS INITIAL.
DO.
READ DATASET PHY_NAME_OUT INTO STR.
IF SY-SUBRC IS INITIAL.
CONCATENATE
OUTPUT
STR
CL_ABAP_CHAR_UTILITIES=>CR_LF
INTO OUTPUT.
ELSE.
EXIT.
ENDIF.
ENDDO.
APP_TYPE = 'APPLICATION/PDF'.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
TEXT = OUTPUT
MIMETYPE = 'APPLICATION/PDF'
* MIMETYPE = 'APPLICATION/PDF;charset=utf-16le'
IMPORTING
BUFFER = L_XSTRING.
CALL METHOD CL_BSP_UTILITY=>DOWNLOAD
EXPORTING
OBJECT_S = L_XSTRING
CONTENT_TYPE = APP_TYPE
CONTENT_DISPOSITION = 'attachment;filename=webforms.pdf'
RESPONSE = _M_RESPONSE
NAVIGATION = NAVIGATION.
Result of this code is : there is a pop up asking to open or save pdf format and process is complete, but i have problem in downloaded file.
At the time of creation i have put BMP image for signature in PDF file and it is working fine but when i upload that file in Application server and then download it with above used code it save the PDF file but when i open that file so whereever i have used signature that page gives error and could not display that scanned signature.
Can anyone please help me in this regard.
or is there any possibility from which i can download that file just like File transfer from BSP.
Keep in mind that i am using BSP technology so all GUI based function module to download file are not working.
waiting for your reply.....
Regards,
GaganHi Raja,
I have standard sap form for TDS Certificate on which i have include an BMP image for digital signature and download that script into pdf format.While i download that PDF looks ok but it is not working in BSP.
Regards,
Gagan -
Downloading file from application server in Binary mode
Hi,
I am trying to read an application server file using open dataset in Binary Mode..
While downloading using gui_download method the file is getting truncated because of its size.
My questions are,
How to increase the size of the internal table dynamically. Already tried using STRING type but it is not accepting.
If I use the CHAR type with maximum length 65535 and if the length of the file is less than that then in the remaining spaces box like symbols are printed .
How can I achieve it.
Thanks & Regards,
NJTYPES: BEGIN OF type_download,
data1 TYPE zchar20000,
data2 TYPE zchar20000,
data3 TYPE char3000,
data4 TYPE char2000,
END OF type_download.
DATA: lt_download TYPE STANDARD TABLE OF type_download,
lx_download TYPE string,
lv_filename TYPE string.
Read data from application server to internal table
OPEN DATASET p_p_ftappl FOR INPUT IN BINARY MODE.
IF sy-subrc = 0.
Read file
DO.
CLEAR lx_download.
READ DATASET p_p_ftappl INTO lx_download.
IF sy-subrc <> 0.
EXIT.
ENDIF.
APPEND lx_download TO lt_download.
ENDDO.
Download data to presentation server from internal table
lv_filename = p_p_ftfron.
Download data from application server to PC
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize =
filename = lv_filename
filetype = c_bin
append = space
write_field_separator = space
header = '00'
trunc_trailing_blanks = 'X' "space "commented
trunc_trailing_blanks_eol = 'X' "added
IMPORTING
filelength =
CHANGING
data_tab = lt_download.
*Exceptions deleted .
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Close file
CLOSE DATASET p_p_ftappl.
Edited by: NewJoinee123 on Mar 25, 2010 8:45 AM -
Urgent : Download file from Application Server via Process Chain.
Hi Experts,
My requirement is to download the file from Application Server to local work station using an ABAP Program .
I want including the above ABAP program in a process chain to execute the program daily,
I tried to use ARCHIVFILE_SERVER_TO_CLIENT and GUI_DOWNLOAD but unfortunately both the above FM doesn't support to run through Process chain.
Can any one of you help me to send the code which selects a file from application server, downloads to local system and deletes it.
Thank you very much for spending your precious time in this regard.Hi Sailekha,
Regarding your case ..
I suggest you to create the program where it run this function: WS_DOWNLOAD.
After it, the program is run by your process chain.
Hopefully it can help you a lot.
Regards,
Niel.
thanks for the points you choose to assign. -
How to download files from Application Server of Unix o.s to local director
Hi All,
I am trying to download files from Apllication server of Unix operating Systems to local file in excel sheet format using a z-program.but whenever I am trying to use OPEN dataset ........
it is showing sy-subrc = 8.
Can I have any clew please.
Thanks in advance,
Regards,
AMEER.Hi Sreekanth,
Thanks a lot for quick reply.I have to download that files from z-program only. I am giving you my code below.
*& Report ZTRAK_DOWNLOAD *
REPORT ZTRAK_DOWNLOAD MESSAGE-ID ZCT .
SELECTION-SCREEN BEGIN OF BLOCK DOWNLOAD WITH FRAME TITLE TEXT1.
PARAMETERS :
SERDIR LIKE RLGRAP-FILENAME DEFAULT '/usr/trak',
LOCDIR LIKE RLGRAP-FILENAME DEFAULT 'C:\Trak'.
SELECTION-SCREEN END OF BLOCK DOWNLOAD .
SELECTION-SCREEN BEGIN OF BLOCK INFO2 WITH FRAME.
SELECTION-SCREEN COMMENT 1(79) TEXT2.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN COMMENT 1(79) TEXT3.
SELECTION-SCREEN END OF BLOCK INFO2 .
SELECTION-SCREEN BEGIN OF BLOCK INFO3 WITH FRAME.
SELECTION-SCREEN COMMENT 1(79) TEXT4.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN COMMENT 1(79) TEXT5.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN COMMENT 1(79) TEXT6.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN COMMENT 1(79) TEXT7.
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN COMMENT 1(79) TEXT8.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN COMMENT 1(79) TEXT9.
SELECTION-SCREEN END OF BLOCK INFO3.
*- Internal Table to output data in Excel
DATA: BEGIN OF tab_excel OCCURS 0,
col1(50),
col2(132),
col3(255),
col4(100),
col5(100),
col6(50),
COL7(60),
col8(30),
col9(30),
col10(30),
col11(20),
col12(15),
col13(15),
END OF tab_excel.
DATA: FILE LIKE RLGRAP-FILENAME .
DATA: W_DATASET(80).
INITIALIZATION.
TEXT1 = 'Download Reports'.
TEXT2 = 'The Program downloads the reports generated by Trak'.
TEXT3 = 'Utility from Server to Local PC.'.
TEXT4 = 'Check the following before executing the Program.'.
TEXT5 = ' 1. A valid Server path is provided.'.
TEXT6 = ' 2. A valid Local PC path is provided.'.
TEXT7 = ' 3. Local PC has 10 MB free space.'.
TEXT8 = 'The report can be executed in the forground.'.
TEXT9 =
'The report should be executed after execution of Transaction TRAK'.
AT SELECTION-SCREEN.
IF SERDIR EQ ''.
MESSAGE E001(ZCT).
ENDIF.
IF LOCDIR EQ ''.
MESSAGE E002(ZCT).
ENDIF.
START-OF-SELECTION.
Download ABAP Development Summary Report
FILE = '\ABAP_Report_Developments.XLS'.
CONCATENATE LOCDIR FILE INTO FILE.
W_DATASET = '/ABAP_Report_Developments.dat'.
CONCATENATE SERDIR W_DATASET INTO W_DATASET.
PERFORM INIT.
Download BDC Development Report
FILE = '\BDC_Developments_Report.XLS'.
CONCATENATE LOCDIR FILE INTO FILE.
W_DATASET = '/BDC_Developments_Report.dat'.
CONCATENATE SERDIR W_DATASET INTO W_DATASET.
PERFORM INIT.
Download Development Summary Report
FILE = '\Developments_Summary_Report.XLS' .
CONCATENATE LOCDIR FILE INTO FILE.
W_DATASET = '/Developments_Summary_Report.dat'.
CONCATENATE SERDIR W_DATASET INTO W_DATASET.
PERFORM INIT.
Download Enhancement Development Report
FILE = '\Enhancement_Developments_Report.XLS'.
CONCATENATE LOCDIR FILE INTO FILE.
W_DATASET = '/Enhancement_Developments_Report.dat'.
CONCATENATE SERDIR W_DATASET INTO W_DATASET.
PERFORM INIT.
Download field exit Development Report
FILE = '\Field_Exit_Developments_Report.XLS'.
CONCATENATE LOCDIR FILE INTO FILE.
W_DATASET = '/Field_Exit_Developments_Report.dat'.
CONCATENATE SERDIR W_DATASET INTO W_DATASET.
PERFORM INIT.
Download Frequency & Purpose Report
FILE = '\Frequency_And_Purpose_Report.XLS'.
CONCATENATE LOCDIR FILE INTO FILE.
W_DATASET = '/Frequency_And_Purpose_Report.dat'.
CONCATENATE SERDIR W_DATASET INTO W_DATASET.
PERFORM INIT.
Download Function Group Developments Report
FILE = '\FunctionGroup_Developments_Report.XLS'.
CONCATENATE LOCDIR FILE INTO FILE.
W_DATASET = '/FunctionGroup_Developments_Report.dat'.
CONCATENATE SERDIR W_DATASET INTO W_DATASET.
PERFORM INIT.
Download Function Module Developments Report
FILE = '\FunctionModule_Developments_Report.XLS' .
CONCATENATE LOCDIR FILE INTO FILE.
W_DATASET = '/FunctionModule_Developments_Report.dat'.
CONCATENATE SERDIR W_DATASET INTO W_DATASET.
PERFORM INIT.
Download Include Developments Report
FILE = '\Include_Developments_Report.XLS'.
CONCATENATE LOCDIR FILE INTO FILE.
W_DATASET = '/Include_Developments_Report.dat'.
CONCATENATE SERDIR W_DATASET INTO W_DATASET.
PERFORM INIT.
Download UserGroup Developments Report
FILE = '\UserGroup_Developments_Report.XLS'.
CONCATENATE LOCDIR FILE INTO FILE.
W_DATASET = '/UserGroup_Developments_Report.dat'.
CONCATENATE SERDIR W_DATASET INTO W_DATASET.
PERFORM INIT.
Download Modified_Standard_SAP_Objects_Report
FILE = '\Modified_Standard_SAP_Objects_Report.XLS' .
CONCATENATE LOCDIR FILE INTO FILE.
W_DATASET = '/Modified_Standard_SAP_Objects_Report.dat'.
CONCATENATE SERDIR W_DATASET INTO W_DATASET.
PERFORM INIT.
Download Include Developments Report
*FILE = '\Include_Developments_Report.XLS'.
*CONCATENATE LOCDIR FILE INTO FILE.
*W_DATASET = '/Include_Developments_Report.dat'.
*CONCATENATE SERDIR W_DATASET INTO W_DATASET.
*PERFORM INIT.
Download SAP Script Developments Report
FILE = '\SAP_Scipt_Developments_Report.XLS'.
CONCATENATE LOCDIR FILE INTO FILE.
W_DATASET = '/SAP_Scipt_Developments_Report.dat'.
CONCATENATE SERDIR W_DATASET INTO W_DATASET.
PERFORM INIT.
Download Transaction Developments Report
FILE = '\Transaction_Developments_Report.XLS'.
CONCATENATE LOCDIR FILE INTO FILE.
W_DATASET = '/Transaction_Developments_Report.dat'.
CONCATENATE SERDIR W_DATASET INTO W_DATASET.
PERFORM INIT.
Download User Exits Developments Report
FILE = '\UserExits_Reports.XLS'.
CONCATENATE LOCDIR FILE INTO FILE.
W_DATASET = '/UserExits_Reports.dat'.
CONCATENATE SERDIR W_DATASET INTO W_DATASET.
PERFORM INIT.
Download ABAP Query Developments Report
FILE = '\ABAPQuery_Developments_Reports.XLS'.
CONCATENATE LOCDIR FILE INTO FILE.
W_DATASET = '/ABAPQuery_Developments_Reports.dat'.
CONCATENATE SERDIR W_DATASET INTO W_DATASET.
PERFORM INIT.
Download Functional Area Developments Report
FILE = '\FunctionalArea_Developments_Report.XLS'.
CONCATENATE LOCDIR FILE INTO FILE.
W_DATASET = '/FunctionalArea_Developments_Report.dat'.
CONCATENATE SERDIR W_DATASET INTO W_DATASET.
PERFORM INIT.
MESSAGE S003(ZCT) WITH LOCDIR.
END-OF-SELECTION.
This routine checks whether file exists if yes downloads it to
the Local PC
FORM INIT.
OPEN DATASET W_DATASET FOR INPUT IN TEXT MODE ENCODING DEFAULT.
DO.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
READ DATASET W_DATASET INTO tab_excel.
APPEND tab_excel.
CLEAR tab_excel.
ENDDO.
PERFORM DOWNLOAD_FILE.
ENDFORM.
This routine downloads the data in an XL format on local PC
FORM Download_File .
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = FILE
FILETYPE = 'DAT'
TABLES
DATA_TAB = tab_excel
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
OTHERS = 10.
IF sy-subrc <> 0.
message ''. " Error in file transfer
ELSE.
CLEAR TAB_EXCEL.
REFRESH TAB_EXCEL.
FILE = ''.
W_DATASET = ''.
ENDIF.
ENDFORM.
I have created those files in Application Server running in another z-program in background mode.Then I am trying to download those files using above the program.I am creating those trak/Trak files manually and I can able to see those files in A.S level.But when downloading the same files I am facing the problem.
regards,
Ameer -
Downloading file from Application Sever
Hi Gurus,
I have a requirement in which I have to execute my program once in every 15 minutes which will check if there are any files present in application server. Is so I have to retreive the files to SAP from Application server.
Now I have couple of issues in doing so.
1. How to find the number of files present in that directory?
2. How to retreive more than 1 file at a time from the directory.
Its bit urgent.
Cheers,
Naveen
NOTE: Points will be awarded to every useful answer.Hi,
You can use FM EPS_GET_DIRECTORY_LISTING to get all the files from application server in given directory.Then looping that table you can get data from file using open data set
IF pa_adir+lw_len(1) NE c_fhash .
CONCATENATE pa_adir c_fhash INTO pa_adir.
ENDIF. " IF pa_adir+lw_len(1) NE c_fhash
CLEAR w_dir.
w_dir = pa_adir.
lw_dirname = pa_adir.
REFRESH:
t_files_app.
Getting all files in that directory with filter
CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
EXPORTING
dir_name = lw_dirname
file_mask = w_filter
TABLES
dir_list = t_files_app
EXCEPTIONS
invalid_eps_subdir = 1
sapgparam_failed = 2
build_directory_failed = 3
no_authorization = 4
read_directory_failed = 5
too_many_read_errors = 6
empty_directory_list = 7
OTHERS = 8.
Here lw_dirname is directory name
and w_filter is filter for file types like *.txt
and you will get all files in t-files_app
Reward points if help ful -
Download files from application server - unknown file name
Hello everybody,
I am working on a report allowing users to download XML files from the application server. All these XML files are created by the SAP system and their names can be found in a table. I can simply use OPEN DATASET for these files, put all file content to a buffer and send them to the GUI with CALL METHOD cl_gui_frontend_services=>gui_download.
The problem is now that some files are touched by an external document management system. These files are moved to another directory and timestamped. The first is no problem since the folder name is always the same and can be replaced before the OPEN DATASET statement. But additionally, the file gets a timestamp, when the filename was xyz.xml before, it now gets xyz.xml.01012008123456123456. As I cannot try all possible values (mircoseconds!), I need a way to search for the right filename on the application server. Is there a function module for this available?
It can always be stated that the former name (xyz.xml) is still a unique prefix, so I don't have to worry that xyz.xml.* will return multiple files.
Thanks in advance for any suggestions.
ChristophHI!
I copy the function GET_DIRECTORY_FILE. In the eyelash of tables create one structures:
DIR_FILES LIKE ZDIR_FILES
The single structure has component NAME (char 250).
I code of the function that I use is:
FUNCTION zget_directory_file.
""Interfase local
*" IMPORTING
*" REFERENCE(NAME_OF_DIR) TYPE CHAR120
*" REFERENCE(NAME_OF_FILE) TYPE CHAR120 OPTIONAL
*" REFERENCE(SP_CS) TYPE CHAR120 OPTIONAL
*" TABLES
*" DIR_FILES STRUCTURE ZDIR_FILES
DATA: a_dir_name TYPE char120,
a_generic_name TYPE char120,
a_must_cs TYPE char120.
a_dir_name = name_of_dir.
a_generic_name = name_of_file.
a_must_cs = sp_cs.
DATA: errcnt(2) TYPE p VALUE 0.
IF a_dir_name IS INITIAL.
MESSAGE e220. " 'Place cursor on valid line !'.
ENDIF.
CALL 'C_DIR_READ_FINISH' " just to be sure
ID 'ERRNO' FIELD file_list-errno
ID 'ERRMSG' FIELD file_list-errmsg.
CALL 'C_DIR_READ_START' ID 'DIR' FIELD a_dir_name
ID 'FILE' FIELD a_generic_name
ID 'ERRNO' FIELD file-errno
ID 'ERRMSG' FIELD file-errmsg.
IF sy-subrc <> 0.
sy-subrc = 4.
EXIT.
ENDIF.
file-dirname = a_dir_name.
DO.
CLEAR file.
file-name = '*.zip'.
CALL 'C_DIR_READ_NEXT'
ID 'TYPE' FIELD file-type
ID 'NAME' FIELD file-name
ID 'LEN' FIELD file-len
ID 'OWNER' FIELD file-owner
ID 'MTIME' FIELD file-mtime
ID 'MODE' FIELD file-mode
ID 'ERRNO' FIELD file-errno
ID 'ERRMSG' FIELD file-errmsg.
file-dirname = a_dir_name.
MOVE sy-subrc TO file-subrc.
CASE sy-subrc.
WHEN 0.
CLEAR: file-errno, file-errmsg.
CASE file-type(1).
WHEN 'F'. " normal file.
PERFORM filename_useable USING file-name file-useable.
WHEN 'f'. " normal file.
PERFORM filename_useable USING file-name file-useable.
WHEN OTHERS. " directory, device, fifo, socket,...
MOVE sap_no TO file-useable.
ENDCASE.
IF file-len = 0.
MOVE sap_no TO file-useable.
ENDIF.
WHEN 1. " end of directory
EXIT.
WHEN 4. " filename too long
MOVE sap_no TO file-useable.
WHEN OTHERS.
ADD 1 TO errcnt.
IF errcnt > 90.
EXIT.
ENDIF.
IF sy-subrc = 5.
MOVE: '???' TO file-type,
'???' TO file-owner,
'???' TO file-mode.
ELSE.
ULINE.
WRITE: / 'C_DIR_READ_NEXT', 'SUBRC', SY-SUBRC.
ENDIF.
MOVE sap_no TO file-useable.
ENDCASE.
PERFORM p6_to_date_time_tz(rstr0400) USING file-mtime
file-mod_time
file-mod_date.
* Does the filename contains the requested pattern?
* Then store it, else forget it.
MOVE-CORRESPONDING file TO file_list.
APPEND file_list.
MOVE file-name TO dir_files-name.
APPEND dir_files.
IF a_must_cs = no_cs.
MOVE-CORRESPONDING file TO file_list.
APPEND file_list.
ELSE.
IF file-name CS a_must_cs.
MOVE-CORRESPONDING file TO file_list.
APPEND file_list.
ENDIF.
ENDIF.
ENDDO.
ENDFUNCTION.
*& Form filename_useable
text
-->A_NAME text
-->A_USEABLE text
FORM filename_useable USING a_name a_useable.
*--================--
DATA l_name(75).
l_name = a_name.
IF l_name(4) = 'core'.
a_useable = sap_no.
ELSE.
a_useable = sap_yes.
ENDIF.
ENDFORM. "FILENAME_USEABLE
With this I obtain all the archives XML of that route in a table
DATA: zfiles LIKE STANDARD TABLE OF zdir_files WITH HEADER LINE.
CALL FUNCTION 'ZGET_DIRECTORY_FILE'
EXPORTING
name_of_dir = dsn
TABLES
dir_files = zfiles.
IF sy-subrc = 0.
LOOP AT zfiles .
IF zfiles-name+0(2) = 'O_' AND
zfiles-name+2(3) = sy-mandt AND
zfiles-name+5(1) = '_' AND
zfiles-name+22(4) = '.xml'.
file = zfiles-name.
endloop.
endif.
I hope this helps you.
Regards. -
Download file from application server to internal table in background
hi all,
i want to download a file from appliaction server into my internal table but in background.
i had tryed CG3Z and CG3Y t-code but screen that is coming is asking for the parameters, and i want that screen should not appear and file should be saved in the predefined path by me.
if there any way to do so,
Points will be rewarded as per the Aswers.
thaks in advance.Hi Sudeep,
Use this code to get file data from application server.
REPORT ZE0232_BDC_APPLSERVER.
DATA: FILE_PATH TYPE STRING.
FILE_PATH = 'c:\bdc_mat.prn'.
DATA: BEGIN OF ITAB OCCURS 0,
END OF ITAB.
OPEN DATASET FILE_PATH FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC = 0.
DO.
READ DATASET FILE_PATH INTO ITAB.
IF ITAB-RESNO NE SPACE.
APPEND ITAB.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
CLOSE DATASET FILE_PATH.
LOOP AT ITAB.
WRITE:/ ITAB.
ENDLOOP.
FILE PATH IS application server path.
IF USEFULL REWARD -
Download file from SAP PLM or Content Server?
Hi all,
I learned that the VEG server download the originals from content server and then started the conversion process.
In my case, I have an error below, it is strange that the IP 153.95.192.93:443 is the ip of SAP PLM server, can anyone tell me is my configuraton right?
thanks
Job 42 (Workflow 'KPRO Retrieve') report
Startup Parameters
FilesPerTask = '5 '(Integer)
InputFilePath = '\ \ NBHXVEG02 \ DSShare \ Workspace \ JM_JOB41 \ KProRetrievalRequest.xml' (String)
OutputFilePath = '\ \ NBHXVEG02 \ DSShare \ Workspace \ JM_JOB41 \ KProRetrievalResponse.xml' (String)
Step 'validate input'
Completed Action 'enter a valid'
Step 'Download'
CompletedWithWarnings Action 'can not download all the files'
Info Message 'document retrieval tasks to be addressed: 1'
Warning Message 'first task failed to retrieve a file (of 1): Unknown error (warning)'
jmp_KproRetrieve (Task 39)
Warning Message 'file' A00021876_20130819.CATProduct 'unable to download: Unable to connect to the remote server: Since the connected party did not properly respond after a period of no response or a host connection, the connection attempt fails. 153.95.192.93:443 'HI Fergal.
I changed the IIS port to XX443(XX means instance number), the https service is also started in the ECC server.
but I got below errors:
Startup Parameters
FilesPerTask = '5 '(Integer)
InputFilePath = '\ \ NBHXVEG02 \ DSShare \ Workspace \ JM_JOB115 \ KProRetrievalRequest.xml' (String)
OutputFilePath = '\ \ NBHXVEG02 \ DSShare \ Workspace \ JM_JOB115 \ KProRetrievalResponse.xml' (String)
Step 'validate input'
Completed Action 'enter a valid'
Step 'Download'
CompletedWithWarnings Action 'can not download all the files'
Info Message 'document retrieval tasks to be addressed: 1'
Warning Message 'first task failed to retrieve a file (of 1): Unknown error (warning)'
jmp_KproRetrieve (Task 122)
Warning Message 'file' A00021876_20130819.CATProduct 'unable to download: The underlying connection was closed: Could not establish trust relationship for the SSL / TLS secure channel. : According to the verification process, the remote certificate is invalid. ' -
Problem in Downloading File from Application Server
Hi All,
We have an Requirement that, iam putting the Flat File
( Output Of a Report ) in to the
Application Server(AL11) By using the OpendataSet, Transer , Close DataSet.
When iam trying to Downloading the Flat File through the FM, GUI_DOWNLOAD, the Data is coming Correctly.
But the Problem is , when trying to Downloading through AL11 i.e System -> List -> Local File it is not coming Correctly.
( Java People is going to Connect with the Application Server for the Flat File )
Kindly Clarify the Problem.
Points will be Rewarded.
Regards,
Kiran.IHi nl,
1. this program will display
selection screen
and ask two things :
a) application server filename
b) local file name
2. then it will download the file
(the file name is CASE Sensitivie)
3. just try it (just copy paste )
*& Report YBCR_FILEDOWNLOAD *
REPORT ybcr_filedownload .
DATA
DATA : file_name TYPE string.
DATA : BEGIN OF itab OCCURS 0,
ln(255) TYPE c,
END OF itab.
SCREEN
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS : appfn(150) TYPE c LOWER CASE OBLIGATORY.
PARAMETERS : p_file LIKE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CLEAR p_file.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_file.
file_name = p_file.
START-OF-SELECTION
START-OF-SELECTION.
OPEN DATASET appfn FOR INPUT IN TEXT MODE ENCODING DEFAULT .
IF sy-subrc <> 0.
MESSAGE s999(yhr) WITH 'COULD NOT OPEN FILE ON APP SERVER'.
LEAVE LIST-PROCESSING.
ENDIF.
DO.
READ DATASET appfn INTO itab.
IF sy-subrc = 0.
APPEND itab.
ELSE.
EXIT.
ENDIF.
ENDDO.
file_name = p_file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = file_name
FILETYPE = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
TABLES
data_tab = itab
FIELDNAMES =
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
regards,
amit m. -
How to download file from application server to local file using tcode
Hi,
I want to download one report output in application sever(/temp/xxx) to local.
But downloaded excel sheet improper format.
In downloaded excel sheet having one complete record(12 fields) in one cell.
I want to separate it each field in each cell in proper format..[requirement]
restriction : without using any programs using standard tcode like CG3Y.
THANKS IN ADVANCE....
Regards,
Ragavendran K.
Moderator message: please search for available information/documentation before asking.
Edited by: Thomas Zloch on Dec 21, 2010 5:15 PMIn downloaded excel sheet having one complete record(12 fields) in one cell.
You did it wrong then. Post your code and someone will tell you what's wrong with it (or you could search the forum). -
File download from application server to presentation server
Hi,
We have requirment to upload a file to application server in .dbf format and then download it to presentation server. while downloading the file to presentation server some of the fields getting junk values. we are downloading file to excel sheet. some of the fields values are Russian texts. Those fields only getting junk values, all other fields are getting correct values.
Please advice.
Regards,
chandra.hi
sample code below should help you......
<u>Download to presentation server</u>
This program can be used to download files from Application server to presentaion server.
1)Maximum length of each field is considered to be 40 characters.
2)Maximum length of the field can be changed by specifying the length in selection screen parameter
3)First line of the Application server file should contain the description of each field.
4)Each field should be delimited by #.
*& Report ZDOWNLOADFILE *
REPORT ZDOWNLOADFILE
MESSAGE-ID B1 .
INCLUDES *
INCLUDE ZDOWNLOADFILE_TOP.
INCLUDE ZDOWNLOADFILE_FORM.
EVENT-AT SELECTION-SCREEN *
AT SELECTION-SCREEN ON pa_appl.
PERFORM check_file_exists USING pa_appl.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_appl.
PERFORM f4_dxfilename USING pa_appl.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_pres.
PERFORM f4_filename USING pa_pres.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_del.
PERFORM f4_dxfilename USING pa_del.
EVENT INITIALIZATION *
INITIALIZATION.
PERFORM initialization.
EVENT START-OF-SELECTION *
START-OF-SELECTION.
PERFORM determine_fields. "Determine number of columns
PERFORM build_itab. "Create internal table based on number
"of columns
PERFORM build_header. "To prepare header for the file
PERFORM download_data. "Download data to presentation server
PERFORM delete_files. "Delete files from application server
*& Include ZDOWNLOADFILE_TOP *
TYPES: BEGIN OF ty_header,
text(100) TYPE c,
END OF ty_header.
DATA: c_fnh_mask type dxfields-filemask value '.',
search_dir type dxfields-longpath value '/sapglobal/users'.
CLASS cl_abap_char_utilities DEFINITION LOAD.
Internal tables *
DATA: gt_header TYPE STANDARD TABLE OF ty_header,
gt_fieldcat TYPE lvc_t_fcat.
Work areas *
DATA: gs_header TYPE ty_header,
gs_fieldcat TYPE lvc_s_fcat.
DATA: wa_filename TYPE string.
DATA: wa_count(2) TYPE N,
wa_start(3) TYPE N,
wa_end(3) TYPE N,
wa_len(3) TYPE N.
DATA: wa_data(12000) TYPE c,
wa_off TYPE I,
itab_appl TYPE REF TO DATA,
itab_line TYPE REF TO DATA,
col(2) TYPE c.
DATA: wa_field(30) TYPE c.
DATA: lv_index TYPE sy-tabix.
DATA: gs_adrp type adrp,
gs_usr02 type usr02,
gs_usr21 type usr21,
gs_char50(50).
CONSTANTS: co_slash(1) value '/'.
FIELD-SYMBOLS: <itab> TYPE STANDARD TABLE,
<wa>,
<fs_line>,
<wa_line>.
SELECTION SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE text-f01.
PARAMETERS: pa_appl LIKE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE text-f02.
PARAMETERS: pa_pres LIKE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B2.
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE text-f03.
PARAMETERS: pa_del LIKE rlgrap-filename .
PARAMETERS: pa_deld AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK B3.
SELECTION-SCREEN BEGIN OF BLOCK B4 WITH FRAME TITLE text-f04.
PARAMETERS: pa_len(3) TYPE c.
SELECTION-SCREEN END OF BLOCK B4.
*& Include ZDOWNLOADFILE_FORM *
*& Form f4_dxfilename
text
-->P_pa_appl text
form f4_dxfilename using p_file.
DATA: wa_file LIKE dxfields-longpath.
CLEAR: wa_file.
call function 'F4_DXFILENAME_TOPRECURSION'
exporting
i_location_flag = 'A'
i_server = ' '
i_path = search_dir
filemask = c_fnh_mask
fileoperation = 'R'
importing
o_path = wa_file
exceptions
rfc_error = 1
error_with_gui = 2
others = 3
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
p_file = wa_file.
endif.
endform. " f4_dxfilename
*& Form f4_filename
text
-->P_pa_pres text
form f4_filename using p_data.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
IMPORTING
FILE_NAME = p_data
endform. " f4_filename
*& Form check_file_exists
text
-->P_pa_appl text
form check_file_exists using p_file.
DATA: wa_file LIKE rlgrap-filename.
wa_file = p_file.
OPEN DATASET wa_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 8.
MESSAGE E714
WITH text-m01 p_file text-m02.
ELSE.
CLOSE DATASET p_file.
ENDIF.
endform. " check_file_exists
*& Form build_header
text
--> p1 text
<-- p2 text
form build_header .
*Select user details
clear gs_usr21-persnumber.
select single persnumber
into (gs_usr21-persnumber)
from usr21
where bname = sy-uname.
concatenate sy-uname
co_slash
gs_adrp-name_text(36)
co_slash
into gs_char50.
condense gs_char50.
clear gs_usr02-class.
select single class
into (gs_usr02-class)
from usr02
where bname = sy-uname.
concatenate gs_char50
gs_usr02-class
into gs_char50.
condense gs_char50.
Write report technical name
write 'Name: ' TO gs_header+0(10).
gs_header+11(*) = sy-repid.
APPEND gs_header TO gt_header.
CLEAR: gs_header.
Write user data
write 'User: ' TO gs_header+0(10).
gs_header+11(*) = gs_char50.
CONCATENATE gs_header gs_char50 INTO
gs_header SEPARATED BY SPACE.
APPEND gs_header TO gt_header.
CLEAR: gs_header.
Write System data
write 'System: ' TO gs_header+0(10).
write: sy-sysid to gs_header+11(3).
write: co_slash to gs_header+14(1).
write: sy-mandt to gs_header+15(3).
APPEND gs_header TO gt_header.
CLEAR: gs_header.
Write System date and time
write 'System: ' TO gs_header+0(10).
write sy-datum to gs_header+11(10).
write sy-uzeit to gs_header+22(8).
APPEND gs_header TO gt_header.
CLEAR: gs_header.
Write Local date and time
write 'Local: ' TO gs_header+0(10).
write sy-datlo to gs_header+11(10).
write sy-timlo to gs_header+22(8).
APPEND gs_header TO gt_header.
CLEAR: gs_header.
APPEND gs_header TO gt_header.
endform. " build_header
*& Form determine_fields
text
--> p1 text
<-- p2 text
form determine_fields .
DATA: wa_data(600) TYPE c.
CLEAR: wa_count,wa_start,wa_end,wa_data.
wa_start = 0.
wa_end = 1.
OPEN DATASET pa_appl FOR INPUT IN TEXT MODE ENCODING DEFAULT.
READ DATASET pa_appl INTO wa_data.
wa_len = STRLEN( wa_data ).
DO wa_len TIMES.
IF wa_data+wa_start(wa_end) EQ
cl_abap_char_utilities=>horizontal_tab.
wa_count = wa_count + 1.
ENDIF.
wa_start = wa_start + 1.
ENDDO.
CLOSE DATASET pa_appl.
wa_count = wa_count + 1.
endform. " determine_fields
*& Form build_itab
text
--> p1 text
<-- p2 text
form build_itab .
DATA: wa_len(4) TYPE c.
CLEAR: wa_len.
IF pa_len IS INITIAL.
wa_len = 40.
ELSE.
wa_len = pa_len.
ENDIF.
col = 1.
DO wa_count TIMES.
CONCATENATE 'FIELD' col INTO wa_field.
gs_fieldcat-fieldname = wa_field.
gs_fieldcat-outputlen = wa_len.
gs_fieldcat-datatype = 'CHAR'.
gs_fieldcat-col_pos = col.
col = col + 1.
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR: wa_field.
ENDDO.
*Create the internal table dynamically based on the file structure,
*this table will be used to download data through GUI_DOWNLOAD fm
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_fieldcat
IMPORTING
EP_TABLE = itab_appl
*Assign the pointer to the field symbol
ASSIGN itab_appl->* TO <itab>.
CREATE DATA itab_line LIKE LINE OF <itab>.
*Create a work area for the dynamic internal table
ASSIGN itab_line->* TO <wa_line>.
col = 1.
OPEN DATASET pa_appl FOR INPUT IN TEXT MODE ENCODING DEFAULT.
DO.
READ DATASET pa_appl INTO wa_data.
IF sy-subrc <> 0.
CLOSE DATASET pa_appl.
RETURN.
ELSE.
wa_start = 0.
lv_index = 1.
DO wa_count TIMES.
ASSIGN COMPONENT lv_index OF STRUCTURE <wa_line> TO <fs_line>.
FIND cl_abap_char_utilities=>horizontal_tab
IN wa_data+wa_start(*) MATCH OFFSET wa_off.
IF sy-subrc = 0.
IF wa_off NE 0.
<fs_line> = wa_data+wa_start(wa_off).
ENDIF.
wa_start = wa_start + wa_off + 1.
lv_index = lv_index + 1.
ELSE.
<fs_line> = wa_data+wa_start(*).
ENDIF.
ENDDO.
APPEND <wa_line> TO <itab>.
CLEAR: <wa_line>,<fs_line>.
ENDIF.
ENDDO.
endform. " build_itab
*& Form download_data
text
--> p1 text
<-- p2 text
form download_data .
clear: wa_filename.
wa_filename = pa_pres.
call function 'GUI_DOWNLOAD'
exporting
filename = wa_filename
filetype = 'DAT'
tables
data_tab = gt_header
exceptions
access_denied = 15
call function 'GUI_DOWNLOAD'
exporting
filename = wa_filename
filetype = 'DAT'
append = 'X'
tables
data_tab = <itab>
exceptions
access_denied = 15
endform. " download_data
*& Form initialization
text
--> p1 text
<-- p2 text
form initialization .
REFRESH: gt_header,gt_fieldcat,gt_header.
endform. " initialization
*& Form delete_files
text
--> p1 text
<-- p2 text
form delete_files .
IF pa_deld EQ 'X'.
DELETE DATASET pa_appl.
ENDIF.
IF pa_del IS NOT INITIAL.
DELETE DATASET pa_del.
ENDIF.
endform. " delete_files
<b>reward points if helpful.</b>
thanks
vijay -
Download PDF file from Application Server in BSP
Hello,
We have a requirement on which we want to download a PDF file stored in Application server using BSP application. I have used function module ARCHIVFILE_SERVER_TO_CLIENT but this FM will help only if i want to download file from GUI it won't work in BSP application.
Further i have used class CL_BSP_UTILITY and download method to download file from application server but it is not working in desired manner.
I am attaching my code for your reference:
DATA: BUTTON_EVENT TYPE REF TO CL_HTMLB_EVENT_BUTTON ,
EVENT TYPE REF TO IF_HTMLB_DATA.
DATA: LS_HOURS LIKE LINE OF GT_HOURS.
DATA STR TYPE STRING.
DATA: OUTPUT TYPE STRING ,
L_XSTRING TYPE XSTRING ,
APP_TYPE TYPE STRING.
EVENT = CL_HTMLB_MANAGER=>GET_EVENT( REQUEST ).
DATA PHY_NAME_OUT TYPE SAPB-SAPPFAD.
IF EVENT IS NOT INITIAL AND EVENT->EVENT_NAME = HTMLB_EVENTS=>BUTTON .
BUTTON_EVENT ?= EVENT .
CASE EVENT->EVENT_SERVER_NAME.
WHEN 'test' .
IF GT_HOURS IS NOT INITIAL.
PHY_NAME_OUT = '/usr/sap/put/form16//01000200_2007.PDF'.
OPEN DATASET PHY_NAME_OUT FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC IS INITIAL.
DO.
READ DATASET PHY_NAME_OUT INTO STR.
IF SY-SUBRC IS INITIAL.
CONCATENATE
OUTPUT
str
cl_abap_char_utilities=>cr_lf
INTO output SEPARATED BY space. "cl_abap_char_utilities=>horizontal_tab
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
*LOOP AT gt_hours INTO ls_hours.
*CONCATENATE
*OUTPUT
*ls_hours-hour
*cl_abap_char_utilities=>cr_lf
*INTO output SEPARATED BY space. "cl_abap_char_utilities=>horizontal_tab
*ENDLOOP.
APP_TYPE = 'APPLICATION/PDF;charset=utf-16le'.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
TEXT = OUTPUT
MIMETYPE = 'APPLICATION/PDF;charset=utf-16le'
IMPORTING
BUFFER = L_XSTRING.
CONCATENATE CL_ABAP_CHAR_UTILITIES=>BYTE_ORDER_MARK_LITTLE
L_XSTRING
INTO L_XSTRING IN BYTE MODE.
CALL METHOD CL_BSP_UTILITY=>DOWNLOAD
EXPORTING
OBJECT_S = L_XSTRING
CONTENT_TYPE = APP_TYPE
CONTENT_DISPOSITION = 'attachment;filename=webforms.pdf'
RESPONSE = _M_RESPONSE
NAVIGATION = NAVIGATION.
ENDIF.
ENDCASE.
ENDIF.
From this code i am able to download PDF file but it is not opening in local machine.
If any other way to download file then please suggest.
waiting for ur reply.
Regards,
GaganHi,
you do the file reading wrong:
have a look at:
Local declarations.
data:
components type stringtab,
component type string,
path type text255,
file type text255,
line_length type i,
filecontent_binary type sdokcntbin,
rows type sytabix,
content type sdokcntbin,
exception type ref to cx_sy_file_access_error,
exception_tmf type ref to cx_sy_too_many_files ,
block_size type i value 1022,
length type i.
field-symbols:
<hex_container> type x.
constants:
c_dms_blk_size type i value 2550.
clear file_size.
try.
open dataset file_name for input in binary mode message message.
catch cx_sy_file_open into exception.
case exception->textid.
when '4182174D03030063000000000A1551B1'. raise access_error.
when '41825AD355C3005E000000000A1551B1'. raise open_error.
when '47E8B03AECE5BA07E10000000A114829'. raise already_open.
when others.
endcase.
catch cx_sy_file_authority into exception.
case exception->textid.
when '4182174D03030063000000000A1551B1'. raise access_error.
when 'A70BB8396F051547E10000000A11447B'. raise authority_error.
when others.
endcase.
catch cx_sy_too_many_files into exception_tmf.
case exception_tmf->textid.
when '8708B73915F6B645E10000000A11447B'. raise too_many_files.
when others.
endcase.
endtry.
do.
try.
read dataset file_name into filecontent_binary-line.
if sy-subrc <> 0.
add line_length to file_size.
append filecontent_binary to file_content_binary.
exit.
else.
add line_length to file_size.
append filecontent_binary to file_content_binary.
endif.
catch cx_sy_file_open_mode into exception.
case exception->textid.
when '9207B73915F6B645E10000000A11447B'. raise cx_sy_file_open_mode.
when '9807B73915F6B645E10000000A11447B'. raise read_only.
when '9E07B73915F6B645E10000000A11447B'. raise not_open.
when '409D273A2D824360E10000000A11447B'. raise incompatible_mode.
when others.
endcase.
endtry.
enddo.
try.
close dataset file_name.
catch cx_sy_file_close into exception.
case exception->textid.
when '4182174D03030063000000000A1551B1'. raise access_error.
when 'C10BB8396F051547E10000000A11447B'. raise close_error.
when others.
endcase.
catch cx_sy_file_access_error into exception.
case exception->textid.
when '4182174D03030063000000000A1551B1'. raise access_error.
when others.
endcase.
endtry.
Get file size.
split file_name at '/' into table components.
describe table components lines sy-tfill.
read table components into component index sy-tfill.
path = file_name.
replace component in path with ''.
file = component.
call function '/EUH/MMS_GET_FILE_SIZE'
exporting
dir_name = path
file_name = file
importing
file_size = file_size.
and function /euh/mms_get_file_size.
""Local Interface:
*" IMPORTING
*" VALUE(DIR_NAME) TYPE TEXT255
*" VALUE(FILE_NAME) TYPE TEXT255
*" EXPORTING
*" VALUE(FILE_SIZE) TYPE SDOK_FSIZE
*" EXCEPTIONS
*" NO_AUTHORITY
*" ACTIVITY_UNKNOWN
*" NOT_A_DIRECTORY
*" NO_MEDIA_IN_DRIVE
*" TOO_MANY_ERRORS
*" TOO_MANY_FILES
*" BRACKET_ERROR_IN_FILENAME
*" NO_SUCH_PARAMETER
types: begin of files,
line like ocs_file,
end of files.
data: file type files,
f_subrc like sy-subrc value 0,
errno(3) type c,
errmsg(40) type c,
pos type i,
len type i,
parameter(120) type c,
help1(120) type c,
help2(120) type c,
error_counter type i.
data:
dir_list like ocs_file occurs 0 with header line.
CASE sy-subrc.
WHEN 1. f_subrc = 64.
WHEN 2. f_subrc = 65.
WHEN 0.
search dir_name for 'SY-HOST'. "Is SY-HOST used in directory name?
if sy-subrc = 0.
pos = sy-fdpos + 7.
move dir_name(sy-fdpos) to help1.
move dir_name+pos to help2.
concatenate help1 sy-host help2 into dir_name.
endif.
do 12 times. " To avoid endless loop
if dir_name cs '$('. " Replace parameter by their value
pos = sy-fdpos + 2.
if dir_name cs ')'.
len = sy-fdpos - pos.
if len le 0.
f_subrc = 4. exit.
else.
parameter = dir_name+pos(len).
call 'C_SAPGPARAM' id 'NAME' field parameter
id 'VALUE' field parameter.
if sy-subrc = 0.
len = pos + len + 1.
pos = pos - 2.
if pos > 0.
move dir_name(pos) to help1.
else.
help1 = ''.
endif.
pos = strlen( dir_name ).
if pos > len.
move dir_name+len to help2.
else.
help2 = ''.
endif.
concatenate help1 parameter help2 into dir_name.
else.
f_subrc = 8. exit.
endif.
endif.
else.
exit.
endif.
else.
exit.
endif.
enddo.
shift dir_name right deleting trailing '/\ '.
shift dir_name left deleting leading space.
call 'C_DIR_READ_FINISH' " this is from RSWATCH0
id 'ERRNO' field errno
id 'ERRMSG' field errmsg.
call 'C_DIR_READ_START'
id 'DIR' field dir_name
id 'FILE' field file_name
id 'ERRNO' field errno
id 'ERRMSG' field errmsg.
case sy-subrc.
when 1.
case errno.
when 2 or 20. f_subrc = f_subrc + 66.
when ' '. f_subrc = f_subrc + 67.
endcase.
when 0.
clear error_counter.
do.
clear file.
clear dir_list.
call 'C_DIR_READ_NEXT'
id 'TYPE' field file-line-type
id 'NAME' field file-line-name
id 'LEN' field file-line-len
id 'OWNER' field file-line-owner
id 'MTIME' field file-line-mtime
id 'MODE' field file-line-acc_mode
id 'ERRNO' field errno
id 'ERRMSG' field errmsg. "sy-subrc = 3 is e.g. if return
if sy-subrc = 0 or sy-subrc = 3."data do not fit into variables
perform p6_to_date_time_tz(rstr0400) using
file-line-mtime
file-line-mod_time
file-line-mod_date.
file_size = file-line-len.
dir_list = file-line.
append dir_list.
elseif sy-subrc = 1. " nothing (more) found
exit.
else.
if error_counter > 50.
call 'C_DIR_READ_FINISH'
id 'ERRNO' field errno
id 'ERRMSG' field errmsg.
pos = f_subrc mod 2.
if pos = 0. f_subrc = f_subrc + 1. endif.
exit.
endif.
add 1 to error_counter.
endif.
if sy-index > 1000.
pos = f_subrc mod 4.
if pos = 0. f_subrc = f_subrc + 2. endif.
exit.
endif.
enddo.
call 'C_DIR_READ_FINISH'
id 'ERRNO' field errno
id 'ERRMSG' field errmsg.
if sy-opsys(3) = 'Win' and not ( file_name cs '*' ).
describe table dir_list lines len.
if len = 0.
help1 = file_name.
translate help1 to upper case.
translate help1 using
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
call 'C_DIR_READ_START'
id 'DIR' field dir_name
id 'FILE' field help1.
if sy-subrc = 0.
clear error_counter.
do.
clear file.
clear dir_list.
call 'C_DIR_READ_NEXT'
id 'TYPE' field file-line-type
id 'NAME' field file-line-name
id 'LEN' field file-line-len
id 'OWNER' field file-line-owner
id 'MTIME' field file-line-mtime
id 'MODE' field file-line-acc_mode
id 'ERRNO' field errno
id 'ERRMSG' field errmsg.
if sy-subrc = 0 or sy-subrc = 3.
help2 = file_name.
translate help2 to upper case.
help1 = file-line-name.
translate help1 to upper case.
if help1 = help2.
perform p6_to_date_time_tz(rstr0400) using
file-line-mtime
file-line-mod_time
file-line-mod_date.
dir_list = file-line.
append dir_list.
endif.
elseif sy-subrc = 1.
exit.
else.
if error_counter > 50.
call 'C_DIR_READ_FINISH'
id 'ERRNO' field errno
id 'ERRMSG' field errmsg.
pos = f_subrc mod 2.
if pos = 0. f_subrc = f_subrc + 1. endif.
exit.
endif.
add 1 to error_counter.
endif.
if sy-index > 1000.
pos = f_subrc mod 4.
if pos = 0. f_subrc = f_subrc + 2. endif.
exit.
endif.
enddo.
call 'C_DIR_READ_FINISH'
id 'ERRNO' field errno
id 'ERRMSG' field errmsg.
endif.
endif.
endif.
endcase.
ENDCASE.
CASE f_subrc.
WHEN 1 OR 3. RAISE too_many_errors.
WHEN 2. RAISE too_many_files.
WHEN 4 OR 5 OR 6 OR 7 OR 70 OR 71.
RAISE bracket_error_in_filename.
WHEN 8 OR 9 OR 10 OR 11 OR 74 OR 75.
RAISE no_such_parameter.
WHEN 64. RAISE no_authority.
WHEN 65. RAISE activity_unknown.
WHEN 66. RAISE not_a_directory.
WHEN 67. RAISE no_media_in_drive.
ENDCASE.
endfunction.
Now you will be able to get the filesize and the file in SDOK format sdokbin.
Okay.
You have to build an request and push the content to the user like:
call method server->response->set_header_field( name = 'Content-Type' value = value ).
describe field file_content_binary-line length line_length in byte mode.
bytes_rest = file-size.
loop at file_content_binaries assigning <file_content_binary>.
move <file_content_binary>-line to data.
if bytes_rest <= 0. "mismatch between line values and size
exit.
endif.
if bytes_rest >= line_length.
call method server->response->append_data( data = data
length = line_length ).
else.
call method server->response->append_data( data = data
length = bytes_rest ).
endif.
bytes_rest = bytes_rest - line_length.
endloop.
This will work.
You can set the header fields like you want. Have also a look at sicf node contentserver
and its handler: CL_HTTP_EXT_CSIF -
How to download a file from application server to presentation server
Hi experts,
I want to download a file from application server to presentaion server, file contaims three fields customer name, customer email id and status..
help me out i m new into sap.Dear Aditya,
Please check below thread
http://scn.sap.com/thread/1010164
it will help you.
BR
Atul
Maybe you are looking for
-
Error on the r12 about workflow
what error on this foe workflow noticfiction? System: Error Local Event ERROR : oracle.apps.fnd.system.exception / 4206714 thanks
-
Dear colleges, Thanks in advance for viewing and suggesting! Now for whatever reason it is the XCHG server is not responsive at all when launching ECP from the other computer on the domain. When logging in to the virtual box EXCH server is hosted on
-
What is the best anti~virus for macbook pro?
What is the best anti~virus foe macbook pro?
-
Internet Explorer 9 and Firefox 4
Hey Everyone - I've heard some reports of IE9 not working well on the forums just yet. Lithium expects to have the issues resolved in mid to late April. If you don't have to upgrade I would recommend not doing so just yet. Also, has anyone tried Fi
-
Error When Posting Returns Delivery
Hello Everyone, I am encountering an error in SAP whenever I am trying to post a returns delivery - "Value of Goods Movement is Negative". I checked OMJJ and negative posting for 122 is allowed. Is there an explanation for this? How can I compute the