Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to use ALV for Hierarchical Lists

Former Member
0 Kudos

Hi All,

I am satish, trying to get the hierarchical list using REUSE_ALV_HIERSEQ_LIST_DISPLAY function module. But it is going to dump. I couldn't find out where is mistake. So please any one help me to do this.

This is the code.

tables: vbak,vbap.

type-pools slis.

DATA: thead like vbak OCCURS 0,

titem like vbap occurs 0,

G_REPID LIKE SY-REPID,

ls_fieldcat TYPE slis_fieldcat_alv.

select * from vbak into table thead up to 5 rows.

select * from vbap into table titem up to 5 rows.

g_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

I_INTERFACE_CHECK = 'I'

I_CALLBACK_PROGRAM = g_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • IS_LAYOUT =

IT_FIELDCAT = ls_fieldcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_DEFAULT = 'X'

I_SAVE = 'A'

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • I_TABNAME_HEADER = 'VBAK'

  • I_TABNAME_ITEM = 'VBAP'

I_STRUCTURE_NAME_HEADER = 'vbak'

I_STRUCTURE_NAME_ITEM = 'vbap'

  • IS_KEYINFO =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB_HEADER = Thead

T_OUTTAB_ITEM = titem.

Thanks & Regards,

Satish.

7 REPLIES 7

laxmanakumar_appana
Active Contributor
0 Kudos

Hi,

Check this report:

BALVHD01

laxman

Former Member
0 Kudos

hi satish,

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

I_INTERFACE_CHECK = 'I'

I_CALLBACK_PROGRAM = g_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • IS_LAYOUT =

IT_FIELDCAT = ls_fieldcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_DEFAULT = 'X'

I_SAVE = 'A'

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • I_TABNAME_HEADER = 'VBAK'

  • I_TABNAME_ITEM = 'VBAP'

I_STRUCTURE_NAME_HEADER = <b>'VBAK'</b>

I_STRUCTURE_NAME_ITEM = <b>'VBAP'</b>

  • IS_KEYINFO =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB_HEADER = Thead

T_OUTTAB_ITEM = titem.

former_member188685
Active Contributor
0 Kudos
report  ZTEST_HIER line-count 65
                             line-size 200
                             no standard page heading
                             message-id zz.

type-pools: slis.

types: begin of ty_head,
      vbeln like vbak-vbeln,
      kunnr like vbak-kunnr,
      name  like kna1-name1,
      end of ty_head.

types: begin of ty_item,
       vbeln like vbap-vbeln,
       posnr like vbap-posnr,
       matnr like vbap-matnr,
       maktx like makt-maktx,
       check(1),
       end of ty_item.
data: it_item type table of ty_item.
data: it_header type table of ty_head,
       it_events type slis_t_event,          "Events.
       it_fieldcat      type slis_t_fieldcat_alv.

data: x_layout         type slis_layout_alv,
      x_fieldcat       type slis_fieldcat_alv,
<b>      x_key           type slis_keyinfo_alv,</b>
      x_events type slis_alv_event,      "Event
      x_vbeln like vbak-vbeln,
      x_item type ty_item.
constants: c_s(1) value '/'.
data: v_flag.
*---------------------------------------------------------------------*
*                   SELECTION-SCREEN                                  *
*---------------------------------------------------------------------*
selection-screen begin of block blk with frame title text-001.
parameters: p_vbeln like vbak-vbeln.      "Sales order Number
selection-screen end of block blk.

at selection-screen.
  if not p_vbeln is initial.
    select single vbeln
           into x_vbeln
           from vbak
           where vbeln = p_vbeln.
    if sy-subrc <> 0.
      message e002 with 'Please enter valid Sales Order'(020).
    endif.
  endif.
*----------------------------------------------------------------------*
*       CLASS lcl_bill_complete DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_bill_complete definition.
  public section.
    methods:get_header_data,
            get_item_data,
            show_data,
            fill_fieldcat,
            fill_events,
            top_of_page.
