Upload a set of files from presentation server to app server.
Hello,
I need an urgent help.
I know how to use GUI_UPLOAD fm for simple file uploading.
However, my requirement is that in my report program(on selection screen) I give the source directory(presentation server) and the target directory
(application server). The report has to get all the files from the presentation server (from this source directory) and has to upload each file to the application server in the target directory.
Could anyone please help me in this?
It would be very helpful if anyone can put the code / standard example if there is any mechanism in ABAP to get the set of files from the presentation server, given the directory name.
THanks a lot for your help,
Best Regards,
Pramod S.
HI Pramod,
After you get the data into the internal table, you need to pass the internal table, record by record into the application server.
data: wa_file type string.
data: tab_file like table of wa_file,
pcount type i.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES
exporting
DIRECTORY = 'C:\test'
FILTER = '.'
FILES_ONLY = 'X'
DIRECTORIES_ONLY
changing
FILE_TABLE = tab_file
count = pcount.
loop at tab_file into wa_file.
clear it_data.
refresh it_data.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
exporting
FILENAME = wa_file
changing
data_tab = it_data.
open dataset <filename> for output in text mode encoding default.
if sy-subrc = 0.
loop at it_data.
transfer it_data to <filename>.
endloop.
close dataset.
endif.
endloop.
Thanks,
Ravi Kanth
Similar Messages
-
Copy File from Presentation Server to Application Server in Background
Hi,
I need to copy Image file from Presentation Server to Application Server.
The below given code is workking fine in Foreground but whenevr I am trying to execute in Background, the job is cancelled and I am getting a dump.
data : wa_source type string,
wa_destination type string.
wa_source = 'C:\PARBIND.BMP'.
wa_destination = 'D:\PARBIND.BMP'.
start-of-selection.
call method cl_gui_frontend_services=>file_copy
exporting
source = wa_source
destination = wa_destination
* overwrite = SPACE
* EXCEPTIONS
* cntl_error = 1
* error_no_gui = 2
* wrong_parameter = 3
* disk_full = 4
* access_denied = 5
* file_not_found = 6
* destination_exists = 7
* unknown_error = 8
* path_not_found = 9
* disk_write_protect = 10
* drive_not_ready = 11
* not_supported_by_gui = 12
* others = 13
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
In backgound Error is....
Exception condition "CNTL_ERROR" raised.*
Any solution is appreciated.
Thanks
ArbindHi Arbind,
Just realize... when you run it in foreground, you have a foreground to capture the file location. so it runs fine..
but when you are running it in background, there is no foreground to check that is no gui present... how can it check where the C:\.... location is??
no need of reading any oss note... just see.. the name is cl_GUI_FRONTEND_service.. its only for front end..
u need open dataset, read dataset, close dataset kind of things while running in background. or RFCs to read the file... (search SDN). -
How to search file from presentation server
Hi All,
In a ABAP program i want to display a dialog box which will help me to find out any file from presentation server.That dialog box should be display after clicking on parameter on selection screen.Parameter is a simple variable,not a field from any internal table. so i can not use function module F4IF_INT_TABLE_VALUE_REQUEST
Please suggest me any function module which will satisfy my requirement.
Thank you.Hi,
Check this example..
DATA: T_FILETABLE TYPE FILETABLE.
DATA: RC TYPE I.
DATA: USER_ACTION TYPE I.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
CHANGING
file_table = T_FILETABLE
rc = RC
USER_ACTION = USER_ACTION
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
others = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Thanks,
Naren -
Read XML file from presentation server
Hi All,
I want read XML file from presentation server currently i am using GUI_UPLOAD fm . but it is reading some junk data.
DATA : BEGIN OF upl OCCURS 0,
f(255) TYPE c,
END OF upl.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = D:\XX.XML'
filetype = 'BIN'
TABLES
data_tab = upl.
is there any other alternative.
Thanks
Swarup,Hi Swarup,
Use method IMPORT_FROM_FILE of class CL_XML_DOCUMENT.
A sample code snippet :-
PARAMETERS: p_filnam TYPE localfile OBLIGATORY
DEFAULT 'C:\Documents and Settings\ssaha\Desktop\test.xml'.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_filnam.
DATA: l_v_fieldname TYPE dynfnam.
l_v_fieldname = p_filnam.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = l_v_fieldname
IMPORTING
file_name = p_filnam.
START-OF-SELECTION.
TYPES:
BEGIN OF ty_tab,
name TYPE string,
value TYPE string,
END OF ty_tab.
DATA:
lcl_xml_doc TYPE REF TO cl_xml_document,
v_subrc TYPE sysubrc,
v_node TYPE REF TO if_ixml_node,
v_child_node TYPE REF TO if_ixml_node,
v_root TYPE REF TO if_ixml_node,
v_iterator TYPE REF TO if_ixml_node_iterator,
v_nodemap TYPE REF TO if_ixml_named_node_map,
v_count TYPE i,
v_index TYPE i,
v_attr TYPE REF TO if_ixml_node,
v_name TYPE string,
v_prefix TYPE string,
v_value TYPE string,
v_char TYPE char2.
DATA:
itab TYPE STANDARD TABLE OF ty_tab,
wa TYPE ty_tab.
CREATE OBJECT lcl_xml_doc.
CALL METHOD lcl_xml_doc->import_from_file
EXPORTING
filename = p_filnam
RECEIVING
retcode = v_subrc.
CHECK v_subrc = 0.
v_node = lcl_xml_doc->m_document.
CHECK NOT v_node IS INITIAL.
v_iterator = v_node->create_iterator( ).
v_node = v_iterator->get_next( ).
WHILE NOT v_node IS INITIAL.
CASE v_node->get_type( ).
WHEN if_ixml_node=>co_node_element.
v_name = v_node->get_name( ).
v_nodemap = v_node->get_attributes( ).
IF NOT v_nodemap IS INITIAL
* attributes
v_count = v_nodemap->get_length( ).
DO v_count TIMES.
v_index = sy-index - 1.
v_attr = v_nodemap->get_item( v_index ).
v_name = v_attr->get_name( ).
v_prefix = v_attr->get_namespace_prefix( ).
v_value = v_attr->get_value( ).
ENDDO.
ENDIF.
WHEN if_ixml_node=>co_node_text OR
if_ixml_node=>co_node_cdata_section.
* text node
v_value = v_node->get_value( ).
MOVE v_value TO v_char.
IF v_char <> cl_abap_char_utilities=>cr_lf.
wa-name = v_name.
wa-value = v_value.
APPEND wa TO itab.
CLEAR wa.
ENDIF.
ENDCASE.
* advance to next node
v_node = v_iterator->get_next( ).
ENDWHILE.
LOOP AT itab INTO wa.
ENDLOOP.
Regards
Abhii -
Read file from presentation server (like GUI_UPLOAD)
Hi,
I need to read a txt file from local pc path in CRM WEB UI runtime. The path and the filename are already known, so I don´t need the control provided by thtmlb:fileUpload control, which automatically adds a u2018Browseu2019 button. I need to read this file without any additional controls or buttons.
I tried with RZL_READ_FILE, but doesn´t work with local files, only with application server files.
As you all know, GUI_UPLOAD doesn´t work in WEB UI...I need exactly something like that!
Any help or suggestion wil be appreciated.
Thanks in advance.
Federico.Hi Federico,
When it comes to web browser (web ui) file upload cannot be done as it is done in SAP GUI. There is a mechanism called 'Form-based File Upload in HTML' through which file is uploaded from web browser to the server, at the back end this is what is used. So you have to use a fileUpload tag to upload a file from web browser.
As an alternative solution, you can use Javascript and activexobjects to upload files. I have developed a wiki which explains excel upload using activexobjects and javascript.
http://wiki.sdn.sap.com/wiki/display/CRM/CRMWebUI-UploadingdatafromExcelfiles
Regards,
Arun -
File Upload and Download From Presentation server
I have a requirement to provide a selection option to user to upload a big file from presentation server.
Not sure whther we can a upload the entire file at one short from presentation server. PLease provide some sample code to upload a huge file from presentation server and downlaod a file to presentation server.Hi,
Try this code for download----
TABLES:
kna1. " General Data in Customer Master
TYPES:
BEGIN OF type_s_kna1,
kunnr TYPE kna1-kunnr, " Customer Number
adrnr TYPE kna1-adrnr, " Address
anred TYPE kna1-anred, " Title
erdat TYPE kna1-erdat, " Date on which record created
ernam TYPE kna1-ernam, " Name of Person who Created the
" Object
END OF type_s_kna1.
DATA:
fs_kna1 TYPE type_s_kna1.
DATA:
t_kna1 LIKE
STANDARD TABLE
OF fs_kna1.
" Select-options----
SELECT-OPTIONS:
s_kunnr FOR kna1-kunnr. " Customer Number
AT SELECTION-SCREEN ON s_kunnr.
SELECT kunnr " Customer number
FROM kna1
INTO s_kunnr UP TO 1 ROWS.
ENDSELECT.
IF sy-subrc NE 0.
MESSAGE 'No such customer exists' TYPE 'S'.
ENDIF. " IF SY-SUBRC NE 0
START-OF-SELECTION.
PERFORM customer_selection.
FORM customer_selection .
SELECT kunnr " Customer Number
adrnr " Address
anred " Title
erdat " Date of record creation
ernam " Person who created object
FROM kna1
INTO TABLE t_kna1
WHERE kunnr IN s_kunnr.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
filename = 'C:\TEMP\CUSTOMER.TXT'
FILETYPE = 'ASC'
write_field_separator = 'X'
HEADER = '00'
WRITE_LF = 'X'
col_select = 'X'
col_select_mask = 'XXXXX'
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
IMPORTING
FILELENGTH =
TABLES
data_tab = t_kna1
EXCEPTIONS
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. " IF SY-SUBRC NE 0
ENDFORM. " FORM CUSTOMER_SELECTION.
for upload----
" Table declarations----
TABLES:
bkpf. " Accounting Document Header
TYPES:
BEGIN OF type_s_bkpf,
bukrs TYPE bkpf-bukrs, " Company code
belnr TYPE bkpf-belnr, " Accounting Document Number
gjahr TYPE bkpf-gjahr, " Fiscal Year
blart TYPE bkpf-blart, " Document type
bldat TYPE bkpf-bldat, " Document Date in Document
END OF type_s_bkpf.
DATA:
fs_bkpf TYPE type_s_bkpf.
DATA:
fname(10) TYPE c VALUE 'ACCOUNTING' .
DATA:
t_bkpf LIKE
STANDARD TABLE
OF fs_bkpf.
*" Select-options----
SELECT-OPTIONS:
s_bukrs FOR bkpf-bukrs, " Company code
s_gjahr FOR bkpf-gjahr. " Fiscal year
OPEN DATASET fname FOR OUTPUT IN BINARY MODE .
PERFORM account_selection.
LOOP AT t_bkpf INTO fs_bkpf.
TRANSFER fs_bkpf TO fname.
ENDLOOP. " LOOP T_BKPF
CLOSE DATASET fname.
FORM account_selection .
SELECT bukrs " Company code
belnr " Accounting document number
gjahr " Fiscal year
blart " Document year
bldat " Document date
FROM bkpf
INTO TABLE t_bkpf
WHERE bukrs IN s_bukrs
AND gjahr IN s_gjahr.
ENDFORM. " FORM ACCOUNT_SELECTION
also try
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\TEMP\CUSTOMER.TXT'
FILETYPE = 'ASC'
has_field_separator = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
IMPORTING
FILELENGTH =
HEADER =
TABLES
data_tab = t_kna1
EXCEPTIONS
disk_full = 15
dp_timeout = 16
OTHERS = 17
IF sy-subrc EQ 0.
PERFORM customer_display.
ELSE.
MESSAGE 'No customer file exists'(006) TYPE 'S'.
ENDIF. " IF SU-SUBRC EQ 0
Regards,
jaya
Edited by: Jayapradha Neeli on May 28, 2009 11:38 AM -
FM to tansfer data in flat file from presentation to application server
Hi Experts,
Please tell the FM to tansfer data in flat file from presentation server to application server or vice versa in ECC 6.0.
Thanks.Hi,
This is how you can achieve it:
1. You read the flat file from presentation layer and store the file content in internal table gt_inrec
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = gw_filename
filetype = 'ASC'
IMPORTING
filelength = gw_length
header = gw_header
TABLES
data_tab = gt_inrec
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
2. Create a new file at the application server:
OPEN DATASET p_ofile FOR OUTPUT IN
TEXT MODE ENCODING DEFAULT.
3. Transfer the content from the internal table into the file at the application server:
LOOP AT gt_inrec.
TRANSFER gt_inrec-record TO p_ofile.
ENDLOOP.
Hope it helps,
Lim.... -
How to delete file from Window server
Hi
Can anybody tell me that Is there any function module for deleting file from presentation server like C directory.
Quick suggestion will highly be appreciated!!!!!!!Try this:
CALL METHOD cl_gui_frontend_services=>file_delete
EXPORTING
filename =
changing
rc =
EXCEPTIONS
FILE_DELETE_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
FILE_NOT_FOUND = 4
ACCESS_DENIED = 5
UNKNOWN_ERROR = 6
NOT_SUPPORTED_BY_GUI = 7
WRONG_PARAMETER = 8
others = 9
this is pretty gud approach .
Message was edited by:
Nishant Rustagi -
Reg : Executing .exe file from application server
Dear Experts,
i have a requirement to execute an .exe file from application server,i tried with method CL_GUI_FRONTEND_SERVICES=>EXECUTE but it executes .exe file from presentation server only.can
anyone kindly clarify to execute .exe file from application server?
Thanks in advance,
SujayHi,
Did you search before posting?
Re: Execute a .exe file present in the Application Server
Vikranth -
How to exreact multiple pdf files from a zip files from application server to presentation server
Hello exprts,
I am passing one pdf file and one text file to zip file in apllication server through my custom program and then downloading it using standard function module to my desktop. its working fine. Then I added another pdf file to my zip file. But only single pdf file is getting download . So can you please help me regardiong this issue?Dear Experts ,
I finded out the way to extrcat pdf files in presentation server. But now my problem is that I am not able to add multiple pdf files in a zip file. When I am adding new pdf file then older one is not coming in read data set. So please kindly tell me how can I add multiple pdf file in my zip file and again I can get all the pdf files from here. -
Upload file from Presentation to Application
Hi Friends,
I M uploading EXEL file from presentation to application server.
but in the transaction AL11 when i double click the file path ,i can not see the EXEL data. it is appearing the dump data. that way, i m finding the dump data in internal table also . what can i do for uploading EXEL file to application server.
please help me.
Thanks,
Rohinihai rohini
To upload excel file to AL11 Please refer to the given below code:
data : if_intern type kcde_cells occurs 0 with header line.
data : vf_index type i.
data : vf_start_col type i value '1',
vf_end_col type i value '256'.
field-symbols : <fs>.
* ----------- " Define Internal tables for ABAP.
data: begin of i_mat OCCURS 10,
empc(5),
name(12),
Age(3),
end of i_mat.
* ----------- " Define data variables for ABAP.
* " Define data variables for Excel Upload.
data: p_text type natxt.
data: dataset(150) type c.:
* ----------- " Selection-Screen.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE text-001.
parameters: p_file2 type rlgrap-filename,
p_brow2 type i,
p_erow2 type i.
SELECTION-SCREEN END OF BLOCK B1.
* ----------- " At Selection- screen.
at selection-screen on value-request for p_file2.
call function 'KD_GET_FILENAME_ON_F4'
EXPORTING
program_name = syst-repid
CHANGING
file_name = p_file2.
* ----------- " Start of ABAP SQL Commands
START-OF-SELECTION.
* dataset = '/tmp/new.xls'.
dataset = '/tmp/new.xls'.
if rg1 = 'X'.
if p_file2 is not initial and
p_brow2 is not initial and
p_erow2 is not initial.
call function 'KCD_EXCEL_OLE_TO_INT_CONVERT'
EXPORTING
filename = p_filename
i_begin_col = vf_start_col
i_begin_row = p_brow2
i_end_col = vf_end_col
i_end_row = p_erow2
TABLES
intern = if_intern.
if if_intern[] is initial.
p_text = 'No Data Uploaded'.
else.
sort if_intern by row col.
loop at if_intern.
move : if_intern-col to vf_index.
assign component vf_index of structure p_download to <fs>.
move : if_intern-value to <fs>.
at end of row.
append p_download.
clear p_download.
endat.
endloop.
endif.
delete dataset dataset.
open dataset dataset for output in text mode encoding default.
loop at i_mat.
if sy-subrc eq 0.
transfer i_mat to dataset.
endif.
endloop.
close dataset dataset. -
Error while uploading the file from Allpcation server in LSMW-7th step
Hi Experts,
what should be the specific CODE PAGE should be maintained while uploading the file from application server in LSMW-7th Step
Thanks in advance,
KSRHi
I mean that there is any seperate CODE PAGE which comes at the bottom of screen while uploading the file from the application server in 7th step.
Is there any specific CODE PAGE to be maintained...
Thanks in advance
Oarsk -
Upload XL file from FTP server
Hi All,
Can anybady help me, how to upload Excel file from FTP server.
Thanks
Sri
Edited by: srikanthn on Apr 14, 2010 6:31 PMHello
How about using SAPFTP?
I hope SAP note 130106 will guide you on this.
Thanks
koju -
Uploading and reading file from application server
Hi
My problem is when am uploading a file to application server it is getting stored in
usr/sap/transyp1/prod/in directory
after that i want to read that file from application server to update database
when using below code it is showing some other directory in f4 help
DATA: lv_hostname TYPE msxxlist-name.
DATA: lv_server TYPE bank_dte_jc_servername.
PARAMETERS: p_file TYPE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'BANK_API_SYS_GET_CURR_SERVER'
IMPORTING
e_server = lv_server.
lv_hostname = lv_server.
CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
EXPORTING
dynpfield_filename = 'P_FILE'
dyname = sy-cprog
dynumb = '1000'
filetype = 'P'
location = 'A'
server = lv_hostname.
experts could you please help me out
Thanks & Regards
Nagesh.ParuchuriUser Transaction file. You will get all logical file path names.
used following fucntion module to read file name and use command open dataset to read the file.
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
CLIENT = SY-MANDT
LOGICAL_FILENAME = C_LOGICAL_FILENAME
OPERATING_SYSTEM = SY-OPSYS
PARAMETER_1 = P_IN_FILENAME
IMPORTING
FILE_NAME = P_OUT_FILENAME
EXCEPTIONS
FILE_NOT_FOUND = 1
OTHERS = 2.
OPEN DATASET P_OPEN_FILE ENCODING UTF-8 IN TEXT MODE FOR OUTPUT.
IF SY-SUBRC <> 0.
MESSAGE E000(38) WITH 'Error in Opening file: ' V_PHY_FILENAME.
ENDIF. -
Problem in uploading file from Application Server
Hi everyone,
i got a problem in uplaoding a file from application server.i am having two folder (one folder name is current and another one is processed)in application server. In current folder i am having N no of files.I want to upload all the files names into one internal table and i want to process one by one file.After processing each file the file should be moved to processed folder and the files should not exist in current folder.All these process must be done everyday.Please rectify my problem asap.Ramesh,
Take authorization from basis guy.
Use the below code to get the list of files from require directory
*& Report ZDIRFILES *
REPORT ZDIRFILES .
PARAMETER: p_fdir type pfeflnamel DEFAULT '/usr/sap/tmp'.
data: begin of it_filedir occurs 10.
include structure salfldir.
data: end of it_filedir.
*START-OF-SELECTION
START-OF-SELECTION.
Get Current Directory Listing for OUT Dir
call function 'RZL_READ_DIR_LOCAL'
exporting
name = p_fdir
tables
file_tbl = it_filedir.
Now in internal table "it_filedir" will have all your files.
For moving and deleting
report zrich_0001.
Parameters: d1 type localfile default '/usr/sap/TST/SYS/fld1/Data1.txt',
d2 type localfile default '/usr/sap/TST/SYS/fld2/Data1.txt'.
data: begin of itab occurs 0,
rec(20) type c,
end of itab.
data: wa(20) type c.
start-of-selection.
open dataset d1 for input in text mode.
if sy-subrc = 0.
do.
read dataset d1 into wa.
if sy-subrc <> 0.
exit.
endif.
itab-rec = wa.
append itab.
enddo.
endif.
close dataset d1.
open dataset d2 for output in text mode.
loop at itab.
transfer itab to d2.
endloop.
close dataset d2.
delete dataset d1.
Check below FM if required
To move the file to archive directoryuse FMs 'PFL_COPY_OS_FILE'
To Delete 'EPS_DELETE_FILE'.
Don't forgot to reward if useful
Maybe you are looking for
-
hi, can anyone tell me whata system and sysaux tablespace contains, and how to manage them.
-
I can't download a driver to allow my computer to recognize my touch. This was the problem after I updated the latest version of Itunes.
-
Deploying BI publisher report from OEM plug-in
Hi! I am a bit confused about how to deploy & access BI publisher report from the plugin I develop I've found only the http://docs.oracle.com/cd/E24628_01/doc.121/e25161/bi_pub.htm and am a bit confused What I did: 1) Integrated BI publisher with OEM
-
Question related to the JAX-RPC.
Hi , I have a question related to the JAX-RPC API. Please clear me following points whether I am right or not? 1. If my two end points are in Java then and only we use the JAX-RPC API. Is it right? 2. If my two end points are in .Net then we use the
-
Can anyone help me with this error?
http://prntscr.com/5uou9e Getting this error trying to use an intro template. Help?