Skip to Content
0

Create Physical Inventory Adjustment via ABSL

Nov 22, 2016 at 11:25 AM

344

avatar image

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)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

6 Answers

Best Answer
Óscar Espinar Lázaro Feb 24, 2017 at 02:12 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Horst Schaude
Nov 22, 2016 at 12:33 PM
0

Hello Sankaran,

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

Sorry,
Horst

Show 1 Share
10 |10000 characters needed characters left 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

0
Horst Schaude
Nov 28, 2016 at 12:07 PM
0

Hello Sankaran,

Is the link to Knut Heusermann available for you?

Bye,
Horst

Share
10 |10000 characters needed characters left characters exceeded
Stefan Resag
Nov 29, 2016 at 12:58 PM
0

Hi,

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

Best regards,

Stefan

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thanks Stefan,

I have raised an incident. Incident External ID is: 3500296063.

Please look at it.

Regards

Sankara A

0
Óscar Espinar Lázaro Feb 23, 2017 at 11:58 PM
0

Hello Sankara,

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

Regards,

Óscar

Share
10 |10000 characters needed characters left characters exceeded
Sankaran A Mar 08, 2017 at 10:56 AM
0
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

Share
10 |10000 characters needed characters left characters exceeded