zoukankan      html  css  js  c++  java
  • ABAP-Dynamic-Internal table

    data:
          lr_any_t  type ref to data,
          lr_any_s  type ref to data.
        data:
          lr_dref   type ref to data,
          lr_stru   type ref to cl_abap_structdescr,
          lr_table  type ref to cl_abap_tabledescr,
          lr_elem   type ref to cl_abap_elemdescr,
          lt_para   type cl_abap_structdescr=>component_table,
          lt_comp   type cl_abap_structdescr=>component_table.
        field-symbols:
          <fs_tab>  type any,
          <ft_tab>  type standard table.
    
        try.
    
          lr_stru ?= cl_abap_tabledescr=>describe_by_data( it_any ).
    
          loop at lr_stru->components[] into data(ls_comps).
            if ls_comps-type_kind = 'P'
            or ls_comps-type_kind = 'X'.
            else.
              ls_comps-length = ls_comps-length / 2.
            endif.
    
            append initial line to lt_comp assigning field-symbol(<fs_comp>).
            <fs_comp>-name  =   ls_comps-name.
            <fs_comp>-type  ?=  cl_abap_elemdescr=>get_by_kind(
                                p_type_kind = ls_comps-type_kind
                                p_length = ls_comps-length
                                p_decimals = ls_comps-decimals ).
            unassign <fs_comp>.
          endloop.
    
          if lt_comp[] is not initial.
            clear:lr_stru,lr_table.
            lr_stru   =   cl_abap_structdescr=>create( lt_comp ).
            lr_table  =   cl_abap_tabledescr=>create( lr_stru ).
    
            create data lr_any_s type handle lr_stru.
            assign lr_any_s->* to <fs_tab>.
    
            create data lr_any_t type handle lr_table.
            assign lr_any_t->* to <ft_tab>.
          endif.
    
          move-corresponding it_any to <ft_tab>[].
    
          catch cx_root into data(lr_rt).
          data(lv_txt) = lr_rt->get_text( ).
          raise exception type zcx_root
            exporting
              textid = value #(
                         msgid = '00'
                         msgno = '001'
                         attr1 = lv_txt
                         ).
        endtry.
    View Code
  • 相关阅读:
    u3d Mecanim动画
    四元数的共轭和逆
    c++ 单例模式
    GVIM、VIM
    Linux磁盘管理——虚拟文件系统
    Linux磁盘管理——MBR 与 GPT
    Link monitoring
    Linux高级网络设置——将多个网卡设置成一个网卡
    Linux高级网络设置——给网卡绑定多个IP
    DNS原理极限剖析
  • 原文地址:https://www.cnblogs.com/datie/p/14955388.html
Copyright © 2011-2022 走看看