Is there any fucntion to find the object size

In X++ coding is there any fucntion to find out the object size

It is a bit tricky - what do you actually mean by object size?
You can count text bytes in classes and jobs, but how would you interpret the size of the objects that do not consist just of the code only, for example forms, queries, reports…?
If form contains ActiveX control inside - do you count the control in?
If Report refers to external resourced images - do you take that into account as well?

Which object you want to find? map,container or array ??? You will check axapta system documentation method node may help you

good working

Ok, my answer was based on the idea that you want to find the size of AOT object… [H]

If you are talking about class objects, it is a different story…

To Janis Cehovs,

i understood the point…if i have only text is there any function

(lets think just i wrore a hello program) for that can i find the size of object ?

When you use search on AOT, you get a list of what has been found and there is a column in this form called “Size” which shows the size of the method where occurence has been found.

The form is SysAotFind - explore the way how it finds the size of the method.

I know, this is not a ready solution, it is just an idea where to dig further.

Otherwise - much better way to go:

There is system table called UtilIdElements and it has BLOB type field (CONTAINER) called “CODE” which represents the actual code on the node.

Select all your required CalssStaticMethod, ClassInstanceMethod type records for your objects on this table and get the size of that BLOB field. That is - done.

Here you go, just what you asked for, an example job that finds the size of the ‘newXMLMapCurrencyCode’ method (used in ‘XMLAxId2Code’ class):

static void Job5(Args _args)
{

UtilIdElements utilIdElements;
BinData binData;
Description elementName;
;

elementName = ‘newXMLMapCurrencyCode’;

select firstonly utilIdElements
where utilIdElements.recordType == UtilElementType::ClassStaticMethod &&
utilIdElements.name == elementName;

binData = new BinData();

binData.setData(utilIdElements.code);

info(strfmt(“Size of the %1 element is: %2 bytes”,elementName,strlen(binData.base64Encode())));

}

Nice one Janis…

I like this=)

Do you simply mean the string length?

str string = “Hello”;
container con;
System.String clrString = string;
System.Char[] chars;
int size;
;

size = strLen(string);
print 'str ', size;

size = clrString.get_Length();
print 'String ', size;

chars = clrString.ToCharArray();
size = chars.GetLength(0);
print 'Char[] ', size;

pause;

Hi janis,

what is utilledElements?

what is the use of Bindata Class?

Hai Daniel,

What is the pupose of using container con; in the above Code

Thanks & Regard

Hi Naresh*,*

None. I was thinking of adding an example using a container, but then changed my mind and forgot to remove the declaration.

Hi Saju,

  • BinData is used for byte arrays. You can, for example, use it to extract binary data from sql into a bitmap to print on a report:

container = BinData::loadFromBase64(strLRTrim(System.Convert::ToBase64String(System.Byte[])));

  • UtilIdElements is the same as UtilElements, except that UtilIdElements also contains a field for the id. These tables list all of the objects in the AOT and show when they were created, modified, the number of times saved and so on.

How to get the length of the container?

conlen()

Example - http://msdn.microsoft.com/en-us/library/aa599330.aspx

Use CONLEN()

http://msdn.microsoft.com/en-us/library/aa599330.aspx

use conLen(nameofcontainer)

/amigasger