Quantcast
Channel: SCN : All Content - ABAP Development
Viewing all articles
Browse latest Browse all 8332

ABAP data in PDF

$
0
0

Hello Experts,

I am working on program to display the invoices data in PDF through ABAP program. For this i have used cl_gui_html_viewer and ALV grid. everything works fine but one. When I click on the PDF preview button on screen then for first PDF its working fine, but when i click on the another PDF preview button then it displays same PDF as per first. In case of rerunning the program it again works fine only for first PDF preview. if anybody have idea regarding this issue please share it with me. FYI i am attaching necessary code with this. The code stated below is for displaying PDF in HTML viewer.

 

METHOD on_link_click.

    DATA : l_str_content TYPE zebd_send_content.

    READ TABLE m_tab_content INDEX row INTO l_str_content.

 

 

    DATA: l_xml  TYPE REF TO cl_xml_document.

 

 

    CREATE OBJECT l_xml.

 

 

    CASE column.

      WHEN 'PRVW'.

        g_attachment_string = l_str_content-attachment.

 

 

        CALL FUNCTION 'Z_EBD_PDF_SHOW'

          EXPORTING

            i_id = l_str_content-id

            i_pdf_string = g_attachment_string.

 

 

        CREATE OBJECT g_rcl_html_control

          EXPORTING

*            shellstyle         =

            parent             = g_rcl_html_container

*            lifetime           = lifetime_default

*            saphtmlp           =

*            uiflag             =

*            name               =

*            saphttp            =

*            query_table_disabled = ''

*          EXCEPTIONS

*            cntl_error         = 1

*            cntl_install_error = 2

*            dp_install_error   = 3

*            dp_error           = 4

*            others             = 5

            .

        IF sy-subrc <> 0.

*         MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*                    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

        ENDIF.

 

 

 

 

 

 

FUNCTION Z_EBD_PDF_SHOW .

*"----------------------------------------------------------------------

*"*"Local Interface:

*"  IMPORTING

*"     REFERENCE(I_PDF_STRING) TYPE  STRING

*"     REFERENCE(I_ID) TYPE  STRING

*"----------------------------------------------------------------------

 

 

  g_attachment_string = i_pdf_string.

  g_id = I_ID.

 

 

  call screen 0101 STARTING AT 5 5.

 

 

 

 

ENDFUNCTION.

 

 

 

 

 

 

*----------------------------------------------------------------------*

***INCLUDE LZ_EBDO01 .

*----------------------------------------------------------------------*

*&---------------------------------------------------------------------*

*&      Module  STATUS_0100  OUTPUT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

module STATUS_0100 output.

 

 

  set pf-status '100'.

*  SET TITLEBAR 'xxx'.

 

 

  clear: g_url, g_tab_pdf_data,g_attachment_binary.

  free: g_rcl_html_container, g_rcl_html_control.

 

 

  create object g_rcl_html_container

    exporting

      container_name = 'PDF'.

 

 

  create object g_rcl_html_control

    exporting

      parent = g_rcl_html_container.

*      lifetime = cl_gui_html_viewer=>lifetime_dynpro.

 

 

*    CREATE OBJECT g_rcl_pdf_control

*      EXPORTING

*        parent            = g_rcl_html_container

**        lifetime          =

**        shellstyle        =

**        autoalign         =

*      EXCEPTIONS

*        cntl_error        = 1

*        cntl_system_error = 2

*        create_error      = 3

*        lifetime_error    = 4

*        others            = 5

*        .

*    IF sy-subrc <> 0.

**     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

**                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

*    ENDIF.

 

 

* Convert xstring to binary table to pass to the LOAD_DATA method

  clear g_attachment_binary.

  call function 'SSFC_BASE64_DECODE'

    exporting

      b64data = g_attachment_string

    importing

      bindata = g_attachment_binary

    exceptions

      others  = 8.

 

 

  clear g_tab_pdf_data.

  call function 'SCMS_XSTRING_TO_BINARY'

    exporting

      buffer     = g_attachment_binary

    tables

      binary_tab = g_tab_pdf_data.

 

 

* Load the HTML

  clear g_url.

  CONCATENATE g_id '.pdf' into g_id.

 

 

  g_rcl_html_control->load_data(

     exporting

       url          = g_id

       type         = 'application'

       subtype      = 'pdf'

     importing

       assigned_url         = g_url

     changing

       data_table           = g_tab_pdf_data

     exceptions

       dp_invalid_parameter = 1

       dp_error_general     = 2

       cntl_error           = 3

       others               = 4 ).

 

 

*     CALL METHOD g_rcl_pdf_control->open_document

*    EXPORTING

*      url               = g_url

*    EXCEPTIONS

*      cntl_error        = 1

*      cntl_system_error = 2

*      others            = 3

*          .

*  IF sy-subrc <> 0.

**   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

**              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

*  ENDIF.

 

 

 

 

 

 

** Show it

  g_rcl_html_control->show_url( url = g_url

    in_place = 'X' ).

 

 

 

 

 

 

endmodule.                 " STATUS_0100  OUTPUT

 

 

Thanks,

Avadhut


Viewing all articles
Browse latest Browse all 8332

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>