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: 

Can anyone send a code for REUSE_ALV_HIERSEQ_LIST_DISPLAY demo

Former Member
0 Kudos

Can you please send me a code regarding REUSE_ALV_HIERSEQ_LIST_DISPLAY demo

Thanks in Advance

1 ACCEPTED SOLUTION

Former Member
0 Kudos

REPORT ZALV5_OBJECTS.

TABLES : EKKO.

TYPE-POOLS : SLIS.

TYPES : BEGIN OF TY_EKKO,

EBELN TYPE EKPO-EBELN,

EBELP TYPE EKPO-EBELP,

STATU TYPE EKPO-STATU,

AEDAT TYPE EKPO-AEDAT,

MATNR TYPE EKPO-MATNR,

MENGE TYPE EKPO-MENGE,

MEINS TYPE EKPO-MEINS,

NETPR TYPE EKPO-NETPR,

PEINH TYPE EKPO-PEINH,

END OF TY_EKKO.

DATA: IT_EKKO TYPE STANDARD TABLE OF TY_EKKO INITIAL SIZE 0,

IT_EKPO TYPE STANDARD TABLE OF TY_EKKO INITIAL SIZE 0,

IT_EMPTYTAB TYPE STANDARD TABLE OF TY_EKKO INITIAL SIZE 0,

WA_EKKO TYPE TY_EKKO,

WA_EKPO TYPE TY_EKKO.

DATA: OK_CODE LIKE SY-UCOMM, "OK-Code

SAVE_OK LIKE SY-UCOMM.

*ALV data declarations

DATA: FIELDCATALOG TYPE LVC_T_FCAT WITH HEADER LINE.

DATA: GD_FIELDCAT TYPE LVC_T_FCAT,

GD_TAB_GROUP TYPE SLIS_T_SP_GROUP_ALV,

GD_LAYOUT TYPE SLIS_LAYOUT_ALV.

*ALVtree data declarations

CLASS CL_GUI_COLUMN_TREE DEFINITION LOAD.

CLASS CL_GUI_CFW DEFINITION LOAD.

DATA: GD_TREE TYPE REF TO CL_GUI_ALV_TREE,

GD_HIERARCHY_HEADER TYPE TREEV_HHDR,

GD_REPORT_TITLE TYPE SLIS_T_LISTHEADER,

GD_LOGO TYPE SDYDO_VALUE,

GD_VARIANT TYPE DISVARIANT.

*Create container for alv-tree

DATA: GD_TREE_CONTAINER_NAME(30) TYPE C,

GD_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.

************************************************************************

*Includes

*INCLUDE ZDEMO_ALVTREEO01. "Screen PBO Modules

*INCLUDE ZDEMO_ALVTREEI01. "Screen PAI Modules

*INCLUDE ZDEMO_ALVTREEF01. "ABAP Subroutines(FORMS)

************************************************************************

*Start-of-selection.

START-OF-SELECTION.

  • ALVtree setup data

PERFORM DATA_RETRIEVAL.

PERFORM BUILD_FIELDCATALOG.

PERFORM BUILD_LAYOUT.

PERFORM BUILD_HIERARCHY_HEADER CHANGING GD_HIERARCHY_HEADER.

PERFORM BUILD_REPORT_TITLE USING GD_REPORT_TITLE GD_LOGO.

PERFORM BUILD_VARIANT.

  • Display ALVtree report

  • CALL SCREEN 100.

&----


*& Form data_retrieval

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DATA_RETRIEVAL .

SELECT EBELN

UP TO 10 ROWS

FROM EKKO

INTO CORRESPONDING FIELDS OF TABLE IT_EKKO.

LOOP AT IT_EKKO INTO WA_EKKO.

SELECT EBELN EBELP STATU AEDAT MATNR MENGE MEINS NETPR PEINH

FROM EKPO

APPENDING TABLE IT_EKPO

WHERE EBELN EQ WA_EKKO-EBELN.

ENDLOOP.

ENDFORM. " data_retrieval

&----


*& Form build_fieldcatalog

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM BUILD_FIELDCATALOG .

  • Please not there are a number of differences between the structure of

  • ALVtree fieldcatalogs and ALVgrid fieldcatalogs.

  • For example the field seltext_m is replace by scrtext_m in ALVtree.

FIELDCATALOG-FIELDNAME = 'EBELN'. "Field name in itab

FIELDCATALOG-SCRTEXT_M = 'Purchase Order'. "Column text

FIELDCATALOG-COL_POS = 0. "Column position

FIELDCATALOG-OUTPUTLEN = 15. "Column width

FIELDCATALOG-EMPHASIZE = 'X'. "Emphasize (X or SPACE)

FIELDCATALOG-KEY = 'X'. "Key Field? (X or SPACE)

  • fieldcatalog-do_sum = 'X'. "Sum Column?

  • fieldcatalog-no_zero = 'X'. "Don't display if zero

APPEND FIELDCATALOG TO GD_FIELDCAT.

CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'EBELP'.

FIELDCATALOG-SCRTEXT_M = 'PO Iten'.

FIELDCATALOG-OUTPUTLEN = 15.

FIELDCATALOG-COL_POS = 1.

APPEND FIELDCATALOG TO GD_FIELDCAT..

CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'STATU'.

FIELDCATALOG-SCRTEXT_M = 'Status'.

FIELDCATALOG-OUTPUTLEN = 15.

FIELDCATALOG-COL_POS = 2.

APPEND FIELDCATALOG TO GD_FIELDCAT..

CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'AEDAT'.

FIELDCATALOG-SCRTEXT_M = 'Item change date'.

FIELDCATALOG-OUTPUTLEN = 15.

FIELDCATALOG-COL_POS = 3.

APPEND FIELDCATALOG TO GD_FIELDCAT..

CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'MATNR'.

FIELDCATALOG-SCRTEXT_M = 'Material Number'.

FIELDCATALOG-OUTPUTLEN = 15.

FIELDCATALOG-COL_POS = 4.

APPEND FIELDCATALOG TO GD_FIELDCAT..

CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'MENGE'.

FIELDCATALOG-SCRTEXT_M = 'PO quantity'.

FIELDCATALOG-OUTPUTLEN = 15.

FIELDCATALOG-COL_POS = 5.

APPEND FIELDCATALOG TO GD_FIELDCAT..

CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'MEINS'.

FIELDCATALOG-SCRTEXT_M = 'Order Unit'.

FIELDCATALOG-OUTPUTLEN = 15.

FIELDCATALOG-COL_POS = 6.

APPEND FIELDCATALOG TO GD_FIELDCAT..

CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'NETPR'.

FIELDCATALOG-SCRTEXT_M = 'Net Price'.

FIELDCATALOG-OUTPUTLEN = 15.

FIELDCATALOG-COL_POS = 7.

FIELDCATALOG-DATATYPE = 'CURR'.

APPEND FIELDCATALOG TO GD_FIELDCAT..

CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'PEINH'.

FIELDCATALOG-SCRTEXT_M = 'Price Unit'.

FIELDCATALOG-OUTPUTLEN = 15.

FIELDCATALOG-COL_POS = 8.

APPEND FIELDCATALOG TO GD_FIELDCAT..

CLEAR FIELDCATALOG.

ENDFORM. " build_fieldcatalog

&----


*& Form build_layout

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM BUILD_LAYOUT .

GD_LAYOUT-NO_INPUT = 'X'.

GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

GD_LAYOUT-TOTALS_TEXT = 'Totals'(201).

  • gd_layout-totals_only = 'X'.

  • gd_layout-f2code = 'DISP'. "Sets fcode for when double

  • "click(press f2)

  • gd_layout-zebra = 'X'.

  • gd_layout-group_change_edit = 'X'.

  • gd_layout-header_text = 'helllllo'

ENDFORM. " build_layout

&----


*& Form build_hierarchy_header

&----


  • text

----


  • <--P_GD_HIERARCHY_HEADER text

----


FORM BUILD_HIERARCHY_HEADER CHANGING

P_HIERARCHY_HEADER TYPE TREEV_HHDR.

P_HIERARCHY_HEADER-HEADING = 'Hierarchy Header'(013).

P_HIERARCHY_HEADER-TOOLTIP = 'This is the Hierarchy Header !'(014).

P_HIERARCHY_HEADER-WIDTH = 30.

P_HIERARCHY_HEADER-WIDTH_PIX = ''.

ENDFORM. " build_hierarchy_header

&----


*& Form build_report_title

&----


  • text

----


  • -->P_GD_REPORT_TITLE text

  • -->P_GD_LOGO text

----


FORM BUILD_REPORT_TITLE USING PT_REPORT_TITLE TYPE SLIS_T_LISTHEADER

P_GD_LOGO TYPE SDYDO_VALUE.

DATA: LS_LINE TYPE SLIS_LISTHEADER,

LD_DATE(10) TYPE C.

  • List Heading Line(TYPE H)

CLEAR LS_LINE.

LS_LINE-TYP = 'H'.

  • ls_line-key "Not Used For This Type(H)

LS_LINE-INFO = 'PO ALVTree Display'.

APPEND LS_LINE TO PT_REPORT_TITLE.

  • Status Line(TYPE S)

LD_DATE(2) = SY-DATUM+6(2).

LD_DATE+2(1) = '/'.

LD_DATE3(2) = SY-DATUM4(2).

LD_DATE+5(1) = '/'.

LD_DATE+6(4) = SY-DATUM(4).

LS_LINE-TYP = 'S'.

LS_LINE-KEY = 'Date'.

LS_LINE-INFO = LD_DATE.

APPEND LS_LINE TO PT_REPORT_TITLE.

  • Action Line(TYPE A)

CLEAR LS_LINE.

LS_LINE-TYP = 'A'.

CONCATENATE 'Report: ' SY-REPID INTO LS_LINE-INFO SEPARATED BY SPACE.

APPEND LS_LINE TO PT_REPORT_TITLE.

ENDFORM. " build_report_title

&----


*& Form build_variant

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM BUILD_VARIANT .

  • Set repid for storing variants

GD_VARIANT-REPORT = SY-REPID.

ENDFORM. " build_variant

<b>Reward points for useful Answers</b>

Kiran

5 REPLIES 5

Former Member
0 Kudos

Hi

See the sample code

REPORT ZBHALV_GRID.

TABLES:LFA1,EKKO.

SELECT-OPTIONS:LIFNR FOR LFA1-LIFNR.

DATA:BEGIN OF ITAB OCCURS 0,

LIFNR LIKE LFA1-LIFNR,

NAME1 LIKE LFA1-NAME1,

LAND1 LIKE LFA1-LAND1,

ORT01 LIKE LFA1-ORT01,

REGIO LIKE LFA1-REGIO,

SORTL LIKE LFA1-SORTL,

END OF ITAB.

*DATA:BEGIN OF JTAB OCCURS 0,

  • LIFNR LIKE EKKO-LIFNR,

  • EBELN LIKE EKKO-EBELN,

  • BUKRS LIKE EKKO-BUKRS,

  • BSTYP LIKE EKKO-BSTYP,

  • BSART LIKE EKKO-BSART,

*END OF JTAB.

DATA:JTAB LIKE EKKO OCCURS 0 WITH HEADER LINE.

