cancel
Showing results for 
Search instead for 
Did you mean: 

How to load CFL from XML ?

Former Member
0 Kudos

Hi Experts,

I am trying to load CFL from XML file.I am using the following XML and Vb.Net code but it is giving -1106 error while loading.

XML File:

<choosefromlist UniqueID="CFL_4" ObjectType="2" MultiSelection="0" IsSystem="0>"

    <conditions>

      <condition alias="CardCode" bracket_close_num="0" bracket_open_num="0" compare_fields="0" compared_field_alias="" cond_end_val="" cond_value="C0001" operation="1" relationship="99" use_result="0" />

      <condition alias="CardCode" bracket_close_num="0" bracket_open_num="0" compare_fields="0" compared_field_alias="" cond_end_val="" cond_value="ttt" operation="1" relationship="0" use_result="0" />

    </conditions>

  </choosefromlist>

Load From XML:

            Dim oCFL As SAPbouiCOM.ChooseFromList = objForm.ChooseFromLists.Item("CFL_4")

            Dim oConds As SAPbouiCOM.Conditions

            Dim oCond As SAPbouiCOM.Condition

            Dim oEmptyConds As New SAPbouiCOM.Conditions

            Dim rsetCFL As SAPbobsCOM.Recordset

            rsetCFL = objMain.objCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

            oCFL.SetConditions(oEmptyConds)

            oConds = oCFL.GetConditions()

            oCond = oConds.Add()

            oConds.LoadFromXML("CFLList.xml") 'Error -1106 Here

Please suggest

Thanks and Regards

DEV

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Dev,

For many reasons, your code will just not work...

If you have the xml definition of the CFL (as in your code excerpt), you have to call a LoadBatchAction to update the form, but the easiest is to copy your xml fragment into the srf/xml definition of your form.

Regards,

Eric

Former Member
0 Kudos

Hi ERIC,

Thank you for reply,

I don't have any Idea how to do as you mention above.Please post any code sample.


or Please mention any changes in my code.



Thanks and Regards

DEV


Former Member
0 Kudos

Hi Dev,

srf files, which are saved by the ScreenPainter add-on are "just" xml files: so easy to read and to modify

When you design your form, on all EditText field you are able to assign a CFL (ChooseFromListUID and ChooseFromListAlias attributes of the <item><specific> element).

This CFL is also defined in the srf-xml file (at the full bottom). If you edit this file you can modify the definition of the CFL and set the conditions; to do it:

  • Go to the ChooseFromListCollection at the bottom of the xml file,
  • Find the ChooseFromList item to which you want to specify the conditions,
  • Replace the <conditions/> element by the one from your xml excerpt.

By doing so, your form will be loaded with the CFL fully defined.

If you look at the header of the srf-xml file, you'll find something like <Application><forms><action type="add"> ...

The type of the action can also be update (<action type="update">) in which case, the xml fragment  can be loaded with the LoadBatchAction function to update the specified form.

Besides these two points, the ChooseFromList element in your xml is not correctly cased: it should like I write it and not like you did.

Regards,

Eric

Former Member
0 Kudos

Hi ERIC,

My conditions are not constant.It may change later depends on query.So I can't fix the conditions.

Former Member
0 Kudos

Hi Dev,

This was not expressed and changes things a bit, for sure.

The rsetCFL object is not used (at least in your fragment) and from your code has to be removed,

The oCond = oConds.Add() will crash,

I'm not sure that the ChooseFromList (bad case in your fragment) is necessary...

In all cases, what I would do is to set the first condition by program, then export it with the Conditions.GetAsXML method. From there, I just would reproduce the structure with the correct values.

Regards,

Eric

Former Member
0 Kudos

Hi ERIC,

I want convert SQL Query to XML from record set. And I want append that XML to CFL.

is it possible with out using oconds.add()?

or

is there any way to append SQL query to CFL directly?

Thanks in Advance

DEV

Former Member
0 Kudos

hi,

Normally  to create CFL, we have to bind object to CFL.

If you want to load query data to CFL, first create one User defined table with the query columns and register it as UDO. Then insert the query data to the user defined table. Finally bind the UDO object to the CFL.

Former Member
0 Kudos

Hi Indhu,

This is all except correct.

Process from the SDK is the following:

  • Create the definition of the CFL (linked to one of the know B1's object, neither UDO, nor query, nor Recordser, ...),
  • Create the item and associate the CFL.

As described, Dev's process is correct, what he is missing is the exact syntax for the xml, and the way to get it was provided in a previous answer:

  • Do the modification once thru the SDK,
  • Export the xml definition wiht the ad'hoc function,
  • Adapt the xml to the real need and do the import.

Regards,

Eric

Former Member
0 Kudos

Sample 17.ChooseFromList from the SDK samples... Just have to adapt.

Regards,

Eric