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: 

alv

Former Member
0 Kudos
200

Actually output is displayed in the grid. When I click a button from there i want to move into another alv display grid. How to do that?

1 ACCEPTED SOLUTION

Former Member
0 Kudos
168

hi ,

Check this code for drill down Reporting it will helpful.

REPORT ZHARALV NO STANDARD PAGE HEADING .

tables : mast,stpo,makt.

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

SELECT-OPTIONS: material FOR mast-matnr,

plant FOR mast-werks.

SELECTION-SCREEN END OF BLOCK B1.

data : begin of it occurs 0,

idnrk like stpo-idnrk,

maktx like makt-maktx,

menge like stpo-menge,

meins like stpo-meins,

end of it.

*----


  • AlV related data declarations

*----


  • Type Pools

TYPE-POOLS: SLIS.

" access from se11-utility, type of dataelemewnt and internal table

CONSTANTS:

GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.

" no use

DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

" for hold field value, perform and function is there

GT_EVENTS TYPE SLIS_T_EVENT WITH HEADER LINE,

  • GT_EVENT TYPE SLIS_T_EVENT WITH HEADER LINE,

" for ctp, for pass top name, at fc for grid, which will match at ctp

"-fn for layout preperation.

"-header line for treat it as table,

GS_LAYOUT TYPE SLIS_LAYOUT_ALV,

GS_PRINT TYPE SLIS_PRINT_ALV,

GT_SORT TYPE SLIS_T_SORTINFO_ALV,

GT_SP_GROUP TYPE SLIS_T_SP_GROUP_ALV.

" not still used

DATA: G_REPID LIKE SY-REPID.

" name of the calling program for function for preparing alv layout

DATA: GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.

" calling with return - top header details & to pass at fc for top.

DATA: G_BOXNAM TYPE SLIS_FIELDNAME VALUE 'BOX',

P_F2CODE LIKE SY-UCOMM VALUE '&ETA',

P_LIGNAM TYPE SLIS_FIELDNAME VALUE 'LIGHTS',

G_SAVE(1) TYPE C,

" used but what is effect?

G_DEFAULT(1) TYPE C,

G_EXIT(1) TYPE C,

GX_VARIANT LIKE DISVARIANT,

G_VARIANT LIKE DISVARIANT.

" not used yet

*----


  • Initialization

*----


INITIALIZATION.

*----


  • Validation Section

*----


AT SELECTION-SCREEN.

*----


  • START-OF-SELECTION

*----


START-OF-SELECTION.

PERFORM Z_FILL_ITAB.

PERFORM DATA_FORMAT.

END-OF-SELECTION.

*----


  • End of selection

*----


&----


*& Form DATA_COLLECTION

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM Z_FILL_ITAB.

select single stlnr

into mast-stlnr " FOR DECREASE TABLE NO.

from mast

where matnr IN material

AND WERKS IN PLANT.

select idnrk menge meins

into (IT-IDNRK, IT-MENGE, IT-MEINS)

*into (stpo-idnrk,stpo-menge,stpo-meins)

from stpo

where stlnr = mast-stlnr.

select single maktx

INTO IT-MAKTX

  • into makt-maktx

from makt

where matnr = IT-IDNRK."stpo-idnrk

  • it-idnrk = stpo-idnrk.

  • it-maktx = makt-maktx.

  • it-menge = stpo-menge.

  • it-meins = stpo-meins.

append it.

endselect.

*LOOP AT IT.

*

  • WRITE: / IT-IDNRK,

  • IT-MAKTX,

  • IT-MENGE,

  • IT-MEINS.

*

*ENDLOOP.

ENDFORM. "z_fill_itab

&----


*& Form DATA_FORMAT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DATA_FORMAT .

G_REPID = SY-REPID.

PERFORM E01_FIELDCAT_INIT USING GT_FIELDCAT[].

" calling with return - body heading

PERFORM E04_COMMENT_BUILD USING GT_LIST_TOP_OF_PAGE[].

" calling with return - top header details

G_SAVE = 'A'.

CLEAR GT_EVENTS.

REFRESH GT_EVENTS.

GT_EVENTS-NAME = 'TOP_OF_PAGE'.

GT_EVENTS-FORM = 'TOP_OF_PAGE'.

