Skip to content

Format: Custom

Nuno Godinho edited this page May 20, 2019 · 3 revisions

Although abaK already has several built-in formats, sometimes you may need to deal with constant data in a different format, like an existing legacy table. In order to accomplish that, you can implement new custom FORMAT classes.

Steps to implement a custom format class

  1. Create a new class implementing interface ZIF_ABAK_FORMAT and implement both methods CONVERT() and GET_TYPE().
  2. Use ZCL_ABAK_FACTORY=>GET_CUSTOM_INSTANCE() to get an abaK instance with your new custom format.

1. Build the custom format class

(TODO)

2. Use it

Get a reference to a ZIF_ABAK instance using the factory's method specific for custom objects GET_CUSTOM_INSTANCE(). Check Instantiating abaK to learn more about this:

DATA: o_abak TYPE zif_abak,
      o_format_custom TYPE REF TO zcl_my_custom_abak_format,
      o_source TYPE REF TO zcl_abak_source_inline.

CREATE OBJECT o_source
  EXPORTING
    i_content = '[data goes here]'.

CREATE OBJECT o_format_custom.
o_abak = zcl_abak_factory=>get_custom_instance( io_format  = o_format_custom
                                                io_source = o_source  ).

Why not contribute with your own generic formats?

If you believe your format is generic and can be used by others, please consider contributing by proposing that your custom format is added to the abaK repository.

Clone this wiki locally