Skip to Content
0

Add item product in Customer Quote using ABSL.

Jan 16 at 12:32 PM

258

avatar image
Former Member

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!!!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
avatar image
Former Member Jan 22 at 08:28 PM
0

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!


Share
10 |10000 characters needed characters left characters exceeded
Horst Schaude
Jan 17 at 12:06 PM
1

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

Show 4 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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 !

0

Hello Pablo,

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

Why don't you use this? :-(

Bye,
. Horst

0
Former Member

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.

0

Hello Pablo,

But does the message still appears on the UI?

Bye,
. Horst

0
avatar image
Former Member Jan 22 at 12:20 PM
1

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";

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

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 :(.

0
avatar image
Former Member Mar 09 at 06:50 AM
1

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

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

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.

0