Little tip to get the nr of elements in a local structure using RTTI
sometimes you need to know the number of elements in a structure for manpulating data
for example you might need to convert the elements in an internal table to a special file format such as "field","field",......"field".
instead of something like this where you have counted the number of elements in your structure
you can obtain the number of elements dynamically. This saves changing the code each time you change the structure and can avoid errors.
data: zstring type string
data: zstring1 type string.
lv_index = 1.
WHILE lv_index LE 47.
.CLEAR zstring.
ASSIGN COMPONENT lv_index OF STRUCTURE your_ structure TO <fsa>.
CONCATENATE '"' <fsa> '"' INTO zstring.
CONCATENATE zstring1 zstring INTO zstring1.
CONCATENATE zstring1 ',' INTO zstring1.
lv_index = lv_index + 1.
CLEAR zstring.
endwhile
lv_index = 48.
ASSIGN COMPONENT lv_index OF STRUCTURE wa_interface_contracts TO <fsa>.
CONCATENATE '"' <fsa> '"' INTO zstring.
CONCATENATE zstring1 zstring INTO zstring1.
CONDENSE zstring1. "Left align all data fields within the string
APPEND zstring1 TO ta_string1.
CLEAR zstring.
CLEAR zstring1.
lv_index = 1.
Using the RTTI
DATA lr_rtti_struc TYPE REF TO cl_abap_structdescr .
DATA: zog LIKE LINE OF lr_rtti_struc->components .
DATA: zogt LIKE TABLE OF zog,
CREATE DATA dref TYPE your_structure
ASSIGN dref->* TO <fs>.
lr_rtti_struc ?= cl_abap_structdescr=>describe_by_data( <fs> ).
* get the structure details into a table.
* table zogt[] contains the structure details
zogt[] = lr_rtti_struc->components.
now the nr of rows in this table contains the number of elements in your structure.
cheers
jimbo
hi Jimbo,
why don't you start blogging?
ec
Similar Messages
-
How to get the number of elements in a tilelist
I'm writing test cases for a flex application using FlexSelenium and I need to get the number of elements displayed in the tilelist.
I know that that the tilelist is fed by an array. but i can't access that array from my test case.
Can anyone tell me how I can get the number of elements in a tilelist on the application? which property of the tilelist can provide that number?try tileList.dataProvider.length;
-
How to get the number of elements in DB
Could you tell me how to get the number of elements in DB??
My code to get the number is below, but I think it is not efficient
DB->cursor(DB, NULL, &cursorp, 0);
while ((ret = cursorp->c_get(cursorp, &key, &data, DB_NEXT)) == 0)
count++;
--------------------------------------------------------------------------------------------------------------Hi,
The most efficient way to get a count from the database is using the DB->stat API (http://docs.oracle.com/cd/E17076_02/html/api_reference/C/dbstat.html)
The code will be something like:
DB *dbp;
DB_BTREE_STAT *statp;
int ret;
/* Print out the number of records in the database. */
if ((ret = dbp->stat(dbp, NULL, &statp, 0)) != 0) {
dbp->err(dbp, ret, "DB->stat");
goto err1;
printf("%s: database contains %lu records\n",
progname, (u_long)statp->bt_ndata);
free(statp);The code comes from the example included in the distribution at examples/c/ex_btrec.c
If the database isn't a btree, you should update to the appropriate statistics structure and field.
It's worth noting that retrieving the count is never a "cheap" operation. The count is not stored in the database - since doing so introduced a single point of contention that creates a bottle neck.
Regards,
Alex Gorrod
Oracle Berkeley DB -
Hello!
I'm trying to create a kind of a navigation tree for my application.
It should represent some elements of an XML structure and some other nodes for other options.
The binding with the context is not a problem, I can create the tree up to all the levels I want to.
The problem now is, that I don't know, how to get the "current tree element", when there is any action.
For example:
public void onActionSelect(...) {
String test = wdContext.currentTreeNodeElement().getText();
wdThis.wdGetContext().currentContextElement().setSelectedElement(test);
With this method I can get the text of the "first level nodes". If I want to get the "second level node", I can do
String test = wdContext.currentTreeNodeElement().currentChildElement.getText();
..and for the next levels so on.
Isn't there any general method to get the information of the selected element without knowing before, whether it is a nodeElement or a nodeElement.currentChildElement or a nodeElement.currentChildElement.currentChildElement, ...?
Greetings,
RamóHi,
if you following that pdf ,
i think your not implemented the below code in DomodifyView method
if (firstTime) {
IWDTreeNodeType treeNode = (IWDTreeNodeType) view.getElement("TheNode");
/* The following line is necessary to create parameter mapping from parameter "path" to parameter "selectedElement".
Parameter "path" is of type string and contains the string representation of the tree element (its corresponding context element to be exact)
that raised the onAction event. Parameter "selectedElement" is of type IWDNodeElement (or extends it) and is defined as parameter in the event handler
that handles the onAction. The parameter mapping defined here translates the String "path" into the corresponding context element that then can
be accessed within the event handler
treeNode.mappingOfOnAction().addSourceMapping("path", "selectedElement");
/* The following line is necessary to create parameter mapping from parameter "path" to parameter "element".
Parameter "path" is of type string and contains the string representation of the tree element (its corresponding context element to be exact)
that raised the onLoadChildren event. Parameter "element" is of type IWDNodeElement (or extends it) and is defined as parameter in the event handler
that handles the onLoadChildren. The parameter mapping defined here translates the String "path" into the corresponding context element that then can
be accessed within the event handler
treeNode.mappingOfOnLoadChildren().addSourceMapping("path", "element");
please cross check once.
Thanks,
Ramesh -
How to get the current node element by its value?
e.g,:
wdContext.current<b>Deal</b>Element().setAttributeValue("<i>deal_id</i>","<i>aaaaaaa</i>");
above code can get the result i wanna.
but now i wanna in terms of its node'name to set attribute vaue of itself. in other words,i have no idea about how to get the current node element by its name"<b>Deal</b>".Hi Wing,
The answer is there in your question itself.
wdContext.currentDealElement()
will give you the current node element by its name"Deal" or you could use
wdContext.nodeDeal().getCurrentElement()
or you could use
wdContext.nodeDeal().getElementAt(wdContext.nodeDeal().getLeadSelection())
Regards,
Sudeep -
Get the number of elements in Array
Hi everyone,
Could anyone give me idea on how to get the number of elements in an Array (not number of rows) ?
I tried to find that in both property node and array functions but nothing.
Thanks,
-KunYou are going to have to provide some proof that the Array Size does not work correctly. Right click on the input to it and select 'Create Indicator'. Run the VI. Go to the front panel and select 'Edit>Make Current Values Default'. Save the VI and attach it to your post.
You can also check the array size yourself. Right click on the index display of the array and select 'Advanced>Show Last Element'. I will bet you that number shown is equal to Array Size -1.
p.s. The number of elements in an array is equal to the number of rows in a 1D array. If you define the number of elements as anything else, you are mistaken.
Message Edited by Dennis Knutson on 04-21-2009 10:40 AM -
I have Photoshop Elements 7.0 and when I go to sort the photos in order (from oldest date) I keep getting the message "Photoshop Elements 7.0 has stopped working" and then the program closes. Sometimes, eventually it has sorted as I request but today this has been rejected over 15 times. What is wrong?
Try the licensing service update:
http://helpx.adobe.com/creative-suite/kb/error-licensing-stopped-windows.html
EDIT I see that maybe you did (is that the patch you mean? ); if so, try the other suggestions there. -
Get the Required Field Element in orchetsration
My input instance is as follows:
<ns0:Students xmlns:ns0="http://CallTemplate_Increment.StudentSchema">
<StudentTransactions>
<ID>100</ID>
<RowIndicator>H</RowIndicator>
<FName>Prakash</FName>
<LName>Sajwan</LName>
<ID_Detail/>
<Cost/>
<GL_String/>
</StudentTransactions>
<StudentTransactions>
<ID/>
<RowIndicator>D</RowIndicator>
<FName></FName>
<LName></LName>
<ID_Detail>100</ID_Detail>
<Cost>200</Cost>
<GL_String>300.890.830.777</GL_String>
</StudentTransactions>
<StudentTransactions>
<ID/>
<RowIndicator>D</RowIndicator>
<FName>D</FName>
<LName></LName>
<ID_Detail>100</ID_Detail>
<Cost>200</Cost>
<GL_String></GL_String>
</StudentTransactions>
<StudentTransactions>
<ID/>
<RowIndicator>D</RowIndicator>
<FName>D</FName>
<LName></LName>
<ID_Detail>100</ID_Detail>
<Cost>100</Cost>
<GL_String>300.890.830.777</GL_String>
</StudentTransactions>
<StudentTransactions>
<ID>200</ID>
<RowIndicator>H</RowIndicator>
<FName>Ramesh</FName>
<LName>Rawat</LName>
<ID_Detail/>
<Cost/>
<GL_String/>
</StudentTransactions>
<StudentTransactions>
<ID/>
<RowIndicator>D</RowIndicator>
<FName>D</FName>
<LName/>
<ID_Detail>200</ID_Detail>
<Cost>700</Cost>
<GL_String>500.890.830.777</GL_String>
</StudentTransactions>
<StudentTransactions>
<ID/>
<RowIndicator>D</RowIndicator>
<FName>D</FName>
<LName/>
<ID_Detail>200</ID_Detail>
<Cost>900</Cost>
<GL_String>500.890.830.777</GL_String>
</StudentTransactions>
</ns0:Students>
If RowIndicator is H then required field is RowIndicator,FName,ID.
IF RowIndicator is D then required field is RowIndicator, ID_Detail,Cost,GL_String.
Now if any required field is empty then store the name of these Elements in a file and send this file in the attachment in mail.And how can I uniquely identify that these information is for particular student.
H stands for header and D stands for details.
One Record (which RowIndicator is H) belongs to other record (which RowIndicator is D) only when ID of
record (which RowIndicator is H) equals to ID_Details of record(which RowIndicator is D).
Any Help would be appreciated.I want to do it orchestration after getting the message by calling a c# function. I have written the attachment function for sending mail.I just want to put those information in a file.
PrakashIn Orchestration, you can call a helper method as the following, where you can apply the validation log and either constructs a XML-Message with error details or a simple error string message with error details appended which you can pass to your email program
and send email.
public static string ContractValidationMsg(XmlDocument xmlInput)
string sErrorMessage = String.Empty;
//Get the HeaderID
XmlNodeList headerNodes = xmlInput.SelectNodes("/*[local-name()='Students' and namespace-uri()='http://CallTemplate_Increment.StudentSchema']/*[local-name()='StudentTransactions' and namespace-uri()=''][RowIndicator='H']");
//Loop thur all the filtered header node
foreach (XmlNode headerNode in headerNodes)
string sHeaderID = headerNode.SelectSingleNode("/*[local-name()='Students' and namespace-uri()='http://CallTemplate_Increment.StudentSchema']/*[local-name()='StudentTransactions' and namespace-uri()='']/*[local-name()='ID' and namespace-uri()='']").InnerText;
//Get the DetailID for the filtered ErrorID
XmlNodeList detailNodes = xmlInput.SelectNodes("/*[local-name()='Students' and namespace-uri()='http://CallTemplate_Increment.StudentSchema']/*[local-name()='StudentTransactions' and namespace-uri()=''][RowIndicator='D'][ID_Detail='" + sHeaderID + "']");
//Loop thru the DetailID
foreach (XmlNode detailNode in detailNodes)
string sCost = detailNode.SelectSingleNode("Cost").InnerText;
//Check Cost in detail is empty, if so then construct the error message
if (sCost == String.Empty)
sErrorMessage +=sErrorMessage + " For HeaderID:" + sHeaderID + " , In its Detail node, value for Cost element is missing /n" ;
string sGL_String = detailNode.SelectSingleNode("GL_String").InnerText;
//Check GL_String in detail is empty, if so then append the error message
if (sGL_String == String.Empty)
sErrorMessage += sErrorMessage + " For HeaderID:" + sHeaderID + " , In its Detail node, value for GL_String element is missing /n";
return sErrorMessage;
This is just to give you an idea and you and fine-tune it to fit your requirement. The above code is a working code.
If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply. -
How to get the list of values for a dynamic parameter using Web Services SDK?
<p>I am struggling to get the list of values for a dynamic parameter of a report.</p><p>I am using Java Web Services SDK ... I tried to use PromptInfo.getLOV().getValues() method but it does not work.</p><p>First of all ... is this possible (to get the list of values for a dynamic param) using Web Services?</p><p>Second of all, if this is possible, how should I do it ... it seems it works fine when running the report from CMC. It asks for DB logon info and after that it provides a list of values.</p><p>Thx </p>
<p>Your assumption is correct. We are trying to get the LOVs from the Crystal Report. I was not aware that this is not supported by Web Services SDK.</p><p>We used Web Services SDK to integrated the Crystal Reports in our web application. We implemented some basic actions for reports: schedule, view instances, run ad-hoc reports.</p><p>We encountered this problem when trying to run/schedule reports with dynamic parameters (a list of values from DB). We were unable to get the LOVs.</p><p>Please let me know if you can think of an alternative to look at.</p><p>Thanks a lot,</p><p>Catalin </p>
-
I have an Apple ID and trying to sign in for the 1st time on iTunes. When I do, I get the message: "This Apple ID has not been used with the iTunes Store. Please review your account information." When I do, it brings me to the same AppleID login window, and I get stuck in the same loop. I never get to the following screen to enter my account info. What's going on?? This is MADDENING!
If you want to use it, click Review and check your account information. Or you could contact the store support staff if you are concerned at http://www.apple.com/emea/support/itunes/contact.html for further help.
-
My mac had to have a new hard drive in its first year. Now, when I try to get the key code for office it tells me its already been used. How do i get the office I've paid for but never used?
The product key is sent to you by email as part of the purchase confirmation.
If you have lost it, log into your Microsoft account. -
HI, Im using Iphone 4 and i recently got my IOS updated to IOS7 and now im getting the error message as "PDP authentication failure" Im using Aircel carrier.
Please let me know how to fix this issueupdate...
I am not one to give up. So I called AT&T today. Now they are telling me they canceled my order because they were unable to fulfill my order. Basically, AT&T told me they sold out so they canceled my order so I can proceed to reorder again. It took them 4 days to realize this. I will be lucky if I get a new phone by Christmas. I am sure they will find a way to cancel my order again.
Again, I argued, how is this my fault. I placed my order at the store around 11 a.m. Pacific time. My friend ordered his phone online sometime after me. He got his but my order was canceled. AT&T tried to explain to me that they sold over 600,000 phones, almost 500 per minute during there peak. Again, I asked, how this was my fault.
I can understand over selling the phone. It is a great product. There is no reason to cancel my order. You adjust my order and tell me you will let me know when my phone will be in. I would have been mad that my phone was going to be late but I would have survived. At least I would be getting one.
At this point, I have no order and AT&T or Apple website will allow me to order one. I just want to get in the QUEUE for one.
Frustrated. -
I can no longer charge my iPhone5 through either of my macbook pros. I get the error message that a USB device is using too much power. Can anyone help?
I reconnected the original powered hub that I thought probably caused the problem and this time it shut down the whole computer. When I rebooted everything now works perfectly. The system reset. I tried another powered hub and it didn't have the same effect so the old one is heading for the bin and with fingers crossed all systems are now working perfectly. Trying to reset PRAM or reset the SMC didn't work but causing the same power issue did. Thanks for your input though. It did get me to think what was the original cause.
Cheers
Guy -
I get the error "missing or invalid personalization information" This used to run, I'm now on Windows 7 64 bit. Anyone have any ideas please? Thanks.
Hi,
If my memory serves me right (it’s some while since I changed and I have not used Photoshop for some years…) I was running it on XP. I upgraded to Win 7 on a new machine but ported across files, programmes etc. I cannot recall if Photoshop ever ran on Win 7.
I have tried to reinstall but the CD is warped and despite applying pressure to it neither of my drives likes it. I have Photoshop 7 on my third hard drive, a portable drive, which came from the XP machine.
Sorry, long-winded but I hope it helps. -
How to get the query result of improvement (Before and After ) using sql de
how to get the query result of improvement (Before and After ) using sql developer.
Check
http://www.oracle.com/technetwork/articles/sql/exploring-sql-developer-1637307.html
Maybe you are looking for
-
.mts files out of sync audio when importing in Premiere Pro CC
When I import .mts files from my nxcam in Premiere Pro CC, the audio of the clips in not in sync. Can anybody help me with this issue? Thank you!
-
I see * in some of rows in web report ?
Hello all, When i am running some of my reports in web I see only * in some cells and when I export it to excel i can see the actual value. Is there any setting that i need to do do for web. ? The two rows that are not showing up properly and showing
-
How can i import .vcf file to iPhone ?
contacts .vcf
-
Can't find photos after upgrading to Windows 7
Bridge was working fine in Vista but after upgrading to Windows 7, I cannot find any of my photo files with bridge. Photoshop CS4 find them OK and so does Lightroom but for some reason Bridge does not list them under Folders. If I click on Librarie
-
Missing Palettes in illustrator CC after clean install
I recently had to do a clean install on my mac with Yosemite and had to uninstall CC and then reinstall, ever since I have had problems with the palettes not appearing when selected, has anyone else had this or similar problems? I did a bit of resear