cancel
Showing results for 
Search instead for 
Did you mean: 

Calling PDF file from Application Server and display through a view

Former Member
0 Kudos

Hi All,

Sorry if I am putting a wrong question.I search for two days before putting this query. \

Issue-->I want to display a PDF file through a view which is store in the application Server.

Development which i completed-->

I have two views ,Main view and PDF view.From Main view i want am calling the PDF view to display the PDF document from Application Server.

View Name--Main

Method --> ONACTIONGENERATE_PDF .

Code-->

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

*  Read the attribute data for the View PDF                        *

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

   DATA lo_el_context      TYPE REF TO if_wd_context_element.

   DATA ls_context         TYPE wd_this->element_context.

   DATA lv_view_pdf        LIKE ls_context-view_pdf.

   DATA lo_msg_manager     TYPE REF TO if_wd_message_manager.

   DATA ls_attach_list     TYPE wd_this->element_attachment_list.


DATA: lv_filename TYPE string,

         lv_content TYPE rcf_attachment_content,

         lt_binary_content TYPE SDOKCNTBINS,

         lv_hex_container TYPE xstring.

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

*Logic to findout the system id and assign the application server        *

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

   clear path_name.

   lv_sid = sy-sysid.

   if lv_sid EQ 'HRD'.

     path_name = '/usr/sap/HRD/Learning/'.

   ELSEIF lv_sid EQ 'HRU'.

     path_name = '/usr/sap/HRU/Learning/'.

   ELSEIF lv_sid EQ 'HRP'.

     path_name = '/usr/sap/HRP/Learning/'.

   ENDIF.

CLEAR: lv_content, lt_binary_content[].

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

*     Select the data from the database table to view as the PDF     *

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

   LOOP AT lt_elements INTO lo_element.

     lo_element->get_static_attributes(

       IMPORTING

         static_attributes = ls_attach_list

     ).

     "Check if record exists in table

     MOVE-CORRESPONDING ls_attach_list TO ls_data.

     APPEND ls_data TO lt_data.

   ENDLOOP.


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

* Read the data from Application Server and convert xstring data to binary          *

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

   CONCATENATE path_name ls_data-file_name into file.

   OPEN DATASET file FOR INPUT IN BINARY MODE MESSAGE msg .

   DO.

     READ DATASET file INTO lv_hex_container MAXIMUM LENGTH 1000.

     IF sy-subrc <> 0.

       EXIT.

     ELSE.

       CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

         EXPORTING

           buffer          = lv_hex_container

           append_to_table = 'X'

         TABLES

           binary_tab      = lt_binary_content.

     ENDIF.

   ENDDO.

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

   CLOSE DATASET file.

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

*transform this result in to a single X-string variabele, that will contain the whole document*

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

   CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'

     EXPORTING

       input_length = 1000000000

     IMPORTING

       buffer       = lv_content

     TABLES

       binary_tab   = lt_binary_content

     EXCEPTIONS

       OTHERS       = 4.

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

* Move the xstring data again to PDF field and call the outbound plug for the PDF view           *

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

   wd_comp_controller->GV_PDF = lt_binary_content.

   wd_this->fire_out_from_popup_plg( ).

View Name-->ViewPDF

Method-->WDDOMODIFYVIEW

method WDDOMODIFYVIEW .

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

* This method used to call the PDF screen                          *

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

   DATA lt_final type standard table of WDR_CONTEXT_CHANGE.

   DATA ls_final type WDR_CONTEXT_CHANGE.

   DATA lo_el_context TYPE REF TO if_wd_context_element.

   DATA ls_context    TYPE wd_this->element_context.

*  DATA lv_pdf        LIKE ls_context-pdf.

   DATA lv_pdf        TYPE SDOKCNTBINS.

   data lv_var type string.

   field-symbols: <fs> type data.

*   get element via lead selection

   lo_el_context = wd_context->get_element).

   clear lv_pdf.

   lv_pdf = wd_comp_controller->GV_PDF.

*  lo_el_context->set_attribute(

*       name =  `PDF`

*       value = lv_pdf  ).

   lo_el_context->set_attribute(

        name `PDF`

        value = ).

endmethod.


Conclusion-->

Everything is working fine till it comes to Set_attribute but after this I am getting a dump as

You attempted to move one data object to another.

This is not possible here because the conversion of a data object

of type "h" to type "y" is not supported.

Please check the code and suggest...i know i am missing something the second method but dont know how to resolve it.

Kindly suggest.

Cheers

Jay

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Not the lt_binary_content.

You have to store lv_content. And it's type is XSTRING.

Former Member
0 Kudos

Hi Derby,

Apology for delay in response. I will try your suggestion and update you ASAP.

Cheers

Jay

Former Member
0 Kudos

Hi

Anyone can please suggest any input on this.

Thanks

Jay