*&---------------------------------------------------------------------* *& Report Z14 *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT z14. TYPE-POOLS:slis. "1.声明变量 DATA:lt_fieldcat TYPE slis_t_fieldcat_alv, ls_fieldcat TYPE slis_fieldcat_alv, ls_layout TYPE slis_layout_alv. "2.定义内表 TYPES:BEGIN OF ty_alvshow, bukrs TYPE bkpf-bukrs,"公司代码 belnr TYPE bkpf-belnr,"会计凭证编号 gjahr TYPE bkpf-gjahr,"会计年度 blart TYPE bkpf-blart,"凭证类型 bktxt TYPE bkpf-bktxt,"凭证抬头文本 END OF ty_alvshow. DATA: lt_ty_alvshow TYPE TABLE OF ty_alvshow, ls_ty_alvshow TYPE ty_alvshow. "3-读取数据 SELECT a~bukrs a~belnr a~gjahr a~blart a~bktxt FROM bkpf AS a INTO TABLE lt_ty_alvshow . ls_layout-zebra = 'X'. ls_layout-detail_popup = 'X'. ls_layout-f2code = '&ETA'. ls_layout-colwidth_optimize = 'X'. ls_layout-detail_titlebar = '详细信息'. DATA index TYPE int2. index = 1. ls_fieldcat-col_pos = index. ls_fieldcat-fieldname = 'bukrs'. ls_fieldcat-key = 'X'. ls_fieldcat-datatype = 'char'. ls_fieldcat-outputlen = '4'. ls_fieldcat-seltext_m = '公司代码'. APPEND ls_fieldcat TO lt_fieldcat. CLEAR ls_fieldcat. index = index + 1. ls_fieldcat-col_pos = index. ls_fieldcat-fieldname = 'belnr'. ls_fieldcat-key = 'X'. ls_fieldcat-datatype = 'char'. ls_fieldcat-outputlen = '10'. ls_fieldcat-seltext_m = '会计凭证编号'. APPEND ls_fieldcat TO lt_fieldcat. CLEAR ls_fieldcat. index = index + 1. ls_fieldcat-col_pos = index. ls_fieldcat-fieldname = 'gjahr'. ls_fieldcat-datatype = 'NUMC'. ls_fieldcat-outputlen = '4'. ls_fieldcat-seltext_m = '会计年度'. APPEND ls_fieldcat TO lt_fieldcat. CLEAR ls_fieldcat. index = index + 1. ls_fieldcat-col_pos = index. ls_fieldcat-fieldname = 'blart'. ls_fieldcat-datatype = 'CHAR'. ls_fieldcat-outputlen = '2'. ls_fieldcat-seltext_m = '凭证类型'. APPEND ls_fieldcat TO lt_fieldcat. CLEAR ls_fieldcat. index = index + 1. ls_fieldcat-col_pos = index. ls_fieldcat-fieldname = 'bktxt'. ls_fieldcat-datatype = 'CHAR'. ls_fieldcat-outputlen = '25'. ls_fieldcat-seltext_m = '凭证抬头文本'. APPEND ls_fieldcat TO lt_fieldcat. CLEAR ls_fieldcat. "显示ALV CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING * I_INTERFACE_CHECK = ' ' * I_BYPASSING_BUFFER = ' ' * I_BUFFER_ACTIVE = ' ' * I_CALLBACK_PROGRAM = ' ' * I_CALLBACK_PF_STATUS_SET = ' ' * I_CALLBACK_USER_COMMAND = ' ' * I_CALLBACK_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_END_OF_LIST = ' ' * I_STRUCTURE_NAME = * I_BACKGROUND_ID = ' ' * I_GRID_TITLE = * I_GRID_SETTINGS = is_layout = ls_layout it_fieldcat = lt_fieldcat * IT_EXCLUDING = * IT_SPECIAL_GROUPS = * IT_SORT = * IT_FILTER = * IS_SEL_HIDE = * I_DEFAULT = 'X' * I_SAVE = ' ' * IS_VARIANT = * IT_EVENTS = * IT_EVENT_EXIT = * IS_PRINT = * IS_REPREP_ID = * I_SCREEN_START_COLUMN = 0 * I_SCREEN_START_LINE = 0 * I_SCREEN_END_COLUMN = 0 * I_SCREEN_END_LINE = 0 * I_HTML_HEIGHT_TOP = 0 * I_HTML_HEIGHT_END = 0 * IT_ALV_GRAPHICS = * IT_HYPERLINK = * IT_ADD_FIELDCAT = * IT_EXCEPT_QINFO = * IR_SALV_FULLSCREEN_ADAPTER = * IMPORTING * E_EXIT_CAUSED_BY_CALLER = * ES_EXIT_CAUSED_BY_USER = TABLES t_outtab = lt_ty_alvshow * EXCEPTIONS * PROGRAM_ERROR = 1 * OTHERS = 2 . IF sy-subrc <> 0. * Implement suitable error handling here ENDIF.
标签:index,layout,会计凭证,BKPF,fieldcat,lt,ls,ALV,TYPE From: https://www.cnblogs.com/hua900822/p/16967201.html