cancel
Showing results for 
Search instead for 
Did you mean: 

How to show pdf

Former Member
0 Kudos

Hi,

I want to show a pdf which is located in the mime repository. I got this error: Access via 'NULL' object reference not possible.

These things I did:

1. I created a context node 'PDF' with attribute 'PDF_SOURCE'. The attribute has the Type XSTRING and as Default Value I deposit test.pdf

2. Then I created an Interactive Form element in the layout and bind the dataSource to the node and the pdfSource to the attribute.

Has anybody an idea what I did wrong?

Regards, Susanne

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

> created a context node 'PDF' with attribute 'PDF_SOURCE'. The attribute has the Type XSTRING and as Default Value I deposit test.pdf

What do you mean you deposited test.pdf in the default value? Did you only supply the name of the file or the actual binary content? I have feeling you supplied the name, as it would be difficult to type in the binary content in the default value.

If that is the case, you misunderstand how this property works. The attribute is type XSTRING because it expects the entire binary content of the PDF document you want to display, not just the name of the file. It doesn't lookup and read the file content for you. Your application logic must do that step.

Former Member
0 Kudos

Yes, I think this is the problem. I need the binary content. But how can I read the pdf in the mime repository to get the content binary? I looked on help.sap.com > Mime repository but I couldn't find something. Do you have a sample? Sorry I am not so close to ABAP and web dynpro.

Thanks, Susanne

Edited by: Susanne Steib on Oct 9, 2008 10:49 AM

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

There is a Mime API Class: IF_MR_API. Here is an example:

data lr_mime_rep type ref to if_mr_api,
                mv_products_xml type xstring.
  constants lc_custom_path type string
                           value 'SAP/PUBLIC/BC/NWDEMO_MODEL/Products_custom.xml'.

  lr_mime_rep = cl_mime_repository_api=>if_mr_api~get_api( ).

  call method lr_mime_rep->get
    exporting
      i_url     = lc_custom_path
    importing
      e_content = mv_products_xml
    exceptions
      not_found = 3.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello,

Usually people get this error bcoz, somewhere they might had forgot to get the instance of class or path of the context node.

Like below:

lo_nd_items = wd_context->path_get_node( path = `ITEMS` ).

and without putting above piece of code , if u try to access the node then it obviously throws this error "Access via 'NULL' object reference not possible". ..

Just check your code once!

Cheers,

Bharath