ALV+EXCEL BDS

 *&---------------------------------------------------------------------* *& Report ZALV_EXCEL_SHOWALLA *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT zalv_excel_showalla. *----------------------------------------------------------------------* * INCLUDE BC_ALVHIERTOP * *----------------------------------------------------------------------* INCLUDE cnt4defs. INCLUDE <list>. INCLUDE <ctldef>. TYPE-POOLS : abap, sbdst. DATA structure TYPE fieldname VALUE 'ZPOWER'. "是ALV FIELDCAT问题的关键 DATA it_sorttab TYPE lvc_t_sort. DATA it_fieldcat TYPE lvc_t_fcat. DATA it_fcat2 TYPE lvc_t_fcat. DATA cnthier1 TYPE int4. DATA cnthier2 TYPE int4. DATA wa_nfieldcat TYPE lvc_s_fcat. *----------------------------------------------------------------------* * INCLUDE OFFICEINTEGRATIONINCLUDE * *----------------------------------------------------------------------* INCLUDE officeintegrationinclude. TYPE-POOLS: sbdst. TYPES: t_url TYPE bds_uri. TYPES: BEGIN OF document_descr, document_name(40), document_id(64), END OF document_descr. TYPES: document_list TYPE TABLE OF document_descr. DATA: retcode TYPE t_oi_ret_string, document_type TYPE soi_document_type VALUE soi_doctype_excel_chart, document_format TYPE soi_document_type. *----------------------------------------------------------------------* * 基础数据声明 * *----------------------------------------------------------------------* DATA contgrid TYPE REF TO cl_gui_custom_container. DATA conttree TYPE REF TO cl_gui_custom_container. DATA tmp TYPE int4. DATA wa_fieldcat TYPE lvc_s_fcat. DATA hgrid TYPE REF TO cl_gui_alv_grid. TABLES zpower. TYPES: BEGIN OF ty_power. INCLUDE STRUCTURE zpower. TYPES: END OF ty_power. DATA itab TYPE TABLE OF ty_power. DATA wa TYPE ty_power. START-OF-SELECTION. CALL SCREEN 100. *----------------------------------------------------------------------* * MODULE STATUS_0102 OUTPUT *----------------------------------------------------------------------* * *----------------------------------------------------------------------* MODULE status_0102 OUTPUT. SET PF-STATUS space. SET TITLEBAR 'DEMO'. " 'HIER-ALV: DEMO. NOT operational'. DATA oncepbod0100 TYPE flag. IF ( oncepbod0100 IS INITIAL ). PERFORM get_data. oncepbod0100 = 'X'. DATA dynnr TYPE sydynnr. dynnr = sy-dynnr. DATA repid TYPE syrepid. repid = sy-repid. IF ( contgrid IS INITIAL ). dynnr = sy-dynnr. repid = sy-repid. CREATE OBJECT contgrid EXPORTING dynnr = dynnr repid = repid container_name = 'GRID'. CREATE OBJECT conttree EXPORTING dynnr = dynnr repid = repid container_name = 'TREE'. CREATE OBJECT hgrid EXPORTING i_parent = contgrid i_parentdbg = conttree. CALL METHOD hgrid->set_table_for_first_display CHANGING it_fieldcatalog = it_fcat2 it_outtab = itab. ENDIF. SET PF-STATUS space. ENDIF. ENDMODULE. " STATUS_0102 OUTPUT *----------------------------------------------------------------------* * MODULE user_command_0100 INPUT *----------------------------------------------------------------------* * *----------------------------------------------------------------------* MODULE user_command_0100 INPUT. CALL METHOD cl_gui_cfw=>dispatch. IF ( sy-ucomm = 'EXIT' OR sy-ucomm = 'BACK' ). LEAVE TO SCREEN 0. ENDIF. ENDMODULE. " USER_COMMAND_0100 INPUT *&---------------------------------------------------------------------* *& Form get_data *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM get_data . SELECT * FROM zpower INTO CORRESPONDING FIELDS OF TABLE itab. CLEAR it_fieldcat[]. CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' EXPORTING i_structure_name = structure CHANGING ct_fieldcat = it_fieldcat. LOOP AT it_fieldcat INTO wa_fieldcat. CLEAR wa_nfieldcat. MOVE-CORRESPONDING wa_fieldcat TO wa_nfieldcat. APPEND wa_nfieldcat TO it_fcat2. ENDLOOP. ENDFORM. " get_data

 

SCREEN 100 里面两个布局,名字分别是TREE/GRID

 

结果如下:

 

 

 ALV+EXCEL BDS_第1张图片

 

 

ALV+EXCEL BDS_第2张图片

 

ALV+EXCEL BDS_第3张图片

 

ALV+EXCEL BDS_第4张图片

 

你可能感兴趣的:(command,Excel,Module,table,include,structure)