Object(task):
To Display the company codes , company names, and cities.
solution:(our task is to fetch the data from database and display it).
To Fetch data from database we need to write a select query:
Syntax of Select Query:
Select <field 1> <field 2>....<field n> from <Data Base Table>
Into Table <Internal Table> where <condition>.
T001(Company Table):
It is standard database table which is given by SAP. It consists of data.
BUKRS -----> Company Code.
BUTXT ------->Company Name.
ORT01 -------->City
LAND1 --------> Country.
TO KNOW THE DATATYPE AND LENTH OF DATATYPE:
we follow this method initially , but there is another method i will dicuss in next post declearing the field variables.
>> But right now , go to ABAP screen. execute SE11.
>> SELECT database table and type the table name as T001(T ZERO ZERO ONE).
>> Click on display.
>> There you can fields like BUKRS ,BUTXT ...ETC on the same row of the field you can see the type and length of the field.
(THIS BELOW FIGURE IS NOT EXACT OF T001 BUT THIS IS THE WAY TO FIND BUKRS, BUTXT....ETC).
PROGRAM:
* declaring work area(work area name is wa , internal table name is It).
DATA : Begin of wa,
BUKRS(4) Type C,
BUTXT(25) Type C,
ORT01(25) Type C,
End of wa.
*declaring internal table.
DATA It Like Table of wa.
*select query to fetch data from database.
Select BUKRS BUTXT ORT01 From T001 Into Table It.
*loop for printing data
Loop At It into wa.
Write : / wa-BUKRS,
wa-BUTXT,
wa-ORT01.
ENDLOOP.
>> Save , Check , Activate the program and test it .(same as before program if you need it refer to previous post.)
>> The output is displayed.





Comments
Post a Comment