Skip to Content

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

using ALV

I want to display sales order items that show various fields and have other fields ready for input.The user can expand or collapse the sales order header lines to decide if they want to review the line item data. Fields are ready for input at both the header and item level :

How can I achieve this in ALV?

Tags:
Former Member
Former Member replied

Hi,

Check this sample for hierarchical ALV to display the sales order details..

TYPE-POOLS: slis.

DATA: BEGIN OF itab OCCURS 0,
        vbeln TYPE vbeln,
        expand,
      END OF itab.

DATA: BEGIN OF itab1 OCCURS 0,
        vbeln TYPE vbeln,
        posnr TYPE posnr,
        matnr TYPE matnr,
        netpr TYPE netpr,
      END OF itab1.

DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
DATA: s_fieldcatalog TYPE slis_fieldcat_alv.

s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname   = 'ITAB'.
s_fieldcatalog-rollname  = 'VBELN'.
s_fieldcatalog-outputlen = '12'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.

s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname   = 'ITAB1'.
s_fieldcatalog-rollname  = 'VBELN'.
s_fieldcatalog-outputlen = '12'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.

s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'POSNR'.
s_fieldcatalog-tabname   = 'ITAB1'.
s_fieldcatalog-rollname  = 'POSNR'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.

s_fieldcatalog-col_pos = '3'.
s_fieldcatalog-fieldname = 'MATNR'.
s_fieldcatalog-tabname   = 'ITAB1'.
s_fieldcatalog-rollname  = 'MATNR'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.

s_fieldcatalog-col_pos = '4'.
s_fieldcatalog-fieldname = 'NETPR'.
s_fieldcatalog-tabname   = 'ITAB1'.
s_fieldcatalog-rollname  = 'NETPR'.
s_fieldcatalog-do_sum    = 'X'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.

DATA: s_layout TYPE slis_layout_alv.

s_layout-subtotals_text            = 'SUBTOTAL TEXT'.
s_layout-key_hotspot = 'X'.
s_layout-expand_fieldname = 'EXPAND'.


SELECT vbeln UP TO 100 ROWS
       FROM
       vbak
       INTO TABLE itab.


IF NOT itab[] IS INITIAL.

  SELECT vbeln posnr matnr netpr
         FROM vbap
         INTO TABLE itab1
         FOR ALL ENTRIES IN itab
         WHERE vbeln = itab-vbeln.

ENDIF.


DATA: v_repid TYPE syrepid.

v_repid = sy-repid.

DATA: s_keyinfo TYPE slis_keyinfo_alv.
s_keyinfo-header01 = 'VBELN'.
s_keyinfo-item01   = 'VBELN'.

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
     EXPORTING
          i_callback_program = v_repid
          is_layout          = s_layout
          it_fieldcat        = t_fieldcatalog
          i_tabname_header   = 'ITAB'
          i_tabname_item     = 'ITAB1'
          is_keyinfo         = s_keyinfo
     TABLES
          t_outtab_header    = itab
          t_outtab_item      = itab1
     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.

Thanks

Naren

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question