cancel
Showing results for 
Search instead for 
Did you mean: 

Upload and display Word Document in WD application

0 Kudos

Hello,

I have a WD ABAP appl. where the user wants to upload an Word / Excel file (from its own local drive).

The document shall be saved in SAP and it shall also be possible to display the document later in the WD application.

I implemented the UI element upload in the view, to determine the path of the document.

For the display implemented the UI element Office control.

1. When i browse the document, the properties data, filename and mime type are filled into the bound context elements of the upload UI.

2. The property datasource of the UI office control I bound to the same context element, that is also bound to the property data of the upload UI.

The office control opens a word document, but the document is empty.

Is it possible that the document is not uploaded correct?

In another application I did an upload for a PDF doc.. There I implemented the following coding as action of the button 'Upload'.

data lo_nd_pdf type ref to if_wd_context_node.

data lo_el_pdf type ref to if_wd_context_element.

data ls_pdf type wd_this->element_pdf.

data lv_pdf like ls_pdf-pdf.

  • navigate from <CONTEXT> to <PDF> via lead selection

lo_nd_pdf = wd_context->get_child_node( name = wd_this->wdctx_pdf ).

  • get element via lead selection

lo_el_pdf = lo_nd_pdf->get_element( ).

  • get single attribute

lo_el_pdf->get_attribute(

exporting

name = `PDF`

importing

value = lv_pdf ).

  • Get a reference to the from processing class.

data: l_fp type ref to if_fp.

l_fp = cl_fp=>get_reference( ).

  • Get a reference to the PDF Object class.

data: l_pdfobj type ref to if_fp_pdf_object.

l_pdfobj = l_fp->create_pdf_object( ).

  • set the pdf in the PDF Object

l_pdfobj->set_document( pdfdata = lv_pdf ).

  • set the PDF Object to extract data the Form data.

l_pdfobj->set_extractdata( ).

  • execute call to ADS

l_pdfobj->execute( ).

  • get the PDF Form data

data: pdf_form_data type xstring.

l_pdfobj->get_data(

importing

formdata = pdf_form_data ).

  • convert the xstring from data to string so it can be processed using the iXML classes

data: converter type ref to cl_abap_conv_in_ce,

formxml type string.

converter = cl_abap_conv_in_ce=>create( input = pdf_form_data ).

converter->read(

importing

data = formxml ).

  • pull in the iXML type group.

type-pools: ixml.

  • get a reference to iXML object

data:l_ixml type ref to if_ixml.

l_ixml = cl_ixml=>create( ).

  • get iStream object from StreamFactory

data: streamfactory type ref to if_ixml_stream_factory,

istream type ref to if_ixml_istream.

streamfactory = l_ixml->create_stream_factory( ).

istream = streamfactory->create_istream_string( formxml ).

  • create an XML document class that will be used to process the XML

data: document type ref to if_ixml_document.

document = l_ixml->create_document( ).

  • create the parser class

data: parser type ref to if_ixml_parser.

parser = l_ixml->create_parser( stream_factory = streamfactory

istream = istream

document = document ).

  • parse the XML

parser->parse( ).

  • define XML Node type object

data: node type ref to if_ixml_node,

attributes type ref to if_ixml_named_node_map.

  • get the psi sales data Node and value.

data ls_psi_sales type wd_this->element_psi_sales.

data: lt_dfies type table of dfies,

ls_defies type dfies.

call function 'DDIF_NAMETAB_GET'

exporting

tabname = 'ZCM_PSI_SALES'

  • ALL_TYPES = ' '

  • LFIELDNAME = ' '

  • GROUP_NAMES = ' '

  • UCLEN =

  • IMPORTING

  • X030L_WA =

  • DTELINFO_WA =

  • TTYPINFO_WA =

  • DDOBJTYPE =

  • DFIES_WA =

  • LINES_DESCR =

tables

  • X031L_TAB =

dfies_tab = lt_dfies

exceptions

not_found = 1

others = 2

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

data: lv_fieldname type string.

field-symbols <fs_field> type any.

loop at lt_dfies into ls_defies.

lv_fieldname = ls_defies-fieldname.

node = document->find_from_name( name = lv_fieldname ).

assign component lv_fieldname

of structure ls_psi_sales

to <fs_field>.

if <fs_field> is assigned.

<fs_field> = node->get_value( ).

endif.

endloop.

  • WRITE DATA INTO CONTEXT

data lo_nd_psi_sales type ref to if_wd_context_node.

data lo_el_psi_sales type ref to if_wd_context_element.

  • navigate from <CONTEXT> to <PSI_SALES> via lead selection

lo_nd_psi_sales = wd_context->get_child_node( name = wd_this->wdctx_psi_sales ).

  • get element via lead selection

lo_el_psi_sales = lo_nd_psi_sales->get_element( ).

  • set all declared attributes

lo_el_psi_sales->set_static_attributes(

exporting

static_attributes = ls_psi_sales ).

Do I need such a code also to upload a word doc?

Which interface / class exists for word documents? (for PDF upload there is the interface IF_FP)

How can I save a document in SAP? (as MIME Object? with which method?)

I hope someone can help me!?

BR

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

You can use the fileupload and filedownload uielements.

Check these links:

[File Upload|http://help.sap.com/saphelp_nw70ehp1/helpdata/en/b3/be7941601b1d09e10000000a155106/content.htm]

[File Download|http://help.sap.com/saphelp_nw70ehp1/helpdata/en/09/a5884121a41c09e10000000a155106/content.htm]

When you upload a file and save in SAP, are you saving it as xstring.

If yes follow these steps for filedownload.

Follow these steps for file download:

1 Create FileDownload uielement in your View

2.Create an Attribute of type xstring.

3.Bind this attribute to the data property of your Filedownload uielement.

4. during fileuplaod as you are saving the document in xstring format, fetch the same from your database table and pass the value to filedownload i.e set the attribute bound to data property of filedownload uielement with the xstring content.

Former Member
0 Kudos

Hi Josephine,

Have you resolved the issue? Please share with me.

Thank you.

Regards,

Henry