Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
VijayCR
Active Contributor
3,036

Introduction :

      As the document attachment functionality is very common requirement now a days in SAP,all the documents are created either as PDF,Text and other SAP readable formats and archived in any of the archiving systems like IXOS or Saperion .These stored documents generally creates a document ID through which the documents are attached in the corresponding FI documents as shown in the below options either as direct attachment or URL link or as a PDF document.

As-Is :

      There is a challenge in storing and printing PDF as spool.All the other document types can be archived using the Function module ARCHIV_GET_CONNECTIONS, ARCHIV_CONNECTION_INSERT , CONVERT_OTF_AND_ARCHIVE  as a 'OTF' or 'PDF'.The stored content can be obtained using the below code:

CALL FUNCTION 'ARCHIVOBJECT_GET      

  EXPORTING

        archiv_id                = c_th

         document_type            = c_pdf

          archiv_doc_id            = w_archiv_doc_id

       IMPORTING

         binlength                = w_length

        TABLES

          binarchivobject          = t_data_raw

       EXCEPTIONS

         error_archiv             = 1

          error_communicationtable = 2

         error_kernel             = 3

          OTHERS                   = 4.

Obtianed data TABL1024 is of RAW type which can not be converted to either SOLIX or OTF format.So we can not create spools instead we can either send as a email attachment or do a file attachment in front end.

Solution Provided :

                 Going forward once the OTF data is obtained convert the OTF to a storable fomat which can be later converted to OTF from the archiving systems.

      •   Create a new internal table with the below type

                    

           types: begin of ty_otf,

             line type c length 72,

               end of ty_otf.

                  

       loop at t_otfdata into f_otf1.

           move f_otf1 to f_otf.

           append f_otf to t_otf.

         endloop.

call function 'SCMS_TEXT_TO_BINARY'

           importing

             output_length = w_len2

           tables

             text_tab      = t_otf "f_job_output_info-OTFDATA

             binary_tab    = it_binary_data

           exceptions

             failed        = 1

             others        = 2.

call function 'SCMS_BINARY_TO_STRING'

           exporting

             input_length = w_len2

           importing

             text_buffer  = fs_property_string

           tables

             binary_tab   = it_binary_data

           exceptions

             failed       = 1

             others       = 2.

*       The function module is used to convert string to xstring

         call function 'SCMS_STRING_TO_XSTRING'

           exporting

             text   = fs_property_string

           importing

             buffer = w_XSTRING

           exceptions

             failed = 1

             others = 2.

 

    •      XSTRING data should be  passed and stored using the FM ARCHIV_CONNECTION_INSERT   into the IXOS or saperion      

          if_proxy_client~execute(

     exporting

       method_name = 'CREATE'

     changing

       parmbind_tab = lt_parmbind

   ).

  •      Document ID is generated and stored in the table.
  •    Below code should be written while retrieving the document from the archiving system :

* Convert Xstring to binary data

     call function 'SCMS_XSTRING_TO_BINARY'

       exporting

         buffer        = w_content_o-parameters-return-content

       importing

         output_length = w_filesize

       tables

         binary_tab    = t_binary_data.

* Convert binary to OTF

     call function 'SCMS_BINARY_TO_TEXT'

       exporting

         input_length  = w_filesize

       importing

         output_length = w_len2

       tables

         binary_tab    = t_binary_data

         text_tab      = t_otf

       exceptions

         failed        = 1

         others        = 2.

     loop at t_otf into f_otf.

       move f_otf to f_otf1.

       append f_otf1 to t_otf1.

     endloop.

call function 'PRINT_OTF'

       exporting

         printoptions = f_itcpo

       importing

         spoolid      = w_spool

       tables

         otf          = t_otf1.

This way we can use this logic for the mass prints which can be run in back ground and can print the PDF's from archiving system either IXOS or Saperion.

Any inputs are highly appreciated.

Labels in this area