EDUCAÇÃO E TECNOLOGIA

Post Request for Adobe Form Generation with OData Version 4

In blog post “Download File through NetWeaver Gateway with OData Version 4” I showed you how you can download a file via NetWeaver Gateway with OData Version 4. Now I would like to present you how you can generate an adobe form via post request. The result is that we have an entry in ZDEMO database table and the key of the entry is in the response of the OData Request.

The next sections contain following topics:

  1. preliminary work
  2. implementation of a model provider
  3. implementation of a data provider
  4. test
  5. conclusion

In my case the system conditions were during the implementations as follows:

Component Release SP-Level Support Package Short Description
SAP_GWFND 754 0000 SAP Gateway Foundation
SAP_UI 754 0002 SAPK-75402INSAPUI User Interface Technology

Embedded Scenario

How you can register and publish a OData Service in SAP was already explained in blog post “Download File through NetWeaver Gateway with OData Version 4”

Before we start with the OData Implementation, we will create for our case a simple Adobe Form without any variables with a simple interface.

Simple%20Adobe%20Form

Simple Adobe Form

Simple%20Adobe%20Form%20Interface

Simple Adobe Form Interface

For our OData Model I created a following structure

OData%20Model%20-%20Structure

OData Model – Structure

The DOC_RECN field will be the key for the generated Adobe Form. This key corresponds to the key of the ZDemo Databse Table. See blog post.

The DOC_RECN will be set in the POST Request as response. The table AFCONTAINERTOAFNAV contains additional data for the adobe form generation. Here a simple example.

Line%20Type%20of%20ZSDEMO_ODATAV4_AF_TAB

Line Type of ZSDEMO_ODATAV4_AF_TAB

Now we can start with our Model Implementation.

We enhance our Model Provider Class from blog post.

Model%20Provider%20Class%20%u2013%20Define%20Method

Model Provider Class – Define Method

Model%20Provider%20Class%20%u2013%20Define%20Adobe%20Form%20Method

Model Provider Class – Define Adobe Form Method

Model%20Provider%20Class%20%u2013%20Define%20Container%20Adobe%20Form%20Method

Model Provider Class – Define Container Adobe Form Method

For our stucture I use navigation properties for our Adobe Form Data.

That’s all. The Model for Adobe Form generation is finished.

We enhance our Data Provider Class from blog post.

In this class we redefine the method /IWBEP/IF_V4_DP_ADVANCED~CREATE_ENTITY

Data%20Provider%20Class%20%u2013%20Create%20Entity%20Method

Data Provider Class – Create Entity Method

Delegate to a private Method

Data%20Provider%20Class%20%u2013%20Create%20Entity%20Af%20Deep%20Method%20Part%20I

Data Provider Class – Create Entity Af Deep Method Part I

Data%20Provider%20Class%20%u2013%20Create%20Entity%20Af%20Deep%20Method%20Part%20II

Data Provider Class – Create Entity Af Deep Method Part II

Data%20Provider%20Class%20%u2013%20Create%20Entity%20Af%20Deep%20Method%20Part%20III

Data Provider Class – Create Entity Af Deep Method Part III

This method reads the request, generate an Adobe Form, creates an entry for our ZDEMO Database table. It sets also the document key into the response which is necessary for the consumer of this service. Afterwards the consumer can call a GET URL with that key to get the document as download file.

Befort we can test our small example we need to ensure that our OData Service is registered and published. See blog post.

Let’s test it with ARC Client. I installed the chorme app. I set the Method to POST and the path: AfContainerSet the Body looks like this:

{
“DocRecn”: “00000000-0000-0000-0000-000000000000”,
“AfContainerToAfNav”: [
{
“Data”: “00003”
}
]
}

POST%20Request%20-%20Part%20I

POST Request – Part I

With an external Break Point you can debugg your code:

POST%20Request%20-%20Part%20II

POST Request – Part II

Result of the response:

POST%20Request%20-%20Part%20III

POST Request – Part III

Result in our ZDEMO Database Table

POST%20Request%20%u2013%20Part%20IV

POST Request – Part IV

This example shows you how you can implememt an Adobe Form Generation through SAP Gateway with OData Service 4.0.

I hope you liked it.

Please, let me know what you are thinking about it.