cancel
Showing results for 
Search instead for 
Did you mean: 

How to update User Defined Form items via xml?

brunomilanez
Explorer
0 Kudos

Sap, Developers?

I've been trying to speed up the form drawing of our add-ons using xml via LoadBatchActions. What I want to do is basically two things:

  • While opening a user defined form, manipulate its xml string (using GetAsXml()) to include valid values into comboboxes dinamically;
  • On changing form mode or navigate through the records, update the form items acting on properties like enabled and visible and also reload valid values of the comboboxes.

So far, I managed to do it only on form properties, for instance, its title and position, but when it comes to the form items, everything seems to be ignored by the LoadBatchActions call. Here is an exemple of a xml used to update a user defined form.

<?xml version=\"1.0\" encoding=\"UTF-16\"?>

<Application>
      <forms>
           <action type=\"update\">

               <form uid=\"1621670730\" left=\"399\" top=\"0\" width=\"759\" height=\"596\" client_width=\"725\" client_height=\"558\">               <datasources>

                         <DataTables>
                               <action type=\"add\" />
                         </DataTables>                             

                         <dbdatasources>

                              <action type=\"add\" />
                          </dbdatasources>
                          <userdatasources>
                              <action type=\"add\" />
                          </userdatasources>
                    </datasources>

                    <Menus />
                     <items>
                          <action type=\"update\">
                               <item enabled=\"0\" uid=\"ETDocNum\" />
                               <item enabled=\"1\" uid=\"FDTrackCT\" />
                               <item enabled=\"1\" uid=\"FDCCe\" />
                               <item enabled=\"1\" uid=\"FDDocAnt\" />
                          </action>
                     </items>
                     <ChooseFromListCollection>
                          <action type=\"add\" />
                     </ChooseFromListCollection>
                     <DataBrowser />
                     <Settings />
                </form>
           </action>
      </forms>
</Application>

Thanks,

Accepted Solutions (1)

Accepted Solutions (1)

pedro_magueija
Active Contributor

Hi Abel,

Remove all tags not used.

Here is a working sample.


<Application>

  <forms>

    <action type="update">

      <form uid="">

        <items>

          <action type="update">

            <item uid="">

            </item>

          </action>

        </items>

      </form>

    </action>

  </forms>

</Application>

You need to set the uid of the form and the uid of the item at runtime.


ps: I once tried to remove all valid values with XML, but there was an issue in the SDK that made it impossible. Adding is possible I'll check if that is still the case and if so, report to SAP. Message was edited by: Pedro Magueija

brunomilanez
Explorer
0 Kudos

Thanks Pedro,

Your template did work out. I am able to add valid values to comboboxes, alternate visibility of form items and change their positions. However I also want to act on the property 'Enabled' of some items, which I couldn't. Do you know if load batch actions does have support to this functionality? What are the load batch actions command limitations?

Former Member
0 Kudos

Hi Bruno,

of course you can declare it. the property is enabled="1" for enabled items and enabled="0" for disabled items.

Below you can found a sample for an enbled combobox

<item uid="cbWhs" type="113" left="120" tab_order="0" width="140" top="50" height="14" visible="1" enabled="1" from_pane="0" to_pane="0" disp_desc="0" right_just="0" description="" linkto="" forecolor="-1" backcolor="-1" text_style="0" font_size="-1" supp_zeros="0" AffectsFormMode="1">

              <AutoManagedAttribute/>

              <specific AffectsFormMode="1" TabOrder="4">

                <ValidValues>

                  <action type="add"/>

                </ValidValues>

                <databind databound="1" table="@MY_TABLES" alias="U_Whs"/>

              </specific>

            </item>

Kind Regards,

Evangelos D. Plagianos

brunomilanez
Explorer
0 Kudos

Hi Evangelos,

I already tried your solution with no success. It works only when adding items to a form, either system or user form. In my case, the form is already loaded, and I need to modify it, using the action type 'update', exemplified on Pedro's working sample.

Regards!

pedro_magueija
Active Contributor
0 Kudos

Hi Abel,

You should be able to also affect the Enabled status of an item. There are a few exceptions though:

On system forms you cannot enable a disabled item;

If you have AutoManagedAttributes set (you can set auto managed enable/disable viewable/unviewable that varies with the form mode) they may override your settings.

It's also possible that an error occurred, and you can get the error information by using: application.GetLastBatchResult();


Returns a string indicating the results (errors or warnings) of the last call to the LoadBatchActions method.


Pedro Magueija


LinkedIn Logo View Pedro Magueija's profile on LinkedIn
Follow @pedromagueija on Twitter

If this answer is helpful or correct, marking it as such is a form of saying thank you.

brunomilanez
Explorer
0 Kudos

Hi Pedro,

Application.GetLastBatchResult(); doesn't return any erros. It is not very helpful.

I don't recall now exactly if I tried to enable/disable items on user forms, so I am gonna check it out. On system forms I did it and it doesn't work as you said.

I will also check the auto managed attribute.

I'll post my tests as soon as I can.

Thank you for your help!

Answers (0)