SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Development resources, articles, tutorials, code samples, tools and downloads for SAP HANA and ABAP, HANA Database, SQLScript, SAP UI5, Screen Personas, Web Dynpro, Workflow

Display Adobe Form in SAP Web Dynpro

To display Adobe Form in an SAP Web Dynpro component, the steps for an ABAP developer is the focus of this Web Dynpro tutorial. Web Dynpro programmer can use InteractiveForm layout element on a Web Dynpro component View to display Adobe Forms document. ABAP developer should set pdfSource property of the InteractiveForm element in WDDOMODIFYVIEW method of the related View.

In the following section of this SAP Web Dynpro tutorial, I will show how to store Adobe Form pdf data in Web Dynpro component context with ABAP codes and bind Adobe Form pdf context to InteractiveForm element pdfSource property.

If you do not prefer to display Adobe Form output embedded in a Web Dynpro popup screen, you can use the alternative method illustrated in Web Dynpro tutorial Display and Download Adobe Form as PDF File in SAP Web Dynpro

I assume the ABAP programmer create Adobe Forms using SAP transaction code SFP and the Adobe Form is ready. I will not also describe the steps to create a Web Dynpro component. I skip these two steps.

First create the required context to store Adobe Forms output pdf source data. As you can see in below screenshot, in Context tab of the Web Dynpro View I create a node named PDF. Then I added attribute ADOBE_FORM under PDF node. The Adobe_Form attribute has type XSTRING

Web Dynpro context for Adobe Form

Now on the Web Dynpro View, switch to Layout node. Under RootUIElementContainer, add a new InteractiveForm element.

Now, we need to bind PDF binary data to InteractiveForm element pdfSource property. Click on Binding column next to pdfSource attribute. Choose the ~.PDF.ADOBE_FORM context attribute as the data source of the Adobe Form element on Web Dynpro View layout.

display Adobe Form PDF in SAP Web Dynpro layout

In WDDOMODIFYVIEW method ABAP code block, we can create ABAP codes to get required parameter values for the Adobe Forms document. Query and store those parameter values on context node and context attribute values. I'll not illustrate these since all Adobe Forms outputs will require different input parameters.

If you want to display Adobe Form in pop up screen like I did in this case, control the first time of the View. Otherwise, when you click OK, or CANCEL, etc buttons on the pop up screen ABAP codes will run unnecessarily.
Within WDDOMODIFYVIEW method, be sure that you execute Adobe Forms code for the view is loaded for the first time. Use the following ABAP CHECK statement to control condition FIRST_TIME if it is equal to 'X' or ABAP_TRUE value.

* execute following code if view is loading for the first time
* check FIRST_TIME = 'X'.
check FIRST_TIME = ABAP_TRUE.
Code

If you are displaying Adobe Forms output on a Web Dynpro view other than pop up screens, ommit the above control.

Here are the summarized main steps verbally in below ABAP codes:
1) Open spool job,
2) Get Adobe Form function module name,
3) Call Adobe Form function module,
4) Store PDF binary data in Context,
5) Close spool job

*** DATA Definitions
* Adobe Forms function module name
data LV_ADOBEFORM_FM_NAME type RS38L_FNAM.

* return parameter values from Adobe Forms function module
* including binary PDF data
types TY_FPFORMOUTPUT type FPFORMOUTPUT.
data WA_FPFORMOUTPUT type TY_FPFORMOUTPUT.

* Form Processing Output Parameter
types TY_OUTPUTPARAMS type SFPOUTPUTPARAMS.
data WA_OUTPUTPARAMS type TY_OUTPUTPARAMS.

WA_OUTPUTPARAMS-DEVICE = 'PRINTER'.
WA_OUTPUTPARAMS-DEST = 'LOCL'.
WA_OUTPUTPARAMS-NODIALOG = 'X'.
WA_OUTPUTPARAMS-PREVIEW = 'X'.
WA_OUTPUTPARAMS-GETPDF = 'X'.

* open spool job
call function 'FP_JOB_OPEN'
 changing
  IE_OUTPUTPARAMS = WA_OUTPUTPARAMS
 exceptions
  CANCEL = 1
  USAGE_ERROR = 2
  SYSTEM_ERROR = 3
  INTERNAL_ERROR = 4
  others = 5.

* get function module name of the Adobe Forms
call function 'FP_FUNCTION_MODULE_NAME'
 exporting
  I_NAME = '/KODYAZ/SAMPLE_PROFORMA_FORM' " Adobe Form name
 importing
  E_FUNCNAME = LV_ADOBEFORM_FM_NAME.

* execute Adobe Forms function module and return PDF data
call function LV_ADOBEFORM_FM_NAME
 exporting
  PROFORMA_H = LV_PROFORMA_H
 importing
  /1BCDWB/FORMOUTPUT = WA_FPFORMOUTPUT.

*** Store PDF data in Context
**********************************************************************
data LO_ND_PDF type ref to IF_WD_CONTEXT_NODE.

data LO_EL_PDF type ref to IF_WD_CONTEXT_ELEMENT.
data LS_PDF type WD_THIS->ELEMENT_PDF.
data LV_ADOBE_FORM type WD_THIS->ELEMENT_PDF-ADOBE_FORM.

* navigate from <CONTEXT> to <PDF> via lead selection
LO_ND_PDF = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_PDF ).

* @TODO handle non existant child
* IF lo_nd_pdf IS INITIAL.
* ENDIF.

* get element via lead selection
LO_EL_PDF = LO_ND_PDF->GET_ELEMENT( ).

* @TODO handle not set lead selection
if LO_EL_PDF is initial.
endif.

* @TODO fill attribute
* Set context attribute value from Adobe Form function module return parameter
* which includes with PDF binary data
LV_ADOBE_FORM = WA_FPFORMOUTPUT-PDF.

* set single attribute
LO_EL_PDF->SET_ATTRIBUTE(
 NAME = 'ADOBE_FORM'
 VALUE = LV_ADOBE_FORM ).
**********************************************************************

* close spool job
call function 'FP_JOB_CLOSE'
 exceptions
  USAGE_ERROR = 1
  SYSTEM_ERROR = 2
  INTERNAL_ERROR = 3
  others = 4.
Code

This SAP Web Dynpro tutorial is showing how to display Adobe Forms output on a Web Dynpro popup screen. I hope this tutorial to be useful for ABAP developers on their Web Dynpro components where they consume and display Adobe Forms outputs.



SAP HANA and ABAP

Install SAP Free
CRM Companies List
Web Based CRM Software


Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.