APPEND GT_EVENTS.

" FOR CTP,to pass top name into the fc for body, SAME AT Fc for top.

  • CLEAR GT_EVENT.

  • REFRESH GT_EVENT.

  • GT_EVENT-NAME = 'top1_OF_PAGE'.

  • GT_EVENT-FORM = 'top1_OF_PAGE'.

  • APPEND GT_EVENT.

PERFORM DISPLAY_REPORT.

ENDFORM. " DATA_FORMAT

&----


*& Form e01_fieldcat_init

&----


FORM E01_FIELDCAT_INIT USING E01_LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'IDNRK'.

LS_FIELDCAT-REF_FIELDNAME = 'IDNRK'.

  • LS_FIELDCAT-REF_TABNAME = ''.

LS_FIELDCAT-HOTSPOT = 'X'.

LS_FIELDCAT-COL_POS = '1'.

LS_FIELDCAT-SELTEXT_L = 'COMPONENT'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'MAKTX'.

LS_FIELDCAT-REF_FIELDNAME = 'MAKTX'.

LS_FIELDCAT-REF_TABNAME = 'MAKT'.

LS_FIELDCAT-COL_POS = '2'.

LS_FIELDCAT-SELTEXT_L = 'DESCRIPTION'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'MENGE'.

LS_FIELDCAT-REF_FIELDNAME = 'MENGE'.

  • LS_FIELDCAT-REF_TABNAME = ''.

LS_FIELDCAT-COL_POS = '3'.

LS_FIELDCAT-SELTEXT_L = 'QUANTITY'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'MEINS'.

LS_FIELDCAT-REF_FIELDNAME = 'MEINS'.

  • LS_FIELDCAT-REF_TABNAME = 'ZTRANSIT_HDR'.

LS_FIELDCAT-COL_POS = '4'.

LS_FIELDCAT-SELTEXT_L = 'UNIT'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

ENDFORM. " e01_fieldcat_init

&----


*& Form display_report

&----


FORM DISPLAY_REPORT.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_BACKGROUND_ID = 'ALV_BACKGROUND'"D:BG SET AT OOAR.

I_CALLBACK_PROGRAM = G_REPID "I:EXP.CUR.POG.NAME

I_CALLBACK_USER_COMMAND = 'USER_COMMAND ' "D:ACTION WHEN COMMAND

IT_FIELDCAT = GT_FIELDCAT[] "I:PASS FIELD HEADING

IT_EVENTS = GT_EVENTS[] "I:PASS TPNAME,TO CTPFN

I_GRID_TITLE = 'BOM' "D:FOR GRID TITLE

IS_LAYOUT = GS_LAYOUT

IT_SPECIAL_GROUPS = GT_SP_GROUP[]

IT_SORT = GT_SORT[]

I_SAVE = G_SAVE

IS_VARIANT = G_VARIANT

IS_PRINT = GS_PRINT

TABLES

T_OUTTAB = IT.

ENDFORM. " display_report

Reawards if it is useful.

6 REPLIES 6

Former Member
0 Kudos
168

Hi,

Check this..

http://www.sap-img.com/abap/display-secondary-list-using-alv-grid.htm

reward if it helps..

Regards,

Omkar.

Former Member
0 Kudos
168

Hi,

Pls go thru the following Threads,

Check this code..

TYPE-POOLS: slis.

DATA: BEGIN OF itab1 OCCURS 0,

vbeln TYPE vbeln,

bstnk TYPE vbak-bstnk,

erdat TYPE vbak-erdat,

kunnr TYPE vbak-kunnr,

END OF itab1.

DATA: BEGIN OF itab2 OCCURS 0,

vbeln TYPE vbeln,

matnr TYPE vbap-matnr,

netpr TYPE vbap-netpr,

kwmeng TYPE vbap-kwmeng,

END OF itab2.

DATA: t_fieldcatalog1 TYPE slis_t_fieldcat_alv.

DATA: t_fieldcatalog2 TYPE slis_t_fieldcat_alv.

DATA: v_repid TYPE syrepid.

v_repid = sy-repid.

  • Get the fieldcatalog1

PERFORM get_fieldcat1.

  • Get the fieldcatalog2

PERFORM get_fieldcat2.

