短转储:字段符号尚未分配

发布于 2025-01-03 05:47:29 字数 1280 浏览 0 评论 0原文

当我运行这个程序时,我得到一个简短的转储(字段符号尚未分配)。 我知道当我没有正确填写 t_fieldcat 时,我可能会收到此错误。 据我所知,我已经正确填写了字段目录。

我无法弄清楚问题出在哪里..请帮忙。

REPORT  Y_ALV1.

type-pools slis.
tables: scarr.

data:
      t_scarr type table of scarr,
      t_fieldcat type slis_t_fieldcat_alv.

data:
      wa_fieldcat type slis_fieldcat_alv.

select-options:
      s_carrid for scarr-carrid.

start-of-selection.
      select * into table t_scarr from scarr where carrid in s_carrid.
        if sy-subrc ne 0.
          leave list-processing.
          endif.

define fill_fieldcatalog.
  wa_fieldcat-col_pos = &1.
  wa_fieldcat-fieldname = &2.
  wa_fieldcat-tabname = &3.
  wa_fieldcat-outputlen = &4.

  append wa_fieldcat to t_fieldcat.

  end-of-definition.


  fill_fieldcatalog 1 'carrid' 't_scarr' 10.
  fill_fieldcatalog 2 'carrname' 't_scarr' 10.

  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
   EXPORTING
      IT_FIELDCAT                    = t_fieldcat
    TABLES
      T_OUTTAB                       = t_scarr
   EXCEPTIONS
     PROGRAM_ERROR                  = 1
     OTHERS                         = 2
            .
  IF SY-SUBRC <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

I am getting a short dump (Field symbol has not yet been assigned) when I run this program.
I know that I may get this error when I don't fill the t_fieldcat correctly.
As far as I know I have filled the field catalog correctly.

I cannot figure out where the problem is..Please help.

REPORT  Y_ALV1.

type-pools slis.
tables: scarr.

data:
      t_scarr type table of scarr,
      t_fieldcat type slis_t_fieldcat_alv.

data:
      wa_fieldcat type slis_fieldcat_alv.

select-options:
      s_carrid for scarr-carrid.

start-of-selection.
      select * into table t_scarr from scarr where carrid in s_carrid.
        if sy-subrc ne 0.
          leave list-processing.
          endif.

define fill_fieldcatalog.
  wa_fieldcat-col_pos = &1.
  wa_fieldcat-fieldname = &2.
  wa_fieldcat-tabname = &3.
  wa_fieldcat-outputlen = &4.

  append wa_fieldcat to t_fieldcat.

  end-of-definition.


  fill_fieldcatalog 1 'carrid' 't_scarr' 10.
  fill_fieldcatalog 2 'carrname' 't_scarr' 10.

  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
   EXPORTING
      IT_FIELDCAT                    = t_fieldcat
    TABLES
      T_OUTTAB                       = t_scarr
   EXCEPTIONS
     PROGRAM_ERROR                  = 1
     OTHERS                         = 2
            .
  IF SY-SUBRC <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清风无影 2025-01-10 05:47:29

不幸的是,这个案例在这里确实很重要。将以下行更改为

fill_fieldcatalog 1 'carrid' 't_scarr' 10.
fill_fieldcatalog 2 'carrname' 't_scarr' 10.

fill_fieldcatalog 1 'CARRID' 't_scarr' 10.
fill_fieldcatalog 2 'CARRNAME' 't_scarr' 10.

Unfortunately the case does matter here. Change the following lines:

fill_fieldcatalog 1 'carrid' 't_scarr' 10.
fill_fieldcatalog 2 'carrname' 't_scarr' 10.

to

fill_fieldcatalog 1 'CARRID' 't_scarr' 10.
fill_fieldcatalog 2 'CARRNAME' 't_scarr' 10.
清醇 2025-01-10 05:47:29

其他选项是在宏中将其转换为大写。这样你在调用它时就永远不会出错。

wa_fieldcat-fieldname = &2.
TRANSLATE wa_fieldcat-fieldname TO UPPER CASE.
wa_fieldcat-tabname = &3.
TRANSLATE wa_fieldcat-tabname TO UPPER CASE.

Other option would be to do the translation to upper case in your macro. That way you can never make a mistake when calling it.

wa_fieldcat-fieldname = &2.
TRANSLATE wa_fieldcat-fieldname TO UPPER CASE.
wa_fieldcat-tabname = &3.
TRANSLATE wa_fieldcat-tabname TO UPPER CASE.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文