Ke hoʻolei ʻana i ka papahana ABAP

PAPA a1 HOAKAKA.
 PAUKU LEHULEHU.
 ʻIkepili: NUM1 TYPE a VALUE 100.
 HANA:m1.
 PAPA HOPE.
 PAPA a1 HOOLAHA.
 HANA m1.
 Kākau: 'a1:',num1.
 HOPE.
 PAPA HOPE.
 PAPA b1 HUAOLELO HOOLAHA MAI a1.
 PAUKU LEHULEHU.
 KANAWAI:m2, m1 HOOLAHA HOU.
 PAPA HOPE.
 PAPA b1 HOOLAHA.
 HANA m1.
 helu1 = helu1 .
 Kākau: 'b1:',num1.
 HOPE.
 HANA m2.
 Kākau: 'M2 ma ka papa b1'.
 HOPE.
 PAPA HOPE.
 HOOMAKA-KO-KOHO.
 ʻIkepili: he ʻano REF TO a1.
 ʻIkepili: b ʻAno REF TO b1.
 *ʻikepili: c ʻano REF TO c1.
 ************************************************* ************** HANA I KA MEA b.
 a = b.  "hoʻokiʻekiʻe kiʻekiʻe KĀNĀWAI a->m1( ).
 *kahea KANAWAI a->m2( ).  "ʻAʻole hiki iā mākou ke komo i nā ʻano subclass ponoʻī me ka hoʻohana ʻana i ka super class ref.
 HOU-LAINA.
 b ?= a.  " hoolei iho KANAWAI KALE b->m1( ).
 HOU-LAINA.
 KANAWAI KALE b->m2( ).
 ************************************************* *************** " hewa null ref hana OBJECT a.
 b ?= a.  "Ka hoʻolei ʻana i lalo i kāna hāʻawi ʻana i ke kelepona ʻo METHOD b->m1( ).
 ************************************************* ************* HANA I KA MEA a.
 HOAO.
 b ?= a.  "Ua hoʻāʻo ʻoe e hoʻohana i kahi 'NULL' mea kuhikuhi dump CATCH cx_sy_move_cast_error.
 KANAWAI KALE b->m1( ).
 HOPE.
 ************************************************* ************* HANA I KA MEA a.
 HANA I KA MEA b.
 HOAO.
 b ?= a.
 CATCH cx_sy_move_cast_error.
 KANAWAI KALE b->m1( ).
 kahea METHOD b->m2( ).
 HOPE.
 PAPA lcl_shape DEFINITION.
 PAUKU LEHULEHU.
 HANA kaha.
 PAPA HOPE.
 KA PALAPALA lcl_circle KA HOʻoilina MAI lcl_shape.
 PAUKU LEHULEHU.
 METHODS: kaha kiʻi REDEFINITION, calc_area.
 PAPA HOPE.
 CLASS lcl_shape IMPLEMENTATION.
 KANAWAI kaha.
 Kākau :/ 'Ke kaha ki'i 'ana i kekahi 'ano.
 HOPE.
 PAPA HOPE.
 CLASS lcl_circle IMPLEMENTATION.
 KANAWAI kaha.
 Kākau :/ 'Ke kaha ki'i kiko'ī: Po'ai'.
 HOPE.
 METHOD calc_area.
 Kākau :/ 'Area Of Crcle = 2iiR'.
 HOPE.
 PAPA HOPE.
 HOOMAKA-KO-KOHO.
 DATA: o_cir TYPE REF TO lcl_circle.
 HANA HANA o_cir.
 KĀNE KANAWAI o_cir->draw( ).  "Kahea ka subclass Draw() ala 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) CALL METHOD o_shp->draw( ).  "E kāhea i ka papa hana Draw() ke ʻano "kahea METHOD o_shp->calc_area().  " hewa hōʻuluʻulu ULINE.
 "---------- Hoʻonui i ka hoʻolei (Downcast) -----------" DATA: o_cir1 TYPE REF TO lcl_circle.
 " o_cir1 = o_shp.  " hewa complilation o_cir1 ?= o_shp.  " Hoʻonui i ka hoʻolei (Downcast) KĀNĀ KAULA o_cir1-> huki ( ).  "Kahea ka subclass Draw() ala CALL METHOD o_cir1->calc_area().
 PAPA a1 HOAKAKA.
 PAUKU LEHULEHU.
 ʻIkepili: NUM1 TYPE a VALUE 100.
 HANA:m1.
 PAPA HOPE.
 PAPA a1 HOOLAHA.
 HANA m1.
 Kākau: 'a1:',num1.
 HOPE.
 PAPA HOPE.
 PAPA b1 HUAOLELO HOOLAHA MAI a1.
 PAUKU LEHULEHU.
 KANAWAI:m2, m1 HOOLAHA HOU.
 PAPA HOPE.
 PAPA b1 HOOLAHA.
 HANA m1.
 helu1 = helu1 .
 Kākau: 'b1:',num1.
 HOPE.
 HANA m2.
 Kākau: 'M2 ma ka papa b1'.
 HOPE.
 PAPA HOPE.
 HOOMAKA-KO-KOHO.
 ʻIkepili: makua TYPE REF TO a1.
 ʻIkepili: keiki TYPE REF TO b1.
 *ʻikepili: c ʻano REF TO c1.
 ************************************************* ************** HĀLĀ I KE KEIKI.
 makua = keiki.  "upcasting CALL METHOD makua->m1( ).
 KANAWAI KAHEA keiki->m1( ).
 KANAWAI KAHEA keiki->m2( ).
 *kahea KANAWAI a->m2( ).  "ʻAʻole hiki iā mākou ke komo i nā ʻano subclass ponoʻī me ka hoʻohana ʻana i ka super class ref.
 HOU-LAINA.
 keiki ?= makua.  " down casting KĀNĀ KANAWAI keiki->m1( ).
 HOU-LAINA.
 KANAWAI KAHEA keiki->m2( ).
 ************************************************* **************** *" hewa null ref *hana i OBJECT a.
 *b ?= a.  "Ke hoʻolei nei i lalo i kona hoʻokuʻu ʻana * kāhea METHOD b->m1( ).
 ************************************************* ***************** * HANA I KA MEA a.
 HOAO.
 b ?= a.  "Ua hoʻāʻo ʻoe e hoʻohana i kahi 'NULL' mea kuhikuhi dump CATCH cx_sy_move_cast_error.
 KANAWAI KALE b->m1( ).
 HOPE.
 ************************************************* ***************** * HANA I KA MEA a.
 HANA I KA MEA b.
 HOAO.
 b ?= a.
 CATCH cx_sy_move_cast_error.
 KANAWAI KALE b->m1( ).
 kahea METHOD b->m2( ).
 HOPE.
 ******** Nā Waiwai Kūʻokoʻa****************** DATA : lv_string TYPE string, lv_string2 TYPE string, lv_string_final TYPE string.
 NĀ ANO: HOOMAKA O 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'.
 E WAHI lv_kuai ma ',' I KA PAPA lt_mea ho'ohana.
 E WAHI lv_string2 MA ',' I KA PAPA lt_user2.
 LOOP MA lt_user2 e hāʻawi ana i ka FIELD-SIMBOL( ).
 HOOLAHA I KA PAPA lt_user.
 ENDLOOP.
 SORT lt_mea hoʻohana MA ka mana.
 E HOʻOPI I KA HOʻOPIʻI ANA MAI lt_user COMPARING auth.
 IF sy-subrc = 0.
 LOOP MA lt_mea hoʻohana e hāʻawi ana i ka FIELD-SIMBOL( ).
 IF lv_string_final IS INITIAL.
 lv_string_final = -auth.
 OE.
 CONCATENATE lv_string_final -auth INTO lv_string_final HOʻAHELE E ','.
 ENDIF.
 ENDLOOP.
 ENDIF.

 

Waiho i ka manaʻo hoʻopuka

Ke hoʻohana nei kēia pūnaewele i ka Akismet e ho'ēmi i ka spam. E aʻo pehea e hanaʻia ai kāuʻikeʻikepili.