2008 Jan 04 1:16 PM
Hi,
i know that process of internal table if it is with headerline but i don't know how the data pass to our internal table if it is with out header line plzz give me the example code for that.
Thanks in advance
2008 Jan 04 1:25 PM
Hi,
Examples:
With Header line:
codedata : itab like <dbtable> occurs 0 with header line.
Data: begin of itab occurs 0,
f1 type f1,
f2 type f2,
end of itab.[/code]
Without Header line.
codeTypes: begin of ty_tab,
f1 type f1,
f2 type f2,
end of ty_tab.
Data: itab type table of ty_tab, " Internal Table
wa type ty_tab. " Work Area[/code]
Hi,
Examples:
With Header line:
codedata : itab like <dbtable> occurs 0 with header line.
Data: begin of itab occurs 0,
f1 type f1,
f2 type f2,
end of itab.[/code]
Without Header line.
codeTypes: begin of ty_tab,
f1 type f1,
f2 type f2,
end of ty_tab.
Data: itab type table of ty_tab, " Internal Table
wa type ty_tab. " Work Area[/code]
2008 Jan 04 1:20 PM
work areas r used for processing data from n into internal table. as work area is a structure which can hold only one record at a time i.e to be inserted into internal table populated from internal table.
work areas generally used for reusability purpose.
i.e a internal table with header line is only used for storing data from a single data base table where as internal table without header line can be used in other inetrnal table. for this pirpose we ll create a explicit work area for processing data.
see this example :
http://help.sap.com/saphelp_nw04/helpdata/en/d6/0db738494511d182b70000e829fbfe/frameset.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/e5/6bc492bd5d214ba02e173a67d5cba3/content.htm
madhavi
2008 Jan 04 1:25 PM
Hi,
Examples:
With Header line:
codedata : itab like <dbtable> occurs 0 with header line.
Data: begin of itab occurs 0,
f1 type f1,
f2 type f2,
end of itab.[/code]
Without Header line.
codeTypes: begin of ty_tab,
f1 type f1,
f2 type f2,
end of ty_tab.
Data: itab type table of ty_tab, " Internal Table
wa type ty_tab. " Work Area[/code]
2008 Jan 04 1:27 PM
Hi,
Check this Example.
TABLES:MARA.
SELECT-OPTIONS:S_MATNR FOR MARA-MATNR DEFAULT '00000000000000001' TO
'000000000000001000'.
TYPES:BEGIN OF T_MARA,
MATNR TYPE MATNR,
ERSDA TYPE ERSDA,
MTART TYPE MTART,
MBRSH TYPE MBRSH,
MATKL TYPE MATKL,
END OF T_MARA.
DATA:IT_MARA TYPE STANDARD TABLE OF T_MARA.
DATA:WA_MARA LIKE LINE OF IT_MARA.
START-OF-SELECTION.
SELECT MATNR
ERSDA
MTART
MBRSH
MATKL FROM MARA INTO TABLE IT_MARA WHERE MATNR IN S_MATNR.
LOOP AT IT_MARA INTO WA_MARA.
WRITE:/ WA_MARA-MATNR,WA_MARA-ERSDA,WA_MARA-MTART,WA_MARA-MBRSH,
WA_MARA-MATKL.
ENDLOOP.
2008 Jan 04 1:30 PM
The following example shows two programs with the same function. One uses a header line, the other does not.
With header line:
TYPES: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA ITAB TYPE HASHED TABLE OF LINE WITH UNIQUE KEY COL1
WITH HEADER LINE.
DO 4 TIMES.
ITAB-COL1 = SY-INDEX.
ITAB-COL2 = SY-INDEX ** 2.
INSERT TABLE ITAB.
ENDDO.
ITAB-COL1 = 2.
READ TABLE ITAB FROM ITAB.
ITAB-COL2 = 100.
MODIFY TABLE ITAB.
ITAB-COL1 = 4.
DELETE TABLE ITAB.
LOOP AT ITAB.
WRITE: / ITAB-COL1, ITAB-COL2.
ENDLOOP.
Without header line:
TYPES: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA: ITAB TYPE HASHED TABLE OF LINE WITH UNIQUE KEY COL1,
WA LIKE LINE OF ITAB.
DO 4 TIMES.
WA-COL1 = SY-INDEX.
WA-COL2 = SY-INDEX ** 2.
INSERT WA INTO TABLE ITAB.
ENDDO.
WA-COL1 = 2.
READ TABLE ITAB FROM WA INTO WA.
WA-COL2 = 100.
MODIFY TABLE ITAB FROM WA.
WA-COL1 = 4.
DELETE TABLE ITAB FROM WA.
LOOP AT ITAB INTO WA.
WRITE: / WA-COL1, WA-COL2.
ENDLOOP.
The list, in both cases, appears as follows:
1 1
2 100
3 9
2008 Jan 04 1:38 PM
Hi,
Instead of inbuilt work area, we will declare explicit workarea and the data transfer will take place same as the inbuilt data transfer.
loop at itb into wa
write : wa.
endloop.
Plzz reward Points if it helps.
2008 Jan 04 1:43 PM
Hi all,
Thanks for suggations and i found the links for internal table. so, my doubt is clarified .
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |