Skip to Content
0
Former Member
Nov 14, 2005 at 10:21 AM

ALV - Interactive list

75 Views

Hi Everybody,

I am creating a ALV report (Interactive). where i am dispalying vendorwise total purchsae for the selected period in basic list and I want to diplay purchase orderwise details of a selected vendor in a second grid i have search on SDN but I am not satified with the codes given so I am giving my code also can any body help onthe same.

Thanks

Vinayak.

The code is

REPORT ZVTEST1 .

tables : ekko,ekpo,lfa1.

data : begin of itab occurs 0,

lifnr like ekko-lifnr,

netwr like ekpo-netwr,

name1 like lfa1-name1,

end of itab.

DATA :TEST_GRID TYPE REF TO CL_GUI_ALV_GRID,

TEST_CONT TYPE SCRFNAME VALUE 'TESTING_ALV',

TEST_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

TEST_LAYOUT TYPE LVC_S_LAYO,

TEST_FIELDCAT TYPE LVC_T_FCAT,

ok_code like sy-ucomm.

select-options: s_bedat for ekko-bedat.

CALL SCREEN 100.

&----


*& Module STATUS_0100 OUTPUT

&----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'TEST'.

PERFORM SELECT-DATA. " FOR THE INITIAL LIST.

PERFORM ALV_DISPLAY. "TO DISPLAY INITIAL SCREEN.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


MODULE USER_COMMAND_0100 INPUT.

CASE OK_CODE.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Form SELECT-DATA

&----


FORM SELECT-DATA .

select alifnr sum( bnetwr ) as netwr

into corresponding fields of itab

from ekko as a inner join ekpo as b on bebeln = aebeln

where abedat in s_bedat group by alifnr.

select single name1 from lfa1 into itab-name1

where lifnr = itab-lifnr.

append itab.

endselect.

ENDFORM. " SELECT-DATA

&----


*& Form ALV_DISPLAY

FORM ALV_DISPLAY .

IF TEST_GRID IS INITIAL.

CREATE OBJECT TEST_CONTAINER

EXPORTING

CONTAINER_NAME = 'TESTING_ALV'.

CREATE OBJECT TEST_GRID

EXPORTING

I_PARENT = TEST_CONTAINER.

PERFORM PROC_CATALOG CHANGING TEST_FIELDCAT.

PERFORM PROC_LAYOUT CHANGING TEST_LAYOUT.

CALL METHOD TEST_GRID->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

IS_LAYOUT = TEST_LAYOUT

CHANGING

IT_OUTTAB = ITAB[]

IT_FIELDCATALOG = TEST_FIELDCAT[].

ELSE.

CALL METHOD TEST_GRID->REFRESH_TABLE_DISPLAY

EXCEPTIONS

FINISHED = 1

others = 2.

ENDIF.

ENDFORM. " ALV_DISPLAY

&----


*& Form PROC_CATALOG

&----


FORM PROC_CATALOG CHANGING P_TEST_FIELDCAT type lvc_t_fcat.

data: TEST_fieldcat type lvc_s_fcat.

TEST_FIELDCAT-fieldname = 'LIFNR'.

TEST_FIELDCAT-REF_TABLE = 'LFA1'.

TEST_FIELDCAT-OUTPUTLEN = '12'.

TEST_FIELDCAT-coltext = 'VENDOR CODE'.

TEST_FIELDCAT-SELTEXT = 'VENDOR CODE'.

TEST_FIELDCAT-HOTSPOT = 'X'.

APPEND TEST_FIELDCAT TO P_TEST_FIElDCAT.

CLEAR TEST_FIELDCAT.

TEST_FIELDCAT-fieldname = 'NAME1'.

TEST_FIELDCAT-REF_TABLE = 'LFA1'.

TEST_FIELDCAT-OUTPUTLEN = '25'.

TEST_FIELDCAT-coltext = 'VENDOR NAME'.

TEST_FIELDCAT-SELTEXT = 'VENDOR NAME'.

APPEND TEST_FIELDCAT TO P_TEST_FIElDCAT.

CLEAR TEST_FIELDCAT.

TEST_FIELDCAT-fieldname = 'NETWR'.

TEST_FIELDCAT-REF_TABLE = 'EKPO'.

TEST_FIELDCAT-OUTPUTLEN = '20'.

TEST_FIELDCAT-coltext = 'PURCHASE AMOUNT'.

APPEND TEST_FIELDCAT TO P_TEST_FIElDCAT.

CLEAR TEST_FIELDCAT.

ENDFORM. " PROC_CATALOG

&----


*& Form PROC_LAYOUT

&----


FORM PROC_LAYOUT CHANGING P_TEST_LAYOUT type lvc_s_layo.

p_TEST_layout-zebra = 'X'.

p_TEST_layouT-grid_title = 'TEST INTERACTIVE ALV'.

p_TEST_layout-smalltitle = 'X'.

p_TEST_layout-no_hgridln = 'X'.

p_TEST_layout-excp_conds = 'X'.

p_TEST_layout-numc_total = 'X'.

ENDFORM. " PROC_LAYOUT

this is displaying 1st list.