|
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622 。
您需要 登录 才可以下载或查看,没有帐号?注册
x
在使用ALV的时候,在给字段集合赋值时,abap是没有自动检查引号内的大小写的,但又必段是大写,我们在申明时用得是小写,在括号中也应该是大写.看例子就明白了
REPORT z_ex1.
TYPE-POOLS: slis.
TABLES:t001.
DATA :BEGIN OF company,
code TYPE t001-bukrs,"公司代码
name TYPE t001-butxt,"公司名称
desc(200) TYPE c, "描述
END OF company.
DATA itab LIKE t001 OCCURS 0 WITH HEADER LINE.
DATA itab_company LIKE company OCCURS 0 WITH HEADER LINE.
DATA:ws_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
ws_fieldgroups_tab TYPE slis_t_sp_group_alv,
ws_layout TYPE slis_layout_alv,
ws_sortfields_tab TYPE slis_t_sortinfo_alv WITH HEADER LINE,
ws_events TYPE slis_t_event.
SELECT * INTO TABLE itab FROM t001.
LOOP AT itab.
company-code = itab-bukrs.
company-name = itab-butxt.
CONCATENATE itab-land1 itab-ort01 itab-adrnr INTO company-desc
SEPARATED BY ''
.
APPEND company TO itab_company.
ENDLOOP.
ws_fieldcat-tabname = 'ITAB'.
ws_fieldcat-fieldname = 'CODE'.
ws_fieldcat-seltext_m = '公司代码'.
ws_fieldcat-col_pos = 1.
ws_fieldcat-outputlen = 8.
ws_fieldcat-datatype = 'CHAR'.
WS_FIELDCAT-DO_SUM = ''.
ws_fieldcat-lzero = 'X'.
ws_fieldcat-no_zero = 'X'.
APPEND ws_fieldcat.
CLEAR ws_fieldcat.
ws_fieldcat-tabname = 'ITAB'.
ws_fieldcat-fieldname = 'NAME'.
ws_fieldcat-seltext_m = '公司名称'.
ws_fieldcat-col_pos = 2.
ws_fieldcat-outputlen = 25.
ws_fieldcat-datatype = 'CHAR'.
WS_FIELDCAT-DO_SUM = ''.
ws_fieldcat-lzero = 'X'.
ws_fieldcat-no_zero = 'X'.
APPEND ws_fieldcat.
CLEAR ws_fieldcat.
ws_fieldcat-tabname = 'ITAB'. "itab我在前面是小写,在这里一定要大写,所有引号内的都必段是大写.
ws_fieldcat-fieldname = 'DESC'."如上
ws_fieldcat-seltext_m = '公司描述'.
ws_fieldcat-col_pos = 3.
ws_fieldcat-outputlen = 200.
ws_fieldcat-datatype = 'CHAR'.
WS_FIELDCAT-DO_SUM = ''.
ws_fieldcat-lzero = 'X'.
ws_fieldcat-no_zero = 'X'.
APPEND ws_fieldcat.
CLEAR ws_fieldcat.
ws_layout-zebra = 'X'.
ws_layout-get_selinfos = 'X'.
ws_layout-colwidth_optimize = 'X'.
ws_layout-detail_popup = 'X'.
ws_layout-no_keyfix = 'X'.
ws_layout-no_totalline = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = ws_layout
it_fieldcat = ws_fieldcat[]
* it_special_groups = ws_fieldgroups_tab[]
* it_sort = ws_sortfields_tab[]
* it_events = ws_events[]
i_grid_title = ''
TABLES
t_outtab = itab_company
EXCEPTIONS
program_error = 1
OTHERS = 2.
另一种情况在使用状态:set pf_status 'STA'.这里引号内的也必段是大写.
这些是初学时容易犯的错误.在此提醒一下初学的人. |
|