SELECT vbeln bstnk erdat kunnr UP TO 10 ROWS

INTO TABLE itab1

FROM vbak.

IF NOT itab1[] IS INITIAL.

SELECT vbeln matnr netpr kwmeng UP TO 10 ROWS

INTO TABLE itab2

FROM vbap

FOR ALL ENTRIES IN itab1

WHERE vbeln = itab1-vbeln.

ENDIF.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = v_repid

i_callback_user_command = 'DISPLAY_DETAIL'

it_fieldcat = t_fieldcatalog1

TABLES

t_outtab = itab1.

----


  • FORM display_detail *

----


  • ........ *

----


  • --> UCOMM *

  • --> SELFIELD *

----


FORM display_detail USING ucomm LIKE sy-ucomm

selfield TYPE slis_selfield.

DATA: itab2_temp LIKE itab2 OCCURS 0 WITH HEADER LINE.

IF ucomm = '&IC1'.

READ TABLE itab1 INDEX selfield-tabindex.

IF sy-subrc = 0.

LOOP AT itab2 WHERE vbeln = itab1-vbeln.

MOVE itab2 TO itab2_temp.

APPEND itab2_temp.

ENDLOOP.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = v_repid

it_fieldcat = t_fieldcatalog2

TABLES

t_outtab = itab2_temp.

ENDIF.

ENDIF.

ENDFORM.

----


  • FORM GET_FIELDCAT1 *

----


  • ........ *

----


FORM get_fieldcat1.

DATA: s_fieldcatalog TYPE slis_fieldcat_alv.

s_fieldcatalog-col_pos = '1'.

s_fieldcatalog-fieldname = 'VBELN'.

s_fieldcatalog-tabname = 'ITAB1'.

s_fieldcatalog-rollname = 'VBELN'.

s_fieldcatalog-hotspot = 'X'.

APPEND s_fieldcatalog TO t_fieldcatalog1.

CLEAR s_fieldcatalog.

s_fieldcatalog-col_pos = '2'.

s_fieldcatalog-fieldname = 'BSTNK'.

s_fieldcatalog-tabname = 'ITAB1'.

s_fieldcatalog-rollname = 'BSTNK'.

APPEND s_fieldcatalog TO t_fieldcatalog1.

CLEAR s_fieldcatalog.

s_fieldcatalog-col_pos = '3'.

s_fieldcatalog-fieldname = 'ERDAT'.

s_fieldcatalog-tabname = 'ITAB1'.

s_fieldcatalog-rollname = 'ERDAT'.

APPEND s_fieldcatalog TO t_fieldcatalog1.

CLEAR s_fieldcatalog.

s_fieldcatalog-col_pos = '4'.

s_fieldcatalog-fieldname = 'KUNNR'.

s_fieldcatalog-tabname = 'ITAB1'.

s_fieldcatalog-rollname = 'KUNNR'.

APPEND s_fieldcatalog TO t_fieldcatalog1.

CLEAR s_fieldcatalog.

ENDFORM.

*

----


  • FORM GET_FIELDCAT2 *

----


  • ........ *

----


FORM get_fieldcat2.

DATA: s_fieldcatalog TYPE slis_fieldcat_alv.

s_fieldcatalog-col_pos = '1'.

s_fieldcatalog-fieldname = 'VBELN'.

s_fieldcatalog-tabname = 'ITAB2'.

s_fieldcatalog-rollname = 'VBELN'.

APPEND s_fieldcatalog TO t_fieldcatalog2.

CLEAR s_fieldcatalog.

s_fieldcatalog-col_pos = '2'.

s_fieldcatalog-fieldname = 'MATNR'.

s_fieldcatalog-tabname = 'ITAB2'.

s_fieldcatalog-rollname = 'MATNR'.

APPEND s_fieldcatalog TO t_fieldcatalog2.

CLEAR s_fieldcatalog.

s_fieldcatalog-col_pos = '3'.

s_fieldcatalog-fieldname = 'NETPR'.

s_fieldcatalog-tabname = 'ITAB2'.

s_fieldcatalog-rollname = 'NETPR'.

APPEND s_fieldcatalog TO t_fieldcatalog2.

CLEAR s_fieldcatalog.

