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
Similar Messages
-
Error while reading excel file from application server into internal table.
Hi experts,
My requirement is to read an excel file from application server into internal table.
Hence I have created an excel file fm_test_excel.xls in desktop and uploaded to app server using CG3Z tcode (as BIN file type).
Now in my program I have used :
OPEN DATASET v_filename FOR INPUT IN text mode encoding default.
DO.
READ DATASET v_filename INTO wa_tab.
The statement OPEN DATASET works fine but I get a dump (conversion code page error) at READ DATASET statement.
Error details:
A character set conversion is not possible.
At the conversion of a text from codepage '4110' to codepage '4103':
- a character was found that cannot be displayed in one of the two
codepages;
- or it was detected that this conversion is not supported
The running ABAP program 'Y_READ_FILE' had to be terminated as the conversion
would have produced incorrect data.
The number of characters that could not be displayed (and therefore not
be converted), is 445. If this number is 0, the second error case, as
mentioned above, has occurred.
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_CONVERSION_CODEPAGE', was not
caught and
therefore caused a runtime error.
The reason for the exception is:
Characters are always displayed in only a certain codepage. Many
codepages only define a limited set of characters. If a text from a
codepage should be converted into another codepage, and if this text
contains characters that are not defined in one of the two codepages, a
conversion error occurs.
Moreover, a conversion error can occur if one of the needed codepages
'4110' or '4103' is not known to the system.
If the conversion error occurred at read or write of screen, the file
name was '/usr/sap/read_files/fm_test_excel.xls'. (further information about
the file: "X 549 16896rw-rw----201105170908082011051707480320110517074803")
Also let me know whether this is the proper way of reading excel file from app server, if not please suggest an alternative .
Regards,
KarthikHi,
Try to use OPEN DATASET v_filename FOR INPUT IN BINARY mode encoding default. instead of OPEN DATASET v_filename FOR INPUT IN text mode encoding default.
As I think you are uploading the file in BIN format to Application server and trying to open text file.
Regards,
Umang Mehta -
Upload XML file from Application Server to Internal Table
Hi Experts,
i have xml file in application server and i want to convert to internal table .
i have tried this link http://wiki.sdn.sap.com/wiki/display/ABAP/UploadXMLfiletointernal+table.
Here the file is loaded from local(presentation Server) ..
i want to know how to select file from application layer ..and schedule in background..
i also tried FM '/SAPDMC/LSM_F4_SERVER_FILE' but this need front end selection of file from application server..
i need to select a xml file from application server and convert into internal table in background.. help me on this..Have a look on
Re: How to convert XML data to different ABAP internal table
Thanks
Ravin -
Issue with uploading XML file from application server into internal table
i Need to fetch the XML file from the application server and place into internal table and i am getting error message while using the functional module SMUM_XML_PARSE and the error message is "line 1 col 1-unexpected symbol; expected '<', '</', entity reference, character data, CDATA section, processing instruction or comment" and could you please let me know how to resolve this issue?
TYPES: BEGIN OF T_XML,
raw(2000) TYPE C,
END OF T_XML.
DATA:GW_XML_TAB TYPE T_XML.
DATA: GI_XML_TAB TYPE TABLE OF T_XML INITIAL SIZE 0.
DATA:GI_STR TYPE STRING.
data: GV_XML_STRING TYPE XSTRING.
DATA: GI_XML_DATA TYPE TABLE OF SMUM_XMLTB INITIAL SIZE 0.
data:GI_RETURN TYPE STANDARD TABLE OF BAPIRET2.
OPEN DATASET LV_FILE1 FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC NE 0.
MESSAGE 'File does not exist' TYPE 'E'.
ELSE.
DO.
* Transfer the contents from the file to the work area of the internal table
READ DATASET LV_FILE1 INTO GW_XML_TAB.
IF SY-SUBRC EQ 0.
CONDENSE GW_XML_TAB.
* Append the contents of the work area to the internal table
APPEND GW_XML_TAB TO GI_XML_TAB.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
* Close the file after reading the data
CLOSE DATASET LV_FILE1.
IF NOT GI_XML_TAB IS INITIAL.
CONCATENATE LINES OF GI_XML_TAB INTO GI_STR SEPARATED BY SPACE.
ENDIF.
* The function module is used to convert string to xstring
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
TEXT = GI_STR
IMPORTING
BUFFER = GV_XML_STRING
EXCEPTIONS
FAILED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE 'Error in the XML file' TYPE 'E'.
ENDIF.
ENDIF.
IF GV_SUBRC = 0.
* Convert XML to internal table
CALL FUNCTION 'SMUM_XML_PARSE'
EXPORTING
XML_INPUT = GV_XML_STRING
TABLES
XML_TABLE = GI_XML_DATA
RETURN = GI_RETURN.
ENDIF.
READ TABLE GI_RETURN TRANSPORTING NO FIELDS WITH KEY TYPE = 'E'.
IF SY-SUBRC EQ 0.
MESSAGE 'Error converting the input XML file' TYPE 'E'.
ELSE.
DELETE GI_XML_DATA WHERE TYPE <> 'V'.
REFRESH GI_RETURN.
ENDIF.Could you please tel me why the first 8 lines were removed, till <Soap:Body and also added the line <?xml version="1.0" encoding="UTF-8"?> in the beggining .
Becuase there will be lot of XML files will be coming from the Vendor daily and that should be uploaded in the application server and should update in the SAP tables based on the data in the XML file.
what information i need to give to vendor that do not add the first 8 lines in the XML file and add the line in the beggining <?xml version="1.0" encoding="UTF-8"?> ??????
Is there any other way we can do with out removing the lines? -
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 -
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 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 Ghi 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. -
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 -
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. -
Problem while uploading file from application server to internal tab in BG
Hi all,
When i see the file in application server.data is like this
#################00\);_(#####}#-#}###############################00\);_(#####}#-#}###############################00\);_(*#####}#-#}#########
###################}###}#############A#############???#00\);_(*#################;_(@_) ########???# ########???# ########???###
#######???#########}###}#############)##############}##00\);_(*#################;_(@_) ############ ############ ##############
###################}#A#}#############:##############}##00\);_(#################;_(@_) }###}##############################00\);_(*##########
#######???#########}#-#}#############F#################00\);_(#####}###}#############@#################00\);_(#################;_(@_) #####
###################}#-#}#############3#################00\);_(#####}#U#}#############E#################00\);_(#################;_(@_) #####
Because the csv which is uploaded has dropdowns and some formattings.
when download from tcode cg3y i am getting correct file
When try to use open(binary mode) and read dataset i getting data as it is (junk).
i need to process in background.
Any help.
Rhea.upload file to string format
begin of ty_tab,
string type char200,
end of ty_tab.
loop at ty_tab into string
use statement replace string into tab deliminated fromat(particular occurance in string)
now call class to break string at tab into fields
endloop.
DATA : BEGIN OF i_data OCCURS 0,
data(200) TYPE c, "To hold Upload file data
END OF i_data.
OPEN DATASET v_str FOR INPUT
IN TEXT MODE
ENCODING DEFAULT IGNORING CONVERSION ERRORS.
IF sy-subrc EQ 0.
DO.
*Read a line from input file
READ DATASET v_str INTO i_data-data.
IF sy-subrc NE 0.
EXIT.
ENDIF.
*Append record to an internal table
APPEND i_data.
CLEAR: i_data.
ENDDO.
*Close the file
CLOSE DATASET v_str.
*---Start of inserti
LOOP AT i_data.
REPLACE ALL OCCURRENCES OF '"' IN i_data WITH '#'.
SPLIT i_data AT cl_abap_char_utilities=>horizontal_tab
INTO i_doc-pvaudt
i_doc-pvpate
i_doc-vecatc
i_doc-vhvend
i_doc-vhidt8
i_doc-vhinvn
i_doc-vhhexp
i_doc-vhiref. -
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. -
Read excel file in application server to internal table
Hi,
I have an excel file located in some folder in my application server. I don't have excel installed in the server. Now I want to read the excel file data into an internal table. I tried to use READ DATASET, but it returned junk characters.
I have searched SDN extensively for this, but without any succesful answer.
Regards,
Arun.Hi Arun,
Please check the code below for your reference.
TABLES:eket.
TYPE-POOLS truxs.
DATA it_truxs(4056) TYPE c OCCURS 0.
DATA:v_dt(2),filename TYPE string,
i_temp TYPE truxs_t_text_data.
DATA:BEGIN OF it_eket OCCURS 0,
ebeln LIKE eket-ebeln,
ebelp LIKE eket-ebelp,
etenr LIKE eket-etenr,
eindt LIKE eket-eindt,
END OF it_eket.
PARAMETERS: p_path TYPE rlgrap-filename.
SELECTION-SCREEN : PUSHBUTTON /2(10) pb_but1 USER-COMMAND get.
PARAMETERS:p_no TYPE i.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = sy-cprog
dynpro_number = sy-dynnr
IMPORTING
file_name = p_path.
START-OF-SELECTION.
REFRESH :it_eket,i_temp,it_truxs.
filename = p_path.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = filename
filetype = 'ASC'
* has_field_separator = 'X'
TABLES
data_tab = i_temp.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
i_tab_raw_data = i_temp
i_filename = p_path
TABLES
i_tab_converted_data = it_eket
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
SORT it_eket BY ebeln.
DELETE ADJACENT DUPLICATES FROM it_eket COMPARING ebeln. -
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. -
Read Excel File on Application Server to Internal Table
Hi Everybody!
Can anyone tell me how I can Read in an Excel File from the Application Server?
I'm familiar with the OPEN DATASET Statement and I already use it to read in text files.
Important is, that it works in the Batch / can be used as a background job
I already tried using
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
which did not work.
Can anybody please help me`?
I created the file I try to read out from the Application Server Folder with the Standard upload
in ABAP Web Dynpro and Wrote it to the Server with the following code. Does anyone know
if maybe already the writing is to the application server is wrong?
try.
convt = cl_abap_conv_in_ce=>create(
input = lv_filedata
encoding = 'UTF-8'
replacement = '?'
ignore_cerr = abap_true ).
convt->read( importing data = s_cont ).
catch cx_sy_conversion_codepage.
wd_comp_controller->show_error( exporting
text = 'There occurred an error during conversioning the code page.' type = 'E' ).
endtry.
open dataset XLSFILEPATH for output in binary mode.
transfer s_cont TO XLSFILEPATH.
close dataset XLSFILEPATH.
Best Regards and Thanks,
SteffenHi Suhan,
I tried the following, but the output in the table doesn't look good at all
Can you please help?
OUTPUT:
??#u0871#?################>###??##############################=#######????########???????????????????????????????????????????????????????????????????????????????????????????????????????
####################################################################################### ###!###"#######$###%###&###'###(###)###*###+###,###-###.###/###0###1###2###3###4###5###6###7#
#?######Z##A#r#i#a#l###3########,#####0#\# #"#? "#;#\#-###,#####0#\# #"#? "###=########,#####0#\# #"#? "#;#[#R#e#d#]#\#-###,#####0#\# #"#? "###?########,#####0#.#0#0#\# #"#? "#;#\#-
###?? ##?########? ?#######?? ##?########? ?#######?? ##?#P######? ?#######?? ##?#P######? ?#######?? ##?# ######? ?#######?? #################A#?#?j}#(#}############################
##########?########}#?#}#############*##################_#? _#-########????#,#####0########????#? _#-#;########????#"#?#?#\########????#_#-#@#_
#######????########}#(#}#############+##################_#? _#-}#(#}#############,##################_#? _#-}#(#}#############-##################_#? _#-}#(#}#############.###########
##########?########}#<#}#############6#############?}#?#_#? _#-########??#?#,#####0}#<#}#############7#############?e#?#_#? _#-########????#,#####0}#?#}#############8###############
#######????########}#?#}#############9#############????#_#? _#-########????#,#####0########????#? _#-#;########????#"#?#?#\########????#_#-#@#_
#######????########}#(#}#############:##################_#? _#-}#-#}#############;##################_#? _#-#####}#P#}#############<##################_#? _#-#############,#####0#####
##Check Cell?#z#?##############?
#C#h#e#c#k# #C#e#l#l##########?##????########????#####?##????#######?##????#######?##????#######?##????##?###+?#??# #?##############?##C#o#m#m#a#####?###,?#??#(#?##############?##C#
#5####Input?#p#?##############?##I#n#p#u#t##########?##?u0319?#####?##??v?#####?#####?#######?#####?#######?#####?#######?#####?##?###6####Linked Cell?#F#?##############?##L#i#n#k#e#d#
?##N#o#t#e##########?##????#####?##????#######?##????#######?##????#######?##????##?###9####Output?#r#?##############?##O#u#t#p#u#t##########?##????#####?##????#####?##????#######?#
#;####Title?#1#?##############?##T#i#t#l#e##############I}?%####?#
#<####Total?#H#?##############?##T#o#t#a#l################?########O???##########O???##?###=####Warning Text?#:#?##############?##W#a#r#n#i#n#g# #T#e#x#t##########?##?##??#X#?######
##Commission###Health Incentive ###Housing Norm###Hypo Tax###Hypo Tax- Special Wages###Paid Time Off(##Vision Insurance- Withheld from Employee###Working Spouse/DP surcharge)##TX St
###########?#?#?######### #########c###?3###N##?h##?t##nu############d#################????MbP?_#####*#####+#####?#####?###########%#####?#?###?#########?#####?#####&###ffffff??'###
#I#######}########+######}#######$
######}#######m###############c###################?###################?###################?###################?###################?###################?###################?##########
CODING:
types: begin of st_excel_parse,
clientno type string,
fileid type string,
paymtreportingid type string,
name type string,
employee_id type string,
home_country type string,
host_country type string,
actstartdt type string,
actenddt type string,
assignment_status type string,
paymttypenm type string,
paymtcategorynm type string,
paymtdt type string,
transeffdt type string,
amount type string,
currency_code type string,
end of st_excel_parse.
data: ls_excel_parse type st_excel_parse,
lt_excel_parse type table of st_excel_parse.
data l_wa_raw_data type string.
open dataset gv_str_filename for input in text mode encoding default.
if sy-subrc = 0.
do.
read dataset gv_str_filename into l_wa_raw_data.
if sy-subrc = 0.
"Split the file record using <TAB> and store inside the work area
split l_wa_raw_data at cl_abap_char_utilities=>horizontal_tab into :
ls_excel_parse-clientno
ls_excel_parse-fileid
ls_excel_parse-paymtreportingid
ls_excel_parse-name
ls_excel_parse-employee_id
ls_excel_parse-home_country
ls_excel_parse-host_country
ls_excel_parse-actstartdt
ls_excel_parse-actenddt
ls_excel_parse-assignment_status
ls_excel_parse-paymttypenm
ls_excel_parse-paymtcategorynm
ls_excel_parse-paymtdt
ls_excel_parse-transeffdt
ls_excel_parse-amount
ls_excel_parse-currency_code .
append ls_excel_parse to lt_excel_parse.
endif.
enddo.
endif.
Maybe you are looking for
-
Error while sendinf pdf file as attachment
hi all., am trying to send the pdf file of a smartform as attachment thru mail .. but its getting failed am getting error (sy-subrc = 6 ) after calling the fm so_new_document_att_send_api1 .. pls. suggest the possible cause of errors. CALL FUNCTION '
-
ITunes stops working when trying to play purchased video
Hey Everyone, For some reason whenever I try to play a video or TV program that I purchased from the iTunes store it causes iTunes to shut down and it won't play the video. It does bring up the player for a few seconds then just hangs and a few secon
-
Hi Everyone, I wonder if someone could advise about a problem? We have a number of video clips from a client in WMV format and wish to import into Flash 8. We did this without any problems and created the flv files using the video import wizard. The
-
FCPx 10.0.3 (exporting video, "proxy" - "original")
When you import video into FCPx and create proxy video from your original video, you must remember afterwards to change in the settings to "use proxy video when editing video", or else in defulte settings you use the original, even if you chosen "cre
-
Print servers and printers problems on Win7 and Win8
Hello, We have some computers, working on Windows operating system in the office: a few forking on the good old XP sp3, one running on the Win7 x64 home edition and one running on Win8 professional (the last one installed for new OS testing purposes)