on 02-11-2009 12:00 PM
Hi guys,
How to download desktop file data into application server in the Web dynpro application?
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For uploading of files you should use the fileUpload UI element.
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/b3/be7941601b1d09e10000000a155106/frameset.htm
It will place the content of the file into a XSTRING context attribute. It is then up to you how you want to process the file. The process for turning it into an internal table will depend upon what type of file from the PC it is.
Hi RajKumar,
I am uploading excel file in my case, & ensure that columns in my excel are exactly present in the internal table structure that i use.
Declare context node FILE
with Attributes:
Filename type String
MimeType type String
FILE type xstring.
Place 'Fileupload UI element' on you view , bind DATA property to Attribute u2018FILEu2019 created in the context node.
Create a Button lets call UPLOAD. on its click action put the following code.
method upload_file .
data: s_cont type string,
x_cont type xstring,
convt type ref to cl_abap_conv_in_ce,
item_file type xstringval.
data: input_string type string,
fields type string_table,
fields2 type string_table,
tbl_fields type string_table,
s_table type string_table,
ls_table like line of s_table,
ls like line of fields,
lv_num_cols type i.
data: lt_data type table of ZMYREC, "here
ls_data like line of lt_data,
lv_data type string.
field-symbols: <wa_table> like line of s_table.
wd_this->m_elem_file->get_attribute(
exporting
name = `FILE`
importing
value = item_file ).
convt = cl_abap_conv_in_ce=>create( input = item_file ).
convt->read( importing data = s_cont ).
"Column headers
split s_cont at cl_abap_char_utilities=>cr_lf into table s_table.
read table s_table into ls_table index 1.
"Delete column header
delete s_table index 1.
split ls_table at cl_abap_char_utilities=>horizontal_tab into table fields.
lv_num_cols = lines( fields ).
refresh fields.
loop at s_table assigning <wa_table>.
split <wa_table> at cl_abap_char_utilities=>horizontal_tab into :
ls_data-recordid
ls_data-bstkd
ls_data-kunnr
ls_data-matnr
ls_data-candno
ls_data-fname
ls_data-inits
ls_data-lname
ls_data-gesch.
append ls_data to lt_data.
clear ls_data.
endloop.
wd_this->m_node_data->bind_table(
exporting
new_items = lt_data
set_initial_elements = abap_true ).
endmethod.
Greetings
Prashant
P.S. Poinst welcome
Hi Prasant and Thomas,thanks a lot for ur valuable input.Actually I am new for webdynpro ABAP and I tried Prasant code and getting Dump (character set conversion not possible). I am getting the dump in this location.
convt = cl_abap_conv_in_ce=>create( input = lv_file ).
convt->read( importing data = s_cont ).
i am giving my code here..
data: s_cont type string,
x_cont type xstring,
convt type ref to cl_abap_conv_in_ce.
data: input_string type string,
fields type string_table,
fields2 type string_table,
tbl_fields type string_table,
s_table type string_table,
ls_table like line of s_table,
ls like line of fields,
lv_num_cols type i.
TYPES:BEGIN OF x_final1,
pspnr TYPE prps-posid,
matnr TYPE mara-matnr,
desc TYPE prps-objnr,
vbeln TYPE vbap-vbeln,
ebeln TYPE ekpo-ebeln,
END OF x_final1.
DATA:lt_data TYPE STANDARD TABLE OF x_final1,
ls_data TYPE x_final1,
lv_data TYPE string.
field-symbols: <wa_table> like line of s_table.
DATA lo_nd_file TYPE REF TO if_wd_context_node.
DATA lo_el_file TYPE REF TO if_wd_context_element.
DATA ls_file TYPE wd_this->element_file.
DATA lv_file type xstring.
* navigate from <CONTEXT> to <FILE> via lead selection
lo_nd_file = wd_context->get_child_node( name = wd_this->wdctx_file ).
* get element via lead selection
lo_el_file = lo_nd_file->get_element( ).
* get single attribute
lo_el_file->get_attribute(
EXPORTING
name = `FILE`
IMPORTING
value = lv_file ).
convt = cl_abap_conv_in_ce=>create( input = lv_file ).
convt->read( importing data = s_cont ).
"Column headers
split s_cont at cl_abap_char_utilities=>cr_lf into table s_table.
read table s_table into ls_table index 1.
"Delete column header
delete s_table index 1.
split ls_table at cl_abap_char_utilities=>horizontal_tab into table fields.
lv_num_cols = lines( fields ).
refresh fields.
loop at s_table assigning <wa_table>.
split <wa_table> at cl_abap_char_utilities=>horizontal_tab into :
ls_data-pspnr
ls_data-matnr
ls_data-desc
ls_data-vbeln
ls_data-ebeln .
append ls_data to lt_data.
clear ls_data.
endloop.
lv_file is containing data in bytes.and i am not able to get the original data in the s_table
Please help me.Thanks in advance.
Hi Rajkumar,
In my case i am using a TabDelimeted file as input. I have an Excel with columns and data. Now from file->save as option i save this file as TEXT (Tab Delimeted) option. then this file is ready for upload.
If you are uploading excel , saving it as tab-delimeted should solve your problem.
Greetings
Prashant
Hi prasant and thomas thank u so much, the problem was i didnt save the file as ttab delimited.
now it is working fine..Now my requirement is to uploaad the data to application server,will DATA SET works.
one more thing..suppose if i user files other than excel,what method i have to use.,
Please Help me ,thanks in advance..
If you are just wanting to store it in the application server, then most of the logic above is not necessary nor would it work for files other than text tab delimited. Just keep the xstring content and write it directly into the filesystem using the DATASET commands.
Why would you want to use FTP if you are writting to the filesystem of the ABAP application server? DATASET commands would be far more efficient. You would only need to use FTP if you want to write to a remote file system that can't be mounted to the ABAP application server. In this case you can use FTP. Look at the function group SFTP for the function modules that you must call. Also look at the programs in the SFTP package.
Hi,
why don't you use the [FileUpload|http://help.sap.com/saphelp_erp2005/helpdata/DE/b3/be7941601b1d09e10000000a155106/frameset.htm] Component?
Regards
Daniel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.