Skip to Content
-2

abap interactive report error !!

can someone help me i getting interactive report output..!

i am just learning please tell whats wrong and why i am not getting output..

REPORT zmanoj6.
TYPE-POOLS : slis.
TABLES : mara, makt.

TYPES : BEGIN OF ty,
          matnr TYPE matnr,
          ersda TYPE ersda,
          ernam TYPE ernam,
          laeda TYPE laeda,
          vpsta TYPE vpsta,
        END OF ty.


TYPES : BEGIN OF ty1,
          matnr TYPE matnr,
          spras TYPE spras,
          maktx TYPE maktx,
          maktg TYPE maktg,
        END OF ty1.

DATA : it  TYPE TABLE OF ty,
       wa  TYPE ty,
       it1 TYPE TABLE OF ty,
       wa1 TYPE ty.

DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
      wa_fieldcat TYPE slis_fieldcat_alv.

DATA: it_fieldcat1 TYPE slis_t_fieldcat_alv,
      wa_fieldcat1 TYPE slis_fieldcat_alv.

DATA : it_events TYPE slis_t_event,
       wa_events LIKE LINE OF it_events.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
PARAMETERS mat TYPE mara-matnr OBLIGATORY .
SELECTION-SCREEN END OF BLOCK b1.


START-OF-SELECTION.

  SELECT matnr,
         ersda,
         ernam,
         laeda,
         vpsta FROM mara INTO TABLE @DATA(it_mara)
         WHERE matnr EQ @mat.


  wa_fieldcat-fieldname = 'MATNR'.
  wa_fieldcat-ref_tabname = 'MARA'.
  wa_fieldcat-seltext_m = 'Accounting Document Number'.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.

  wa_fieldcat-fieldname = 'ERSDA'.
  wa_fieldcat-ref_tabname = 'MARA'.
  wa_fieldcat-seltext_m = 'Ating Document Number'.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.

  wa_fieldcat-fieldname = 'ERNAM'.
  wa_fieldcat-ref_tabname = 'MARA'.
  wa_fieldcat-seltext_m = 'Accounument Number'.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.

  wa_fieldcat-fieldname = 'LAEDA'.
  wa_fieldcat-ref_tabname = 'MARA'.
  wa_fieldcat-seltext_m = 'AccounNumber'.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.

  wa_fieldcat-fieldname = 'VPSTA'.
  wa_fieldcat-ref_tabname = 'MARA'.
  wa_fieldcat-seltext_m = 'Accounr'.
  APPEND wa_fieldcat TO it_fieldcat.
  CLEAR wa_fieldcat.


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_grid_title     = 'FIRST ALV'
      it_fieldcat      = it_fieldcat
      it_events        = it_events
      i_structure_name = 'TY_MARA'
    TABLES
      t_outtab         = it_mara.

  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    IMPORTING
      et_events = it_events.

  READ TABLE it_events INTO wa_events WITH KEY = 'user_command'.
  wa_events-form = 'FORM_USER_COMMAND'.
*  MODIFY it_events FROM wa_events INDEX sy-tabix.


FORM user_command USING r_ucomm LIKE sy-ucomm
                        rs_selfield TYPE slis_selfield.
  READ TABLE it_mara INTO wa INDEX rs_selfield-tabindex.

  SELECT matnr
         spras
         maktx
         maktg FROM makt INTO TABLE IT1 WHERE matnr = wa-matnr.


 CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_grid_title     = 'SECOND ALV'
      it_fieldcat      = it_fieldcat1
      it_events        = it_events
      i_structure_name = 'TY_MAKT'
    tables
      t_outtab         = it1.



  wa_fieldcat1-fieldname = 'MATNR'.
  wa_fieldcat1-ref_tabname = 'MAKT'.
  wa_fieldcat1-seltext_m = 'QQQQ'.
  APPEND wa_fieldcat1 TO it_fieldcat1.
  CLEAR wa_fieldcat1.

  wa_fieldcat1-fieldname = 'SPRAS'.
  wa_fieldcat1-ref_tabname = 'MAKT'.
  wa_fieldcat1-seltext_m = 'Accounr'.
  APPEND wa_fieldcat1 TO it_fieldcat1.
  CLEAR wa_fieldcat1.

  wa_fieldcat1-fieldname = 'MAKTX'.
  wa_fieldcat1-ref_tabname = 'MAKT'.
  wa_fieldcat1-seltext_m = 'AccoSSSr'.
  APPEND wa_fieldcat1 TO it_fieldcat1.
  CLEAR wa_fieldcat1.

  wa_fieldcat1-fieldname = 'MAKTG'.
  wa_fieldcat1-ref_tabname = 'MAKT'.
  wa_fieldcat1-seltext_m = 'Accounr'.
  APPEND wa_fieldcat1 TO it_fieldcat1.
  CLEAR wa_fieldcat1.

  endform.
