‎2007 Feb 08 12:49 PM
Hello to all ,
Please tell me which is the best practice to define a internal table .
Bye ..
‎2007 Feb 08 12:53 PM
hi,
the best way to declare is to define types and then declare the internal table of that type.
regards,
madhumitha.
‎2007 Feb 09 6:11 AM
Hi,
this is way which i follow...
TYPES : BEGIN OF ts_dd04l,
rollname TYPE dd04l-rollname,
shlpname TYPE dd04l-shlpname,
END OF ts_dd04l,
tt_dd04l TYPE STANDARD TABLE OF ts_dd04l.
DATA: wa_dd04l TYPE ts_dd04l, "wa
it_dd04l TYPE tt_dd04l. "table
‎2007 Feb 08 8:14 PM
Hi Anubhav,
A good practise is (like already mentioned) create the type declaration for the table, then create the table as a standard table with the type defined above.
Also DO NOT create the table with a header line, since all OO objects dont support internal tables with header lines. Hence create a work area awith the same types structure.
Hope it helps.
Rgds,
Aditya
‎2007 Feb 08 8:17 PM
Hi,
Check this example..It is better to create internal table without header line.
Example
-
TYPES: BEGIN OF TYPE_MAT_DETAIL,
MATNR TYPE MATNR,
WERKS TYPE WERKS_D,
VKORG TYPE VKORG,
END OF TYPE_MAT_DETAIL.
DATA: T_MAT_DETAIL TYPE STANDARD TABLE OF TYPE_MAT_DETAIL.
DATA: WA_MAT_DETAIL TYPE TYPE_MAT_DETAIL.
LOOP AT T_MAT_DETAIL INTO WA_MAT_DETAIL.
WRITE: / WA_MAT_DETAIL-MATNR.
ENDLOOP.
Thanks,
Naren
‎2007 Feb 09 5:06 AM
Example:
TYPES: BEGIN OF ty_mara,
matnr LIKE mara-matnr,
matkl LIKE mara-matkl,
END OF ty_mara.
DATA: i_mara TYPE STANDARD TABLE of ty_mara,
wa_mara TYPE ty_mara.So after selecting data to i_mara.
While u loop aor read always do as
LOOP AT i_mara INTO wa_mara.
.............
MODIFY i_mara from wa_mara.
clear wa_mara.
ENDLOOP.
If u appen tehn
APPEND wa_mara TO i_mara.
READ i_mara INTO wa_mara WITH KEY .....Hope this helps.
‎2007 Feb 09 6:08 AM
Hi,
This is the best way i think.
TYPES : BEGIN OF ts_dd04l,
rollname TYPE dd04l-rollname,
shlpname TYPE dd04l-shlpname,
END OF ts_dd04l,
tt_dd04l TYPE STANDARD TABLE OF ts_dd04l.
DATA: wa_dd04l TYPE ts_dd04l, "work area
it_dd04l TYPE tt_dd04l.
‎2007 Feb 09 10:07 AM
hi Anubhav,
As long as u don't specify occurs n it's a good practice but it's always advantageous using a header line . Also for best Practices u can follow this in SE38 transaction environment->examples->performance Examples.
pl. Provide points if found helpful
‎2007 Feb 09 10:21 AM
Hi,
If you want the all the fields in a table or structure,
data itab type standard table of table_name.
If you want only few fields from several structures,
types : begin of ty,
f1 type d1-f1,
f2 type d2-f2,
end of ty.
data itab type standard table of ty.
‎2007 Feb 09 11:19 AM
Hi,
Data : begin of itab occurs 0.
(req fields),
end of itab.
Thiis will be a internal table with a work area...
but when u yse TYPES to declre a table.. please follow this..
*TYPES : BEGIN OF tp_test,
vbeln LIKE vbak-vbeln,
auart LIKE vbak-auart,
END OF tp_test.
*
*DATA : wa_test TYPE tp_test. " work area of type tp_test
*
*DATA : t_test TYPE tp_test OCCURS 0.. " internal table without a header line
*
*DATA : tt_test TYPE STANDARD TABLE OF tp_test. " internal table without a header line
*
*DATA : ttt_test TYPE STANDARD TABLE OF tp_test WITH HEADER LINE. " internal table with header line
Hope this helps..
Award if useful..
Rajiv
‎2007 Feb 09 2:06 PM
as per my coding standards
TYPES:BEGIN OF ty_ekes,
ebeln TYPE ebeln, "Purchasing Document Number
ebelp TYPE ebelp, "Item Number of Purchasing Document
etens TYPE etens, "Sequential Number of Vendor Confirmation
ebtyp TYPE ebtyp, "Confirmation category
vbeln TYPE vbeln_vl, "Delivery
vbelp TYPE posnr_vl, "Delivery item
eindt TYPE bbein, "Delivery date of vendor confirmation
END OF ty_ekes,
ty_ekes_t TYPE STANDARD TABLE OF ty_ekes.
DATA: it_ekes TYPE ty_ekes_t, Internal table
wa_ekes TYPE ty_ekes. work area.
‎2007 Feb 14 10:51 AM
Hello Anubhav,
DATA: lwa_t001 type t001,
gt_t001 like standard table of lwa_t001.
This is one of the good practice.
And dont ever declare an internal table with header line. It will have lot of performance issues.
Regs,
Venkat Ramanan N