Current Position:Home > Error in ALV grid

Error in ALV grid

Update:11-30Source: network consolidation
Advertisement
Hi ALV masters,
Plz help me ..
I have an ALV grid report where i have the data in my final table t_final.
now i'm trying to populate the fieldcat using FM reuse_alv_fieldcatalog_merge but its not at all getting populated.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      I_PROGRAM_NAME         = l_repid
      I_INTERNAL_TABNAME     = 'T_Final'
      I_INCLNAME             = l_repid
    CHANGING
      CT_FIELDCAT            = T_FIELDCAT[]
    EXCEPTIONS
      INCONSISTENT_INTERFACE = 1
      PROGRAM_ERROR          = 2
      OTHERS                 = 3.
Please help me and if possibl try to send som sample code also.
Thanks in advance..

The Best Answer

Advertisement
Hi Mukesh,
this is my code.
plz tell where i'm going rong..
*& Report  ZMMR_CHANGES                                                *
Title       : Material Master: Display Changes                       *
Description : This ABAP report will collectively list all material   *
              master changes to the fields specified in the selection*
              criteria.                                              *
Request No  : SRDK922644                                             *
Author      : Praveen Reddy                                          *
Created on  : 14-FEB-2007                                            *
REPORT  ZMMR_CHANGES
        NO STANDARD PAGE HEADING
        message-id ZSPR.
TYPE-POOLS : SLIS.
TABLES : CDHDR ,           " Change document header
         CDPOS ,           " Change document item
         MARAV ,           " View Table for Logical DB MGM
         MARC  ,           " Plant Data for Material
         MVKE  .           " Sales Data for Material
SELECTION-SCREEN BEGIN OF BLOCK A WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN BEGIN OF BLOCK GENERAL WITH FRAME TITLE TEXT-002.
SELECT-OPTIONS :
         S_OBJCLS  FOR CDHDR-OBJECTCLAS           ,
         S_MATNR   FOR CDHDR-OBJECTID            ,
         S_WERKS   FOR MARC-WERKS                ,
         S_VKORG   FOR MVKE-VKORG                ,
         S_VTWEG   FOR MVKE-VTWEG                ,
         S_TABNAM  FOR CDPOS-TABNAME             ,
         S_FNAME   FOR CDPOS-FNAME               ,
         S_CHGIND  FOR CDPOS-CHNGIND             ,
         S_DATE    FOR CDHDR-UDATE               ,
         S_USER    FOR CDHDR-USERNAME            .
SELECTION-SCREEN END OF BLOCK GENERAL.
SELECTION-SCREEN END OF BLOCK A.
*Data  : G_WERKS LIKE MARC-WERKS                 ,
       G_VKORG LIKE MVKE-VKORG                 ,
       G_VTWEG LIKE MVKE-VTWEG                 ,
       G_DESC  LIKE MARAV-MAKTX                .
TYPES  : BEGIN           OF   TY_FOR_DISP        ,
         OBJCLASS        LIKE CDHDR-OBJECTCLAS   ,
         OBJID           LIKE CDHDR-OBJECTID     ,
         WERKS           LIKE MARC-WERKS           ,
         VKORG           LIKE MVKE-VKORG         ,
         VTWEG           LIKE MVKE-VTWEG         ,                
         DESC            LIKE MARAV-MAKTX        ,
         TABNAME         LIKE CDPOS-TABNAME      ,
         FNAME           LIKE CDPOS-FNAME        ,
         CHNGIND         LIKE CDPOS-CHNGIND      ,
         UDATE           LIKE CDHDR-UDATE        ,
         USERNAME        LIKE CDHDR-USERNAME     ,
         VALUE_OLD       LIKE CDPOS-VALUE_OLD    ,
         VALUE_NEW       LIKE CDPOS-VALUE_NEW    ,
         END             OF   TY_FOR_DISP        .
TYPES  : BEGIN           OF   TY_CDHDR,
         OBJCLASS        LIKE CDHDR-OBJECTCLAS   ,
         OBJID           LIKE CDHDR-OBJECTID     ,
       CHNGIND         LIKE CDPOS-CHNGIND      ,
         CHANGENR        LIKE CDHDR-CHANGENR     ,
         UDATE           LIKE CDHDR-UDATE        ,
         USERNAME        LIKE CDHDR-USERNAME     ,
       VALUE_OLD       LIKE CDPOS-VALUE_OLD    ,
       VALUE_NEW       LIKE CDPOS-VALUE_NEW    ,
         END             OF   TY_CDHDR           .
TYPES  : BEGIN           OF   TY_CDPOS,
         TABNAME         LIKE CDPOS-TABNAME      ,
         FNAME           LIKE CDPOS-FNAME        ,
         CHANGENR        LIKE CDHDR-CHANGENR     ,
         CHNGIND         LIKE CDPOS-CHNGIND      ,
         TABKEY          LIKE CDPOS-TABKEY       ,
         FIELDTEXT       LIKE DFIES-FIELDTEXT,
       UDATE           LIKE CDPOS-UDATE        ,
       USERNAME        LIKE CDPOS-USERNAME     ,
         VALUE_OLD       LIKE CDPOS-VALUE_OLD    ,
         VALUE_NEW       LIKE CDPOS-VALUE_NEW    ,
         END             OF   TY_CDPOS           .
DATA   : T_FOR_DISP      TYPE STANDARD TABLE OF TY_FOR_DISP
                         WITH HEADER LINE        ,
         T_CDHDR         TYPE STANDARD TABLE OF TY_CDHDR
                         WITH HEADER LINE        ,
         T_CDPOS         TYPE STANDARD TABLE OF TY_CDPOS
                          WITH HEADER LINE       .
DATA   : G_LANGU LIKE SY-LANGU,
         G_TABIX LIKE SY-TABIX,
         G_DATE  LIKE SY-DATUM.
DATA   : G_WERKS LIKE MARC-WERKS  ,
         G_VKORG LIKE MVKE-VKORG  ,
         G_VTWEG LIKE MVKE-VTWEG  ,
         G_DESC  LIKE MARAV-MAKTX .
*------ALV Grid Field Catalog Fields
DATA: T_FIELDCAT   TYPE SLIS_T_FIELDCAT_ALV,
      T_FIELDCAT_H LIKE T_FIELDCAT WITH HEADER LINE.
*------End
CONSTANTS : C_MATERIAL(10)    VALUE 'MATERIAL'   ,
            C_OBJCLASS(10)    VALUE 'OBJCLASS'   ,
            C_OBJECTID(8)     VALUE 'OBJID'      ,
            C_WERKS(5)        VALUE 'WERKS'      ,
            C_VKORG(5)        VALUE 'VKORG'      ,
            C_VTWEG(5)        VALUE 'VTWEG'      ,                
            C_DESC(4)         VALUE 'DESC'       ,
            C_TABNAME(7)      VALUE 'TABNAME'    ,
            C_FNAME(5)        VALUE 'FNAME'      ,
            C_CHNGIND(7)      VALUE 'CHNGIND'    ,
            C_UDATE(5)        VALUE 'UDATE'      ,
            C_USERNAME(8)     VALUE 'USERNAME'   ,
            C_VALUE_OLD(9)    VALUE 'VALUE_OLD'  ,
            C_VALUE_NEW(9)    VALUE 'VALUE_NEW'  .
*CONSTANTS: C_TABNAM_FOR_ALV_FM TYPE SLIS_TABNAME VALUE 'T_FOR_DISP'.
  INITIALIZATION   *****************
INITIALIZATION.
  CLEAR:  T_CDHDR,
          T_CDPOS,
          T_FIELDCAT,
          T_FIELDCAT_H,
          T_FOR_DISP.
  REFRESH:T_CDHDR,
          T_CDPOS.
CLEAR :  CDHDR,           " Change document header
          CDPOS.           " Change document items
****START-OF-SELECTION.
START-OF-SELECTION.
*-FETCHING DETAILS of Changes done
  PERFORM SUB_GET_DETAILS.
