码迷,mamicode.com
首页 > 其他好文 > 详细

ABAP创建动态内表

时间:2021-06-28 19:30:21      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:部分   initial   method   abap   repo   fine   create   fnr   end   

 

*&---------------------------------------------------------------------*
*& Report YCX_DYNAMIC_TABLE
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ycx_dynamic_table.

DATA:gt_dyn_table TYPE REF TO data,
     gs_dyn_line  TYPE REF TO data.
FIELD-SYMBOLS:<fs_dyn_table> TYPE STANDARD TABLE,
              <fs_dyn_wa>,
              <fs_dyn_field>.

DATA:lv_copos TYPE i.
DATA:ct_fieldcate TYPE lvc_t_fcat.
FIELD-SYMBOLS:<fs_fieldcate> TYPE lvc_s_fcat.

DEFINE make_col.
  APPEND INITIAL LINE TO ct_fieldcate ASSIGNING <fs_fieldcate>.
  lv_copos = lv_copos + 1.
  <fs_fieldcate>-col_pos   = lv_copos.
  <fs_fieldcate>-inttype   = &1.
  <fs_fieldcate>-intlen    = &2.
  <fs_fieldcate>-decimals  = &3.
  <fs_fieldcate>-fieldname = &4.
  <fs_fieldcate>-outputlen = &2.
  <fs_fieldcate>-scrtext_m = &5.
  <fs_fieldcate>-no_zero   = &6.
  <fs_fieldcate>-emphasize = &7."带颜色高亮
END-OF-DEFINITION.

*主数据部分
make_col I 10 0 NO 序号 X ‘‘.
make_col C 40 0 MATNR_MI 小米物料号 X ‘‘.
make_col C 40 0 MATNR 工厂物料号 X ‘‘.
make_col C 40 0 MAKTX 物料描述 X ‘‘.
make_col C 40 0 ZZLIFNR 生产厂商 X ‘‘.
make_col C 40 0 ZZNAME 品名 X ‘‘.
make_col C 40 0 ZZUNAME 采购 X ‘‘.
make_col C 1 0 MAABC A/B/C类 X ‘‘.
make_col C 1 0 ZZMTYPE 物料属性 X ‘‘.
make_col C 30 0 ZZSTAGE 工段 X ‘‘.
make_col C 16 0 PROJECT 项目 X ‘‘.
make_col C 1333 0 ZZWHERE 用于哪 X ‘‘.
make_col C 10 0 TDLX 替代类型 X ‘‘.
make_col C 10 0 TDLSY 替代料是否认证使用 X ‘‘.
make_col N 10 0 NUM 号码 X ‘‘.
make_col N 2 0 ALPRF 替代组 X ‘‘.
make_col C 2 0 ALPGR 替代小组 X ‘‘.

*计划中的主键部分
*LOOP AT gt_013 INTO DATA(ls_013).
*  make_col ‘C‘ ‘18‘ ‘0‘ ls_013-matnr ls_013-matnr ‘X‘ ‘‘.
*ENDLOOP.

SORT ct_fieldcate BY col_pos.

CALL METHOD cl_alv_table_create=>create_dynamic_table
  EXPORTING
    it_fieldcatalog = ct_fieldcate
  IMPORTING
    ep_table        = gt_dyn_table.

ASSIGN  gt_dyn_table->* TO <fs_dyn_table>.

IF SY-SUBRC EQ 0.

ENDIF.

 

ABAP创建动态内表

标签:部分   initial   method   abap   repo   fine   create   fnr   end   

原文地址:https://www.cnblogs.com/rainysblog/p/14939848.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!