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_tcod,
- caracter type c length 1,
- cod type c length 4,
- end of zty_tcod,
- begin of zty_cod,
- cod type c length 4,
- end of zty_cod,
- begin of zty_char,
- cod type c length 1,
- end of zty_char.
- class-data: ztty_cod type table of zty_tcod.
- class-data: zsty_cod type zty_tcod.
- class-methods append_tdecoding
- importing
- im_cod type string.
- class-methods mcoding
- changing
- cg_string type string .
- private section.
- endclass.
- class zrun_decoding implementation.
- method append_tdecoding.
- data: lt_cod type table of zty_cod,
- lv_return type string,
- lv_count type i.
- split im_cod at space into table lt_cod.
- lv_count = 0.
- loop at lt_cod assigning field-symbol(<fs_txt>).
- clear:zsty_cod.
- zsty_cod-caracter = sy-abcde+lv_count(1).
- zsty_cod-cod = <fs_txt>.
- append zsty_cod to ztty_cod.
- lv_count = lv_count + 1.
- endloop.
- endmethod.
- method mcoding.
- data lv_return type string.
- data lv_count type i.
- data(lv_strlen) = strlen( cg_string ).
- lv_count = 0.
- do.
- if lv_count = lv_strlen.
- exit.
- endif.
- read table ztty_cod with key caracter = cg_string+lv_count(1) into zsty_cod.
- if sy-subrc = 0.
- lv_return = lv_return && zsty_cod-cod.
- endif.
- lv_count = lv_count + 1.
- enddo.
- cg_string = lv_return.
- endmethod.
- endclass.
- data: zcl_run type ref to zrun_decoding.
- parameters: p_text type string.
- start-of-selection.
- data: lv_txt type string.
- lv_txt = p_text.
- zcl_run = new zrun_decoding( ).
- zcl_run->append_tdecoding( '.- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- .-. ... - ..- ...- .-- -..- -.-- --..' ).
- zcl_run->mcoding( changing cg_string = lv_txt ).
- write lv_txt.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement