Create a FM that generates a PDF file.

Hello Evryone.
I have the following requirement.
I need to create a function module that given a Personnel Number would generate the payslip for that person based on an existing SE51 form and return the payslip as a PDF file, so that it could be used in WebDynpro.
Can any of you help me with this. How should I write this FM?
Thanks a lot in advance.
Francisco.

HI Please refer the following code for converting a smartform into a PDF file
DATA: BIN_FILESIZE TYPE I,
      BIN_FILE TYPE XSTRING,
     T_OTF  LIKE ITCOO OCCURS 200 WITH HEADER LINE,
      T_DOC  LIKE DOCS OCCURS 200 WITH HEADER LINE,
      T_LINES1 LIKE TLINE OCCURS 200 WITH HEADER LINE,
      T_FINAL_PDF LIKE TLINE OCCURS 500 WITH HEADER LINE,
filename TYPE string VALUE 'EXP.pdf',
      path TYPE string VALUE 'C:\DESKTOP\..',
      fullpath     TYPE string VALUE 'C:\DESKTOP\PDF\EXP.pdf',
CALL FUNCTION 'CONVERT_OTF_2_PDF'
  EXPORTING
    use_otf_mc_cmd               = 'X'
  ARCHIVE_INDEX                =
IMPORTING
    bin_filesize                 = bin_filesize
TABLES
    otf                          = t_otf
    doctab_archive               = t_doc
    lines                        = t_lines1
EXCEPTIONS
   err_conv_not_possible        = 1
   err_otf_mc_noendmarker       = 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.
  LOOP AT t_lines1 INTO t_lines1.
       APPEND t_lines1 TO t_final_pdf.
  ENDLOOP.
  CALL METHOD cl_gui_frontend_services=>file_save_dialog
    EXPORTING
      default_file_name   = 'EXPO_INVpdf'
      prompt_on_overwrite = 'X'
    CHANGING
      filename            = filename
      path                = path
      fullpath            = fullpath.
  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      bin_filesize = bin_filesize
      filename     = fullpath
      filetype     = 'BIN'
      append       = 'X'
    IMPORTING
      filelength   = bin_filesize
    TABLES
      data_tab     = t_final_pdf.
  IF sy-subrc EQ 0.
    MESSAGE s018(zmsg) WITH 'PDF Generated Successfully'.
  ELSE.
    MESSAGE s011(zmsg) WITH 'PDF Not Generated !!!'.
  ENDIF.

