Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Declaring Variable

balaji_viswanath
Participant
0 Kudos
88

Hi,

I declared a variable for material number as "g_matnr TYPE mara-matnr" but my QA person has raised a point saying I should declare variable as "g_matnr TYPE matnr" i.e. he asks me to directly refer data element instead of table name-fieldname and also he says directly referring data element improve the performance. Is it correct? Will it really improve the performance?

Advance thanks.

Regards,

Balaji Viswanath.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
59

Hi Balaji,

What max said is true...

You wont see a great improvement in performance.. because that resolution of field to data element will probably take a micro second or lesser...

But it is generally a good practise to give the data element so that the system doenst have to do this resolution at runtime.

So ur QA said the right thing..

And rememebr to reward the points to answer that helped you most and close the thread.

Rgds,

Prabhu.

10 REPLIES 10

Former Member
0 Kudos
59

Pehaps it's true...i think the system can bypass one step: the system doesn't has to check which data element is linked to your dictionary field (MARA-MATNR in your case).

When it uses stataments 'data my_var like ....', the variable get the characteristics that are defined in data element and domain linked to dictionary field.

0 Kudos
59

The important question is if you want to refer to the dictionary or the mentioned field in a table (or structure). If you're working with the mentioned structure or table I would prefer the use of "like" in case the theoratical event occurs that SAP decides to change the type of certain table-fields.

Former Member
0 Kudos
60

Hi Balaji,

What max said is true...

You wont see a great improvement in performance.. because that resolution of field to data element will probably take a micro second or lesser...

But it is generally a good practise to give the data element so that the system doenst have to do this resolution at runtime.

So ur QA said the right thing..

And rememebr to reward the points to answer that helped you most and close the thread.

Rgds,

Prabhu.

0 Kudos
59

Thanks Max and Prashanth, I am ready to declare some 10 variables in both the ways and check the performance... how to do it.. can you please tell me Transaction code to trace performance.

Advance thanks.

Regards,

Balaji Viswanath.

0 Kudos
59

SE30 is the runtime performance analysis.

Regards,

Rich Heilman

0 Kudos
59

try SE30 or ST05

I am pretty sure you won't find much difference in performance.. the QA is person only trying to make you adhere to the standards..

Good luck,

Suresh Datti

0 Kudos
59

Hi Balaji,

Go for transaction code : SE30 thats enough.

Bye....

sri.

0 Kudos
59

Balaji,

SE30 is the transaction where you can check for performance. But take it from me, that you will not see much difference in performance. Because, as I said in my earlier post, the performance improvement u get by declaring these by directly referring to the data element is very small. however it is a good practise to do it this way.

Kindly reward points.. and if ur Q is answered, close this post.

Prash.

Former Member
0 Kudos
59

Hi,

It will surely improve ur performance, u r refering directly yo a dataelemnt in the case of

g_matnr TYPE matnr

but in the other case u referring to a table and then to its field.

SO it will take a bit ime more to fetch the type.

U can also give as

g_matnr LIKE matnr

To check for performance u can do a performance check in the program itself. Or u can do in ST05.

Hope this helps.

Kindly reward and close the thread.

Former Member
0 Kudos
59

you will surely get good performance,

BUT YOU WILL NOT HAVE F4 (default from database) facility.

regards