Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

In the previous blog we have seen the GET (Read ) operation and the various query options available along with it of Purchase Contract API.


In this blog we will cover the POST operation and Create a new Purchase contract.


Again navigate to Purchase Contract ODATA API in the API hub.



Select the POST operation of A_PurchaseContract (Purchase Contract Header).


Click on Try out, you will see a sample payload. This sample payload can be edited with the data with which you want to create the Purchase Contract.



The sample payload template have Header Data , Item Data , Conditions Data (This can be removed as the base condition will be created by default with the Net Price) Address and Partner Data.


Kindly note that by default the Contract template is pre filled with value "string" ,so remove the string value or you might get errors related to string not be able to get converted to number errors (depends upon the field). Either remove the fields which are not required or clear out the string value. Also note that all Boolean fields should have the value true or false without the quotes (" ").


It is required to send the X-CSRF-TOKEN for any POST request , to fetch a X-CSRF-TOKEN we can use a GET request and fetch the X-CSRF-TOKEN from the backend.


Select the GET A_PurchaseContract and click on Add and then select Header.




Enter Header Name as X-CSRF-TOKEN and Header Value as FETCH and EXECUTE.




With GET request response in the Request Header we will get CSRF token which then can be used in our POST calls.




Come back to Your POST request , enter CSRF token and execute.


If the contract creation is successful , you will get the 201 response and the response payload will have the newly created contract details.


In the below snapshot you can see that Purchase Contract 4600000351 was created .



If there's an error that can be seen in the response body and then can be corrected.


Sample Payload-