endclass.                    "lcl_bill_complete DEFINITION
*----------------------------------------------------------------------*
*       CLASS lcl_bill_complete IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_bill_complete implementation.
  method get_header_data.
    select vbak~vbeln
           vbak~kunnr
           kna1~name1
           into table it_header
           from vbak join kna1
           on vbak~kunnr = kna1~kunnr
           where vbak~vbeln = p_vbeln.
  endmethod.                    "get_header_data
  method get_item_data.
    select vbap~vbeln
           vbap~posnr
           vbap~matnr
           makt~maktx
           into corresponding fields of table it_item
           from vbap join makt
           on vbap~matnr = makt~matnr
           where vbap~vbeln = p_vbeln
            and  makt~spras = 'EN'.
  endmethod.                    "get_item_data

  method show_data.
<b>    x_key-header01 = 'VBELN'.

    x_key-item01   = 'VBELN'.
    x_key-item02   = 'POSNR'.</b>


    call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
      exporting
        i_callback_program       = sy-repid
        is_layout                = x_layout
        it_fieldcat              = it_fieldcat[]
<b>        i_tabname_header         = 'IT_HEADER'
        i_tabname_item           = 'IT_ITEM'</b>
<b>        is_keyinfo               = x_key</b>
        it_events                = it_events
      tables
        t_outtab_header          = it_header
        t_outtab_item            = it_item
      exceptions
        program_error            = 1
        others                   = 2.
  endmethod.                    "show_data
  method fill_fieldcat.
    data: l_pos type i.
    x_layout-header_text      = 'HEADER'.
    x_layout-item_text        = 'ITEM'.
    x_layout-default_item     = ' '.
    x_layout-no_keyfix        = 'X'.
    x_layout-box_tabname      = 'IT_ITEM'.

    l_pos = l_pos + 1.
*- Sales Order Number
    x_fieldcat-fieldname   = 'VBELN'.
    x_fieldcat-tabname    = 'IT_HEADER'.
    x_fieldcat-seltext_m   = 'Sales Order'(017).
    x_fieldcat-outputlen  = 11.
    x_fieldcat-col_pos     = l_pos.
    append x_fieldcat to it_fieldcat.
    clear  x_fieldcat.
    l_pos = l_pos + 1.

    x_fieldcat-fieldname   = 'KUNNR'.
    x_fieldcat-tabname    = 'IT_HEADER'.
    x_fieldcat-seltext_m   = 'Sold-to Party'(010).
    x_fieldcat-outputlen  = 13.
    x_fieldcat-col_pos     = l_pos.
    append x_fieldcat to it_fieldcat.
    clear  x_fieldcat.
    l_pos = l_pos + 1.

    x_fieldcat-fieldname   = 'NAME'.
    x_fieldcat-tabname    = 'IT_HEADER'.
    x_fieldcat-outputlen  = 15.
    x_fieldcat-seltext_m   = 'Sold-to name'(011).
    x_fieldcat-col_pos     = l_pos.
    append x_fieldcat to it_fieldcat.
    clear  x_fieldcat.
    l_pos = l_pos + 1.

    x_fieldcat-fieldname   = 'CHECK'.
    x_fieldcat-tabname    = 'IT_ITEM'.
    x_fieldcat-checkbox   = 'X'.
    x_fieldcat-input  = 'X'.
    x_fieldcat-edit  = 'X'.
    x_fieldcat-seltext_m   = ' '.
    x_fieldcat-outputlen  = 2.
    x_fieldcat-col_pos     = l_pos.
    append x_fieldcat to it_fieldcat.
    clear  x_fieldcat.
    l_pos = l_pos + 1.
    x_fieldcat-fieldname   = 'VBELN'.
    x_fieldcat-tabname    = 'IT_ITEM'.
    x_fieldcat-seltext_m   = 'Sales Order'(017).
    x_fieldcat-outputlen  = 11.
    x_fieldcat-tech = 'X'.
    x_fieldcat-col_pos     = l_pos.
    append x_fieldcat to it_fieldcat.
    clear  x_fieldcat.
    l_pos = l_pos + 1.
*- Sales Order Item
    x_fieldcat-fieldname   = 'POSNR'.
    x_fieldcat-tabname    = 'IT_ITEM'.
    x_fieldcat-seltext_m   = 'SO Item'(018).
    x_fieldcat-outputlen  = 7.
    x_fieldcat-col_pos     = l_pos.
    append x_fieldcat to it_fieldcat.
    clear  x_fieldcat.
    l_pos = l_pos + 1.

    x_fieldcat-fieldname   = 'MATNR'.
    x_fieldcat-tabname    = 'IT_ITEM'.
    x_fieldcat-outputlen  = 18.
    x_fieldcat-seltext_m   = 'Material number'(012).
    x_fieldcat-col_pos     = l_pos.
    append x_fieldcat to it_fieldcat.
    clear  x_fieldcat.
    l_pos = l_pos + 1.

    x_fieldcat-fieldname   = 'MAKTX'.
    x_fieldcat-tabname    = 'IT_ITEM'.
    x_fieldcat-outputlen  = 40.
    x_fieldcat-seltext_m   = 'Material Description'(013).
    x_fieldcat-col_pos     = l_pos.
    append x_fieldcat to it_fieldcat.
    clear  x_fieldcat.

  endmethod.                    "fill_fieldcat
*--Fill the events table
  method fill_events.
*-  Top of page
    x_events-name =  'TOP_OF_PAGE'.
    x_events-form =  'TOP_OF_PAGE'.
    append x_events to it_events.
  endmethod.                    "fill_events
"fill_events
  method top_of_page.
*-  Call Steelcase Standard Header
write 'top_of_page here'.
  endmethod.                    "top_of_page
endclass.                    "lcl_bill_complete IMPLEMENTATION

start-of-selection.
  data: obj type ref to lcl_bill_complete.
  create object obj.
  call method obj->get_header_data.
  call method obj->get_item_data.
  call method obj->fill_fieldcat.
  call method obj->fill_events.
  call method obj->show_data.
*&---------------------------------------------------------------------*
*&      Form  top_of_page
*&---------------------------------------------------------------------*
*      TOP_OF_PAGE
*----------------------------------------------------------------------*
form top_of_page.
*-To show the top of page
  call method obj->top_of_page.
endform.                    "top_of_page

try to see the bold code.

Regards

Vijay

Former Member
0 Kudos

Hi satish,

check this sample code:

REPORT ZKEERTHI_ALV4 .

&----


*& tables declaration

&----


tables: vbak.

&----


*& type-pools declaration

&----


type-pools: slis.

&----


*& data declaration

&----


data: g_repid type sy-repid.

DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV, "mara

WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,

X_KEYINFO TYPE SLIS_KEYINFO_ALV,

IT_HEADER TYPE SLIS_TABNAME,

IT_ITEM TYPE SLIS_TABNAME. .

DATA: BEGIN OF IT_VBAK occurs 0,

VBELN LIKE VBAK-VBELN,

AUDAT LIKE VBAK-AUDAT,

AUART LIKE VBAK-AUART,

NETWR LIKE VBAK-NETWR,

END OF IT_VBAK.

DATA: BEGIN OF IT_VBAP OCCURS 0,

VBELN LIKE VBAP-VBELN,

POSNR LIKE VBAP-POSNR,

MATNR LIKE VBAP-MATNR,

CHARG LIKE VBAP-CHARG,

PSTYV LIKE VBAP-PSTYV,

END OF IT_VBAP.

&----


*& initialisation

&----


initialization.

g_repid = sy-repid.

IT_HEADER = 'IT_VBAK'.

IT_ITEM = 'IT_VBAP'.

CLEAR X_KEYINFO.

X_KEYINFO-HEADER01 = 'VBELN'.

" comparing the keys and relating the header and item internal tables

X_KEYINFO-ITEM01 = 'VBELN'.

X_KEYINFO-HEADER02 = SPACE.

X_KEYINFO-ITEM02 = 'POSNR'.

&----


*& selection screen

&----


selection-screen begin of block b with frame title text-001.

select-options: s_vbeln for vbak-vbeln,

s_auart for vbak-auart.

selection-screen end of block b.

&----


*& start of selection

&----


start-of-selection.

perform get_vbak.

perform get_vbap.

&----


*& Form get_vbak

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_vbak .

select vbeln

audat

auart

netwr from vbak

into table it_vbak

where vbeln in s_vbeln and

auart in s_auart.

ENDFORM. " get_vbak

&----


*& Form get_vbap

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_vbap .

select vbeln

posnr

matnr

charg

pstyv from vbap

into table it_vbap

for all entries in it_vbak

where vbeln = it_vbak-vbeln.

ENDFORM. " get_vbap

&----


*& end of selection

&----


end-of-selection.

perform modify_fieldcat.

PERFORM HIERARCHICAL_LIST.

&----


*& Form modify_fieldcat

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM modify_fieldcat .

clear wa_fieldcat.

WA_FIELDCAT-TABNAME = 'IT_VBAK'.

WA_FIELDCAT-FIELDNAME = 'VBELN'.

WA_FIELDCAT-SELTEXT_L = 'DOC NO'.

WA_FIELDCAT-COL_POS = 1.

WA_FIELDCAT-OUTPUTLEN = 10.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_VBAK'.

WA_FIELDCAT-FIELDNAME = 'AUDAT'.

WA_FIELDCAT-SELTEXT_L = 'DOC DATE'.

WA_FIELDCAT-COL_POS = 2.

WA_FIELDCAT-OUTPUTLEN = 8.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_VBAK'.

WA_FIELDCAT-FIELDNAME = 'AUART'.

WA_FIELDCAT-SELTEXT_L = 'DOC TYPE'.

WA_FIELDCAT-COL_POS = 3.

WA_FIELDCAT-OUTPUTLEN = 4.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_VBAK'.

WA_FIELDCAT-FIELDNAME = 'NETWR'.

WA_FIELDCAT-SELTEXT_L = 'DOC NO'.

WA_FIELDCAT-COL_POS = 4.

WA_FIELDCAT-OUTPUTLEN = 15.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_VBAP'.

WA_FIELDCAT-FIELDNAME = 'VBELN'.

WA_FIELDCAT-SELTEXT_L = 'DOC NO'.

WA_FIELDCAT-OUTPUTLEN = 10.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_VBAP'.

WA_FIELDCAT-FIELDNAME = 'POSNR'.

WA_FIELDCAT-SELTEXT_L = 'SALES ITEM'.

WA_FIELDCAT-OUTPUTLEN = 6.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_VBAP'.

WA_FIELDCAT-FIELDNAME = 'MATNR'.

WA_FIELDCAT-SELTEXT_L = 'MAT NO'.

WA_FIELDCAT-OUTPUTLEN = 18.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_VBAP'.

WA_FIELDCAT-FIELDNAME = 'CHARG'.

WA_FIELDCAT-SELTEXT_L = 'BATCH NO'.

WA_FIELDCAT-OUTPUTLEN = 10.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-TABNAME = 'IT_VBAP'.

WA_FIELDCAT-FIELDNAME = 'PSTYV'.

WA_FIELDCAT-SELTEXT_L = 'ITEM CAT'.

WA_FIELDCAT-OUTPUTLEN = 4.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

ENDFORM. " modify_fieldcat

&----


*& Form HIERARCHICAL_LIST

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM HIERARCHICAL_LIST .

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

I_CALLBACK_PROGRAM = G_REPID

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • IS_LAYOUT =

IT_FIELDCAT = IT_FIELDCAT

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

I_TABNAME_HEADER = IT_HEADER

I_TABNAME_ITEM = IT_ITEM

  • I_STRUCTURE_NAME_HEADER =

  • I_STRUCTURE_NAME_ITEM =

IS_KEYINFO = X_KEYINFO

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB_HEADER = it_vbak

T_OUTTAB_ITEM = it_vbap

  • 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.

regards,

keerthi.

0 Kudos

Hi KEERTHI,

Thanks a lot

Regards

satish

Former Member
0 Kudos

Hi,

Add following code in your program and just try it out.

DATA: IT_HEADER TYPE SLIS_TABNAME,

IT_ITEM TYPE SLIS_TABNAME.

INITIALIZATION.

G_REPID = SY-REPID.

IT_HEADER = 'THEAD'.

IT_ITEM = 'TITEM'.

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = g_repid

