06-08-2007 7:16 AM
whats basic difference between data and types while declearing the internal tables...
DATA : BEGIN OF t_vbap OCCURS 0,
vbeln1 LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
kwmeng LIKE vbap-kwmeng,
netpr LIKE vbap-netpr,
netwr LIKE vbap-netwr,
werks LIKE vbap-werks,
matnr LIKE vbap-matnr,
arktx LIKE vbap-arktx,
END OF t_vbap.
vs
TYPES : BEGIN OF t_vbap,
vbeln1 LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
kwmeng LIKE vbap-kwmeng,
netpr LIKE vbap-netpr,
netwr LIKE vbap-netwr,
werks LIKE vbap-werks,
matnr LIKE vbap-matnr,
arktx LIKE vbap-arktx,
END OF t_vbap.
and vs
TYPES : BEGIN OF t_vbap,
vbeln1 LIKE vbeln,
posnr LIKE posnr,
kwmeng LIKE kwmeng,
netpr LIKE netpr,
netwr LIKE netwr,
werks LIKE werks,
matnr LIKE matnr,
arktx LIKE arktx,
END OF t_vbap.
06-08-2007 7:53 AM
hi,
like -> used for refering existing data elements in data dictionary or in sap
type -> used for refering existing data types in sap.
types: used for creating used defined structure of tables which has fields from more tahn one table.
diff b/w types and type in creation of internal tables is that when u create a table with types then u can use same for work area creation also.
ex:
TYPES : BEGIN OF t_vbap,
vbeln1 LIKE vbeln,
posnr LIKE posnr,
kwmeng LIKE kwmeng,
netpr LIKE netpr,
netwr LIKE netwr,
werks LIKE werks,
matnr LIKE matnr,
arktx LIKE arktx,
END OF t_vbap.
data: itab1 type t_vbap
wa_itab1 type t_vbap.
when type is used then u have to create a defintion of work area for another time when internal table doesnt have headr line as
ex:
DATA : BEGIN OF t_vbap OCCURS 0,
vbeln1 LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
kwmeng LIKE vbap-kwmeng,
netpr LIKE vbap-netpr,
netwr LIKE vbap-netwr,
werks LIKE vbap-werks,
matnr LIKE vbap-matnr,
arktx LIKE vbap-arktx,
END OF t_vbap.
DATA : BEGIN OF wa_vbap,
vbeln1 LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
kwmeng LIKE vbap-kwmeng,
netpr LIKE vbap-netpr,
netwr LIKE vbap-netwr,
werks LIKE vbap-werks,
matnr LIKE vbap-matnr,
arktx LIKE vbap-arktx,
END OF wa_vbap.
if helpful reward soem points.
with regards,
suresh.
06-08-2007 7:18 AM
Hi Amit,
DATA : BEGIN OF t_vbap OCCURS 0,
This will create an internal table
whereas TYPES : BEGIN OF t_vbap
This will create just a structure .
Regards,
Sree.
PS: Reward points if Useful.
06-08-2007 7:19 AM
Hi,
1. TYPES statement defines the structure without allocation of memory, DATA statements allocate the memory at runtime.
2. Create a structure by using types statement and refer it by using the DATA statement.
3. In order to avoid the internal table declaration without header line, we are declaring a structure by types statemnet and declaring an internal table with reference to the structure.
***do reward if usefull
vijay
06-08-2007 7:40 AM
use types and delcare structure.
then declare internal table.
ex-
types: begin of ty_lfa1,
kunnr like kna1-kunnr,'end of ty_kna1.
data : i_kna1 type standard table of ty_kna1 with header line.
regards
Suresh.D
06-08-2007 7:53 AM
hi,
like -> used for refering existing data elements in data dictionary or in sap
type -> used for refering existing data types in sap.
types: used for creating used defined structure of tables which has fields from more tahn one table.
diff b/w types and type in creation of internal tables is that when u create a table with types then u can use same for work area creation also.
ex:
TYPES : BEGIN OF t_vbap,
vbeln1 LIKE vbeln,
posnr LIKE posnr,
kwmeng LIKE kwmeng,
netpr LIKE netpr,
netwr LIKE netwr,
werks LIKE werks,
matnr LIKE matnr,
arktx LIKE arktx,
END OF t_vbap.
data: itab1 type t_vbap
wa_itab1 type t_vbap.
when type is used then u have to create a defintion of work area for another time when internal table doesnt have headr line as
ex:
DATA : BEGIN OF t_vbap OCCURS 0,
vbeln1 LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
kwmeng LIKE vbap-kwmeng,
netpr LIKE vbap-netpr,
netwr LIKE vbap-netwr,
werks LIKE vbap-werks,
matnr LIKE vbap-matnr,
arktx LIKE vbap-arktx,
END OF t_vbap.
DATA : BEGIN OF wa_vbap,
vbeln1 LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
kwmeng LIKE vbap-kwmeng,
netpr LIKE vbap-netpr,
netwr LIKE vbap-netwr,
werks LIKE vbap-werks,
matnr LIKE vbap-matnr,
arktx LIKE vbap-arktx,
END OF wa_vbap.
if helpful reward soem points.
with regards,
suresh.