Kutumiza mu Pulogalamu ya ABAP

CLASS a1 DEFINITION.
 GAWO LA ANTHU.
 DATA: nambala1 TYPE ndi VALUE 100.
 NJIRA:m1.
 ENDCLASS.
 CLASS a1 KUCHITA.
 NJIRA m1.
 LEMBA: 'a1:',nambala1.
 MAPETO.
 ENDCLASS.
 CLASS b1 TANTHAUZO CHOLOWA KUCHOKERA KU a1.
 GAWO LA ANTHU.
 NJIRA:m2, m1 KUTANTHAUZIRA NTCHITO.
 ENDCLASS.
 KUKHALITSA PHUNZIRO b1.
 NJIRA m1.
 nambala1 = nambala1.
 LEMBA: 'b1:', nambala1.
 MAPETO.
 NJIRA m2.
 LEMBA: 'M2 m'kalasi b1'.
 MAPETO.
 ENDCLASS.
 KUYAMBA-KUSANKHA.
 DATA: TYPE REF KWA a1.
 DATA: b TYPE REF KWA b1.
 *data: c lembani REF KWA c1.
 ******************************************** ************** PANGANI CHINTHU b.
 ndi = b.  "kukweza NJIRA YOYENERA KUKHALA a->m1( ).
 *itanani METHOD a->m2( ).  "Sitingathe kupeza njira zathu zamagulu ang'onoang'ono pogwiritsa ntchito super class ref.
 WATSOPANO.
 b?= ndi.  " kuponya pansi NTCHITO YOITANIRA b->m1( ).
 WATSOPANO.
 NJIRA YOYAMBIRA b->m2( ).
 ********************************************** *************** " cholakwika null ref pangani OBJECT a.
 b?= ndi.  "kuponyabe kutayira kwake kuitana METHOD b->m1( ).
 ******************************************** *************** PANGANI CHINTHU a.
 YESANI.
 b?= ndi.  "munayesa kugwiritsa ntchito 'NULL' kutaya chinthu CATCH cx_sy_move_cast_error.
 NJIRA YOYAMBIRA b->m1( ).
 MAPETO.
 ******************************************** *************** PANGANI CHINTHU a.
 PANGANI CHINTHU b.
 YESANI.
 b?= ndi.
 CATCH cx_sy_move_cast_error.
 NJIRA YOYAMBIRA b->m1( ).
 itanani METHOD b->m2( ).
 MAPETO.
 CLASS lcl_shape DEFINITION.
 GAWO LA ANTHU.
 NJIRA kujambula.
 ENDCLASS.
 CLASS lcl_circle KUCHOKERA KUCHOKERA KUCHOKERA KU lcl_shape.
 GAWO LA ANTHU.
 NJIRA: kujambula REDEFINITION, calc_area.
 ENDCLASS.
 CLASS lcl_shape IMPLEMENTATION.
 METHOD kujambula.
 LEMBANI :/ 'Kujambula Mawonekedwe aliwonse'.
 MAPETO.
 ENDCLASS.
 CLASS lcl_circle IMPLEMENTATION.
 METHOD kujambula.
 LEMBANI :/ 'Kujambula mawonekedwe enieni: kuzungulira'.
 MAPETO.
 METHOD calc_area.
 LEMBANI :/ 'Area Of Crcle = 2iiR'.
 MAPETO.
 ENDCLASS.
 KUYAMBA-KUSANKHA.
 DATA : o_cir TYPE REF TO lcl_circle.
 PANGANI CHINTHU o_cir.
 KUYAMBIRA NJIRA o_cir->jambula ().  " imayitanitsa njira ya subclass Draw() CALL METHOD o_cir->calc_area().
 ULINE.
 "--------- Narrow cast(Upcast)---------------" DATA : o_shp TYPE REF TO lcl_shape.
 o_shp = o_cir.  " Narrow cast(Upcast) IYIMBANI NJIRA o_shp->draw().  " imatchula njira ya sub class Draw() "imbani METHOD o_shp->calc_area( ) .  " cholakwika chophatikiza ULINE.
 "---------- Widening Cast(Downcast) -----------" DATA : o_cir1 TYPE REF TO lcl_circle.
 "o_cir1 = o_shp.  " complilation error o_cir1 ?= o_shp.  " Widening Cast(Downcast) INJIRA YOITANIRA o_cir1->jambula().  " imayitanitsa njira ya subclass Draw() CALL METHOD o_cir1->calc_area().
 CLASS a1 DEFINITION.
 GAWO LA ANTHU.
 DATA: nambala1 TYPE ndi VALUE 100.
 NJIRA:m1.
 ENDCLASS.
 CLASS a1 KUCHITA.
 NJIRA m1.
 LEMBA: 'a1:',nambala1.
 MAPETO.
 ENDCLASS.
 CLASS b1 TANTHAUZO CHOLOWA KUCHOKERA KU a1.
 GAWO LA ANTHU.
 NJIRA:m2, m1 KUTANTHAUZIRA NTCHITO.
 ENDCLASS.
 KUKHALITSA PHUNZIRO b1.
 NJIRA m1.
 nambala1 = nambala1.
 LEMBA: 'b1:', nambala1.
 MAPETO.
 NJIRA m2.
 LEMBA: 'M2 m'kalasi b1'.
 MAPETO.
 ENDCLASS.
 KUYAMBA-KUSANKHA.
 DATA: kholo TYPE REF KWA a1.
 DATA: mwana TYPE REF TO b1.
 *data: c lembani REF KWA c1.
 ******************************************** ************** PANGANI CHINTHU mwana.
 kholo = mwana.  "kukweza CALL METHOD kholo->m1( ).
 NJIRA YOYAMBIRA mwana->m1( ).
 NJIRA YOYAMBIRA mwana->m2( ).
 *itanani METHOD a->m2( ).  "Sitingathe kupeza njira zathu zamagulu ang'onoang'ono pogwiritsa ntchito super class ref.
 WATSOPANO.
 mwana?= kholo.  " kuponya pansi CALL NJIRA mwana->m1( ).
 WATSOPANO.
 NJIRA YOYAMBIRA mwana->m2( ).
 ******************************************** ************* *" cholakwika null ref *create OBJECT a.
 *b?= ndi.  "kuponyabe kutayira kwake *itanani METHOD b->m1( ).
 ******************************************** ************* * PANGANI CHINTHU a.
 YESANI.
 b?= ndi.  "munayesa kugwiritsa ntchito 'NULL' kutaya chinthu CATCH cx_sy_move_cast_error.
 NJIRA YOYAMBIRA b->m1( ).
 MAPETO.
 ******************************************** ************* * PANGANI CHINTHU a.
 PANGANI CHINTHU b.
 YESANI.
 b?= ndi.
 CATCH cx_sy_move_cast_error.
 NJIRA YOYAMBIRA b->m1( ).
 itanani METHOD b->m2( ).
 MAPETO.
 ******** Makhalidwe Apadera****************** DATA : lv_string TYPE zingwe, lv_string2 TYPE zingwe, lv_string_final TYPE zingwe.
 MITUNDU: KUYAMBA KWA ty_data, auth TYPE c, END OF ty_data.
 DATA: ls_user TYPE ty_data, ls_user2 TYPE ty_data, lt_user2 TYPE TABLE OF ty_data, lt_user TYPE TABLE OF ty_data.
 lv_string = 'a,b,c,a'.
 lv_string2 = 'd,b,c,a'.
 SPLIT lv_string AT ',' INTO TABLE lt_user.
 SPLIT lv_string2 AT ',' MU TABLE lt_user2.
 LOOP AT lt_user2 ASSIGNING FIELD-SYMBOL( ).
 lowetsani MU TABLE lt_user.
 ENDLOOP.
 SORT lt_user BY auth.
 Chotsani ADJACENT DUPLICATES KWA lt_user KUFANANIZA auth.
 NGATI sy-subrc = 0.
 LOOP AT lt_user ASSIGNING FIELD-SYMBOL( ).
 NGATI lv_string_final NDI YOYAMBA.
 lv_string_final = -uth.
 ZINA.
 CONCATENATE lv_string_final -auth MU lv_string_final ZOSINTHA NDI ','.
 ENDIF.
 ENDLOOP.
 ENDIF.

 

Kusiya ndemanga

Tsambali likugwiritsa ntchito Akismet kuchepetsa spam. Phunzirani momwe deta yanu ikufotokozera.