Get the field description.
PERFORM SUB_CALL_DDIF_FIELDINFO_GET.
****END-OF-SELECTION.
END-OF-SELECTION.
*--DISPLAYING DATA IN ALV
  PERFORM SUB_DISPLAY_ALV.
*&      Form  SUB_GET_DETAILS
   This subrouting is used to get Final output which will shown in
   ALV Grid From Table CDPOS.
FORM SUB_GET_DETAILS.
SELECT OBJECTCLAS
        OBJECTID
        CHANGENR
        UDATE
        USERNAME
        INTO TABLE T_CDHDR
        FROM CDHDR
WHERE  OBJECTCLAS IN S_OBJCLS
   AND  OBJECTID   IN S_MATNR
AND  TABNAME    IN S_TABNAM
AND  FNAME      IN S_FNAME
AND  CHNGIND    IN S_CHGIND
AND  UDATE      IN S_DATE
   AND  UDATE      IN S_DATE
   AND  USERNAME   IN S_USER  .
IF SY-SUBRC <> 0.
WRITE:/ TEXT-003.
ENDIF.
  LOOP AT T_CDHDR.
    CLEAR T_FOR_DISP.
  IF T_CDHDR-OBJCLASS = C_MATERIAL.
   SELECT SINGLE MAKTX
   INTO G_DESC
   FROM MARAV
   WHERE MATNR = T_CDHDR-OBJID+0(18)
     AND SPRAS = SY-LANGU.
  ENDIF.
    T_FOR_DISP-DESC = G_DESC.
    CLEAR G_DESC.
   CLEAR T_FOR_DISP.
    T_FOR_DISP-OBJCLASS = T_CDHDR-OBJCLASS   .
    T_FOR_DISP-OBJID    = T_CDHDR-OBJID      .
    T_FOR_DISP-UDATE    = T_CDHDR-UDATE      .
    T_FOR_DISP-USERNAME = T_CDHDR-USERNAME   .
*ENDIF.
   APPEND T_FOR_DISP.
ENDLOOP.
*ENDIF.
SELECT
       TABNAME
       FNAME
       CHANGENR
       CHNGIND
       TABKEY
     UDATE
     USERNAME
       VALUE_OLD
       VALUE_NEW
       FROM CDPOS
       INTO TABLE T_CDPOS
       FOR ALL ENTRIES IN T_CDHDR
     CDHDRCHANGENR = CDPOSCHANGENR
WHERE
       CHANGENR EQ T_CDHDR-CHANGENR
   AND TABNAME  IN S_TABNAM
   AND FNAME    IN S_FNAME
   AND CHNGIND  IN S_CHGIND         .
AND UDATE    IN S_DATE.
AND OBJECTID IN S_DATE
AND USERNAME IN S_USER           .
IF SY-SUBRC <> 0.
WRITE:/ TEXT-003.
ENDIF.
*CLEAR T_FOR_DISP.
READ TABLE T_CDPOS
      WITH KEY CHANGENR = T_CDHDR-CHANGENR.
CLEAR : G_WERKS,
         G_VKORG,
         G_VTWEG.
       G_DESC .
IF T_CDPOS-TABNAME  = 'MARC'.
             G_WERKS = T_CDPOS-TABKEY+21(4).
ENDIF.
      CHECK G_WERKS IN S_WERKS.
IF SY-SUBRC = 0.
  T_FOR_DISP-WERKS = G_WERKS.
ENDIF.
IF T_CDPOS-TABNAME  = 'MVKE'.
      G_VKORG = T_CDPOS-TABKEY+21(4).
ENDIF.
      CHECK G_VKORG IN S_VKORG.
    T_FOR_DISP-VKORG = G_VKORG.
      G_VTWEG = T_CDPOS-TABKEY+25(2).
      CHECK G_VTWEG IN S_VTWEG.
     T_FOR_DISP-VTWEG = G_VTWEG.
   T_FOR_DISP-TABNAME   = T_CDPOS-TABNAME.
   T_FOR_DISP-FNAME     = T_CDPOS-FNAME.
   T_FOR_DISP-CHNGIND   = T_CDPOS-CHNGIND.
   T_FOR_DISP-VALUE_OLD = T_CDPOS-VALUE_OLD.
   T_FOR_DISP-VALUE_NEW = T_CDPOS-VALUE_NEW.
  APPEND T_FOR_DISP.
