CLASS lcl_t100_new_fields DEFINITION.

  PUBLIC SECTION.

    INTERFACES: if_salv_ida_calc_field_handler.

  PRIVATE SECTION.

    TYPES:

      BEGIN OF ty_t100_new_fields,

        count_ph   TYPE i,

        ucase_text TYPE t100-text,

      END   OF ty_t100_new_fields.

ENDCLASS.

 

 

CLASS lcl_t100_new_fields IMPLEMENTATION.

  METHOD if_salv_ida_calc_field_handler~get_calc_field_structure.

    "RTTS

    ro_calc_field_structure ?=

      cl_abap_typedescr=>describe_by_name( 'TY_T100_NEW_FIELDS' ).

  ENDMETHOD.

*

  METHOD if_salv_ida_calc_field_handler~get_requested_fields.

    "define the source fields used for calculation of this new fields

    DATA lv_field_name TYPE fieldname.

 

    READ TABLE its_calc_field_name

      TRANSPORTING NO FIELDS WITH KEY TABLE_LINE = 'UCASE_TEXT'.

    IF sy-subrc EQ 0.

      lv_field_name = 'TEXT'.

      INSERT lv_field_name INTO TABLE rts_db_field_name.

    ENDIF.

  ENDMETHOD.

*

  METHOD if_salv_ida_calc_field_handler~calculate_line.

*

    DATA: ls_t100_new_fields TYPE ty_t100_new_fields.

    DATA: ls_t100            TYPE t100.

 

* Transfer from "flat" to structured

    ls_t100 = is_data_base_line.

 

* new field

    ls_t100_new_fields-ucase_text = TO_UPPER( ls_t100-text ).

    FIND ALL OCCURRENCES OF '&'

      IN ls_t100-text

      MATCH COUNT ls_t100_new_fields-count_ph.

 

* Send it back

    es_calculated_fields = ls_t100_new_fields.

 

  ENDMETHOD.

 

  METHOD if_salv_ida_calc_field_handler~start_page.

*   get access to the data for the given page

 

  ENDMETHOD.

  METHOD if_salv_ida_calc_field_handler~end_page.

*   Use for cleanup purpose

  ENDMETHOD.

ENDCLASS.


Serkan AKKAVAK

Computer Engineer BSc

SAP Department Deputy Manager

Contact : serkurumsal@yandex.com