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

Print program code for generated PDFs



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Smartforms, SapScripts, PDF
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Thu Feb 19, 2009 3:36 pm    Post subject: Print program code for generated PDFs Reply with quote

Print program code for generated PDFs
Author: Markus Meisl
Source from: http: /www.sappro.com/downloads/PrintProgram.pdf

You can use the following code as an example of a print program for the PDFs you generate. Note that you
need to place all form processing instructions between the opening and closing of the spool job.

Code:
   *----------------------------------------------------------------------------*
   *       Report ZFP_SOLUTION
   *----------------------------------------------------------------------------*
   *       Printing of documents using PDF based forms
   *----------------------------------------------------------------------------*
   report zfp_solution.
   * Data declaration
   data: carr_id type sbook-carrid,
            customer          type scustom,
            bookings          type ty_bookings,
            connections       type ty_connections,
            fm_name           type rs381_fnam,
            fp_docparams      type sfpdocparams,
            fp_outputparams   type sfpoutputparams,
            error_string      type string,
            l_booking         type sbook,
            t_sums            type table of sbook,
            l_sums            like line of t_sums.
   parameter:      p_custid type scustom-id default 38.
   select-options: s_carrid for carr_id     default 'AA' to 'ZZ'.
   parameter:      p_form   type fpwbformname   default  'ZFP_SOLUTION'.
   parameter:      language    type sfpdocparams-langu    default 'E'.
   parameter:      country  type sfpdocparams-country default 'US'.
   * Get data from the following tables: scustom(Flight customer)
   *                                     sbook  (Single flight reservation)
   *                                     spfli  (Flight plan)
   select single * from scustom into customer where id = p_custid.
   check sy_subrc = 0.
   select * from sbook into table bookings
                where customid = p_custid
                and carrid     in s_carrid
                order by primary key.
   select * from spfli into table connections
                for all entries in bookings
                where carrid = bookings-carrid
                and   connid = bookings-connid
                order by primary key.
   * Print data:
   * First get name of the generated function module
   call function 'FP_FUNCTION_MODULE_NAME'
      exporting
         i_name     = p_form
      importing
         e_funcname = fm_name.
   if sy-subrc <> 0.
      message e001(fp_example).
   end if.
   * Set output parameters and open spool job
   * fp_outputparams-nodialog = 'X'.    " suppress printer dialog popup
   * fp_outputparams-preview  = 'X'.    " launch print preview
   call function 'FP_JOB_OPEN'
      changing
         ie_outputparams = fp_outputparams
      exceptions
         cancel          = 1
         usage_error     = 2
         system_error    = 3
         internal_error  = 4
         others          = 5.
   * Set form language and country (->form locale)
   fp_docparams-langu   = language.
   fp_docparams-country = country.
   *fp_docparams-langu   = 'E'.
   *fp_docparams-country = 'GB'.
   * currency key dependant summing
   loop at bookings into l_booking.
      l_sums-forcuram  = l_booking-forcuram.
      l_sums-forcurkey = l_booking-forcurkey.
      collect l_sums into t_sums.
   endloop.
   * Now call the generated function module
   call function fm_name
      exporting
         /1bcdwb/docparams = fp_docparams
         customer          = customer
         bookings          = bookings
         connections       = connections
         t_sums            = t_sums
      exceptions
         usage_error       = 1
         system_error      = 2
         internal_error    = 3
         others            = 4.
   if sy-subrc <> 0.
      call function 'FP_GET_LAST_ADS_ERRSTR'
         importing
            e_adserrstr = error_string.
      if not error_string is initial.
   *     we received a detailed error description
         write:/ error_string.
         exit.
      else.
         message id sy-msgid type sy-msgty number sy-msgno
                     with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
   endif.
   * Close spool job
   call function 'FP_JOB_CLOSE'
      exceptions
         usage_error       = 1
         system_error      = 2
         internal_error    = 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.
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 -> Smartforms, SapScripts, PDF 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.