SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Mailing from ALV with HTML



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Tue Nov 20, 2007 2:14 pm    Post subject: Mailing from ALV with HTML Reply with quote

Code:
TYPE-POOLS: sdydo.
DATA: do TYPE REF TO cl_dd_document.
DATA: is_displayed.
DATA: v_email_sent TYPE c,
v_attached TYPE c.
DATA: BEGIN OF gt_extab OCCURS 0,
fcode LIKE rsmpe-func,
END OF gt_extab.

TYPES: BEGIN OF t_data,
matnr TYPE matnr,
zzdaycod TYPE zzdaycod,
zzgroes TYPE groes,
zzcsstrttm TYPE zzcsstrttm,
zzcsendtm TYPE zzcsendtm,
zzstkhld TYPE zzstkhld,
END OF t_data,

BEGIN OF t_comp,
field TYPE rollname,
text(30) TYPE c,
END OF t_comp.

DATA: gt_data TYPE STANDARD TABLE OF t_data,
gs_data TYPE t_data,
gt_comp TYPE STANDARD TABLE OF t_comp,
gs_comp TYPE t_comp.


PARAMETERS: p_qmnum LIKE qmel-qmnum OBLIGATORY
DEFAULT '000000402194'.

PARAMETERS: p_mailid(255) TYPE c OBLIGATORY
DEFAULT '[email protected]' LOWER CASE.

SELECT matnr zzdaycod zzgroes zzcsstrttm zzcsendtm zzstkhld
FROM viqmel
INTO TABLE gt_data
WHERE refnum = '402194'.

* Event Handler Definition, handling changes of GUI fonts, colors,...
CLASS cl_my_event_handler DEFINITION.
  PUBLIC SECTION.
    METHODS:
    use_new_resources FOR EVENT resources_changed OF cl_gui_resources.
ENDCLASS. "cl_my_event_handler DEFINITION
DATA: my_handler TYPE REF TO cl_my_event_handler.
CREATE OBJECT my_handler.

* Call Screen
CALL SCREEN 100.

*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'BRP' EXCLUDING gt_extab.
  IF is_displayed IS INITIAL.
    SET HANDLER my_handler->use_new_resources.
* create document
    CREATE OBJECT do.
* fill document
* PERFORM dd_add_text USING do.
    PERFORM zf_dd_add_text USING do.
* merge document
    CALL METHOD do->merge_document.
* display document
    CALL METHOD do->display_document
      EXPORTING
        container          = 'HTML'
      EXCEPTIONS
        html_display_error = 1.
    " do some exception handling ...
    is_displayed = 'X'.
  ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* MODULE user_command_0100 INPUT
*&---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  CASE sy-ucomm.
    WHEN 'BACK'. "Beenden
      LEAVE PROGRAM.
    WHEN 'ATTACH'.
      PERFORM zf_attach_html.
      APPEND 'ATTACH' TO gt_extab.
    WHEN 'EMAIL'.
      PERFORM zf_send_email.
* perform zf_send_email2.
      APPEND 'EMAIL' TO gt_extab.
  ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Form DD_ADD_TEXT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM dd_add_text USING p_do TYPE REF TO cl_dd_document.
  DATA ta TYPE REF TO cl_dd_table_element.
  DATA col1 TYPE REF TO cl_dd_area.
  DATA col2 TYPE REF TO cl_dd_area.

  DATA text TYPE sdydo_text_element.
  DATA text1 TYPE sdydo_text_element.
  DATA text2 TYPE sdydo_text_element.
  DATA text3 TYPE sdydo_text_element.
  DATA texttable TYPE sdydo_text_table.
  DATA buffer(4).
* set Heading
  text = 'Text display in dynamic documents'(001).
  CALL METHOD p_do->add_text
    EXPORTING
      text      = text
      sap_style = 'heading'.
  CALL METHOD p_do->new_line.
  CALL METHOD p_do->new_line.
  text = 'Methods ADD_TEXT, NEW_LINE, UNDERLINE; Rel99'(002).
  CALL METHOD p_do->add_text
    EXPORTING
      text = text.
  CALL METHOD p_do->new_line.
  CALL METHOD p_do->underline.
  CALL METHOD p_do->new_line.

