How to generate a PDF document from ABAP program

Hi experts,
I have arequirement where in i need to create a PDF document using program. I have all the data collected into tables and i have used the calss CL_FP_PDF_OBJECT.
A pdf document is successfully created, but unable to open it because of some error. I guess some encryption is missing.
As an alternative I have created a smartform and generated its OTF data in my program and created a PDF. This is working fine.
But as per my requirement, i cannot go for a smart form.
Any help to resolve this issue will be highly appreciated.
Thanks & regards,
Asrar Ahamed MA
Infosys Tech. Ltd. INDIA

Hi Asrar ,
create a report with this Copy and give your program name in the selection screen whose output need to be in PDF.
*report  zanusha_spool_to_pdf.
---TABLES----
tables:
  tsp01.
---STRUCTURES---
data:
  mstr_print_parms like pri_params,
  mc_valid(1)      type c,
  mi_bytecount     type i,
  mi_length        type i,
  mi_rqident       like tsp01-rqident.
---INTERNAL TABLES---
data:
  mtab_pdf    like tline occurs 0 with header line,
  mc_filename like rlgrap-filename.
---SELECTION SCREEN---
parameters:
  p_repid like sy-repid, " Report to execute
  p_linsz like sy-linsz default 132, " Line size
  p_paart like sy-paart default 'X_65_132'.  " Paper Format
start-of-selection.
  concatenate 'c:\'
              p_repid
              '.pdf'
    into mc_filename.
*-- Explicitly set line width, and output format so that
*-- the PDF conversion comes out OK
  mstr_print_parms-linsz = p_linsz.
  mstr_print_parms-paart = p_paart.
*-- Make sure that a printer destination has been set up.
*-- If this is not done the PDF function module ABENDS
  if mstr_print_parms-pdest = space.
    mstr_print_parms-pdest = 'LOCL'.
  endif.
*-- Setup the Print Parmaters
  call function 'GET_PRINT_PARAMETERS'
    exporting
     authority              = space
      copies                 = '1'
     cover_page             = space
     data_set               = space
     department             = space
     destination            = space
      expiration             = '1'
     immediately            = space
     in_archive_parameters  = space
     in_parameters          = space
     layout                 = space
     mode                   = space
      new_list_id            = 'X'
      no_dialog              = 'X'
      user                   = sy-uname
    importing
      out_parameters         = mstr_print_parms
      valid                  = mc_valid
    exceptions
      archive_info_not_found = 1
      invalid_print_params   = 2
      invalid_archive_params = 3
      others                 = 4.
  submit (p_repid) to sap-spool without spool dynpro
                   spool parameters mstr_print_parms
                   via selection-screen
                   and return.
*-- Find out the spool number
  perform get_spool_number using sy-repid
             sy-uname
    changing mi_rqident.
*-- Convert Spool to PDF
  call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
    exporting
      src_spoolid              = mi_rqident
      no_dialog                = space
      dst_device               = mstr_print_parms-pdest
    importing
      pdf_bytecount            = mi_bytecount
    tables
      pdf                      = mtab_pdf
    exceptions
      err_no_abap_spooljob     = 1
      err_no_spooljob          = 2
      err_no_permission        = 3
      err_conv_not_possible    = 4
      err_bad_destdevice       = 5
      user_cancelled           = 6
      err_spoolerror           = 7
      err_temseerror           = 8
      err_btcjob_open_failed   = 9
      err_btcjob_submit_failed = 10
      err_btcjob_close_failed  = 11
      others                   = 12.
*-- Download the file
  call function 'DOWNLOAD'
    exporting
      bin_filesize = mi_bytecount
      filename     = mc_filename
      filetype     = 'BIN'
    importing
      act_filename = mc_filename
    tables
      data_tab     = mtab_pdf.
      FORM get_spool_number *
      Get the most recent spool created by user/report              *
-->  F_REPID               *
-->  F_UNAME               *
-->  F_RQIDENT             *
form get_spool_number using f_repid
     f_uname
                changing f_rqident.
  data:
    lc_rq2name like tsp01-rq2name.
  concatenate f_repid+0(9)
              f_uname+0(3)
    into lc_rq2name.
  select * from tsp01 where  rq2name = lc_rq2name
  order by rqcretime descending.
    f_rqident = tsp01-rqident.
    exit.
  endselect.
  if sy-subrc ne 0.
    clear f_rqident.
  endif.
endform." get_spool_number
Thanx
Anusha.

