Complete Dictionary Objects
Complete Dictionary Objects
1. Tables
2. Views
3. Data elements
4. Domains
5. Type Groups
6. Search Helps
7. Table Types
8. Lock objects
9. Structures
Master data:
Transaction data:
Other header and item tables: - Sales Documents (VBAK and VBAP),
Purchase Documents (EKKO and EKPO)
We can also create the custom tables for storing the customer
specific data.
Primary key:
In SAP, every table must contain minimum 1 primary key field and
maximum 16 primary key fields. Primary key fields should be at the
beginning of the table.
Based on the client field, the database tables are classified into two
types.
The records in these tables are specific to the client i.e. the record
inserted in one client will not be available in other client.
Eg: KNA1, MARA, LFA1, VBAK, VBAP, EKKO, EKPO, VBRK, VBRP
The record’s in this tables are not specific to any client’s i.e. they
are available across the client’s by default.
Table creation:
1. Delivery class.
Delivery class:
A -> application table used for storing master and transaction data.
In dialog box:
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari
Note:
In this we can only view the data but we can’t perform the
operations like insertion, deletion and modification.
Technical settings:
1. Data class.
2. Size category
Data class:
Size category:
Enhancement category:
Table maintenance:
The table maintenance allows the end user to maintain the table
for performing the operations like insertion, deletion,
Modification and view the data (display).
i. One step:
In overview screen we can only view the data, delete the data
and modify the data.
Viewname z845emp
Update X
Note: For collecting screen field names, goto sm30 initial screen,
press f1 in table/view field and collect the screen field name,
similarly put focus on ‘maintain’ button, press f1 and collect the
function code (upd) (equal to update)
Note: Whenever we create t-code for any object, select the check box
‘SAP GUI for windows’, otherwise t-code cannot be used (incomplete).
Two Ways:
Dictionary structure:
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari
REPORT ZUSEGLOBALSTR.
types : begin of ty_emp,
empno type i,
ename(20) type c.
* include structure z7amstr.
include type z7amstr.
types : empdesig(25) type c,
end of ty_emp.
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari
data wa_emp type ty_emp.
wa_emp-empno = 6.
wa_emp-ename = 'Ravi'.
wa_emp-jdate = sy-datum.
wa_emp-jtime = sy-uzeit.
wa_emp-empdesig = 'Manager'.
write :/ wa_emp-empno,
/ wa_emp-ename,
/ wa_emp-jdate,
/ wa_emp-jtime,
/ wa_emp-empdesig.
form abc.
z730employee-jdate = sy-datum.
z730employee-jtime = sy-uzeit.
endform.
Type groups:
All the components in the type group must prefix with type group
name followed by ‘_’.
Inside the type group we can use only types and constant
keywords.
TYPE-POOL ZABC .
constants zabc_x type i value 10.
constants zabc_y type string value 'Gensoft'.
types zabc_m type i.
types : begin of zabc_emp,
empno type i,
ename type string,
empdesig type string,
end of zabc_emp.
types : begin of zabc_student,
cname type string.
* include structure z7amstr. "(or)
include type z7amstr.
types : caddr type string,
end of zabc_student.
uline.
data wa_emp type zabc_emp.
wa_emp-empno = 6.
wa_emp-ename = 'Raju'.
wa_emp-empdesig = 'Manager'.
write :/ wa_emp-empno,
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari
/ wa_emp-ename,
/ wa_emp-empdesig.
Indexes:
Primary index:
1. Unique. 2. Non-unique.
:
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari
i. Database view
Database view:
Save and activate the view, execute the view directly and check
the no. of records and data retrieved.
REPORT ZUSE_DBVIEW_KNA1 line-size 140.
types : BEGIN OF ty_customer.
include type zdbview_kna1.
types end of ty_customer.
data : t_customer type table of ty_customer,
wa_customer type ty_customer.
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari
select * from zdbview_kna1 into table t_customer.
if sy-subrc eq 0.
write :/ 'No of records fetched :',sy-dbcnt.
loop at t_customer into wa_customer.
write :/ wa_customer-mandt,
wa_customer-kunnr,
wa_customer-land1,
wa_customer-fname,
wa_customer-lname,
wa_customer-ort01.
endloop.
else.
message 'No data' type 'I'.
endif.
Save and activate the view, execute the view directly and check
the no. of records and data retrieved.
REPORT ZUSE_DB_HEADER_ITEM line-size 140.
* ernam type vbak-ernam,
* posnr type vbap-posnr,
* matnr type vbap-matnr,
* end of ty_sales.
*
*data : t_sales type table of ty_sales,
* wa_sales type ty_sales.
*
*select vbak~mandt vbak~vbeln vbak~erdat vbak~ernam
* posnr matnr
* into table t_sales
* from vbak INNER JOIN vbap
* on vbak~vbeln = vbap~vbeln
* where vbak~vbeln in ('0000004970','0000004971','0000004
972').
* if sy-subrc eq 0.
* write :/ 'No of records fetched :',sy-dbcnt.
* loop at t_sales into wa_sales.
* write :/ wa_sales-mandt,
* wa_sales-vbeln,
* wa_sales-erdat,
* wa_sales-ernam,
* wa_sales-posnr,
* wa_sales-matnr.
* endloop.
* else.
* message 'No data' type 'I'.
*endif.
data : t_sales type table of ty_sales,
wa_sales type ty_sales.
select * from zdb_head_item into table t_sales.
if sy-subrc eq 0.
write :/ 'No of records fetched :',sy-dbcnt.
loop at t_sales into wa_sales.
write :/ wa_sales-mandt,
wa_sales-vbeln,
wa_sales-erdat,
wa_sales-ernam,
wa_sales-posnr,
wa_sales-matnr.
endloop.
else.
message 'No data' type 'I'.
endif.
Projection view:
Note:
Example:
Fields:
Deptno’s:- 10,20,30
Fields:
empno zemp_num
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari
ename zename
empdesig zempdesig
Maintenance view:
Material tables:
MARD (MATERIAL STORAGE LOCATION DATA) --> MANDT, MATNR, WERKS, LGORT
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari
The reference table can be same table (or) external table and
reference field can be same table field (or) external table field.
The reference data type for (curr) currency is ‘cuky’ and reference
data type for (quan) quantity is ‘unit’.
A Table type can refer to a direct data type / line type (structure)/
reference type (class or interface)
REPORT ZUSE_TTYPE1.
data gt_ttype type z830ttype1. "internal table
data gs_ttype like line of gt_ttype. "work area
clear gs_ttype.
gs_ttype = 'Raju'.
append gs_ttype to gt_ttype.
clear gs_ttype.
gs_ttype = 'Ravi'.
append gs_ttype to gt_ttype.
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari
clear gs_ttype.
gs_ttype = 'Ashok'.
append gs_ttype to gt_ttype.
clear gs_ttype.
gs_ttype = '10'.
append gs_ttype to gt_ttype.
loop at gt_ttype into gs_ttype.
write :/ gs_ttype.
endloop.
REPORT ZUSE_TTYPE2.
data gt_emp type z830ttype2. "internal table
*data gs_emp like line of gt_emp. "work area (or)
data gs_emp type z830ltype. "work area
clear gs_emp.
gs_emp-empno = 1.
gs_emp-ename = 'Ravi'.
gs_emp-empdesig = 'Manager'.
append gs_emp to gt_emp.
clear gs_emp.
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari
gs_emp-empno = 2.
gs_emp-ename = 'Vamshi'.
gs_emp-empdesig = 'Employee'.
append gs_emp to gt_emp.
clear gs_emp.
gs_emp-empno = 3.
gs_emp-ename = 'Kiran'.
gs_emp-empdesig = 'Supervisor'.
append gs_emp to gt_emp.
clear gs_emp.
gs_emp-empno = 4.
gs_emp-ename = 'Praveen'.
gs_emp-empdesig = 'CEO'.
append gs_emp to gt_emp.
loop at gt_emp into gs_emp.
write :/ gs_emp-empno,
gs_emp-ename,
gs_emp-empdesig.
endloop.
REPORT ZUSEDBVIEW2 line-size 120.
data t_dbview type zemp_dept WITH HEADER LINE.
select * from zdataview
into table t_dbview.
if sy-subrc eq 0.
write :/ 'No of records retrieved :',sy-dbcnt.
loop at t_dbview.
write :/ t_dbview-empno,
t_dbview-ename,
t_dbview-empdesig,
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari
t_dbview-dno,
t_dbview-deptno,
(25) t_dbview-dname,
t_dbview-loc.
endloop.
else.
write :/ 'No data'.
endif.
REPORT ZUSEDBVIEW3 line-size 120.
select * from zdataview
into table t_dbview.
if sy-subrc eq 0.
write :/ 'No of records retrieved :',sy-dbcnt.
loop at t_dbview into wa_dbview.
write :/ wa_dbview-empno,
wa_dbview-ename,
wa_dbview-empdesig,
wa_dbview-dno,
wa_dbview-deptno,
(25) wa_dbview-dname,
wa_dbview-loc.
endloop.
else.
write :/ 'No data'.
endif.
Lock Objects:
1. They are used for performing row-level locking of the table data
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari
3. Lock Objects names must start with ‘EZ’ (or) ‘EY’ and locking is
done based on primary key field/s
1. Exclusive / Write Lock In this, only one user can read or edit
the locked record. If other users request for the Exclusive lock,
his request will be rejected but the request is stored in the
queue. Once the first user releases the exclusive lock, the
exclusive lock access is given to other user in the queue.
2. Shared / Read Lock: In this, multiple users can read the locked
record and if a user modifies the locked record, the modified
data is not accessible to other users.
REPORT ZUSE_LOCKOBJECTS.
PARAMETERS p_kunnr type kna1-kunnr.
data : gv_name1 type kna1-name1,
gv_ort01 type kna1-ort01.
* Lock the customer
CALL FUNCTION 'ENQUEUE_EZLOCKOBJ_CUSTNO'
EXPORTING
MODE_KNA1 = 'E'
MANDT = SY-MANDT
KUNNR = p_kunnr
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
IF SY-SUBRC eq 1.
message 'Customer is locked' type 'E'.
endif.
select single name1 ort01
from kna1
into (gv_name1,gv_ort01)
where kunnr = p_kunnr.
if sy-subrc eq 0.
write :/ 'Customer Name :',gv_name1,
/ 'Customer City :',gv_ort01.
else.
write :/ 'No customer'.
ENDIF.
at USER-COMMAND.
case sy-ucomm.
when 'FC1'.
leave PROGRAM.
when 'FC2'.
* release the lock on customer
CALL FUNCTION 'DEQUEUE_EZLOCKOBJ_CUSTNO'
EXPORTING
MODE_KNA1 = 'E'
MANDT = SY-MANDT
KUNNR = p_kunnr.
endcase.
Note: To test Lock object functionality, run the above two programs in
2 sessions and provide customer no in one session, execute, displays
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari
Assigning function code for the back button in the GUI status for
enabling it:
SEARCH HELPS:
It is triggered when the user presses ‘F4’ key in the Input Field.
REPORT ZUSE_SEARCHHELP.
Table 1: z9amemp
Table 2: z9amdept
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari
Report 1:
REPORT ZUSEDBVIEW.
types : begin of ty_dbview.
include type zdataview.
types end of ty_dbview.
data : t_dbview type table of ty_dbview,
wa_dbview type ty_dbview.
select * from zdataview
into table t_dbview.
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari
if sy-subrc eq 0.
write :/ 'No of records retrieved :',sy-dbcnt.
loop at t_dbview into wa_dbview.
write :/ wa_dbview-empno,
wa_dbview-ename,
wa_dbview-empdesig,
wa_dbview-dno,
wa_dbview-deptno,
wa_dbview-dname,
wa_dbview-loc.
endloop.
else.
write :/ 'No data'.
endif.
REPORT ZUSEDBVIEW1 line-size 120.
types : begin of ty_dbview.
include type zdataview.
types end of ty_dbview.
data : t_dbview type table of ty_dbview,
wa_dbview type ty_dbview.
select * from zdataview
into table t_dbview.
if sy-subrc eq 0.
write :/ 'No of records retrieved :',sy-dbcnt.
loop at t_dbview into wa_dbview.
write :/ wa_dbview-empno,
wa_dbview-ename,
wa_dbview-empdesig,
wa_dbview-dno,
wa_dbview-deptno,
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari
(25) wa_dbview-dname,
wa_dbview-loc.
endloop.
else.
write :/ 'No data'.
endif.