Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Send It to Html with header

Former Member
0 Likes
2,300

Hi,

i use the fm WWW_ITAB_TO_HTML to send internal table to html ,

the problem is that i dont get the header i now that there is Fm:

WWW_ITAB_TO_HTML_HEADERS that i put there the header , but i saw the documentation of the fm and i have to send every Colman name manually there is a way to do it dynamic ?

Regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,728

HI Arona,

thanks for yuor Replay,

my problem is how to add the Header of the colman to HTML,

in your program it move only the body of the table i need the colman name to .

i need it for sending mail with internal table at the end .

Thanks,

Ferry

Hi,

i use the fm WWW_ITAB_TO_HTML to send internal table to html ,

the problem is that i dont get the header i now that there is Fm:

WWW_ITAB_TO_HTML_HEADERS that i put there the header , but i saw the documentation of the fm and i have to send every Colman name manually there is a way to do it dynamic ?

Regards

8 REPLIES 8
Read only

Former Member
0 Likes
1,728

HI Friends,

Any idea?

Regards

Read only

Former Member
0 Likes
1,728

Hi Ferry ,

Take a look the below code that Jose send to me maybe it helps .

Regards

DATA: send_request  TYPE REF TO cl_bcs,
      document      TYPE REF TO cl_document_bcs,
      recipient     TYPE REF TO cl_cam_address_bcs,
      bcs_exception TYPE REF TO cx_bcs,
      sent_to_all   TYPE os_boolean,
      lt_tab        TYPE TABLE OF makt,
      lt_fields     TYPE TABLE OF w3fields,
      lt_html       TYPE TABLE OF w3html.
 
PARAMETER mailid TYPE adr6-smtp_addr.
 
SELECT * FROM makt UP TO 10 ROWS INTO TABLE lt_tab WHERE spras = 'E'.
 
CALL FUNCTION 'WWW_ITAB_TO_HTML'
  TABLES
    html   = lt_html[]
    fields = lt_fields
    itable = lt_tab.
 
TRY.
    send_request = cl_bcs=>create_persistent( ).
    document = cl_document_bcs=>create_document(  i_type    = 'HTM'
                                                  i_text    = lt_html
                                                  i_subject = 'Table' ).
    send_request->set_document( document ).
    recipient = cl_cam_address_bcs=>create_internet_address( mailid ).
    send_request->add_recipient( EXPORTING i_recipient = recipient
                                           i_express   = 'X' ).
    send_request->set_send_immediately( 'X' ).
    send_request->send( EXPORTING i_with_error_screen = 'X'
                        RECEIVING result              = sent_to_all ).
    COMMIT WORK.
 
  CATCH cx_bcs INTO bcs_exception.
    EXIT.
ENDTRY.

Read only

Former Member
0 Likes
1,729

HI Arona,

thanks for yuor Replay,

my problem is how to add the Header of the colman to HTML,

in your program it move only the body of the table i need the colman name to .

i need it for sending mail with internal table at the end .

Thanks,

Ferry

Read only

0 Likes
1,728

Hi Ferry,

It appears to me that these Func modules are bit simillar to our

ALV FMs. We have to pass 1) a data table and 2) Either a header table (like our field catalog) or a DDIC structure name.

In our internal table the no of fields is going to be constant( unless u use a dynamic int table ). So we can build the header

manually as we do for field catalog table in ALV.

btw are u using a dynamic internal table??

Cheers,

Jose.

Read only

0 Likes
1,728

Hi Josh,

Thanks for Replay!

Yes i want to use dynmic internal table .

Regards

Read only

0 Likes
1,728

Hi Ferry,

See the below example...

Here i hav used a dynamic int table ( u can specify any DB table and any two of its fields as parameters )

and used the same code (as in the other thread).

Now first 10 records(only the two specified fields) of the specified DB table is sent as mail.

TYPE-POOLS abap.

PARAMETERS : table  TYPE tabname   DEFAULT 'MAKT' ,
             field1 TYPE fieldname DEFAULT 'MATNR',
             field2 TYPE fieldname DEFAULT 'MAKTX',
             mailto TYPE adr6-smtp_addr.

DATA : lt_comp_tab    TYPE abap_component_tab WITH HEADER LINE,
       tab_ref        TYPE REF TO data,
       line_ref       TYPE REF TO data,
       line_type      TYPE REF TO cl_abap_structdescr,
       tab_type       TYPE REF TO cl_abap_tabledescr,
       data_describer TYPE REF TO cl_abap_datadescr.

DATA: lo_send_request TYPE REF TO cl_bcs,
      lo_document      TYPE REF TO cl_document_bcs,
      lo_recipient     TYPE REF TO cl_cam_address_bcs,
      lo_exception     TYPE REF TO cx_bcs,
      lv_sent_to_all   TYPE os_boolean,
      lt_fields        TYPE TABLE OF w3fields WITH HEADER LINE,
      lt_header        TYPE TABLE OF w3head   WITH HEADER LINE,
      lt_html          TYPE TABLE OF w3html   WITH HEADER LINE,
      ls_tab_header    TYPE w3head.

FIELD-SYMBOLS : <table> TYPE table,
                <line>  TYPE ANY,
                <field> TYPE ANY.

lt_comp_tab-name =  field1.
lt_comp_tab-type ?= cl_abap_datadescr=>describe_by_data( field1 ).
APPEND lt_comp_tab.

lt_comp_tab-name =  field2.
lt_comp_tab-type ?= cl_abap_datadescr=>describe_by_data( field2 ).
APPEND lt_comp_tab.

line_type ?= cl_abap_structdescr=>create( lt_comp_tab[] ).
tab_type  ?= cl_abap_tabledescr=>create( line_type ).

CREATE DATA : tab_ref  TYPE HANDLE tab_type,
              line_ref TYPE HANDLE line_type.

ASSIGN tab_ref->*  TO <table>.
ASSIGN line_ref->* TO <line>.

SELECT * FROM (table) INTO CORRESPONDING FIELDS OF TABLE <table> UP TO 10 ROWS.

MOVE 'Genetated List' TO ls_tab_header-text.
MOVE 'Arial'          TO ls_tab_header-font.
MOVE '2'              TO ls_tab_header-size.

LOOP AT lt_comp_tab.
  MOVE lt_comp_tab-name TO lt_header-text.
  SELECT SINGLE reptext FROM dd04t INTO lt_header-text WHERE rollname   = lt_header-text
                                                         AND ddlanguage = sy-langu.
  MOVE : sy-tabix         TO lt_header-nr,
         'orange'         TO lt_header-bg_color.
  APPEND lt_header.
ENDLOOP.

CALL FUNCTION 'WWW_ITAB_TO_HTML'
  EXPORTING
    table_header = ls_tab_header
  TABLES
    html         = lt_html[]
    fields       = lt_fields[]
    row_header   = lt_header[]
    itable       = <table>.

TRY.
    lo_send_request = cl_bcs=>create_persistent( ).
    lo_document = cl_document_bcs=>create_document( i_type    = 'HTM'
                                                    i_text    = lt_html[]
                                                    i_subject = 'Table' ).
    lo_send_request->set_document( lo_document ).
    lo_recipient = cl_cam_address_bcs=>create_internet_address( mailto ).
    lo_send_request->add_recipient( EXPORTING i_recipient = lo_recipient
                                              i_express   = 'X' ).
    lo_send_request->set_send_immediately( 'X' ).
    lv_sent_to_all = lo_send_request->send( 'X' ).
    COMMIT WORK.

  CATCH cx_bcs INTO lo_exception.
    EXIT.
ENDTRY.

Cheers,

Jose.

Read only

0 Likes
1,728

Hi Josh,

Thanks a lot!!!

Thanks for your patience You Are amazing ,

Plz write the same solution in abap objects so i can close the post .

Thanks again

Best Regards

Read only

former_member194669
Active Contributor
0 Likes
1,728

Try this way


 " get for fields for your itab
  i_ref_descr ?= cl_abap_typedescr=>describe_by_data( ITAB ).
  i_details[] = i_ref_descr->components[].

  data : v_head TYPE w3head.

  loop at i_details into wa_details.
     select single * from dd04t into wa_dd04t
            where rollname = wa_details-name.
     if sy-subrc eq 0.
       v_head-text = wa_dd04t-SCRTEXT_M.

*-Fill Column Headings

    CALL FUNCTION 'WWW_ITAB_TO_HTML_HEADERS'
      EXPORTING
        field_nr = sy-tabix
        text     = v_head-text
      TABLES
        header   = t_colhdr.
     endif. 
  endloop.


  CALL FUNCTION 'WWW_ITAB_TO_HTML'
    EXPORTING
      table_header = wa_header
    TABLES
      html         = i_html
      fields       = i_fields
      row_header   = i_colhdr
      itable       = i_output.