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

    最近老忘备注下,动态内表传参。

     1     data:
     2       lr_any_t  type ref to data,
     3       lr_any_s  type ref to data.
     4     data:
     5       lr_dref   type ref to data,
     6       lr_stru   type ref to cl_abap_structdescr,
     7       lr_table  type ref to cl_abap_tabledescr,
     8       lr_elem   type ref to cl_abap_elemdescr,
     9       lt_para   type cl_abap_structdescr=>component_table,
    10       lt_comp   type cl_abap_structdescr=>component_table.
    11     field-symbols:
    12       <fs_tab>  type any,
    13       <ft_tab>  type standard table.
    14 
    15     try.
    16 
    17       lr_stru ?= cl_abap_tabledescr=>describe_by_data( it_any ).
    18 
    19       loop at lr_stru->components[] into data(ls_comps).
    20         if ls_comps-type_kind = 'P'
    21         or ls_comps-type_kind = 'X'.
    22         else.
    23           ls_comps-length = ls_comps-length / 2.
    24         endif.
    25 
    26         append initial line to lt_comp assigning field-symbol(<fs_comp>).
    27         <fs_comp>-name  =   ls_comps-name.
    28         <fs_comp>-type  ?=  cl_abap_elemdescr=>get_by_kind(
    29                             p_type_kind = ls_comps-type_kind
    30                             p_length = ls_comps-length
    31                             p_decimals = ls_comps-decimals ).
    32         unassign <fs_comp>.
    33       endloop.
    34 
    35       if lt_comp[] is not initial.
    36         clear:lr_stru,lr_table.
    37         lr_stru   =   cl_abap_structdescr=>create( lt_comp ).
    38         lr_table  =   cl_abap_tabledescr=>create( lr_stru ).
    39 
    40         create data lr_any_s type handle lr_stru.
    41         assign lr_any_s->* to <fs_tab>.
    42 
    43         create data lr_any_t type handle lr_table.
    44         assign lr_any_t->* to <ft_tab>.
    45       endif.
    46 
    47       move-corresponding it_any to <ft_tab>[].
    48 
    49       catch cx_root into data(lr_rt).
    50       data(lv_txt) = lr_rt->get_text( ).
    51       raise exception type zcx_root
    52         exporting
    53           textid = value #(
    54                      msgid = '00'
    55                      msgno = '001'
    56                      attr1 = lv_txt
    57                      ).
    58     endtry.
  • 相关阅读:
    Layui的省市区三级联动
    Uncaught SyntaxError: Unexpected token ','
    Cannot use 'in' operator to search for '23' in
    Linux 递归批量删除文件夹或文件的命令
    PHPstorm常用快捷键(Windows)
    Isset、empty、count、is_null的比较
    PHPstorm快捷键的学习
    Elasticsearch索引按月划分以及获取所有索引数据
    Elasticsearch入门
    java自学-流程控制语句
  • 原文地址:https://www.cnblogs.com/ricoo/p/14663565.html
Copyright © 2011-2022 走看看