gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 06:46:17 25 4
gpt4 key购买 nike

我在想我可能缺少一个导出参数(来自我的函数调用 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
以及异常加处理。
我已经检查过我传递的内部表是否有数据,并且确实如此。
我认为我提供的信息就足够了,但是如果您真的需要查看代码,我会这样做。
我是菜鸟,任何帮助将不胜感激。
谢谢。

最佳答案

有多种使用 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.

    在公益组织
      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.

    希望这有帮助,
    问候

    纪尧姆·帕特里

    关于abap - 如何让我的数据显示在我的 ALV 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3732114/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com