Powered By

Free XML Skins for Blogger

Powered by Blogger

Wednesday, October 1, 2008

ABAP ALV HIRARCHIAL VIEWER Report Sample Code

****EXE PROGRAM-****
REPORT ZREPORT .

***TABLE WORK AREA****
TABLES:KNA1,VBAK.
***INTERNAL TABLE***
DATA:ITAB TYPE VBAK OCCURS 0,
****LOGIC FOR CUTOM CONTROL OF SCREEN 100 ****

CONTAINER TYPE SCRFNAME VALUE 'LVCONTROL',

CUST TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

TREE TYPE REF TO CL_GUI_ALV_TREE_SIMPLE,


CL_GUI_ALV_TREE_SIMPLE,

FCAT TYPE LVC_T_FCAT,

***DECLARE FOR THE INTERNL TABLE BODY AND WORK AREA***
SORT_B TYPE LVC_T_SORT,

SORT_W TYPE LVC_S_SORT.

CALL SCREEN 100.

FORM COL_HEAD.
***CALL FUNCTION LVC_FIELDCATLOG_MERGE'
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 'VBAK'

CHANGING
ct_fieldcat = FCAT.
ENDFORM.

***SUBROUTINE FOR OUTPUT
FORM OUTPUT.
SELECT * FROM VBAK INTO TABLE ITAB WHERE KUNNR = KNA1-KUNNR.
ENDFORM.

****SUBROUTINE SORTING****

FORM SORT.
****FIRST COLUM HEAD
SORT_W-SPOS = 1.
SORT_W-FIELDNAME = 'VBELN'.
APPEND SORT_W TO SORT_B.
***SECOND COLUMN HEAD
SORT_W-SPOS = 2.
SORT_W-FIELDNAME = 'ERDAT'.
APPEND SORT_W TO SORT_B.
***THIRD COLUMN HEAD
SORT_W-SPOS = 3.
SORT_W-FIELDNAME = 'ERNAM'.
APPEND SORT_W TO SORT_B.
***FOURTH COLUMN HEAD
SORT_W-SPOS = 4.
SORT_W-FIELDNAME = 'NETWR'.
APPEND SORT_W TO SORT_B.

ENDFORM.



*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
module USER_COMMAND_0100 input.
****LOGIC FOR DISPLAY AND EXIT**
CASE SY-UCOMM.
WHEN 'DISPLAY'.
****PERFORM FOR CALLSUB
PERFORM CALLSUB.

WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
endmodule. " USER_COMMAND_0100 INPUT
****SUBROUTINE FOR THE TO CALL PREVIESLY DEFINED SUBROTINES***
FORM CALLSUB.

PERFORM COL_HEAD.

PERFORM OUTPUT.

PERFORM SORT.
****LOGIC FOR DISPLAY THE LOCATION***
IF CUST IS INITIAL.

CREATE OBJECT CUST

EXPORTING

CONTAINER_NAME = CONTAINER.

CREATE OBJECT TREE

EXPORTING

I_PARENT = CUST.

CALL METHOD TREE->SET_TABLE_FOR_FIRST_DISPLAY

CHANGING
IT_OUTTAB = ITAB

IT_FIELDCATALOG = FCAT

IT_SORT = SORT_B.

ENDIF.

No comments:

Archives