Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- report zdev_test.
- class zrun_decoding definition.
- public section.
- types: begin of zty_cod,
- caracter type c length 1,
- cod type c length 4,
- end of zty_cod,
- begin of zty_txt,
- cod type c length 4,
- end of zty_txt.
- class-data: ztty_cod type table of zty_cod.
- class-data: zsty_cod type zty_cod.
- class-methods append_tdecoding
- importing
- im_caracter type char1
- im_cod type char4.
- class-methods mdecoding
- changing
- cg_string type string .
- private section.
- endclass.
- class zrun_decoding implementation.
- method append_tdecoding.
- clear:zsty_cod.
- zsty_cod-caracter = im_caracter.
- zsty_cod-cod = im_cod.
- append zsty_cod to ztty_cod.
- endmethod.
- method mdecoding.
- data: lt_txt type table of zty_txt,
- lv_return type string.
- split cg_string at space into table lt_txt.
- loop at lt_txt assigning field-symbol(<fs_txt>).
- read table ztty_cod with key cod = <fs_txt>-cod into zsty_cod.
- if sy-subrc = 0.
- lv_return = lv_return && zsty_cod-caracter.
- endif.
- endloop.
- cg_string = lv_return.
- endmethod.
- endclass.
- data: zcl_run type ref to zrun_decoding.
- start-of-selection.
- data: lv_text type string.
- "Test case1
- lv_text = '.- -... -.-. -.. .'.
- zcl_run = new zrun_decoding( ).
- zcl_run->append_tdecoding( exporting im_caracter = 'A' im_cod = '.-' ).
- zcl_run->append_tdecoding( exporting im_caracter = 'B' im_cod = '-...' ).
- zcl_run->append_tdecoding( exporting im_caracter = 'C' im_cod = '-.-.' ).
- zcl_run->append_tdecoding( exporting im_caracter = 'D' im_cod = '-..' ).
- zcl_run->append_tdecoding( exporting im_caracter = 'E' im_cod = '.' ).
- zcl_run->mdecoding( changing cg_string = lv_text ).
- write lv_text.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement