最近开发在执海关合同维护系统时,对进口料件的汇总,由于栏位显示与出口成品的品种多少相关,所以显示的栏位是不确定的,为此研究了一番。

同样,在报关时,不管是对出口成品还是进口料件报关,栏位显示都与出口成品品种或进口料件品种相关。在同一行上显示所有的出口成品或进口料件,对于操作人员来说都是一件易操作的表现。

程序设计要注意事项:

第一、   每一张合同中出口成品品种数量的多少确定;

第二、   每一种或每类出口成品共同属性是否具有相同性,比如在进口料件汇总表中对于每一类出口成品都有单耗、损耗,数量,耗边料数特性。

第三、   进口料件汇总表固定列位确定。

第四、   动态创建内表区域。

动态创建报关数量登记表:

perform container_free_2.
 perform create_structure_1 USING len '进口料件'.
 perform create_table_display_2.
 perform ctable_for_atci.

form container_free_2.
   if not g_custom_container_2 is initial .
     call method  g_custom_container_2->free.
     clear g_custom_container_2.
   endif.
endform.

form create_structure_1 USING II mtart.  "报关出口成品相关处理

DATA : ERTXT TYPE string,
         ERTTX TYPE string,
         ERNUM TYPE string,
         ERIND TYPE I.

clear it_structure[].

wa_structure-fieldname = 'BGDHA'.  第一列列名      报关单号
  wa_structure-col_pos   = 1.       表示第一列
  wa_structure-inttype = 'C'.       数据类型
  wa_structure-intlen = 18.          长度
  wa_structure-decimals = 0 .
  wa_structure-ref_table = '' .
  wa_structure-ref_field = '' .
  wa_structure-coltext = '报关单号' .
  wa_structure-seltext = '报关单号' .
  wa_structure-just = 'C' .
  wa_structure-edit = 'X' .
  wa_structure-outputlen = 18 .
  wa_structure-fix_column = 'X' .
  APPEND wa_structure TO it_structure.

wa_structure-fieldname = 'BUDAT'.             "报关日期
  wa_structure-col_pos   = 2.
  wa_structure-inttype = 'D'.
  wa_structure-intlen = 18.
  wa_structure-decimals = 0 .
  wa_structure-ref_table = 'ZSD19ATCI' .
  wa_structure-ref_field = 'BUDAT' .
  wa_structure-coltext = '日期' .
  wa_structure-seltext = '日期' .
  wa_structure-just = 'C' .
  wa_structure-edit = 'X' .
  wa_structure-outputlen = 12 .
  wa_structure-fix_column = 'X' .
  APPEND wa_structure TO it_structure.

erind = 2 .
  DO II TIMES.
    ernum = ernum + 1 .
    erind = erind + 1.
    CONCATENATE 'ERFMG' ernum into ERTXT.
    CONCATENATE mtart ernum into ERTTX.
    CONDENSE ERTXT NO-GAPS.
    CONDENSE ERTTX NO-GAPS.
    wa_structure-fieldname = ERTXT.             "报关数量,对应每一个出口成品
    wa_structure-col_pos   = erind.
    wa_structure-inttype = 'P'.
    wa_structure-intlen = 13.
    wa_structure-decimals = 3 .
    wa_structure-ref_table = 'ZSD19ATCI' .
    wa_structure-ref_field = 'ERFMG' .
    wa_structure-coltext = ERTTX .
    wa_structure-seltext = ERTTX .
    wa_structure-just = 'R' .
    wa_structure-edit = 'X' .
*    wa_structure-do_sum = 'X'.
    wa_structure-outputlen = 13 .
    wa_structure-fix_column = '' .
    APPEND wa_structure TO it_structure.
  ENDDO.
endform.

form create_table_display_2.
  create object g_custom_container_2
         exporting container_name = g_container_2.
  create object g_grid
         exporting i_parent = g_custom_container_2.
endform.

form ctable_for_atci.
   data: gs_layout type lvc_s_layo.

data: lt_exclude type ui_functions.
   data: retxt type string,
         renum type string.

clear gt_fieldcat[] .
   clear it_fieldcat[].

perform exclude_tb_functions changing lt_exclude.
   perform cfield_atci using '' changing gt_fieldcat it_fieldcat.
   perform f4_alv_field.

assign new_table->* to <l_table>.
   create data new_line like line of <l_table>.
   assign new_line->* to <l_line>.
   clear <l_table>[].
   create data old_table like <l_table>.
   assign old_table->* to <old_table>.

*   <l_table>[] = t_sunh[] .

loop at r_atci.

