Saturday, August 8, 2020

Global classes (Types, Attributes, Methods) & accessing global class in report (class 9)

  

 i created a class in se24 and create a type structure for table and i have  used code based rather than form based.

and i declared a table of ty_vbak , which when we see in form based on attribute tab , we will see T_VBAK table in it and protected type .

and now creating methods :

i have created 2 methods : 1 for fetching data and other for displaying data.

get_data method : which instance and should be public 

display : which is instance and should be protected.

 now coming to the parameters of get_data methods.

 code for get_data.

 

 

 

 now write logic to display data in display method.

 

 Activate it  and ready to use it in reports.

 

 


 

 Create a report in se38 .

 *&---------------------------------------------------------------------*
*& Report  ZOOABAP_CL9
*& Calling Global class from local report
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZOOABAP_CL9"report name 

DATA OB TYPE REF TO ZOOABAP_CL9."CLASS NAME CREATED VIA SE24
CREATE OBJECT OB.

PARAMETERS P_KUNNR TYPE KUNNR
CALL METHOD ob->get_data "method 
  EXPORTING
    im_kunnr P_KUNNR  
    .