* create table
  CALL METHOD p_do->add_table
    EXPORTING
      no_of_columns               = 2
      cell_background_transparent = space
    IMPORTING
      table                       = ta.
* set columns
  CALL METHOD ta->add_column
    EXPORTING
      width  = '70%'                                        "'30%'
    IMPORTING
      column = col1.
  CALL METHOD ta->add_column
    EXPORTING
      width  = '30%'                                        "70%'
    IMPORTING
      column = col2.
  CALL METHOD ta->set_column_style
    EXPORTING
      col_no    = 1
      sap_color = cl_dd_area=>list_key.
* fill columns
  text = 'Passing a text element - recommended for' &
  'texts that need translation'(003).
  CALL METHOD col1->add_text
    EXPORTING
      text = text.
  CALL METHOD col1->new_line.
  text = '(ADD_TEXT, Parameter: TEXT )'(018).
  CALL METHOD col1->add_text
    EXPORTING
      text = text.
  text = 'Text elem.'(500).
  CALL METHOD col2->add_text
    EXPORTING
      text = text.
  CALL METHOD ta->new_row.
  text = 'Text originates in a field (up to 255 chars)'(004).
  CALL METHOD col1->add_text
    EXPORTING
      text = text.
  CALL METHOD col1->new_line.
  text = '(ADD_TEXT, Parameter: TEXT )'(005).
  CALL METHOD col1->add_text
    EXPORTING
      text = text.
  text =
  '111111111 222222222 333333333 444444444 555555555 ' &
  '666666666 777777777 888888888 999999999 000000000 ' &
  '111111111 222222222 333333333 444444444 555555555 ' &
  '666666666 777777777 888888888 999999999 000000000 ' &
  '111111111 222222222 333333333 444444444 555555555 '.
  CALL METHOD col2->add_text
    EXPORTING
      text = text.

  CALL METHOD ta->new_row.
  text =
  'Text originates in a table and is displayed as continuous text'(007).
  CALL METHOD col1->add_text
    EXPORTING
      text = text.
  CALL METHOD col1->new_line.
  text = '(ADD_TEXT, Parameter: TEXT_TABLE )'(008).
  CALL METHOD col1->add_text
    EXPORTING
      text = text.
  DO 30 TIMES.
    text = 'Text display...'(009).
    buffer = sy-index.
    CONCATENATE text buffer INTO text.
    APPEND text TO texttable.
  ENDDO.
  CALL METHOD col2->add_text
    EXPORTING
      text_table = texttable.

  CALL METHOD ta->new_row.
  text =
  'Text originates in a table and is displayed in lines'(017).
  CALL METHOD col1->add_text
    EXPORTING
      text = text.
  CALL METHOD col1->new_line.
  text = '(ADD_TEXT, Parameter: TEXT_TABLE und FIX_LINES )'(010).
  CALL METHOD col1->add_text
    EXPORTING
      text = text.
  CLEAR texttable.
  DO 10 TIMES.
    text = 'Text display....'(009).
    buffer = sy-index.
    CONCATENATE text buffer INTO text.
    APPEND text TO texttable.
  ENDDO.
  CALL METHOD col2->add_text
    EXPORTING
      text_table = texttable
      fix_lines  = 'X'.

  CALL METHOD ta->new_row.
  text = 'Hard line feed between texts'(011).
  CALL METHOD col1->add_text
    EXPORTING
      text = text.
  CALL METHOD col1->new_line.
  CALL METHOD col1->add_text
    EXPORTING
      text = '(NEW_LINE)'.
  text1 = 'First line ...'(012).
  CALL METHOD col2->add_text
    EXPORTING
      text = text1.
  CALL METHOD col2->new_line.
  text2 = 'Second line ...'(013).
  CALL METHOD col2->add_text
    EXPORTING
      text = text2.
  CALL METHOD col2->new_line.
  text3 = 'Third line ...'(014).
  CALL METHOD col2->add_text
    EXPORTING
      text = text3.

  CALL METHOD ta->new_row.
  text = 'Blank line between texts'(015).
  CALL METHOD col1->add_text
    EXPORTING
      text = text.
  CALL METHOD col1->new_line.
  CALL METHOD col1->add_text
    EXPORTING
      text = '(NEW_LINE)'.
  CALL METHOD col2->add_text
    EXPORTING
      text = text1.
  CALL METHOD col2->new_line
    EXPORTING
      repeat = 1.
  CALL METHOD col2->add_text
    EXPORTING
      text = text2.
  CALL METHOD col2->new_line
    EXPORTING
      repeat = 2.
  CALL METHOD col2->add_text
    EXPORTING
      text = text3.

  CALL METHOD ta->new_row.
  text = 'Underscore between texts'(016).
  CALL METHOD col1->add_text
    EXPORTING
      text = text.
  CALL METHOD col1->new_line.
  CALL METHOD col1->add_text
    EXPORTING
      text = '(UNDERLINE)'.
  CALL METHOD col2->add_text
    EXPORTING
      text = text1.
  CALL METHOD col2->underline.
  CALL METHOD col2->add_text
    EXPORTING
      text = text2.
  CALL METHOD col2->underline.
  CALL METHOD col2->add_text
    EXPORTING
      text = text3.

  CALL METHOD ta->new_row.
  text = 'Space between text output'(019).
  CALL METHOD col1->add_text
    EXPORTING
      text = text.
  CALL METHOD col1->new_line.
  text = '(ADD_GAP, Parameter: WIDTH)'(020).
  CALL METHOD col1->add_text
    EXPORTING
      text = text.
  CALL METHOD col2->add_text
    EXPORTING
      text = text1.
  CALL METHOD col2->add_gap.
  CALL METHOD col2->add_text
    EXPORTING
      text = text1.
  CALL METHOD col2->new_line.
  CALL METHOD col2->add_text
    EXPORTING
      text = text2.
  CALL METHOD col2->add_gap
    EXPORTING
      width = 10.
  CALL METHOD col2->add_text
    EXPORTING
      text = text2.
  CALL METHOD col2->new_line.
  CALL METHOD col2->add_text
    EXPORTING
      text = text3.
  CALL METHOD col2->add_gap
    EXPORTING
      width = 20.
  CALL METHOD col2->add_text
    EXPORTING
      text = text3.