ASSIGN COMPONENT 'BGDHA' OF STRUCTURE <l_line> TO <l_field>.
      <l_field> = r_atci-bgdha.

ASSIGN COMPONENT 'BUDAT' OF STRUCTURE <l_line> TO <l_field>.
      <l_field> = r_atci-budat.

loop at t_atci where hname = r_atci-hname and bgdha = r_atci-bgdha and budat = r_atci-budat.
          clear s_atci.
          read table s_atci with key hname = t_atci-hname extwg = t_atci-extwg.
          renum = sy-tabix.
          concatenate 'ERFMG' renum into retxt.

ASSIGN COMPONENT retxt OF STRUCTURE <l_line> TO <l_field>.
          <l_field> = t_atci-erfmg.
      endloop.
      INSERT <l_line> INTO TABLE <l_table>.
   endloop.

set handler z_receiver->handle_before_user_command for g_grid.
   set handler z_event_double->handle_onf4 for g_grid.

call method g_grid->register_edit_event
           exporting
               i_event_id = cl_gui_alv_grid=>mc_evt_enter.

call method g_grid->register_f4_for_fields
      exporting
        it_f4 = lt_f4.

call method g_grid->set_table_for_first_display
      exporting
       is_layout            = gs_layout
       it_toolbar_excluding = lt_exclude
       i_save                        = 'A'
*       i_buffer_active               = 'X'
      changing
*      IT_SORT          = GB_SORTFLD
       it_outtab            = <l_table>[]
       it_fieldcatalog      = gt_fieldcat[]
       it_sort              = gt_sort .

call method g_grid->set_ready_for_input "处于非编辑状态
          exporting
            i_ready_for_input = 1.
     call method cl_gui_control=>set_focus    "设置焦点在go_grid 上
         exporting
           control = g_grid .
          <old_table>[] = <l_table>[].

CALL METHOD cl_gui_cfw=>flush
    EXCEPTIONS
      cntl_system_error = 1
      cntl_error        = 2.

endform.         "ctable_for_atci

 

form cfield_atci using dab changing pt_fieldcat type lvc_t_fcat ft_fieldcat type lvc_t_fcat.

data : stnum type i.

clear lf_fieldcat[].

loop at it_structure into wa_structure.
 “宏
   m_fieldcat wa_structure-fieldname wa_structure-ref_table  wa_structure-ref_field wa_structure-coltext wa_structure-just wa_structure-edit wa_structure-outputlen wa_structure-fix_column.

endloop.

loop at lf_fieldcat.
   if lf_fieldcat-fieldname = 'BGDHA' OR lf_fieldcat-fieldname = 'BUDAT' . "设置关键字段
       lf_fieldcat-key = 'X' .
       lf_fieldcat-F4AVAILABL = 'X'.
       modify lf_fieldcat index sy-tabix.
   endif.
   if lf_fieldcat-ref_field = 'ERFMG'.
       lf_fieldcat-do_sum = 'X' .           "汇总求和
       lf_fieldcat-no_zero = 'X' .          "隐藏零
       modify lf_fieldcat index sy-tabix.
   endif.
   if lf_fieldcat-fieldname = 'ERFMO'.
        lf_fieldcat-coltext = dab.
        lf_fieldcat-emphasize = 'C601' .     "红色
       modify lf_fieldcat index sy-tabix.
   endif.
   if lf_fieldcat-fieldname = 'ZJLYL'.
        lf_fieldcat-emphasize = 'C601' .     "红色
       modify lf_fieldcat index sy-tabix.
   endif.
   if lf_fieldcat-fieldname+0(4) = 'FLAG'.
        lf_fieldcat-emphasize = 'C61' .     "深红色
       modify lf_fieldcat index sy-tabix.
   endif.
 endloop.

append lines of lf_fieldcat to pt_fieldcat.

clear lf_fieldcat[].
 loop at it_structure into wa_structure.
   st_fieldcat wa_structure-fieldname wa_structure-col_pos wa_structure-inttype wa_structure-intlen  wa_structure-decimals.
 endloop.

append lines of lf_fieldcat to ft_fieldcat .

clear new_table .
 call method cl_alv_table_create=>create_dynamic_table
      exporting
        it_fieldcatalog = it_fieldcat
      importing
        ep_table        = new_table.
endform.                  "cfield_atci

转自:http://blog.chinaunix.net/u1/50618/showart_1915346.html

