简体   繁体   English

ABAP在Alv中动态显示字段符号

[英]ABAP Display field symbol dynamic in alv

I am pasting this program for example but i will never know the type of the table (here vbap and vbak). 例如,我正在粘贴此程序,但我永远都不知道表的类型(此处为vbap和vbak)。

My goals is to display my field symbol without knowing the types. 我的目标是在不知道类型的情况下显示字段符号。

Is it possible ? 可能吗 ?

Here is my code : 这是我的代码:

REPORT  ZTEST_FME_FOL.
type-pools slis .
FIELD-SYMBOLS : <mytable> TYPE ANY TABLE.

DATA :  lv_alv_table  TYPE REF TO cl_salv_table,
  lv_funct TYPE REF TO cl_salv_functions,
  lv_columns TYPE REF TO cl_salv_columns_table,
  lv_column TYPE REF TO CL_SALV_COLUMN_table.

 SELECT * from vbap INNER JOIN VBAK ON vbap~vbeln = vbak~vbeln UP TO 10 ROWS INTO TABLE <mytable>.


TRY.
 cl_salv_table=>factory(
IMPORTING
  r_salv_table = lv_alv_table
CHANGING
  t_table      = <mytable> ).
CATCH cx_salv_msg .
 ENDTRY.
  lv_funct = lv_alv_table->get_functions( ).
 lv_funct->set_all( Abap_True ).
 lv_columns = lv_alv_table->get_columns( ).
 lv_alv_table->display( ).

Thanks in advance ! 提前致谢 !

Depending on what you 're trying to do there's going to be more validation required than what I've done, but in essence this is what you need. 根据您要执行的操作,将需要比我已经完成的验证更多的验证,但是从本质上讲,这就是您所需要的。 Using (dynamic) joins may be particularly tricky. 使用(动态)联接可能特别棘手。

report zevw_test_dynamic_alv.

parameters: p_table type string obligatory.

field-symbols: <gt_table> type standard table.

data: gt_data type ref to data.


start-of-selection.

  create data gt_data type table of (p_table).

  assign gt_data->* to <gt_table>.

  select * from (p_table) up to 10 rows
    into table <gt_table>.

  perform display_results using <gt_table>.  "Your ALV stuff will be in here 

You may even have to build the fieldcat manually and then use 您甚至可能必须手动构建fieldcat,然后使用

call method cl_alv_table_create=>create_dynamic_table
  exporting
    it_fieldcatalog = gt_fieldcat[]
  importing
    ep_table        = gt_data.

to get the data reference 获取数据参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM