Figure 1: Response of Material Stock Display
Step | Description | Outcome |
1. | Open the tab “Resource” of the “Material Stock Display” OData service in the S/4HANA Cloud section of API Hub . | |
2. | Under the resource “GET A_MaterialStock”, enter a value like “10” for the parameter “$top” to reduce the number of lines that will be later returned in the response. | |
3. | Select the value “to_MatlStkInAcctMod” for the parameter “$expand” to retrieve later the actual stock quantities. | |
4. | Click the button “Try it out!” | The request is executed and the response contains several materials including the current stock levels. See also Figure 1: Response of Material Stock Display. |
5. | Select one result entity where the fields “InventoryStockType” equals “01”, “InventorySpecialStockType” equals “”, and “Batch” equals “”. Note the fields “Material”, “Plant”, “StorageLocation”, “MaterialBaseUnit”, and "MatlWrhsStkQtyInMatlBaseUnit". | The field "MatlWrhsStkQtyInMatlBaseUnit" shows the current quantity. |
Step | Description | Outcome |
6. | Open the tab “Resource” of the “Process Material Documents” OData service in API Hub. | |
7. | Under the resource “GET A_MaterialDocumentHeader”, create a new header parameter by clicking the button “Add” -> “Header”. Enter the header name “X-CSRF-Token” and the value “Fetch”. | |
8. | Enter a value of “10” for the parameter “$top”. | |
9. | Click the button “Try it out!” | The service returns 10 existing material documents. Under the section “Response Headers” the field “x-csrf-token” can be found. |
10. | Note the content of the header “x-csrf-token” in the response. The brackets “[]” can be omitted. | The noted token looks like “rEZ8WXMxOtCbY9N3JnoGlA==”, it will be created newly for each session. This token will be needed to send data changing requests to the service. |
Step | Description | Outcome |
11. | Open the resource “POST A_MaterialDocumentHeader”. | |
12. | Add a new header parameter with “Add” -> “Header”. Enter the header name “X-CSRF-Token” and the value from step 10.). | |
13. | Add the following JSON fragment into the field “A_MaterialDocumentHeaderType” and replace the fields for material, plant, storage location, and material base unit with the content that has been noted in step 5.). Replace the field for the posting date with a current date and enter a small quantity into “QuantityInEntryUnit” (because of the material document created here, this quantity will be added to the stock quantity from step 5.):
| |
14. | Click the button “Try it out!” | After the material document is processed, a response code “201” is returned. The response body contains the key of the newly created document (fields “MaterialDocumentYear” and “MaterialDocument”). If a return code “400” with the error code “M7/053”, error message “Posting only possible in periods … and … in company code …” is returned, the posting date in the request has to be changed to match the given periods. After a correction of the posting date, step 13.) can be repeated. |
Step | Description | Outcome |
15. | Return to the “Material Stock Display” OData service and expand the resource “GET /A_MaterialStock(‘{Material}’)”. Enter the name of the material from step 5.) as the “Material” parameter. | |
16. | Select the value “to_MatlStkInAcctMod” for the parameter “$expand”. Click the button “Try it out!”. | The quantity in field “MatlWrhsStkQtyInMatlBaseUnit” was increased by the quantity given in step 13.) compared to the stock quantity in step 5.). Note down the content of this quantity field. |
Step | Description | Outcome |
17. | Open the tab “Resource” of the “Process Physical Inventory Documents” OData service in the API hub. | |
18. | Expand the section “A_PhysInventoryDocItem” and then “GET /A_PhysInventoryDocItem”. | |
19. | Fill the “$filter” field with a search string like this:
The material, plant, and storage location are taken over from step 5.). | A response code “200” is returned together with a list of all matching physical inventory document items. Please note: The list can be empty. In this case, no physical inventory document with a corresponding item was created yet, which is okay to continue this guideline. |
Step | Description | Outcome |
20. | Open the resource “POST /A_PhysInventoryDocHeader”. | |
21. | Add a new header parameter with “Add” -> “Header”. Enter the header name “X-CSRF-Token” and the value from step 10.). | |
22. | Add the following JSON fragment into the field “A_PhysInventoryDocHeaderType” and replace the fields for material, plant, and storage location with the content that has been noted in step 5.). Replace the field for the document and planned count date with a current date:
| |
23. | Click the button “Try it out!”. | After the physical inventory document has been created, a status code “201” is returned. In the response body, the identifier of the new physical inventory document can be found. If the response code is “400” with the error code “M7/728", error message "Phys. inventory document can only be created for year …", repeat step 22.) with an adjusted document and planned count date. An error code “M7/700" "Physical inventory for 1710 171A TG11” is already active" would be returned here if in step 19.) a physical inventory item which is not finished is found. |
24. | Note down the content of the fields “PhysicalInventoryDocument” and “FiscalYear” in the response body. Additionally, the field “etag” is needed in the next steps. |
Step | Description | Outcome |
25. | Open the resource “PATCH /A_PhysInventoryDocItem(FiscalYear='{FiscalYear}', PhysicalInventoryDocument='{PhysicalInventoryDocument}', PhysicalInventoryDocumentItem='{PhysicalInventoryDocumentItem}')” | |
26. | Add a new header parameter with “Add” -> “Header”. Enter the header name “X-CSRF-Token” and the value from step 10.). | |
27. | Add a new header parameter with “Add” -> “Header”. Enter the header name “If-Match” and the “etag”-value from step 24.) in the format “W/"datetimeoffset'2018-01-31T13%3A31%3A33.7933940Z'"”. | |
28. | Enter the values from step 24.) for the corresponding parameters “FiscalYear” and “PhysicalInventoryDocument”. Enter “001” in the parameter field “PhysicalInventoryDocumentItem”. | |
29. | Add the following JSON fragment into the field “A_PhysInventoryDocItemType” and replace the fields for material and material base unit with the content that has been noted in step 5.). Replace the field for the planned count date with a current date. Chose a quantity that is near the quantity from step 16.), but with a small difference:
| |
30. | Click the button “Try it out!”. | After the count result has been entered into the physical inventory document item, a status code “204” is returned. There is no response body. Note down the new etag that can be found under the response headers. |
Step | Description | Outcome |
31. | Open the resource “POST /PostDifferencesOnItem”. | |
32. | Add a new header parameter with “Add” -> “Header”. Enter the header name “X-CSRF-Token” and the value from step 10.). | |
33. | Add a new header parameter with “Add” -> “Header”. Enter the header name “If-Match” and the “etag”-value from step 30.) in the format “W/"datetimeoffset'2018-01-31T13%3A31%3A33.7933940Z'"”. | |
34. | Enter the values from step 24.) for the corresponding parameters “FiscalYear” and “PhysicalInventoryDocument”. Enter “001” in the parameter field “PhysicalInventoryDocumentItem”. | |
35. | Enter the material from step 5.) in the parameter field “Material”. | |
36. | Enter a current date in the parameter field “PostingDate” in the format “datetime’2018-01-02T00:00:00’” | |
37. | Click the button “Try it out!”. | When the difference is posted, the service returns a status code of “200”. The response body contains the field “BookQtyBfrCountInMatlBaseUnit”, which should show the quantity from step 16.). |
Step | Description | Outcome |
38. | Return to the “Material Stock Display” OData service and expand the resource “GET /A_MaterialStock(‘{Material}’)”. Enter the name of the material from step 5.) as the “Material” parameter. | |
39. | Select the value “to_MatlStkInAcctMod” for the parameter “$expand”. Click the button “Try it out!”. | The quantity in field “MatlWrhsStkQtyInMatlBaseUnit” was changed to the quantity given in step 29.). Thus the physical inventory count was posted successfully. |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
12 | |
5 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 | |
2 | |
2 |