ENDFORM. "dd_add_text

* CLASS cl_my_event_handler IMPLEMENTATION.
CLASS cl_my_event_handler IMPLEMENTATION.
  METHOD use_new_resources.
    IF is_displayed = 'X'.
* initialize document
      CALL METHOD do->initialize_document.
* fill document
      PERFORM dd_add_text USING do.
* merge document
      CALL METHOD do->merge_document.
* display document
      CALL METHOD do->display_document
        EXPORTING
          reuse_control      = 'X'
          reuse_registration = 'X'.
    ENDIF.
  ENDMETHOD. "use_new_resources
ENDCLASS. "cl_my_event_handler IMPLEMENTATION
*&---------------------------------------------------------------------*
*& Form zf_attach_html
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM zf_attach_html.
  DATA: i_files LIKE bapifiles OCCURS 1 WITH HEADER LINE,
  i_signature LIKE bapisignat OCCURS 1 WITH HEADER LINE,
  i_components LIKE bapicompon OCCURS 1 WITH HEADER LINE,
  lv_logsys TYPE tbdls-logsys,
  lv_objectkey TYPE bapibds01-objkey.
  DATA: lt_doc_content1 TYPE
  STANDARD TABLE OF bapiconten WITH HEADER LINE.
  DATA: g_numbytes TYPE i.
  DATA: lt_ascii TYPE STANDARD TABLE OF bapiascont WITH HEADER LINE.
  DATA: v_binary_flag TYPE bapibds01-x.
  DATA: wa_html TYPE w3html.
*
  LOOP AT do->html_table INTO wa_html.
    lt_ascii = wa_html.
    APPEND lt_ascii.
  ENDLOOP.
*
*****Convert lt_ascii into stream format
  DATA: ld_content_string TYPE string.
  DATA: ld_charsize_uc TYPE i. "unicode
  DATA: ld_size TYPE sy-tabix,
  ld_length TYPE i,
  lt_content LIKE bapiascont OCCURS 1,
  ls_content_line LIKE LINE OF lt_content.
  FIELD-SYMBOLS: <ld_html_c> TYPE c. "unicode

  LOOP AT lt_ascii.
    ASSIGN lt_ascii-line TO <ld_html_c> CASTING. "unicode
    CONCATENATE ld_content_string <ld_html_c> "unicode
    INTO ld_content_string. "unicode
  ENDLOOP.
* if ld_charsize_uc <= 1. "unicode
* concatenate '</' gc_tag_isr_char '>' into ld_end_tag.
* search ld_content_string for ld_end_tag.
* ld_length = strlen( ld_end_tag ).
* ld_size = sy-fdpos + ld_length.
* else. "unicode
  ld_size = STRLEN( ld_content_string ). "unicode
* endif. "unicode
  g_numbytes = ld_size.
  DO.
    CLEAR ls_content_line.

    IF ld_size >= 1022.
      ld_length = 1022.
      ls_content_line = ld_content_string(ld_length).
      SHIFT ld_content_string BY ld_length PLACES.
      ld_size = ld_size - ld_length.
      APPEND ls_content_line TO lt_content.
    ELSEIF ld_size > 0.
      ld_length = ld_size.
      ls_content_line(ld_length) =
      ld_content_string(ld_length).
      APPEND ls_content_line TO lt_content.
      EXIT.
    ELSE.
      EXIT.
    ENDIF.

  ENDDO.

*
  CLEAR i_components.
  i_components-doc_count = '1'.
  i_components-comp_count = '1'.
  i_components-comp_id = 'SAP_URL'.
  i_components-mimetype = 'TEXT/HTML'.
  i_components-comp_size = g_numbytes.
  APPEND i_components.

  CLEAR i_signature.
  i_signature-doc_count = 1.

* i_signature-prop_name = 'BDS_DOCUMENTCLASS'.
* i_signature-prop_value = 'HTML'. "file_extension.
* append i_signature.

  i_signature-doc_id = 'Document ID'.
  i_signature-doc_count = 1.
  i_signature-prop_name = 'DESCRIPTION'.
  i_signature-prop_value = 'Description'.
  APPEND i_signature.

*
* clear i_components.
* i_components-doc_count = '1'.
* i_components-comp_count = '1'.
* i_components-comp_id = 'SAP_URL'.
* i_components-mimetype = 'TEXT/HTML'.
* i_components-comp_size = g_numbytes.
* append i_components.
*
*
* i_signature-prop_name = 'BDS_DOCUMENTCLASS'.
* i_signature-prop_value = 'HTML'. "file_extension.
* append i_signature.
* clear i_signature.
* i_signature-doc_id = 'Document ID'.
* i_signature-doc_count = 1.
* i_signature-prop_name = 'TEST'.
* i_signature-prop_value = 'Free Form Description Here'.
* i_signature-doc_ver_no = 1.
* append i_signature.


*
  CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
    IMPORTING
      own_logical_system             = lv_logsys
    EXCEPTIONS
      own_logical_system_not_defined = 1
      OTHERS                         = 2.

  CLEAR: v_binary_flag.

  lv_objectkey = p_qmnum.
  CALL FUNCTION 'BDS_BUSINESSDOCUMENT_CREA_TAB'
  EXPORTING
  logical_system = lv_logsys
  classname = 'QMSM'
* classname = 'BUS2078'
  classtype = 'BO'
  client = sy-mandt
  object_key = lv_objectkey
  binary_flag = v_binary_flag
* IMPORTING
* OBJECT_KEY =
  TABLES
  signature = i_signature
  components = i_components
  ascii_content = lt_content "lt_ascii
  EXCEPTIONS
  nothing_found = 1
  parameter_error = 2
  not_allowed = 3
  error_kpro = 4
  internal_error = 5
  not_authorized = 6
  OTHERS = 7
  .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
*

  DATA: go_myobject TYPE REF TO cl_gos_manager,
  ls_object TYPE borident.

  ls_object-objkey = lv_objectkey.
  ls_object-objtype = 'QMSM'.
  ls_object-logsys = lv_logsys.

  CREATE OBJECT go_myobject
  EXPORTING is_object = ls_object.
*
  IF sy-subrc = 0.
  ENDIF.

  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
