Form.GetFromFile(file.xml)
Roberto Marra
Hi there,today Im getting crazy but finally I understood that the metod:
where file.xml is a file generated with ScreenPainter is not handable by the Form.AddHandler_Load(), this because alreday the method GetFromFile load the form.Form.GetFromFile("C:file.xml")
So my question is, how can add the AddHandler_Load to a form that I load thru the GetFromFile method?
Is that possible? And if not how can I handle the situation where I want to, still, do some stuff when I load the ScreenPainter generated file? I tried this:
Form.AddHandler_Load(Form.GetFormFromFile(@"FormXMLListaArticoli.xml").UniqueID.ToString(), ModeComponent.FormModes.ALL, ListaArticoli);
But dosn't work, I mean dosn't enter in the delegate "ListaArticoli"
Any help will be appriciate.
Thx
Rgs
Roberto
Marco Schweighauser
Hello Roberto,the Static form load method can be used for this. Instead of the XML code you have to hand over the form type:
Form.AddHandler_Load("My_Form_Type_As_In_The_Xml", ModeComponent.FormModes.ALL, ListaArticoli);
Kind regards,
Marco
Roberto Marra
Hi Marco,sorry I don't get your answer you mean that I can do:
Form.AddHandler_Load("ListaArticoli.xml", ModeComponent.FormModes.ALL, ListaArticoli);
Or something like:
Form listArticolitmp = GetFromAFile(@"C:ListaArticoli.xml");
Form.AddHandler_Load("listArticolitmp", ModeComponent.FormModes.ALL, ListaArticoli);
I don't get what you mean with "My_Form_Type_As_In_The_Xml". Is the attribute called FormType that if Im not wrong is set = "-1"?
Sorry Marco but Im a new with your framework.
Thx
Rgds
Roberto
Marco Schweighauser
Hello Roberto,No problem. In the XMl file there are two different form types. "FormType" is the old one and not used by SAP anymore. There must be a second one like FormTypeEx. This value you have to specify in the Load event to catch if a form of this type has been loaded.
Kind regards,
Marco
Roberto Marra
Im sorry but I cannot find any attribute or element calledin the srf file generated by ScreenPainter.FormTypeEx
Thx
Roberto
Massimiliano Luppis
Hello Roberto,maybe I found a solution also is almost a trick.
I run the project without the handler, move the mouse on the form and register the form type, in my case it was 60004.
Then I wrote the handler as suggested by Marco:
Form.AddHandler_Load("60004", ModeComponent.FormModes.ALL, ListaArticoli);
It seems to work.
Bye
Max
Roberto Marra
Hi Max,thx for your reply. Actually I did the same, but that ID is generated by SAP and is going to change if you open another instance of the same windows.
Bye
Roberto
Massimiliano Luppis
Hi Roberto,I tried to create several instances of the same form at the same time, but I got always the same form type "60004".
You are right when talking about the Unique ID, that is different for any form, but I think that in this case "60004" is the Form Type referred by Marco.
I also tried to create a form by code (no XML file), and if you use the statement:
frmProva = Form.CreateNew(FormType, FormUniqueID);
the first parameter is Type not UID, and Type seems remains always the same for all instances of the same form.
Max
Roberto Marra
Ok, Im goint to try again. Im just worried that if I install, let say my module on another SAP to, for instace, an external client, that system going to generate another ID... you know what I mean?Roberto
Massimiliano Luppis
Yeah, that could be a nightmare.However you can try to use some code trick, for example I found that if you have a form named frmProva, you can use the Type property to get the Type of the form.
Please note that this is not the same of the GetType method that returns the system object, frmProva.Type returns you the FormType ("60004" in my environment).
So you can try to create the form in PreInstall , catch the FormType and use it to add the handler.
I know there are some code to write and test, but this is the best that I can offer you.
Have a nice weekend
Max
Roberto Marra
Ok,I'll let you know.
Have a nice weekend too
Roberto
Roberto Marra
Hi,Im coming back to my problem. Sorry Massimiliano but your solution dosn't work with an XML generated by Screen Painter. To get a Form generated by ScreenPainter the only way is using the getFormFromFile(path & xmlfile) & when you are using this method the form is automatically loaded.
Still, I want to capture, in the same way as the SAP form, ex. 139, the Load event, with an AddHandler_Load my form, but seems is not possible.
Im I wrong? If is possible pls forward C# code as example.
Appriciate
Thx
Roberto
Adrian Meier
Hi RobertoIf you want to open more than one form of the same type, you have to have different form unique id's. You have to set it in this case in the xml, before you load it into SAP.
Example to replace unique id:
string formType = "NAMESPACE_FormType";
XmlNode uidNode = xmlNode.SelectSingleNode("/Application/forms/action/form[@uid]");
if (uidNode != null)
{
string uidSingle = uidNode.Attributes.GetNamedItem("uid").Value;
if (formType != null)
{
uidSingle = formType;
uidNode.Attributes.GetNamedItem("FormType").Value = formType;
}
string uidDef = uidSingle + "_" + SwissAddonFramework.Utils.UniqueStringGenerator.Next();
uidNode.Attributes.GetNamedItem("uid").Value = uidDef;
}
HTH, Adrian
Roberto Marra
Hi Adrian,thx for your reply. Your solution look very interesting, but thinking to other stuff.
My real need is just to add and handler in the load event of my ScreenPainter generated file, just that as same as you do when you're want to handle the Load event, for instance, of a Sales Order SAP form.
Thx
Roberto
Adrian Meier
Hi RobertoIt is not possible to add a screen painter form to an existing formn in the load event. I would propose that you catch the load event of the form and add the additional items by code. To do small changes the easiest way is to do it with coresuite customize.
HTH, Adrian
Roberto Marra
Hi Adrian,thank you for you confirm. I don't know if is possible, but maybe in the next version of coresuite you can add this feature (of course if there are lot of request - but seems not)
Thx anyway
Rgds
Roberto
Adrian Meier
Hi RobertoIt is not possible to do it with this function. It give possibilities to to that over loadbatchactions on the application object, but in this case you have to set paramters manually on xml. So the easier way is to extend existing forms by code.
HTH, Adrian
0
Please sign in to leave a comment.
Comments
0 comments