cancel
Showing results for 
Search instead for 
Did you mean: 

check if object is locked by user ?

itaKraus
Explorer
0 Kudos
415

hi
Hello everyone

I register a withdrawal
and receives into the variable every SALES ORDER according to the parameters I chose

Right now I want to go through all the results obtained from the fetch
and check whether the record is locked by a system user or not

 

How to write such a code in ABSL

I hope you can send me a serial code example!

I want to verify a lock on the SALES ORDER object

View Entire Topic
HarshalVakil
Active Contributor
0 Kudos

Hello,

Can you check if following works?

var currentDate = Context.GetCurrentGlobalDateTime();
var currentDate1 = currentDate.ConvertToLocalNormalisedDateTime();
var SalesOrders = SalesOrder.QueryByElements;
var SalesOrderDate_SelParams = SalesOrders.CreateSelectionParams();
SalesOrderDate_SelParams.Add(SalesOrders.Status.ItemListCustomerOrderLifeCycleStatusCode, "I", "EQ", "1");
SalesOrderDate_SelParams.Add(SalesOrders.Status.ItemListCustomerOrderLifeCycleStatusCode, "I", "EQ", "2");

var SalesOrderData_Results = SalesOrders.Execute(SalesOrderDate_SelParams);
var SalesOrderData_ResultsCopy = SalesOrders.Execute(SalesOrderDate_SelParams);

var ordersToRemove = new List<SalesOrderType>();

foreach (var SO in SalesOrderData_ResultsCopy)
{
var uuid = Library::UUID.ParseFromString(SO.UUID.content.ToString()); // sales order id
var messages;
var lock = BOAction.CheckLock("SalesOrder", "http://sap.com/xi/AP/CRM/Global", "Root", uuid);
messages = lock.MessageTypeItem;

var validationFailed = false; // Reset for each iteration

if (!lock.IsInitial() && messages.Count() > 0)
{
foreach (var message in messages)
{
if (message.MessageSeverityText == "E" && message.MessageID.content == "CL_CDA_DOCHD/000")
{
validationFailed = true;
ordersToRemove.Add(SO); // Mark for removal
lock.Clear();
break; // Break the inner loop since we already know this order is locked
}
}
messages.Clear();
}
}

// Remove all marked orders after the loop
foreach (var orderToRemove in ordersToRemove)
{
SalesOrderData_Results.Remove(ins => ins.ID.content == orderToRemove.ID.content);
}


Regards,
Harshal