|
That's an X-Y-Problem. As usual. There is a problem, someone has an idea of how to tackle it, and experiences a problem on that way - now the question is how to continue that way.
Instead of the correct question: what does the customer really need, and - next (nto same!) question - how can that be accomplished. A totally common problem in requirements engineering....
|
|
|
|
|
|
Hello everybody.
I'm not familiar with ABAP at all and I'm trying to automate a SAP report for my job.
At the momment I gotta open SAP (manually of course), login, call the transaction, add some parameters to it, execute it and download the first report. After that I have to work it around (thing that I already automate, so it's not a problem) but then I have to get some other parameters from it and call another transaction to execute with the new parameters that I got from the first report... And so on 2 more times.
My problem is that, after automating all the excel related stuff with C#, I can't find a way to interact with SAP R/3 to login, call the transaction, execute with the parameters and get the report.
Can somebody give me a hint about this?
I googled for a couple of hours and all I found out is that I may have to work with RFC's and BAPI's but I still can't figure out how to do it nor how to use these properly (if I'm right that I have to)
Thanks in advance,
Goliadkin.
|
|
|
|
|
Anyone, something?
|
|
|
|
|
Hi,
first time poster.
I have been programming for quite a while (and used code project quite a lot) but have so far avoided to use XML files.
Now I have to and while I can parse the data, and read values, it still escapes me how XML is the new, so easy way to store ans retrieve data.
I have a XML structure that basically contains a list of files on a hard drive and while I can imagine all kinds of complicated loops to list all paths and files in a list box, I cannot find an easy way to accomplish that.
(I which I could upload an image of the structure
so here it is a code.
The length of the path (Contained folder) is totally arbitrary of course:
Thanks a lot for any input!!!
<pre>
<pre>
-<Drive>
<Name>C:</Name>
-<ContainedFolders>
-<Folder>
<Name>Program Files</Name>
-<ContainedFolders>
-<Folder>
<Name>VirtualBox</Name>
-<ContainedFolders>
<pre><Name>TEST</Name >
-<ContainedFiles>
-<File>
<Name>qtaccessiblewidgets4.dll</Name>
|
|
|
|
|
XML really wasn't designed to be a database if that's what you mean by "store and retrieve data". It's more intended for the formatting, serialization, transmission and transformation of data. It just so happens that XML is a text format that happens to be very easily stored on any storage medium.
In any case, I think your schema could be laid out a bit better. Such as:
<drives>
<drive identifier="C">
<folders>
<folder name="Program Files">
<folders>
<folder name="Some Folder">
<folders />
<files>
<file name="MyApplication.exe" size="1064322" />
<file name="MyLibrary.dll" size="103223" />
</files>
</folder>
<files />
</folders>
</folder>
</folders>
<files>
<file name="Some Junk.txt" size="2310" />
</files>
</drive>
</drives>
A better option would be to skip trying to worry about the details of the XML file and worry more about your class definitions that can be serialized into an XML file. That way you can just build an object graph with the data you're tracking and then just send it to the XmlSerializer and it'll create the XML file for you.
The same serializer can be used to reconstitute the graph from the XML data it wrote.
modified 7-Aug-14 1:33am.
|
|
|
|
|
Do you have a schema definition (*.xsd file) for that type of XML files? If so, you can easily generate classes for handling the data with the xsd tool, e.g.
xsd.exe D:\Temp\gpx.xsd /classes /out:D:\Temp /language:CS
|
|
|
|
|
Assuming you're just looking to get a list of the full paths of all the <File> elements, then LINQ makes this reasonably simple:
static string GetFullPath(XElement fileElement)
{
var names = new HashSet<XName> { "Drive", "Folder", "File" };
IEnumerable<string> pathParts = fileElements.AncestorsAndSelf()
.Where(el => names.Contains(el.Name))
.Select(el => (string)el.Element("Name"))
.Reverse();
return string.Join("\\", pathParts);
}
...
const string xml = @"<Drive>
<Name>C:</Name>
<ContainedFolders>
<Folder>
<Name>Program Files</Name>
<ContainedFolders>
<Folder>
<Name>VirtualBox</Name>
<ContainedFolders>
<Folder>
<Name>Test</Name>
<ContainedFiles>
<File>
<Name>qtaccessiblewidgets4.dll</Name>
</File>
</ContainedFiles>
</Folder>
</ContainedFolders>
</Folder>
</ContainedFolders>
</Folder>
</ContainedFolders>
</Drive>";
XDocument document = XDocument.Parse(xml);
IList<string> filePaths = document.Descendants("File").Select(GetFullPath).ToList();
LINQ[^]
LINQ to XML[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi
This is driving me nuts.
Besides my first structure containing "drive" information, I also have a registry content XML file.
I thought I'd just apply some analogy and it sort of works but for some reason I do not seem to be able to dig deeper into the structure than <value> but I would like to get the value of <action>, <type> and <content> (inside if <value> too.
So here is the structure:
<Registry>
<RootKey>
<Name>HKEY_LOCAL_MACHINE</Name>
<Action>None</Action>
<ContainedKeys>
<Key>
<Name>SOFTWARE</Name>
<Action>None</Action>
<ContainedKeys>
<Key>
<Name>Classes</Name>
<Action>None</Action>
<ContainedKeys>
<Key>
<Name>Installer</Name>
<Action>None</Action>
<ContainedKeys>
<Key>
<Name>Features</Name>
<Action>None</Action>
<ContainedKeys>
<Key>
<Name>8CD5D2FB0DBCDD64A8D2AB1D09CAF271</Name>
<Action>Created</Action>
<ContainedValues>
<Value>
<Name>ClientPrograms</Name>
<Action>Created</Action>
<After>
<Data>
<Type>REG_SZ</Type>
<Contents></Contents>
</Data>
</After>
</Value>
<Value>
<Name>DataFiles</Name>
<Action>Created</Action>
<After>
<Data>
<Type>REG_SZ</Type>
<Contents>Server</Contents>
</Data>
</After>
</Value>
Using the example that Richard gave, my code is:
<pre
IList<string> Regs = document.Descendants("Value").Select(GetFullPathtoKey).ToList();
static string GetFullPathtoKey(XElement fileElement)
{
var names = new HashSet<XName> { "RootKey", "Key", "Value","Type", "Name", "Data", "Contents" };
IEnumerable<string> pathParts = fileElement.AncestorsAndSelf()
.Where(el => names.Contains(el.Name))
.Select(el => (string)el.Element("Name"))
.Reverse();
return string.Join("\\", pathParts);
}
<pre lang="text">
That works fine and a list entry is for instance:
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Features\8CD5D2FB0DBCDD64A8D2AB1D09CAF271\ClientPrograms
But if I extend the Path to include , it will just not work:
Like:
<pre
IList<string> Regs = document.Descendants("Data").Select(GetFullPathtoKey).ToList();
static string GetFullPathtoKey(XElement fileElement)
{
var names = new HashSet<XName> { "RootKey", "Key", "Value","Type", "Name", "Data", "Contents" };
IEnumerable<string> pathParts = fileElement.AncestorsAndSelf()
.Where(el => names.Contains(el.Name))
.Select(el => (string)el.Element("Contents"))
.Reverse();
return string.Join("\\", pathParts);
}
<pre lang="text">
will give \\\\\\\\ for the first entry and
\\\\\\\Server for the second.
No I can create three lists for the path with Value, the Action and the Content, but that seems to be overkill.
After extracting the Path: "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Features\8CD5D2FB0DBCDD64A8D2AB1D09CAF271\ClientPrograms"
how can I derive easily the Action, Type and the Content???
I have been piddling with this for the whole weekend without success. I guess I do not understand what the difference is
between the path to <value> and the path to .
Thanks a lot for any help!!!!
|
|
|
|
|
The problem with your second method is that your <Value> , <Key> and <RootKey> elements don't contain an element called "Contents". That means that you'll get the value from the <Contents> element under the <Data> element, and an empty string for each ancestor element.
If you just want to append the value from the <Contents> element to the path, then use:
static string GetFullPathToKey(XElement dataElement)
{
var names = new HashSet<XName> { "RootKey", "Key", "Value", "Data" };
IEnumerable<string> pathParts = dataElement.AncestorsAndSelf()
.Where(el => names.Contains(el.Name))
.Select(el => (string)el.Element("Name") ?? (string)el.Element("Contents"))
.Reverse();
return string.Join("\\", pathParts);
}
IList<string> Regs = document.Descendants("Data").Select(GetFullPathToKey).ToList();
If you want to include the <Action> , <Type> and <Content> in a different format, then try something like this:
static string GetFullPathToKey(XElement dataElement)
{
var names = new HashSet<XName> { "RootKey", "Key", "Value" };
IEnumerable<string> pathParts = dataElement.AncestorsAndSelf()
.Where(el => names.Contains(el.Name))
.Select(el => (string)el.Element("Name"))
.Reverse();
string fullPath = string.Join("\\", pathParts);
string details = string.Format(" {{ Action: '{0}', Type: '{1}', Contents: '{2}' }}",
(string)dataElement.Element("Action"),
(string)dataElement.Elements("After").Elements("Data").Elements("Type").FirstOrDefault(),
(string)dataElement.Elements("After").Elements("Data").Elements("Contents").FirstOrDefault());
return fullPath + details;
}
IList<string> Regs = document.Descendants("Value").Select(GetFullPathToKey).ToList();
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you Richard!!!
I really appreciate your help.
|
|
|
|
|
You must be a true XML Linq wiz!
|
|
|
|
|
Thank you everybody
Sorry, I did not get the formatting right ...
Richard, the "Descendants" look very promising.
Bernhard, thanks for the xsd tip, I'll have to check this out - again, first time XML user.
Dave, thanks for the reformatting. No I do not want to use XML as a database,
but this is the output of a disk analysis tool, that I need a human (management ) readable report of.
Thanks again
|
|
|
|
|
eblaschka wrote: this is the output of a disk analysis tool, that I need a human (management ) readable report of.
That would have helped if you put that in your original post. I wouldn't have suggested you start with the classes then.
I would agree with Bernhards use of the XSD tool to generate the classes for you. You could still use link over that object graph to your report data.
|
|
|
|
|
Thank you Dave for cleaning up my XML code, I really screwed up the format.
I definitely do not want to use XML as a database, but I do have an output file that I have to make human (rather: Management ) readable for reports.
Thanks Bernhard, I will have to look into the xsd stuff.
Thanks Richard, your "Descendant" method. It works great, BUT only if I cut the file between <drives> part. (The Structur is bigger).
That is not a big issue, but is there something like "get everything from <file> and <drive> " ???
(How does "GetFullPath" know where to stop?)
Thanks a lot to all.
|
|
|
|
|
If you reply to someone's message, then they get notified that you've replied. If you reply to yourself, then nobody else will be notified.
There's almost certainly a way to make it work, but without knowing the full structure of your XML file, we can only guess:
static string GetFullPath(XElement fileElement)
{
var names = new HashSet<XName> { "Drive", "Folder", "File" };
IEnumerable<string> pathParts = fileElements.AncestorsAndSelf()
.TakeWhile(el => el.Name != "Drives")
.Where(el => names.Contains(el.Name))
.Select(el => (string)el.Element("Name"))
.Reverse();
return string.Join("\\", pathParts);
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
Hi,
I have a C# WIndows Application Form with MySQL backend (which can be on Windows or Linux Server).
I want my application to send email notifications about the contracts data in my applications (contracts expiry notifications) by email according to a schedule(probably daily once)
What's the best cross platform way to do it which will work on windows and linux server?
Thanks
Technology News @ www.JassimRahma.com
|
|
|
|
|
There are some scripting languages available which can be used both on Linux and Windows, e.g. PERL. But do you really want to learn a new programming language just for that task, including all the WTFs of scripting languages?
I'd suggest to use a Windows Service which connects to your database to retrive the information and then sends the emails. Alternatively, a "normal" Windows console application is started as a "scheduled task" and does that job.
|
|
|
|
|
WIndows Services is fine but not when the user is away or traveling and don't have access to his PC which means the windows services will not run because his PC is switched off because the server side could be linux not windows!
Technology News @ www.JassimRahma.com
|
|
|
|
|
Jassim Rahma wrote: the windows services will not run because his PC is switched off Well, I do not know of any application or service to run on a switched-off computer...
|
|
|
|
|
What is Framework of .net and its features?
Shail...
|
|
|
|
|
Here you go. There's plenty of good material here[^].
|
|
|
|
|
Wow, Pete, you are a genius!
|
|
|
|
|
You can google this to find enough resources.Your question should be as specific and concise as possible.It would be good if it is related to a practical real time issue
Thanks
Do not forget to comment and rate the article if it helped you by any means.
|
|
|
|
|