cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot access a PSM released node item in ABSL

former_member606838
Participant
0 Kudos

Hi Experts,

I have asked the same question in the past and no one gave me the correct answer maybe because my question was not clear enough. Here is what I want to achieve: In SAP Business ByDesign In creating Purchase order, I am trying to default the value of Location of Service Provision when the item time is "Service" and the Process type is "Third party". The default value currently is "On-Site" and I want to make it "Supplier Service Center".


*Note: I know that if this was a "service order" then I can follow :https://apps.support.sap.com/sap/support/knowledge/public/en/2740657 But it's not the case *

So I went to the SDK and I created business object extenstion for the Purchase Order BO and I created an After-Modify event that Suppose to Take the value of the note element TypeCode under the node Item and check if the value was 19 - Service then I make the value of ServiceProvisionLocationTypeCode equals to 3.

I made sure that all the components are PSM released

This is why I did and I had the above errors. Can anyone help me with this explaining what is happening? or provide me with a code snippet that works!

Thanks,

Mousa

Accepted Solutions (1)

Accepted Solutions (1)

former_member226
Employee
Employee

Hi,

in your ABSL script, "this.item" carries a Collection of values. hence you need to loop each entry in order to access corresponding node fields.

A sample code could be:

var items = this.item;
foreach(var inst in items)
{
inst.ServiceProvisionLocationypeCode = "19";
}

Thanks

Saurabh

former_member606838
Participant
0 Kudos

Thanks Saurabh.

I tried this code in two events one under Root and one under Item nodes and didn't work any idea what could be the problem?

Answers (2)

Answers (2)

andy_blankley
Participant

Dear Mousa,

I hope you are doing well!

In order to satisfy your requirement, you have to remember that you are executing a script to check a BO Node that has 0..N multiplicity.

This means that at any one time there can be 0 or N number of items for that Purchase Order instance.

I can see Saurabh has already touched on that point, however here is the ABSL code in a similar design to yours:

.

In the above, you can see that you are accessing "An Instance" on the Item node using the GetFirst() function, and then checking the TypeCode element.

Similarly, you should do the same using a ForEach loop (dependent on your scenario) and run through each item on the Purchase Order BO instance.

.

Hope this helps you and your developments! (Mark this as answered if the question was solved!).

Kind regards,

Andy Blankley

former_member606838
Participant
0 Kudos

Dear Andrew.

Thanks for your output. I tried that and it didn't work under Root nor Item nodes when had an after modify event under them. I am trying to have a real-time response like whenever the user will change from Material to Service this will be in effect. Should that be something to do with the ABSL code or with UI designer (as I am still newbie in this).

Thanks!

thomaskenner
Participant

Hi,

if you have just created the AfterModify action the Mass enabled flag was enabled in this case your "this" is a collectionand you have to loop over it:

foreach(var inst in this){
foreach{var item in inst.Item}{
if(item.TypeCode == "19"){
item.ServiceProvisioningTypeCode= "3";
}
}
}

this is the structure please check the syntax.

best regards

Thomas

former_member606838
Participant
0 Kudos

Thanks Thomas,

I will try it today and will let you know. But what is the difference if the mass flag is checked or not? I read it somewhere but it wasn't clear.

best,

Mousa

thomaskenner
Participant
0 Kudos

Hi Mousa,

There is a very good explanation in the article SAP Cloud Application Studio Performance Best Practices by stefankrauth

and if you want to know more here is a guide Performance best practice with Mass enabled event by pradeepkumar.n

I hope this will help you to resolve your issue 🙂

best regards

Thomas