ENDLOOP.
ENDLOOP.
CLEAR T_FOR_DISP.
ENDFORM.                    " SUB_GET_DETAILS
*&      Form  SUB_DISPLAY_ALV
This Subroutine is used to display data to ALV Grid from internal    *
tables T_CDHDR & T_CDPOS. which is filled in subroutine              *
SUB_GET_DETAILS                                                      *
FORM SUB_DISPLAY_ALV .
BREAK-POINT.
  DATA: l_layout     type slis_layout_alv,
        l_title      type lvc_title,
        l_repid      like sy-repid.
  l_repid = sy-repid.
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      I_PROGRAM_NAME         = l_repid
      I_INTERNAL_TABNAME     = 'TY_FOR_DISP'
      I_INCLNAME             = l_repid
    CHANGING
      CT_FIELDCAT            = T_FIELDCAT[]
    EXCEPTIONS
      INCONSISTENT_INTERFACE = 1
      PROGRAM_ERROR          = 2
      OTHERS                 = 3.
  IF SY-SUBRC <> 0.
  WRITE:/ 'ERROR IN CALLING ALV FM'.
  ENDIF.
*----Change Field Heading We move All field data from T_FIELDCAT To
*----another Internal table with header line namely T_FIELDCAT_H
*CLEAR T_FIELDCAT_H[].
REFRESH T_FIELDCAT_H[].
BREAK-POINT.
  MOVE T_FIELDCAT[] TO T_FIELDCAT_H[].
CLEAR G_TABIX.
LOOP AT T_FIELDCAT_H.
G_TABIX = SY-TABIX.
    CASE T_FIELDCAT_H-FIELDNAME.
      WHEN C_OBJCLASS.
        T_FIELDCAT_H-SELTEXT_L = TEXT-004.
        T_FIELDCAT_H-SELTEXT_M = TEXT-004.
        T_FIELDCAT_H-SELTEXT_S = TEXT-004.
       T_FIELDCAT_H-OUTPUTLEN = 15.
      WHEN C_OBJECTID.
        T_FIELDCAT_H-SELTEXT_L = TEXT-005.
        T_FIELDCAT_H-SELTEXT_M = TEXT-005.
        T_FIELDCAT_H-SELTEXT_S = TEXT-005.
       T_FIELDCAT_H-OUTPUTLEN = 20.
      WHEN C_DESC.
        T_FIELDCAT_H-SELTEXT_L = TEXT-006.
        T_FIELDCAT_H-SELTEXT_M = TEXT-006.
        T_FIELDCAT_H-SELTEXT_S = TEXT-006.
       T_FIELDCAT_H-OUTPUTLEN = 20.
      WHEN C_WERKS.
        T_FIELDCAT_H-SELTEXT_L = TEXT-007.
        T_FIELDCAT_H-SELTEXT_M = TEXT-007.
        T_FIELDCAT_H-SELTEXT_S = TEXT-007.
       T_FIELDCAT_H-OUTPUTLEN = 20.
      WHEN C_VKORG.
        T_FIELDCAT_H-SELTEXT_L = TEXT-008.
        T_FIELDCAT_H-SELTEXT_M = TEXT-008.
        T_FIELDCAT_H-SELTEXT_S = TEXT-008.
       T_FIELDCAT_H-OUTPUTLEN = 20.
      WHEN C_VTWEG.
        T_FIELDCAT_H-SELTEXT_L = TEXT-009.
        T_FIELDCAT_H-SELTEXT_M = TEXT-009.
        T_FIELDCAT_H-SELTEXT_S = TEXT-009.
       T_FIELDCAT_H-OUTPUTLEN = 20.
      WHEN C_TABNAME.
        T_FIELDCAT_H-SELTEXT_L = TEXT-010.
        T_FIELDCAT_H-SELTEXT_M = TEXT-010.
        T_FIELDCAT_H-SELTEXT_S = TEXT-010.
       T_FIELDCAT_H-OUTPUTLEN = 20.
      WHEN C_FNAME.
        T_FIELDCAT_H-SELTEXT_L = TEXT-011.
        T_FIELDCAT_H-SELTEXT_M = TEXT-011.
        T_FIELDCAT_H-SELTEXT_S = TEXT-011.
       T_FIELDCAT_H-OUTPUTLEN = 20.
      WHEN C_CHNGIND.
        T_FIELDCAT_H-SELTEXT_L = TEXT-012.
        T_FIELDCAT_H-SELTEXT_M = TEXT-012.
        T_FIELDCAT_H-SELTEXT_S = TEXT-012.
       T_FIELDCAT_H-OUTPUTLEN = 20.
      WHEN C_UDATE.
        T_FIELDCAT_H-SELTEXT_L = TEXT-013.
        T_FIELDCAT_H-SELTEXT_M = TEXT-013.
        T_FIELDCAT_H-SELTEXT_S = TEXT-013.
       T_FIELDCAT_H-OUTPUTLEN = 20.
      WHEN C_USERNAME.
        T_FIELDCAT_H-SELTEXT_L = TEXT-014.
        T_FIELDCAT_H-SELTEXT_M = TEXT-014.
        T_FIELDCAT_H-SELTEXT_S = TEXT-014.
       T_FIELDCAT_H-OUTPUTLEN = 20.
      WHEN C_VALUE_OLD.
        T_FIELDCAT_H-SELTEXT_L = TEXT-015.
        T_FIELDCAT_H-SELTEXT_M = TEXT-015.
        T_FIELDCAT_H-SELTEXT_S = TEXT-015.
       T_FIELDCAT_H-OUTPUTLEN = 20.
      WHEN C_VALUE_NEW.
        T_FIELDCAT_H-SELTEXT_L = TEXT-016.
        T_FIELDCAT_H-SELTEXT_M = TEXT-016.
        T_FIELDCAT_H-SELTEXT_S = TEXT-016.
       T_FIELDCAT_H-OUTPUTLEN = 20.
      WHEN OTHERS.
    CONTINUE.
    ENDCASE.
    MODIFY T_FIELDCAT_H.
   CLEAR  T_FIELDCAT_H.
  ENDLOOP.
*BREAK-POINT.
  MOVE T_FIELDCAT_H[] TO T_FIELDCAT[].
*----End
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       exporting
            i_callback_program       = l_repid
          i_callback_pf_status_set = 'SET_STATUS'
          i_callback_user_command  = 'USER_COMMAND'
           i_callback_top_of_page   = 'TOP_OF_PAGE'
           i_grid_title             = l_title
           is_layout                = l_layout
             it_fieldcat              = t_fieldcat
           i_save                   = 'A'
       tables
            t_outtab                 = T_FOR_DISP[]
       exceptions
            program_error            = 1
            others                   = 2.
IF SY-SUBRC <> 0.
   WRITE:/ TEXT-017.
ENDIF.
ENDFORM.                    " SUB_DISPLAY_ALV
*&      Form  TOP_OF_PAGE
   This subrouting is used to show heading to ALV Grid. This
   subrouting is called from subrouting 'SUB_DISPLAY_ALV', Function
  'REUSE_ALV_GRID_DISPLAY' & export param 'i_callback_top_of_page'
*Form TOP_OF_PAGE.
DATA :  L_HEADER   TYPE SLIS_T_LISTHEADER,
         L_HEADER_H TYPE SLIS_LISTHEADER.
DATA :   L_FROMDAT(10) TYPE C,
          L_TODATE(10)  TYPE C.
*CONSTANTS : C_DOT(1) TYPE C     VALUE '.',
           C_L_HEADER_H_TYP(1) VALUE 'H'.   "---ALV Grid Header Type
CLEAR : L_HEADER.
**--To Manage Date Format
CONCATENATE S_DATE-LOW+6(2)
             C_DOT
             S_DATE-LOW+4(2)
             C_DOT
             S_DATE-LOW+0(4)
        INTO L_FROMDAT.
CONCATENATE S_DATE-HIGH+6(2)
             C_DOT
             S_DATE-HIGH+4(2)
             C_DOT
             S_DATE-HIGH+0(4)
        INTO L_TODATE.
**---End
IF L_TODATE <> '00.00.0000'.
   CONCATENATE 'Purchase Org:'(014)
               S_VKORG-LOW
               'PO changes from'(015)
               L_FROMDAT
               'To'(013)
               L_TODATE
               INTO L_HEADER_H-INFO SEPARATED BY SPACE.
ELSE.
    G_DATE = SY-DATUM.
   CONCATENATE 'CHANGES: '
                G_DATE
               INTO L_HEADER_H-INFO SEPARATED BY SPACE.
ENDIF.
Main report header
L_HEADER_H-TYP = C_L_HEADER_H_TYP.
APPEND L_HEADER_H TO L_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
   EXPORTING
     IT_LIST_COMMENTARY = L_HEADER
     I_LOGO             = ''.
*ENDFORM.                    "TOP_OF_PAGE
Plz look into this and suggest me ..thanks a lot.
  • Error While ALV Grid is exported to Excel. Update:10-11

    Hi Experts, I get an error OBJECTS_NOT_CHARLIKE , while I try to download an ALV Grid , to an excel file using the standard icon Export  present on the ALV Grid. Regards. Edited by: sunitha j on May 19, 2009 1:15 PMThis happens when your output list

  • Error in ALV grid Update:11-30

    Hi ALV masters, Plz help me .. I have an ALV grid report where i have the data in my final table t_final. now i'm trying to populate the fieldcat using FM reuse_alv_fieldcatalog_merge but its not at all getting populated. CALL FUNCTION 'REUSE_ALV_FIE

  • Error when double clicking any field in Alv grid Update:10-11

    Hi All, I have created a custom container. To that custom container I am displaying an alv grid with all editable fields using oops concept. Hence when I am double clicking on any on the field of the table I am getting a dump " an exception condition

  • Runtime error while trying to execute custom F4 help in OOP ALV grid. Update:10-11

    Dear All, I am trying to add custom search help for one of my column in ALV grid. I'm using OOP ALV, when i click for search help for that column, the system shows runtime error like below. I am new to OOP concept and tried to follow program BCALV_ED

  • Run-time error while executing alv grid report Update:10-11

    Hi everyone I m trying to run a alv grid report it is giving a run time error while executing the statement CALL METHOD V_ALV->SET_TOOLBAR_INTERACTIVE. Actually i added 2 buttons in the toolbar.after that when i execute the report i m getting errors.

  • Display error message in ALV grid  using OOPS Update:10-11

    Hi, I have a requirement to display report in ALV. I have created ALV grid using OOPS with three editable cells and 1 button on toolbar. When user enter values in Ediatble cell  and click on the Toolbar button, sales order item should be assigned to

  • Error in field catalog in ALV grid display using classes at do_sum = "X'. Update:10-11

    Hi, I'm using classes in ALV Grid display. the code for the field catalog is going to dump because of the statement in the field catalog for field 'netwr',do_sum = 'X'. that do_sum = 'X' is not working and going to dump when executed.with out that do

  • CL_SALV_BS_TT_RESULT_TABLE====CP error while downloading data from ALV grid Update:10-11

    Hi , I am  facing a problem when ever i am going to donload data from ALV grid to excel file.I am getting CL_SALV_BS_TT_RESULT_TABLE====CP error in GET_CELL_VALUE. Could you please provide me is there any OSS note or any patch required to solve this

  • Error in clicking save to local file button in alv grid? Update:10-11

    Hi I am getting error , While clicking on some buttons like save as local file button in alv grid display How to rectify it Thanks in advanceIn your REUSE_ALV_GRID_DISPLAY  EXPORTING       I_SAVE                  = 'U' put this field....and then chec

  • Error in clicking save to local file button in alv grid? urgent Update:10-11

    >>>>>       if lr_tabledescr->applies_to_data( <coltab_any> ) eq 'X'.  exactly i am getting error here how to rectify this error Error in clicking save to local file button and mail receipt button in alv grid?In your REUSE_ALV_GRID