10-23-2007 1:31 PM
Hi.
I need to create an internal table where some of the fields are from a database table, and the other fields are user specified. How do i do that?
*********************************************************************************************
Example:
DB table ZTAB with fields ZTAB-FIELD1, ZTAB-FIELD2.
I want to create an internal table ITAB with the fields ZTAB-FIELD1, ZTAB-FIELD2 from ZTAB. In addition, I also want to have one more field RECORD_NO, which is not from ZTAB. How do I do it? Could I do something like below?
DATA BEGIN OF ITAB.
INCLUDE STRUCTURE ZTAB.
DATA RECORD_NO TYPE I.
DATA END OF UPLINE.
*********************************************************************************************
Or, are there more efficient way of doing it? Thanks.
10-23-2007 1:37 PM
hi keon kong,
there is nothing wrong in it. u can give like that.
regards
karthik
10-23-2007 1:36 PM
hi KIan,
go:
general type
TYPE : BEGIN OF ty_itab,
field1 TYPE ztab-field1,
field2 TYPE ztab-field2,
*your own fields here:
field TYPE i,
field(30) TYPE c,
END OF ty_itab.
work area
DATA : gw_itab TYPE ty_itab.
internal table
DATA : gt_itab TYPE TABLE OF ty_itab.
hope this helps
ec
10-23-2007 1:37 PM
hi keon kong,
there is nothing wrong in it. u can give like that.
regards
karthik
10-23-2007 1:41 PM
Hi Kian,
here a shor example.
TABLES: MARA.
*
DATA: BEGIN OF ITAB OCCURS 0.
DATA: NO LIKE SY-DBCNT.
INCLUDE STRUCTURE MARA.
DATA: END OF ITAB.
*
SELECT * FROM MARA UP TO 100 ROWS.
*
ITAB-NO = SY-DBCNT.
MOVE-CORRESPONDING MARA TO ITAB.
APPEND ITAB.
*
ENDSELECT.
*
LOOP AT ITAB. WRITE: / ITAB-NO, ITAB-MATNR, ITAB-BRGEW. ENDLOOP.
Regards, Dieter
10-23-2007 2:55 PM