Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Vijayendar Reddy
REPORT ZRELIANCE_PROGRAM1. PROGRAM1: Class SALES definition. Public section. Methods: create_sales_order, Change_sales_order, Display_sales_order. EndClass. Class SALES implementation. Method create_sales_order. Call Transaction 'VA01'. EndMethod. Method change_sales_order. Call Transaction 'VA02'. EndMethod. Method display_sales_order. Call Transaction 'VA03'. EndMethod.
EndClass. Start-of-selection. Selection-screen begin of Block B1 with Frame Title Sales. Parameter: RB_crete RadioButton Group G1, RB_chnge RadioButton Group G1, RB_displ RadioButton Group G1. Selection-screen end of Block B1. Data: obj Type Ref To SALES. Create Object obj. If RB_crete = 'X'. Obj->create_sales_order( ). Elseif RB_chnge = 'X'. Obj->change_sales_order( ). Elseif RB_displ = 'X'. Obj->display_sales_order( ). Endif.
Note: Convert the Above Local Class( SE38 ) To Global Class ( SE24 ).
Create a Global Class: Name : ZCL_SALES. In SE38 Program: Change local class NAME to global Class NAME. And implement the following code .
Start-of-selection. Selection-screen begin of Block B1 with Frame Title Sales. Parameter: RB_crete RadioButton Group G1, RB_chnge RadioButton Group G1, RB_displ RadioButton Group G1. Selection-screen end of Block B1. Data: obj Type Ref To ZCL_SALES. Create Object obj. If RB_crete = 'X'. Obj->create_sales_order( ). Elseif RB_chnge = 'X'. Obj->change_sales_order( ). Elseif RB_displ = 'X'. Obj->display_sales_order( ). Endif.
Class EMP definition. Public Section. Methods : ASSIGNMD, DISPLAYMD. PROTECTED SECTION. DATA : EMPNO TYPE I, ENAME(20) TYPE C. ENDCLASS. CLASS EMP IMPLEMENTATION. METHOD ASSIGNMD. EMPNO = '1'. ENAME = 'VIJAYENDAR REDDY'. ENDMETHOD. METHOD DISPLAYMD. WRITE : / EMPNO,ENAME. ENDMETHOD. ENDCLASS. START-OF-SELECTION. DATA OBJ TYPE REF TO EMP. CREATE OBJECT OBJ. OBJ->DISPLAYMD( ). OBJ->ASSIGNMD( ). OBJ->DISPLAYMD( ). Note: Convert the Above Local Class( SE38 ) To Global Class ( SE24 ).
Create a Global Class: Name : ZCL_EMP. In SE38 Program: Change local class NAME to global Class NAME. And implement the following code .
START-OF-SELECTION. DATA OBJ TYPE REF TO ZCL_EMP.
REPORT ZRELIANCE_PROGRAM3. DESCRIPTION : THIS CLASS WILL DISPLAY THE LIST OF COMPANY CODE. CLASS COMPANYCLASS DEFINITION. PUBLIC SECTION. DATA : BEGIN OF WA, BUKRS TYPE BUKRS, BUTXT TYPE BUTXT, ORT01 TYPE ORT01, LAND1 TYPE LAND1, END OF WA. DATA ITAB LIKE TABLE OF WA. METHODS : SELECTMD, DISPLAYMD. ENDCLASS. CLASS COMPANYCLASS IMPLEMENTATION. METHOD SELECTMD. SELECT BUKRS BUTXT ORT01 LAND1 FROM T001 INTO TABLE ITAB. ENDMETHOD. METHOD DISPLAYMD. WRITE : / 'CODE', 'COMPANY NAME ', ' COMPANY COUNTRY'. NEW-lINE. LOOP AT ITAB INTO WA. WRITE : / wa-bukrs,WA-BUTXT,WA-ORT01,WA-LAND1. ENDLOOP. ENDMETHOD. ENDCLASS. START-OF-SELECTION. DATA OBJ TYPE REF TO COMPANYCLASS. CREATE OBJECT OBJ. OBJ->SELECTMD( ). OBJ->DISPLAYMD( ).
Using Method Parameters: ------------------------------------------------------------IF Method definition: methods : selectmd importing vbelnlow type vbak-vbeln vbelnhigh type vbak-vbeln returning name type string
THEN while calling method : obj->selectmd( exporting vbelnlow = so_vbeln-Low vbelnhigh = so_vbeln-high receiving name = tname.
PUBLIC SECTION. tYPES : BEGIN OF ty_vbak, vbeln type vbak-vbeln, ernam type vbak-ernam, erdat type vbak-erdat, erzet type vbak-erzet, END OF ty_vbak. data : itab TYPE STANDARD TABLE OF TY_VBAK. DATA : WA TYPE TY_VBAK. METHODS: SELECTMD, DISPLAYMD.
SELECTMD.
SELECT VBELN ERNAM ERDAT ERZET FROM VBAK INTO TABLE ITAB. ENDMETHOD . METHOD DISPLAYMD.
LOOP AT ITAB INTO WA. WRITE:/ ENDLOOP. ENDMETHOD . EndClass. START-OF-SELECTION. DATA OBJ TYPE REF TO SALES. CREATE OBJECT OBJ. OBJ->SELECTMD( ). OBJ->DISPLAYMD( ). WA-VBELN, WA-ERNAM,WA-ERDAT, WA-ERZET.
OOABAP Report which displays SALES HEADER DATA: With Select-OPTIONS: Technique 1: without METHOD parameters:
CLASS Sales DEFINITION.
PUBLIC SECTION. tYPES : BEGIN OF ty_vbak, vbeln type vbak-vbeln, ernam type vbak-ernam, erdat type vbak-erdat, erzet type vbak-erzet, END OF ty_vbak. data : itab TYPE STANDARD TABLE OF TY_VBAK. DATA : WA TYPE TY_VBAK. DATA : data : vbelnlow Type vbak-vbeln. vbelnhigh Type vbak-vbeln.
METHODS:
SELECTMD , DISPLAYMD.
SELECTMD.
SELECT VBELN ERNAM ERDAT ERZET FROM VBAK INTO TABLE ITAB where vbeln >= vbelnlow AND vbeln <= vbelnhigh . ENDMETHOD . METHOD DISPLAYMD.
LOOP AT ITAB INTO WA. WRITE:/ ENDLOOP. ENDMETHOD . EndClass. WA-VBELN, WA-ERNAM,WA-ERDAT, WA-ERZET.
Select-OPTIONS
OOABAP Report which displays SALES HEADER DATA: With Select-OPTIONS: Technique 2: with METHOD parameters:
CLASS Sales DEFINITION.
PUBLIC SECTION. tYPES : BEGIN OF ty_vbak, vbeln type vbak-vbeln, ernam type vbak-ernam, erdat type vbak-erdat, erzet type vbak-erzet, END OF ty_vbak. data : itab TYPE STANDARD TABLE OF TY_VBAK. DATA : WA TYPE TY_VBAK. METHODS: SELECTMD DISPLAYMD. EndClass. CLASS Sales METHOD IMPLEMENTATION. importing vbelnlow TYPE vbak-vbeln vbelnhigh TYPE vbak-vbeln,
SELECTMD.
SELECT VBELN ERNAM ERDAT ERZET FROM VBAK INTO TABLE ITAB where vbeln >= vbelnlow AND vbeln <= vbelnhigh . ENDMETHOD . METHOD DISPLAYMD.
LOOP AT ITAB INTO WA. WRITE:/ WA-VBELN, WA-ERNAM,WA-ERDAT, WA-ERZET. ENDLOOP. ENDMETHOD . EndClass.
START-OF-SELECTION. TABLES VBAK. DATA OBJ TYPE REF TO SALES. Select-OPTIONS so_vbeln for vbak-vbeln.
CREATE OBJECT OBJ. OBJ->SELECTMD( EXPORTING vbelnlow = so_vbeln-low vbelnhigh = so_vbeln-high OBJ->DISPLAYMD( ).
).
create object k. write :/ k->empno, k->ename. k->empno = 10. k->ename = 'xyz'. write :/ k->empno, k->ename.
optional,
parameters : p_x type i, p_y(20) type c. call method ob->m1 exporting x = p_x y = p_y. call method ob->m2.
Z730AMCLASS3: ATTRIBUTES: METHODS: PARAMETERS METHOD M1: DOUBLE CLICK ON METHOD M1:
method m1. empno = x. ename = y. endmethod.
class abc implementation. method m1. m = x + y. n = x - y. endmethod. endclass. start-of-selection. data ob type ref to abc. create object ob. data : lv_r1 type i, lv_r2 type i. call method ob->m1 exporting x = 20 y = 10 importing m = lv_r1 n = lv_r2. write :/ lv_r1,lv_r2.
PROGRAM8(RETURNING PARAMETERS):
REPORT Z730AMOOPS8. class abc definition. public section. methods m1 importing x type i y type i returning value(z) type i. endclass. class abc implementation. method m1. z = x + y. endmethod. endclass. start-of-selection. data ob type ref to abc. create object ob. data lv_r type i. call method ob->m1 exporting x = 10 y = 20 receiving z = lv_r. write :/ 'sum is ',lv_r. clear lv_r.
parameters : p_x type i, p_y type i. data lv_r type i. call method ob->m1 exporting x = p_x y = p_y importing z = lv_r. write :/ 'Division is ',lv_r. write :/ 'End of program'.
write :/ 'Program is :',prgname, / 'Include is :',incname, / 'Line no is :',pos. endtry. endmethod. endclass. start-of-selection. data ob type ref to abc. create object ob. parameters : p_x type i, p_y type i. data lv_r type i. call method ob->m1 exporting x = p_x y = p_y importing z = lv_r. write :/ 'Division is ',lv_r. write :/ 'End of program'.
PROGRAM12(RAISING KEYWORD):
REPORT Z730AMOOPS12. class abc definition. public section. methods m1 importing x type i y type i exporting z type i raising cx_sy_zerodivide. endclass. class abc implementation. method m1. z = x / y. endmethod. endclass. start-of-selection. data ob type ref to abc. create object ob. parameters : p_x type i, p_y type i. data : lv_r type i. try. call method ob->m1 exporting
x = p_x y = p_y importing z = lv_r. catch cx_sy_zerodivide. write :/ 'Exception raised'. endtry. write :/ 'Division is ',lv_r. write :/ 'End'.
ob1->y, abc=>y. ob1->x = 10. ob1->y = 20. write :/ 'object ob1'. write :/ ob1->x, ob1->y. data ob2 type ref to abc. create object ob2. write :/ 'object ob2'. write :/ ob2->x, ob2->y. ob2->y = 30. write :/ 'object ob1'. write :/ ob1->x, ob1->y, ob2->x.
method class_constructor. write :/ 'static const'. endmethod. endclass. start-of-selection. data ob1 type ref to abc. create object ob1. data ob2 type ref to abc. create object ob2.
PROGRAM20(PARAMETERS TO CONSTRUCTORS):
REPORT Z730AMOOPS20. class abc definition. public section. methods : constructor importing x type i y type c, display. protected section. data : empno type i, ename(20) type c. endclass.
class abc implementation. method constructor. empno = x. ename = y. endmethod. method display. write :/ empno,ename. endmethod. endclass. start-of-selection. parameters : p_x type i, p_y(20) type c. data ob type ref to abc. create object ob exporting x = p_x y = p_y. call method ob->display.
PROGRAM21(SINGLE INHERITANCE):
REPORT Z730AMOOPS21 . class cycle definition. public section. methods : setcycle, display. protected section. data : wheels type i, brakes type i, colour(20) type c. endclass. class cycle implementation. method setcycle. wheels = 2. brakes = 2. colour = 'green'. endmethod. method display. write :/ wheels,brakes,colour. endmethod. endclass. class scooter definition inheriting from cycle. public section. methods setscooter. endclass. class scooter implementation. method setscooter. wheels = 2. brakes = 4. colour = 'red'. endmethod. endclass. start-of-selection. data ob1 type ref to cycle. create object ob1.
call method : ob1->setcycle, ob1->display. data ob2 type ref to scooter. create object ob2. call method ob2->setscooter. call method ob2->display.
PROGRAM22(MULTILEVEL INHERITANCE):
REPORT Z730AMOOPS22 . class cycle definition. public section. methods : setcycle, display. protected section. data : wheels type i, brakes type i, colour(20) type c. endclass. class cycle implementation. method setcycle. wheels = 2. brakes = 2. colour = 'green'. endmethod. method display. write :/ wheels,brakes,colour. endmethod. endclass. class scooter definition inheriting from cycle. public section. methods setscooter. endclass. class scooter implementation. method setscooter. wheels = 2. brakes = 4. colour = 'red'. endmethod. endclass. class car definition inheriting from scooter. public section. methods setcar. endclass. class car implementation. method setcar. wheels = 4. brakes = 5. colour = 'blue'. endmethod. endclass. start-of-selection.
data ob1 type ref to cycle. create object ob1. call method : ob1->setcycle, ob1->display. data ob2 type ref to scooter. create object ob2. call method ob2->setscooter. call method ob2->display. data ob3 type ref to car. create object ob3. call method ob3->setcar. call method ob3->display.
Z730AMSCOOTER: ATTRIBUTES:
PROGRAM25(METHOD OVERLOADING):
REPORT Z730AMOOPS25 . class abc definition. public section. methods m1. methods m1 importing x type i. endclass.
PROGRAM26(METHOD OVERLOADING):
REPORT Z730AMOOPS26 . class abc definition. public section. methods m1. endclass. class abc implementation. method m1. write :/ 'inside super class m1'. endmethod. endclass. class pqr definition inheriting from abc. public section. methods m1 redefinition. endclass. class pqr implementation. method m1. write :/ 'inside sub class method m1'. call method super->m1. endmethod. endclass. start-of-selection. data ob1 type ref to pqr. create object ob1. call method ob1->m1.
public section. methods constructor. class-methods class_constructor. endclass. class abc implementation. method constructor. write :/ 'inside super class instance const'. endmethod. method class_constructor. write :/ 'inside super class static const'. endmethod. endclass. class pqr definition inheriting from abc. public section. class-methods class_constructor. endclass. class pqr implementation. method class_constructor. write :/ 'inside sub class static const'. endmethod. endclass. start-of-selection. data ob1 type ref to pqr. create object ob1.
method class_constructor. write :/ 'inside sub class static const'. endmethod. endclass. start-of-selection. data ob1 type ref to pqr. create object ob1.
PROGRAM30(PUBLIC CLASSES):
REPORT * Z730AMOOPS30. class abc definition. class abc definition create public. public section. data x type i. endclass. class pqr definition inheriting from abc. endclass. start-of-selection. data ob type ref to abc. create object ob. data ob1 type ref to pqr. create object ob1.
PROGRAM31(PROTECTED CLASSES):
REPORT Z730AMOOPS31 class abc definition create protected. public section. data x type i. endclass. class pqr definition create public inheriting from abc. public section. methods m1. endclass. class pqr implementation. method m1. data ob type ref to abc. create object ob. endmethod. endclass. start-of-selection. data ob1 type ref to pqr. create object ob1. .
PROGRAM32(PRIVATE CLASSES):
REPORT Z730AMOOPS32 class pqr definition deferred. . class abc definition create private friends pqr. public section. data x type i. endclass. class pqr definition create public inheriting from abc.
public section. methods m1. endclass. class pqr implementation. method m1. data ob type ref to abc. create object ob. endmethod. endclass. start-of-selection. data ob1 type ref to pqr. create object ob1.
class creditcard definition inheriting from restaurant. public section. methods payment redefinition. protected section. data : ccno type i, amount type i, bankname(20) type c. endclass. class creditcard implementation. method payment. ccno = 5555. amount = 444. bankname = 'xyz'. write :/ ccno,amount,bankname. endmethod. endclass. start-of-selection. data r type ref to restaurant. data cq type ref to cheque. create object cq. write :/ 'CHEQUE Class'. call method : cq->set, cq->display, cq->payment. write :/ ' CHEQUE --> RESTAURANT'. r = cq. call method : r->set, r->display, r->payment. data cc type ref to creditcard. create object cc. write :/ 'CREDITCARD Class'. call method : cc->set, cc->display, cc->payment. write :/ ' CREDITCARD --> RESTAURANT'. r = cc.
ZCHEQUE(SE24): ATTRIBUTES:
METHODS: DOUBLE CLICK ON METHOD SET:
method set . tableno = 1. steward = 'abc'. endmethod.
SELECTION-SCREEN: BEGIN OF BLOCK B2 WITH frame TITLE PaRAMETER: RB_CRET RADIOBUTToN GROuP G2, RB_CHANG RADIOBUTToN GROuP G2, RB_DISP RADIOBUTToN GROuP G2. SELECTION-SCREEN END OF BLOCK B2. Interface I_data. Methods: create, change, display. endInterface. Class LCL_customer definition. public section. Interfaces:I_data. endclass. Class LCL_customer Implementation. method I_data~create. call transaction 'XD01'. endmethod. method I_data~change. call transaction 'XD02'. endmethod. method I_data~display. call transaction 'XD03'. endmethod. endclass. Class LCL_sales_order definition. public section. Interfaces:I_data. endclass. Class LCL_sales_order Implementation. method I_data~create. call transaction 'VA01'. endmethod. method I_data~change. call transaction 'VA02'. endmethod. method I_data~display. call transaction 'VA03'. endmethod. ENDClaSS. DATA:o_CUSTOMER TYPE REF TO LCL_customer, o_sorder type Ref to LCL_sales_order, IRef_data type ref to I_data. start-of-selection. create object o_customer.
TEXT-001.
create object o_sorder. if rb_cust = 'X'. IRef_data = o_customer. elseif RB_sales = 'X'. IRef_data = o_sorder. endif. if Rb_cret ='X'. call method IRef_data->create. elseif RB_chang = 'X'. CALL METHOD IRef_data->change. elseif RB_disp = 'X'. CALL METHOD IRef_data->display. endif.
PROGRAM36(LOCAL INTERFACES):
REPORT Z730AMOOPS36 interface rectangle. constants : length type i value 10, breadth type i value 5. methods : area, perimeter. endinterface. interface square. constants : side type i value 7. methods : area, perimeter. endinterface. class abc definition. public section. data r type i. interfaces : rectangle, square. endclass. class abc implementation. method rectangle~area. r = rectangle~length * rectangle~breadth. write :/ 'Area of rectangle is ',r. endmethod.
endmethod. method square~area. r = square~side * square~side. write :/ 'Area of square is ',r. endmethod. method square~perimeter. r = 4 * square~side. write :/ 'perimeter of square is ',r. endmethod. endclass. start-of-selection. data ob type ref to abc. create object ob. call method : ob->rectangle~area, ob->rectangle~perimeter, ob->square~area, ob->square~perimeter.
interface abc. methods : m1, m2, m3. endinterface. class pqr definition abstract. public section. interfaces abc abstract methods m2 m3. endclass. class pqr implementation. method abc~m1. write :/ 'inside m1'. endmethod.
endclass. class xyz definition inheriting from pqr. public section. methods : abc~m2 redefinition, abc~m3 redefinition. endclass. class xyz implementation. method abc~m2. write :/ 'inside m2'. endmethod. method abc~m3. write :/ 'inside m3'. endmethod. endclass. start-of-selection. data ob type ref to xyz. create object ob. call method : ob->abc~m1, ob->abc~m2, ob->abc~m3.
PROGRAM38(LOCAL ALIASES):
REPORT Z730AMOOPS38. interface abc. methods : m1, m2. endinterface. class pqr definition. public section. interfaces abc. aliases a1 for abc~m1. protected section. aliases a2 for abc~m2. endclass. class pqr implementation. method a1. write :/ 'inside m1'. call method a2. endmethod. method a2. write :/ 'inside m2'. endmethod. endclass. start-of-selection. data ob type ref to pqr. create object ob.
Z30IMP1(SE24): INTERFACES: DOUBLE CLICK ON INTERFCES: METHODS: DOUBLE CLICK ON METHOD ZINTER~M1:
method zinter~m1. write :/ 'inside m1'. call method a2. endmethod. method zinter~m2. write :/ 'inside m2'. endmethod.
DOUBLE CLICK ON METHOD ZINTER~M2: PROGRAM40(PERSISTENCE SERVICE USING BUSINESS KEY IDENTITY):
REPORT Z730AMOOPS40. parameters : p_dno type Zdept-deptno, p_dname type zdept-deptname, p_loc type zdept-loc. parameters : r1 radiobutton group g1, r2 radiobutton group g1, r3 radiobutton group g1. data actor type ref to zca_8dept. data pers type ref to zcl_8dept.
start-of-selection. actor = zca_8dept=>agent. if r1 = 'X'. TRY. call method actor->create_persistent exporting I_DEPTNAME = p_dname i_deptno = p_dno I_LOC = p_loc receiving result = pers. if pers is not initial. commit work. endif. CATCH CX_OS_OBJECT_EXISTING . message 'Exception' type 'I'. ENDTRY. elseif r2 = 'X'. TRY. call method actor->delete_persistent exporting i_deptno = p_dno. commit work. CATCH CX_OS_OBJECT_NOT_EXISTING . message 'Object not found' type 'I'. ENDTRY. endif.
if pers is not initial. commit work. endif. CATCH CX_OS_OBJECT_EXISTING . message 'Exception' type 'I'. ENDTRY. elseif r2 = 'X'. TRY. call method actor->delete_persistent exporting i_deptno = p_dno. commit work. CATCH CX_OS_OBJECT_NOT_EXISTING . message 'Object not found' type 'I'. ENDTRY. elseif r3 = 'X'. clear pers. TRY. call method actor->get_persistent exporting i_deptno = p_dno receiving result = pers. if pers is not initial. clear : p_dname, p_loc. p_dname = pers->get_deptname( ). p_loc = pers->get_loc( ). write :/ 'Department name :',p_dname, / 'Location :',p_loc. endif. CATCH CX_OS_OBJECT_NOT_FOUND . message 'object not found' type 'I'. ENDTRY. endif.
call method cl_os_system=>get_transaction_manager receiving result = trans_mng. call method trans_mng->create_transaction receiving result = trans. try. call method trans->start. * perform the operation call method m2. catch cx_os_transaction . message 'Exception in starting transaction' type 'I'. endtry. * end the transaction try. call method trans->end. catch cx_os_check_agent_failed . catch cx_os_transaction . call method trans->undo. endtry. endmethod.
call method actor->create_persistent exporting i_deptname = 'HR' i_deptno = 46 i_loc = 'Hyderabad' receiving result = pers. catch cx_os_object_existing . message 'Exception in create' type 'I'. endtry. endmethod.
PROGRAM42:
REPORT
Z730AMOOPS42.
parameters : p_guid type zmemp-guid, p_empno type zmemp-empno, p_ename type zmemp-ename. parameters : r1 radiobutton group g1,
r2 radiobutton group g1, r3 radiobutton group g1. data : actor type ref to zca_8emp, pers type ref to zcl_8emp, ob type ref to object. start-of-selection. actor = zca_8emp=>agent. if r1 = 'X'. TRY. call method actor->create_persistent EXPORTING I_EMPNO = p_empno I_ENAME = p_ename receiving result = pers. if pers is not initial. commit work. endif. CATCH CX_OS_OBJECT_EXISTING . message 'Exception' type 'I'. ENDTRY. elseif r3 = 'X'. TRY. call method actor->if_os_ca_persistency~get_persistent_by_oid exporting i_oid = p_guid receiving result = ob. clear : pers, p_empno, p_ename. pers ?= ob. p_empno = pers->get_empno( ). p_ename = pers->get_ename( ). write :/ 'Employee no is :',p_empno, 'Employee name is :',p_ename. CATCH CX_OS_OBJECT_NOT_FOUND . CATCH CX_OS_CLASS_NOT_FOUND . message 'not found' type 'I'. ENDTRY. elseif r2 = 'X'. * Check for existence of object call method actor->if_os_ca_persistency~get_persistent_by_oid exporting i_oid = p_guid receiving result = ob. if ob is not initial. clear pers. pers ?= ob. endif.
TRY. call method actor->if_os_factory~delete_persistent exporting i_object = pers. commit work. CATCH CX_OS_OBJECT_NOT_EXISTING . message 'not found' type 'I'. ENDTRY. endif.
PROGRAM43:
report z730amoops43. class abc definition create private. public section. class-data ob type ref to abc. "static reference class-methods class_constructor. "static const class-methods m2 returning value(k) type ref to abc. "static method methods m1. endclass. class abc implementation. method class_constructor. create object ob. endmethod. method m1. write :/ 'inside instance method'. endmethod. method m2. k = ob. endmethod. endclass. start-of-selection. data r type ref to abc. r = abc=>m2( ). call method r->m1.
RTTS PROGRAM:
REPORT ZRTTS. parameters : p_tab type dd02l-tabname. field-symbols : <fstab> type any table, <fswa> type any,
<fsfield> type any. data : ref_rowtype type ref to cl_abap_structdescr, ref_tabletype type ref to cl_abap_tabledescr. data : ref_tab type ref to DATA, ref_wa type ref to DATA. start-of-selection. * Dynamic instantiation ref_rowtype ?= cl_abap_typedescr=>describe_by_name( p_name = p_tab ).
tRY. call method cl_abap_tabledescr=>create exporting p_line_type = ref_rowtype receiving p_result = ref_tabletype. CATCH CX_SY_TABLE_CREATION . message 'Error in creating internal table' type 'I'. ENDTRY. * Create the object create data ref_wa type handle ref_rowtype. create data ref_tab type handle ref_tabletype. * Value assignment (MAPPING DBTABLE STRUCTURE TO FIELDSYMBOLS) assign ref_wa->* to <fswa>. assign ref_tab->* to <fstab>. * Data retrieval select * from (p_tab) into table <fstab> UP TO 5 ROWS. * Data Display loop at <fstab> into <fswa>. do. assign component sy-index of structure <fswa> to <fsfield>. if sy-subrc eq 0. write : <fsfield>. else. NEW-LINE. exit. endif. enddo. endloop.
events e1. "instance event methods : m1 for event e1 of abc, "instance event handler method m2. "instance normal method endclass. class abc implementation. method m1. write :/ 'inside instance event handler m1'. endmethod. method m2. write :/ 'inside m2'. raise event e1. endmethod. endclass. start-of-selection. data ob type ref to abc. create object ob. call method ob->m2.
REPORT Z730AMOOPS44. class abc definition. public section. events e1. "instance event methods : m1 for event e1 of abc, "instance event handler method m2. "instance normal method endclass. class abc implementation. method m1. write :/ 'inside instance event handler m1'. endmethod. method m2. write :/ 'inside m2'. raise event e1. endmethod. endclass. start-of-selection. data ob type ref to abc. create object ob. call method ob->m2. set handler ob->m1 for ob.
events e1. "instance event methods : m1 for event e1 of abc, "instance event handler method m2. "instance normal method endclass. class abc implementation. method m1. write :/ 'inside instance event handler m1'. endmethod. method m2. write :/ 'inside m2'. raise event e1. endmethod. endclass. start-of-selection. data ob type ref to abc. create object ob. set handler ob->m1 for ob. call method ob->m2.
start-of-selection. data ob type ref to abc. create object ob. data ob1 type ref to abc. create object ob1. set handler ob->m1 for ob. set handler ob->m1 for ob1. call method ob->m2. call method ob1->m2.
PROGRAM51(STATIC EVENTS):
REPORT Z730AMOOPS51 class abc definition. public section. class-events e1. methods : m1 for event e1 of abc, m2.
endclass. class abc implementation. method m1. write :/ 'inside event handler m1'. endmethod. method m2. write :/ 'inside m2'. raise event e1. endmethod. endclass. start-of-selection. data ob type ref to abc. create object ob. data ob1 type ref to abc. create object ob1. set handler ob->m1. call method ob->m2. call method ob1->m2.
PROGRAM52(STATIC EVENTS):
REPORT Z730AMOOPS51 class abc definition. public section. events e1. methods : m1 for event e1 of abc, m2. endclass. class abc implementation. method m1. write :/ 'inside first event handler m1'. endmethod. method m2. write :/ 'inside m2'. raise event e1. endmethod. endclass. class pqr definition. public section. methods m3 for event e1 of abc. endclass. class pqr implementation. method m3. write :/ 'second event handler method m3'. endmethod.
endclass. start-of-selection. data ob type ref to abc. create object ob. data ob1 type ref to pqr. create object ob1. set handler ob1->m3 for ob. set handler ob->m1 for ob. call method ob->m2.
Z730CLASS10: METHODS:
EVENTS: PARAMETERS OF EVENT E1: PROGRAM55: PROGRAM56: PROGRAM57: PROGRAM58: PROGRAM59: PROGRAM60: