DATA
: container TYPE REF TO cl_gui_custom_container
, docking TYPE REF TO cl_gui_docking_container
, splitter TYPE REF TO cl_gui_splitter_container
, splitter1 TYPE REF TO cl_gui_splitter_container.
DATA: ls_stable TYPE lvc_s_stbl.
ls_stable-row = 'X'.
ls_stable-col = 'X'.
IF docking IS INITIAL .
CREATE OBJECT docking
EXPORTING
repid = sy-repid
dynnr = sy-dynnr
side = docking->dock_at_bottom
extension = 1000.
IF sy-subrc = 0.
IF splitter IS INITIAL .
CREATE OBJECT splitter
EXPORTING
link_dynnr = sy-dynnr
link_repid = sy-repid
height = 50
align = 15
parent = docking
rows = 2
columns = 1.
splitter->set_row_height( EXPORTING id = 1 height = 100 ).
ENDIF.
IF sy-subrc = 0.
IF splitter1 IS INITIAL.
CREATE OBJECT splitter1
EXPORTING
link_dynnr = sy-dynnr
link_repid = sy-repid
height = 50
align = 15
parent = splitter->get_container( row = 2 column = 1 )
rows = 1
columns = 2.
ENDIF.
ENDIF.
ENDIF.
CREATE OBJECT gc_grida
EXPORTING
i_parent = splitter->get_container( row = 1 column = 1 ).
CALL METHOD gc_grida->refresh_table_display
EXPORTING
is_stable = ls_stable
i_soft_refresh = 'X'.
oo alv获取选择列
DATA : rs_selfield TYPE slis_selfield,
lt_row TYPE lvc_t_row,
lt_roid TYPE lvc_t_roid,
ls_roid TYPE lvc_s_roid,
ls_row TYPE lvc_s_row
.
rs_selfield-col_stable = 'X'.
rs_selfield-row_stable = 'X'.
rs_selfield-refresh = 'X'.
ls_stable-row = 'X'.
ls_stable-col = 'X'.
CALL METHOD gc_grida->get_selected_rows
IMPORTING
et_index_rows = lt_row
et_row_no = lt_roid.
LOOP AT lt_roid INTO ls_roid .
LOOP AT gt_out ASSIGNING FIELD-SYMBOL(<fs_out>) .
IF sy-tabix = ls_roid-row_id.
<fs_out>-sel = 'X'.
ENDIF.
ENDLOOP.
ENDLOOP.
abap:结构转为内表的方法
1.类调用
DATA:BEGIN OF ty_output,
z_no TYPE ztrfico008-z_no, "流水号
z_item TYPE ztrfico008-z_item, "行目号
bukrs TYPE ztrfico008-bukrs, "公司代码
gjahr TYPE ztrfico008-gjahr, "财年
monat TYPE ztrfico008-monat, "会计期间
bktxt TYPE ztrfico008-bktxt, "凭证抬头文本
drcrk TYPE ztrfico008-drcrk, "借方/贷方标识
racct TYPE ztrfico008-racct, "科目号
rassc TYPE ztrfico008-rassc, "贸易伙伴的公司标识
rhcur TYPE ztrfico008-rhcur, "公司代码货币
tsl TYPE ztrfico008-tsl, " 金额(余额交易货币)
kurst TYPE tcurr-kurst, "汇率类型
ukurs TYPE ukurs_curr , "汇率
msl TYPE z_hbje, "合并金额
prctr TYPE ztrfico008-prctr, "利润中心
rfarea TYPE ztrfico008-rfarea, "功能范围
sgtxt TYPE ztrfico008-sgtxt, "项目文本
bldat TYPE ztrfico008-bldat, "日期
usnam TYPE ztrfico008-usnam, "用户名
END OF ty_output.
r_tabdescr ?= cl_abap_structdescr=>describe_by_data( ty_output ).
CALL METHOD cl_salv_data_descr=>read_structdescr
EXPORTING
r_structdescr = r_tabdescr
RECEIVING
t_dfies = t_dfies.
LOOP AT t_dfies INTO wa_field.
CLEAR gs_fieldcat.
MOVE-CORRESPONDING wa_field TO gs_fieldcat.
gs_fieldcat-coltext = gs_fieldcat-scrtext_m.
IF gs_fieldcat-inttype = 'P'.
gs_fieldcat-intlen = 23.
ENDIF.
CLEAR gs_fieldcat-convexit."若alv列 不能正常筛选数据时,将此列清空
APPEND gs_fieldcat TO gt_fieldcat.
ENDLOOP.
2.使用函数
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'xxxx'
CHANGING
ct_fieldcat = xxxx.