Tuesday, November 12, 2013

A Simple OOP abap program


REPORT  ZOOPSLearn.


/*Class Definition */

CLASS Learn DEFINITION.

PUBLIC SECTION.
 
DATA:
W_TEXT 
TYPE STRING value 'Learn Abap programming'.
methodsDISPLAY.
ENDCLASS.

/* Class Implementation */

CLASS Learn Implementation.

  
Method display.
    
Write:'This helps to display'.
    
ENDMETHOD.

 
ENDCLASS.

/* The Program */
Start
-of-selection.
 
Data:
       Learn1 
type ref to Learn.
 
Create ObjectLearn1.
 
write:/ Learn1->w_text.
 
call method:
 learn1
->display
.


This is a simple program to learn OOPS abap programming. Like in any Object oriented programming language, the first step is to create definition and then implementation followed by the program steps. In class definition, the keyword used for Methods are 'Methods' and not method even if its single method that is being used. Using the '->' operator, you can access the data and in case its method, then along with the keyword 'Call method:', it can access the method used in declaration earlier.

The output of the program would be:
Learn Abap programming

This helps to display

No comments:

Post a Comment