* EXPORTING
* WAIT =
* IMPORTING
* RETURN =
  MESSAGE i004(zbc) WITH 'Content has been attached to QN' p_qmnum.
  CLEAR: i_signature, i_components, lt_content.
  REFRESH: i_signature, i_components, lt_content.



  CALL FUNCTION 'BDS_BUSINESSDOCUMENT_GET_TAB'
  EXPORTING
  logical_system = lv_logsys
  classname = 'QMSM'
  classtype = 'BO'
  client = sy-mandt
  object_key = lv_objectkey
  binary_flag = 'X'
  text_as_stream = ' '
  TABLES
  signature = i_signature
  components = i_components
* CONTENT = lt_content
  ascii_content = lt_content
  EXCEPTIONS
  nothing_found = 1
  parameter_error = 2
  not_allowed = 3
  error_kpro = 4
  internal_error = 5
  not_authorized = 6
  OTHERS = 7.

  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  DATA: lv_doc_id TYPE bapibds01-doc_id.
  LOOP AT i_signature.
    lv_doc_id = i_signature-doc_id.
    EXIT.
  ENDLOOP.

  CALL FUNCTION 'BDS_DOCUMENT_DISPLAY'
  EXPORTING
* CLIENT = SY-MANDT
  doc_id = lv_doc_id
* TABLES
* SIGNATURE =
  EXCEPTIONS
  nothing_found = 1
  parameter_error = 2
  not_allowed = 3
  error_kpro = 4
  internal_error = 5
  not_authorized = 6
  OTHERS = 7
  .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDFORM. " zf_attach_html

*&---------------------------------------------------------------------*
*& Form zf_send_email
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM zf_send_email .

  DATA: i_content TYPE STANDARD TABLE OF soli WITH HEADER LINE,
  i_recipients TYPE STANDARD TABLE OF soli WITH HEADER LINE,
  l_subject(200) TYPE c.
  DATA: wa_html TYPE w3html.

*
  l_subject = 'Testing HTML email'.
*
  CLEAR i_recipients. REFRESH i_recipients.
  i_recipients-line = p_mailid.
  APPEND i_recipients.
*
  CLEAR i_content. REFRESH i_content.
  LOOP AT do->html_table INTO wa_html.
    i_content = wa_html.
    APPEND i_content.
  ENDLOOP.

  CALL FUNCTION 'Z_BC_ABAP_EXTERNAL_SENDMAIL'
  EXPORTING
  l_subject = l_subject
  l_html_content = 'X'
  l_return_address = p_mailid
  TABLES
  i_content = i_content
  i_recipients = i_recipients
  EXCEPTIONS
  send_failed = 1
* FILENAME_INUSE = 2
  OTHERS = 3
  .
  IF sy-subrc <> 0.
    MESSAGE e006(z1) WITH 'Send Failed'.
* message id sy-msgid type sy-msgty number sy-msgno
* with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ELSE.
    MESSAGE i004(zbc) WITH 'Content has sent as email to' p_mailid.
  ENDIF.
ENDFORM. " zf_send_email

*&---------------------------------------------------------------------*
*& Form zf_dd_add_text
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM zf_dd_add_text USING p_do TYPE REF TO cl_dd_document.
  DATA ta TYPE REF TO cl_dd_table_element.
  DATA col1 TYPE REF TO cl_dd_area.
  DATA col2 TYPE REF TO cl_dd_area.
  DATA col3 TYPE REF TO cl_dd_area.
  DATA col4 TYPE REF TO cl_dd_area.
  DATA col5 TYPE REF TO cl_dd_area.
  DATA col6 TYPE REF TO cl_dd_area.
  DATA col7 TYPE REF TO cl_dd_area.
  DATA col8 TYPE REF TO cl_dd_area.


  DATA lv_col TYPE REF TO object.


  DATA text TYPE sdydo_text_element.

  DATA: lt_comp TYPE STANDARD TABLE OF rstrucinfo,
  lv_program TYPE sy-repid,
  lv_structure TYPE tfdir-funcname,
  comp1 TYPE i.

  DATA: lv_cols TYPE i,
  lv_percent(03) TYPE n,
  lv_colw TYPE sdydo_value,
  lv_coln(04) TYPE c,
  lv_idx TYPE sy-tabix.

  FIELD-SYMBOLS: <col> TYPE REF TO cl_dd_area.

  lv_program = 'ZJOETEST10'.
  lv_structure = 'GS_DATA'.

  CALL FUNCTION 'GET_COMPONENT_LIST'
    EXPORTING
      program    = lv_program
      fieldname  = lv_structure
    TABLES
      components = lt_comp[].

  SELECT rollname ddtext
  FROM dd04t
  INTO TABLE gt_comp
  FOR ALL ENTRIES IN lt_comp
  WHERE rollname = lt_comp-compname
  AND ddlanguage = sy-langu.


