Quantcast
Channel: SCN : Blog List - ABAP Development
Viewing all articles
Browse latest Browse all 943

Web Service using ADOBE forms

$
0
0

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

 

1.jpg

 

 

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

 

2.jpg

3.jpg

 

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

 

1.jpg

Then activate and check the function module

 

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

 

1.jpg

 

Step 5: A Web Service Wizard  will be displayed

 

Give the Service name and Description

 

Press continue

 

1.jpg
Press continue

 

1.jpg
Press continue

 

1.jpg
Check local object or package name

 

Press continue

 

1.jpg
Press complete

 

1.jpg

Step 6: Now goto Transaction SOAMANAGER

 

The browser will start

 

Goto Tab Business Administration ->Web Service Administration

 

1.jpg
To find your webservice type your Service name in the Search  Pattern and then select your service then click

 

1.jpg
Step 7: Click Open WSDL Document for selected binding

 

1.jpg
A Browser Window opens with XML code

 

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

 

1.jpg

II . Create Adobe Forms

 

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

 

Goto the layout tab

 

Edit ->New data connections

 

1.jpg

 

Enter a New Data Connection Name

 

Select WSDL File and click next

 

1.jpg


  Paste your URL and press next

 

1.jpg

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 it's control type to Execute

 

1.jpg

In execute tab select your Data connection name

 

1.jpg

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

 

1.jpg
  activate the form

 

Step 5 : Create a print program for the form.

 

 

In the '####' place  paste 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 , then it fetches the description of the Material entered.


1.jpg

 

Please let me know if anyone face any issue while developing or testing it.

 

Thanks & Regrads,

Arun,

Arunkumar Chandrasekar,

Senior Consultant - SAP Practice @Kaavian Systems Pvt. Ltd.


Viewing all articles
Browse latest Browse all 943

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>