‎2013 Dec 18 9:10 AM
Hi,
please, explain me the deference between the create object and create data statements in abap programming.
Regards,
Krishna.
‎2013 Dec 18 9:23 AM
‎2013 Dec 18 9:36 AM
Hi hasan,
Thanks for your reply.i have gone through the links .
my doubt is that,in create object the definition in like :-
CREATE DATA allows you to create fields in a pre-defined or user-defined data type .(the same we can achieve by using the types and data statements . ) .
can you please , explain me in detail .
Regards,
Krishna.
‎2013 Dec 18 10:23 AM
using CREATE DATA we can define something that is already declared.
like
FIELD-SYMBOLS: <WA> TYPE ANY.
DATA: WA_REF TYPE REF TO DATA.
CREATE DATA WA_REF TYPE (TAB_NAME).
but using types or data we can define anything new..
data : farid type c.
‎2013 Dec 18 10:27 AM
do one thing..
just write two lines..
CREATE DATA krishna TYPE C.
DATA krishna TYPE C.
& now check your program,
‎2013 Dec 19 5:33 AM
Hi farid hasan,
i got the conceptual definition now.thanks for sharing .and i did the sample code provided in the bc-aba document in my ides and executed and the program is terminated with a short dump ."OBJECTS_NOT_FLAT" at the select query ,below is the code for your reference ,
REPORT ZSA_SAMPLE.
PARAMETERS:
tab_name like sy-tname ,
tab_comp like X031L-TABNAME ,
nls type i default 10 .
FIELD-SYMBOLS : <lfs_dtab> TYPE ANY ,<lfs_dcomp> .
DATA : wa_ref TYPE REF TO data .
CREATE DATA wa_ref TYPE REF TO (tab_name) .
ASSIGN wa_ref->* to <lfs_dtab> .
SELECT * FROM (tab_name) INTO <lfs_dtab> UP TO nls ROWS.
WRITE :/ tab_comp,<lfs_dcomp>.
ENDSELECT .
And i changed it to
ASSIGN wa_ref->* to <lfs_dcomp> .
SELECT * FROM (tab_name) INTO <lfs_dcomp> UP TO nls ROWS.
then it is terminating with "TARGET AREA IS TOO SMALL" dump.
do u have any idea about this short dump.
thanks ,
krishna.
‎2013 Dec 18 2:22 PM
Create Object is used to create data object of user define type i.e, nothing but the class. And Create Data is used to create data object of predefined type like char, decimal, integer, structure,internal table.
Let say you have a class lcl_demo_class.
Then if you want to create a data object of type "lcl_demo_class" then you have to use create object as follows.
Data: obj type ref to lcl_demo_class. "Declaration of the reference. Please mark that data object
" is not created of type lcl_demo_class.
CREAT OBJECT obj.
and Create Data is used to create a data object of predefined type( c,i,d,p etc). It creates a data object dynamically.
data: obj type c.
create data c.
It will create a data object dynamically of type c.
Create Data do the same as the DATA. It will create a data of predefined type. Create Data is mainly used in RTTS(RunTime Type Services).
RTTS is used to create data type dynamically. Please mark, RTTS is used to define data type dynamically, not data object.
After defining the data type dynamically through RTTS, when you need to create data object of that type, then you need CREATE DATA.
Let me know if you have any doubt on this.
Thanks.
Gourab
‎2013 Dec 19 5:29 AM
Thankq gourab,thanks for your explanation .
regards,
krishna .
‎2013 Dec 18 4:15 PM
Hi,
Create Object creates reference to Object( which is runtime instance of class).
Create Data creates reference to Data(which is other than class and interface).
We can access object attributes by objectreference->attribute
but we cannot access data with data reference,we should dereferenced it to get value
datareference->*
Regards,
Sreenivas.
‎2013 Dec 19 5:34 AM