Skip to Content
avatar image
Former Member

Display Smartform Pdf output in Webdynpro application

Hi All,

I want to display a smartform pdf output generated in SAP CRM using a Webdynpro application.

1. I have created a custom RFC to provide smartform pdf output in internal table(TLINE) format.

2. I have problems converting this data to pdf in Webdynpro.

Any sort of help is appreciated.

Thanks,

Anil

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    May 28, 2007 at 01:42 PM

    Hi Anil

    This is regarding my requirement , i have to display a smartform output in webdynpro. Your code is helpful to me, you will be rewarding full points. I have

    doubts in this code, can you please clarify them.

    1) executeZquote_Writer_Input(); -> is this is a built in function or we have to write some thing in that

    2) just explain me this bit of code

    String fileName = wdContext.currentZquote_Writer_InputElement().getOrder ().toString().trim() + System.currentTimeMillis() + ".pdf";

    String pdfOutput = new String(wdContext.currentOutputElement().getBinfile());

    if (pdfOutput != null)

    3) In this code where i have to mention the SMARTFORM name

    4) Where u r mentioning the smartform name explain me

    please reply asap

    regards

    jalandhar.

    Convert smartform output in to PDF using CONVERT_OTF function module and you can write pdf using parameter 'binfile' of this function in WebDynpro using the following code:

    It is copied from my prg. I hope you understand it.

    public void onActionGetQuote(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

    {

    //@@begin onActionGetQuote(ServerEvent)

    wdThis.wdGetOppt_QwriterCustController().executeZquote_Writer_Input();

    String fileName = wdContext.currentZquote_Writer_InputElement().getOrder().toString().trim() + System.currentTimeMillis() + ".pdf";

    String pdfOutput = new String(wdContext.currentOutputElement().getBinfile());

    if (pdfOutput != null)

    {

    try

    {

    String pdfResoucePath = WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart(), fileName);

    FileOutputStream fileOutputStream = new FileOutputStream(new File(pdfResoucePath));

    PrintStream ps = new PrintStream(fileOutputStream);

    ps.print(pdfOutput);

    ps.close();

    //Display the PDF to the browser

    String fileURL = WDURLGenerator.getAbsoluteWebResourceURL(wdComponentAPI.getDeployableObjectPart(), fileName);

    IWDWindow window = wdComponentAPI.getWindowManager().createExternalWindow(fileURL, "Pdf Browser", false);

    window.removeWindowFeature(WDWindowFeature.ADDRESS_BAR);

    window.removeWindowFeature(WDWindowFeature.MENU_BAR);

    window.removeWindowFeature(WDWindowFeature.STATUS_BAR);

    window.removeWindowFeature(WDWindowFeature.TOOL_BAR);

    window.open();

    // To collect all the file created in the server by user

    quoteFiles.add(quoteFiles.size(), pdfResoucePath);

    } catch (Exception e)

    {

    throw new WDRuntimeException(e);

    }

    }

    //@@end

    }

    ***************************************

    and then delete the file in resources when u close window.

    public void wdDoExit()

    {

    //@@begin wdDoExit()

    if (quoteFiles.size() > 0)

    {

    for (int i = 0; i < quoteFiles.size(); i++)

    {

    String filePath = quoteFiles.get(i).toString();

    if (filePath != null)

    {

    try

    {

    File file = new File(filePath);

    file.delete();

    } catch (Exception fe)

    {

    throw new WDRuntimeException(fe);

    }

    }

    }

    }

    //@@end

    }

    Cheers,

    Anil

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Jalandhar,

      1)executeZquote_Writer_Input(); This will be related to Bapi he is going to call to execute a smartform.

      2) just explain me this bit of code

      String fileName = wdContext.currentZquote_Writer_InputElement().getOrder ().toString().trim() + System.currentTimeMillis() + ".pdf";

      String pdfOutput = new String(wdContext.currentOutputElement().getBinfile());

      if (pdfOutput != null)

      He is getting the bin file from the context which is filled after Bapi call.

      3) In this code where i have to mention the SMARTFORM name

      In SAP systems whenever a smartform is created, a function module related to that smartform will be created automatically.

      Executing a smartform means executing that function module.And that function module is not remote enabled.

      Each function module generated will have different interfaces depending up on the parameters used in the smartform.

      So a remote enabled Function module need to be written in which smartform related FM can be called.

      Smartform name will be used in the RFM written by us.

      You can pass that name to this RFM through interface or you can hard code it there.

      4) Where u r mentioning the smartform name explain me

      He is doing it in the RFM written by them.

      So you cannot see that Web Dynpro code.

      Hope this will be helpful.

      Regards,

      Nagaraju Donikena

      Regards,

      Nagaraju Donikena

  • avatar image
    Former Member
    Jul 11, 2006 at 07:06 AM

    Hi

    Can you please let me know if you hace solved this issue.

    Me too require a similar kind of solution.

    Thank you

    With Wishes

    Krishna Kanth

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Anil,

      I am trying to display the smartform stored in SAP from webdynpro java. I am getting the binfle from the BAPI. I have implemented the codes provided by you but while running the application I am getting the null pointer exception.I am not able to retrieve the backend data.Can you provide with any possible solution for that.

      Looking forward to the reply.

      Regards,

      Pawan

  • avatar image
    Former Member
    May 29, 2007 at 04:20 PM

    Hi Anil

    can you please clarify these doubts in you below code

    1) What are the mandatory input and output parameters

    I have to pass here in this code to my application

    2) please check my previous post also in this regards please

    Looking for you. Please reply at the very earliest.

    -


    Convert smartform output in to PDF using CONVERT_OTF function module and you can write pdf using parameter 'binfile' of this function in WebDynpro using the following code:

    It is copied from my prg. I hope you understand it.

    public void onActionGetQuote(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

    {

    //@@begin onActionGetQuote(ServerEvent)

    wdThis.wdGetOppt_QwriterCustController().executeZquote_Writer_Input();

    String fileName = wdContext.currentZquote_Writer_InputElement().getOrder().toString().trim() + System.currentTimeMillis() + ".pdf";

    String pdfOutput = new String(wdContext.currentOutputElement().getBinfile());

    if (pdfOutput != null)

    {

    try

    {

    String pdfResoucePath = WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart(), fileName);

    FileOutputStream fileOutputStream = new FileOutputStream(new File(pdfResoucePath));

    PrintStream ps = new PrintStream(fileOutputStream);

    ps.print(pdfOutput);

    ps.close();

    //Display the PDF to the browser

    String fileURL = WDURLGenerator.getAbsoluteWebResourceURL(wdComponentAPI.getDeployableObjectPart(), fileName);

    IWDWindow window = wdComponentAPI.getWindowManager().createExternalWindow(fileURL, "Pdf Browser", false);

    window.removeWindowFeature(WDWindowFeature.ADDRESS_BAR);

    window.removeWindowFeature(WDWindowFeature.MENU_BAR);

    window.removeWindowFeature(WDWindowFeature.STATUS_BAR);

    window.removeWindowFeature(WDWindowFeature.TOOL_BAR);

    window.open();

    // To collect all the file created in the server by user

    quoteFiles.add(quoteFiles.size(), pdfResoucePath);

    } catch (Exception e)

    {

    throw new WDRuntimeException(e);

    }

    }

    //@@end

    }

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 06, 2007 at 01:12 PM

    Hi Nagaraju

    First lots of thanks for cliarifying the doubts. But the problem i s

    Mycode in this regard is not working. I have still some doubts in this answer. Can you please give me your contact number or your AOL id or any chat id or any personal id please. It is very urgent to discuss with you.

    Kindly give me these details.

    Lookingforward to you

    regards

    jalandhar.

    1)executeZquote_Writer_Input(); This will be related to Bapi he is going to call to execute a smartform.

    2) just explain me this bit of code

    String fileName = wdContext.currentZquote_Writer_InputElement().getOrder ().toString().trim() + System.currentTimeMillis() + ".pdf";

    String pdfOutput = new String(wdContext.currentOutputElement().getBinfile());

    if (pdfOutput != null)

    He is getting the bin file from the context which is filled after Bapi call.

    3) In this code where i have to mention the SMARTFORM name

    In SAP systems whenever a smartform is created, a function module related to that smartform will be created automatically.

    Executing a smartform means executing that function module.And that function module is not remote enabled.

    Each function module generated will have different interfaces depending up on the parameters used in the smartform.

    So a remote enabled Function module need to be written in which smartform related FM can be called.

    Smartform name will be used in the RFM written by us.

    You can pass that name to this RFM through interface or you can hard code it there.

    4) Where u r mentioning the smartform name explain me

    He is doing it in the RFM written by them.

    So you cannot see that Web Dynpro code.

    Hope this will be helpful.

    Regards,

    Nagaraju Donikena

    Add comment
    10|10000 characters needed characters exceeded