Skip to Content
Technical Articles
Author's profile photo Guruprasad Durai

Managing Physical Inventory – More flexible through SAP Cloud Application Studio for SAP Business ByDesign

Use Case: Your business requires a more flexible way of using Physical Inventory in SAP Business ByDesign. For Example: You want to create physical inventory count documents for a changing set of products or you might want to upload count task result via Excel.

This blog guides how to achieve more flexibility through SAP Cloud Applications Studio (CAS) with regards to:

  • Create Physical Inventory Document
  • Complete Count Task
  • Approve Physical Inventory Document

For all 3 cases, you can achieve it with simple custom developments.

Note: The blog is explained considering a business use case where one count document will have one task only. Underlying assumption for this use case is that business already knows how to split their documents. Further-more to keep the use case simple, only one item is considered in the task to demonstrate the CAS capabilities for enabling counting process. The following document explains the same with details.

In case, your use case demands multiple tasks and multiple items to be created against one count document, the use case is scalable by modeling the BO and the UI accordingly.


Let us now look into the above functionalities one by one:

1. Creating Physical Inventory Document

Physical Inventory Document can be created in the system based on Product count or on Logistics Area count. To achieve this, create a Custom BO as shown below with the following mentioned fields.

BO Fields

locID – To Capture Location ID

cmCode – Product or LoA count

loa – LoA where the count must be performed

prodID – Product for which the count document must be created

qty – Counted quantity for the product

taskID – Task ID to count the quantity

cDocID – Count Document ID

BO Action           

createDoc – This action will create count document

Save and activate the BO. Create ABSL scripts for required events and actions.

createDoc Action ABSL

In this ABSL create the count document based on the below approach:

  • Create an instance of Root PhysicalInventoryCount BO
  • Pass user input of Storage Location ID & Count Method to corresponding fields in the root node
  • For the created Root instance, create an instance of OperationCount Node under the same BO
  • Pass value as “4” for CountScopeCode field under the OperationCount Node
  • Create an instance of OperationActivity from OperationCount Node
  • Call the Action “CreateTask” from OperationActivity Node
  • Once the task is created, navigate to ReferenceObject from OperationActivity
  • Create CountInventory instance
  • Pass value of LoA here under this node
  • Create instance of InventoryItem from CountInventory Node
  • Pass Product ID value under this node
  • Finally create the instance of ItemQuantity Node from InventoryItem

Sample snippet of the code with only one Product per count document.

To achieve create document process, User Interface would be required. The screens are generated from studio for created custom BO with Work Center, Work Center View, OWL, OIF & QAF.

UI to Create ‘Count Document’

User enters the required information by clicking on ‘New’ from the Custom Work Center View and then clicks on ‘createDoc’ Button and then clicks on Save. Close the screen.

The Count Document will be created in the system which can be verified under Physical Inventory Work Center -> By PI Count Document -> PI Count Not Started and find for recent created count document.


2. Recording Count results against the Task

In the defined BO, add a new Action by name updateTask as below:

In the createDoc ABSL, TaskID is stored in the custom BO. This TaskID would now be used to query from PhysicalInventoryTask BO and then pass the captured Counted Quantity to the ItemQuantity Node and finally Finish the task.

Sample snippet of the code to update ONE task and finish.

UI to record the results of the count against a Task

Enhance the UI with updateTask button as shown below.

Once the document is created, click on Edit from custom OWL, which will then launch the screen where user can record the count quantity.

After entering quantity, user clicks on updateTask button and finally clicks on Save. Close the screen.

The count document can now be seen under Physical Inventory Work Center -> By PI Count Document -> PI count “In Process” and click on Edit and navigate to Count Tasks to verify the counted quantity being filled and task in Finished Status.


3. Approve Document

In the defined BO, add a new Action by name approveTask as below:

In the updateTask ABSL, Count Document ID is stored in the custom BO. This ID would now be used to query from PhysicalInventoryCount BO and then call the Action Approve to complete the process.

Sample snippet of the code to Approve Count Document.

UI to Approve Task

Click on Edit from custom OWL and then user clicks on approveTask button and finally clicks on Save.

The count document can now be seen under Physical Inventory Work Center -> By PI Count Document -> PI Count Finished and click on Edit. Here the status of the document can be found as Finished and under Count Items the status to be as Approved.

Note: In the above blog post, all the actions in terms of creation/recording count result/approving the document are all shown as manual action. If the data volumes are high, then you can also explore the option of mass upload (For Ex: via XLS) to perform those steps. Refer to the blog Mass Upload for more details..


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Xingang Li
      Xingang Li

      Dear Guruprasad,

      As you mentioned at the "Note" part that we can use "Mass upload" to trggier mass action, but after check the link  i understand it just directly insert or update data to Business Objects, seems like can't do mass call of actions.

      Now we want do mass creation, mass Count and mass Approval, Could you please share us some hints on this topic ?

      Thank you advance.

      • Create Physical Inventory Document
      • Complete Count Task
      • Approve Physical Inventory Document
      Author's profile photo Maxime Gillet
      Maxime Gillet

      Thanks for the blog, That helped me started!

      Unfortunatly it seems a bit outdated now. I managed to create a physical count method 3 but  I am having trouble with count method 2.

      The code is throwing an exception when I execute OperationActivityCountInventory.Create()


      "Operation not possible. Document is not finished"


      import ABSL;
      import AP.LogisticsExecution.Global;
      var picRoot = PhysicalInventoryCount.Create();
      picRoot.LocationID.content = this.LocationID.content;
      picRoot.CountMethodCode = "2";
      picRoot.KeyDate = this.Date;
      var picOpCount = picRoot.OperationCount.Create();
      picOpCount.PhysicalInventoryCountScopeCode = "4";
      var picAct = picOpCount.OperationActivity.Create();
      var countInv = picAct.OperationActivityCountInventory.Create();
      countInv.LogisticsAreaKey.ID = "STOCKAGE";
      foreach(var item in this.CountItems){
      	var inventoryItem = countInv.OperationActivityInventoryItem.GetFirst();
      	inventoryItem.MainInventorySeparatingValues.MaterialKey.ProductID.content = item.ProductID.content;
      	//7.Navigate to InventoryItemQuantity node instance and provide the adjustable quantity in CountedQuantity.
      	var qty = inventoryItem.OperationActivityInventoryItemQuantity.GetFirst();
      	qty.CountedQuantity = item.Quantity;
      	qty.CountedQuantity.unitCode = "EA";
      	qty.ZeroCountedQuantityConfirmedIndicator = false;

       any idea what am I missing Guruprasad Durai ? thanks

      Author's profile photo Minh Tri Le
      Minh Tri Le

      Hi Guruprasad Durai,

      Thanks for a good blog.

      I'm not sure if this only happens to me or it's a bug.

      At the steps of createDoc script

      • Call the Action “CreateTask” from OperationActivity Node
      • Once the task is created, navigate to ReferenceObject from OperationActivity

      It doesn't work because of the error No access possible via a NULL data reference at the line refObj and picTaskRoot