{


"PurchaseContract": "",


"PurchaseContractType": "MK",


"CompanyCode": "1010",


"PurchasingDocumentDeletionCode": "",


"CreationDate": "/Date(1580959800000)/",


"CreatedByUser": "",


"Supplier": "10300001",


"PurchasingOrganization": "1010",


"PurchasingGroup": "001",


"PaymentTerms": "0004",


"CashDiscount1Days": "0",


"CashDiscount2Days": "0",


"NetPaymentDays": "0",


"CashDiscount1Percent": "0",


"CashDiscount2Percent": "0",


"DocumentCurrency": "EUR",


"ExchangeRate": "",


"ExchangeRateIsFixed": false,


"ValidityStartDate": "/Date(1580959800000)/",


"ValidityEndDate": "/Date(1583465400000)/",


"QuotationSubmissionDate": "/Date(1580959800000)/",


"CorrespncExternalReference": "",


"SupplierQuotation": "",


"SupplierRespSalesPersonName": "API",


"SupplierPhoneNumber": "",


"SupplyingSupplier": "",


"IncotermsClassification": "",


"IncotermsTransferLocation": "",


"PurchaseContractTargetAmount": "0",


"InvoicingParty": "",


"CorrespncInternalReference": "",


"ReleaseCode": "",


"IncotermsVersion": "",


"IncotermsLocation1": "",


"IncotermsLocation2": "",


"IsEndOfPurposeBlocked": "",


"PurgContractIsInPreparation": false,


"to_PurchaseContractItem": {


"results": [


{


"PurchaseContract": "",


"PurchaseContractItem": "00010",


"PurchasingContractDeletionCode": "",


"PurchaseContractItemText": "Item 10 API Test",


"Plant": "1010",


"StorageLocation": "",


"RequirementTracking": "",


"MaterialGroup": "L004",


"SupplierMaterialNumber": "",


"OrderQuantityUnit": "EA",


"TargetQuantity": "1000",


"PurgDocReleaseOrderQuantity": "0",


"OrderPriceUnit": "EA",


"OrderPriceUnitToOrderUnitNmrtr": "1",


"OrdPriceUnitToOrderUnitDnmntr": "1",


"ContractNetPriceAmount": "15",


"DocumentCurrency": "EUR",


"NetPriceQuantity": "1",


"TaxCode": "",


"StockType": "",


"IsInfoRecordUpdated": "",


"PriceIsToBePrinted": true,


"PurgDocEstimatedPrice": true,


"NoDaysReminder1": "0",


"NoDaysReminder2": "0",


"NoDaysReminder3": "0",


"OverdelivTolrtdLmtRatioInPct": "0",


"UnlimitedOverdeliveryIsAllowed": false,


"UnderdelivTolrtdLmtRatioInPct": "0",


"PurchasingDocumentItemCategory": "0",


"AccountAssignmentCategory": "K",


"MultipleAcctAssgmtDistribution": "",


"GoodsReceiptIsExpected": true,


"GoodsReceiptIsNonValuated": false,


"InvoiceIsExpected": true,


"InvoiceIsGoodsReceiptBased": false,


"IsOrderAcknRqd": false,


"PurgDocOrderAcknNumber": "",


"ShippingInstruction": "",


"ManualDeliveryAddressID": "",


"VolumeUnit": "",


"Subcontractor": "",


"EvaldRcptSettlmtIsAllowed": false,


"Material": "",


"ServicePerformer": "",


"ProductType": "1",


"MaterialType": "",


"FormattedPurchaseContractItem": "",


"to_PurCtrAccount": {


"results": [


{


"AccountAssignment": "1",


"PurchaseContractItem": "",


"PurchaseContract": "",


"IsDeleted": false,


"Quantity": "1000",


"MultipleAcctAssgmtDistrPercent": "0",


"PurgDocNetAmount": "0",


"GLAccount": "10010000",


"BusinessArea": "",


"CostCenter": "",


"SalesOrder": "",


"SalesOrderItem": "",


"SalesOrderScheduleLine": "",


"MasterFixedAsset": "",


"FixedAsset": "",


"OrderID": "",


"GoodsRecipientName": "",


"UnloadingPointName": "",


"ControllingArea": "A000",


"CostObject": "",


"ProfitCenter": "",


"ProjectNetwork": "",


"RealEstateObject": "",


"PartnerAccountNumber": "",


"CommitmentItem": "",


"JointVentureRecoveryCode": "",


"FundsCenter": "",


"FunctionalArea": "",


"SettlementReferenceDate": "/Date(1492041600000)/",


"TaxCode": "",


"TaxJurisdiction": "",


"NonDeductibleInputTaxAmount": "0",


"CostCtrActivityType": "",


"BusinessProcess": "",


"EarmarkedFundsDocument": "",


"GrantID": "",


"BudgetPeriod": "",


"WBSElement": ""


}


]


},


"to_PurCtrAddress": {


"results": [


{


"PurchaseContract": "",


"AddressID": "",


"PurchaseContractItem": "",


"FormOfAddress": "",


"FullName": "",


"ConsigneeName3": "",


"ConsigneeName4": "",


"CareOfName": "",


"CityName": "",


"District": "",


"CityCode": "",


"PostalCode": "",


"POBoxPostalCode": "",


"CompanyPostalCode": "",


"POBox": "",


"POBoxDeviatingCityName": "",


"StreetName": "",


"HouseNumber": "",


"StreetPrefixName": "",


"AdditionalStreetPrefixName": "",


"AdditionalStreetSuffixName": "",


"Building": "",


"Floor": "",


"RoomNumber": "",


"Country": "",


"CorrespondenceLanguage": "",


"Region": "",


"AddressTimeZone": "",


"TaxJurisdiction": "",


"PrfrdCommMediumType": "",


"PhoneNumber": "",


"FaxNumber": "",


"TransportZone": "",


"HouseNumberSupplementText": "",


"StreetSuffixName": ""


}


]


}


}


]


},


"to_PurCtrPartners": {


"results": [


{


"PurchaseContract": "",


"PurchaseContractItem": "",


"PurchasingOrganization": "1010",


"PartnerFunction": "VN",


"Plant": "1010",


"SupplierSubrange": "",


"PartnerCounter": "1",


"Supplier": "10300001",


"DefaultPartner": false


}


]


}}


Note - Please remember to remove the existing { } when copy and pasting the above payload in API hub.

5 Comments
Labels in this area