Sending the Multiple ALVs as PDF Attachment through Email

...Previous

Subroutine to Display Second ALV

*&---------------------------------------------------------------------*
*&      Form  SUB_DISPLAY_SECONDALV
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_I_FIELDCATALOG2  text
*      -->P_I_ORDERS2  text
*----------------------------------------------------------------------*
FORM sub_display_secondalv  USING   fp_i_fieldcatalog2 TYPE lvc_t_fcat
                                    fp_i_orders2     TYPE ty_t_orders2.

* Local data declaration
  DATA: li_layout TYPE lvc_s_layo,
        lx_print TYPE lvc_s_prnt.


* Layout for ALV
  PERFORM sub_prepare_layout USING c_x
                                   text-012
                                   c_x
                                   c_cellstyle
                          CHANGING li_layout.
*  Use Flush
  CALL METHOD cl_gui_cfw=>flush.

  IF g_custom_container2 IS INITIAL.       "To ensure that object is created only once

    CREATE OBJECT g_custom_container2
      EXPORTING
        container_name = 'G_CONTAINER2'.

*     Create an instance of ALV control
    CREATE OBJECT g_grid2
      EXPORTING
        i_parent = g_custom_container2.


    CALL METHOD g_grid2->set_table_for_first_display
      EXPORTING
        it_toolbar_excluding          = i_exclude
        is_layout                     = li_layout
        is_print                      = lx_print
      CHANGING
        it_outtab                     = fp_i_orders2
        it_fieldcatalog               = fp_i_fieldcatalog2
      EXCEPTIONS
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        OTHERS                        = 4.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
  ENDIF.

ENDFORM.                    “SUB_DISPLAY_SECONDALV

Subroutine to Display Third ALV

*&---------------------------------------------------------------------*
*&      Form  SUB_DISPLAY_THIRDALV
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_I_FIELDCATALOG3  text
*      -->P_I_INVSTATUS  text
*----------------------------------------------------------------------*
FORM sub_display_thirdalv  USING    fp_i_fieldcatalog3 TYPE lvc_t_fcat
                                    fp_i_invstatus TYPE ty_t_invstatus.

* Local data declaration
  DATA: li_layout TYPE lvc_s_layo,
        lx_print TYPE lvc_s_prnt.


* Layout for ALV
  PERFORM sub_prepare_layout USING c_x
                                   text-013
                                   c_x
                                   c_cellstyle
                          CHANGING li_layout.
*  Use Flush
  CALL METHOD cl_gui_cfw=>flush.

  IF g_custom_container3 IS INITIAL.       "To ensure that object is created only once

    CREATE OBJECT g_custom_container3
      EXPORTING
        container_name = 'G_CONTAINER3'.

*     Create an instance of ALV control
    CREATE OBJECT g_grid3
      EXPORTING
        i_parent = g_custom_container3.


    CALL METHOD g_grid3->set_table_for_first_display
      EXPORTING
        it_toolbar_excluding          = i_exclude
        is_layout                     = li_layout
        is_print                      = lx_print
      CHANGING
        it_outtab                     = fp_i_invstatus
        it_fieldcatalog               = fp_i_fieldcatalog3
      EXCEPTIONS
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        OTHERS                        = 4.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
  ENDIF.
ENDFORM.                    “SUB_DISPLAY_THIRDALV

Subroutine for ALV layout

*&---------------------------------------------------------------------*
*&      Form  SUB_PREPARE_LAYOUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_LI_LAYOUT  text
*----------------------------------------------------------------------*
FORM sub_prepare_layout  USING fp_c_x         TYPE xfeld
                               fp_title       TYPE lvc_title
                               fp_smalltitle  TYPE xfeld
                               fp_stylename   TYPE lvc_fname
                      CHANGING fp_li_layout   TYPE lvc_s_layo.

  fp_li_layout-zebra      = fp_c_x.
  fp_li_layout-grid_title = fp_title.
  fp_li_layout-smalltitle = fp_smalltitle.
  fp_li_layout-stylefname = fp_stylename.

ENDFORM.                    “SUB_PREPARE_LAYOUT

Subroutine for Report header, which will be created dynamically based on the fields selected by the User for a User selected report layout. 

*&---------------------------------------------------------------------*
*&      Form SUB_TOP_OF_PAGE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
* --> p1        text
* <-- p2        text
*----------------------------------------------------------------------*
FORM sub_top_of_page.

* Local data Declaration
  DATA: l_text TYPE sdydo_text_element,
        l_datel (10) TYPE c,
        l_dateh (10) TYPE c.

* Calling the methods for dynamic text
  CALL METHOD g_document->add_text
    EXPORTING
      text         = text-014
      sap_emphasis = cl_dd_area=>strong " For bold
      sap_fontsize = cl_dd_area=>extra_large.

* Adding Line
  CALL METHOD g_document->new_line.
* Adding Line
  CALL METHOD g_document->new_line.

*   Sold-to customer
  IF s_kunnr-high IS NOT INITIAL.
    CONCATENATE  s_kunnr-low 'to' s_kunnr-high INTO l_text SEPARATED BY ' '.
  ELSE.
    l_text = s_kunnr-low.
  ENDIF.

  CALL METHOD g_document->add_text
    EXPORTING
      text         = text-015
      sap_emphasis = cl_dd_area=>strong. “For bold.

  CALL METHOD g_document->add_gap
    EXPORTING
      width = '15'.

  CALL METHOD g_document->add_text
    EXPORTING
      text = l_text.
  CALL METHOD g_document->new_line.


  CLEAR: l_text.
*   Change date
*   Converting date format
  CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
    EXPORTING
      date_internal = s_erdat-low
    IMPORTING
      date_external = l_datel.

* Converting date format
  CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
    EXPORTING
      date_internal = s_erdat-high
    IMPORTING
      date_external = l_dateh.

  IF s_erdat-high IS NOT INITIAL.
    CONCATENATE l_datel 'to' l_dateh INTO l_text SEPARATED BY ' '.
  ELSE.
    l_text = l_datel.
  ENDIF.

  CALL METHOD g_document->add_text
    EXPORTING
      text         = text-016
      sap_emphasis = cl_dd_area=>strong. “For bold.

  CALL METHOD g_document->add_gap
    EXPORTING
      width = '24'.

  CALL METHOD g_document->add_text
    EXPORTING
      text = l_text.
  CALL METHOD g_document->new_line.

  CLEAR: l_text.
  IF NOT s_vkorg IS INITIAL.
*   Sales Organization
    IF s_vkorg-high IS NOT INITIAL.
      CONCATENATE  s_vkorg-low 'to' s_vkorg-high INTO l_text SEPARATED BY ' '.
    ELSE.
      l_text = s_vkorg-low.
    ENDIF.

    CALL METHOD g_document->add_text
      EXPORTING
        text         = text-017
        sap_emphasis = cl_dd_area=>strong. “For bold.

    CALL METHOD g_document->add_gap
      EXPORTING
        width = '12'.

    CALL METHOD g_document->add_text
      EXPORTING
        text = l_text.
    CALL METHOD g_document->new_line.
  ENDIF.

  CLEAR : l_text.
  IF NOT s_bsark IS INITIAL.
*   PO Type
    IF s_bsark-high IS NOT INITIAL.
      CONCATENATE  s_bsark-low 'to' s_bsark-high INTO l_text SEPARATED BY ' '.
    ELSE.
      l_text = s_bsark-low.
    ENDIF.

    CALL METHOD g_document->add_text
      EXPORTING
        text         = text-018
        sap_emphasis = cl_dd_area=>strong. “For bold.

    CALL METHOD g_document->add_gap
      EXPORTING
        width = '32'.

    CALL METHOD g_document->add_text
      EXPORTING
        text = l_text.
    CALL METHOD g_document->new_line.
  ENDIF.

* Display the data
  CALL METHOD g_document->display_document
    EXPORTING
      parent = g_top_container.
* Calling the method of ALV to process top of page
  CALL METHOD g_grid1->list_processing_events
    EXPORTING
      i_event_name = text-019
      i_dyndoc_id  = g_document.

ENDFORM.                    “SUB_TOP_OF_PAGE

Click here to continue...

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image