IT_FIELDCAT = ls_fieldcat

I_TABNAME_HEADER = IT_HEADER

I_TABNAME_ITEM = IT_ITEM

TABLES

T_OUTTAB_HEADER = Thead

T_OUTTAB_ITEM = titem.

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.

Thanks,

Pramod

Former Member
0 Kudos

HI Satish,

Check this code.

report zxxx_alvexer4 message-id zz .

&----


*& TABLES DECLARATION *

&----


tables: vbak, vbap.

&----


*& TYPE POOLS DECLARATION *

&----


type-pools: slis.

----


  • DATA DECLARATIONS *

----


data: v_flag type c. "Flag to display the header

data: v_repid type sy-repid.

&----


*& INTERNAL TABLE DECLARATION *

&----


data: begin of it_vbak occurs 0,

vbeln like vbak-vbeln,

audat like vbak-audat,

auart like vbak-auart,

netwr like vbak-netwr,

expand(1),

end of it_vbak.

data: begin of it_vbap occurs 0,

vbeln like vbap-vbeln,

posnr like vbap-posnr,

matnr like vbap-matnr,

pstyv like vbap-pstyv,

charg like vbap-charg,

end of it_vbap.

data: it_fldcat type slis_t_fieldcat_alv,

it_fldcat1 type slis_t_fieldcat_alv,

*events

it_events type slis_t_event with header line,

v_call type c,

x_user type slis_exit_by_user,

it_variant like disvariant occurs 0 with header line,

x_keyinfo type slis_keyinfo_alv,

*layout

x_layout type slis_layout_alv,

*sort

it_sort type slis_t_sortinfo_alv,

wa_sort like line of it_sort,

x_cat type slis_fieldcat_alv,

v_tabix like sy-tabix.

----


  • Selection screen Declaration

----


*--BLOCK1

selection-screen begin of block b1 with frame title text-001.

select-options: s_vbeln for vbak-vbeln,

s_auart for vbak-auart.

selection-screen end of block b1.

----


  • AT SELECTION-SCREEN *

----


*- Validations

at selection-screen.

perform validate_screen.

----


  • START OF SELECTION *

----


start-of-selection.

*- To get data from VBAK

perform get_data.

*to get data from VBAP

perform get_data_vbap.

perform prepare_alv.

----


  • END OF SELECTION *

----


end-of-selection.

perform display_report.

&----


*& Form VALIDATE_SCREEN

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form validate_screen .

data: lv_vbeln like vbak-vbeln,

lv_auart like vbak-auart.

if not s_vbeln[] is initial.

select vbeln

into lv_vbeln

from vbak

where vbeln in s_vbeln.

endselect.

if sy-subrc <> 0.

message e000 with 'INVALID SALES DOC'(002).

endif.

endif.

if not s_auart[] is initial.

select auart

into lv_auart

from vbak

where auart in s_auart.

endselect.

if sy-subrc <> 0.

message e000 with 'INVALID SALES DOC TYPE'(003).

endif.

endif.

endform. " VALIDATE_SCREEN

&----


*& Form GET_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_data .

select vbeln

audat

auart

netwr

from vbak

into table it_vbak

where vbeln in s_vbeln

and auart in s_auart.

if sy-subrc = 0.

sort it_vbak by vbeln.

endif.

endform. " GET_DATA

&----


*& Form GET_DATA_VBAP

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_data_vbap .

select vbeln

posnr

matnr

pstyv

charg

into table it_vbap

from vbap

for all entries in it_vbak

where vbeln = it_vbak-vbeln.

if sy-subrc = 0.

sort it_vbap by vbeln posnr.

endif.

endform. " GET_DATA_VBAP

&----


*& Form prepare_alv

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form prepare_alv .

  • Prepare field catalog .

perform prepare_catalog.

  • Modify catalog

perform change_attr_of_catalog.

  • Modify Layout

perform modify_layout.

  • Sort Catalog

perform sort_catalog.

endform. " prepare_alv

&----


*& Form prepare_catalog

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form prepare_catalog .

call function 'REUSE_ALV_FIELDCATALOG_MERGE'

exporting

i_program_name = sy-repid

i_internal_tabname = 'IT_VBAK'

i_inclname = sy-repid

changing

ct_fieldcat = it_fldcat1[]

exceptions

inconsistent_interface = 1

program_error = 2

others = 3.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

append lines of it_fldcat1 to it_fldcat.

clear: it_fldcat1[].

call function 'REUSE_ALV_FIELDCATALOG_MERGE'

exporting

i_program_name = sy-repid

i_internal_tabname = 'IT_VBAP'

i_inclname = sy-repid

changing

ct_fieldcat = it_fldcat1[]

exceptions

inconsistent_interface = 1

program_error = 2

others = 3.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

append lines of it_fldcat1 to it_fldcat.

endform. " prepare_catalog

&----


*& Form change_attr_of_catalog

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form change_attr_of_catalog .

loop at it_fldcat into x_cat.

v_tabix = sy-tabix.

case x_cat-fieldname.

when 'EXPAND'.

if x_cat-tabname = 'IT_VBAK'.

x_cat-no_out = 'X'.

endif.

  • when 'VBELN'.

  • if x_cat-tabname = 'IT_VBAK'.

  • x_cat-no_out = 'X'.

  • endif.

when 'VBELN'.

if x_cat-tabname = 'IT_VBAK'.

x_cat-col_pos = '1'.

x_cat-seltext_m = 'SALES DOC'.

x_cat-seltext_l = 'SALES DOC'.

x_cat-seltext_s = 'SALES DOC'.

x_cat-outputlen = '10'.

endif.

when 'AUDAT'.

if x_cat-tabname = 'IT_VBAK'.

x_cat-col_pos = '2'.

x_cat-seltext_m = 'DOC DATE'.

x_cat-seltext_l = 'DOC DATE'.

x_cat-seltext_s = 'DOC DATE'.

x_cat-outputlen = '8'.

endif.

when 'AUART'.

if x_cat-tabname = 'IT_VBAK'.

x_cat-col_pos = '3'.

x_cat-seltext_m = 'ORDER REASON'.

x_cat-seltext_l = 'ORDER REASON'.

x_cat-seltext_s = 'ORDER REASON'.

x_cat-outputlen = '5'.

endif.

when 'NETWR'.

if x_cat-tabname = 'IT_VBAK'.

x_cat-col_pos = '4'.

x_cat-seltext_m = 'NET PRICE'.

x_cat-seltext_l = 'NET PRICE'.

x_cat-seltext_s = 'NET PRICE'.

x_cat-outputlen = '15'.

endif.

endcase.

modify it_fldcat from x_cat.

clear x_cat.

endloop.

endform. " change_attr_of_catalog

&----


*& Form modify_layout

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form modify_layout .

x_layout-default_item = 'X'.

x_layout-zebra = 'X'.

x_layout-expand_fieldname = 'EXPAND'.

endform. " modify_layout

&----


*& Form sort_catalog

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form sort_catalog .

clear wa_sort.

wa_sort-spos = '01'.

wa_sort-fieldname = 'VBELN' .

wa_sort-tabname = 'IT_VBAP'.

wa_sort-up = 'X'.

append wa_sort to it_sort.

clear wa_sort.

wa_sort-spos = '02'.

wa_sort-fieldname = 'POSNR' .

wa_sort-tabname = 'IT_VBAP'.

wa_sort-up = 'X'.

append wa_sort to it_sort.

endform. " sort_catalog

&----


*& Form DISPLAY_REPORT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form display_report .

it_variant-report = sy-repid.

sort it_vbak by vbeln.

sort it_vbap by vbeln posnr.

call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

exporting

i_callback_program = sy-repid

is_layout = x_layout

it_fieldcat = it_fldcat[]

it_sort = it_sort

is_variant = it_variant

it_events = it_events[]

i_tabname_header = 'IT_VBAK'

i_tabname_item = 'IT_VBAP'

is_keyinfo = x_keyinfo

importing

e_exit_caused_by_caller = v_call

es_exit_caused_by_user = x_user

tables

t_outtab_header = it_vbak

t_outtab_item = it_vbap

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.

Regards,

Plz reward points and close the thread,

Laxmi.