Artikel CFL in Verkaufsbelegen durch Parameter beeinflussen
Manuel Kuebler
Ich habe im Artikelstamm bestimmte Artikel, die nur bestimmte Kunden kaufen können. Wenn ich nun den Kunden Mustermann auswähle, sollen nur noch die Artikel im Choose From List Fenster angezeigt werden, die dieser Kunde kaufen kann. Wie kann ich die Abfrage, die hinter dem Fenster liegt durch Parameter oder sogar eine andere Abfrage ändern?
Paolo Manfrin
Hi Manuel,
the best way is to use the customize CFL instead of the standard on.
1.
Create a simple chose from list rule with the query "SELECT ItemCode, ItemName FROM OITM".
This actually creates an optimizer rule in the background.
2.
Go into the optimizer rule. At this point you can use TextEdit.GetFromUID(pVal.Form, "customerCode") to retrieve the customer id and adjust the query before it gets displayed
3.
Capture the standard ChoseFromList event triggered by SAP and disable it to avoid both choose from list to appear.
We created already similar rules. If you would need help for your implementation feel free to contact our support to sort this out.
hth
paolo
Manuel Kuebler
Hi paolo,
thanks for your message.
I have added the CFL with the Optimizer and I get the following error in the Form Load-Event.
[attachment=365:cfl_error_form_load.PNG]
Edit: I get the same error in the Form Loaded-Event
Paolo Manfrin
Hi Manuel, to which field did you add the CFL?
Manuel Kuebler
I added the CFL to the field 38,1. Matrix 38 and Column 1 (ItemCode)
Manuel Kuebler
Auch nach einem Update auf die Version 3.95 ist diese Fehlermeldung immer noch da.
Anders Olsson
Hi Manuel,
It is only possible to add a CFL to matrix columns of type TextEdit. The item column is of type LinkedButton. Besides this column already has a SAP cfl behind it so even if it was possible to add a coresuite cfl both would be triggered.
Since there is already a SAP cfl on the column the best thing would be to modify that.
You can use the following code and modify it to your needs. You can put it in an Optimizer FormLoad rule:
SAPbouiCOM.Form sapForm = SwissAddonFramework.B1Connector.GetB1Connector().Application.Forms.Item(pVal.Form.UniqueID);
SAPbouiCOM.Matrix matrix = (SAPbouiCOM.Matrix) sapForm.Items.Item("38").Specific;
SAPbouiCOM.ChooseFromList cfl = (SAPbouiCOM.ChooseFromList) sapForm.ChooseFromLists.Item(matrix.Columns.Item("1").ChooseFromListUID);
SAPbouiCOM.Conditions cons = cfl.GetConditions();
SAPbouiCOM.Condition con = cons.Add();
con.Alias = "ItemCode";
con.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL;
con.CondVal = "A00001";
cfl.SetConditions(cons);
This will create a filter so that only the item "A00001" is shown. Using these SAP conditions is not very flexible but you will have to do with that I'm afraid.
There is an example in the SAP SDK UI API documentation about this under "ChooseFromList Object".
HTH,
Anders
Manuel Kuebler
Hi Anders,
thanks you for your example, It works great for me.
M.Zurbrüggen
May you can help me.
I Try exactly the same: I want to create a CFL on an UDF wich has the ItemCode as a variable in the query.
Now i read this post, but i don´t get it.
What exactly have i to do for get it working?
Please sign in to leave a comment.
Comments
0 comments