I_DATA TYPE REF TO DATA
CT_OBJVALUESNUM TYPE TT_BAPI1003_ALLOC_VALUES_NUM
CT_OBJVALUESCHAR TYPE TT_BAPI1003_ALLOC_VALUES_CHAR
CT_OBJVALUESCURR TYPE TT_BAPI1003_ALLOC_VALUES_CURR
NO_DATA_TO_PASS
  method move_ref_data_to_bapi_tables.
    field-symbols: <ms> type any,
                   <any> type any,
                   <any2> type any,
                   <table> type any table,
                   <line> type any,
                   <p> type any,
                   <val> type api_vali,
                   <charact> type bapi1003_charact_r,
                   <char> type bapi1003_alloc_values_char,
                   <curr> type bapi1003_alloc_values_curr,
                   <num>  type  bapi1003_alloc_values_num.
    data: m_p(16) type p.
    data: mo_type type ref to cl_abap_elemdescr.
    data: m_format type cabn-atfor.
    data: m_currency type rctmv-waers.
    data: m_atinn type api_vali-atinn.
    data: m_objectkey type bapi1003_key-object.
    data: m_objecttable type bapi1003_key-objecttable.
    data: m_classnum type bapi1003_key-classnum.
    data: m_classtype type bapi1003_key-classtype.
    data: mt_classcharacteristics type standard table of bapi1003_charact_r.
    data: ms_return type bapiret2.
    if i_data is initial.
      raise no_data_to_pass.
    endif.
    refresh: ct_objvalueschar[], ct_objvaluescurr[], ct_objvaluesnum[].
    assign i_data->* to <ms>.
    if sy-subrc eq 0.
      assign component 'CLASSTYPE' of structure <ms> to <any>.
      if sy-subrc eq 0.
        m_classtype = <any>.
      endif.
      assign component 'CLASS' of structure <ms> to <any>.
      if sy-subrc eq 0.
        m_classnum = <any>.
      endif.
      call function 'BAPI_CLASS_READ'
        exporting
          classtype            = m_classtype
          classnum             = m_classnum
*         LANGUISO             = LANGUISO
*         LANGUINT             = SY-LANGU
          keydate              = sy-datum
         importing
*         CLASSBASICDATA       = CLASSBASICDATA
*         CLASSDOCUMENT        = CLASSDOCUMENT
*         CLASSADDITIONAL      = CLASSADDITIONAL
*         CLASSSTANDARD        = CLASSSTANDARD
          return               = ms_return
        tables
*         classdescriptions    = mt_classdescriptions
*         classlongtexts       = mt_classlongtexts
          classcharacteristics = mt_classcharacteristics
*         classcharactvalues   =   mt_classcharactvalues
        .
      loop at mt_classcharacteristics assigning <charact>.
        "get characteristic ID
        call function 'COC1_FEATURE_CHECK'
          exporting
*           feature_id                  = atinn
            feature_neutral_name        = <charact>-name_char
          importing
            format                      = m_format
            feature_id                  = m_atinn
*           feature_neutral_name        = atnam
*           conversion_exit             = l_atkon
*           number_of_positions         = l_anzst
*           set_get_parameter           = l_atpid
          exceptions
            invalid_class_type          = 1
            missing_feature_information = 2
            no_feature_found            = 3
            no_feature_valid            = 4
            no_language                 = 5
            others                      = 6.
        if sy-subrc <> 0.
