cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP webDynpro MS Office component usage throws - Access via 'NULL' object

Former Member
0 Kudos

I am trying to include MS office word in my custom ABAP webDynro application based on the sample SAP Package SIOS for all the MS office component usage. <br>

In WDMODIFY method , when the courser is reaching the point to call office component it throws a Null pointer exception. Not sure , if i am missing some thing here or skip a step. Please advice. <br>

  • get the IOS interface <br>

wd_this->factory ?= office->_method_handler. <br>

Below is the code for WDMODIFY <br>

method WDDOMODIFYVIEW . <br>

DATA: <br>

office TYPE REF TO cl_wd_view_element, <br>

office_res TYPE REF TO cl_wd_view_element,<br>

mime_repository TYPE REF TO if_mr_api,<br>

content TYPE xstring, <br>

url TYPE string VALUE <br>

'/SAP/BC/WebDynpro/SAP/PUblic/BC/ssr/uuielibs/office_integration' & <br>

'/iostest_fields.doc'. <br>

DATA refexp TYPE REF TO cx_ios_exception.

DATA: msgid TYPE syst-msgid,

msgnr TYPE syst-msgno,

msgty TYPE syst-msgty.

  • get message manager

DATA: l_current_controller TYPE REF TO if_wd_controller,

l_message_manager TYPE REF TO if_wd_message_manager.

DATA envproxy TYPE REF TO if_ios_environment.

  • just do it once

CHECK first_time = abap_true.

mime_repository = cl_mime_repository_api=>get_api( ).

CALL METHOD mime_repository->get

EXPORTING

i_url = url

IMPORTING

e_content = content.

wd_context->set_attribute( name = 'DATAS' value = content ).

  • get the office control

office ?= view->get_element( 'GENERIC_OFFICE' ).

ASSERT ID sios_demo CONDITION office IS BOUND.

  • not possible : Missing bugfix component bc-wd-aba

  • office_res ?= view->get_element( 'RESULT_DOCUMENT' ).

  • ASSERT ID sios_demo CONDITION office IS BOUND.

  • get the IOS interface

wd_this->factory ?= office->_method_handler.

ASSERT ID sios_demo CONDITION wd_this->factory IS BOUND.

  • wd_this->factory_res ?= office_res->_method_handler.

  • ASSERT ID sios_demo CONDITION wd_this->factory_res IS BOUND.

TRY.

wd_this->factory->get_wordprocessing_proxy(

IMPORTING proxy = wd_this->document ).

ASSERT ID sios_demo CONDITION wd_this->document IS BOUND.

  • wd_this->factory_res->get_wordprocessing_proxy(

  • IMPORTING proxy = wd_this->document_res ).

  • ASSERT ID sios_demo CONDITION wd_this->document IS BOUND.

  • ----------------------------------------------------------------

*calling setfields

DATA co_error_info_getfields TYPE REF TO if_wd_context_element.

DATA co_error_info_getfields_stru TYPE wdr_ext_attribute_pointer.

co_error_info_getfields = wd_context->get_lead_selection( ).

co_error_info_getfields_stru-attribute_name =

'error_info_getfields'.

co_error_info_getfields_stru-element = co_error_info_getfields.

DATA fields TYPE if_ios_wordprocessing=>fields_type.

DATA fieldstable TYPE if_ios_wordprocessing=>fields_type_table.

DATA co_fieldcontent TYPE REF TO if_wd_context_element.

DATA co_fieldcontent_stru TYPE wdr_ext_attribute_pointer.

DATA inputfield1 TYPE xstring.

DATA tabulator TYPE xstring.

DATA endofline TYPE xstring.

DATA: conv TYPE REF TO cl_abap_conv_out_ce.

DATA: testfielddata TYPE string.

testfielddata = 'SAPTEST'.

conv = cl_abap_conv_out_ce=>create( encoding = '4110'

ignore_cerr = abap_true ).

CALL METHOD conv->convert( EXPORTING data = 'field1'

IMPORTING buffer =

fields-fieldidentifier ).

CALL METHOD conv->convert( EXPORTING data = testfielddata

IMPORTING buffer = fields-value

).

CALL METHOD conv->convert( EXPORTING data =

cl_abap_char_utilities=>horizontal_tab

IMPORTING buffer = tabulator ).

CALL METHOD conv->convert( EXPORTING data =

cl_abap_char_utilities=>cr_lf

IMPORTING buffer = endofline ).

wd_context->set_attribute( name = 'inputfield1'

value = testfielddata ).

APPEND fields TO fieldstable.

wd_context->set_attribute( name = 'fieldcontent' value =

fieldstable ).

co_fieldcontent = wd_context->get_lead_selection( ).

co_fieldcontent_stru-attribute_name = 'fieldcontent'.

co_fieldcontent_stru-element = co_fieldcontent.

  • document is set through datasource!

wd_this->document->setfields( EXPORTING fieldsptr =

co_fieldcontent_stru

tabulator = tabulator

endofline = endofline

errorinformation =

co_error_info_getfields_stru ).

  • ----------------------------------------------------------------

*calling opening result document

DATA co_error_getcontent TYPE REF TO if_wd_context_element.

DATA co_error_getcontent_stru TYPE wdr_ext_attribute_pointer.

co_error_getcontent = wd_context->get_lead_selection( ).

co_error_getcontent_stru-attribute_name = 'error_getcontent'.

co_error_getcontent_stru-element = co_error_getcontent.

DATA co_createdcontent TYPE REF TO if_wd_context_element.

DATA co_createdcontent_stru TYPE wdr_ext_attribute_pointer.

co_createdcontent = wd_context->get_lead_selection( ).

co_createdcontent_stru-attribute_name = 'createdcontent'.

co_createdcontent_stru-element = co_createdcontent.

  • waiting of ACF Patch!

  • wd_this->document->getcontent( errorinformation =

*co_error_getcontent_stru

  • contentpointer_result = co_createdcontent_stru ).

*----


*calling reopening template

DATA error_opendocument TYPE REF TO if_wd_context_element.

DATA error_opendocument_stru TYPE wdr_ext_attribute_pointer.

error_opendocument = wd_context->get_lead_selection( ).

error_opendocument_stru-attribute_name = 'error_opendocument'.

error_opendocument_stru-element = error_opendocument.

  • wd_this->document_res->if_ios_document~opendocument( EXPORTING errorinformation = error_opendocument_stru ).

CATCH cx_ios_document INTO refexp.

CATCH cx_ios_communicationwrapper INTO refexp.

CATCH cx_ios_factory INTO refexp.

CATCH cx_ios_environment INTO refexp.

CATCH cx_ios_exception INTO refexp.

ENDTRY.

IF refexp IS NOT INITIAL.

refexp->get_message( IMPORTING

mtype = msgty

number = msgnr

mid = msgid ).

l_current_controller ?= wd_this->wd_get_api( ).

CALL METHOD l_current_controller->get_message_manager

RECEIVING

message_manager = l_message_manager.

  • report message

CALL METHOD l_message_manager->report_t100_message

EXPORTING

msgid = msgid

msgno = msgnr

msgty = msgty.

ENDIF.

endmethod.

Edited by: suryajoshi on Jan 13, 2011 5:04 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

First of all the post is not readable. Please do a preview before you post.

I think you have copied the coding from SIOS package. i see some assert statements checking sios.

Probably you do not have the DATAS attribute in your node.

You can follow the SIOS and you can create a simple document by yourself . You need a attribute of type xstring.

bind this attribute to the officecontrol dataSource property.

Former Member
0 Kudos

Thanks for your reply.

I have defined DATAS attribute as XSTRING. You are right i am using SIOS code from WDMODIFY.

I am getting exception at this line: Please advice. Its seems that factory is not been recognize. I double check , factory is present in attributes Tabs of the View.

  • get the IOS interface

wd_this->factory ?= office->_method_handler.

ASSERT ID sios_demo CONDITION wd_this->factory IS BOUND.

Answers (0)