cancel
Showing results for 
Search instead for 
Did you mean: 

Query by customer specific field

0 Kudos

Hi guys,

I've created a customer specific field at the material master data. Now I would like to create a query on this field. Unfortunately I can't choose this field as QueryPath in my query params:

selParameter.Add( ???, "I", "EQ", this.TestElement.content);

I've tried to leave the selParameter blank and loop through all materials. But the performance is too poor.

Does somebody has an idea?

Best regards,

Michael

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Michael,

Can I know How you have created this customer specific field in the Material Master Data..? I mean it is either through Adaptation or through using ByD SDK..

If it is through Adaptation you cannot access the field added by the business user in your SDK programming. So if in case you did the same, change it and do it with the help of SDK add an element to the Material BO and enhance the same element to the needed screens. Then activate the entire project/solution and try to use in query..

Hope this should help  you in doing this..

Regards..
Hanu K

0 Kudos

Hi Hanu,

thanks for your answer.

The customer specific field was created via Key User Tool Adaption.

It's not possible to recreate the Material Master Data fields by SDK because the customer already filled the fields with content when they migrated their materials. Now i need to access this data.

Is there another way to make this possible?

Best regards,

Michael

Former Member
0 Kudos

Hi Michael,

I would like to know one small information, is this field data is going to be different for each and every material or the same for all the materials what ever is getting migrated?

This is because if it is going to hold the same data for all the materials, then hardcode it in any of the events like "After Modify/Before Save" using SDK by adding an element to the needed screens by enhancing Material BO. When ever a data is getting migrated and saving as Material in the system any one of the above stated scripts will invoke and your hardcoded value will be filled in the extension field. This procedure is only if in case the extension field is going to hold same value every time and for every material.

Regards..
Hanu K

0 Kudos

Hi Hanu,

unfortunately the content of the customer specific field could change in each material. The "After Modify/Before Save" script will not work in this case.

Maybe there is a chance to make this field available in the SDK with help by SAP Cloud Support?

Best regards, Michael

Former Member
0 Kudos

Michael,

No such support from SAP side you cannot expect I think, better to give a try and let us know how it is going to work from SAP side.

Regards..
Hanu K

Former Member
0 Kudos

There is something called References to Customer-Specific fields. This should help you in using Extension fields that are created through Adaptation in SDK.

If you are in 1308, then refer to page# 357 Section 8.4.1.3.9 in 1308 studio documentation.

Former Member
0 Kudos

Yeah Srivatsava/Michael, this reference to customer specific field section is there in 13.08 documentation in Page #349 section 7.4.1.3.9. I didn't suggested this to Michael because he is saying that the field will be populated using Data Migration templates so I am not sure to which extent this .ref file will be useful.I would like to suggest Michael to give a try for this..

Regards..
Hanu K

0 Kudos

I am already using the "References to Customer-Specific fields". So I can access the field by using:


Material.Common.EXTMyCustomerField001638282C09239C612

The problem is, I can't / I don't know using the customer specific field in a query now. The field was created in the Material Master Data common area with the Adaption mode. The canceled code is not possible for me now:


var query = Material.Common.QueryByElements;

var selParam = query.CreateSelectionParams();

selParam.Add(query.EXTMyCustomerField001638282C09239C612.content, "I", "EQ", this.MyBOField.content);

result = query.Execute(selParam);

I dont know how I've to declare the query variable to use the customer specific field in my querypath for the selParam.

Best regards,
Michael

Former Member
0 Kudos

Hi Michael Kaupp,

Every node does not have QueryByElements, Its means you can't query each node.

But as a work arround you can query material BO..


var qm = Material.QueryByDescription;

var qm_sel = qm.CreateSelectionParams();

qm_sel.Add(qm.ProductID.content, "I", "EQ", this.zMaterialID.content);

var qm_res = qm.Execute(qm_sel);

foreach( var ins in qm_res){

if(ins1.Common.EXTCustomerFiledXXXXX == this.myfield){

// *** write your own logic

   }

try this and let me know if this help.

Thanks

Sunil

0 Kudos

Hi Sunil,

thanks for your code example.

I've to check the customer specific field on every single material. So I can't use the selection parameter:


qm_sel.Add(qm.ProductID.content, "I", "EQ", this.zMaterialID.content);

When I leave the qm_sel blank, I receive nearly 5.000 materials. A foreach iteration is not performant enough to loop over this 5.000 items, i receive a dump right now.

Best regards,

Michael

Former Member
0 Kudos

Extending a BO would enhance its related std. query only on result set but not on Query params.

So, you can't have your extended field in the query param section.

Instead of reading every element in a for loop, try filtering your result set using the qryResult.where(n => n.ExtField == "blah"); even before using for loop and see if it fills your luck else sorry.

Former Member
0 Kudos

You might have received dump because the query result does not have any instances.

before using query result you should check the number of returns in query results

use

if(qm_res.Count()>0){

try the way Srivats has explained

}

Thanks

Sunil