* set Heading
  text = 'EMAIL TO WMS SITES (DETAIL LEVEL)'.
  CALL METHOD p_do->add_text
    EXPORTING
      text      = text
      sap_style = 'heading'.
  CALL METHOD p_do->new_line.
  CALL METHOD p_do->new_line.
  text = '** This is a test **'.
  CALL METHOD p_do->add_text
    EXPORTING
      text = text.
  CALL METHOD p_do->new_line.
  CALL METHOD p_do->underline.
  CALL METHOD p_do->new_line.


  lv_cols = LINES( gt_comp ).
  lv_percent = 100 / lv_cols.

* create table
  CALL METHOD p_do->add_table
    EXPORTING
      no_of_columns               = lv_cols
      cell_background_transparent = space
    IMPORTING
      table                       = ta.

* JR
  CALL METHOD ta->new_row
    EXPORTING
      sap_color    = 'LIST_TOTAL'
      sap_fontsize = 'LARGE'.

  DATA lv_first.
  FIELD-SYMBOLS: <text> TYPE ANY.

  LOOP AT gt_data INTO gs_data.

    CLEAR lv_first.
    AT FIRST.
      lv_first = 'x'.
    ENDAT.

    LOOP AT gt_comp INTO gs_comp.
      lv_idx = sy-tabix.
      CONCATENATE lv_percent '%' INTO lv_colw.


      IF lv_first = 'x'.
        text = gs_comp-text.
      ELSE.
        ASSIGN COMPONENT lv_idx OF STRUCTURE gs_data TO <text>.
        IF sy-subrc = 0.
          text = <text>.
        ENDIF.
      ENDIF.

* set columns
      IF lv_first = 'x'.
        CALL METHOD ta->add_column
          EXPORTING
            width = lv_colw.
      ENDIF.

      CHECK lv_idx LE ta->no_of_columns.

* set text
      READ TABLE ta->table_of_columns INDEX lv_idx INTO lv_col.

      col1 ?= lv_col. " Type cast from Object to CL_DD_AREA.

      CALL METHOD col1->add_text
        EXPORTING
          text = text.

    ENDLOOP.

    AT LAST.
      EXIT.
    ENDAT.

    CALL METHOD ta->new_row.

  ENDLOOP.


** CALL METHOD ta->set_column_style
** EXPORTING col_no = 1
** sap_color = cl_dd_area=>list_key
*.
** fill columns
* text = 'Material'.
* call method col1->add_text
* exporting
* text = text.
* text = 'Material Desc'.
* call method col2->add_text
* exporting
* text = text.
* text = 'Size/Dimension'.
* call method col3->add_text
* exporting
* text = text.
* text = 'Code Date'.
* call method col4->add_text
* exporting
* text = text.
* text = 'Plant'.
* call method col5->add_text
* exporting
* text = text.
*
*
* call method ta->new_row.
* text = '152080000'.
* call method col1->add_text
* exporting
* text = text.
* text = 'PB Biscuit'.
* call method col2->add_text
* exporting
* text = text.
* text = '15oz/8CT'.
* call method col3->add_text
* exporting
* text = text.
* text = '27JAN6NA'.
* call method col4->add_text
* exporting
* text = text.
* text = 'New Albany'.
* call method col5->add_text
* exporting
* text = text.
*
* text = '155550000'.
* call method col1->add_text
* exporting
* text = text.
* text = 'PB Biscuit'.
* call method col2->add_text
* exporting
* text = text.
* text = '22oz/12CT'.
* call method col3->add_text
* exporting
* text = text.
* text = '29JAN6NA'.
* call method col4->add_text
* exporting
* text = text.
* text = 'New Albany'.
* call method col5->add_text
* exporting
* text = text.
*
* text = 'Instructions for WMS Sites'.
* call method p_do->add_text
* exporting
* text = text.

  CALL METHOD p_do->new_line.
  CALL METHOD p_do->new_line.
  CALL METHOD p_do->underline.

  DATA: v_url TYPE string.
  DATA v_name TYPE sdydo_element_name.

