Internal Table with header Line
- In Internal table with header line , Internal table's first line act as Work Area.
- Syntax
DATA: <Internal table name> like <table structure/ structure name > occurs 0 with header line.
OR
DATA : <Internal table name> like standard table of <structure name> with header line.
Ex 1 :
Data: itab like mara occurs 0 with header line.
or
Data :itab like standard table of ekko with header line.
Ex 2:
Steps :
- Go to transaction code SE38.
- Enter the program name Z or Y<program name>.
- Select attribute type as Executable program.
- Click on Save.
Source Code
TYPES : BEGIN OF TY_MAT,
NAME(12) TYPE C,
AGE TYPE I,
PLACE(20) TYPE C,
END OF TY_MAT.
DATA: IT_MAT TYPE TABLE OF TY_MAT WITH HEADER LINE.
IT_MAT-NAME = 'MANI'.
IT_MAT-AGE = 23.
IT_MAT-PLACE = 'BANGALORE'.
APPEND IT_MAT .
CLEAR IT_MAT.
IT_MAT-NAME = 'RAHUL'.
IT_MAT-PLACE = 'CHENAI'.
APPEND IT_MAT .
CLEAR IT_MAT.
LOOP AT IT_MAT .
WRITE : / IT_MAT-NAME ,IT_MAT-AGE ,IT_MAT-PLACE.
ENDLOOP.
Save ->check->activate->execute.
Output
Ex 3 :
Steps :
- Go to transaction code SE38.
- Enter the program name Z or Y<program name>.
- Select attribute type as Executable program.
- Click on Save.
Source Code
TYPES : BEGIN OF TY_MAT,
MATNR TYPE MAKT-MATNR,
SPRAS TYPE MAKT-SPRAS,
MAKTX TYPE MAKT-MAKTX,
END OF TY_MAT.
DATA: IT_MAT TYPE TABLE OF TY_MAT WITH HEADER LINE.
SELECT-OPTIONS : S_MATNR FOR IT_MAT-MATNR.
SELECT MATNR SPRAS MAKTX FROM MAKT INTO TABLE IT_MAT
WHERE MATNR IN S_MATNR.
LOOP AT IT_MAT .
WRITE : / IT_MAT-MATNR , IT_MAT-SPRAS , IT_MAT-MAKTX.
ENDLOOP.
MATNR TYPE MAKT-MATNR,
SPRAS TYPE MAKT-SPRAS,
MAKTX TYPE MAKT-MAKTX,
END OF TY_MAT.
DATA: IT_MAT TYPE TABLE OF TY_MAT WITH HEADER LINE.
SELECT-OPTIONS : S_MATNR FOR IT_MAT-MATNR.
SELECT MATNR SPRAS MAKTX FROM MAKT INTO TABLE IT_MAT
WHERE MATNR IN S_MATNR.
LOOP AT IT_MAT .
WRITE : / IT_MAT-MATNR , IT_MAT-SPRAS , IT_MAT-MAKTX.
ENDLOOP.
Save -> Check -> Activate-> Execute.
Input
Output
Ex 4:
Steps :
- Go to transaction code SE38.
- Enter the program name Z or Y<program name>.
- Select attribute type as Executable program.
- Click on Save.
Source Code
DATA : BEGIN OF TY_VBAK OCCURS 0,
VBELN TYPE VBAK-VBELN,
ERDAT TYPE VBAK-ERDAT,
ERNAM TYPE VBAK-ERNAM,
NETWR TYPE VBAK-NETWR,
END OF TY_VBAK.
SELECT-OPTIONS : S_VBELN FOR TY_VBAK-VBELN.
SELECT VBELN
ERDAT
ERNAM
NETWR FROM VBAK INTO TABLE TY_VBAK[] WHERE VBELN IN S_VBELN.
LOOP AT TY_VBAK .
WRITE : / TY_VBAK-VBELN , TY_VBAK-ERDAT , TY_VBAK-ERNAM , TY_VBAK-NETWR.
ENDLOOP.
VBELN TYPE VBAK-VBELN,
ERDAT TYPE VBAK-ERDAT,
ERNAM TYPE VBAK-ERNAM,
NETWR TYPE VBAK-NETWR,
END OF TY_VBAK.
SELECT-OPTIONS : S_VBELN FOR TY_VBAK-VBELN.
SELECT VBELN
ERDAT
ERNAM
NETWR FROM VBAK INTO TABLE TY_VBAK[] WHERE VBELN IN S_VBELN.
LOOP AT TY_VBAK .
WRITE : / TY_VBAK-VBELN , TY_VBAK-ERDAT , TY_VBAK-ERNAM , TY_VBAK-NETWR.
ENDLOOP.
Comments
Post a Comment