Skip to Content

Let discuss the PO creation steps using gateway services in detail.

Step1. Open Tcode SEGW and create a project as shown in below.

/wp-content/uploads/2016/03/1_900546.png

Give the details as shown  below .

/wp-content/uploads/2016/03/2_900547.png

Step 2. Create the first entity by importing an RFC interface. For this right-click on Data Model and choose Import -> RFC/BOR Interface.

/wp-content/uploads/2016/03/3_900549.png

Step 3. Enter the following values in the wizard and then choose next:

Entity Type Name

PurchaseOrder

Target System

Local

Data Source Type

Remote Function Calls

Data Source Name

bapi_po_getdetail

/wp-content/uploads/2016/03/4_900550.png

Step 4. Expand the PO_HEADER node and select the following fields:
POHEADER,COMPANYCODE,DOC_CAT,DOC_TYPE,STATUS,VENDOR,PURCH_ORG,PUR_GROUP and Choose Next.



/wp-content/uploads/2016/03/5_900555.png

Step 5. In the first line, PO_NUMBER, select the field Is Key and choose Finish:

/wp-content/uploads/2016/03/6_900556.png

Step 6. Create the second entity again by importing an RFC interface. Right-click Data Model and choose Import -> RFC/BOR Interface

/wp-content/uploads/2016/03/7_900560.png

Step 7. Enter the following values in the wizard and choose next:

Entity Type Name

PurchaseOrderItem

Target System

Local

Data Source Type

Remote Function Calls

Data Source Name

BAPI_PO_GETITEMS   

/wp-content/uploads/2016/03/8_900561.png

Step 8. Expand the PO_ITEMS node and select the following fields:
po_item,material,pur_mat,mat_grp,net_price,price_unit,disp_quan
Choose Next.

     /wp-content/uploads/2016/03/9_900562.png

/wp-content/uploads/2016/03/10_900569.png

Step 9.Now our project has 2 entities – one for the Purchase Order and one for the Purchase Order Item. As a next step we create entity-sets out of these entities. Expand the node Data Model and double-click Entity Sets:

Name

Entity Type Name

PurchaseOrderSet

PurchaseOrder

PurchaseOrderItemSet

PurchaseOrderItem

/wp-content/uploads/2016/03/11_900570.png

Step 10.Now the basic definition of the Model is done. As a next step we can generate the necessary runtime artifacts.

a.     Click on the Generate pushbutton:

b.     Leave the default values and choose Enter:

/wp-content/uploads/2016/03/12_900617.png

Please note the Technical Service Name ZPURCHASEORDER_SRV is equal to the External Service Name required to consume this service later on. 

c .Choose Local Object.

d. Runtime objects have been generated successfully now.

  Step 11.Now we can Register and Activate the Service.

a. Double-click Service Maintenance

/wp-content/uploads/2016/03/13_900618.png

b. Select system EC7 and click on the Register button. Please note that the entries listed here depend on the System Alias configuration you have done in the SAP Net Weaver Gateway Implementation Guide (IMG). In a local deployed environment (Backend and Hub components deployed on the same box) you might also find “LOCAL” with the RFC destination “NONE” here

/wp-content/uploads/2016/03/14_900619.png

c. Confirm the warning message displayed in the popup: click yes

d.Press F4 to select the system alias. Select LOCAL from the input held.

e.Confirm the Select System Alias popup: click ok

f. Leave the default values and enter $tmp as the package and choose Enter:

/wp-content/uploads/2016/03/15_900623.png

The External Service Name is defaulted with the Technical Service Name from the Generation Step

g. Verify that the service has been registered and activated successfully:

/wp-content/uploads/2016/03/16_900624.png

Step 12.Now we can run our service the first time. Please note that we’ve only maintained the basic model data so far. As a consequence we can access the metadata of the service,

a. Open a new window, start transaction /IWFND/GW_CLIENT.

b. Enter URI:  /sap/opu/odata/sap/ ZPURCHASEORDER_SRV /$metadata and choose Execute

/wp-content/uploads/2016/03/17_900625.png

Step 13.ZPURCHASEORDER_SRV is External Service Name that was registered before.

We have created a Service Builder Project with two entities and two entity-sets. We have generated the runtime artifacts and registered and activated our OData service.

Step 14.Now we will map the data provider to bring life into our OData service.

(i)Get the PO header data

  • We will start with the Query method for the PurchaseOrderSet entity-set. Expand the node Service Implementation -> PurchaseOrderSet and right-click GetEntity (Read) and select Map to Data Source:

/wp-content/uploads/2016/03/18_900629.png

  • In the map to data source window, enter the following values and choose Enter:

Target System

Local

Data Source Type

Remote Function Call

Data Source Name

bapi_po_getdetail

/wp-content/uploads/2016/03/19_900630.png

  • Map the output parameters by dragging the fields from the model on right side. Also create an input parameter for providing the PO to the RFC. Choose Enter:

Mapping will look like,

/wp-content/uploads/2016/03/20_900631.png

Then Save.

We are done with getting the PO header details.

(ii). Now, we need to get the lines item based on given purchase order number.

For this, we will create operation in entity set PurchaseOrderItemSet.

  • We will start with the Query method for the PurchaseOrderItemSet entity-set.
  • Expand the node Service Implementation – PurchaseOrderItemSet and right-click GetEntitySet (Query) and select Map to Data Source:

/wp-content/uploads/2016/03/21_900635.png

  • Provide Data source name as ‘BAPI_PO_GETITEMS’ and Data source type as ‘Remote Function Call’.
  • Map the output parameters by dragging the fields from the model on right side. Also create an input parameter for providing the PO to the RFC. Choose Enter:

/wp-content/uploads/2016/03/22_900636.png

  • Regenerate the artifacts.

Testing the Service:

Select the registered service and click on gateway client.

/wp-content/uploads/2016/03/23_900637.png

Sample Case 1: For getting PO HEADER DATA provide

/sap/opu/odata/SAP/ZPURCHASEORDER_SRV/PurchaseOrderSet(‘3000000004’) and click on execute.

/wp-content/uploads/2016/03/24_900641.png

/wp-content/uploads/2016/03/25_900642.png

Sample Case 2: For getting PO ITEM DATA provide /sap/opu/odata/SAP/ZPURCHASEORDER_SRV/PurchaseOrderItemSet?$filter=PoNumber eq ‘3000000004’ and click on execute

/wp-content/uploads/2016/03/26_900644.png

/wp-content/uploads/2016/03/27_900645.png

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Tom Ryan

    Thank you for this detailed tutorial using Gateway.  This is very helpful in getting started with Gateway.

    I am encountering an error in the PurchaseOrderSet within the GetEntitySet mapping.  The error states “No output table is mapped in the query operation”.  I’m an trying to determine why I am receiving this error since the PO_HEADER structure is being returned.  Do you have any suggestions?

    Thanks in advance,
    Tom

    (0) 
    1. Jahnavi Teja Venati Post author

      Hi Tom,

      Thank you ,

      I think there is some wrong mapping done for input to outputs.

      Can you please check with the mapping part .

      Thanks for understanding,

      Jahnavi Venati

      (0) 

Leave a Reply