Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8950

Dump - Access using NULL object reference is not possible!!!

$
0
0

Hi,

 

I'm using the BCS class for sending HTM format email so i use the below code for that its working,

 

DATA: gr_document      TYPE REF TO cl_document_bcs,

gr_document = cl_document_bcs=>create_document(

                      i_type    = 'HTM'
                       i_text    = t_html
                       i_importance = '5'
                       i_subject = gc_subject ).

 

Next task is to send the image so i'm creating an another object to the same class, below code

 

*--------------------------------------------------------------------*
*Image from MIME
*--------------------------------------------------------------------*

DATA: o_mr_api         TYPE REF TO if_mr_api.

DATA is_folder TYPE boole_d.
DATA l_img1 TYPE xstring.
DATA l_img2 TYPE xstring.
DATA l_loio TYPE skwf_io.

DATA: lo_document   TYPE REF TO cl_document_bcs.

IF o_mr_api IS INITIAL.

   o_mr_api = cl_mime_repository_api=>if_mr_api~get_api( ).

ENDIF.
CALL METHOD o_mr_api->get
   EXPORTING
     i_url              = '/SAP/PUBLIC/ZDEMO/tick.png'
   IMPORTING
     e_is_folder        = is_folder
     e_content          = l_img1
     e_loio             = l_loio
   EXCEPTIONS
     parameter_missing  = 1
     error_occured      = 2
     not_found          = 3
     permission_failure = 4
     OTHERS             = 5.

CALL METHOD o_mr_api->get
   EXPORTING
     i_url              = '/SAP/PUBLIC/ZDEMO/Delete.png'
   IMPORTING
     e_is_folder        = is_folder
     e_content          = l_img2
     e_loio             = l_loio
   EXCEPTIONS
     parameter_missing  = 1
     error_occured      = 2
     not_found          = 3
     permission_failure = 4
     OTHERS             = 5.

*Convert XSTRING to ITAB
DATA :lt_hex1 TYPE solix_tab,
       lt_hex2 TYPE solix_tab,
       ls_hex LIKE LINE OF lt_hex1,
       lv_img1_size TYPE sood-objlen,
       lv_img2_size TYPE sood-objlen.

CLEAR : lt_hex1, lt_hex2, ls_hex, lv_img1_size, lv_img2_size.

WHILE l_img1 IS NOT INITIAL.
   ls_hex-line = l_img1.
   APPEND ls_hex TO lt_hex1.
   SHIFT l_img1 LEFT BY 255 PLACES IN BYTE MODE.
ENDWHILE.

WHILE l_img2 IS NOT INITIAL.
   ls_hex-line = l_img2.
   APPEND ls_hex TO lt_hex2.
   SHIFT l_img2 LEFT BY 255 PLACES IN BYTE MODE.
ENDWHILE.

*Findthe Size of the image
DESCRIBE TABLE lt_hex1 LINES lv_img1_size.
DESCRIBE TABLE lt_hex2 LINES lv_img2_size.

lv_img1_size = lv_img1_size * 255.
lv_img2_size = lv_img2_size * 255.

*--------------------------------------------------------------------*
*Attach Images
*--------------------------------------------------------------------*


clear: lo_document.

lo_document->add_attachment(
   EXPORTING
     i_attachment_type     =  'png'                  " Document Class for Attachment
     i_attachment_subject  =  'img1'                " Attachment Title
     i_attachment_size     =  lv_img1_size           " Size of Document Content
     i_att_content_hex     =  lt_hex1  " Content (Binary)
).

lo_document->add_attachment(
   EXPORTING
     i_attachment_type     =  'png'                  " Document Class for Attachment
     i_attachment_subject  =  'img2'                " Attachment Title
     i_attachment_size     =  lv_img2_size           " Size of Document Content
     i_att_content_hex     =  lt_hex2  " Content (Binary)
).

 

but it throws the dump " Access using NULL object reference is not possible"  when i tries to access for method add_attachment...

 

Thanks,

Siva


Viewing all articles
Browse latest Browse all 8950

Trending Articles