cancel
Showing results for 
Search instead for 
Did you mean: 

Add item product in Customer Quote using ABSL.

pablo_daniel
Participant

Hi experts, i found a problem trying to add a product using ABSL Code.

Basically, i was created a Script that calls a WS (this WS returs a List of products with the ID Product, Quantity and Measure) and when a try to add a product i have a message Exception.

1) Using this way, inside the script in the CustomerQuote Extension BO , the products was added but i have a message exception (The product doesnt exist )

var itemToCreate = this.Item.Create(); //In this line, the exception is raised 😞 itemToCreate.ItemProduct.ProductKey.ProductID.content = material.InternalID.content; itemToCreate.ItemProduct.QuantityMeasureUnitCode = itemResp.GUabsmg; itemToCreate.FirstRequestedItemScheduleLine.Quantity.content = itemResp.zRtCmp ;

2) I tried another way to add a product but i cannot see the node/association ItemProduct.

var itemToCreate : elementsof CustomerQuote.Item;

//In the following lines i have an error because i cannot to access to the association ItemProduct.

itemToCreate.ItemProduct.ProductKey.ProductID.content = material.InternalID.content; itemToCreate.ItemProduct.QuantityMeasureUnitCode = itemResp.GUabsmg; itemToCreate.FirstRequestedItemScheduleLine.Quantity.content = itemResp.zRtCmp ;

There is another way to add the products??

Thanks!!!

Accepted Solutions (1)

Accepted Solutions (1)

pablo_daniel
Participant

Hi Pranav, I tried by this way.

In debug mode, the Warning is raised in the line var createitem = this.Item.Create();

When the product is setted, in the followings lines, the product is saved 🙂 but the warning is showed :(.

Thanks!

Answers (4)

Answers (4)

pablo_daniel
Participant

Hi colleagues,

I have a solution for this issue, basically we have to set the node itemProposal.

var itemProd : elementsof CustomerQuote.ItemProposal;

itemProd.ProductKey.ProductID.content = prom.ProductID;

itemProd.Quantity.content = prom.CantidadSol.content;

var itemprop = this.ItemProposal.Create(itemProd);

itemprop.Accept(); //This line is very important.

//Now we find the product created and now can be modified all the custom fields

var prodTomodify = this.Item.Where(p=>p.ID.RemoveLeadingZeros() == prom.ItemNumber).GetFirst();

Best Regards.

PeterK
Participant
0 Kudos

Hello Pablo!

You made my day! Thank you very much for your code.

The error message does not appear anymore!

Thank you very much!

Best regards

By the way I also opened an incident last year and this is what the support wrote us:

"Dear Peter,

We have checked this issue with our development team and here are their findings: PDI does a create of an item: // CustomerQuote: create item instance this.Item.Create(elCustomerQuote_Item);

In standard processing the consistency is determined and the error message regarding missing product is raised. Afterwards, PDI sets the product in sub-nide ItemProduct:

// set product identifier - mandatory

this.Item.GetFirst().ItemProduct.ProductKey.ProductID.content = "1000001";

In standard processing the consistency is determined again and the item gets consistent (Status.ConsistencyStatusCode onItem becomes 3 = Consitent).

However, a message that is raised cannot be deleted again in the same round-tip! Hence, the action returns the error message although the error is resolved already. The issue can only be resolved if the creation of the item and the provision of the product happens together as it is done for instance in an OData call."

former_member245804
Discoverer

Hi Pablo,

I have the same issue by adding products to a sales Quote via PDI absl code.

If you use a custom action (getSuggestedProduct) like you, this message (Item contains errors) will occur.

I solved this problem with a workaround; the same coding in the event BeforeSave works.

E.g. bind a button with your custom action (getSuggestedProduct) and use this action only to set a transient field to true

and in the event BeforeSave your real coding to add products and use an if-statement at the beginning of the coding...

if(this.YYAddProducts == true){

..... // add products

}

this.YYAddProducts = false;

and at the end (outside of the if-statement) set this field to false again. So you will ensure your coding will be executed only

if an user clicks this button and not each time saving a sales quote.

I think that is a bug that SAP has to fix, since the same coding works using the event BeforeSave... I have reported this issue to SAP and hope it will be fixed with the next releases.

Best Regards,

Burak Balkaya

pablo_daniel
Participant
0 Kudos

Thanks Burak,

Finally i solved the issue consuming a Web service standar provided in the service explorer, even following the instructions in the repository explorer the problem persists. Then using the WS the problem is solved.

The only problem is thats the products is not showing, but when is refreshed they appears.

Regards Pablo.

PeterK
Participant
0 Kudos

Hello burak,

did you get a response for the reported issue?

I am facing the same issue even though my steps to create a item are like the SAP Example in the Repository Explorer.

Best Regards,

Peter Krieger

mm00396
Explorer

HI Pablo,

In one my similar requirements ,I first created the item with all the mandatory fields and then created product:

Please see the below code. Please let me know if you can create an item with the below approach.

varcreateitem = this.Item.Create();

createitem.Description.content = "Consulting Service";

createitem.ExpectedNetAmount.content = weightedvalue;

createitem.ExpectedNetAmount.currencyCode = "USD";

createitem.Quantity.content = 1;

createitem.Quantity.unitCode = "EA";

if (createitem.ItemProduct.IsSet()){

createitem.ItemProduct.ProductKey.ProductID.content = "10000000";

createitem.ItemProduct.ProductCategoryHierarchyProductCategoryIDKey.ProductCategoryInternalID = "1";

pablo_daniel
Participant
0 Kudos

Hi Pranav, thanks for the helping.

I tried several times with this way. My problem is with the line,

var createitem = this.Item.Create(); // In debug mode this line raise the message error "The item doesn´t have a product"

Even when the message is raised, the product is created and saved. But the message error still appearing :(.

HorstSchaude
Product and Topic Expert
Product and Topic Expert

Hello Pablo,

You need to provide the data with the Create call.

Please have a look into the examples found via the Repository Explorer in the documentation for the CustomerQuote BO.

HTH,
. Horst

pablo_daniel
Participant
0 Kudos

Hi Horst, Thanks for the reply.

I tried by this way but the problem is the warning raised. (Even the product is already saved, but the warning is displayed.)

In the following image i tried first to fill the data and finally i tried to Create the item, but i cannot to access to the itemproduct.

In this case i tried to create the item and then to fill the data, there is no problem. But in the Execution i have a warning message when i tried to execute the line this.Item.Create(). I need to eliminate this warning in the kut (The product in the line not exist is the message).

Thanks !

HorstSchaude
Product and Topic Expert
Product and Topic Expert

Hello Pablo,

The mentioned documentation contains a code example for creating an item.

Why don't you use this? 😞

Bye,
. Horst

pablo_daniel
Participant
0 Kudos

Hello Horst!

I follow your suggestion and the results is the same.

Basically i tried the following lines. (The same example taked from Repository explorer)

And in the debugger the result is the same.

After the execution of the line var itemToCreate = this.Item.Create(itemAux), the warning message is still appearing (right side in the output debug.)

Thanks so much for the helping.

Best Regards. Pablo.

HorstSchaude
Product and Topic Expert
Product and Topic Expert

Hello Pablo,

But does the message still appears on the UI?

Bye,
. Horst