Skip to Content

FUNCTION z_bapi_fill_x.

*”———————————————————————-

*”*”Interface local:

*”  TABLES

*”      I_TABLE TYPE  TABLE

*”      E_TABLEX TYPE  TABLE

*”———————————————————————-

  DATA table_descr TYPE REF TO cl_abap_tabledescr.

  DATA struct_descr TYPE REF TO cl_abap_structdescr.

  DATA columns TYPE abap_compdescr_tab.

  FIELD-SYMBOLS <column> LIKE LINE OF columns.

  FIELD-SYMBOLS <fs_var>.

  FIELD-SYMBOLS <fs_varx>.

  DATA l_aux TYPE string.

  table_descr ?= cl_abap_typedescr=>describe_by_data( e_tablex[] ).

  struct_descr ?= table_descr->get_table_line_type( ).

  columns = struct_descr->components.

  LOOP AT i_table.

    LOOP AT columns ASSIGNING <column>.

      CONCATENATE ‘E_TABLEX’ ‘-‘ <column>-name INTO l_aux.

      ASSIGN (l_aux) TO <fs_varx>.

      CONCATENATE ‘I_TABLE’ ‘-‘ <column>-name INTO l_aux.

      ASSIGN (l_aux) TO <fs_var>.

      <fs_varx> = <fs_var>.

      IF <column>-name NE ‘CHANGE_ID’.

        IF <column>-type_kind NE ‘N’.

          IF <fs_varx> IS NOT INITIAL AND <fs_varx> NE ‘0’ AND <fs_varx> NE ‘0.00’.

            <fs_varx> = ‘X’.

          ENDIF.

        ENDIF.

      ENDIF.

      UNASSIGN: <fs_varx>, <fs_var>.

    ENDLOOP.

  ENDLOOP.

  UNASSIGN <column>.

ENDFUNCTION.

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply