Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Class

Former Member
0 Likes
500

Hi,

Give some simple example program for Interfaces.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
463

Hallo Ramesh,

Classes, their instances (objects), and access to objects using reference variables form the basics of ABAP Objects. These means already allow you to model typical business applications, such as customers, orders, order items, invoices, and so on, using objects, and to implement solutions using ABAP Objects.

syntax :

INTERFACE <intf>.

...

ENDINTERFACE.

Example :

TABLES ZVIJIRANK.

DATA IT LIKE TABLE OF ZVIJIRANK WITH HEADER LINE.

INTERFACE I1.

METHODS : GETDATA.

ENDINTERFACE.

CLASS CL1 DEFINITION.

PUBLIC SECTION.

INTERFACES I1.

ENDCLASS.

CLASS CL2 DEFINITION.

PUBLIC SECTION.

INTERFACES I1.

ENDCLASS.

CLASS CL1 IMPLEMENTATION.

METHOD I1~GETDATA.

SELECT * FROM ZVIJIRANK INTO TABLE IT.

ENDMETHOD.

ENDCLASS.

CLASS CL2 IMPLEMENTATION.

METHOD I1~GETDATA.

SELECT * FROM ZVIJIRANK INTO TABLE IT WHERE REG_NO = '101'.

ENDMETHOD.

ENDCLASS.

DATA: OBJ1 TYPE REF TO CL1,

OBJ2 TYPE REF TO CL2.

START-OF-SELECTION.

CREATE OBJECT: OBJ1 , OBJ2.

CALL METHOD OBJ1->I1~GETDATA.

LOOP AT IT.

WRITE : / IT-REG_NO , IT-NAME , IT-BRANCH.

ENDLOOP.

CALL METHOD OBJ2->I1~GETDATA.

LOOP AT IT.

WRITE : / IT-REG_NO , IT-NAME , IT-BRANCH.

ENDLOOP.

If you have doubt means go through the following links.

http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm

2 REPLIES 2
Read only

Former Member
0 Likes
464

Hallo Ramesh,

Classes, their instances (objects), and access to objects using reference variables form the basics of ABAP Objects. These means already allow you to model typical business applications, such as customers, orders, order items, invoices, and so on, using objects, and to implement solutions using ABAP Objects.

syntax :

INTERFACE <intf>.

...

ENDINTERFACE.

Example :

TABLES ZVIJIRANK.

DATA IT LIKE TABLE OF ZVIJIRANK WITH HEADER LINE.

INTERFACE I1.

METHODS : GETDATA.

ENDINTERFACE.

CLASS CL1 DEFINITION.

PUBLIC SECTION.

INTERFACES I1.

ENDCLASS.

CLASS CL2 DEFINITION.

PUBLIC SECTION.

INTERFACES I1.

ENDCLASS.

CLASS CL1 IMPLEMENTATION.

METHOD I1~GETDATA.

SELECT * FROM ZVIJIRANK INTO TABLE IT.

ENDMETHOD.

ENDCLASS.

CLASS CL2 IMPLEMENTATION.

METHOD I1~GETDATA.

SELECT * FROM ZVIJIRANK INTO TABLE IT WHERE REG_NO = '101'.

ENDMETHOD.

ENDCLASS.

DATA: OBJ1 TYPE REF TO CL1,

OBJ2 TYPE REF TO CL2.

START-OF-SELECTION.

CREATE OBJECT: OBJ1 , OBJ2.

CALL METHOD OBJ1->I1~GETDATA.

LOOP AT IT.

WRITE : / IT-REG_NO , IT-NAME , IT-BRANCH.

ENDLOOP.

CALL METHOD OBJ2->I1~GETDATA.

LOOP AT IT.

WRITE : / IT-REG_NO , IT-NAME , IT-BRANCH.

ENDLOOP.

If you have doubt means go through the following links.

http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm