Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

ALV

Hi,

This is example program for intractive report, here if i click basic list it will go to secondary list.

How i can do the same program in ALV. if any body know please help me

REPORT ZE0232_CLIENT .

WRITE:'BASIC LIST'.

AT LINE-SELECTION.

IF SY-LSIND = 1.

WRITE: 'THIS IS SECONDARY LIST'.

ENDIF.

Tags:
Former Member
Former Member replied

Hi,

Check this sample code..

TYPE-POOLS: slis.
DATA: BEGIN OF itab1 OCCURS 0,
        vbeln TYPE vbeln,
        bstnk TYPE vbak-bstnk,
        erdat TYPE vbak-erdat,
        kunnr TYPE vbak-kunnr,
      END OF itab1.

DATA: BEGIN OF itab2 OCCURS 0,
        vbeln  TYPE vbeln,
        matnr  TYPE vbap-matnr,
        netpr  TYPE vbap-netpr,
        kwmeng TYPE vbap-kwmeng,
      END OF itab2.


DATA: t_fieldcatalog1 TYPE slis_t_fieldcat_alv.
DATA: t_fieldcatalog2 TYPE slis_t_fieldcat_alv.
DATA: v_repid         TYPE syrepid.


v_repid = sy-repid.

* Get the fieldcatalog1
PERFORM get_fieldcat1.

* Get the fieldcatalog2
PERFORM get_fieldcat2.


SELECT vbeln bstnk erdat kunnr UP TO 10 ROWS
       INTO TABLE itab1
       FROM vbak.

IF NOT itab1[] IS INITIAL.
  SELECT vbeln matnr netpr kwmeng UP TO 10 ROWS
         INTO TABLE itab2
         FROM vbap
         FOR ALL ENTRIES IN itab1
         WHERE vbeln = itab1-vbeln.

ENDIF.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
     EXPORTING
          i_callback_program      = v_repid
          i_callback_user_command = 'DISPLAY_DETAIL'
          it_fieldcat             = t_fieldcatalog1
     TABLES
          t_outtab                = itab1.

*---------------------------------------------------------------------*
*       FORM display_detail                                           *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  UCOMM                                                         *
*  -->  SELFIELD                                                      *
*---------------------------------------------------------------------*
FORM display_detail USING ucomm LIKE sy-ucomm
                        selfield TYPE slis_selfield.

  DATA: itab2_temp LIKE itab2 OCCURS 0 WITH HEADER LINE.

  IF ucomm = '&IC1'.

    READ TABLE itab1 INDEX selfield-tabindex.

    IF sy-subrc = 0.

      LOOP AT itab2 WHERE vbeln = itab1-vbeln.
        MOVE itab2 TO itab2_temp.
        APPEND itab2_temp.
      ENDLOOP.

      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
           EXPORTING
                i_callback_program = v_repid
                it_fieldcat        = t_fieldcatalog2
           TABLES
                t_outtab           = itab2_temp.

    ENDIF.

  ENDIF.

ENDFORM.

*---------------------------------------------------------------------*
*       FORM GET_FIELDCAT1                                            *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM get_fieldcat1.

  DATA: s_fieldcatalog TYPE slis_fieldcat_alv.

  s_fieldcatalog-col_pos = '1'.
  s_fieldcatalog-fieldname = 'VBELN'.
  s_fieldcatalog-tabname   = 'ITAB1'.
  s_fieldcatalog-rollname  = 'VBELN'.
  s_fieldcatalog-hotspot   = 'X'.
  APPEND s_fieldcatalog TO t_fieldcatalog1.
  CLEAR s_fieldcatalog.

  s_fieldcatalog-col_pos = '2'.
  s_fieldcatalog-fieldname = 'BSTNK'.
  s_fieldcatalog-tabname   = 'ITAB1'.
  s_fieldcatalog-rollname  = 'BSTNK'.
  APPEND s_fieldcatalog TO t_fieldcatalog1.
  CLEAR s_fieldcatalog.

  s_fieldcatalog-col_pos = '3'.
  s_fieldcatalog-fieldname = 'ERDAT'.
  s_fieldcatalog-tabname   = 'ITAB1'.
  s_fieldcatalog-rollname  = 'ERDAT'.
  APPEND s_fieldcatalog TO t_fieldcatalog1.
  CLEAR s_fieldcatalog.

  s_fieldcatalog-col_pos = '4'.
  s_fieldcatalog-fieldname = 'KUNNR'.
  s_fieldcatalog-tabname   = 'ITAB1'.
  s_fieldcatalog-rollname  = 'KUNNR'.
  APPEND s_fieldcatalog TO t_fieldcatalog1.
  CLEAR s_fieldcatalog.

ENDFORM.
*
*---------------------------------------------------------------------*
*       FORM GET_FIELDCAT2                                            *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM get_fieldcat2.

  DATA: s_fieldcatalog TYPE slis_fieldcat_alv.

  s_fieldcatalog-col_pos = '1'.
  s_fieldcatalog-fieldname = 'VBELN'.
  s_fieldcatalog-tabname   = 'ITAB2'.
  s_fieldcatalog-rollname  = 'VBELN'.
  APPEND s_fieldcatalog TO t_fieldcatalog2.
  CLEAR s_fieldcatalog.

  s_fieldcatalog-col_pos = '2'.
  s_fieldcatalog-fieldname = 'MATNR'.
  s_fieldcatalog-tabname   = 'ITAB2'.
  s_fieldcatalog-rollname  = 'MATNR'.
  APPEND s_fieldcatalog TO t_fieldcatalog2.
  CLEAR s_fieldcatalog.

  s_fieldcatalog-col_pos = '3'.
  s_fieldcatalog-fieldname = 'NETPR'.
  s_fieldcatalog-tabname   = 'ITAB2'.
  s_fieldcatalog-rollname  = 'NETPR'.
  APPEND s_fieldcatalog TO t_fieldcatalog2.
  CLEAR s_fieldcatalog.

  s_fieldcatalog-col_pos = '4'.
  s_fieldcatalog-fieldname = 'KWMENG'.
  s_fieldcatalog-tabname   = 'ITAB2'.
  s_fieldcatalog-rollname  = 'KWMENG'.
  APPEND s_fieldcatalog TO t_fieldcatalog2.
  CLEAR s_fieldcatalog.
ENDFORM.

Thanks

Naren

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question