Tuesday, February 8, 2011

Using Web Services in Adobe Forms

Scenario: Fetching the Material Description for a Material in Adobe Form using Web Service.

Consider a Scenario User enters a Material Number in a Adobe Form and the Material Description has to be fetched from the Material master table , for this we use web service to fetch the description.

I. Create a Web Service:

Step 1: we need to create a Remote enable function module

Step 2 : Define one Import parameter material number(MATNR) and Two Export parameter material Description (MAKTX) and BAPIRETURN (Mandatory)

Step 3: Write the code for to fetch the material description in source code.

Then activate and check the function module

Step 4: Goto the Utilities->More utilities->Create web service->From the function module

Step 5: A Web Service Wizard will be displayed

Give the Service name and Description

Press continue

Press continue

Press continue

Check local object or package name

Press continue

Press complete

Step 6: Now go to Transaction SOAMANAGER

The browser will start

Go to Tab Business Administration ->Web Service Administration

To find your web service, type your Service name in the Search Pattern and then select your service then click

Step 7: Click Open WSDL Document for selected binding

A Window opens with XML code

Copy the URL, This URL is the generated WSDL Link.



II . Create Adobe Forms

Step 1 : Then go to the transaction SFP and create a empty interface then create a form

Go to the layout tab

Edit ->New data connections

Enter a New Data Connection Name

Select WSDL File and click next

Paste your URL and press next

Step 2: Select your web service and press finish

The web service is added to the form.

Step 3: In layout to create a new button and change its control type to Execute

In execute tab select your Data connection name

Step 4: Drag and drop the MATNR and MAKTX fields to the Form.

Activate the form

Step 5: Create a print program for the form.

In the '####' place, enter your form name

 data: ie_outputparams type sfpoutputparams.
data: i_name type fpname,
i_funcname type funcname.
data: fp_docparams type sfpdocparams.
data: fp_formoutput type fpformoutput.
data: data_tab type SOLIX_TAB.
ie_outputparams-getpdf = 'X'.
ie_outputparams-nodialog = 'X'. " suppress printer dialog popup
call function 'FP_JOB_OPEN'
changing
ie_outputparams = ie_outputparams.
try.
i_name = '######################'. "Your Form Name
 call function 'FP_FUNCTION_MODULE_NAME'
exporting
i_name = i_name
importing
e_funcname = i_funcname.
catch cx_fp_api_repository.
catch cx_fp_api_usage.
catch cx_fp_api_internal.
endtry.
fp_docparams-langu = 'E'.
fp_docparams-country = 'US'.
fp_docparams-FILLABLE = 'X'.
call function i_funcname
exporting
/1bcdwb/docparams = fp_docparams
importing
/1bcdwb/formoutput = fp_formoutput
exceptions
usage_error = 1
system_error = 2
internal_error = 3.
 call function 'FP_JOB_CLOSE'
exceptions
usage_error = 1
system_error = 2
internal_error = 3
others = 4.
 data: filename type string,
path type string,
fullpath type string,
default_extension type string value 'PDF'.
cl_gui_frontend_services=>file_save_dialog(
exporting
default_extension = default_extension
changing
 filename = filename
path = path
fullpath = fullpath ).
check fullpath is not initial.
 call function 'SCMS_XSTRING_TO_BINARY'
exporting
buffer = fp_formoutput-pdf
tables
binary_tab = data_tab.
 cl_gui_frontend_services=>gui_download(
exporting
filename = filename
filetype = 'BIN'
changing
data_tab = data_tab ).
cl_gui_frontend_services=>execute(
exporting
document = filename ).

Output:

Step 6: Run the print program and then save the pdf form in your drive or desktop, then open the form using the Adobe Reader (7.0 or above).

Give the material number and press description Button; it fetches the description of the Material entered.




No comments:

Tutorials on SAP-ABAP

Adobe Interactive Forms Tutorials

Business Server Pages (BSP)

Userexits/BADIs

Web Dynpro for ABAP (Step by step procedure for web dynpro,Tutorials on Web Dynpro,)

ALV Tutorials

Blog Archive

goodsites