‎2007 Apr 04 4:30 PM
HI,
Which one is the best practice of declaring variable and why?
vbeln like vbak-vbeln
or
vbeln type vbeln.
does declaring LIKE will effect the performance of the program?
‎2007 Apr 04 4:33 PM
‎2007 Apr 04 4:33 PM
Hi!
Declaring will not affect the program runtime.
You can use the way you like better.
Regards
Tamá
‎2007 Apr 04 8:51 PM
Hi,
you can use LIKE to refer to any object that has been declared using DATA or a similar statement, and is visible in the current context. The object only has to have been declared. It is irrelevant whether the data object already exists in memory when you make the LIKE reference.
In principle, the local data objects in the same program are visible. As with local data types, there is a difference between local data objects in procedures and global data objects. Data objects defined in a procedure obscure other objects with the same name that are declared in the global declarations of the program.
<b>TYPE:</b>
Example: TYPE <type>
to refer to any data type <type> that is already known at this point in the program
When you refer to known data types using the TYPE addition, the visibility of the data types is important.
The predefined ABAP types (C, D, F, I, N, P, T, and X) are always visible. You cannot declare types with the same names as these data types, either in the program or in the ABAP Dictionary.
When we talk about the visibility of local data types in the program, we must differentiate between local data types in procedures and global data types. Data types defined in a procedure obscure other objects with the same name that are declared in the global declarations of the program. All local data types in a program obscure data types with the same names in the ABAP Dictionary. This also applies to data types from type groups.
In the ABAP Dictionary, different visibility rules apply to standalone data types and the data types stored in type groups. Data types in type groups obscure standalone data types with the same names. However, this should be an exceptional situation. All data types in the ABAP Dictionary should be in the same namespace. When you create a standalone data type, the system displays a warning if the name begins with the name of a type group followed by an underscore. Equally, you cannot create a type group if there is already a standalone data type with the same name followed by an underscore.
Regards
Sudheer
‎2007 Apr 04 11:56 PM
Performance wise there is not much of a difference but SAP is moving away from LIKE in OO context.
‎2007 Apr 05 5:48 AM
Hi Neha,
Bith the declarations are helpful and also best performance wise.
But for a huge program, we go for the <b>TYPES</b> declaration as it holds the reusability concept unlike the <b>LIKE</b> declaration. So in some kind, we can say that a little bit of performance can be improved using <b>TYPES</b> rather than <b>LIKE</b> in our program.
Hope this resolves your query.
Reward all the helpful answers.
Regards
‎2007 Apr 05 8:42 AM
I feel there will not be any performance difference while execution. If at all there can be any diffence, then it should be during the intermediate code generation. Both these codes will result in same ABAP intermediate codes and will be executed by the ABAP engine in same fashion.