Similar Messages

  • How to generate a pdf document from excel on ipad version?

    IS there a way to generate a pdf document from an excel file directly from excel ipad version ?

    IS there a way to generate a pdf document from an excel file directly from excel ipad version ?

  • How can I send PDF document from adobe

    How can I send PDF document from adobe

    If you mean, "How can I send a PDF document from Adobe Reader?" then answer is: Click on the Share button (arrow out of box icon), and choose E-mail document.

  • How can I print PDF attachments from ABAP report in transaction ME23N?

    Hi,
    Users attach PDF files using "services for objects" in transaction ME23N.
    How can I print the PDF attachments from ABAP report ?
    Thanks in advance,,

    Hi,
      check this link,this might help you to solve your problem
    /people/thomas.jung3/blog/2005/04/28/setting-up-an-adobe-writer-for-abap-output
    Regards
    Kiran Sure

  • How to generate a pdf form from a webform

    HOW TO GENERATE POPULATED PDF?
    We used to fill out the forms at work longhand (yes, with a pen!)
    Now since we created the form using Acrobat 9 Pro, we just enter the data on computer, and print out the form.
    Acrobat 9 form creator was great - I found it quite easy to use.
    Now, I'd like to automate the process even further.
    Each week we receive response forms from our website (maybe about 20-25).  These response forms have about 10 fields that
    people have completed with their information.Currently I am printing  out the response form and then open up the acrobat form and I enter their information into the pdf (and then print).
    1. Is it possible to automatically populate a pdf from the response form ? (without me having to print out the response form and re-enter the data)
    2. Is it really complicated; is this something I can do with some software/learning or do i need a programmer?
    Thank you kindly for any advice or direction.

    It sounds like you are using the forms in your local shop and that e-mail may work fine. If e-mail submission works fine (not recommended for normal use, but find in a controlled environment where you can be sure each e-mail client is running MAPI), then add a submit button to submit a FDF or XML data file (I like FDF when using forms in Acrobat, Designer only uses XML forms). You can then import the FDF or XML data to the form and print it. You can even manipulate the FDF or XML data and add it to a database of some form, furthering your processing even more.

  • How do I transfer pdf documents from my pc to my iOS device?

    How do I transfer a pdf document from my pc to my iOS device?  How do I tranfer a pdf document from my iOS device to my pc?

    The document Charu mentioned is great, but it is slightly out of date and missing one important method that I use frequently. I like to go to http://files.acrobat.com and upload files to my Acrobat.com account. The uploader there allows me to upload multiple documents at the same time (shift clicking on them on my PC or cmd-clicking on them on my Mac). Then, I connect my Adobe Reader to my Acrobat.com account and I can see all of those files!

  • How do I import à pdf document from an email?

    How do i import a pdf document from an email? Thanks.

    If you haven't, update Reader to Reader 11.2.1. Use the Help system to find out how to bring a PDF from your email. If you're still having problems, check back here.

  • How to print a PDF document from Labview?

    I am looking to create a paper copy of a PDF document.  Note: I do NOT want to create a PDF document.
    In other words I want to print a PDF document from Lab View or Visual Basic or C#.  The application is used in a production environment so I want a clean solution.
    The requirements are:
    1) Be able to specify the output printer.
    2) Set the quantity to print.
    3) Specify the file to print.
    4) Function returns when printing is complete
    5) Silent operation, that means no popup boxes.
    Any help is appreciated.

    http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/prnmngr.mspx?mfr=true
    http://forums.ni.com/ni/board/message?board.id=170&message.id=183895&requireLogin=False
    you might be able to use system exec to print files.

  • How can I read pdf documents from SD card

    Is it (or will it be) possible to read pdf documents from SD card in Windows Phone 8?
    Thanks

    Yes, it is possible. You can create even a folder on SD card and put in it the pdf's. It is working on my lumia 620 with Adobe reader 10.3 version.. You insert the SD in the phone, connect the phone to the computer and you will see the phone and the SD under it.
    More....
    You drag your pdf's on the SD card. when you open the Adobe reader on the phone you go to the documents and here they are (with a small card icon near the document which shows you that the file is on the SD card.

  • How to open the pdf document from KM  through Link to URL UI element

    Hi All,
    I have Link to URL UI element  in webdynpro java layout - on click of the link we need to open the pdf document from KM respository.
    KM Document location : irj/go/km/docs/documents/RHPortal//USA/A/Test/Employee_details.pdf.
    Once this is transported to Test and Production portals , we need to retrieve the KM document from the respective portal location through the Link to URL UI element .
    Thanks,
    Portaluser100

    Hi,
    If you set the link to your document in a Context attribute by using a relative path this should work just fine.
    Example:
    wdContext.currentContextElement().setUrl("/irj/go/km/docs/documents/RHPortal//USA/A/Test/Employee_details.pdf");
    Bind that attribute to the reference property of the LinkToURL element.
    Cheers,
    Leo

  • How to generate an XML Document from XQuery

    The following query returns me the required XML output. However, I need to generate an XML Document out of it. How do I go about generating an XML Doc?.
    SELECT XMLQuery('<Data>
    {for $tert in ora:view("DATA"),
               $tert_audit in ora:view("DATA_AUDIT")
           let $tert_cmd_id := $tert/ROW/ID/text(),
               $tert_spouse_name := $tert/ROW/SPOUSE_NAME/text(),
               $tert_directions := $tert/ROW/DIRECTIONS/text(),
               $tert_soil_zone := $tert/ROW/SOIL_ZONE/text(),
               $tert_audit_cmd_id := $tert_audit/ROW/ID/text(),
               $tert_audit_trans_date := $tert_audit/ROW/TRANSACTION_DATE/text()
               where $tert_cmd_id = $tert_audit_cmd_id and
               $tert_audit_trans_date >= xs:date(V_Last_Successful_Date)
               order by $tert_cmd_id
           return
           <op>
             <op_type>I</op_type>
             <ent_id>{$tert_cmd_id}</ent_id>
    <source>S</source>
    <fg>
    <val_flds>
    <fld>
    <id>spouse_name</id>
    <val>{$tert_spouse_name}</val>
    </fld>
    <fld>
    <id>directions</id>
    <val>{$tert_directions}</val>
    </fld>
    <fld>
    <id>soil_zone</id>
    <val>{$tert_soil_zone}</val>
    </fld>
    </val_flds>
    </fg>
    </op>}</Data>' RETURNING CONTENT)
    INTO V_Other_Insert
    FROM dual;

    Hi Geoff,
    I would like to generate an XML file which contains data as shown below:
    <Insert>
    <result>
    <type>A</type>
    <id>1</id>
    <date>11/11/2006</date>
    <source>Web</source>
    </result>
    </Insert>
    I'm using the below given query for this purpose:
    SELECT XMLQuery('<Insert>
    {for $c in ora:view("TableA")
           let $id := $c/ROW/ID/text(),
               $code := $c/ROW/CODE/text(),
               $type := $c/ROW/TYPE/text(),
               $date := $c/ROW/DATE/text()
           return
           <result>
             <type>{$type }</type>
    <id>{$id}</id>
    <date>{$date}</date>
    <source>S</source>
    </result> }</Insert>' RETURNING CONTENT)
    INTO V_Insert
    FROM dual;
    V_Insert stores the required result.
    How do I save this result to a XML Document?
    Please help.

  • How to generate a pdf file from Excel

    Hi all,
    I've a Excel file i want to generate a pdf file by using java...can any one explain wht r the things r required. If ur answer is "iText" or "apache FOP" then wht r the things to be needed...I want to know the exact answer...step by step....plz help me out...
    Eagarly waiting for reply...
    regards
    [email protected]

    hi,
    I've a idea on jdk,,,i need to know who to use FOP packages?
    regards,
    [email protected]

  • Sending Data to PDF Forms from ABAP Program.

    Hi Experts,
    I left ABAP Programing for a while around 1+ years Due to some personal problems
    Now I have struck up with new issue. Its ADOBE PDF forms.
    I am Entirely new to this topic & knows about Nothing.
    My requirement is to display a report in PDF form. Its totally Independent form from NACE.
    I have written a Driver program & retrieved all the DATA into a Final internal table.
    Now All that I need is to display the same Internal Table data into PDF form output.
    Can anyone help me how to send this data(47 records in Internal table with 8 fields in Internal table) to PDF.
    Please help me out Experts with any suggestions.
    Thanks & Regards,
    Dileep .C

    Hi,
    if u pass your internal table to smartform we can achieve . because we can convert smartform output into pdf easily.
    Regards,
    karthikeyan k s,
    Edited by: karthikeyanks on Nov 19, 2010 12:58 PM

  • How to execute application server file from abap program

    Hi Friends,
    i have a requirement to execute application server file using abap program.
    i got a file directory like '/home/im3/hrintf/xxx.sh' , it's of unix file, so they want me to execute through abap program.
    pls suggest me with relevant logic.
    Thank you.
    Regards
    Ramesh M

    Define the external command in SM49/SM69
    Try with SXPG_CALL_SYSTEM or SXPG_COMMAND_EXECUTE
    Also check this link
    link:[Execute Unix Script|http://searchsap.techtarget.com/tip/0,289483,sid21_gci774071,00.html]

  • How to upload a PDF document from an e-mail attachment file and convert it to word document for edit

    I received an e-mail.The attachment is in PDF format. I would like to upload the file to convert it to word for editing.How to do that?

    Hi Quincy,
    You would need to save the file to your desktop and upload it from there for conversion using your ExportPDF subscription.
    Let me know if you need further assistance!
    Regards, Stacy

Maybe you are looking for