使用动态内表——ALV输出相关推荐

  1. 一个简单的动态内表alv案例

    动态内表的问题一直没搞明白,每次都要复制粘贴. 动态内表的创建和使用主要有以下几点: 1.动态内表的创建,首先要定义动态结构,然后再根据定义的动态结构利用系统一个标准的method:"cl_ ...

  2. ABAP中创建动态内表的三种方法(转载)

    BAP中创建动态内表的三种方法 第一种: 如果我们需要的动态内表字段或者动态工作区和数据字典中的类型一致,可以直接使用CREATE DATA生成,当然也可以是自定义类型. 比如要产生和数据表MARA结 ...

  3. 动态内表 动态ALV显示

    动态内表及动态ALV显示 最近写了一个forecast,要求按用户输入的日期分周或月显示,我把它贴出来,给有需要的人参考一下 *&------------------------------- ...

  4. 动态SQL查询,动态内表

    1.动态sql语句查询 简单来说,查询的字段,查询的表格,还有where条件都是变量.可以作为选择屏幕或者接口数据输入,最后得出输入条件的数据.具有通用性. 其中,动态查询的关键在于:sql语句查询结 ...

  5. 关于动态内表的逆向考勤程序

    基于逆向考勤的动态程序,BP表是人员表,DB表是结果信息表 根据年月生成实际表格,ALV展示 *&----------------------------------------------- ...

  6. FIELD-SYMBOLS 动态内表

    相关类 CL_ALV_TABLE_CREATE 动态内表构建步骤 (1)获得主数据:获取将要展示的数据 (2)构建fieldcat :根据选择屏幕来动态的构建fieldcat (3)根据fieldca ...

  7. SAP ABAP 动态内表的条件查询(SORT / READ TABLE / LOOP)

    SAP ABAP 动态内表的条件查询(SORT / READ TABLE / LOOP) 简介: 动态内表是动态报表的核心,动态内表的条件操作能有效解决性能问题.这篇文章用于普及动态内表在 SORT ...

  8. 动态内表的俩栗子_SAP刘梦_新浪博客

    货铺QQ群号:834508274 微信群不能扫码进了,可以加我微信SAPliumeng拉进群,申请时请提供您哪个模块顾问,否则是一律不通过的. 进群统一修改群名片,例如BJ_ABAP_森林木.群内禁止 ...

  9. SAP FPM通过ABAP读取EXCEL值到动态内表并把数据发送到其他组件

    文章目录 需求 一.效果 二.实现 1.部分代码 2.其中相关的内容可查看系列文章获悉 总结 需求 在网页应用中(FPM.FBI.WDA)通过ABAP读取EXCEL值到动态内表并把数据发送到其他组件 ...

最新文章

  1. ZooKeeper与Eureka对比
  2. jmeter+mysql+set_Jmeter中如何进行对数据库压测(上)
  3. 【知识星球】千奇百怪的网络结构板块更新到哪里了?
  4. MySQL分片 --转自Peter Zaitsev对MySQL分片的建议
  5. 如何从XMLHttpRequest创建自定义获取API
  6. 百度地图demo基础组件演示
  7. 《Hadoop与大数据挖掘》——2.6 TF-IDF算法原理及Hadoop MapReduce实现
  8. Web上的支持的图片格式以及它们之间的区别
  9. Windows 下的坐标系
  10. 2017 Multi-University Training Contest - Team 4 hdu6071 Lazy Running
  11. 各种语言的模块导入导出形式
  12. hadoop学习笔记(五):java api 操作hdfs
  13. 21天学通C语言-学习笔记(2)
  14. c语言令牌桶原理,令牌桶算法及实现(二)
  15. 复制html代码怎么粘贴快捷键,电脑复制粘贴快捷键,教您电脑怎么用键盘复制粘贴...
  16. 权重初始化方法及适用情况
  17. Python Selenium3.141+Win7(64位)+IEDriverServer(32位版本)+调用IE11卡死的解决
  18. 中庸----做人的智慧
  19. 压缩比13为什么建议用92的油_马自达为啥能在13:1高压缩比下仍然使用92汽油
  20. 【沃顿商学院学习笔记】商业基础——Operation Management:02运营管理活动中的详细流程分析

热门文章

  1. 当交易所开始“革命”,整个行业将“为之一颤”
  2. webAPP优化方案总结
  3. 小白初学搭建 配置本地yum
  4. BEA-141281 unable to get file lock, will retry ...
  5. 给写新疆开放互联网一周纪念
  6. 新建了一个英文Blog
  7. RAID技术详细解答之一:入门基础篇
  8. 怎么样做一个漂亮女人
  9. node 实现Token状态登录 及数据库增删改查
  10. MySQL 配置文件优化