Add comment
10|10000 characters needed characters exceeded

5 Answers

  • Best Answer
    Posted on 4 days ago

    Compare your coding to SAP Demo Reports, such as "BCALV_FULLSCREEN_DEMO" that utilise the FM REUSE_ALV_GRID_DISPLAY.

    Besides that, try moving to the object oriented ALV, like the class cl_gui_alv_grid and look at demo reports such as BCALV_GRID_DEMO" (or any other "BCALV_GRID_*" report).

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on 4 days ago

    Your code is full of obsolete commands.

    Goto developers.sap.com.
    There you'll find tutorials how to write ABAP today.

    e.g. https://developers.sap.com/group.abap-dev-repository-objects.html could be a good place to start.

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on 4 days ago
    INCLUDE ztest_sumanth_top.
    INCLUDE ztest_sumanth_sub.
    
    AT SELECTION-SCREEN OUTPUT.
      PERFORM disable_doctype.
    
    START-OF-SELECTION.
      PERFORM get_data.
    
    END-OF-SELECTION.
      PERFORM disp_data.
      
    *&---------------------------------------------------------------------*
    *&  Include           ZTEST_SUMANTH_TOP
    *&---------------------------------------------------------------------*
    
    TYPE-POOLS slis.
    DATA : v_ebeln TYPE ebeln,
           v_werks TYPE werks_d,
           v_erdat TYPE erdat.
    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS  : s_ebeln FOR v_ebeln,
                      s_werks FOR v_werks NO INTERVALS NO-EXTENSION,
                      s_erdat FOR v_erdat OBLIGATORY.
    PARAMETERS : p_esart TYPE esart DEFAULT 'UB'.
    SELECTION-SCREEN END OF BLOCK blk1.
    
    INITIALIZATION.
      s_erdat-sign = 'I'.
      s_erdat-option = 'BT'.
      s_erdat-low = '20200501'.
      s_erdat-high = sy-datum.
      APPEND s_erdat.
    
      TYPES : BEGIN OF ty_ekko,
                ebeln TYPE ebeln,
                erdat TYPE erdat,
                count TYPE i,
              END OF ty_ekko.
      DATA : it_ekko TYPE TABLE OF ty_ekko,
             wa_ekko TYPE          ty_ekko.
    
      TYPES : BEGIN OF ty_ekpo,
                ebeln TYPE ebeln,
                ebelp TYPE ebelp,
                werks TYPE werks_d,
                matnr TYPE matnr,
              END OF ty_ekpo.
      DATA : it_ekpo TYPE TABLE OF ty_ekpo,
             wa_ekpo TYPE          ty_ekpo.
    
      TYPES : BEGIN OF ty_makt,
                matnr TYPE matnr,
                maktx TYPE maktx,
              END OF ty_makt.
      DATA : it_makt TYPE TABLE OF ty_makt,
             wa_makt TYPE          ty_makt.
    
      TYPES : BEGIN OF ty_final,
                ebeln TYPE ebeln,
                count TYPE i,
              END OF ty_final.
      DATA : it_final TYPE TABLE OF ty_final,
             wa_final TYPE          ty_final.
    
      TYPES : BEGIN OF ty_final2,
                EBELN TYPE EBELN,
                ebelp TYPE ebelp,
                matnr TYPE matnr,
                maktx TYPE maktx,
              END OF ty_final2.
      DATA : gt_final TYPE TABLE OF ty_final2,
             gs_final TYPE          ty_final2.
    
      DATA : it_fcat TYPE slis_t_fieldcat_alv,
             wa_fcat TYPE slis_fieldcat_alv.
      DATA : gt_fcat TYPE slis_t_fieldcat_alv.
     
      *&---------------------------------------------------------------------*
    *&  Include           ZTEST_SUMANTH_SUB
    *&---------------------------------------------------------------------*
    *&---------------------------------------------------------------------*
    *&      Form  GET_DATA
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM get_data .
      DATA v_lines TYPE i.
      SELECT ebeln
             aedat
        FROM ekko
        INTO TABLE it_ekko
       WHERE ebeln IN s_ebeln
         AND aedat IN s_erdat
         AND bsart EQ p_esart.
    
      IF it_ekko IS NOT INITIAL.
        SELECT ebeln
               ebelp
               werks
         FROM ekpo
          INTO TABLE it_ekpo
          FOR ALL ENTRIES IN it_ekko
          WHERE ebeln EQ it_ekko-ebeln AND
                werks IN s_werks AND
                elikz NE 'X'.
      ENDIF.
    
    
      SORT it_ekko BY ebeln.
      LOOP AT it_ekpo INTO wa_ekpo.
        READ TABLE it_ekko INTO wa_ekko WITH KEY ebeln = wa_ekpo-ebeln BINARY SEARCH.
        IF sy-subrc IS INITIAL.
          wa_final-ebeln = wa_ekko-ebeln.
          wa_final-count  = 1.
        ENDIF.
        COLLECT wa_final INTO it_final.
        CLEAR : wa_final,wa_ekko,wa_ekpo.
      ENDLOOP.
    
    
    ENDFORM.
    *&---------------------------------------------------------------------*
    *&      Form  DISP_DATA
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM disp_data .
    
    
      PERFORM it_fcat USING '' 'EBELN' 'Purchase Doc No'.
      PERFORM it_fcat USING 'X' 'COUNT' 'Line Item Count'.
    
    
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program      = sy-repid
          i_callback_user_command = 'DBL_CLK'
          it_fieldcat             = it_fcat
        TABLES
          t_outtab                = it_final
        EXCEPTIONS
          program_error           = 1
          OTHERS                  = 2.
      IF sy-subrc <> 0.
    * Implement suitable error handling here
      ENDIF.
    ENDFORM.
    *&---------------------------------------------------------------------*
    *&      Form  DISABLE_DOCTYPE
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM disable_doctype .
      LOOP AT SCREEN..
        IF screen-name = 'P_ESART'.
          screen-input = 0.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
    ENDFORM.
    *&---------------------------------------------------------------------*
    *&      Form  IT_FCAT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      -->P_0113   text
    *      -->P_0114   text
    *      -->P_0115   text
    *----------------------------------------------------------------------*
    FORM it_fcat  USING    VALUE(p_0113)
                           VALUE(p_0114)
                           VALUE(p_0115).
      wa_fcat-hotspot = p_0113.
      wa_fcat-fieldname = p_0114.
      wa_fcat-seltext_l = p_0115.
      APPEND wa_fcat TO it_fcat.
      CLEAR wa_fcat.
    ENDFORM.
    
    FORM dbl_clk USING p_ucomm LIKE sy-ucomm
                       p_selfield TYPE slis_selfield.
      DATA : ebeln TYPE ebeln.
      CASE p_ucomm.
          ..
        WHEN '&IC1'.
          READ TABLE it_final INTO wa_final INDEX p_selfield-tabindex.
          IF sy-subrc IS INITIAL.
            ebeln = wa_final-ebeln.
            HIDE wa_final-ebeln.
            PERFORM item_data.
          ENDIF.
      ENDCASE.
    
    
    ENDFORM.
    *&---------------------------------------------------------------------*
    *&      Form  ITEM_DATA
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM item_data .
    
    
      DATA : ebeln TYPE ebeln.
      REFRESH : it_ekpo,gt_final.
      SELECT ebeln ebelp werks matnr
        FROM ekpo
        INTO TABLE it_ekpo
        WHERE ebeln EQ wa_final-ebeln.
      SORT it_ekpo BY ebeln.
    
    
      IF it_ekpo IS NOT INITIAL.
        SELECT matnr maktx FROM makt
          INTO TABLE it_makt
          FOR ALL ENTRIES IN it_ekpo
          WHERE matnr EQ it_ekpo-matnr.
        SORT it_makt BY matnr.
      ENDIF.
    
    
      LOOP AT it_ekpo INTO wa_ekpo.
        gs_final-ebelp = wa_ekpo-ebelp.
        gs_final-matnr = wa_ekpo-matnr.
        gs_final-ebeln = wa_ekpo-ebeln.
        READ TABLE it_makt INTO wa_makt WITH KEY matnr = gs_final-matnr BINARY SEARCH.
        IF sy-subrc IS INITIAL.
          gs_final-maktx = wa_makt-maktx.
        ENDIF.
        APPEND gs_final TO gt_final.
        CLEAR : gs_final,wa_makt,wa_ekpo,wa_final.
      ENDLOOP.
    
    
      PERFORM gt_fcat USING '' 'EBELP' 'Item No'.
      PERFORM gt_fcat USING '' 'MATNR' 'Mat.Code'.
      PERFORM gt_fcat USING '' 'MAKTX' 'MAt.Desc'.
    
    
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
    
          i_callback_program     = sy-repid
          i_callback_top_of_page = 'TOP_OF_PAGE'
          it_fieldcat            = gt_fcat
          i_screen_start_column  = 10
          i_screen_start_line    = 20
          i_screen_end_column    = 100
          i_screen_end_line      = 40
        TABLES
          t_outtab               = gt_final
        EXCEPTIONS
          program_error          = 1
          OTHERS                 = 2.
      IF sy-subrc <> 0.
    * Implement suitable error handling here
      ENDIF.
    ENDFORM.
    *&---------------------------------------------------------------------*
    *&      Form  GT_FCAT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      -->P_0352   text
    *      -->P_0353   text
    *      -->P_0354   text
    *----------------------------------------------------------------------*
    FORM gt_fcat  USING    VALUE(p_0352)
                           VALUE(p_0353)
                           VALUE(p_0354).
      wa_fcat-hotspot = p_0352.
      wa_fcat-fieldname = p_0353.
      wa_fcat-seltext_l = p_0354.
      APPEND wa_fcat TO gt_fcat.
      CLEAR wa_fcat.
    
    
    ENDFORM.
    FORM top_of_page.
      DATA : it_list TYPE slis_t_listheader,
             wa_list TYPE      slis_listheader.
      DATA : title(1000).
    
    
      READ TABLE gt_final INTO gs_final INDEX 1.
      CONCATENATE 'Item details of ' gs_final-ebeln INTO title SEPARATED BY space.
      wa_list-typ = 'H'.
      wa_list-info = title.
      APPEND wa_list TO it_list.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = it_list
    *     I_LOGO             =
    *     I_END_OF_LIST_GRID =
    *     I_ALV_FORM         =
        .
      REFRESH it_list.
    ENDFORM.
    

    Hi ,
    Please refer above program

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on 4 days ago

    kindly pass i_repid = sy-repid in reuse grid display function module

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on 4 days ago

    You can take the reference of attached report.

    Requirement:

    Sales Order Repot

    Select Option: Order No., Order Date, Customer ID

    First Level output:

    - Order No.

    - Order Date

    - Customer ID

    - Customer Name

    - Total order Value

    On click of Order No: Second level:

    • -Order No.
    • -Item No.
    • -Material Code
    • -Material Description
    • -Quantity
    • -Order Unit
    • -Item Value

    In the first level Output provide tool bar to show order Details:

    • -When button -Display VA03 tool to Display order Detail
    • -When come back from VA03 again first level display to be shown.

    Find attached .txt file.zsd-ord.txt


    zsd-ord.txt (20.3 kB)
    Add comment
    10|10000 characters needed characters exceeded