Skip to Content

Create Physical Inventory Adjustment via ABSL

Hi Everyone!

Please look at the below code. I have tried to create Physical Inventory Adjustment using ABSL.

I have tried this blog. https://archive.sap.com/discussions/message/16777316#16777316

But I'm facing the below error.

BeforeSave Script:

import ABSL;
import AP.LogisticsExecution.Global;

var createPIA : elementsof PhysicalInventoryCount;
createPIA.LocationID.content = "L1100";
createPIA.CountMethodCode = "2";
var resultPIA = PhysicalInventoryCount.Create(createPIA);

var operationalCnt = resultPIA.OperationCount.Create();
operationalCnt.PhysicalInventoryCountScopeCode = "4";

var Activity = operationalCnt.OperationActivity.Create();

var InventoryNoe = Activity.OperationActivityCountInventory.Create();
InventoryNoe.LogisticsAreaKey.ID = "L1100-30-10";
InventoryNoe.LogisticsAreaKey.SiteID.content = "L1100";
InventoryNoe.AddItem();

var inventoryItem = InventoryNoe.OperationActivityInventoryItem.Create();
inventoryItem.MainInventorySeparatingValues.MaterialKey.ProductID.content = "EMB51";

var qty = inventoryItem.OperationActivityInventoryItemQuantity.Create();
qty.ZeroCountedQuantityConfirmedIndicator = true;

Activity.EndCountActivity();

Am I Missing anything? Please help to solve this problem.

Regards

Sankaran A

error.png (7.5 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

9 Answers

  • Best Answer
    Feb 24, 2017 at 02:12 PM

    Hello all,

    This is the revised code working perfectly. The bug was in the creation of OperationActivityInventoryItem and OperationActivityInventoryItemQuantity Nodes.

    import ABSL;
    import AP.LogisticsExecution.Global;
    
    //1.Create Root node instance of PhysicalInventoryCount BO with Count Method = 2 and provide Location ID 
    var createPIA : elementsof PhysicalInventoryCount;
    createPIA.LocationID.content = "COM";
    createPIA.CountMethodCode = "3";
    var resultPIA = PhysicalInventoryCount.Create(createPIA);
    
    //2.Create OperationCount node instance with CountScopeCode = 4
    var operationalCnt = resultPIA.OperationCount.Create();
    operationalCnt.PhysicalInventoryCountScopeCode = "4";
    
    //3.Create Activity node instance
    var Activity = operationalCnt.OperationActivity.Create();
    
    //4.Create CountInventory node instance and here provide LogisticsAreaID ..
    var InventoryNoe = Activity.OperationActivityCountInventory.Create();
    InventoryNoe.LogisticsAreaKey.ID = "A.";
    
    //5.Perform Action “AddItem” in the Inventory Node
    InventoryNoe.AddItem();
    
    //6.Navigate to InventoryItem node instance and provide all the Product details required which needs to be adjusted.
    var inventoryItem = InventoryNoe.OperationActivityInventoryItem.GetFirst();
    inventoryItem.MainInventorySeparatingValues.MaterialKey.ProductID.content = "ALXRN02";
    inventoryItem.IdentifiedStockInventorySeparatingValues.IdentifiedStockKey.ID.content = "304050607080";
    
    //7.Navigate to InventoryItemQuantity node instance and provide the adjustable quantity in CountedQuantity.
    var qty = inventoryItem.OperationActivityInventoryItemQuantity.GetFirst();
    qty.CountedQuantity.content = 12;
    qty.CountedQuantity.unitCode = "EA";
    qty.ZeroCountedQuantityConfirmedIndicator = false;
    
    //8.Perform Action “EndCountActivity” on the instance of Activity node.
    Activity.EndCountActivity();
    
    //9.Perform Action “ApproveCount” on the instance of Root node.
    //resultPIA.ApproveCount();
    

    Regards,

    Óscar

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 22, 2016 at 12:33 PM

    Hello Sankaran,

    This is that special that you need someone from Logistics Execution (or @Knut.Heusermann).

    Sorry,
    Horst

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Horst,

      Thanks for your help.

      Can I contact someone from Logistics Execution? I am not able to continue my development due to this issue. I need someone's help on this topic.

      Regards

      Sankaran A

  • Nov 28, 2016 at 12:07 PM

    Hello Sankaran,

    Is the link to Knut Heusermann available for you?

    Bye,
    Horst

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 29, 2016 at 12:58 PM

    Hi,

    I talked to development. They ask you to create an incident for this.

    Best regards,

    Stefan

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 23, 2017 at 11:58 PM

    Hello Sankara,

    Did you get your code finally working? Could you share some tips...

    Regards,

    Óscar

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 08, 2017 at 10:56 AM
    import ABSL;
    import AP.LogisticsExecution.Global;
    var createPIA : elementsof PhysicalInventoryCount;
    createPIA.LocationID.content = "L1100";
    createPIA.CountMethodCode = "2";
    var resultPIA = PhysicalInventoryCount.Create(createPIA);
    var operationalCnt = resultPIA.OperationCount.Create();
    operationalCnt.PhysicalInventoryCountScopeCode = "4";
    var Activity = operationalCnt.OperationActivity.Create();
    var InventoryNoe = Activity.OperationActivityCountInventory.Create();
    
    
    InventoryNoe.LogisticsAreaKey.ID = "L1100-30-10";
    InventoryNoe.LogisticsAreaKey.SiteID.content = "L1100";
    InventoryNoe.AddItem();
    var inventoryItem = InventoryNoe.OperationActivityInventoryItem.Create();
    
    
    inventoryItem.MainInventorySeparatingValues.MaterialKey.ProductID.content = "EMB51";
    var qty = inventoryItem.OperationActivityInventoryItemQuantity.Create();
    qty.ZeroCountedQuantityConfirmedIndicator = true;
    
    
    // BEGIN OF ADDITIONAL CODE
    foreach(var inst in InventoryNoe.OperationActivityInventoryItem)
    {
      if(inst.MainInventorySeparatingValues.MaterialKey.ProductID.content.IsInitial())
      {
          inst.Delete();
      }
    }
    
    // END OF ADDITIONAL CODE
    Activity.EndCountActivity();
    resultPIA.ApproveCount();

    Sorry for the delay. The above code is working for me.

    @Óscar thanks for your effect. Your code is also working for me.

    Regards

    Sankaran A

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 12, 2018 at 07:16 AM

    Hi Everyone、

    I also create physical inventory count with this code .

    It is ok.

    I want to add internal comment of inventory adjustment via absl.

    I can't write internal comment and can't find the internal comment value in repository .

    I can't execute the internal comment value via query of PhysicalInventoryCount .

    Could you please point out me technical value?

    Best Regards,

    Charm

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 12, 2018 at 10:54 AM

    Hi Charm,

    Please find in this path.

    PhysicalInventoryCount>OperationCount>OperationActivity>OperationActivityTextCollection>Text>TextContent

    Regards,

    May

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 14, 2018 at 11:38 PM

    Hi May,

    Thanks for your advice , I already find this path .

    There is no data in text collection node.

    Best Regards,

    Charm

    Add comment
    10|10000 characters needed characters exceeded