Skip to Content

Recently I saw some requests to send some graphics in mail attachments.

I look around and as far as I know (Which is questionable….) I did not found any built in support in SAP

(Please correct me if I am wrong) .

The ingredients:

– SVG technology – http://en.wikipedia.org/wiki/Scalable_Vector_Graphics 
– cl_document_bcs – To send mail .

– cl_ixml – To create SVG documents which are ( surprise surprise !!! ) an XML documents .

– Some reading in http://www.w3schools.com .

The program included (Y_R_EITAN_TEST_10_05) send a mail message with SVG attachments .

SVG give us the capability to create (using code) geometric primitives and use them to compose some very nice stuff..(e.g. http://upload.wikimedia.org/wikipedia/commons/2/28/Beetle.svg)

The multi rectangles in “HTML5 inline SVG (2).HTM” is the result of a loop.

Tips: There are some open and free open source tools to create SVG files so using those can make life a little bit easier.

/wp-content/uploads/2014/04/screenshot_01_439673.png

/wp-content/uploads/2014/04/screenshot_01_439673.png

/wp-content/uploads/2014/04/screenshot_03_439676.png

/wp-content/uploads/2014/04/screenshot_02_439678.png

To report this post you need to login first.

12 Comments

You must be Logged on to comment or reply to a post.

  1. Abhishek Tripathi

    Hello,

    The program is getting dumped in my system. Could you please provide both the files as a attachment in this document ? So that i can make it clear what is actually the basic difference between svg and inline svg ?

    Will SVG viewer plugin still be required after converting the current svg code to inline svg html5 ?

    Best Regards,

    Abhishek

    (0) 
    1. Eitan Rosenberg Post author

      Hi,

      – Can you post the dump.

      – The files are displayed using Internet Explorer 9 which have support to SVG out of the box .

      – The files contents:

      HTML5 inline SVG.HTM

      <!DOCTYPE html><html><body><p>This is html5 page with embeded SVG </p><svg xmlns=”http://www.w3.org/2000/svg” width=”600″ height=”600″>
      <rect x=”0 ” y=”0 ” width=”100.00%” height=”100.00%” stroke=”black” stroke-width=”2″ fill=”rgb(208,034,231)”/>
      <rect x=”12 ” y=”12 ” width=”98.00%” height=”98.00%” stroke=”black” stroke-width=”2″ fill=”rgb(213,032,248)”/>
      <rect x=”24 ” y=”24 ” width=”96.00%” height=”96.00%” stroke=”black” stroke-width=”2″ fill=”rgb(233,056,161)”/>
      <rect x=”36 ” y=”36 ” width=”94.00%” height=”94.00%” stroke=”black” stroke-width=”2″ fill=”rgb(078,024,140)”/>
      <rect x=”48 ” y=”48 ” width=”92.00%” height=”92.00%” stroke=”black” stroke-width=”2″ fill=”rgb(071,048,140)”/>
      <rect x=”60 ” y=”60 ” width=”90.00%” height=”90.00%” stroke=”black” stroke-width=”2″ fill=”rgb(254,245,255)”/>
      <rect x=”72 ” y=”72 ” width=”88.00%” height=”88.00%” stroke=”black” stroke-width=”2″ fill=”rgb(247,247,040)”/>
      <rect x=”84 ” y=”84 ” width=”86.00%” height=”86.00%” stroke=”black” stroke-width=”2″ fill=”rgb(185,248,251)”/>
      <rect x=”96 ” y=”96 ” width=”84.00%” height=”84.00%” stroke=”black” stroke-width=”2″ fill=”rgb(245,028,124)”/>
      <rect x=”108 ” y=”108 ” width=”82.00%” height=”82.00%” stroke=”black” stroke-width=”2″ fill=”rgb(204,204,076)”/>
      <rect x=”120 ” y=”120 ” width=”80.00%” height=”80.00%” stroke=”black” stroke-width=”2″ fill=”rgb(036,001,107)”/>
      <rect x=”132 ” y=”132 ” width=”78.00%” height=”78.00%” stroke=”black” stroke-width=”2″ fill=”rgb(028,234,163)”/>
      <rect x=”144 ” y=”144 ” width=”76.00%” height=”76.00%” stroke=”black” stroke-width=”2″ fill=”rgb(202,224,245)”/>
      <rect x=”156 ” y=”156 ” width=”74.00%” height=”74.00%” stroke=”black” stroke-width=”2″ fill=”rgb(128,167,204)”/>
      <rect x=”168 ” y=”168 ” width=”72.00%” height=”72.00%” stroke=”black” stroke-width=”2″ fill=”rgb(009,092,217)”/>
      <rect x=”180 ” y=”180 ” width=”70.00%” height=”70.00%” stroke=”black” stroke-width=”2″ fill=”rgb(054,239,174)”/>
      <rect x=”192 ” y=”192 ” width=”68.00%” height=”68.00%” stroke=”black” stroke-width=”2″ fill=”rgb(173,102,193)”/>
      <rect x=”204 ” y=”204 ” width=”66.00%” height=”66.00%” stroke=”black” stroke-width=”2″ fill=”rgb(189,190,121)”/>
      <rect x=”216 ” y=”216 ” width=”64.00%” height=”64.00%” stroke=”black” stroke-width=”2″ fill=”rgb(100,108,167)”/>
      <rect x=”228 ” y=”228 ” width=”62.00%” height=”62.00%” stroke=”black” stroke-width=”2″ fill=”rgb(044,043,077)”/>
      <rect x=”240 ” y=”240 ” width=”60.00%” height=”60.00%” stroke=”black” stroke-width=”2″ fill=”rgb(180,204,008)”/>
      <rect x=”252 ” y=”252 ” width=”58.00%” height=”58.00%” stroke=”black” stroke-width=”2″ fill=”rgb(081,070,223)”/>
      <rect x=”264 ” y=”264 ” width=”56.00%” height=”56.00%” stroke=”black” stroke-width=”2″ fill=”rgb(011,038,024)”/>
      <rect x=”276 ” y=”276 ” width=”54.00%” height=”54.00%” stroke=”black” stroke-width=”2″ fill=”rgb(254,210,210)”/>
      <rect x=”288 ” y=”288 ” width=”52.00%” height=”52.00%” stroke=”black” stroke-width=”2″ fill=”rgb(177,032,081)”/>
      <rect x=”300 ” y=”300 ” width=”50.00%” height=”50.00%” stroke=”black” stroke-width=”2″ fill=”rgb(195,243,125)”/>
      <rect x=”312 ” y=”312 ” width=”48.00%” height=”48.00%” stroke=”black” stroke-width=”2″ fill=”rgb(008,169,112)”/>
      <rect x=”324 ” y=”324 ” width=”46.00%” height=”46.00%” stroke=”black” stroke-width=”2″ fill=”rgb(032,097,053)”/>
      <rect x=”336 ” y=”336 ” width=”44.00%” height=”44.00%” stroke=”black” stroke-width=”2″ fill=”rgb(195,013,203)”/>
      <rect x=”348 ” y=”348 ” width=”42.00%” height=”42.00%” stroke=”black” stroke-width=”2″ fill=”rgb(009,047,104)”/>
      <rect x=”360 ” y=”360 ” width=”40.00%” height=”40.00%” stroke=”black” stroke-width=”2″ fill=”rgb(125,117,114)”/>
      <rect x=”372 ” y=”372 ” width=”38.00%” height=”38.00%” stroke=”black” stroke-width=”2″ fill=”rgb(124,165,203)”/>
      <rect x=”384 ” y=”384 ” width=”36.00%” height=”36.00%” stroke=”black” stroke-width=”2″ fill=”rgb(181,235,193)”/>
      <rect x=”396 ” y=”396 ” width=”34.00%” height=”34.00%” stroke=”black” stroke-width=”2″ fill=”rgb(206,070,180)”/>
      <rect x=”408 ” y=”408 ” width=”32.00%” height=”32.00%” stroke=”black” stroke-width=”2″ fill=”rgb(174,000,167)”/>
      <rect x=”420 ” y=”420 ” width=”30.00%” height=”30.00%” stroke=”black” stroke-width=”2″ fill=”rgb(181,041,164)”/>
      <rect x=”432 ” y=”432 ” width=”28.00%” height=”28.00%” stroke=”black” stroke-width=”2″ fill=”rgb(030,116,127)”/>
      <rect x=”444 ” y=”444 ” width=”26.00%” height=”26.00%” stroke=”black” stroke-width=”2″ fill=”rgb(198,245,146)”/>
      <rect x=”456 ” y=”456 ” width=”24.00%” height=”24.00%” stroke=”black” stroke-width=”2″ fill=”rgb(087,224,149)”/>
      <rect x=”468 ” y=”468 ” width=”22.00%” height=”22.00%” stroke=”black” stroke-width=”2″ fill=”rgb(206,057,004)”/>
      <rect x=”480 ” y=”480 ” width=”20.00%” height=”20.00%” stroke=”black” stroke-width=”2″ fill=”rgb(192,210,065)”/>
      <rect x=”492 ” y=”492 ” width=”18.00%” height=”18.00%” stroke=”black” stroke-width=”2″ fill=”rgb(210,129,240)”/>
      <rect x=”504 ” y=”504 ” width=”16.00%” height=”16.00%” stroke=”black” stroke-width=”2″ fill=”rgb(178,105,228)”/>
      <rect x=”516 ” y=”516 ” width=”14.00%” height=”14.00%” stroke=”black” stroke-width=”2″ fill=”rgb(108,245,148)”/>
      <rect x=”528 ” y=”528 ” width=”12.00%” height=”12.00%” stroke=”black” stroke-width=”2″ fill=”rgb(140,040,035)”/>
      <rect x=”540 ” y=”540 ” width=”10.00%” height=”10.00%” stroke=”black” stroke-width=”2″ fill=”rgb(195,038,058)”/>
      <rect x=”552 ” y=”552 ” width=” 8.00%” height=” 8.00%” stroke=”black” stroke-width=”2″ fill=”rgb(065,207,215)”/>
      <rect x=”564 ” y=”564 ” width=” 6.00%” height=” 6.00%” stroke=”black” stroke-width=”2″ fill=”rgb(253,065,085)”/>
      <rect x=”576 ” y=”576 ” width=” 4.00%” height=” 4.00%” stroke=”black” stroke-width=”2″ fill=”rgb(208,076,062)”/>
      <rect x=”588 ” y=”588 ” width=” 2.00%” height=” 2.00%” stroke=”black” stroke-width=”2″ fill=”rgb(003,237,055)”/>
      </svg>
      </html></body>

      Stand alone SVG.svg

      <?xml version=”1.0″?>
      <!DOCTYPE svg PUBLIC “-//W3C//DTD SVG 1.0//EN” “http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd“>

      <svg xmlns=”http://www.w3.org/2000/svg” width=”300″ height=”300″>
      <circle cx=”150″ cy=”150″ r=”100″ stroke=”green” stroke-width=”4″ fill=”yellow”/>
      </svg>

      Regards.

      (0) 
      1. Abhishek Tripathi

        Hello Eitan,

        The dump is mentioned below:

        Runtime Errors         UNCAUGHT_EXCEPTION

        Except.                CX_BCS

        Date and Time          07/09/2014 10:50:51

        Short text

             An exception occurred that was not caught.

        What happened?

             The exception ‘CX_BCS’ was raised, but it was not caught anywhere along

             the call hierarchy.

             Since exceptions represent error situations and this error was not

             adequately responded to, the running ABAP program

              ‘CL_BCS_CONVERT================CP’ has to be

             terminated.

        What can you do?

             Note down which actions and inputs caused the error.

             To process the problem further, contact you SAP system

             administrator.

             Using Transaction ST22 for ABAP Dump Analysis, you can look

             at and manage termination messages, and you can also

             keep them for a long time.

        Error analysis

             An exception occurred that is explained in detail below.

             The exception, which is assigned to class ‘CX_BCS’, was not caught in

             procedure “GET_SVGI_2” “(FORM)”, nor was it propagated by a RAISING clause.

             Since the caller of the procedure could not have anticipated that the

             exception would occur, the current program is terminated.

        I need help in understanding the diffrence between svg and inline svg html5 like:

        – will inline svg html5 will also require svg viewer plugin ?

        – can you please provide a sample svg code which has been converted to inline 5(with the same example so that i can understand the coding difference) ?

        Thanks for your help.

        Best Regards

        (0) 
  2. Eitan Rosenberg Post author

    Try this

    1. REPORT  y_r_eitan_test_10_05 .
    2. TYPE-POOLS: abap .
    3. DATA: adsmtp TYPE adsmtp  .
    4. SELECTION-SCREEN BEGIN OF BLOCK block04 WITH FRAME .
    5. SELECT-OPTIONS: s_rcpn FOR adsmtp-smtp_addr OBLIGATORY NO INTERVALS .
    6. PARAMETERS: p_sbjct TYPE so_obj_des .
    7. SELECTION-SCREEN END OF BLOCK block04 .
    8. *———————————————————————-*
    9. *———————————————————————-*
    10. INITIALIZATION.
    11.   PERFORM at_initialization .
    12. AT SELECTION-SCREEN .
    13.   PERFORM at_selection_screen_input .
    14. *———————————————————————-*
    15. *———————————————————————-*
    16. FORM at_initialization .
    17.   DATA: st_address TYPE bapiaddr3 .
    18.   DATA: it_return TYPE bapirettab .
    19.   CALL FUNCTION ‘BAPI_USER_GET_DETAIL’
    20.     EXPORTING
    21.       username = sy-uname
    22.     IMPORTING
    23.       address  = st_address
    24.     TABLES
    25.       return   = it_return.
    26.   CONCATENATE ‘IEQ’ st_address-e_mail INTO s_rcpn .
    27.   APPEND s_rcpn .
    28.   CONCATENATE ‘Hi there-‘ sy-datum ‘-‘ sy-uzeit INTO p_sbjct .
    29. ENDFORM .                    “at_initialization
    30. *———————————————————————-*
    31. *———————————————————————-*
    32. FORM at_selection_screen_input .
    33. * only for “execute” or “execute and print”
    34.   CHECK ‘ONLI PRIN ‘ CS sy-ucomm .
    35.   PERFORM mail_1_main .
    36. ENDFORM .                    “at_selection_screen_input
    37. *———————————————————————-*
    38. FORM get_rgbc_1
    39.   CHANGING
    40.     string TYPE string .
    41.   DATA: color TYPE c LENGTH 32 .
    42.   STATICS: ob_abap_random TYPE REF TO cl_abap_random_int .
    43.   IF  ob_abap_random IS INITIAL .
    44.     ob_abap_random = cl_abap_random_int=>create( min = 0 max = 255 ) .
    45.   ENDIF .
    46. * Get RGB color rgb(0,0,255)
    47. * Just a showoff…
    48.   DATA: field_x TYPE i .
    49.   DATA: field_c TYPE n LENGTH 3  .
    50.   DATA: rnd_value TYPE datatype-integer4 .
    51.   CLEAR color .
    52.   DO 3 TIMES .
    53.     field_x = ob_abap_random->get_next( ) . .
    54.     field_c = field_x .
    55.     CONCATENATE color field_c INTO color .
    56.     CASE sy-index .
    57.       WHEN 1 OR 2 .
    58.         CONCATENATE color ‘,’ INTO color .
    59.     ENDCASE.
    60.   ENDDO .
    61.   CONCATENATE ‘rgb(‘ color ‘)’ INTO color .
    62.   string = color .
    63. ENDFORM .                                                   “get_rgbc_1
    64. *———————————————————————-*
    65. FORM get_body_1
    66.   CHANGING
    67.     it_soli TYPE soli_tab .
    68.   CLEAR it_soli .
    69.   DATA: it_string TYPE TABLE OF string  .
    70.   APPEND ‘<font color=red size=+4>Please check the SVG attachments</font><br>’ TO it_string .
    71.   APPEND ‘<BR>’ TO it_string .
    72.   FIELD-SYMBOLS: <st_string> LIKE LINE OF it_string  .
    73.   DATA: big_string TYPE string .
    74.   LOOP AT it_string ASSIGNING <st_string>  .
    75.     CONCATENATE big_string <st_string> INTO big_string .
    76.   ENDLOOP.
    77.   CALL METHOD cl_bcs_convert=>string_to_soli
    78.     EXPORTING
    79.       iv_string = big_string
    80.     RECEIVING
    81.       et_soli   = it_soli.
    82. ENDFORM .                                                   “get_body_1
    83. *———————————————————————-*
    84. FORM get_svgi_1
    85.   CHANGING
    86.     it_solix TYPE solix_tab .
    87.   CLEAR: it_solix[] .
    88.   DATA: ob_ixml               TYPE REF TO if_ixml .
    89.   DATA: ob_ixml_document      TYPE REF TO if_ixml_document ,
    90.         ob_ixml_encoding      TYPE REF TO if_ixml_encoding ,
    91.         ob_ixml_document_type TYPE REF TO if_ixml_document_type .
    92.   ob_ixml = cl_ixml=>create( ).
    93.   ob_ixml_document = ob_ixml->create_document( ).
    94.   ob_ixml_document->set_standalone( standalone = abap_false ) .
    95.   ob_ixml_document->set_declaration( declaration = abap_true ) .
    96.   ob_ixml_document_type = ob_ixml_document->create_document_type( name = ‘svg’ ) .
    97.   ob_ixml_document_type->set_public_id( ‘-//W3C//DTD SVG 1.0//EN’ ) .
    98.   ob_ixml_document_type->set_system_id( ‘http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd‘ ) .
    99.   ob_ixml_document->set_document_type( ob_ixml_document_type ) .
    100.   DATA: ob_root  TYPE REF TO if_ixml_element .
    101.   ob_root = ob_ixml_document->create_simple_element(
    102.             name = ‘svg’ parent = ob_ixml_document ) .
    103.   ob_root->set_attribute( name = ‘xmlns’  value = ‘http://www.w3.org/2000/svg‘ ) .
    104.   ob_root->set_attribute( name = ‘width’  value = ‘300’ ) .
    105.   ob_root->set_attribute( name = ‘height’ value = ‘300’ ) .
    106.   DATA: ob_element TYPE REF TO if_ixml_element .
    107.   ob_element = ob_ixml_document->create_simple_element(
    108.                name = ‘circle’ parent = ob_root ) .
    109.   ob_element->set_attribute( name = ‘cx’ value = ‘150’ ) .
    110.   ob_element->set_attribute( name = ‘cy’ value = ‘150’ ) .
    111.   ob_element->set_attribute( name = ‘r’  value = ‘100’ ) .
    112.   ob_element->set_attribute( name = ‘stroke’ value = ‘green’ ) .
    113.   ob_element->set_attribute( name = ‘stroke-width’ value = ‘4’ ) .
    114.   ob_element->set_attribute( name = ‘fill’ value = ‘yellow’ ) .
    115.   DATA: ob_ixml_stream_factory TYPE REF TO if_ixml_stream_factory.
    116.   DATA: ob_ostream  TYPE REF TO if_ixml_ostream .
    117.   DATA: ob_renderer TYPE REF TO if_ixml_renderer .
    118.   DATA: xstring TYPE xstring.
    119.   ob_ixml_stream_factory = ob_ixml->create_stream_factory( ).
    120.   ob_ostream = ob_ixml_stream_factory->create_ostream_xstring( string = xstring ) .
    121.   ob_ostream->set_pretty_print( pretty_print = abap_true ).
    122.   ob_renderer = ob_ixml->create_renderer( document = ob_ixml_document ostream  = ob_ostream ) .
    123.   ob_renderer->render( ).
    124.   CALL METHOD cl_bcs_convert=>xstring_to_solix
    125.     EXPORTING
    126.       iv_xstring = xstring
    127.     RECEIVING
    128.       et_solix   = it_solix.
    129. ENDFORM .                                                   “get_svgi_1
    130. *———————————————————————-*
    131. FORM get_svgi_2
    132.   CHANGING
    133.     it_solix TYPE solix_tab .
    134. * Embeded SVG
    135.   CLEAR: it_solix[] .
    136.   DATA: it_string TYPE TABLE OF string  .
    137.   APPEND ‘<!DOCTYPE html>’ TO it_string .
    138.   APPEND ‘<html>’ TO it_string .
    139.   APPEND ‘<body>’ TO it_string .
    140.   APPEND ‘<p>This is html5 page with embeded SVG </p>’ TO it_string .
    141.   DATA: ob_ixml               TYPE REF TO if_ixml .
    142.   DATA: ob_ixml_document      TYPE REF TO if_ixml_document ,
    143.         ob_ixml_encoding      TYPE REF TO if_ixml_encoding ,
    144.         ob_ixml_document_type TYPE REF TO if_ixml_document_type .
    145.   ob_ixml = cl_ixml=>create( ).
    146.   ob_ixml_document = ob_ixml->create_document( ).
    147. *  ob_ixml_document->set_standalone( standalone = abap_false ) .
    148.   ob_ixml_document->set_declaration( declaration = abap_false ) .
    149. *  ob_ixml_document_type = ob_ixml_document->create_document_type( name = ‘svg’ ) .
    150. *  ob_ixml_document_type->set_public_id( ‘-//W3C//DTD SVG 1.0//EN’ ) .
    151. *  ob_ixml_document_type->set_system_id( ‘http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd‘ ) .
    152. *  ob_ixml_document->set_document_type( ob_ixml_document_type ) .
    153.   DATA: ob_root  TYPE REF TO if_ixml_element .
    154.   ob_root = ob_ixml_document->create_simple_element(
    155.             name = ‘svg’ parent = ob_ixml_document ) .
    156.   ob_root->set_attribute( name = ‘xmlns’  value = ‘http://www.w3.org/2000/svg‘ ) .
    157.   ob_root->set_attribute( name = ‘width’  value = ‘600’ ) .
    158.   ob_root->set_attribute( name = ‘height’ value = ‘600’ ) .
    159.   DATA: ob_element TYPE REF TO if_ixml_element .
    160.   DATA: index_i TYPE i .
    161.   DATA: value_n TYPE n LENGTH 5 .
    162.   DATA: value_c TYPE c LENGTH 6 .
    163.   DATA: value_p TYPE p DECIMALS 2 .
    164.   DATA: value_s TYPE string .
    165.   DATA: value_i TYPE i .
    166.   DATA: loops TYPE i VALUE 50 .
    167.   DO loops TIMES .
    168.     ob_element = ob_ixml_document->create_simple_element(
    169.               name = ‘rect’ parent = ob_root ) .
    170.     value_i = 600 / loops * index_i .
    171.     value_s = value_i .
    172.     ob_element->set_attribute( name = ‘x’ value = value_s ) .
    173.     ob_element->set_attribute( name = ‘y’ value = value_s ) .
    174.     value_p = 100 – ( index_i / loops * 100 ) .
    175.     value_c = value_p .
    176.     CONCATENATE value_c ‘%’ INTO value_s .
    177.     ob_element->set_attribute( name = ‘width’ value = value_s ) .
    178.     ob_element->set_attribute( name = ‘height’ value = value_s ) .
    179.     ob_element->set_attribute( name = ‘stroke’ value = ‘black’ ) .
    180.     ob_element->set_attribute( name = ‘stroke-width’ value = ‘2’ ) .
    181.     DATA: color TYPE string .
    182.     PERFORM get_rgbc_1
    183.       CHANGING
    184.         color .
    185.     ob_element->set_attribute( name = ‘fill’ value = color ) .
    186.     index_i =  index_i + 1 .
    187.   ENDDO .
    188.   DATA: ob_ixml_stream_factory TYPE REF TO if_ixml_stream_factory.
    189.   DATA: ob_ostream  TYPE REF TO if_ixml_ostream .
    190.   DATA: ob_renderer TYPE REF TO if_ixml_renderer .
    191.   DATA: xstring TYPE xstring.
    192.   ob_ixml_stream_factory = ob_ixml->create_stream_factory( ).
    193.   ob_ostream = ob_ixml_stream_factory->create_ostream_xstring( string = xstring ) .
    194.   ob_ostream->set_pretty_print( pretty_print = abap_true ).
    195.   ob_renderer = ob_ixml->create_renderer( document = ob_ixml_document ostream  = ob_ostream ) .
    196.   ob_renderer->render( ).
    197.   DATA: string TYPE string.
    198.   PERFORM xstring2string
    199.               USING
    200.                  xstring
    201.               CHANGING
    202.                  string.
    203.   APPEND string TO it_string .
    204.   APPEND ‘</html></body>’ TO it_string .
    205.   DATA: big_string TYPE string .
    206.   FIELD-SYMBOLS: <st_string> LIKE LINE OF it_string  .
    207.   LOOP AT it_string ASSIGNING <st_string>  .
    208.     CONCATENATE big_string <st_string> INTO big_string .
    209.   ENDLOOP.
    210.   CALL METHOD cl_bcs_convert=>string_to_solix
    211.     EXPORTING
    212.       iv_string = big_string
    213.     IMPORTING
    214.       et_solix  = it_solix.
    215. ENDFORM .                                                   “get_svgi_2
    216. *———————————————————————-*
    217. FORM get_svgi_3
    218.   CHANGING
    219.     it_soli TYPE soli_tab .
    220.   CLEAR: it_soli[] .
    221.   DATA: it_string TYPE TABLE OF string  .
    222.   APPEND ‘<!DOCTYPE html>’ TO it_string .
    223.   APPEND ‘<html>’ TO it_string .
    224.   APPEND ‘<body>’ TO it_string .
    225.   APPEND ‘<p>This is html5 page with embeded SVG </p>’ TO it_string .
    226.   DATA: ob_ixml               TYPE REF TO if_ixml .
    227.   DATA: ob_ixml_document      TYPE REF TO if_ixml_document ,
    228.         ob_ixml_encoding      TYPE REF TO if_ixml_encoding ,
    229.         ob_ixml_document_type TYPE REF TO if_ixml_document_type .
    230.   ob_ixml = cl_ixml=>create( ).
    231.   ob_ixml_document = ob_ixml->create_document( ).
    232. *  ob_ixml_document->set_standalone( standalone = abap_false ) .
    233.   ob_ixml_document->set_declaration( declaration = abap_false ) .
    234. *  ob_ixml_document_type = ob_ixml_document->create_document_type( name = ‘svg’ ) .
    235. *  ob_ixml_document_type->set_public_id( ‘-//W3C//DTD SVG 1.0//EN’ ) .
    236. *  ob_ixml_document_type->set_system_id( ‘http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd‘ ) .
    237. *  ob_ixml_document->set_document_type( ob_ixml_document_type ) .
    238.   DATA: ob_root  TYPE REF TO if_ixml_element .
    239.   ob_root = ob_ixml_document->create_simple_element(
    240.             name = ‘svg’ parent = ob_ixml_document ) .
    241.   ob_root->set_attribute( name = ‘xmlns’  value = ‘http://www.w3.org/2000/svg‘ ) .
    242.   ob_root->set_attribute( name = ‘width’  value = ‘600’ ) .
    243.   ob_root->set_attribute( name = ‘height’ value = ‘600’ ) .
    244.   DATA: ob_element TYPE REF TO if_ixml_element .
    245.   DATA: index_i TYPE i .
    246.   DATA: value_n TYPE n LENGTH 5 .
    247.   DATA: value_c TYPE c LENGTH 6 .
    248.   DATA: value_p TYPE p DECIMALS 2 .
    249.   DATA: value_s TYPE string .
    250.   DATA: value_i TYPE i .
    251.   DATA: loops TYPE i VALUE 50 .
    252.   DO loops TIMES .
    253.     ob_element = ob_ixml_document->create_simple_element(
    254.               name = ‘rect’ parent = ob_root ) .
    255.     value_i = 600 / loops * index_i .
    256.     value_s = value_i .
    257.     ob_element->set_attribute( name = ‘x’ value = value_s ) .
    258.     ob_element->set_attribute( name = ‘y’ value = value_s ) .
    259.     value_p = 100 – ( index_i / loops * 100 ) .
    260.     value_c = value_p .
    261.     CONCATENATE value_c ‘%’ INTO value_s .
    262.     ob_element->set_attribute( name = ‘width’ value = value_s ) .
    263.     ob_element->set_attribute( name = ‘height’ value = value_s ) .
    264.     ob_element->set_attribute( name = ‘stroke’ value = ‘black’ ) .
    265.     ob_element->set_attribute( name = ‘stroke-width’ value = ‘2’ ) .
    266.     DATA: color TYPE string .
    267.     PERFORM get_rgbc_1
    268.       CHANGING
    269.         color .
    270.     ob_element->set_attribute( name = ‘fill’ value = color ) .
    271.     index_i =  index_i + 1 .
    272.   ENDDO .
    273.   DATA: ob_ixml_stream_factory TYPE REF TO if_ixml_stream_factory.
    274.   DATA: ob_ostream  TYPE REF TO if_ixml_ostream .
    275.   DATA: ob_renderer TYPE REF TO if_ixml_renderer .
    276.   DATA: cstring TYPE string.
    277.   ob_ixml_stream_factory = ob_ixml->create_stream_factory( ).
    278.   ob_ostream = ob_ixml_stream_factory->create_ostream_cstring( cstring ).
    279.   ob_ostream->set_pretty_print( pretty_print = abap_true ).
    280.   ob_renderer = ob_ixml->create_renderer( document = ob_ixml_document ostream  = ob_ostream ) .
    281.   ob_renderer->render( ).
    282.   APPEND cstring TO it_string .
    283.   APPEND ‘</html></body>’ TO it_string .
    284.   DATA: big_string TYPE string .
    285.   FIELD-SYMBOLS: <st_string> LIKE LINE OF it_string  .
    286.   LOOP AT it_string ASSIGNING <st_string>  .
    287.     CONCATENATE big_string <st_string> INTO big_string .
    288.   ENDLOOP.
    289.   CALL METHOD cl_bcs_convert=>string_to_soli
    290.     EXPORTING
    291.       iv_string = big_string
    292.     RECEIVING
    293.       et_soli   = it_soli.
    294. ENDFORM .                                                   “get_svgi_3
    295. *———————————————————————-*
    296. FORM xstring2string
    297.   USING
    298.     xstring TYPE xstring
    299.   CHANGING
    300.     string TYPE string .
    301.   DATA: ob_abap_conv_in_ce TYPE REF TO cl_abap_conv_in_ce .
    302.   TRY.
    303.       CALL METHOD cl_abap_conv_in_ce=>create
    304.         EXPORTING
    305.           input       = xstring
    306.           replacement = ‘?’
    307.           ignore_cerr = abap_true
    308.         RECEIVING
    309.           conv        = ob_abap_conv_in_ce.
    310.     CATCH cx_parameter_invalid_range .
    311.     CATCH cx_sy_codepage_converter_init .
    312.   ENDTRY.
    313.   TRY.
    314.       CALL METHOD ob_abap_conv_in_ce->read
    315.         IMPORTING
    316.           data = string.
    317.     CATCH cx_sy_conversion_codepage .
    318.     CATCH cx_sy_codepage_converter_init .
    319.     CATCH cx_parameter_invalid_type .
    320.     CATCH cx_parameter_invalid_range .
    321.   ENDTRY.
    322. ENDFORM .                    “Xstring2String
    323. *———————————————————————-*
    324. FORM mail_1_main .
    325.   DATA: sample_text TYPE string .
    326.   DATA: it_soli TYPE soli_tab .
    327.   PERFORM get_body_1
    328.     CHANGING
    329.        it_soli .
    330.   DATA: ob_document_bcs TYPE REF TO cl_document_bcs.
    331.   CALL METHOD cl_document_bcs=>create_document
    332.     EXPORTING
    333.       i_type    = ‘HTM’
    334.       i_subject = p_sbjct
    335.       i_text    = it_soli
    336.     RECEIVING
    337.       result    = ob_document_bcs.
    338.   DATA: attachment_subject TYPE so_obj_des .
    339.   DATA: it_solix TYPE solix_tab .
    340. * Suspend solix
    341.   IF 1 EQ 2 .
    342.     attachment_subject = ‘Stand alone SVG’ .
    343.     PERFORM get_svgi_1
    344.       CHANGING
    345.         it_solix .
    346.     CALL METHOD ob_document_bcs->add_attachment
    347.       EXPORTING
    348.         i_attachment_type    = ‘svg’
    349.         i_attachment_subject = attachment_subject
    350.         i_att_content_hex    = it_solix.
    351.     attachment_subject = ‘HTML5 inline SVG it_solix’ .
    352.     PERFORM get_svgi_2
    353.       CHANGING
    354.         it_solix .
    355.     CALL METHOD ob_document_bcs->add_attachment
    356.       EXPORTING
    357.         i_attachment_type    = ‘HTM’
    358.         i_attachment_subject = attachment_subject
    359.         i_att_content_hex    = it_solix.
    360.   ENDIF .
    361.   attachment_subject = ‘HTML5 inline it_soli’ .
    362.   PERFORM get_svgi_3
    363.       CHANGING
    364.         it_soli .
    365.   CALL METHOD ob_document_bcs->add_attachment
    366.     EXPORTING
    367.       i_attachment_type    = ‘HTM’
    368.       i_attachment_subject = attachment_subject
    369.       i_att_content_text   = it_soli.
    370. *     i_att_content_hex    = it_solix.
    371.   DATA: ob_bcs TYPE        REF TO cl_bcs.
    372.   DATA: ob_sapuser_bcs     TYPE REF TO cl_sapuser_bcs.
    373.   DATA: ob_cam_address_bcs TYPE REF TO cl_cam_address_bcs .
    374.   ob_bcs = cl_bcs=>create_persistent( ).
    375.   CALL METHOD ob_bcs->set_document( ob_document_bcs ).
    376.   ob_sapuser_bcs = cl_sapuser_bcs=>create( sy-uname ).
    377.   CALL METHOD ob_bcs->set_sender
    378.     EXPORTING
    379.       i_sender = ob_sapuser_bcs.
    380.   LOOP AT s_rcpn .
    381.     ob_cam_address_bcs = cl_cam_address_bcs=>create_internet_address( s_rcpn-low ).
    382.     CALL METHOD ob_bcs->add_recipient
    383.       EXPORTING
    384.         i_recipient = ob_cam_address_bcs.
    385.   ENDLOOP.
    386.   DATA: result TYPE abap_bool .
    387.   CALL METHOD ob_bcs->send
    388.     EXPORTING
    389.       i_with_error_screen = abap_true
    390.     RECEIVING
    391.       result              = result.
    392.   COMMIT WORK .
    393. ENDFORM .                    “mail_1_main
    (0) 
    1. Abhishek Tripathi

      Hello Eitan,

      No error but no output too. It didn’t sent any email to email ids i mentioned as input.

      Actually the main requirement of mine is that i need a reference where something has been done with standard svg and then the same has been adapted as inline svg html5 so that i can figure out the differences.

      Best Regards.

      (0) 

Leave a Reply