如何让我的数据显示在我的 ALV 中?

发布于 2024-09-19 18:28:18 字数 383 浏览 9 评论 0原文

我想我可能缺少导出参数(来自我的函数调用 POV)。

REUSE_ALV_GRID_DISPLAY函数调用中,我传递的参数是: 导出:

   i_callback_program,
   i_callback_pf_status_set,
   i_callback_user_command,
   is_layout,
   it_fieldcat,
   i_save
Tables:
   t_outtab

以及异常和处理。

我已经检查过我传递的内部表是否有数据,确实如此。

我认为我提供的信息就足够了,但如果您确实需要查看代码,我会这样做。

我是菜鸟,任何帮助将不胜感激。

谢谢。

I'm thinking that I'm probably missing an export parameter (from my Function Call POV).

In the REUSE_ALV_GRID_DISPLAY function call, the parameters I pass around are:
Exporting:

   i_callback_program,
   i_callback_pf_status_set,
   i_callback_user_command,
   is_layout,
   it_fieldcat,
   i_save
Tables:
   t_outtab

And the exceptions plus handling.

I've checked that the internal table that I pass has data and it does.

I think the information I put up will suffice but if you really need to see the code, I'll do so.

I'm a noob and any help would be appreciated.

Thanx.

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

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

发布评论

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

