|
Data: Begin
of WA,
Eid(10) type c,
Eid
|
Ename
|
Ename
|
1
|
Divya
|
Vidya nagar
|
2
|
Sai
|
Anand theter
|
Ename(25) type c,
Eadd(35) type c,
End of WA.
Data
IT like table of WA.
WA-Eid
= '1'.
WA-Ename
= 'divya'.
WA-Eadd
= 'vidya Nagar'.
Append
WA to IT.
WA-Eid
= '2'.
WA-Ename
= 'sai'.
WA-Eadd
= 'anand theter'.
Append
WA to IT.
Loop
at IT into WA.
Write:
/ WA-Eid , WA -Ename,
WA-Eadd.
Endloop.
- In the above program we defined one work area WA with three variables.
- First we fill the work area and transfer this records into internal table IT.
- here we are filling the internal table manually by using APPEND keyword.
- Internal table can hold up to 2GB storage.
- we can't access the data Directly from internal table so we loop the internal table into work area and print that data in output screen by using WRITE keyword.
Syntax to select
query: -
Select is a Keyword which is used to fetch the Data from the database and placed into internal table or work area.
syntax :
Select <filed1>
<filed2> …. from <data base table> into table <internal
table> where <condition>.
EX :
Data:
Begin of WA,
BUKRS(4) type C,
BUTXT(25) type C,
ORT01(25) type C,
End of WA.
Data
IT like table of WA.
Select
BUKRS BUTXT ORT01 from T001 into table IT.
Loop
at IT into WA.
Write:/
WA-BUKRS , WA -BUTXT,
WA-ORT01.
Endloop.
result :
1000 Punj Lloyd Ltd Gurgon.
2000 New Publications Mumbai.
Syntax of declaring
the field: -
Data <filed
name>(<length>) type <data type>
(OR)
Data <filed
name> type <data elements>
(OR)
Data <filed
name> type <data base table> - <field name>
Ex: - Data BUKRS(4)
type C.
(OR)
Data BUKRS type BUKRS
(OR)
Data Bukrs type T001-Bukrs.
Display the company codes, company names &
cities.
step 1 : identify the table we already knew T001 is a company table which have all company related data.
Step 2 : Declare one work area and internal table with those fields.
Data:
Begin of WA_T001, "wa_t001 is a work area"
BUKRS type T001-BUKRS, "Bukrs : company code"
BUTXT type T001-BUTXT, "Butxt : company name"
ORT01 type T001-ORT01, "Ort01 : company city"
End of WA_T001.
Data
IT like table of WA_T001.
Step 3 : write select query.
Select
BUKRS BUTXT ORT01 from T001 into table IT.
Step 4 :loop the internal table data and print in output screen by using WRITE keyword.
Loop
at IT into WA_T001.
Write:/
WA _T001-BUKRS , WA _T001-BUTXT,
WA_T001-ORT01.
Endloop.
No comments:
Post a Comment