Skip to Content

statement is not accessible in call function

hi when i going to activate this alv report i m geting statement is not accessible please help me getting fix in this issue

*&---------------------------------------------------------------------*

*& Report  ZSG_ALV

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

REPORT  ZSG_ALV.

TABLEs: mara.

TYPE-POOLS : SLIS.

TYPES: BEGIN OF ty_mara,

        matnr TYPE matnr,

        mtart TYPE mtart,

        MBRSH TYPE MBRSH,

        matkl TYPE matkl,

        END OF ty_mara.

data : it_mara TYPE STANDARD TABLE OF ty_mara,

        wa_mara TYPE ty_mara,

        FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

        GD_REPID like sy-repid.

GD_REPID = SY-REPID.

SELECT-OPTIONS s_matnr for mara-matnr.

START-OF-SELECTION.

SELECT matnr mtart MBRSH matkl FROM mara into TABLE it_mara WHERE

matnr in s_matnr.

PERFORM build_fieldcatalog.

*&---------------------------------------------------------------------*

*&      Form  BUILD_FIELDCATALOG

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*  -->  p1        text

*  <--  p2        text

*----------------------------------------------------------------------*

form BUILD_FIELDCATALOG .

FIELDCATALOG-col_pos = 0.

FIELDCATALOG-fieldname = 'matnr'.

FIELDCATALOG-seltext_m = 'MATERIAL NO'.

APPEND FIELDCATALOG to FIELDCATALOG.

CLEAR FIELDCATALOG.

   FIELDCATALOG-col_pos = 1.

   FIELDCATALOG-fieldname = 'mtart'.

   FIELDCATALOG-seltext_m = 'MATERIAL TYPE'.

   APPEND FIELDCATALOG TO FIELDCATALOG.

   CLEAR FIELDCATALOG.

   FIELDCATALOG-col_pos = 2.

   FIELDCATALOG-fieldname = 'mbrsh'.

   FIELDCATALOG-seltext_m = 'Industry sector'.

   APPEND FIELDCATALOG TO FIELDCATALOG.

   CLEAR FIELDCATALOG.

   FIELDCATALOG-col_pos = 3.

   FIELDCATALOG-fieldname = 'matkl'.

   FIELDCATALOG-seltext_m = 'material group'.

   APPEND FIELDCATALOG TO FIELDCATALOG.

   CLEAR FIELDCATALOG.

endform.                    " BUILD_FIELDCATALOG

  PERFORM DISPLAY_ALV_REPORT.

*&---------------------------------------------------------------------*

*&      Form  DISPLAY_ALV_REPORT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*  -->  p1        text

*  <--  p2        text

*----------------------------------------------------------------------*

form DISPLAY_ALV_REPORT .

   CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

   EXPORTING

     i_callback_program = GD_REPID

*  is_layout          = w_layout

     it_fieldcat        = FIELDCATALOG[]

*  it_events          = i_events

   TABLES

     t_outtab           = it_mara

   EXCEPTIONS

     program_error      = 1

     OTHERS             = 2.

   IF sy-subrc <> 0.

     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

   ENDIF.

endform.                    " DISPLAY_ALV_REPORT

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Dec 26, 2014 at 02:13 PM

    Hi Sudip,

    Write the "GD_REPID = SY-REPID" either inside the Start-of-selection or inside INITIALIZATION event.

    And Give the Field Catalog-FIELNAME in CAPITAL Format.

    Regards.

    Praveer.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 26, 2014 at 04:35 PM

    hi sudip,

    there are two problems in this report

    1) PERFORM DISPLAY_ALV_REPORT. should be after


    PERFORM build_fieldcatalog.


    2) as said by praveen kumar sen



    ----------------------------working report is follows:


    REPORT  ZSG_ALV.

    TABLEs: mara.
    TYPE-POOLS : SLIS.
    TYPES: BEGIN OF ty_mara,
             matnr TYPE matnr,
             mtart TYPE mtart,
             MBRSH TYPE MBRSH,
             matkl TYPE matkl,
             END OF ty_mara.

      data : it_mara TYPE STANDARD TABLE OF ty_mara,
             wa_mara TYPE ty_mara,
             FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
             GD_REPID like sy-repid.
    GD_REPID = SY-REPID.

    SELECT-OPTIONS s_matnr for mara-matnr.
    START-OF-SELECTION.
    SELECT matnr mtart MBRSH matkl FROM mara into TABLE it_mara WHERE matnr in s_matnr.
     
    PERFORM build_fieldcatalog.
    PERFORM DISPLAY_ALV_REPORT.

    *&---------------------------------------------------------------------*
    *&      Form  BUILD_FIELDCATALOG
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    form BUILD_FIELDCATALOG .
    FIELDCATALOG-col_pos = 0.
    FIELDCATALOG-fieldname = 'MATNR'.
    FIELDCATALOG-seltext_m = 'MATERIAL NO'.
    FIELDCATALOG-OUTPUTLEN   = 20.
    APPEND FIELDCATALOG to FIELDCATALOG.
    CLEAR FIELDCATALOG.

        FIELDCATALOG-col_pos = 1.
        FIELDCATALOG-fieldname = 'MTART'.
        FIELDCATALOG-seltext_m = 'MATERIAL TYPE'.
        APPEND FIELDCATALOG TO FIELDCATALOG.
        CLEAR FIELDCATALOG.

        FIELDCATALOG-col_pos = 2.
        FIELDCATALOG-fieldname = 'MBRSH'.
        FIELDCATALOG-seltext_m = 'Industry sector'.
        APPEND FIELDCATALOG TO FIELDCATALOG.
        CLEAR FIELDCATALOG.

        FIELDCATALOG-col_pos = 3.
        FIELDCATALOG-fieldname = 'MATKL'.
        FIELDCATALOG-seltext_m = 'material group'.
        APPEND FIELDCATALOG TO FIELDCATALOG.
        CLEAR FIELDCATALOG.

    endform.                    " BUILD_FIELDCATALOG

    *&---------------------------------------------------------------------*
    *&      Form  DISPLAY_ALV_REPORT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    form DISPLAY_ALV_REPORT .

        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = GD_REPID
    *  is_layout          = w_layout
          it_fieldcat        = FIELDCATALOG[]
    *  it_events          = i_events
        TABLES
          t_outtab           = it_mara
        EXCEPTIONS
          program_error      = 1
          OTHERS             = 2.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.

    endform.                    " DISPLAY_ALV_REPORT

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 26, 2014 at 05:17 PM

    thank you it is working

    Add comment
    10|10000 characters needed characters exceeded