cancel
Showing results for 
Search instead for 
Did you mean: 

动态内表数据处理

Former Member
0 Kudos

想对动态内表里的数据进行分组汇总. 现有两个动态内表如下:

动态内表1的结构<DYN_TABLE>是:

VBELN KUNNR NAME1 MATNR 动态列1 u2026动态列N

动态内表2的结构<DYN_TABLE2>是:

NAME1 动态列1u2026动态列N

问题一: 如何把<DYN_TABLE>自动查找对应的字段数据赋给<DYN_TABLE2>?

MOVE-CORRESPONDING <dyn_table> to <dyn_table2>. 是通不过的

问题二:内表<DYN_TABLE2>的Field Catalog如何获取到<DYN_TABLE1>的动态列1u2026动态N的Field Catalog?

谢谢!

Accepted Solutions (1)

Accepted Solutions (1)

yang_aiolos
Active Participant
0 Kudos

REPORT  ZTEST_AIOLOS_003.
types:
  begin of t_dyn_table1,
    c1 type c,
    c2 type c,
  end of t_dyn_table1,

  begin of t_dyn_table2,
    c2 type c,
  end of t_dyn_table2.
data: dy_table1 type ref to data,
      dy_table2 type ref to data,
      ln_dy_table1 type ref to data,
      ln_dy_table2 type ref to data.
field-symbols: <fs1> type standard table,  <fs2> type standard table,
               <fs_line1> type any,<fs_line2> type any,
               <fs_comp1> type any,
               <fs_comp2> type any.

create data dy_table1 type table of t_dyn_table1.

create data dy_table2 type table of t_dyn_table2.


assign dy_table1->* to <fs1>.
create data ln_dy_table1 like line of <fs1>.
assign dy_table2->* to <fs2>.
create data ln_dy_table2 like line of <fs2>.

assign ln_dy_table1->* to <fs_line1>.
assign ln_dy_table2->* to <fs_line2>.
* u8FD9u662Fu4E00u6BB5u8D4Bu503Cu7528u7684u7A0Bu5E8FuFF0Cu5982u679Cu4F60u7684u52A8u6001u8868u5DF2u7ECFu6709u6570u636Eu7684u8BDDuFF0Cu5C31u4E0Du7528u8FD9u4E00u6BB5u4E86
do 3 times.
    assign component 'C1' of structure <fs_line1> to <fs_comp1>.
    <fs_comp1> = sy-index.
    assign component 'C2' of structure <fs_line1> to <fs_comp2>.
    <fs_comp2> = sy-index * 2.
    append <fs_line1> to <fs1>.

    clear: <fs_comp1>,
           <fs_comp2>,
           <fs_line1>.
enddo.

loop at <fs1> into <fs_line1>.
  move-corresponding <fs_line1> to <fs_line2>.
  append <fs_line2> to <fs2>.
endloop.

希望对你哟帮助

Former Member
0 Kudos

OK. Thanks.

Answers (1)

Answers (1)

WilliamGao
Participant
0 Kudos

RTTS 是做动态编程的技术,但它是不会取到Field Catalog的,能查到参考类型。

我在研究函数REUSE_ALV_GRID_DISPLAY,响应小记代码事件的时候跟踪到,ALV小计功能已经实现了动态内表分组汇总的功能。以下是调用的堆栈。


9	SAPLSKBH				FUNCTION	ALV_SUBTOTALS_GET
8	SAPLSLVC				FUNCTION	LVC_TOTALS_GET
7	CL_GUI_ALV_GRID===============CP	METHOD		SOFT_REFRESH_TABLE_DISPLAY
6	CL_GUI_ALV_GRID===============CP	METHOD		SET_FUNCTION_CODE
5	SAPLSLVC_FULLSCREEN			FORM		PAI
4	SAPLSLVC_FULLSCREEN			MODULE (PAI)	PAI
3	SAPLSLVC_FULLSCREEN			FUNCTION	REUSE_ALV_GRID_DISPLAY
2	Z_GVV_ALV_TEST_2			FORM		SUB_ALV_REPORT_DISPLAY
1	Z_GVV_ALV_TEST_2			EVENT		END-OF-SELECTION

FUNCTION - LVC_TOTALS_GET 的参数较为简单,你可以试一试。