*   Error
*    raise characteristic_unknown.
        endif.
        assign component <charact>-name_char of structure <ms> to <table>.
        if sy-subrc eq 0.
          loop at <table> assigning <line>.
            case m_format.
              when 'NUM' or 'DATE' or 'TIME'.
                insert initial line into table ct_objvaluesnum assigning <num>.
                if sy-subrc eq 0.
                  <num>-charact = <charact>-name_char.
                  assign component 'LOW' of structure <line> to <any>.
                  if sy-subrc eq 0.
                    <num>-value_from = zcl_abapblog_com_classific=>convert_char_value(
                                                     i_atnam       = <charact>-name_char
                                                     i_value_new   = <any>
                                                        ).
                  endif.
                  assign component 'HIGH' of structure <line> to <any>.
                  if sy-subrc eq 0.
                    <num>-value_to = zcl_abapblog_com_classific=>convert_char_value(
                                                      i_atnam       = <charact>-name_char
                                                      i_value_new   = <any>
                                                      ).
                  endif.
                  assign component 'UNIT_FROM' of structure <line> to <any>.
                  if sy-subrc eq 0.
                    <num>-unit_from = <any>.
                  endif.
                  assign component 'UNIT_TO' of structure <line> to <any>.
                  if sy-subrc eq 0.
                    <num>-unit_to = <any>.
                  endif.
                  unassign: <any>, <any2>.
                  assign component 'OPTLOW' of structure <line> to <any>.
                  if sy-subrc eq 0.
                    case <any>.
                      when 'EQ'.
                        <num>-value_relation = 1.
                      when 'GE'.
                        assign component 'OPTHIGH' of structure <line> to <any2>.
                        if sy-subrc eq 0.
                          case <any2>.
                            when 'LT'.
                              <num>-value_relation = 2.
                            when 'LE'.
                              <num>-value_relation = 3.
                            when space.
                              <num>-value_relation = 9.
                          endcase.
                        else.
                          <num>-value_relation = 9.
                        endif.
                      when 'GT'.
                        assign component 'OPTHIGH' of structure <line> to <any2>.
                        if sy-subrc eq 0.
                          case <any2>.
                            when 'LT'.
                              <num>-value_relation = 4.
                            when 'LE'.
                              <num>-value_relation = 5.
                            when space.
                              <num>-value_relation = 8.
                          endcase.
                        else.
                          <num>-value_relation = 8.
                        endif.
                      when 'LT'.
                        <num>-value_relation = 6.
                      when 'LE'.
                        <num>-value_relation = 7.
                    endcase.
                  endif.
                endif.
              when 'CURR'.
                insert initial line into table ct_objvaluescurr assigning <curr>.
                if sy-subrc eq 0.
                  <curr>-charact = <charact>-name_char.
                  assign component 'LOW' of structure <line> to <any>.
                  if sy-subrc eq 0.
                    <curr>-value_from = zcl_abapblog_com_classific=>convert_char_value(
                                                                          i_atnam       = <charact>-name_char
                                                                          i_value_new   = <any>
                                                                          ).
                  endif.
                  assign component 'HIGH' of structure <line> to <any>.
                  if sy-subrc eq 0.
                    <curr>-value_to = zcl_abapblog_com_classific=>convert_char_value(
                                                                               i_atnam       = <charact>-name_char
                                                                               i_value_new   = <any>
                                                                               ).
                  endif.
                  assign component 'CURRENCY_FROM' of structure <line> to <any>.
                  if sy-subrc eq 0.
                    <curr>-currency_from = <any>.
                  endif.
                  assign component 'CURRENCY_TO' of structure <line> to <any>.
                  if sy-subrc eq 0.
                    <curr>-currency_to = <any>.
                  endif.
                  unassign: <any>, <any2>.
                  assign component 'OPTLOW' of structure <line> to <any>.
                  if sy-subrc eq 0.
                    case <any>.
                      when 'EQ'.
                        <curr>-value_relation = 1.
                      when 'GE'.
                        assign component 'OPTHIGH' of structure <line> to <any2>.
                        if sy-subrc eq 0.
                          case <any2>.
                            when 'LT'.
                              <curr>-value_relation = 2.
                            when 'LE'.
                              <curr>-value_relation = 3.
                            when space.
                              <curr>-value_relation = 9.
                          endcase.
                        else.
                          <curr>-value_relation = 9.
                        endif.
                      when 'GT'.
                        assign component 'OPTHIGH' of structure <line> to <any2>.
                        if sy-subrc eq 0.
                          case <any2>.
                            when 'LT'.
                              <curr>-value_relation = 4.
                            when 'LE'.
                              <curr>-value_relation = 5.
                            when space.
                              <curr>-value_relation = 8.
                          endcase.
                        else.
                          <curr>-value_relation = 8.
                        endif.
                      when 'LT'.
                        <curr>-value_relation = 6.
                      when 'LE'.
                        <curr>-value_relation = 7.
                    endcase.
                  endif.
                endif.
              when 'CHAR'.
                insert initial line into table ct_objvalueschar assigning <char>.
                if sy-subrc eq 0.
                  <char>-charact = <charact>-name_char.
                  assign component 'LOW' of structure <line> to <any>.
                  if sy-subrc eq 0.
                    <char>-value_char = <any>.
                    <char>-value_neutral = <any>.
                  endif.
                endif.
            endcase.
          endloop.
        endif.
      endloop.
    endif.
  endmethod.                    "move_ref_data_to_bapi_tables



