GRID方式ALV导出数据到本地丢掉最后一位的问题详解编程语言

这是SAP的一个Bug,FM方式ALV GridClass ALV Grid都会出现,但是ALV List好像没有这个BUG。
 
在以下几个条件满足的时候就会出现这个问题:
1.字段对应的域Convers. routine = ALPHA,也就是有前导零的字段,比如供应商号、商品号、客户号等。
2.做ALV Fieldcat的时候,没有指定参考表和参考字段
3.列的表头文本(seltext_s等)比实际显示的数据短
 
所以解决问题的时候从2、3两点下手即可。
 
 1 TYPE-POOLS: slis. 
 2 DATA: gd_fieldcat TYPE slis_t_fieldcat_alv. 
 3 DATA: sla TYPE slis_layout_alv , 
 4       i_repid LIKE sy-repid , 
 5       ls_fieldcat TYPE slis_fieldcat_alv. 
 6 DATA: BEGIN OF itab OCCURS 0, 
 7         lifnr LIKE lfa1-lifnr , 
 8         kunnr LIKE kna1-kunnr , 
 9         matnr LIKE mara-matnr , 
10         bukrs LIKE bsik-bukrs , 
11       END OF itab. 
12  
13 START-OF-SELECTION. 
14   itab-lifnr = '0000100047'. 
15   itab-kunnr = '0000001006'. 
16   itab-bukrs = 'ZB01'. 
17   itab-matnr = '000000000001100198'. 
18   APPEND itab. 
19  
20   CLEAR ls_fieldcat . 
21   ls_fieldcat-fieldname     =  'LIFNR'. 
22   ls_fieldcat-seltext_s     =  'LI'. 
23   ls_fieldcat-seltext_l     =  'LILI'. 
24   ls_fieldcat-seltext_m     =  'LILILI'. 
25   ls_fieldcat-ref_fieldname = 'LIFNR'.  "|注释 
26   ls_fieldcat-ref_tabname   = 'LFA1'.   "| 
27   ls_fieldcat-ddictxt       = 'S'. 
28   APPEND ls_fieldcat TO gd_fieldcat . 
29  
30   CLEAR ls_fieldcat . 
31   ls_fieldcat-fieldname     =  'KUNNR'. 
32   ls_fieldcat-seltext_s     =  'KU'. 
33   ls_fieldcat-ref_fieldname = 'KUNNR'.  "|注释 
34   ls_fieldcat-ref_tabname   = 'KNA1'.   "| 
35   APPEND ls_fieldcat TO gd_fieldcat . 
36  
37   CLEAR ls_fieldcat . 
38   ls_fieldcat-fieldname     =  'BUKRS'. 
39   ls_fieldcat-seltext_s     =  'BU'. 
40   APPEND ls_fieldcat TO gd_fieldcat . 
41  
42   CLEAR ls_fieldcat . 
43   ls_fieldcat-fieldname     =  'MATNR'. 
44   ls_fieldcat-seltext_s     =  'MAT'. 
45   ls_fieldcat-ref_fieldname = 'MATNR'.  "|注释 
46   ls_fieldcat-ref_tabname   = 'MAKT'.   "| 
47   APPEND ls_fieldcat TO gd_fieldcat . 
48  
49   i_repid = sy-repid. 
50   CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' 
51     EXPORTING 
52       i_callback_program      = i_repid 
53       it_fieldcat             = gd_fieldcat[] 
54       i_save                  = 'A' 
55       is_layout               = sla 
56       i_callback_user_command = 'USER_COMMAND' 
57     TABLES 
58       t_outtab                = itab 
59     EXCEPTIONS 
60       program_error           = 1 
61       OTHERS                  = 2.

View Code

原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/18431.html

(0)
上一篇 2021年7月19日
下一篇 2021年7月19日

相关推荐

发表回复

登录后才能评论