s_fieldcatalog-col_pos = '4'.

s_fieldcatalog-fieldname = 'KWMENG'.

s_fieldcatalog-tabname = 'ITAB2'.

s_fieldcatalog-rollname = 'KWMENG'.

APPEND s_fieldcatalog TO t_fieldcatalog2.

CLEAR s_fieldcatalog.

ENDFORM.

Regards,

Padmam.

Former Member
0 Kudos
168

hi

good

go to se38

put BCALV*

press F4

you ll find lots of example related to interactive alv,test them and use them accordingly.

Thanks

mrutyun^

Former Member
0 Kudos
168

Hello Veera...

use form user_command in REUSE-ALV_GRID_DISPLAY

FORM user_command USING r_ucomm TYPE sy-ucomm r_selfield TYPE slis_selfield

.

CASE R_UCOMM.

WHEN '&IC1'.

  • use alv display with second internal table.

ENDCASE.

ENDFORM.

-


If u r using OOPS concept:

create two screen for two ALV, add to cointer in both of the screen and by the user command of the first ALV call the second alv.

The same also can be done in case OF classical ALV( Using FM) , in the user command of first ALV, call the second "REUSE_ALV_GRID_DISPLAY" and pass the parameters of second alv there.

Reward if Helpful

Regards

--

Sasidhar Reddy Matli.

Former Member
0 Kudos
169

hi ,

Check this code for drill down Reporting it will helpful.

REPORT ZHARALV NO STANDARD PAGE HEADING .

tables : mast,stpo,makt.

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

SELECT-OPTIONS: material FOR mast-matnr,

plant FOR mast-werks.

SELECTION-SCREEN END OF BLOCK B1.

data : begin of it occurs 0,

idnrk like stpo-idnrk,

maktx like makt-maktx,

menge like stpo-menge,

meins like stpo-meins,

end of it.

*----


  • AlV related data declarations

*----


  • Type Pools

TYPE-POOLS: SLIS.

" access from se11-utility, type of dataelemewnt and internal table

CONSTANTS:

GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.

" no use

DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

" for hold field value, perform and function is there

GT_EVENTS TYPE SLIS_T_EVENT WITH HEADER LINE,

  • GT_EVENT TYPE SLIS_T_EVENT WITH HEADER LINE,

" for ctp, for pass top name, at fc for grid, which will match at ctp

"-fn for layout preperation.

"-header line for treat it as table,

GS_LAYOUT TYPE SLIS_LAYOUT_ALV,

GS_PRINT TYPE SLIS_PRINT_ALV,

GT_SORT TYPE SLIS_T_SORTINFO_ALV,

GT_SP_GROUP TYPE SLIS_T_SP_GROUP_ALV.

" not still used

DATA: G_REPID LIKE SY-REPID.

" name of the calling program for function for preparing alv layout

DATA: GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.

" calling with return - top header details & to pass at fc for top.

DATA: G_BOXNAM TYPE SLIS_FIELDNAME VALUE 'BOX',

P_F2CODE LIKE SY-UCOMM VALUE '&ETA',

P_LIGNAM TYPE SLIS_FIELDNAME VALUE 'LIGHTS',

G_SAVE(1) TYPE C,

" used but what is effect?

G_DEFAULT(1) TYPE C,

G_EXIT(1) TYPE C,

GX_VARIANT LIKE DISVARIANT,

G_VARIANT LIKE DISVARIANT.

" not used yet

*----


  • Initialization

*----


INITIALIZATION.

*----


  • Validation Section

*----


AT SELECTION-SCREEN.

*----


  • START-OF-SELECTION

*----


START-OF-SELECTION.

PERFORM Z_FILL_ITAB.

PERFORM DATA_FORMAT.

END-OF-SELECTION.

*----


  • End of selection

*----


&----


*& Form DATA_COLLECTION

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM Z_FILL_ITAB.

select single stlnr

into mast-stlnr " FOR DECREASE TABLE NO.

from mast

where matnr IN material

AND WERKS IN PLANT.

select idnrk menge meins

into (IT-IDNRK, IT-MENGE, IT-MEINS)

*into (stpo-idnrk,stpo-menge,stpo-meins)

from stpo

where stlnr = mast-stlnr.

select single maktx

