how to write code alv with interactive?when i clicked
1field i will generated next-level report,is it possible in
alv?

Answer Posted / nitin sharma

Just check the following code

Building Interactive ALV list
using 'REUSE_ALV_LIST_DISPLAY'.

By Haritha

This program displays the Purchase Order header details on
the basic
list and on double-clicking any of the record on the basic
list,
the item-level information is displayed on the secondary
list.

REPORT ZPURCHASE_ORDER.

************************************************************
***********
* TYPE-POOLS DECLARATION
************************************************************
***********
TYPE-POOLS:
SLIS.

************************************************************
***********
* DATA DECLARATIONS
************************************************************
***********

DATA:
W_EBELN TYPE EKKO-EBELN,
W_PROG TYPE SY-REPID,
T_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
FS_FIELDCAT LIKE LINE OF T_FIELDCAT,
T_EVENTCAT TYPE SLIS_T_EVENT,
W_EVENTCAT LIKE LINE OF T_EVENTCAT.

************************************************************
***********
* SELECT-OPTIONS DECLARATION
************************************************************
***********
SELECT-OPTIONS:
S_EBELN FOR W_EBELN.

************************************************************
***********
* INTERNAL TABLE AND FIELD-STRING DECLARATIONS
************************************************************
***********

DATA:
T_EKKO LIKE
STANDARD TABLE
OF EKKO,
FS_EKKO LIKE LINE OF T_EKKO.

DATA:
T_EKPO LIKE
STANDARD TABLE
OF EKPO,
FS_EKPO LIKE LINE OF T_EKPO.

************************************************************
***********
* START-OF-SELECTION
************************************************************
***********
START-OF-SELECTION.
SELECT *
FROM EKKO
INTO TABLE T_EKKO
WHERE EBELN IN S_EBELN.

W_PROG = SY-REPID.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = W_PROG
I_CALLBACK_USER_COMMAND = 'PICK'
I_STRUCTURE_NAME = 'EKKO'
TABLES
T_OUTTAB = T_EKKO
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 pick
*&----------------------------------------------------------
----------*
* -->UCOMM text
* -->SELFIELD text
*-----------------------------------------------------------
----------*
FORM PICK USING COMMAND LIKE SY-UCOMM
SELFIELD TYPE SLIS_SELFIELD.
READ TABLE T_EKKO INTO FS_EKKO INDEX SELFIELD-TABINDEX.

CASE COMMAND.
WHEN '&IC1'.
SELECT *
FROM EKPO
INTO TABLE T_EKPO
WHERE EBELN EQ FS_EKKO-EBELN.

W_PROG = SY-REPID.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 'EKPO'
CHANGING
CT_FIELDCAT = T_FIELDCAT
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.

DELETE T_FIELDCAT WHERE FIELDNAME EQ 'EBELN'.
DELETE T_FIELDCAT WHERE FIELDNAME EQ 'BUKRS'.
DELETE T_FIELDCAT WHERE FIELDNAME EQ 'LGORT'.
DELETE T_FIELDCAT WHERE FIELDNAME EQ 'WERKS'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = W_PROG
IT_FIELDCAT = T_FIELDCAT
IT_EVENTS = T_EVENTCAT
TABLES
T_OUTTAB = T_EKPO
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.

ENDCASE. " CASE COMMAND
ENDFORM. " FORM PICK

FORM T_EVENTCAT.
W_EVENTCAT-NAME = 'TOP_OF_PAGE'.
W_EVENTCAT-FORM = 'TOP'.
APPEND W_EVENTCAT TO T_EVENTCAT.
ENDFORM.

FORM TOP.
READ TABLE T_EKPO INTO FS_EKPO INDEX 1.
WRITE:/ 'Purchase Document Number'(001),30 FS_EKPO-EBELN,
/ 'Company Code'(002), 30 FS_EKPO-BUKRS,
/ 'Plant'(003), 30 FS_EKPO-WERKS,
/ 'Storage Location'(004),30 FS_EKPO-LGORT.
ENDFORM.

Test Run:


If we enter the Purchasing Document Number and execute,
the Basic list will be displayed as follows.










When we double click on a record,
the secondary list will be displayed as follows:















Yes, it is possible.

Is This Answer Correct ?    6 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the disadvantage of using exec sql statement in abap?

540


What is the function of the transport system and workbench organiser?

643


What are the differences between structure and table in data dictionary in abap? : sap abap data dictionary

591


What are the difference between call screen and leave screen?

607


when does a list get sent to the screen on the presentation layer?

1448






What are the buffering options in abap?

575


When the get cursor command used in interactive lists?

606


What is check table?

583


HOW TO TRANSFER VENDOR MASTER DATA FROM LEGACY SYSTEM TO SAP SYSTEM THRU LSMW (IN LSMW, USING DIRECT INPUT PROGRAM:RFBIKR00)

3298


What are ranges?

600


What is foreign key relationship? : abap hr

626


How many default tab strips are there? How to insert more tabs in it?

618


Explain what is the significance of hide?

542


Can we create field without data element? If yes, how?

698


What is meant by slab? How is indian slab and us slab? : sap abap hr

564