SAP Virtual/Onsite Trainings

Document Categories:

What's New?

Contribute?

Sample Specs

What's Hot?

Web Dynpro for ABAP Tutorials 


Join the Mailing List
Enter name and email address below:
Name:
Email:
Subscribe  Unsubscribe 

Nested Interfaces

By Sravanthi

General Explanation:

This program will demonstrate how an interface can be included in another interface …. And the final interface containing all the interfaces can be used inside a class.

Description:

·         Interface sales_a contains method display.

·         Interface sales_b includes interface sales_a. However, it also contains method select of its own.

·         Class sales contain interface sales_b and implements methods: sales_a~display, sales_b~select.

·         Object is created from class sales and all the methods are called.  

Code:  

REPORT  znested_interface NO STANDARD PAGE HEADING.
*----------------------------------------------------------------------*
*       INTERFACE sales_a
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
INTERFACE sales_a.
  
METHODS:  display.
ENDINTERFACE.                    "sales_a
*----------------------------------------------------------------------*
*       INTERFACE sales_b
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
INTERFACE sales_b.
  
METHODS : select IMPORTING vbelnlow TYPE vbak-vbeln
                             vbelnhigh 
TYPE vbak-vbeln.
  
INTERFACES sales_a.
ENDINTERFACE.                    "sales_b
*----------------------------------------------------------------------*
*       CLASS c1 DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS sales DEFINITION.
  
PUBLIC SECTION.
    
DATA tab TYPE TABLE OF vbak.
    
DATA wa TYPE vbak.

    
INTERFACES :  sales_b.
ENDCLASS.                    "sales DEFINITION

*----------------------------------------------------------------------*
*       CLASS c1 IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS sales IMPLEMENTATION.

  
METHOD : sales_b~select.
    
SELECT * FROM vbak INTO CORRESPONDING FIELDS OF TABLE tab
      
WHERE vbeln >= vbelnlow AND
            vbeln <= vbelnhigh.
  
ENDMETHOD.                    ":

  
METHOD : sales_a~display.
    
LOOP AT tab INTO wa.
      
WRITE : / wa-vbeln, wa-erdat, wa-erzet, wa-ernam.
    
ENDLOOP.
  
ENDMETHOD.                    ":
ENDCLASS.                    "sales IMPLEMENTATION

START-
OF-SELECTION.
  
TABLES : vbak.
  
SELECT-OPTIONS s_vbeln FOR vbak-vbeln.
  
DATA obj TYPE REF TO sales.
  
CREATE OBJECT obj.
  obj->sales_b~
selectEXPORTING vbelnlow = s_vbeln-low
                                            vbelnhigh =  s_vbeln-high ).
  obj->sales_a~display( ).
 

Output:

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image