SELECT * FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE LIFNR

IN LIFNR.

SELECT * FROM EKKO INTO CORRESPONDING FIELDS OF TABLE JTAB WHERE LIFNR

IN LIFNR.

TYPE-POOLS:SLIS.

DATA:FCAT TYPE SLIS_T_FIELDCAT_ALV.

DATA:KINFO TYPE SLIS_KEYINFO_ALV.

DATA:LAYOUT TYPE SLIS_LAYOUT_ALV.

DATA:EVE TYPE SLIS_T_EVENT WITH HEADER LINE.

DATA:HEAD TYPE SLIS_T_LISTHEADER WITH HEADER LINE.

LAYOUT-ZEBRA = 'X'.

LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

LAYOUT-WINDOW_TITLEBAR = 'VENDORS AND PURCHASE DOCCUMENTS

DETAILS'.

LAYOUT-numc_sum = 'X'.

KINFO-HEADER01 = 'LIFNR'.

KINFO-ITEM01 = 'LIFNR'.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = EVE[]

EXCEPTIONS

LIST_TYPE_WRONG = 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.

READ TABLE EVE WITH KEY NAME = 'TOP_OF_PAGE'.

EVE-FORM = 'TOPOFPAGE'.

MODIFY EVE TRANSPORTING FORM WHERE NAME = 'TOP_OF_PAGE'.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = SY-REPID

I_INTERNAL_TABNAME = 'ITAB'

  • I_STRUCTURE_NAME =

  • I_CLIENT_NEVER_DISPLAY = 'X'

I_INCLNAME = SY-REPID

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

CT_FIELDCAT = FCAT

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

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

I_CALLBACK_PROGRAM = SY-REPID

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

IS_LAYOUT = LAYOUT

IT_FIELDCAT = FCAT

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_SCREEN_START_COLUMN = 5

  • I_SCREEN_START_LINE = 5

  • I_SCREEN_END_COLUMN = 120

  • I_SCREEN_END_LINE = 25

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

IT_EVENTS = EVE[]

  • IT_EVENT_EXIT =

I_TABNAME_HEADER = 'ITAB'

I_TABNAME_ITEM = 'JTAB'

I_STRUCTURE_NAME_HEADER = 'LFA1'

I_STRUCTURE_NAME_ITEM = 'EKKO'

IS_KEYINFO = KINFO

  • 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 = ITAB[]

T_OUTTAB_ITEM = JTAB[]

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

FORM TOPOFPAGE.

REFRESH HEAD.

HEAD-TYP = 'H'.

HEAD-INFO = 'VENDORS & PURCHASE DOCC. DETAILS'.

APPEND HEAD.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = HEAD[]

  • I_LOGO = ' '

  • I_END_OF_LIST_GRID =

.

ENDFORM.

<b>Reward points for useful Answers</b>

Regards

Anji

Former Member
0 Kudos

Refer the following:

type-pools : slis.
Data : it_1 type table of mara ,
       it_event type SLIS_T_EVENT ,
       wa_event like line of it_event,
       it_header type SLIS_T_LISTHEADER ,
       wa_header like line of it_header.
 
 
 
start-of-selection.
 
select * into table it_1  " Select Data
from mara
up to 10 rows.
 
 
CALL FUNCTION 'REUSE_ALV_EVENTS_GET' " Get the list of events
* EXPORTING
*   I_LIST_TYPE           = 0
 IMPORTING
   ET_EVENTS             = it_event
* EXCEPTIONS
*   LIST_TYPE_WRONG       = 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.
 
read table it_event into wa_event with key name = 'TOP_OF_PAGE'.
 if sy-subrc = 0.
     wa_event-form = 'TOP_OF_PAGE'.
     MODIFY  IT_EVENT FROM WA_EVENT INDEX SY-TABIX.
 endif.
 
 
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'" call the alv
 EXPORTING
*   I_INTERFACE_CHECK              = ' '
*   I_BYPASSING_BUFFER             =
*   I_BUFFER_ACTIVE                = ' '
   I_CALLBACK_PROGRAM             = SY-REPID
*   I_CALLBACK_PF_STATUS_SET       = ' '
*   I_CALLBACK_USER_COMMAND        = ' '
   I_STRUCTURE_NAME               = 'MARA'
*   IS_LAYOUT                      =
*   IT_FIELDCAT                    =
*   IT_EXCLUDING                   =
*   IT_SPECIAL_GROUPS              =
*   IT_SORT                        =
*   IT_FILTER                      =
*   IS_SEL_HIDE                    =
*   I_DEFAULT                      = 'X'
*   I_SAVE                         = ' '
*   IS_VARIANT                     =
   IT_EVENTS                      = IT_EVENT
*   IT_EVENT_EXIT                  =
*   IS_PRINT                       =
*   IS_REPREP_ID                   =
*   I_SCREEN_START_COLUMN          = 0
*   I_SCREEN_START_LINE            = 0
*   I_SCREEN_END_COLUMN            = 0
*   I_SCREEN_END_LINE              = 0
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER        =
*   ES_EXIT_CAUSED_BY_USER         =
  TABLES
    T_OUTTAB                       = IT_1
* 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.
 
 
 
 
form TOP_OF_PAGE.
 
BREAK-POINT.
 
 
wa_header-typ = 'H'.
wa_header-info = 'test'.
APPEND wa_header to it_header.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY       = it_header
*         I_LOGO                   =
*         I_END_OF_LIST_GRID       =
*                .
.
 
endform.

Former Member
0 Kudos

REPORT ZALV5_OBJECTS.

TABLES : EKKO.

TYPE-POOLS : SLIS.

TYPES : BEGIN OF TY_EKKO,

EBELN TYPE EKPO-EBELN,

EBELP TYPE EKPO-EBELP,

STATU TYPE EKPO-STATU,

AEDAT TYPE EKPO-AEDAT,

MATNR TYPE EKPO-MATNR,

MENGE TYPE EKPO-MENGE,

MEINS TYPE EKPO-MEINS,

NETPR TYPE EKPO-NETPR,

PEINH TYPE EKPO-PEINH,

END OF TY_EKKO.

DATA: IT_EKKO TYPE STANDARD TABLE OF TY_EKKO INITIAL SIZE 0,

IT_EKPO TYPE STANDARD TABLE OF TY_EKKO INITIAL SIZE 0,

IT_EMPTYTAB TYPE STANDARD TABLE OF TY_EKKO INITIAL SIZE 0,

WA_EKKO TYPE TY_EKKO,

WA_EKPO TYPE TY_EKKO.

DATA: OK_CODE LIKE SY-UCOMM, "OK-Code

SAVE_OK LIKE SY-UCOMM.

*ALV data declarations

DATA: FIELDCATALOG TYPE LVC_T_FCAT WITH HEADER LINE.

DATA: GD_FIELDCAT TYPE LVC_T_FCAT,

GD_TAB_GROUP TYPE SLIS_T_SP_GROUP_ALV,

GD_LAYOUT TYPE SLIS_LAYOUT_ALV.

*ALVtree data declarations

CLASS CL_GUI_COLUMN_TREE DEFINITION LOAD.

CLASS CL_GUI_CFW DEFINITION LOAD.

DATA: GD_TREE TYPE REF TO CL_GUI_ALV_TREE,

GD_HIERARCHY_HEADER TYPE TREEV_HHDR,

GD_REPORT_TITLE TYPE SLIS_T_LISTHEADER,

GD_LOGO TYPE SDYDO_VALUE,

GD_VARIANT TYPE DISVARIANT.

*Create container for alv-tree

DATA: GD_TREE_CONTAINER_NAME(30) TYPE C,

GD_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.

************************************************************************

*Includes

*INCLUDE ZDEMO_ALVTREEO01. "Screen PBO Modules

*INCLUDE ZDEMO_ALVTREEI01. "Screen PAI Modules

*INCLUDE ZDEMO_ALVTREEF01. "ABAP Subroutines(FORMS)

************************************************************************

*Start-of-selection.

START-OF-SELECTION.

  • ALVtree setup data

PERFORM DATA_RETRIEVAL.

PERFORM BUILD_FIELDCATALOG.

PERFORM BUILD_LAYOUT.

PERFORM BUILD_HIERARCHY_HEADER CHANGING GD_HIERARCHY_HEADER.

PERFORM BUILD_REPORT_TITLE USING GD_REPORT_TITLE GD_LOGO.

PERFORM BUILD_VARIANT.

  • Display ALVtree report

  • CALL SCREEN 100.

&----


*& Form data_retrieval

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DATA_RETRIEVAL .

SELECT EBELN

UP TO 10 ROWS

FROM EKKO

INTO CORRESPONDING FIELDS OF TABLE IT_EKKO.

LOOP AT IT_EKKO INTO WA_EKKO.

SELECT EBELN EBELP STATU AEDAT MATNR MENGE MEINS NETPR PEINH

FROM EKPO

APPENDING TABLE IT_EKPO

WHERE EBELN EQ WA_EKKO-EBELN.

ENDLOOP.

ENDFORM. " data_retrieval

&----


*& Form build_fieldcatalog

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM BUILD_FIELDCATALOG .

  • Please not there are a number of differences between the structure of

  • ALVtree fieldcatalogs and ALVgrid fieldcatalogs.

  • For example the field seltext_m is replace by scrtext_m in ALVtree.

FIELDCATALOG-FIELDNAME = 'EBELN'. "Field name in itab

FIELDCATALOG-SCRTEXT_M = 'Purchase Order'. "Column text

FIELDCATALOG-COL_POS = 0. "Column position

FIELDCATALOG-OUTPUTLEN = 15. "Column width

FIELDCATALOG-EMPHASIZE = 'X'. "Emphasize (X or SPACE)

FIELDCATALOG-KEY = 'X'. "Key Field? (X or SPACE)

  • fieldcatalog-do_sum = 'X'. "Sum Column?

  • fieldcatalog-no_zero = 'X'. "Don't display if zero

APPEND FIELDCATALOG TO GD_FIELDCAT.

CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'EBELP'.

FIELDCATALOG-SCRTEXT_M = 'PO Iten'.

FIELDCATALOG-OUTPUTLEN = 15.

FIELDCATALOG-COL_POS = 1.

APPEND FIELDCATALOG TO GD_FIELDCAT..

CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'STATU'.

FIELDCATALOG-SCRTEXT_M = 'Status'.

FIELDCATALOG-OUTPUTLEN = 15.

FIELDCATALOG-COL_POS = 2.

APPEND FIELDCATALOG TO GD_FIELDCAT..

CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'AEDAT'.

FIELDCATALOG-SCRTEXT_M = 'Item change date'.

FIELDCATALOG-OUTPUTLEN = 15.

FIELDCATALOG-COL_POS = 3.

APPEND FIELDCATALOG TO GD_FIELDCAT..

CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'MATNR'.

FIELDCATALOG-SCRTEXT_M = 'Material Number'.

FIELDCATALOG-OUTPUTLEN = 15.

FIELDCATALOG-COL_POS = 4.

APPEND FIELDCATALOG TO GD_FIELDCAT..

CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'MENGE'.

FIELDCATALOG-SCRTEXT_M = 'PO quantity'.

FIELDCATALOG-OUTPUTLEN = 15.

FIELDCATALOG-COL_POS = 5.

APPEND FIELDCATALOG TO GD_FIELDCAT..

CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'MEINS'.

FIELDCATALOG-SCRTEXT_M = 'Order Unit'.

FIELDCATALOG-OUTPUTLEN = 15.

FIELDCATALOG-COL_POS = 6.

APPEND FIELDCATALOG TO GD_FIELDCAT..

CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'NETPR'.

FIELDCATALOG-SCRTEXT_M = 'Net Price'.

FIELDCATALOG-OUTPUTLEN = 15.

FIELDCATALOG-COL_POS = 7.

FIELDCATALOG-DATATYPE = 'CURR'.

APPEND FIELDCATALOG TO GD_FIELDCAT..

CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'PEINH'.

FIELDCATALOG-SCRTEXT_M = 'Price Unit'.

FIELDCATALOG-OUTPUTLEN = 15.

FIELDCATALOG-COL_POS = 8.

APPEND FIELDCATALOG TO GD_FIELDCAT..

CLEAR FIELDCATALOG.

ENDFORM. " build_fieldcatalog

&----


*& Form build_layout

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM BUILD_LAYOUT .

GD_LAYOUT-NO_INPUT = 'X'.

GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

GD_LAYOUT-TOTALS_TEXT = 'Totals'(201).

  • gd_layout-totals_only = 'X'.

  • gd_layout-f2code = 'DISP'. "Sets fcode for when double

  • "click(press f2)

  • gd_layout-zebra = 'X'.

  • gd_layout-group_change_edit = 'X'.

  • gd_layout-header_text = 'helllllo'

ENDFORM. " build_layout

&----


*& Form build_hierarchy_header

&----


  • text

----


  • <--P_GD_HIERARCHY_HEADER text

----


FORM BUILD_HIERARCHY_HEADER CHANGING

P_HIERARCHY_HEADER TYPE TREEV_HHDR.

P_HIERARCHY_HEADER-HEADING = 'Hierarchy Header'(013).

P_HIERARCHY_HEADER-TOOLTIP = 'This is the Hierarchy Header !'(014).

P_HIERARCHY_HEADER-WIDTH = 30.

P_HIERARCHY_HEADER-WIDTH_PIX = ''.

ENDFORM. " build_hierarchy_header

&----


*& Form build_report_title

&----


  • text

----


  • -->P_GD_REPORT_TITLE text

  • -->P_GD_LOGO text

----


FORM BUILD_REPORT_TITLE USING PT_REPORT_TITLE TYPE SLIS_T_LISTHEADER

P_GD_LOGO TYPE SDYDO_VALUE.

DATA: LS_LINE TYPE SLIS_LISTHEADER,

LD_DATE(10) TYPE C.

  • List Heading Line(TYPE H)

CLEAR LS_LINE.

LS_LINE-TYP = 'H'.

  • ls_line-key "Not Used For This Type(H)

LS_LINE-INFO = 'PO ALVTree Display'.

APPEND LS_LINE TO PT_REPORT_TITLE.

  • Status Line(TYPE S)

LD_DATE(2) = SY-DATUM+6(2).

LD_DATE+2(1) = '/'.

LD_DATE3(2) = SY-DATUM4(2).

LD_DATE+5(1) = '/'.

LD_DATE+6(4) = SY-DATUM(4).

LS_LINE-TYP = 'S'.

LS_LINE-KEY = 'Date'.

LS_LINE-INFO = LD_DATE.

APPEND LS_LINE TO PT_REPORT_TITLE.

  • Action Line(TYPE A)

CLEAR LS_LINE.

LS_LINE-TYP = 'A'.

CONCATENATE 'Report: ' SY-REPID INTO LS_LINE-INFO SEPARATED BY SPACE.

APPEND LS_LINE TO PT_REPORT_TITLE.

ENDFORM. " build_report_title

&----


*& Form build_variant

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM BUILD_VARIANT .

  • Set repid for storing variants

GD_VARIANT-REPORT = SY-REPID.

ENDFORM. " build_variant

<b>Reward points for useful Answers</b>

Kiran

Former Member
0 Kudos

Dear Vijay ,

Please find the code:

&----


*& Report ZRND_ALV *

*& *

&----


*& *

*& *

&----


*developed by saurabh just for exploring alv

REPORT ZRND_ALV NO STANDARD PAGE HEADING LINE-COUNT 40 LINE-SIZE 100

.

TYPE-POOLS:SLIS,ABAP,KKBLO.

TABLES: VBAP,VBAK.

DATA:BEGIN OF ITAB_HEADER OCCURS 0,

CHECK ,

VBELN LIKE VBAK-VBELN,

ERDAT LIKE VBAK-ERDAT,

END OF ITAB_HEADER.

DATA: COMMAND LIKE SY-UCOMM.

DATA: BEGIN OF ITAB_ITEM OCCURS 0,

  • CHECK ,

VBELN LIKE VBAP-VBELN,

POSNR LIKE VBAP-POSNR,

MATNR LIKE VBAP-MATNR,

CHARG LIKE VBAP-CHARG,

NETPR LIKE VBAP-NETPR,

WERKS LIKE VBAP-WERKS,

END OF ITAB_ITEM.

DATA: BEGIN OF IT_MARC OCCURS 0,

MATNR LIKE MARC-MATNR,

WERKS LIKE MARC-WERKS,

BWTAY LIKE MARC-BWTTY,

END OF IT_MARC.

DATA: L_EVENT TYPE SLIS_T_EVENT," OCCURS 0 WITH HEADER LINE.

LS_EVENT TYPE SLIS_ALV_EVENT.

DATA:ITAB_KEYINFO TYPE SLIS_KEYINFO_ALV OCCURS 0 WITH HEADER LINE.

*DATA:ITAB_FIELDCAT TYPE DD02L-TABNAME OCCURS 0 WITH HEADER LINE.

DATA:SLIS_T_FIELDCAT_ALV1 TYPE SLIS_T_FIELDCAT_ALV.

DATA:LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

DATA: LT_EXTAB TYPE KKBLO_T_EXTAB WITH HEADER LINE.

SELECTION-SCREEN BEGIN OF BLOCK BLK WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS:S_ERDAT FOR VBAK-ERDAT.

SELECTION-SCREEN END OF BLOCK BLK.

SELECT VBELN ERDAT FROM VBAK INTO CORRESPONDING FIELDS OF TABLE

ITAB_HEADER WHERE ERDAT IN S_ERDAT.

CHECK SY-SUBRC = 0.

SELECT * FROM VBAP INTO CORRESPONDING FIELDS OF TABLE ITAB_ITEM FOR ALL

ENTRIES IN ITAB_HEADER WHERE VBELN EQ ITAB_HEADER-VBELN.

PERFORM EVENTTAB USING L_EVENT[].

&----


*& Form eventtab

&----


  • text

----


  • -->P_L_EVENT[] text

----


FORM EVENTTAB USING LT_EVENT TYPE SLIS_T_EVENT.

DATA: LS_EVENT TYPE SLIS_ALV_EVENT.

DATA: FORMNAME TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.

DATA: FORMNAME1 TYPE SLIS_FORMNAME VALUE 'USER_COMMAND'.

DATA: FORMNAME2 TYPE SLIS_FORMNAME VALUE 'PF_STATUS'.

DATA: GT_SLIS_LAYO TYPE SLIS_LAYOUT_ALV.

DATA: GT_FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV.

DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

DATA: LS_KEY TYPE SLIS_KEYINFO_ALV.

LS_KEY-HEADER01 = 'VBELN'.

LS_KEY-ITEM01 = 'VBELN'.

  • LS_KEY-HEADER02 = 'CHECK'.

  • LS_KEY-ITEM02 = 'CHECK'.

GT_SLIS_LAYO-ZEBRA = 'X'.

  • GT_SLIS_LAYO-EDIT = 'X'.

  • GT_SLIS_LAYO-EDIT_MODE = 'X'.

GT_SLIS_LAYO-F2CODE = 'DUMMY'.

GT_SLIS_LAYO-NUMC_SUM = 'X'.

GT_SLIS_LAYO-DETAIL_POPUP = 'X'.

GT_SLIS_LAYO-CONFIRMATION_PROMPT = 'X'.

GT_SLIS_LAYO-BOX_FIELDNAME = 'CHECK'.

GT_SLIS_LAYO-BOX_TABNAME = 'ITAB_HEADER'.

  • gt_slis_layo-box_rollname = 'SPRAS'.

LS_FIELDCAT-FIELDNAME = 'VBELN'.

LS_FIELDCAT-TABNAME = 'ITAB_HEADER'.

LS_FIELDCAT-REF_FIELDNAME = 'VBELN'.

LS_FIELDCAT-REF_TABNAME = 'VBAK'.

APPEND LS_FIELDCAT TO GT_FIELDCATALOG.

  • ls_fieldcat-fieldname = 'CHECK'.

  • ls_fieldcat-tabname = 'ITAB_HEADER'.

  • LS_FIELDCAT-CHECKBOX = 'X'.

  • APPEND LS_FIELDCAT TO GT_FIELDCATALOG.

LS_FIELDCAT-FIELDNAME = 'VBELN'.

LS_FIELDCAT-TABNAME = 'ITAB_ITEM'.

LS_FIELDCAT-REF_FIELDNAME = 'VBELN'.

LS_FIELDCAT-REF_TABNAME = 'VBAP'.

  • ls_fieldcat-hotspot = 'X'.

  • ls_fieldcat-edit = 'X'.

APPEND LS_FIELDCAT TO GT_FIELDCATALOG.

LS_FIELDCAT-FIELDNAME = 'VBELN'.

LS_FIELDCAT-TABNAME = 'ITAB_ITEM'.

LS_FIELDCAT-REF_FIELDNAME = 'VBELN'.

LS_FIELDCAT-REF_TABNAME = 'VBAP'.

APPEND LS_FIELDCAT TO GT_FIELDCATALOG.

LS_FIELDCAT-FIELDNAME = 'POSNR'.

LS_FIELDCAT-TABNAME = 'ITAB_ITEM'.

LS_FIELDCAT-REF_FIELDNAME = 'POSNR'.

LS_FIELDCAT-REF_TABNAME = 'VBAP'.

APPEND LS_FIELDCAT TO GT_FIELDCATALOG.

LS_FIELDCAT-FIELDNAME = 'MATNR'.

LS_FIELDCAT-TABNAME = 'ITAB_ITEM'.

LS_FIELDCAT-REF_FIELDNAME = 'MATNR'.

LS_FIELDCAT-KEY = 'X'.

LS_FIELDCAT-REF_TABNAME = 'VBAP'.

APPEND LS_FIELDCAT TO GT_FIELDCATALOG.

LS_FIELDCAT-FIELDNAME = 'CHARG'.

LS_FIELDCAT-TABNAME = 'ITAB_ITEM'.

LS_FIELDCAT-REF_FIELDNAME = 'CHARG'.

LS_FIELDCAT-REF_TABNAME = 'VBAP'.

APPEND LS_FIELDCAT TO GT_FIELDCATALOG.

LS_FIELDCAT-FIELDNAME = 'NETPR'.

LS_FIELDCAT-TABNAME = 'ITAB_ITEM'.

LS_FIELDCAT-REF_FIELDNAME = 'NETPR'.

LS_FIELDCAT-DO_SUM = 'X'.

LS_FIELDCAT-REF_TABNAME = 'VBAP'.

APPEND LS_FIELDCAT TO GT_FIELDCATALOG.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = LT_EVENT

EXCEPTIONS

LIST_TYPE_WRONG = 1

OTHERS = 2.

READ TABLE LT_EVENT WITH KEY NAME = SLIS_EV_TOP_OF_PAGE INTO

LS_EVENT.

IF SY-SUBRC EQ 0.

MOVE FORMNAME TO LS_EVENT-FORM.

APPEND LS_EVENT TO LT_EVENT .

ENDIF.

CLEAR LS_EVENT.

READ TABLE LT_EVENT WITH KEY NAME = SLIS_EV_USER_COMMAND INTO LS_EVENT.

IF SY-SUBRC EQ 0.

MOVE FORMNAME1 TO LS_EVENT-FORM.

APPEND LS_EVENT TO LT_EVENT .

ENDIF.

CLEAR LS_EVENT.

READ TABLE LT_EVENT WITH KEY NAME = SLIS_EV_PF_STATUS_SET INTO LS_EVENT

.

IF SY-SUBRC EQ 0.

MOVE FORMNAME2 TO LS_EVENT-FORM.

APPEND LS_EVENT TO LT_EVENT .

ENDIF.

CLEAR: COMMAND.

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

IS_LAYOUT = GT_SLIS_LAYO

IT_FIELDCAT = GT_FIELDCATALOG

IT_EVENTS = LT_EVENT

I_TABNAME_HEADER = 'ITAB_HEADER'

I_TABNAME_ITEM = 'ITAB_ITEM'

IS_KEYINFO = LS_KEY

TABLES

T_OUTTAB_HEADER = ITAB_HEADER

T_OUTTAB_ITEM = ITAB_ITEM

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. " eventtab

*----


*----


*----


FORM USER_COMMAND USING USERCOMMAND LIKE COMMAND

LIST TYPE KKBLO_SELFIELD.

  • USERCOMMAND = SY-UCOMM.

CASE USERCOMMAND.

  • WHEN '&IC1'.

**WRITE : LIST-TABNAME , LIST-TABINDEX .

  • PERFORM DISPLAYS USING LIST-VALUE.

  • WHEN 'DETAILS' .

  • MESSAGE 'DUMMAY' TYPE 'I'.

WHEN 'DETAIL'.

PERFORM DISPLAY.

WHEN 'BACK'.

CALL SCREEN 1000.

LEAVE SCREEN.

WHEN 'DUMMY'.

MESSAGE 'CHOOSE A VALID FUNCTION CODE' TYPE 'I'.

ENDCASE.

ENDFORM. "USER_COMMAND

&----


*& Form DISPLAYS

&----


  • text

----


  • -->P_LIST_FIELDNAME text

----


FORM DISPLAYS USING FIELDVALUE.

*data: gt_slis_layo1 TYPE slis_layout_alv.

*gt_slis_layo1-

SELECT * FROM MARC INTO CORRESPONDING FIELDS OF TABLE IT_MARC .

  • WHERE MATNR EQ FIELDVALUE.

LOOP AT IT_MARC.

WRITE: /1 SY-VLINE, 2(18) IT_MARC-MATNR CENTERED,

20 SY-VLINE, 21(15) IT_MARC-WERKS CENTERED,

36 SY-VLINE, 37(14) IT_MARC-BWTAY CENTERED.

ENDLOOP.

ENDFORM. " DISPLAYS

*----


*----


*----


FORM PF_STATUS USING LT_EXTAB.

SET PF-STATUS 'FIRST'.

ENDFORM. "FORMNAME2

&----


*& Form DISPLAY

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DISPLAY .

DATA: LINES LIKE SY-TABIX.

DATA: FORMNAME4 TYPE SLIS_FORMNAME VALUE 'MODIFY_LIST'.

DATA: FORMNAME5 TYPE SLIS_FORMNAME VALUE 'PF_STATUS1'.

DATA: ITAB_ITEMLIST LIKE ITAB_ITEM OCCURS 0 WITH HEADER LINE.

DATA: ITAB_HEADERLIST LIKE ITAB_HEADER OCCURS 0 WITH HEADER LINE.

LOOP AT ITAB_HEADER WHERE CHECK EQ 'X'.

MOVE-CORRESPONDING ITAB_HEADER TO ITAB_HEADERLIST.

APPEND ITAB_HEADERLIST.

ENDLOOP.

CLEAR: ITAB_ITEMLIST,ITAB_ITEMLIST[].

ITAB_ITEMLIST[] = ITAB_ITEM[].

SORT ITAB_ITEM BY VBELN.

LOOP AT ITAB_ITEMLIST.

LINES = SY-TABIX.

READ TABLE ITAB_HEADERLIST WITH KEY VBELN = ITAB_ITEMLIST-VBELN.

IF SY-SUBRC <> 0.

DELETE ITAB_ITEMLIST INDEX LINES.

ENDIF.

ENDLOOP.

IF ITAB_ITEMLIST[] IS NOT INITIAL.

*data for displaying ther data

DATA:GT_SLIS_LAYO1 TYPE SLIS_LAYOUT_ALV.

DATA:GT_FIELDCATALOG1 TYPE SLIS_T_FIELDCAT_ALV.

*DATA: ls_fieldcat TYPE slis_fieldcat_alv.

CLEAR LS_FIELDCAT.

GT_SLIS_LAYO1-ZEBRA = 'X'.

  • gt_slis_layo1-edit = 'X'.

  • gt_slis_layo1-edit_mode = 'X'.

GT_SLIS_LAYO1-NUMC_SUM = 'X'.

LS_FIELDCAT-FIELDNAME = 'VBELN'.

LS_FIELDCAT-TABNAME = 'ITAB_ITEMLIST'.

LS_FIELDCAT-SELTEXT_L = 'SALES DOCUMENT'.

LS_FIELDCAT-SELTEXT_M = 'DOCUMENT'.

LS_FIELDCAT-SELTEXT_S = 'DOC'.

APPEND LS_FIELDCAT TO GT_FIELDCATALOG1.

LS_FIELDCAT-FIELDNAME = 'POSNR'.

LS_FIELDCAT-TABNAME = 'ITAB_ITEMLIST'.

LS_FIELDCAT-SELTEXT_L = 'ITEM'.

LS_FIELDCAT-SELTEXT_M = 'ITEM'.

LS_FIELDCAT-SELTEXT_S = 'ITEM'.

APPEND LS_FIELDCAT TO GT_FIELDCATALOG1.

LS_FIELDCAT-FIELDNAME = 'MATNR'.

LS_FIELDCAT-TABNAME = 'ITAB_ITEMLIST'.

LS_FIELDCAT-SELTEXT_L = 'MATERAIL'.

LS_FIELDCAT-SELTEXT_M = 'MATER'.

LS_FIELDCAT-SELTEXT_S = 'MAT'.

APPEND LS_FIELDCAT TO GT_FIELDCATALOG1.

LS_FIELDCAT-FIELDNAME = 'CHARG'.

LS_FIELDCAT-TABNAME = 'ITAB_ITEMLIST'.

LS_FIELDCAT-SELTEXT_L = 'CHARGE'.

LS_FIELDCAT-SELTEXT_M = 'CHARGE'.

LS_FIELDCAT-SELTEXT_S = 'CHARGE'.

LS_FIELDCAT-EDIT = 'X'.

APPEND LS_FIELDCAT TO GT_FIELDCATALOG1.

LS_FIELDCAT-FIELDNAME = 'NETPR'.

LS_FIELDCAT-TABNAME = 'ITAB_ITEMLIST'.

LS_FIELDCAT-SELTEXT_L = 'NET PRICE'.

LS_FIELDCAT-SELTEXT_M = 'NET P'.

LS_FIELDCAT-SELTEXT_S = 'NET'.

LS_FIELDCAT-EDIT = 'X'.

APPEND LS_FIELDCAT TO GT_FIELDCATALOG1.

CLEAR: LS_EVENT.

CLEAR: L_EVENT . REFRESH: L_EVENT.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = L_EVENT

EXCEPTIONS

LIST_TYPE_WRONG = 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.

READ TABLE L_EVENT WITH KEY SLIS_EV_LIST_MODIFY INTO LS_EVENT.

IF SY-SUBRC EQ 0.

MOVE FORMNAME4 TO LS_EVENT-FORM.

APPEND LS_EVENT TO L_EVENT.

ENDIF.

READ TABLE L_EVENT WITH KEY SLIS_EV_PF_STATUS_SET INTO LS_EVENT.

IF SY-SUBRC EQ 0.

MOVE FORMNAME5 TO LS_EVENT-FORM.

APPEND LS_EVENT TO L_EVENT.

ENDIF.

READ TABLE L_EVENT WITH KEY = SLIS_EV_USER_COMMAND INTO LS_EVENT.

IF SY-SUBRC EQ 0.

ENDIF.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = 'ZRND_ALV'

IS_LAYOUT = GT_SLIS_LAYO1

IT_FIELDCAT = GT_FIELDCATALOG1

IT_EVENTS = L_EVENT

TABLES

T_OUTTAB = ITAB_ITEMLIST

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

ENDIF.

ENDFORM. " DISPLAY

*----


*----


*----


*-

FORM PF_STATUS1 USING LT_EXTAB.

SET PF-STATUS 'SECOND'.

ENDFORM. "MODIFY_LIST

Former Member
0 Kudos

Hi,

Please refer the below code.

Define SORT table and FIELDCATALOG table .

Data :i_field type slis_t_fieldcat_alv,

w_field like line of i_field,

i_sort type slis_t_sortinfo_alv,

w_sort like line of i_sort.

2.Grand Total

While buildingfieldcatalog,We have to set DO_SUM = 'X' for quantity field .

ex.

w_field-fieldname = 'MENGE'.

w_field-tabname = 'I_TAB'.

w_field-DO_SUM = 'X'.

append w_field to i_field.

clear w_field.

3.Subtotal

Whenever WERKS is changed Subtotal is displayed .

Build sort table .

Clear: w_sort,i_sort[].

w_sort-spos = 1.

w_sort-fieldname = 'WERKS'.

w_sort-up = 'X'.

w_sort-subtot = 'X'.

append w_sort to i_sort.

clear w_sort.

4.

Pass this I_SORT table thru REUSE_ALV_LIST_DISPLAY function module ..like fieldcatalog table.

Or

For sub totals you need to sort and pass the sort table to FM.

But for total you need to pass to field catalog like below

fieldcatalog-fieldname = 'NETPR'.

fieldcatalog-seltext_m = 'Net Price'.

fieldcatalog-col_pos = 7.

fieldcatalog-outputlen = 15.

fieldcatalog-do_sum = 'X'. "Display column total

fieldcatalog-datatype = 'CURR'.

append fieldcatalog to fieldcatalog.

Thanks,

Bala.