Similar Messages

  • After the last update that was pushed out by Adobe, my Acrobat 9 Pro will not generate a PDF file fr

    After the last update that was pushed out by Adobe, my Acrobat 9 Pro will not generate a PDF file from; [right click], Combine files into one PDF multiple files chosen in the explorer.  A message pops up asking if I want to run repair.  Answering in the afirmative results in another message stating files are missing.  And we are back at square one.

    What is the exact error?  Else you could always reinstall your software.

  • How to preserve a background color, when generating a PDF file

    I am trying to create a PDF file from some application. Please note that the picture in this application has the black background. So I invoke a Print command and set a printer as "Adobe PDF". As a result, I have generated
     a brilliant PDF file of my picture, but on the WHITE background. When selecting the Adobe PDF printer, I have looked through all its settings ( in the Adobe PDF settings, I have found several tabs: General, Images, Fonts, Color, Advanced, PDF/X), none of them generated the original background color. 
    So how can a generate a PDF file, having the original background color (black, in my case) ?
    Oleg

    Now I feel that the background definition in the Adobe PDF printer and the background definition in the application the Adobe PDF printer is invoked from -- two different things. So I guess how can I define the black background in the Adobe PDF printer? I cannot find such settings.

  • Parameter issue - report not generating any pdf files

    Hi All,
    I'm trying to run a report which generates pdf files. Is there any limitation on the parameter string size? For one of the parameter values - '11F EA Accept nonhonor ASnSOMnSON_20091201090150846' the report is not generating any pdf files. I assumed the reason is of the keyword 'AS' in it and created another parameter value - '11F EA Accept nonhonor AnS-SOM-SON_20091202074331997', but it is also not generating any pdf files. I get this message from Adobe Reader " There was an error opening this document. This file cannot be opened because it has no pages. " The report is working normally when i hardcode the same parameter values into the logic. Any suggestions on this?
    Thanks.
    Edited by: user1049091 on Dec 2, 2009 9:17 AM
    Edited by: user1049091 on Dec 2, 2009 12:37 PM

    Tim,
    That report is working normally for all the parameter values, except this one. It is not working only if i pass the value - ''11F EA Accept nonhonor ASnSOMnSON_20091201090150846' as a parameter. It is generating the pdf files when i hardcode the same value into sql query logic in the data template, instead of passing it as a parameter. Please advise.
    Thanks.

  • Images present in datagridview not exporting to file only text contents are generating into PDF file..

    Hi Everyone,
       I have created simple Desktop app in that I trying to generate PDF file from Datagridview...when I click on ExportPDf button Pdf file is generation successfully but the issue is in that pdf whatever the images has present in datagridview that images
    are not generation into PDF only the text contents are Present in PDF file.
      Does any one can tell me how to generate the PDF file along with images.
    Here is my code:
      private void btnexportPDF_Click(object sender, EventArgs e)
                int ApplicationNameSize = 15;
                int datesize = 12;
                Document document = null;
                try
                    SaveFileDialog savefiledg = new SaveFileDialog();
                    savefiledg.Filter = "All Files | *.* ";
                    if (savefiledg.ShowDialog() == DialogResult.OK)
                        string path = savefiledg.FileName;
                        document = new Document(PageSize.A4, 3, 3, 10, 5);
                        PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(path + ".pdf", FileMode.Create));
                        document.Open();
                        // Creates a phrase to hold the application name at the left hand side of the header.
                        Phrase phApplicationName = new Phrase("Sri Lakshmi Finance,Hosur-560068", FontFactory.GetFont("Arial", ApplicationNameSize, iTextSharp.text.Font.NORMAL));
                        // Creates a phrase to show the current date at the right hand side of the header.
                        Phrase phDate = new Phrase(DateTime.Now.ToLongDateString(), FontFactory.GetFont("Arial", datesize, iTextSharp.text.Font.NORMAL));
                        document.Add(phApplicationName);
                        document.Add(phDate);
                        iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance("D:\\logo.JPG");
                        document.Add(img);
                        iTextSharp.text.Font font5= iTextSharp.text.FontFactory.GetFont(FontFactory.TIMES_ROMAN, 5);
                        iTextSharp.text.Font font6 = iTextSharp.text.FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 6);
                        //float[] columnDefinitionSize = { 2.5f, 7.0f,6.6f, 8.6f, 6.6f, 5.0f, 4.5f, 7.0f, 6.3f, 7.0f, 3.5f, 6.0f, };
                        PdfPTable table = null;
                        table = new PdfPTable(dataGridView1.Columns.Count);
                        table.WidthPercentage = 100;
                        PdfPCell cell = null;
                        foreach (DataGridViewColumn c in dataGridView1.Columns)
                            cell = new PdfPCell(new Phrase(new Chunk(c.HeaderText,font6)));
                            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                            cell.VerticalAlignment = PdfPCell.ALIGN_CENTER;
                            cell.BackgroundColor = new iTextSharp.text.BaseColor(240, 240, 240);
                            table.AddCell(cell);
                        if (dataGridView1.Rows.Count > 0)
                            for (int i = 0; i < dataGridView1.Rows.Count; i++)
                                PdfPCell[] objcell = new PdfPCell[dataGridView1.Columns.Count];
                                for (int j = 0; j < dataGridView1.Columns.Count - 0; j++)
                                    cell = new PdfPCell(new Phrase(dataGridView1.Rows[i].Cells[j].Value.ToString(), font5));
                                    cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                                    cell.VerticalAlignment = PdfPCell.ALIGN_LEFT;
                                    cell.Padding = PdfPCell.ALIGN_LEFT;
                                    objcell[j] = cell;
                                PdfPRow newrow = new PdfPRow(objcell);
                                table.Rows.Add(newrow);
                        document.Add(table);
                        MessageBox.Show("PDF Generated Successfully");
                        document.Close();
                    else
                        //Error 
                catch (FileLoadException fle)
                    MessageBox.Show(fle.Message);
                    MessageBox.Show("Error in PDF Generation", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    Runtime Gridview content:
    Generated PDF File:
    Thanks & Regards RAJENDRAN M

    Hi Everyone,
       I have created simple Desktop app in that I trying to generate PDF file from Datagridview...when I click on ExportPDf button Pdf file is generation successfully but the issue is in that pdf whatever the images has present in datagridview that images
    are not generation into PDF only the text contents are Present in PDF file.
      Does any one can tell me how to generate the PDF file along with images.
    Here is my code:
      private void btnexportPDF_Click(object sender, EventArgs e)
                int ApplicationNameSize = 15;
                int datesize = 12;
                Document document = null;
                try
                    SaveFileDialog savefiledg = new SaveFileDialog();
                    savefiledg.Filter = "All Files | *.* ";
                    if (savefiledg.ShowDialog() == DialogResult.OK)
                        string path = savefiledg.FileName;
                        document = new Document(PageSize.A4, 3, 3, 10, 5);
                        PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(path + ".pdf", FileMode.Create));
                        document.Open();
                        // Creates a phrase to hold the application name at the left hand side of the header.
                        Phrase phApplicationName = new Phrase("Sri Lakshmi Finance,Hosur-560068", FontFactory.GetFont("Arial", ApplicationNameSize, iTextSharp.text.Font.NORMAL));
                        // Creates a phrase to show the current date at the right hand side of the header.
                        Phrase phDate = new Phrase(DateTime.Now.ToLongDateString(), FontFactory.GetFont("Arial", datesize, iTextSharp.text.Font.NORMAL));
                        document.Add(phApplicationName);
                        document.Add(phDate);
                        iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance("D:\\logo.JPG");
                        document.Add(img);
                        iTextSharp.text.Font font5= iTextSharp.text.FontFactory.GetFont(FontFactory.TIMES_ROMAN, 5);
                        iTextSharp.text.Font font6 = iTextSharp.text.FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 6);
                        //float[] columnDefinitionSize = { 2.5f, 7.0f,6.6f, 8.6f, 6.6f, 5.0f, 4.5f, 7.0f, 6.3f, 7.0f, 3.5f, 6.0f, };
                        PdfPTable table = null;
                        table = new PdfPTable(dataGridView1.Columns.Count);
                        table.WidthPercentage = 100;
                        PdfPCell cell = null;
                        foreach (DataGridViewColumn c in dataGridView1.Columns)
                            cell = new PdfPCell(new Phrase(new Chunk(c.HeaderText,font6)));
                            cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                            cell.VerticalAlignment = PdfPCell.ALIGN_CENTER;
                            cell.BackgroundColor = new iTextSharp.text.BaseColor(240, 240, 240);
                            table.AddCell(cell);
                        if (dataGridView1.Rows.Count > 0)
                            for (int i = 0; i < dataGridView1.Rows.Count; i++)
                                PdfPCell[] objcell = new PdfPCell[dataGridView1.Columns.Count];
                                for (int j = 0; j < dataGridView1.Columns.Count - 0; j++)
                                    cell = new PdfPCell(new Phrase(dataGridView1.Rows[i].Cells[j].Value.ToString(), font5));
                                    cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                                    cell.VerticalAlignment = PdfPCell.ALIGN_LEFT;
                                    cell.Padding = PdfPCell.ALIGN_LEFT;
                                    objcell[j] = cell;
                                PdfPRow newrow = new PdfPRow(objcell);
                                table.Rows.Add(newrow);
                        document.Add(table);
                        MessageBox.Show("PDF Generated Successfully");
                        document.Close();
                    else
                        //Error 
                catch (FileLoadException fle)
                    MessageBox.Show(fle.Message);
                    MessageBox.Show("Error in PDF Generation", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    Runtime Gridview content:
    Generated PDF File:
    Thanks & Regards RAJENDRAN M
    Hello,
    Since this issue is mainly related to iTextSharp which belongs to third-party, I would recommend you consider posting this issue on its support website to get help.
    Maybe the following forum will help.
    http://support.itextpdf.com/forum/26
    Regards,
    Carl
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Unable to generate a PDF file for 1 of 3 books

    I'm making three documents (books) in FrameMaker and then converting to PDF. The first two books generated to PDF with no "major" problems. There were a couple of glitches here and there but most were simply operator error. This forum solved two of my problems.
    Now, with the third book, I can't generate the PDF and get error messages in the log file. I've gone back and triple checked everything and can't find a thing that's different between this last book and the first two. I've used the same templates and all of the paragraph formats and character formats are identical in all three documents.
    I'm setting all of the PDF setup parameters the same. In the Adobe PDF setup, I've made certain that the "Rely on system fonts only..." check box is unchecked.
    One of the error messages in the log file says,
          %%[ Warning: LucidaSans cannot be embedded because of licensing restrictions. ]%%
          %%[ Font vendor (B&H) does not permit this font to be embedded in PDF. ]%%
    This would make sense if Lucida Sans font were only used in this one book. But it's used in the first two books as well and they generate as PDF with no problems. In fact, just to make sure, I went back and generated one of the first books over again and it worked perfectly.
    The only significant (?) difference in the third book is that it is much larger than the first two. It runs to 150 pages while the first two are 45 pages and 70 pages. But I've worked with books as large as 450 pages in the past.
    I've been creating the PDF documents by the FM Save as PDF feature. But because of this problem, I downloaded and installed a trial version of Acrobat X. Then printed to PS file, opened with Acrobat and tried to distill. Got the same results and the same error messages.
    My experience with FrameMaker and Adobe in general is that error messages and indicated results may be cryptic and sometimes have absolutely nothing to do with the actual problem. In any event, I'm totally snowed by this one. (I really shouldn't pick on Adobe for that. Microsoft is much worse when it comes to vague and cryptic error messages!)
    Sure wish I had a Mac right now. Or Linux. Or...

    Thank you very much for the input. That makes perfect sense to me. The Lucida fonts are, indeed, all from Bigelow & Holmes (B&H). So that explains the difficulties I was encountering. Now, here’s where it gets a little weird.
    I created the first two pdf files at work. I work about half of the time from home and was trying to create the pdf file yesterday at home. And that didn’t work. This morning, I loaded all of the files back into the computer in the office and tried again. No problem! Created a nice looking 162-page pdf file. Oh, I did say it got weird, didn’t I? Well, the computer at home and the one at work are both running the same version of Win 7 Pro, the same versions of FM10 and Acrobat X. And the Lucida fonts installed (probably the default set with Windows) are all B&H fonts. That’s right; the same on both computers.
    Your input was very helpful because I might have continued spinning my wheels for another day or so on this thing. As it is, I’m considering the matter solved because I just won’t try to make pdf files from these three documents at home. The other alternative would be to use a different font. Umm, no, not at this time. All of the body paragraphs are Lucida Sans. What a task that would be! The other alternative, of course, is to spend a few bucks and by fonts for my home computer that have the proper licensing.
    Again, thanks!

  • Generate a PDF file

    Hi all
    I am trying to generate a PDF file from the browser contents(html).
    if i give the mime type as owa_util.mime_header(ccontent_type => 'application/vnd.ms-excel'); i am able to genetate a excel file
    but on the other hand if i use owa_util.mime_header(ccontent_type => 'application/pdf');
    i thoucht that i will et pdf output but
    nothing happens
    i am using pl/sql language to generate this code (i mean it is a pl/sql portlets).
    can any one help me on this plz.
    thanks
    Balaganesh

    hi, Jaber,
    The basic coding is listed as following:
    package mypackage1;
    import com.lowagie.text.Image;
    import com.lowagie.text.Element;
    import com.lowagie.text.Document;
    import com.lowagie.text.DocumentException;
    import com.lowagie.text.PageSize;
    import com.lowagie.text.Paragraph;
    import com.lowagie.text.Rectangle;
    import com.lowagie.text.html.HtmlWriter;
    import com.lowagie.text.pdf.PdfWriter;
    import com.lowagie.text.rtf.RtfWriter2;
    import com.lowagie.text.Image;
    import com.lowagie.text.pdf.PdfPCell;
    import com.lowagie.text.pdf.PdfPTable;
    import java.awt.Color;
    import com.lowagie.text.pdf.BaseFont;
    import com.lowagie.text.Font;
    import com.lowagie.text.Chunk;
    import com.lowagie.text.pdf.BarcodeEAN;
    import com.lowagie.text.pdf.PdfContentByte;
    public class Servlet1 extends HttpServlet
    public void doGet (HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
    // step 1
    // Create new document with A4 pagesize and standard margins: Left(3.18cm), Right(3.18cm), Top(2.54cm), Bottom(2.54cm).
    Document document = new Document(PageSize.A4, 93, 93, 72, 72);
    try {
    // step 2
    // Set the ContentType and create an instance of the corresponding Writer
    response.setContentType("application/pdf");
    PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream());
    //Define Chinese fonts.
    BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
    Font font_section = new Font(bfChinese, 12, Font.NORMAL|Font.BOLD);
    // step 3
    // Open the document
    document.open();     
    // step 4
    // Add the text.
    Paragraph application_name = new Paragraph("System Account Application Form", font_application);
    application_name.setAlignment(Element.ALIGN_CENTER);
    application_name.setSpacingAfter(10);
    document.add(application_name);
    catch(DocumentException de) {
    de.printStackTrace();
    System.err.println("document: " + de.getMessage());
    // step 5: we close the document (the outputstream is also closed internally)
    document.close();
    thanks
    George
    My HK travel blog: http://hktour.blogspot.com
    (Update daily)

  • Generate a PDF file Using Adobe Document Service

    Hi All,
    How can I generate a PDF file using Adobe Document Service? The content of the PDF can be from any DataSource (Oracle/ BW/ R3 ).
    Can anyone get me some information.Points will be rewarded
    Thanks in advance
    Deepak Raj

    Hi Raj,
    You can look into this blog
    Creating your first application using Interactive forms
    If you get your answer ...set the thread as "answered"
    Regards,
    Sekhar

  • Automatically Generate a PDF File and a Paper Copy

    Is it possible to generate a PDF file automatically when a report is printed to paper?  I don't want the users to print to paper in one process then have to print a second time to a PDF file because that step will be forgotten.

    Hi Layne,
    I haven't heard of something like this. I'm sure CR does not have this functionality, however there could be third party add-ons for CR that could do this.
    -Abhilash

  • Idoc types that generate the log files

    Hi All,
    Can anybody provide me the list of IDOC types that generated application log files.
    As I found that material master IDOCs generate log files. Is there IDOC types other
    than material master that generate log files.
    Regards,
    Azra.

    Hi Azra,
    You can tell whether an IDOC does create the application log from the function module it uses.
    Go to SE37, and type in IDOC_INPUT_<message_type> for inbound or IDOC_OUTPUT_<message_type> for outbound, and search for any function module which start with 'BAL_'. If you can find it, then it creates application log files.
    Regards,
    Lim...

  • Acrobat 8 Professional can't find the scanning device when creating the second page of the PDF file

    Hey guys, this is my first post here, so please excuse me if there is anything I need to know.
    I am a Mac User and I have the whole CS3 suit installed.
    Everything works just great except there is this little thing bugs me around.
    When I try to use Acrobat Professional 8.0 to create a PDF file through my scanner, (samsung SCX-4725FN, it's scan/print/fax combined) I wouldn't be able to continue to scan to the second page. To be more specific, I have no problem to scan and create the first page of the PDF file, when it asks me if I want to scan and create another page, when I confirmed it, I wouldn't be able to see the scanner in the "Acrobat Scan" window. The "scan" botton stay faded, therefore I can't continue. If I click "cancel" and try to create another PDF file from the scanner, the smae problem will show up again. The only way that I can continue to scan is to quit the program from the menu bar and restart it, then I can start to create the next '1st page only' PDF file from the scanner. I had to do this rapidly to get all the pages scanned first, and then combine them to get my work done. This is a pain in the butt. I have downloaded the most updated scanner driver, and patched Acrobat to version 8.1.2 , but the problem still exist. I have tested the scanner with PS CS3, the scanner works just fine. So I assume there is a glitch here with the software. Can anyone help me please?

    I am not very clear at which step you are facing issue. Below is the sequence in order to scan more pages from Acrobat:
    1. Launch Acrobat. Click menu File->Create PDF->From Scanner....
    2. "Acrobat Scan" dialog will appear. Select your scanner installed in Scanner dropdown. Check 'Prompt for scanning more pages' checkbox as you want to scan more than one page. Click Scan button in "Acrobat Scan" dialog.
    3. Now scanner UI will appear. Make setting like color mode/resolution and click Scan button(or may be Accept button) in this dialog. (This is scanner specific ui)
    4. After this scanning will happen and "Acrobat Scan" dialog will appear with "Scan is Complete" and "Scan more pages" option.
    5. Select "Scan more pages" option and click OK in this dialog to scan more pages.
    6. Now again scanner UI will appear as in step 3 above. Make your settings and proceed.
    Do you see scanner UI or "Acrobat Scan" dialog in step6? Are you not able to click Scan(or Accept) button in scanner UI?

  • Generate to PDF file anomaly

    The generate to PDF file option produces duplicate rows for fields in the lowest level group under the following circumstances:
    1. Report has been run to the viewer and the viewer window is open.
    2. The PDF file to be produced does not exist already.
    If the PDF file is then generated a second time, no duplicate rows are produced.
    Also, when the PDF file to be produced does not exist already, if the PDF file is generated after the report has been run to the viewer but the viewer window has been closed, no duplcate rows are produced.
    Is this a Reports bug or is there something in my report I should address? We are running Report Builder 6.0.8.23.0

    sounds like a bug, however make sure you are on the latest patchset and it still reproduces there. then you need to open a service request with oracle support services and they will, in case this issue is not already logged as one, create a bug for this.
    thanks,
    ph.

  • Each page of Oracle Report Generates separate pdf file.

    I have a problem that i want that oracle report runs for one time and generates sepatate pdf files for each oracle report page.eg. if there are 8 page of report then 8 pdf files should generate (one pdf file for each page) but the condition is that the print job is set to NO and page range should not be given each time.

    What version of Reports are you using?
    If it's 10g then have a look at Report Bursting as this should enable you to send the report to multiple files based on a repeating group.
    Mark

  • I have tried a lot to find an app or some way in email to attach multiple of pdf files in one email. I could not find anything that sends multiple pdf file in one email and still keeping the file in simple pdf format for the recipient.

    I have tried a lot to find an app or some way in email to attach multiple of pdf files in one email. I could not find anything that sends multiple pdf file in one email and still keeping the file in simple pdf format for the recipient.

    I am not aware of a way except for photos that allows you to select multiple files in an email. I even checked settings in the Adobe Reader app, and it does not show that ability.

  • 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]

Maybe you are looking for