* Portal links
  CASE sy-sysid.
    WHEN 'ERD' OR 'ERX'.
      text = text-042.
    WHEN 'ERQ'.
      text = 'http://gmlinkqa.genmills.com/irj'(043).
    WHEN 'ERP'.
      text = 'http://gmlink.genmills.com/irj/index.html'(044).
  ENDCASE.

* call method p_do->add_text
* exporting
* text = text.

  v_name = 'Joe_Link'.
  v_url = 'http://sapportaldev2.genmills.com/irj/portal'.
*v_url = 'http://www.google.com'.
* SAP users title link line
  text = 'Link Test'.
  CALL METHOD p_do->add_link
    EXPORTING
      text = text
      url  = v_url.

ENDFORM. " zf_dd_add_text

*&---------------------------------------------------------------------*
*& Form zf_send_email2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM zf_send_email2 .

  DATA: g_lines TYPE i,
  g_numbytes TYPE i,
  g_form_name TYPE rs38l_fnam,
  g_pdfspoolid LIKE tsp01-rqident,
  g_jobname LIKE tbtcjob-jobname,
  g_jobcount LIKE tbtcjob-jobcount,
  g_otfspoolid LIKE tsp01-rqident,
  g_control_param TYPE ssfctrlop,
  g_output_options TYPE ssfcompop,
  g_document_data LIKE sodocchgi1,
  g_filename TYPE string.

  DATA:
  i_contents LIKE solisti1 OCCURS 1 WITH HEADER LINE,
  wa_html TYPE solisti1,
  i_packing_list LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE,
  i_object_header LIKE solisti1 OCCURS 1 WITH HEADER LINE,
  i_receivers LIKE somlreci1 OCCURS 1 WITH HEADER LINE,
  l_sender_address LIKE soextreci1-receiver,
  l_sender_adr_type LIKE soextreci1-adr_typ.

  DATA: lv_length TYPE i,
  lv_size LIKE sodocchgi1-doc_size.

  g_document_data-obj_name = 'obectname'.
  g_document_data-obj_descr = 'object description'.

* loop at do->html_table into wa_html.
* i_contents = wa_html.
* append i_contents.
* endloop.

  i_contents = 'This is a test'.
  APPEND i_contents.

  DESCRIBE TABLE i_contents LINES g_lines.
  lv_size = ( g_lines - 1 ) * 255.
  READ TABLE i_contents INDEX g_lines.
  lv_length = STRLEN( i_contents-line ).
  g_document_data-doc_size = lv_size + lv_length.

  CLEAR i_packing_list.
  i_packing_list-head_start = 1.
  i_packing_list-head_num = 0.
  i_packing_list-body_start = 1.
  i_packing_list-body_num = 1.
  i_packing_list-doc_type = 'HTM'.
  APPEND i_packing_list.

  i_object_header = '123456'.
  APPEND i_object_header.

  i_receivers-receiver = '[email protected]'.
  i_receivers-rec_type = 'U'.
  APPEND i_receivers.

  l_sender_address = sy-uname.
  l_sender_adr_type = 'B'.

* i_packing_list defines the document to be sent. The first line
* defines the document and the next lines define the attachment(s).
* CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
  CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
  EXPORTING
  document_data = g_document_data
  put_in_outbox = 'X'
  sender_address = l_sender_address
  sender_address_type = l_sender_adr_type
  commit_work = 'X'
  TABLES
  packing_list = i_packing_list
  object_header = i_object_header
* contents_bin = i_pdf_255
  contents_txt = i_contents
  receivers = i_receivers
  EXCEPTIONS
  too_many_receivers = 1
  document_not_sent = 2
  document_type_not_exist = 3
  operation_no_authorization = 4
  parameter_error = 5
  x_error = 6
  enqueue_error = 7
  OTHERS = 8.

  IF sy-subrc = 0.
  ENDIF.


ENDFORM. " zf_send_email2
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.