0% found this document useful (0 votes)
32 views

Case Study Global Class

The document describes a case study on using a global class in ABAP to display customer details. It involves creating a global class ZCL_GLOBAL_CLASS with methods GET_DATA to retrieve customer data based on input selection and DISPLAY_DATA to output the results. A program ZGLOBAL_CLASS is created to call these methods via an object reference to display the customer details.

Uploaded by

bakkali_bilal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Case Study Global Class

The document describes a case study on using a global class in ABAP to display customer details. It involves creating a global class ZCL_GLOBAL_CLASS with methods GET_DATA to retrieve customer data based on input selection and DISPLAY_DATA to output the results. A program ZGLOBAL_CLASS is created to call these methods via an object reference to display the customer details.

Uploaded by

bakkali_bilal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 11

Case Study: OOABAP-Global Class.

Business Requirement:
To create a global class and display the customer details using global class.
To have a very simple scenario on this, Lets enter customer

numbers on selection screen.


Based on the input ,The customer details will be displayed.

Solution:
Go to se24 Tcode

Provide the global class name as ZCL_GLOBAL_CLASS.

Click on the Create Button.

Author: Nageswar

Page 1

02/tt/jjjj

Provide the Description.

Press Save button .Then we can view the scree like this

Author: Nageswar

Page 2

02/tt/jjjj

Provide method name as GET_DATA.

Goto Attributes and provide the values.

Author: Nageswar

Page 3

02/tt/jjjj

In Above screen ZSTR_KNA1 is structure

and ZTT_KNA1 is table type.

Author: Nageswar

Page 4

02/tt/jjjj

Go to methods tab and double click on the method GET_DATA and provide the bellow logic.
method GET_DATA .
SELECT KUNNR
LAND1
NAME1
ORT01
FROM KNA1 INTO TABLE IT_KNA1
WHERE KUNNR BETWEEN S_KUNNR_LOW AND S_KUNNR_HIGH.
endmethod.

Author: Nageswar

Page 5

02/tt/jjjj

Save Check and Activate .


Provide another method as DISPLAY_DATA.

Double click on the DISPLAY_DATA and provide the bellow logic.


method DISPLAY_DATA .
LOOP AT IT_KNA1 INTO WA_KNA1.
WRITE:/ WA_KNA1-KUNNR,
WA_KNA1-LAND1,
WA_KNA1-NAME1,
WA_KNA1-ORT01.
ENDLOOP.
endmethod.

Author: Nageswar

Page 6

02/tt/jjjj

Save Check and Activate .


Go to SE38 and create program with name ZGLOBAL_CLASS.

Provide the description.

Author: Nageswar

Page 7

02/tt/jjjj

Provide the bellow logic.


DATA:KNA1 TYPE KNA1.
*Select Options
SELECT-OPTIONS:S_KUNNR FOR KNA1-KUNNR.
*Declaration of object reference variable
DATA:OBJ TYPE REF TO ZCL_GLOBAL_CLASS.
START-OF-SELECTION.
*Create Object
CREATE OBJECT OBJ.
*Provide attribute values
OBJ->S_KUNNR_LOW = S_KUNNR-LOW.
OBJ->S_KUNNR_HIGH = S_KUNNR-HIGH.
*Calling the method to get data.
CALL METHOD OBJ->GET_DATA.
*Calling the method to display data.
CALL METHOD OBJ->DISPLAY_DATA.

Author: Nageswar

Page 8

02/tt/jjjj

Save Check and Activate .


Execute the program.

Author: Nageswar

Page 9

02/tt/jjjj

Provide the customer numbers in selection screen.

Author: Nageswar

Page 10

02/tt/jjjj

Execute it.
Output:

Author: Nageswar

Page 11

02/tt/jjjj

You might also like