如何使用 REUSE_ALV_FIELDCATALOG_MERGE 功能模块? [英] How to use REUSE_ALV_FIELDCATALOG_MERGE function module?

查看:27
本文介绍了如何使用 REUSE_ALV_FIELDCATALOG_MERGE 功能模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用功能模块REUSE_ALV_FIELDCATALOG_MERGE 来传递ddic 中的字段标签以显示在alv 报告的列标题中.但是,那没有用.

I'm trying to use the function module REUSE_ALV_FIELDCATALOG_MERGE to pass the field label in ddic to display in the column header of the alv report. But, that didn't work.

如果我评论 I_STRUCTURE_NAME = 'TY_YNAH_CUS_OBJ_REQ' 行,它会给我运行时错误状态

If I comment the I_STRUCTURE_NAME = 'TY_YNAH_CUS_OBJ_REQ' line, it give me runtime error state

ABAP 程序行比内表宽.

The ABAP program lines are wider than the internal table.

但是如果我取消注释,程序仍然无法运行

But if I uncomment it ,the program still did not work

REPORT YALV_TEST.

        tables sscrfields. 
        type-pools : slis.

        "CREATE STRUCTURE -1 
        TYPES: BEGIN OF TY_YNAH_CUS_OBJ_REQ, 
               REQID TYPE YNAH_REQ_ID, 
               REQUESTOR TYPE YNAH_REQUESTOR,
               BUSINESS_OWNER TYPE YNAH_BUS_OWN,
               FUNCTIONAL_OWNER TYPE YNAH_FUNC_OWN, 
               REQNUM TYPE YNAH_SERVICE_REQ_NUM, 
               PROJECT_ID TYPE YNAH_PRO_ID, 
               SYSTEM_ID TYPE YNAH_SYS_ID, 
               FUNCTIONAL_AREA TYPE YNAH_FUNC_AREA,
               REQUEST_DATE TYPE YNAH_REQ_DATE,
               REQUEST_TIME TYPE YNAH_REQ_TIME,

           END OF TY_YNAH_CUS_OBJ_REQ.

        "defining internal table -2 

        DATA: IT_YNAH_CUS_OBJ_REQ type TABLE OF TY_YNAH_CUS_OBJ_REQ 
         * WA_YNAH_CUS_OBJ_REQ type TY_YNAH_CUS_OBJ_REQ.

        DATA: it_fcat TYPE slis_t_fieldcat_alv ,
         wa_fcat TYPE slis_fieldcat_alv,
         gd_layout TYPE slis_layout_alv.

        SELECTION-SCREEN BEGIN OF BLOCK menu WITH FRAME TITLE text-001.
        SELECT-OPTIONS: s_proid FOR IT_YNAH_CUS_OBJ_REQ-PROJECT_ID.
        PARAMETER p_sysid type TY_YNAH_CUS_OBJ_REQ-SYSTEM_ID.
        SELECTION-SCREEN: BEGIN OF LINE,
        pushbutton 33(8) BUT user-command search. 
        SELECTION-SCREEN END OF LINE. 
        SELECTION-SCREEN END OF BLOCK menu.

        initialization. 
        BUT = 'SEARCH'. END-OF-SELECTION.

        "execute search function when user click search button
        at selection-screen. "after processing user input 
         case SSCRFIELDS.
           when 'SEARCH'.
            SSCRFIELDS-UCOMM = 'ONLI'.
        endcase.

    "fetch data using select-4 START-OF-SELECTION. 

    SELECT * 
    FROM YNAH_CUS_OBJ_REQ "Database 
    INTO CORRESPONDING FIELDS OF TABLE IT_YNAH_CUS_OBJ_REQ "Into internal table 
    WHERE 
       PROJECT_ID in s_proid and 
       SYSTEM_ID eq p_sysid.

        CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' 
        EXPORTING
         I_PROGRAM_NAME = sy-repid
        I_INTERNAL_TABNAME ='TY_YNAH_CUS_OBJ_REQ'
        * I_STRUCTURE_NAME = 'TY_YNAH_CUS_OBJ_REQ'
        * I_CLIENT_NEVER_DISPLAY = 'X'
        I_INCLNAME = sy-repid 
        * I_BYPASSING_BUFFER = 'X' 
        * I_BUFFER_ACTIVE = CHANGING CT_FIELDCAT = it_fcat. 
        * EXCEPTIONS 
        * INCONSISTENT_INTERFACE = 1 
        * PROGRAM_ERROR = 2 
        * OTHERS = 3 
        * .
         IF SY-SUBRC <> 0. 
        ** Implement suitable error handling here 
        ENDIF.

推荐答案

  1. 不支持REUSE_*ALV* 功能模块.我建议切换到 CL_SALV_* 类.文档更好,有更多示例程序 (DEMO_SALV_*) 并且您得到支持.
  2. 如果您想获得基于字典的字段描述(废话),您需要一个字典结构.如果使用TYPE ... BEGIN OF ... END OF ...在ABAP级别组装结构类型,据我所知,各个字段的字典类型转换为ABAP首先类型,然后才组装成结构类型.无论如何,原始字段的字典参考丢失了.不要在代码中定义输出表的结构,而是使用字典结构.
  1. The REUSE_*ALV* function modules are unsupported. I'd suggest switching to the CL_SALV_* classes. The documentation is better, there are more sample programs (DEMO_SALV_*) and you get support.
  2. You need a dictionary structure if you want to get dictionary-based field descriptions (duh). If you assemble a structure type on the ABAP level using TYPE ... BEGIN OF ... END OF ..., as far as I know, the dictionary types for the individual fields are converted to ABAP types first and only then assembled into a structure type. Anyway, the dictionary reference of the original fields is lost. Instead of defining the structure of the output table in your code, use a dictionary structure.

这篇关于如何使用 REUSE_ALV_FIELDCATALOG_MERGE 功能模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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