INTO IT-MAKTX

  • into makt-maktx

from makt

where matnr = IT-IDNRK."stpo-idnrk

  • it-idnrk = stpo-idnrk.

  • it-maktx = makt-maktx.

  • it-menge = stpo-menge.

  • it-meins = stpo-meins.

append it.

endselect.

*LOOP AT IT.

*

  • WRITE: / IT-IDNRK,

  • IT-MAKTX,

  • IT-MENGE,

  • IT-MEINS.

*

*ENDLOOP.

ENDFORM. "z_fill_itab

&----


*& Form DATA_FORMAT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DATA_FORMAT .

G_REPID = SY-REPID.

PERFORM E01_FIELDCAT_INIT USING GT_FIELDCAT[].

" calling with return - body heading

PERFORM E04_COMMENT_BUILD USING GT_LIST_TOP_OF_PAGE[].

" calling with return - top header details

G_SAVE = 'A'.

CLEAR GT_EVENTS.

REFRESH GT_EVENTS.

GT_EVENTS-NAME = 'TOP_OF_PAGE'.

GT_EVENTS-FORM = 'TOP_OF_PAGE'.

APPEND GT_EVENTS.

" FOR CTP,to pass top name into the fc for body, SAME AT Fc for top.

  • CLEAR GT_EVENT.

  • REFRESH GT_EVENT.

  • GT_EVENT-NAME = 'top1_OF_PAGE'.

  • GT_EVENT-FORM = 'top1_OF_PAGE'.

  • APPEND GT_EVENT.

PERFORM DISPLAY_REPORT.

ENDFORM. " DATA_FORMAT

&----


*& Form e01_fieldcat_init

&----


FORM E01_FIELDCAT_INIT USING E01_LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'IDNRK'.

LS_FIELDCAT-REF_FIELDNAME = 'IDNRK'.

  • LS_FIELDCAT-REF_TABNAME = ''.

LS_FIELDCAT-HOTSPOT = 'X'.

LS_FIELDCAT-COL_POS = '1'.

LS_FIELDCAT-SELTEXT_L = 'COMPONENT'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'MAKTX'.

LS_FIELDCAT-REF_FIELDNAME = 'MAKTX'.

LS_FIELDCAT-REF_TABNAME = 'MAKT'.

LS_FIELDCAT-COL_POS = '2'.

LS_FIELDCAT-SELTEXT_L = 'DESCRIPTION'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'MENGE'.

LS_FIELDCAT-REF_FIELDNAME = 'MENGE'.

  • LS_FIELDCAT-REF_TABNAME = ''.

LS_FIELDCAT-COL_POS = '3'.

LS_FIELDCAT-SELTEXT_L = 'QUANTITY'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

CLEAR LS_FIELDCAT.

LS_FIELDCAT-FIELDNAME = 'MEINS'.

LS_FIELDCAT-REF_FIELDNAME = 'MEINS'.

  • LS_FIELDCAT-REF_TABNAME = 'ZTRANSIT_HDR'.

LS_FIELDCAT-COL_POS = '4'.

LS_FIELDCAT-SELTEXT_L = 'UNIT'.

APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

ENDFORM. " e01_fieldcat_init

&----


*& Form display_report

&----


FORM DISPLAY_REPORT.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_BACKGROUND_ID = 'ALV_BACKGROUND'"D:BG SET AT OOAR.

I_CALLBACK_PROGRAM = G_REPID "I:EXP.CUR.POG.NAME

I_CALLBACK_USER_COMMAND = 'USER_COMMAND ' "D:ACTION WHEN COMMAND

IT_FIELDCAT = GT_FIELDCAT[] "I:PASS FIELD HEADING

IT_EVENTS = GT_EVENTS[] "I:PASS TPNAME,TO CTPFN

I_GRID_TITLE = 'BOM' "D:FOR GRID TITLE

IS_LAYOUT = GS_LAYOUT

IT_SPECIAL_GROUPS = GT_SP_GROUP[]

IT_SORT = GT_SORT[]

I_SAVE = G_SAVE

IS_VARIANT = G_VARIANT

IS_PRINT = GS_PRINT

TABLES

T_OUTTAB = IT.

ENDFORM. " display_report

Reawards if it is useful.