Monday, February 7, 2011

Working with import, export and change parameters of a class

Go to SE38 and create a program.

Then provide the following code.

REPORT  ZLOCALCLASS_VARIABLES.
*How we can use import and export and changing parameters in the class.
*Provide the variables
DATA: V_IMP TYPE I,
V_CHA TYPE I VALUE 100.
*Define the class.
CLASS CL_LC DEFINITION.
PUBLIC SECTION.
METHODS: DISPLAY IMPORTING A TYPE I
EXPORTING B TYPE I
CHANGING C TYPE I.
ENDCLASS.
*Implement the class.
CLASS CL_LC IMPLEMENTATION.
METHOD DISPLAY.
B = A + 20.
C = A + 30.
ENDMETHOD.
ENDCLASS.
*Create the object.
DATA OBJ TYPE REF TO CL_LC.
START-OF-SELECTION.
CREATE OBJECT OBJ.
CALL METHOD OBJ->DISPLAY
EXPORTING
A = 10
IMPORTING
B = V_IMP
CHANGING
C = V_CHA.
WRITE:/ 'OUTPUT PARAMETR',    V_IMP,
'CHANGING PARAMETER', V_CHA.

Save and activate the program.

Now execute the program by inserting a breakpoint.

Press F5.

Press F5

Press F5.

The values are changed.

Press F5.

Then

Final output.

No comments:

Tutorials on SAP-ABAP

Adobe Interactive Forms Tutorials

Business Server Pages (BSP)

Userexits/BADIs

Web Dynpro for ABAP (Step by step procedure for web dynpro,Tutorials on Web Dynpro,)

ALV Tutorials

Blog Archive

goodsites