21.03.2013 Views

Object Oriented ABAP

Object Oriented ABAP

Object Oriented ABAP

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Working with import, export and change<br />

parameters of a class<br />

Go to SE38 and create a program.<br />

Then provide the following code.<br />

REPORT ZLOCALCLASS_VARIABLES.<br />

*How we can use import and export and changing parameters in the class.<br />

*Provide the variables<br />

DATA: V_IMP TYPE I,<br />

V_CHA TYPE I VALUE 100.<br />

*Define the class.<br />

CLASS CL_LC DEFINITION.<br />

PUBLIC SECTION.<br />

METHODS: DISPLAY IMPORTING A TYPE I<br />

EXPORTING B TYPE I<br />

CHANGING C TYPE I.<br />

ENDCLASS.<br />

*Implement the class.<br />

CLASS CL_LC IMPLEMENTATION.<br />

METHOD DISPLAY.<br />

B = A + 20.<br />

C = A + 30.<br />

ENDMETHOD.<br />

ENDCLASS.<br />

*Create the object.<br />

DATA OBJ TYPE REF TO CL_LC.<br />

START-OF-SELECTION.<br />

CREATE OBJECT OBJ.<br />

CALL METHOD OBJ->DISPLAY<br />

EXPORTING<br />

A = 10<br />

IMPORTING<br />

B = V_IMP<br />

CHANGING<br />

C = V_CHA.<br />

WRITE:/ 'OUTPUT PARAMETR', V_IMP,<br />

'CHANGING PARAMETER', V_CHA.<br />

Save and activate the program.<br />

Now execute the program by inserting a breakpoint.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!