从用户命令导航时出现 ALV 刷新问题 [英] ALV refresh problem while navigating from user command

查看:18
本文介绍了从用户命令导航时出现 ALV 刷新问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 2 个屏幕 7000 和 7001,7000 屏幕包含一个按钮,当我们点击它时,它必须导航到 7001 屏幕,但它没有按预期工作.SCREEN 7000 也有一些细节可以显示为 alv.

I have 2 screens 7000 and 7001, 7000 screen contains one button when we click on it it has to navigate to the 7001 screen, but it was not working as expected. SCREEN 7000 also have some details to display as an alv.

屏幕导航到屏幕 7001,但数据没有得到刷新.任何人都可以帮忙.我正在使用 alv 网格容器.对于两个屏幕,我都使用相同的 alv 网格

screen was navigating to screen 7001 but the data was not getting refresh. can any one help on it. I am using alv grid container. for both the screens i am using same alv grid

示例代码:

screen 7000 PAI:
WHEN 'DISPLAY'.
      call SCREEN 7001.

screen 7001 PBO:
 GET REFERENCE OF m_instance->gt_field INTO lr_output.

  CREATE OBJECT gr_grid
    EXPORTING
      i_parent = cl_gui_container=>default_screen.

  CALL FUNCTION 'ZLSO_GENERATE_GENERIC_FIELDCAT'
    EXPORTING
      ir_input_value   = lr_output
    IMPORTING
      et_fieldcat_fcat = lt_fldcat
    EXCEPTIONS
      xc_invalid_type  = 1
      xc_empty_table   = 2
      xc_unknown_error = 3
      OTHERS           = 4.
  IF sy-subrc <> 0.
    MESSAGE ' Error in generating ALV' TYPE 'E'.
  ENDIF.

  CALL METHOD gr_grid->set_table_for_first_display
    EXPORTING
      is_layout       = gs_layout
    CHANGING
      it_fieldcatalog = lt_fldcat
      it_outtab       = m_instance->gt_field.

  gr_grid->refresh_table_display( ).

推荐答案

1) 主要问题

可能您遇到过将多个 UI 控件分配给同一个 UI 容器的情况,只显示分配的第一个控件.

Probably you are experiencing the case that several UI controls are assigned to the same UI container, only the first control assigned is displayed.

为避免该问题,您必须释放额外的控件,以便每个容器只分配一个控件.

To avoid that issue, you must free the extra controls so that only one control remains assigned to each container.

在您的情况下,您有 2 个 ALV 网格分配给同一个虚拟容器 DEFAULT_SCREEN;您的控件是 CL_GUI_ALV_GRID 类的实例,您可以调用方法 FREE 来释放它.

In your case, you have 2 ALV Grids assigned to the same dummy container DEFAULT_SCREEN; your control being an instance of the class CL_GUI_ALV_GRID, you may call the method FREE to free it.

2) 您的代码中存在另一个问题

上面的解决方案应该可以解决您当前的问题,但这会产生另一个问题,因为在导航回屏幕 7000 时您必须重新实例化 ALV 网格,这将重置滚动位置等.

The solution above should solve your immediate issue, but that will create another one, because you will have to re-instantiate the ALV Grid when navigating back to the screen 7000, and that will reset the scroll position and so on.

您可以通过更改代码中的其他内容来避免它,如下所述.

You may avoid it by changing something else in your code, as I explain below.

一个 dynpro(ABAP 屏幕)包含 UI 元素,但是如果您将控件分配给虚拟屏幕"(CL_GUI_CONTAINER 的任何静态属性 *SCREEN*),此控件将显示在 dynpro 上(除了工具栏外,根本不显示 dynpro 的 UI 元素).

A dynpro (ABAP screen) contains UI elements, but if you assign a control to a "dummy screen" (any of the static attributes *SCREEN* of CL_GUI_CONTAINER), this control will be displayed over the dynpro (the UI elements of the dynpro are not shown at all, except the toolbar).

您应该定义一个 自定义控制区域在你的dynpro中,给它一个名字,然后在PBO中,创建一个自定义容器(类CL_GUI_CUSTOM_CONTAINER)通过指示区域名称,并将ALV网格分配给该容器.

Instead of using dummy screens, you should define a custom control area in your dynpro, give it a name, then in the PBO, create a custom container (class CL_GUI_CUSTOM_CONTAINER) by indicating the area name, and assign the ALV Grid to that container.

如果您在两个屏幕中执行此操作,那么每个容器将只有一个 ALV Grid,并且您无需在每个导航步骤释放和重新实例化控件.

If you do that in your two screens, then you will have only one ALV Grid per container, and you won't need to free and re-instantiate the controls at each navigation step.

这篇关于从用户命令导航时出现 ALV 刷新问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