评论(5

白况 2024-09-26 18:28:19

将输出内部表传递给 FM 参数“t_outtab”。
它将打印您的数据输出。

Pass the output internal table to the FM Parameter "t_outtab".
It will print your data output.

独夜无伴 2024-09-26 18:28:18

使用 ALV 的方法有多种,因此我们可能确实需要有关您的代码的更多信息来提供帮助。

  • 第一种方法是使用功能模块REUSE_ALV_GRID_DISPLAY。这将直接在输出 dynpro 中显示表格内容。如果您需要的只是显示,那么就使用它,因为这是最简单的:如果表结构在字典中,则此调用可以像下面一样简单(这会将结构的所有成员显示为列)
myreport = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
          i_callback_program          = myreport
          it_excluding                = exclude_tab
       TABLES
          t_outtab                    = display_data
       EXCEPTIONS
          program_error               = 1
          OTHERS                      = 2.

如果在程序中声明了该结构,那么您必须创建一个字段目录。
以下代码可以作为基础:

FORM fill_fieldcat CHANGING p_fieldcat   TYPE slis_t_fieldcat_alv.

* Data definition
  DATA ls_fieldcat  TYPE slis_fieldcat_alv.

* Macro definition
  DEFINE append_fieldcat.
    clear ls_fieldcat.

    ls_fieldcat-fieldname      = &1. * name of the field in struct
    ls_fieldcat-tabname        = &2. * name of the table
    ls_fieldcat-row_pos        = &3. * column
    ls_fieldcat-ref_fieldname  = &4. * field in ref table
    ls_fieldcat-ref_tabname    = &5. * ref table
    ls_fieldcat-outputlen      = &6. * size of output
    ls_fieldcat-seltext_m      = &7. * text (space if using the element typetext)
    ls_fieldcat-ddictxt        = 'M'.
    ls_fieldcat-key            = &8.  * is this a key field in table
    ls_fieldcat-emphasize      = &9.  * emphisze  column display

    append ls_fieldcat to p_fieldcat.
  END-OF-DEFINITION.

* Init.
  REFRESH p_fieldcat.

* Append fielcatalog for ALV
  append_fieldcat:
  'FORMATIONCODE' 'DISPLAY_TAB' 1 'SHORT' 'HRP1000' 12    'Code Stage'     space space,
  'FORMATIONTEXT' 'DISPLAY_TAB' 1 'STEXT' 'HRP1000' 20    'Libelle Stage'  space space,
  'SESSIONID'     'DISPLAY_TAB' 1 'OBJID' 'HRP1000' space 'Session'        space space,
  'BEGDA'         'DISPLAY_TAB' 1 'BEGDA' 'HRP1000' space 'Debut'          space space,
  'ENDDA'         'DISPLAY_TAB' 1 'BEGDA' 'HRP1000' space 'Fin'            space space,
ENDFORM.                    "fill_fieldCat

然后调用表单来创建字段目录,并在函数调用的 it_fieldcat 参数中使用它。

  • 第二种方法是使用ABAP-Object。使用 check se83 作为此用法的示例。基础如下:

在 Dynpro 中,您声明一个具有给定名称(“ALV_CONT”)的自定义容器。然后在 dynpro 的 PBO 中初始化容器并在其中放入 ALV 对象:

* global variables :
DATA : delegationlist_table     TYPE REF TO cl_gui_alv_grid,
       delegationlist_container TYPE REF TO cl_gui_custom_container.
data : gs_layout   TYPE lvc_s_layo.

在 PBO 中

  IF delegationlist_container IS INITIAL.
*   create a custom container control for our ALV Control
    CREATE OBJECT delegationlist_container
      EXPORTING
        container_name              = 'ALV_CONT'
      EXCEPTIONS
        cntl_error                  = 1
        cntl_system_error           = 2
        create_error                = 3
        lifetime_error              = 4
        lifetime_dynpro_dynpro_link = 5.

*   create an instance of alv control
    CREATE OBJECT delegationlist_table
      EXPORTING
        i_parent = delegationlist_container.

*   Set a titlebar for the grid control
    gs_layout-grid_title = 'Délégations'.
    gs_layout-sel_mode = 'A'.
    gs_layout-cwidth_opt ='X'.

*   set table as data source
*   the struct name *must* be uppercase
*   the table must have this struc
    CALL METHOD delegationlist_table->set_table_for_first_display
      EXPORTING
        i_structure_name = 'ZPRT_DELEGATIONLIST'
        is_layout        = gs_layout
      CHANGING
        it_outtab        = delegationlist.

  ENDIF.

希望有帮助,
问候 纪尧姆

·帕特里

There are several ways to use ALV, so we may indeed need more info on your code to help.

  • First Method is to use the function module REUSE_ALV_GRID_DISPLAY. This will directly display the table content in the output dynpro. If all you need is a display, then go for it, as this is the simpliest : If the table structure is in the dictionnary, this call can be as simple as the following (this will display all members of the struct as column)
myreport = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
          i_callback_program          = myreport
          it_excluding                = exclude_tab
       TABLES
          t_outtab                    = display_data
       EXCEPTIONS
          program_error               = 1
          OTHERS                      = 2.

If the structure is declared in the program, then you have to create a field catalog.
the following code can serve as basis :

FORM fill_fieldcat CHANGING p_fieldcat   TYPE slis_t_fieldcat_alv.

* Data definition
  DATA ls_fieldcat  TYPE slis_fieldcat_alv.

* Macro definition
  DEFINE append_fieldcat.
    clear ls_fieldcat.

    ls_fieldcat-fieldname      = &1. * name of the field in struct
    ls_fieldcat-tabname        = &2. * name of the table
    ls_fieldcat-row_pos        = &3. * column
    ls_fieldcat-ref_fieldname  = &4. * field in ref table
    ls_fieldcat-ref_tabname    = &5. * ref table
    ls_fieldcat-outputlen      = &6. * size of output
    ls_fieldcat-seltext_m      = &7. * text (space if using the element typetext)
    ls_fieldcat-ddictxt        = 'M'.
    ls_fieldcat-key            = &8.  * is this a key field in table
    ls_fieldcat-emphasize      = &9.  * emphisze  column display

    append ls_fieldcat to p_fieldcat.
  END-OF-DEFINITION.

* Init.
  REFRESH p_fieldcat.

* Append fielcatalog for ALV
  append_fieldcat:
  'FORMATIONCODE' 'DISPLAY_TAB' 1 'SHORT' 'HRP1000' 12    'Code Stage'     space space,
  'FORMATIONTEXT' 'DISPLAY_TAB' 1 'STEXT' 'HRP1000' 20    'Libelle Stage'  space space,
  'SESSIONID'     'DISPLAY_TAB' 1 'OBJID' 'HRP1000' space 'Session'        space space,
  'BEGDA'         'DISPLAY_TAB' 1 'BEGDA' 'HRP1000' space 'Debut'          space space,
  'ENDDA'         'DISPLAY_TAB' 1 'BEGDA' 'HRP1000' space 'Fin'            space space,
ENDFORM.                    "fill_fieldCat

you then call the form to create the field catalog, and use it in the it_fieldcat parameter of the function call.

  • Second method is to use ABAP-Object. Use check se83 for exemples of this use. the basis is as follows :

In your Dynpro you declare a custom container with a given name ("ALV_CONT"). Then in then PBO of the dynpro you initialize the container and put an ALV objct inside :

* global variables :
DATA : delegationlist_table     TYPE REF TO cl_gui_alv_grid,
       delegationlist_container TYPE REF TO cl_gui_custom_container.
data : gs_layout   TYPE lvc_s_layo.

in PBO

  IF delegationlist_container IS INITIAL.
*   create a custom container control for our ALV Control
    CREATE OBJECT delegationlist_container
      EXPORTING
        container_name              = 'ALV_CONT'
      EXCEPTIONS
        cntl_error                  = 1
        cntl_system_error           = 2
        create_error                = 3
        lifetime_error              = 4
        lifetime_dynpro_dynpro_link = 5.

*   create an instance of alv control
    CREATE OBJECT delegationlist_table
      EXPORTING
        i_parent = delegationlist_container.

*   Set a titlebar for the grid control
    gs_layout-grid_title = 'Délégations'.
    gs_layout-sel_mode = 'A'.
    gs_layout-cwidth_opt ='X'.

*   set table as data source
*   the struct name *must* be uppercase
*   the table must have this struc
    CALL METHOD delegationlist_table->set_table_for_first_display
      EXPORTING
        i_structure_name = 'ZPRT_DELEGATIONLIST'
        is_layout        = gs_layout
      CHANGING
        it_outtab        = delegationlist.

  ENDIF.

Hopes this help,
Regards

Guillaume PATRY

鱼忆七猫命九 2024-09-26 18:28:18

编辑:哦,还有一件事 - 如果您确实处于 POV(处理 Value-Request = F4),请注意您可以做的事情是有限的。在开始选择后立即在简单报告中尝试您的代码,如果有效,请在 POV 模块中尝试相同的代码。

===

如果您不传递结构名称,则必须确保传递完整的 (!) 字段目录,否则 ALV 网格可能会开始不稳定工作或根本无法工作。使用功能模块 LVC_FIELDCATALOG_MERGE 和 LVC_FIELDCAT_COMPLETE(按此顺序)获取可与类或 REUSE_ALV_GRID_DISPLAY_LVC 一起使用的 LVC 字段目录。

EDIT: Oh, and another thing - if you're really in POV (process on Value-Request = F4), be aware that there are limitations to what you can do. Try your code in a simple report right after START-OF-SELECTION, and if that works, try the same code in a POV module.

===

If you don't pass a structure name, you have to ensure that you pass a complete (!) field catalog, otherwise the ALV grid might start to work erratically or not at all. Use the function modules LVC_FIELDCATALOG_MERGE and LVC_FIELDCAT_COMPLETE (in this order) to get a LVC field catalog that can be used with the classes or REUSE_ALV_GRID_DISPLAY_LVC.

晨与橙与城 2024-09-26 18:28:18

这里有几个人建议使用 REUSE_ALV_GRID_DISPLAY。我确信这是一种常见的完成事情的方法(我自己曾经使用过它),但是我最近参加了 sap delta 课程,他们强烈建议不要再使用它了(你可以查一下,REUSE_ALV_GRID_DISPLAY 是SAP 不再提供官方支持)。

相反,请使用 CL_SALV_TABLE,此处的文档: http://help.sap .com/erp2005_ehp_04/helpdata/EN/d7/b22041aa7df323e10000000a155106/frameset.htm

其实用起来也比较方便。

A couple people here suggested using the REUSE_ALV_GRID_DISPLAY. I'm sure this is a common way to get things done (I used to use it myself), but I've taken a sap delta course recently and they strongly suggested to not use it anymore (you can look it up, REUSE_ALV_GRID_DISPLAY is not officialy supported by SAP anymore).

Instead, use CL_SALV_TABLE, documentation here: http://help.sap.com/erp2005_ehp_04/helpdata/EN/d7/b22041aa7df323e10000000a155106/frameset.htm

It's actually rather convenient to use too.

何必那么矫情 2024-09-26 18:28:18

感谢您的努力,但事实证明,我犯的错误是在构建字段目录时没有将字段名称大写。这样的新手错误。我想我很快就不会再犯同样的错误了。

-米格

Thanks for the effort but as it turned out, the mistake I did was that I didn't capitalize field names in building the Field Catalog. Such a newbie mistake. I guess I won't be doing that mistake again any time soon.

-migs

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