2007 Jul 21 2:04 PM
Hi all,
Can anyone give me simplest example of Interactive ALV Report.
Please give some description with that so that i can understand it ..
Thanks
Raj
2007 Jul 21 2:12 PM
REPORT ZZ_22038_22098_002 NO STANDARD PAGE HEADING LINE-SIZE 650
MESSAGE-ID ZZ_9838 .
TYPE-POOLS: SLIS.
*type declaration for values from ekko
TYPES: BEGIN OF I_EKKO,
EBELN LIKE EKKO-EBELN,
AEDAT LIKE EKKO-AEDAT,
BUKRS LIKE EKKO-BUKRS,
BSART LIKE EKKO-BSART,
LIFNR LIKE EKKO-LIFNR,
END OF I_EKKO.
DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,
WA_EKKO TYPE I_EKKO.
*type declaration for values from ekpo
TYPES: BEGIN OF I_EKPO,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
MATNR LIKE EKPO-MATNR,
MENGE LIKE EKPO-MENGE,
MEINS LIKE EKPO-MEINS,
NETPR LIKE EKPO-NETPR,
END OF I_EKPO.
DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,
WA_EKPO TYPE I_EKPO .
*variable for Report ID
DATA: V_REPID LIKE SY-REPID .
*declaration for fieldcatalog
DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
declaration for events table where user comand or set PF status will
be defined
DATA: V_EVENTS TYPE SLIS_T_EVENT,
WA_EVENT TYPE SLIS_ALV_EVENT.
declartion for layout
DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
declaration for variant(type of display we want)
DATA: I_VARIANT TYPE DISVARIANT,
I_VARIANT1 TYPE DISVARIANT,
I_SAVE(1) TYPE C.
*PARAMETERS : p_var TYPE disvariant-variant.
*Title displayed when the alv list is displayed
DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.
DATA: I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.
INITIALIZATION.
V_REPID = SY-REPID.
PERFORM BUILD_FIELDCATLOG.
PERFORM EVENT_CALL.
PERFORM POPULATE_EVENT.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_REPORT.
&----
*& Form BUILD_FIELDCATLOG
&----
Fieldcatalog has all the field details from ekko
----
FORM BUILD_FIELDCATLOG.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'AEDAT'.
WA_FIELDCAT-SELTEXT_M = 'DATE.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'LIFNR'.
WA_FIELDCAT-NO_OUT = 'X'.
WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG
&----
*& Form EVENT_CALL
&----
we get all events - TOP OF PAGE or USER COMMAND in table v_events
----
FORM EVENT_CALL.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
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.
ENDFORM. "EVENT_CALL
&----
*& Form POPULATE_EVENT
&----
Events populated for TOP OF PAGE & USER COMAND
----
FORM POPULATE_EVENT.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'USER_COMMAND'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-NAME.
ENDIF.
ENDFORM. "POPULATE_EVENT
&----
*& Form data_retrieval
&----
retreiving values from the database table ekko
----
FORM DATA_RETRIEVAL.
SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.
ENDFORM. "data_retrieval
&----
*& Form bUild_listheader
&----
text
----
-->I_LISTHEADEtext
----
FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA HLINE TYPE SLIS_LISTHEADER.
HLINE-INFO = 'this is my first alv pgm'.
HLINE-TYP = 'H'.
ENDFORM. "build_listheader
&----
*& Form display_alv_report
&----
text
----
FORM DISPLAY_ALV_REPORT.
V_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = I_TITLE_EKKO
I_GRID_SETTINGS =
IS_LAYOUT = ALV_LAYOUT
IT_FIELDCAT = I_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
i_default = 'ZLAY1'
I_SAVE = 'A'
is_variant = i_variant
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_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.
ENDFORM. "display_alv_report
&----
*& Form TOP_OF_PAGE
&----
text
----
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
i_logo =
I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
&----
*& Form USER_COMMAND
&----
text
----
-->R_UCOMM text
-->, text
-->RS_SLEFIELDtext
----
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
PERFORM BUILD_FIELDCATLOG_EKPO.
PERFORM EVENT_CALL_EKPO.
PERFORM POPULATE_EVENT_EKPO.
PERFORM DATA_RETRIEVAL_EKPO.
PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_EKPO.
ENDCASE.
ENDFORM. "user_command
&----
*& Form BUILD_FIELDCATLOG_EKPO
&----
text
----
FORM BUILD_FIELDCATLOG_EKPO.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELP'.
WA_FIELDCAT-SELTEXT_M = 'LINE NO'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MENGE'.
WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MEINS'.
WA_FIELDCAT-SELTEXT_M = 'UOM'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'NETPR'.
WA_FIELDCAT-SELTEXT_M = 'PRICE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG_EKPO
&----
*& Form event_call_ekpo
&----
we get all events - TOP OF PAGE or USER COMMAND in table v_events
----
FORM EVENT_CALL_EKPO.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
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.
ENDFORM. "event_call_ekpo
&----
*& Form POPULATE_EVENT
&----
Events populated for TOP OF PAGE & USER COMAND
----
FORM POPULATE_EVENT_EKPO.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
ENDFORM. "POPULATE_EVENT
&----
*& Form TOP_OF_PAGE
&----
text
----
FORM F_TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
i_logo =
I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
&----
*& Form USER_COMMAND
&----
text
----
-->R_UCOMM text
-->, text
-->RS_SLEFIELDtext
----
*retreiving values from the database table ekko
FORM DATA_RETRIEVAL_EKPO.
SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.
ENDFORM.
FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA: HLINE1 TYPE SLIS_LISTHEADER.
HLINE1-TYP = 'H'.
HLINE1-INFO = 'CHECKING PGM'.
ENDFORM.
FORM DISPLAY_ALV_EKPO.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE = I_TITLE_EKPO
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = I_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT =
I_SAVE = 'A'
IS_VARIANT =
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_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.
ENDFORM.
____________________________________________________________________
another sample code
TYPE-POOLS: SLIS.
*type declaration for values from ekko
TYPES: BEGIN OF I_EKKO,
EBELN LIKE EKKO-EBELN,
AEDAT LIKE EKKO-AEDAT,
BUKRS LIKE EKKO-BUKRS,
BSART LIKE EKKO-BSART,
LIFNR LIKE EKKO-LIFNR,
END OF I_EKKO.
DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,
WA_EKKO TYPE I_EKKO.
*type declaration for values from ekpo
TYPES: BEGIN OF I_EKPO,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
MATNR LIKE EKPO-MATNR,
MENGE LIKE EKPO-MENGE,
MEINS LIKE EKPO-MEINS,
NETPR LIKE EKPO-NETPR,
END OF I_EKPO.
DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,
WA_EKPO TYPE I_EKPO .
*variable for Report ID
DATA: V_REPID LIKE SY-REPID .
*declaration for fieldcatalog
DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
declaration for events table where user comand or set PF status will
be defined
DATA: V_EVENTS TYPE SLIS_T_EVENT,
WA_EVENT TYPE SLIS_ALV_EVENT.
declartion for layout
DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
declaration for variant(type of display we want)
DATA: I_VARIANT TYPE DISVARIANT,
I_VARIANT1 TYPE DISVARIANT,
I_SAVE(1) TYPE C.
*PARAMETERS : p_var TYPE disvariant-variant.
*Title displayed when the alv list is displayed
DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.
DATA: I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.
INITIALIZATION.
V_REPID = SY-REPID.
PERFORM BUILD_FIELDCATLOG.
PERFORM EVENT_CALL.
PERFORM POPULATE_EVENT.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_REPORT.
&----
*& Form BUILD_FIELDCATLOG
&----
Fieldcatalog has all the field details from ekko
----
FORM BUILD_FIELDCATLOG.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'AEDAT'.
WA_FIELDCAT-SELTEXT_M = 'DATE.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'LIFNR'.
WA_FIELDCAT-NO_OUT = 'X'.
WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG
&----
*& Form EVENT_CALL
&----
we get all events - TOP OF PAGE or USER COMMAND in table v_events
----
FORM EVENT_CALL.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
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.
ENDFORM. "EVENT_CALL
&----
*& Form POPULATE_EVENT
&----
Events populated for TOP OF PAGE & USER COMAND
----
FORM POPULATE_EVENT.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'USER_COMMAND'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-NAME.
ENDIF.
ENDFORM. "POPULATE_EVENT
&----
*& Form data_retrieval
&----
retreiving values from the database table ekko
----
FORM DATA_RETRIEVAL.
SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.
ENDFORM. "data_retrieval
&----
*& Form bUild_listheader
&----
text
----
-->I_LISTHEADEtext
----
FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA HLINE TYPE SLIS_LISTHEADER.
HLINE-INFO = 'this is my first alv pgm'.
HLINE-TYP = 'H'.
ENDFORM. "build_listheader
&----
*& Form display_alv_report
&----
text
----
FORM DISPLAY_ALV_REPORT.
V_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = I_TITLE_EKKO
I_GRID_SETTINGS =
IS_LAYOUT = ALV_LAYOUT
IT_FIELDCAT = I_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
i_default = 'ZLAY1'
I_SAVE = 'A'
is_variant = i_variant
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_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.
ENDFORM. "display_alv_report
&----
*& Form TOP_OF_PAGE
&----
text
----
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
i_logo =
I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
&----
*& Form USER_COMMAND
&----
text
----
-->R_UCOMM text
-->, text
-->RS_SLEFIELDtext
----
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
PERFORM BUILD_FIELDCATLOG_EKPO.
PERFORM EVENT_CALL_EKPO.
PERFORM POPULATE_EVENT_EKPO.
PERFORM DATA_RETRIEVAL_EKPO.
PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_EKPO.
ENDCASE.
ENDFORM. "user_command
&----
*& Form BUILD_FIELDCATLOG_EKPO
&----
text
----
FORM BUILD_FIELDCATLOG_EKPO.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELP'.
WA_FIELDCAT-SELTEXT_M = 'LINE NO'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MENGE'.
WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MEINS'.
WA_FIELDCAT-SELTEXT_M = 'UOM'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'NETPR'.
WA_FIELDCAT-SELTEXT_M = 'PRICE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG_EKPO
&----
*& Form event_call_ekpo
&----
we get all events - TOP OF PAGE or USER COMMAND in table v_events
----
FORM EVENT_CALL_EKPO.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
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.
ENDFORM. "event_call_ekpo
&----
*& Form POPULATE_EVENT
&----
Events populated for TOP OF PAGE & USER COMAND
----
FORM POPULATE_EVENT_EKPO.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
ENDFORM. "POPULATE_EVENT
&----
*& Form TOP_OF_PAGE
&----
text
----
FORM F_TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
i_logo =
I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
&----
*& Form USER_COMMAND
&----
text
----
-->R_UCOMM text
-->, text
-->RS_SLEFIELDtext
----
*retreiving values from the database table ekko
FORM DATA_RETRIEVAL_EKPO.
SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.
ENDFORM.
FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA: HLINE1 TYPE SLIS_LISTHEADER.
HLINE1-TYP = 'H'.
HLINE1-INFO = 'CHECKING PGM'.
ENDFORM.
FORM DISPLAY_ALV_EKPO.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE = I_TITLE_EKPO
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = I_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT =
I_SAVE = 'A'
IS_VARIANT =
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_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.
ENDFORM.
___________________________________________________________________
REPORT Z_PO_ALV_R02 NO STANDARD PAGE HEADING MESSAGE-ID ZROJA.
*-----tables declaration
TABLES:EKKO.
TYPE-POOLS:SLIS.
*-----data declaration
TYPES:BEGIN OF X_EKKO,
EBELN type EKKO-EBELN, "PO Number
BUKRS type EKKO-BUKRS, "Company code
BSART type EKKO-BSART, "Purchasing Document type
LIFNR type EKKO-LIFNR, "Vendor
SPRAS type EKKO-SPRAS, "Language Key
ZTERM type EKKO-ZTERM, "Terms of payment key
END OF X_EKKO,
BEGIN OF X_EKPO,
EBELN type EKPO-EBELN,
EBELP type EKPO-EBELP, "Item number
WERKS type EKPO-WERKS, "Plant
MATNR type EKPO-MATNR, "Material Number
MATKL type EKPO-MATKL, "Material Group
END OF X_EKPO.
DATA:IT_EKKO TYPE STANDARD TABLE OF X_EKKO,
IT_EKPO TYPE STANDARD TABLE OF X_EKPO,
WA_EKKO TYPE X_EKKO,
WA_EKPO TYPE X_EKPO, "#EC *
IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
IT_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
WA_FIELDCAT1 TYPE SLIS_FIELDCAT_ALV.
*-----Selection-screen design
SELECTION-SCREEN BEGIN OF BLOCK B1.
SELECT-OPTIONS:S_EBELN FOR EKKO-EBELN.
SELECTION-SCREEN END OF BLOCK B1.
*-----SELECTION-SCREEN VALIDATION
AT SELECTION-SCREEN.
SELECT EBELN
FROM EKKO
INTO TABLE IT_EKKO
WHERE EBELN IN S_EBELN.
*-----if there are no values display an error
IF SY-SUBRC NE 0.
MESSAGE E009.
ENDIF.
*-----Data retrieval
START-OF-SELECTION.
*-----retrieving data from the PO header
SELECT EBELN BUKRS BSART LIFNR SPRAS ZTERM
FROM EKKO
INTO TABLE IT_EKKO
WHERE EBELN IN S_EBELN.
*-----if there are no records display an error
IF SY-SUBRC NE 0.
MESSAGE E003.
ENDIF.
*-----Field catalog for the PO Header
REFRESH IT_FIELDCAT[].
WA_FIELDCAT-COL_POS = '1'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-KEY = 'X'.
WA_FIELDCAT-HOTSPOT = 'X'.
WA_FIELDCAT-REF_FIELDNAME = 'EBELN'.
WA_FIELDCAT-REF_TABNAME = 'EKKO'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = '2'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-REF_FIELDNAME = 'BUKRS'.
WA_FIELDCAT-REF_TABNAME = 'EKKO'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = '3'.
WA_FIELDCAT-FIELDNAME = 'BSART'.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-REF_FIELDNAME = 'BSART'.
WA_FIELDCAT-REF_TABNAME = 'EKKO'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = '4'.
WA_FIELDCAT-FIELDNAME = 'LIFNR'.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-REF_FIELDNAME = 'LIFNR'.
WA_FIELDCAT-REF_TABNAME = 'EKKO'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = '5'.
WA_FIELDCAT-FIELDNAME = 'SPRAS'.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-REF_FIELDNAME = 'SPRAS'.
WA_FIELDCAT-REF_TABNAME = 'EKKO'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = '6'.
WA_FIELDCAT-FIELDNAME = 'ZTERM'.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-REF_FIELDNAME = 'ZTERM'.
WA_FIELDCAT-REF_TABNAME = 'EKKO'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
*-----to display the header details
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = IT_FIELDCAT[]
TABLES
T_OUTTAB = IT_EKKO[].
&----
*& Form USER_COMMAND
&----
text
----
-->UCOMM text
-->FIELD1 text
----
FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM FIELD1 TYPE "#EC CALLED
SLIS_SELFIELD. "#EC *
READ TABLE IT_EKKO INTO WA_EKKO INDEX FIELD1-TABINDEX.
*-----retrieving item details from the PO Item table
SELECT EBELN EBELP WERKS MATNR MATKL
FROM EKPO
INTO TABLE IT_EKPO
WHERE EBELN = WA_EKKO-EBELN.
*-----to display an error if other than PO Number is clicked
IF SY-SUBRC NE 0.
MESSAGE E001.
ENDIF.
*-----Fieldcatalog for the PO item details
REFRESH IT_FIELDCAT1[].
WA_FIELDCAT1-COL_POS = '1'.
WA_FIELDCAT1-FIELDNAME = 'EBELN'.
WA_FIELDCAT1-TABNAME = 'IT_EKPO'.
WA_FIELDCAT1-REF_FIELDNAME = 'EBELN'.
WA_FIELDCAT1-REF_TABNAME = 'EKPO'.
APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.
CLEAR WA_FIELDCAT1.
WA_FIELDCAT1-COL_POS = '2'.
WA_FIELDCAT1-FIELDNAME = 'EBELP'.
WA_FIELDCAT1-TABNAME = 'IT_EKPO'.
WA_FIELDCAT1-REF_FIELDNAME = 'EBELP'.
WA_FIELDCAT1-REF_TABNAME = 'EKPO'.
APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.
CLEAR WA_FIELDCAT1.
WA_FIELDCAT1-COL_POS = '3'.
WA_FIELDCAT1-FIELDNAME = 'WERKS'.
WA_FIELDCAT1-TABNAME = 'IT_EKPO'.
WA_FIELDCAT1-REF_FIELDNAME = 'WERKS'.
WA_FIELDCAT1-REF_TABNAME = 'EKPO'.
APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.
CLEAR WA_FIELDCAT1.
WA_FIELDCAT1-COL_POS = '4'.
WA_FIELDCAT1-FIELDNAME = 'MATNR'.
WA_FIELDCAT1-TABNAME = 'IT_EKPO'.
WA_FIELDCAT1-REF_FIELDNAME = 'MATNR'.
WA_FIELDCAT1-REF_TABNAME = 'EKPO'.
APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.
CLEAR WA_FIELDCAT1.
WA_FIELDCAT1-COL_POS = '5'.
WA_FIELDCAT1-FIELDNAME = 'MATKL'.
WA_FIELDCAT1-TABNAME = 'IT_EKPO'.
WA_FIELDCAT1-REF_FIELDNAME = 'MATKL'.
WA_FIELDCAT1-REF_TABNAME = 'EKPO'.
APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.
CLEAR WA_FIELDCAT1.
*-----to display the item details
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = IT_FIELDCAT1[]
TABLES
T_OUTTAB = IT_EKPO[].
ENDFORM. "user_command_form
regards,
srinivas
<b>*reward for useful answers*</b>
2007 Jul 21 2:12 PM
REPORT ZZ_22038_22098_002 NO STANDARD PAGE HEADING LINE-SIZE 650
MESSAGE-ID ZZ_9838 .
TYPE-POOLS: SLIS.
*type declaration for values from ekko
TYPES: BEGIN OF I_EKKO,
EBELN LIKE EKKO-EBELN,
AEDAT LIKE EKKO-AEDAT,
BUKRS LIKE EKKO-BUKRS,
BSART LIKE EKKO-BSART,
LIFNR LIKE EKKO-LIFNR,
END OF I_EKKO.
DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,
WA_EKKO TYPE I_EKKO.
*type declaration for values from ekpo
TYPES: BEGIN OF I_EKPO,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
MATNR LIKE EKPO-MATNR,
MENGE LIKE EKPO-MENGE,
MEINS LIKE EKPO-MEINS,
NETPR LIKE EKPO-NETPR,
END OF I_EKPO.
DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,
WA_EKPO TYPE I_EKPO .
*variable for Report ID
DATA: V_REPID LIKE SY-REPID .
*declaration for fieldcatalog
DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
declaration for events table where user comand or set PF status will
be defined
DATA: V_EVENTS TYPE SLIS_T_EVENT,
WA_EVENT TYPE SLIS_ALV_EVENT.
declartion for layout
DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
declaration for variant(type of display we want)
DATA: I_VARIANT TYPE DISVARIANT,
I_VARIANT1 TYPE DISVARIANT,
I_SAVE(1) TYPE C.
*PARAMETERS : p_var TYPE disvariant-variant.
*Title displayed when the alv list is displayed
DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.
DATA: I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.
INITIALIZATION.
V_REPID = SY-REPID.
PERFORM BUILD_FIELDCATLOG.
PERFORM EVENT_CALL.
PERFORM POPULATE_EVENT.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_REPORT.
&----
*& Form BUILD_FIELDCATLOG
&----
Fieldcatalog has all the field details from ekko
----
FORM BUILD_FIELDCATLOG.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'AEDAT'.
WA_FIELDCAT-SELTEXT_M = 'DATE.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'LIFNR'.
WA_FIELDCAT-NO_OUT = 'X'.
WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG
&----
*& Form EVENT_CALL
&----
we get all events - TOP OF PAGE or USER COMMAND in table v_events
----
FORM EVENT_CALL.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
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.
ENDFORM. "EVENT_CALL
&----
*& Form POPULATE_EVENT
&----
Events populated for TOP OF PAGE & USER COMAND
----
FORM POPULATE_EVENT.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'USER_COMMAND'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-NAME.
ENDIF.
ENDFORM. "POPULATE_EVENT
&----
*& Form data_retrieval
&----
retreiving values from the database table ekko
----
FORM DATA_RETRIEVAL.
SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.
ENDFORM. "data_retrieval
&----
*& Form bUild_listheader
&----
text
----
-->I_LISTHEADEtext
----
FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA HLINE TYPE SLIS_LISTHEADER.
HLINE-INFO = 'this is my first alv pgm'.
HLINE-TYP = 'H'.
ENDFORM. "build_listheader
&----
*& Form display_alv_report
&----
text
----
FORM DISPLAY_ALV_REPORT.
V_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = I_TITLE_EKKO
I_GRID_SETTINGS =
IS_LAYOUT = ALV_LAYOUT
IT_FIELDCAT = I_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
i_default = 'ZLAY1'
I_SAVE = 'A'
is_variant = i_variant
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_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.
ENDFORM. "display_alv_report
&----
*& Form TOP_OF_PAGE
&----
text
----
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
i_logo =
I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
&----
*& Form USER_COMMAND
&----
text
----
-->R_UCOMM text
-->, text
-->RS_SLEFIELDtext
----
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
PERFORM BUILD_FIELDCATLOG_EKPO.
PERFORM EVENT_CALL_EKPO.
PERFORM POPULATE_EVENT_EKPO.
PERFORM DATA_RETRIEVAL_EKPO.
PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_EKPO.
ENDCASE.
ENDFORM. "user_command
&----
*& Form BUILD_FIELDCATLOG_EKPO
&----
text
----
FORM BUILD_FIELDCATLOG_EKPO.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELP'.
WA_FIELDCAT-SELTEXT_M = 'LINE NO'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MENGE'.
WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MEINS'.
WA_FIELDCAT-SELTEXT_M = 'UOM'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'NETPR'.
WA_FIELDCAT-SELTEXT_M = 'PRICE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG_EKPO
&----
*& Form event_call_ekpo
&----
we get all events - TOP OF PAGE or USER COMMAND in table v_events
----
FORM EVENT_CALL_EKPO.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
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.
ENDFORM. "event_call_ekpo
&----
*& Form POPULATE_EVENT
&----
Events populated for TOP OF PAGE & USER COMAND
----
FORM POPULATE_EVENT_EKPO.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
ENDFORM. "POPULATE_EVENT
&----
*& Form TOP_OF_PAGE
&----
text
----
FORM F_TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
i_logo =
I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
&----
*& Form USER_COMMAND
&----
text
----
-->R_UCOMM text
-->, text
-->RS_SLEFIELDtext
----
*retreiving values from the database table ekko
FORM DATA_RETRIEVAL_EKPO.
SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.
ENDFORM.
FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA: HLINE1 TYPE SLIS_LISTHEADER.
HLINE1-TYP = 'H'.
HLINE1-INFO = 'CHECKING PGM'.
ENDFORM.
FORM DISPLAY_ALV_EKPO.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE = I_TITLE_EKPO
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = I_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT =
I_SAVE = 'A'
IS_VARIANT =
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_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.
ENDFORM.
____________________________________________________________________
another sample code
TYPE-POOLS: SLIS.
*type declaration for values from ekko
TYPES: BEGIN OF I_EKKO,
EBELN LIKE EKKO-EBELN,
AEDAT LIKE EKKO-AEDAT,
BUKRS LIKE EKKO-BUKRS,
BSART LIKE EKKO-BSART,
LIFNR LIKE EKKO-LIFNR,
END OF I_EKKO.
DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,
WA_EKKO TYPE I_EKKO.
*type declaration for values from ekpo
TYPES: BEGIN OF I_EKPO,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
MATNR LIKE EKPO-MATNR,
MENGE LIKE EKPO-MENGE,
MEINS LIKE EKPO-MEINS,
NETPR LIKE EKPO-NETPR,
END OF I_EKPO.
DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,
WA_EKPO TYPE I_EKPO .
*variable for Report ID
DATA: V_REPID LIKE SY-REPID .
*declaration for fieldcatalog
DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
declaration for events table where user comand or set PF status will
be defined
DATA: V_EVENTS TYPE SLIS_T_EVENT,
WA_EVENT TYPE SLIS_ALV_EVENT.
declartion for layout
DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
declaration for variant(type of display we want)
DATA: I_VARIANT TYPE DISVARIANT,
I_VARIANT1 TYPE DISVARIANT,
I_SAVE(1) TYPE C.
*PARAMETERS : p_var TYPE disvariant-variant.
*Title displayed when the alv list is displayed
DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.
DATA: I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.
INITIALIZATION.
V_REPID = SY-REPID.
PERFORM BUILD_FIELDCATLOG.
PERFORM EVENT_CALL.
PERFORM POPULATE_EVENT.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_REPORT.
&----
*& Form BUILD_FIELDCATLOG
&----
Fieldcatalog has all the field details from ekko
----
FORM BUILD_FIELDCATLOG.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'AEDAT'.
WA_FIELDCAT-SELTEXT_M = 'DATE.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'LIFNR'.
WA_FIELDCAT-NO_OUT = 'X'.
WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG
&----
*& Form EVENT_CALL
&----
we get all events - TOP OF PAGE or USER COMMAND in table v_events
----
FORM EVENT_CALL.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
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.
ENDFORM. "EVENT_CALL
&----
*& Form POPULATE_EVENT
&----
Events populated for TOP OF PAGE & USER COMAND
----
FORM POPULATE_EVENT.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'USER_COMMAND'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-NAME.
ENDIF.
ENDFORM. "POPULATE_EVENT
&----
*& Form data_retrieval
&----
retreiving values from the database table ekko
----
FORM DATA_RETRIEVAL.
SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.
ENDFORM. "data_retrieval
&----
*& Form bUild_listheader
&----
text
----
-->I_LISTHEADEtext
----
FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA HLINE TYPE SLIS_LISTHEADER.
HLINE-INFO = 'this is my first alv pgm'.
HLINE-TYP = 'H'.
ENDFORM. "build_listheader
&----
*& Form display_alv_report
&----
text
----
FORM DISPLAY_ALV_REPORT.
V_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = I_TITLE_EKKO
I_GRID_SETTINGS =
IS_LAYOUT = ALV_LAYOUT
IT_FIELDCAT = I_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
i_default = 'ZLAY1'
I_SAVE = 'A'
is_variant = i_variant
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_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.
ENDFORM. "display_alv_report
&----
*& Form TOP_OF_PAGE
&----
text
----
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
i_logo =
I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
&----
*& Form USER_COMMAND
&----
text
----
-->R_UCOMM text
-->, text
-->RS_SLEFIELDtext
----
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
PERFORM BUILD_FIELDCATLOG_EKPO.
PERFORM EVENT_CALL_EKPO.
PERFORM POPULATE_EVENT_EKPO.
PERFORM DATA_RETRIEVAL_EKPO.
PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_EKPO.
ENDCASE.
ENDFORM. "user_command
&----
*& Form BUILD_FIELDCATLOG_EKPO
&----
text
----
FORM BUILD_FIELDCATLOG_EKPO.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELP'.
WA_FIELDCAT-SELTEXT_M = 'LINE NO'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MENGE'.
WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MEINS'.
WA_FIELDCAT-SELTEXT_M = 'UOM'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'NETPR'.
WA_FIELDCAT-SELTEXT_M = 'PRICE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG_EKPO
&----
*& Form event_call_ekpo
&----
we get all events - TOP OF PAGE or USER COMMAND in table v_events
----
FORM EVENT_CALL_EKPO.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
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.
ENDFORM. "event_call_ekpo
&----
*& Form POPULATE_EVENT
&----
Events populated for TOP OF PAGE & USER COMAND
----
FORM POPULATE_EVENT_EKPO.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
ENDFORM. "POPULATE_EVENT
&----
*& Form TOP_OF_PAGE
&----
text
----
FORM F_TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
i_logo =
I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
&----
*& Form USER_COMMAND
&----
text
----
-->R_UCOMM text
-->, text
-->RS_SLEFIELDtext
----
*retreiving values from the database table ekko
FORM DATA_RETRIEVAL_EKPO.
SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.
ENDFORM.
FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA: HLINE1 TYPE SLIS_LISTHEADER.
HLINE1-TYP = 'H'.
HLINE1-INFO = 'CHECKING PGM'.
ENDFORM.
FORM DISPLAY_ALV_EKPO.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE = I_TITLE_EKPO
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = I_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT =
I_SAVE = 'A'
IS_VARIANT =
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_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.
ENDFORM.
___________________________________________________________________
REPORT Z_PO_ALV_R02 NO STANDARD PAGE HEADING MESSAGE-ID ZROJA.
*-----tables declaration
TABLES:EKKO.
TYPE-POOLS:SLIS.
*-----data declaration
TYPES:BEGIN OF X_EKKO,
EBELN type EKKO-EBELN, "PO Number
BUKRS type EKKO-BUKRS, "Company code
BSART type EKKO-BSART, "Purchasing Document type
LIFNR type EKKO-LIFNR, "Vendor
SPRAS type EKKO-SPRAS, "Language Key
ZTERM type EKKO-ZTERM, "Terms of payment key
END OF X_EKKO,
BEGIN OF X_EKPO,
EBELN type EKPO-EBELN,
EBELP type EKPO-EBELP, "Item number
WERKS type EKPO-WERKS, "Plant
MATNR type EKPO-MATNR, "Material Number
MATKL type EKPO-MATKL, "Material Group
END OF X_EKPO.
DATA:IT_EKKO TYPE STANDARD TABLE OF X_EKKO,
IT_EKPO TYPE STANDARD TABLE OF X_EKPO,
WA_EKKO TYPE X_EKKO,
WA_EKPO TYPE X_EKPO, "#EC *
IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
IT_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
WA_FIELDCAT1 TYPE SLIS_FIELDCAT_ALV.
*-----Selection-screen design
SELECTION-SCREEN BEGIN OF BLOCK B1.
SELECT-OPTIONS:S_EBELN FOR EKKO-EBELN.
SELECTION-SCREEN END OF BLOCK B1.
*-----SELECTION-SCREEN VALIDATION
AT SELECTION-SCREEN.
SELECT EBELN
FROM EKKO
INTO TABLE IT_EKKO
WHERE EBELN IN S_EBELN.
*-----if there are no values display an error
IF SY-SUBRC NE 0.
MESSAGE E009.
ENDIF.
*-----Data retrieval
START-OF-SELECTION.
*-----retrieving data from the PO header
SELECT EBELN BUKRS BSART LIFNR SPRAS ZTERM
FROM EKKO
INTO TABLE IT_EKKO
WHERE EBELN IN S_EBELN.
*-----if there are no records display an error
IF SY-SUBRC NE 0.
MESSAGE E003.
ENDIF.
*-----Field catalog for the PO Header
REFRESH IT_FIELDCAT[].
WA_FIELDCAT-COL_POS = '1'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-KEY = 'X'.
WA_FIELDCAT-HOTSPOT = 'X'.
WA_FIELDCAT-REF_FIELDNAME = 'EBELN'.
WA_FIELDCAT-REF_TABNAME = 'EKKO'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = '2'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-REF_FIELDNAME = 'BUKRS'.
WA_FIELDCAT-REF_TABNAME = 'EKKO'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = '3'.
WA_FIELDCAT-FIELDNAME = 'BSART'.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-REF_FIELDNAME = 'BSART'.
WA_FIELDCAT-REF_TABNAME = 'EKKO'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = '4'.
WA_FIELDCAT-FIELDNAME = 'LIFNR'.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-REF_FIELDNAME = 'LIFNR'.
WA_FIELDCAT-REF_TABNAME = 'EKKO'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = '5'.
WA_FIELDCAT-FIELDNAME = 'SPRAS'.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-REF_FIELDNAME = 'SPRAS'.
WA_FIELDCAT-REF_TABNAME = 'EKKO'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = '6'.
WA_FIELDCAT-FIELDNAME = 'ZTERM'.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-REF_FIELDNAME = 'ZTERM'.
WA_FIELDCAT-REF_TABNAME = 'EKKO'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
*-----to display the header details
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = IT_FIELDCAT[]
TABLES
T_OUTTAB = IT_EKKO[].
&----
*& Form USER_COMMAND
&----
text
----
-->UCOMM text
-->FIELD1 text
----
FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM FIELD1 TYPE "#EC CALLED
SLIS_SELFIELD. "#EC *
READ TABLE IT_EKKO INTO WA_EKKO INDEX FIELD1-TABINDEX.
*-----retrieving item details from the PO Item table
SELECT EBELN EBELP WERKS MATNR MATKL
FROM EKPO
INTO TABLE IT_EKPO
WHERE EBELN = WA_EKKO-EBELN.
*-----to display an error if other than PO Number is clicked
IF SY-SUBRC NE 0.
MESSAGE E001.
ENDIF.
*-----Fieldcatalog for the PO item details
REFRESH IT_FIELDCAT1[].
WA_FIELDCAT1-COL_POS = '1'.
WA_FIELDCAT1-FIELDNAME = 'EBELN'.
WA_FIELDCAT1-TABNAME = 'IT_EKPO'.
WA_FIELDCAT1-REF_FIELDNAME = 'EBELN'.
WA_FIELDCAT1-REF_TABNAME = 'EKPO'.
APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.
CLEAR WA_FIELDCAT1.
WA_FIELDCAT1-COL_POS = '2'.
WA_FIELDCAT1-FIELDNAME = 'EBELP'.
WA_FIELDCAT1-TABNAME = 'IT_EKPO'.
WA_FIELDCAT1-REF_FIELDNAME = 'EBELP'.
WA_FIELDCAT1-REF_TABNAME = 'EKPO'.
APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.
CLEAR WA_FIELDCAT1.
WA_FIELDCAT1-COL_POS = '3'.
WA_FIELDCAT1-FIELDNAME = 'WERKS'.
WA_FIELDCAT1-TABNAME = 'IT_EKPO'.
WA_FIELDCAT1-REF_FIELDNAME = 'WERKS'.
WA_FIELDCAT1-REF_TABNAME = 'EKPO'.
APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.
CLEAR WA_FIELDCAT1.
WA_FIELDCAT1-COL_POS = '4'.
WA_FIELDCAT1-FIELDNAME = 'MATNR'.
WA_FIELDCAT1-TABNAME = 'IT_EKPO'.
WA_FIELDCAT1-REF_FIELDNAME = 'MATNR'.
WA_FIELDCAT1-REF_TABNAME = 'EKPO'.
APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.
CLEAR WA_FIELDCAT1.
WA_FIELDCAT1-COL_POS = '5'.
WA_FIELDCAT1-FIELDNAME = 'MATKL'.
WA_FIELDCAT1-TABNAME = 'IT_EKPO'.
WA_FIELDCAT1-REF_FIELDNAME = 'MATKL'.
WA_FIELDCAT1-REF_TABNAME = 'EKPO'.
APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.
CLEAR WA_FIELDCAT1.
*-----to display the item details
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = IT_FIELDCAT1[]
TABLES
T_OUTTAB = IT_EKPO[].
ENDFORM. "user_command_form
regards,
srinivas
<b>*reward for useful answers*</b>
2007 Jul 21 2:47 PM
<b>An Interactive ALV Report</b>
&----
*& Report ZZ_22038_22098_002 *
*& *
&----
*& This is an Interactive ALV report, where on line slection we can see
*& the secondry list
*&
*& *
&----
REPORT ZZ_22038_22098_002 NO STANDARD PAGE HEADING LINE-SIZE 650
MESSAGE-ID ZZ_9838 .
TYPE-POOLS: SLIS.
*type declaration for values from ekko
TYPES: BEGIN OF I_EKKO,
EBELN LIKE EKKO-EBELN,
AEDAT LIKE EKKO-AEDAT,
BUKRS LIKE EKKO-BUKRS,
BSART LIKE EKKO-BSART,
LIFNR LIKE EKKO-LIFNR,
END OF I_EKKO.
DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,
WA_EKKO TYPE I_EKKO.
*type declaration for values from ekpo
TYPES: BEGIN OF I_EKPO,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
MATNR LIKE EKPO-MATNR,
MENGE LIKE EKPO-MENGE,
MEINS LIKE EKPO-MEINS,
NETPR LIKE EKPO-NETPR,
END OF I_EKPO.
DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,
WA_EKPO TYPE I_EKPO .
*variable for Report ID
DATA: V_REPID LIKE SY-REPID .
*declaration for fieldcatalog
DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
declaration for events table where user comand or set PF status will
be defined
DATA: V_EVENTS TYPE SLIS_T_EVENT,
WA_EVENT TYPE SLIS_ALV_EVENT.
declartion for layout
DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
declaration for variant(type of display we want)
DATA: I_VARIANT TYPE DISVARIANT,
I_VARIANT1 TYPE DISVARIANT,
I_SAVE(1) TYPE C.
*PARAMETERS : p_var TYPE disvariant-variant.
*Title displayed when the alv list is displayed
DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.
DATA: I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.
INITIALIZATION.
V_REPID = SY-REPID.
PERFORM BUILD_FIELDCATLOG.
PERFORM EVENT_CALL.
PERFORM POPULATE_EVENT.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_REPORT.
&----
*& Form BUILD_FIELDCATLOG
&----
Fieldcatalog has all the field details from ekko
----
FORM BUILD_FIELDCATLOG.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'AEDAT'.
WA_FIELDCAT-SELTEXT_M = 'DATE.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'LIFNR'.
WA_FIELDCAT-NO_OUT = 'X'.
WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG
&----
*& Form EVENT_CALL
&----
we get all events - TOP OF PAGE or USER COMMAND in table v_events
----
FORM EVENT_CALL.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
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.
ENDFORM. "EVENT_CALL
&----
*& Form POPULATE_EVENT
&----
Events populated for TOP OF PAGE & USER COMAND
----
FORM POPULATE_EVENT.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'USER_COMMAND'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-NAME.
ENDIF.
ENDFORM. "POPULATE_EVENT
&----
*& Form data_retrieval
&----
retreiving values from the database table ekko
----
FORM DATA_RETRIEVAL.
SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.
ENDFORM. "data_retrieval
&----
*& Form bUild_listheader
&----
text
----
-->I_LISTHEADEtext
----
FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA HLINE TYPE SLIS_LISTHEADER.
HLINE-INFO = 'this is my first alv pgm'.
HLINE-TYP = 'H'.
ENDFORM. "build_listheader
&----
*& Form display_alv_report
&----
text
----
FORM DISPLAY_ALV_REPORT.
V_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = I_TITLE_EKKO
I_GRID_SETTINGS =
IS_LAYOUT = ALV_LAYOUT
IT_FIELDCAT = I_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
i_default = 'ZLAY1'
I_SAVE = 'A'
is_variant = i_variant
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_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.
ENDFORM. "display_alv_report
&----
*& Form TOP_OF_PAGE
&----
text
----
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
i_logo =
I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
&----
*& Form USER_COMMAND
&----
text
----
-->R_UCOMM text
-->, text
-->RS_SLEFIELDtext
----
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
PERFORM BUILD_FIELDCATLOG_EKPO.
PERFORM EVENT_CALL_EKPO.
PERFORM POPULATE_EVENT_EKPO.
PERFORM DATA_RETRIEVAL_EKPO.
PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_EKPO.
ENDCASE.
ENDFORM. "user_command
&----
*& Form BUILD_FIELDCATLOG_EKPO
&----
text
----
FORM BUILD_FIELDCATLOG_EKPO.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELP'.
WA_FIELDCAT-SELTEXT_M = 'LINE NO'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MENGE'.
WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MEINS'.
WA_FIELDCAT-SELTEXT_M = 'UOM'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'NETPR'.
WA_FIELDCAT-SELTEXT_M = 'PRICE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG_EKPO
&----
*& Form event_call_ekpo
&----
we get all events - TOP OF PAGE or USER COMMAND in table v_events
----
FORM EVENT_CALL_EKPO.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
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.
ENDFORM. "event_call_ekpo
&----
*& Form POPULATE_EVENT
&----
Events populated for TOP OF PAGE & USER COMAND
----
FORM POPULATE_EVENT_EKPO.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
ENDFORM. "POPULATE_EVENT
&----
*& Form TOP_OF_PAGE
&----
text
----
FORM F_TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
i_logo =
I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
&----
*& Form USER_COMMAND
&----
text
----
-->R_UCOMM text
-->, text
-->RS_SLEFIELDtext
----
*retreiving values from the database table ekko
FORM DATA_RETRIEVAL_EKPO.
SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.
ENDFORM.
FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA: HLINE1 TYPE SLIS_LISTHEADER.
HLINE1-TYP = 'H'.
HLINE1-INFO = 'CHECKING PGM'.
ENDFORM.
FORM DISPLAY_ALV_EKPO.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE = I_TITLE_EKPO
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = I_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT =
I_SAVE = 'A'
IS_VARIANT =
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_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.
ENDFORM.
<b>Example 2</b>
TYPE-POOLS : SLIS.
TYPES:BEGIN OF TW_VBAK,
VBELN TYPE VBELN_VA,
ERNAM TYPE ERNAM,
ERDAT TYPE ERDAT,
VBTYP TYPE VBTYP,
END OF TW_VBAK,
TT_VBAK TYPE STANDARD TABLE OF TW_VBAK.
TYPES:BEGIN OF TW_VBAP,
VBELN TYPE VBELN_VA,
POSNR TYPE POSNR_VA,
MATNR TYPE MATNR,
ARKTX TYPE ARKTX,
END OF TW_VBAP,
TT_VBAP TYPE STANDARD TABLE OF TW_VBAP.
DATA:LW_FIELDCAT1 TYPE SLIS_FIELDCAT_ALV,
LT_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV,
LW_FIELDCAT2 TYPE SLIS_FIELDCAT_ALV,
LT_FIELDCAT2 TYPE SLIS_T_FIELDCAT_ALV,
LF_VBELN TYPE VBELN_VA.
DATA:LT_VBAK TYPE TT_VBAK,
LT_VBAP TYPE TT_VBAP,
LF_REPID TYPE SYREPID.
SELECTION-SCREEN BEGIN OF block B1 with FRAME TITLE TEXT-001.
SELECT-OPTIONS:SO_VBELN FOR LF_VBELN.
SELECTION-SCREEN END OF BLOCK B1.
start-of-selection.
SELECT VBELN ERNAM ERDAT VBTYP INTO TABLE LT_VBAK
FROM VBAK
WHERE VBELN IN SO_VBELN.
LW_FIELDCAT1-COL_POS = '1'.
LW_FIELDCAT1-FIELDNAME = 'VBELN'.
LW_FIELDCAT1-TABNAME = 'LT_VBAK'.
LW_FIELDCAT1-REF_FIELDNAME = 'VBELN'.
LW_FIELDCAT1-REF_TABNAME = 'VBAK'.
LW_FIELDCAT1-SELTEXT_M = 'SALES NUMBER'.
LW_FIELDCAT1-HOTSPOT = 'X'.
APPEND LW_FIELDCAT1 TO LT_FIELDCAT1.
LW_FIELDCAT1-COL_POS = '2'.
LW_FIELDCAT1-FIELDNAME = 'ERNAM'.
LW_FIELDCAT1-TABNAME = 'LT_VBAK'.
LW_FIELDCAT1-REF_FIELDNAME = 'ERNAM'.
LW_FIELDCAT1-REF_TABNAME = 'VBAK'.
LW_FIELDCAT1-SELTEXT_M = 'NAME'.
LW_FIELDCAT1-HOTSPOT = 'X'.
APPEND LW_FIELDCAT1 TO LT_FIELDCAT1.
LW_FIELDCAT1-COL_POS = '3'.
LW_FIELDCAT1-FIELDNAME = 'ERDAT'.
LW_FIELDCAT1-TABNAME = 'LT_VBAK'.
LW_FIELDCAT1-REF_FIELDNAME = 'ERDAT'.
LW_FIELDCAT1-REF_TABNAME = 'VBAK'.
LW_FIELDCAT1-SELTEXT_M = 'DATE'.
LW_FIELDCAT1-HOTSPOT = 'X'.
APPEND LW_FIELDCAT1 TO LT_FIELDCAT1.
LW_FIELDCAT1-COL_POS = '4'.
LW_FIELDCAT1-FIELDNAME = 'VBTYP'.
LW_FIELDCAT1-TABNAME = 'LT_VBAK'.
LW_FIELDCAT1-REF_FIELDNAME = 'VBTYP'.
LW_FIELDCAT1-REF_TABNAME = 'VBAK'.
LW_FIELDCAT1-SELTEXT_M = 'TYPE'.
LW_FIELDCAT1-HOTSPOT = 'X'.
APPEND LW_FIELDCAT1 TO LT_FIELDCAT1.
LW_FIELDCAT2-COL_POS = '1'.
LW_FIELDCAT2-FIELDNAME = 'VBELN'.
LW_FIELDCAT2-TABNAME = 'LT_VBAP'.
LW_FIELDCAT2-REF_FIELDNAME = 'VBELN'.
LW_FIELDCAT2-REF_TABNAME = 'VBAP'.
LW_FIELDCAT2-SELTEXT_M = 'SALES NUMBER'.
APPEND LW_FIELDCAT2 TO LT_FIELDCAT2.
LW_FIELDCAT2-COL_POS = '2'.
LW_FIELDCAT2-FIELDNAME = 'POSNR'.
LW_FIELDCAT2-TABNAME = 'LT_VBAP'.
LW_FIELDCAT2-REF_FIELDNAME = 'POSNR'.
LW_FIELDCAT2-REF_TABNAME = 'VBAP'.
LW_FIELDCAT2-SELTEXT_M = 'ITEM NUMBER'.
APPEND LW_FIELDCAT2 TO LT_FIELDCAT2.
LW_FIELDCAT2-COL_POS = '3'.
LW_FIELDCAT2-FIELDNAME = 'MATNR'.
LW_FIELDCAT2-TABNAME = 'LT_VBAP'.
LW_FIELDCAT2-REF_FIELDNAME = 'MATNR'.
LW_FIELDCAT2-REF_TABNAME = 'VBAP'.
LW_FIELDCAT2-SELTEXT_M = 'MATERIAL NUMBER'.
APPEND LW_FIELDCAT2 TO LT_FIELDCAT2.
LW_FIELDCAT2-COL_POS = '4'.
LW_FIELDCAT2-FIELDNAME = 'ARKTX'.
LW_FIELDCAT2-TABNAME = 'LT_VBAP'.
LW_FIELDCAT2-REF_FIELDNAME = 'ARKTX'.
LW_FIELDCAT2-REF_TABNAME = 'VBAP'.
LW_FIELDCAT2-SELTEXT_M = 'SHORT TEXT FOR SALES ORDER ITEM'.
APPEND LW_FIELDCAT2 TO LT_FIELDCAT2.
LF_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = LF_REPID
I_CALLBACK_USER_COMMAND = 'INTERACTIVE'
IT_FIELDCAT = LT_FIELDCAT1
TABLES
T_OUTTAB = LT_VBAK[]
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 INTERACTIVE USING LF_UCOMM TYPE SYUCOMM
LF_FIELD TYPE SLIS_SELFIELD.
DATA: LF_VBELN TYPE VBELN_VA.
CASE LF_UCOMM.
WHEN '&IC1'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = LF_FIELD-VALUE
IMPORTING
OUTPUT = lf_vbeln
.
SELECT VBELN POSNR MATNR ARKTX INTO TABLE LT_VBAP
FROM VBAP
WHERE VBELN = lf_vbeln.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = LF_REPID
IT_FIELDCAT = LT_FIELDCAT2[]
TABLES
T_OUTTAB = LT_VBAP
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.
ENDFORM.
<b>Example 3</b>
REPORT ZTEST_ALV123 .
TYPE-POOLS:SLIS.
DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
IT_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV.
DATA: BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBAK-VBELN,
POSNR LIKE VBAP-POSNR,
END OF ITAB.
DATA: BEGIN OF ITAB1 OCCURS 0,
VBELN LIKE LIKP-VBELN,
POSNR LIKE LIPS-POSNR,
VGBEL LIKE LIPS-VGBEL,
VGPOS LIKE LIPS-VGPOS,
END OF ITAB1.
DATA: IT_LIPS LIKE ITAB1 OCCURS 0 WITH HEADER LINE.
SELECT VBELN
POSNR
UP TO 100 ROWS
FROM VBAP
INTO TABLE ITAB.
IF SY-SUBRC = 0.
SORT ITAB BY VBELN .
SELECT VBELN
POSNR
VGBEL
VGPOS
INTO TABLE ITAB1
FROM LIPS
FOR ALL ENTRIES IN ITAB
WHERE VGBEL = ITAB-VBELN
AND VGPOS = ITAB-POSNR.
ENDIF.
DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
X_FIELDCAT-FIELDNAME = 'VBELN'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 1.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
X_FIELDCAT-FIELDNAME = 'POSNR'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 1.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'PFSTATUS'
I_CALLBACK_USER_COMMAND = 'HANDLE_USER_COMMAND'
IT_FIELDCAT = IT_FIELDCAT
TABLES
T_OUTTAB = ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC = 0.
ENDIF.
&----
*& Form POPUP
&----
text
----
-->P_EXTAB text
----
FORM POPUP USING P_EXTAB TYPE SLIS_T_EXTAB.
"here double click on PFSTATUS and create the status, "activate, before that set PICK for choose(F2).
*- Pf status
SET PF-STATUS 'PFSTATUS'.
ENDFORM. " POPUP
&----
*& Form HANDLE_USER_COMMAND
&----
text
----
-->R_UCOMM text
-->RS_SELFIELD text
----
FORM HANDLE_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
IF RS_SELFIELD-FIELDNAME = 'VBELN'.
READ TABLE ITAB INDEX RS_SELFIELD-TABINDEX.
LOOP AT ITAB1 WHERE VGBEL = ITAB-VBELN
AND VGPOS = ITAB-POSNR.
MOVE-CORRESPONDING ITAB1 TO IT_LIPS.
APPEND IT_LIPS.
ENDLOOP.
PERFORM INTERACTIVE_REPORT.
ENDIF.
ENDCASE.
ENDFORM. "HANDLE_USER_COMMAND
&----
*& Form interactive_report
&----
text
----
FORM INTERACTIVE_REPORT .
X_FIELDCAT-FIELDNAME = 'VBELN'.
X_FIELDCAT-SELTEXT_L = 'VBELN'.
X_FIELDCAT-TABNAME = 'IT_LIPS'.
X_FIELDCAT-COL_POS = 1.
APPEND X_FIELDCAT TO IT_FIELDCAT1.
CLEAR X_FIELDCAT.
X_FIELDCAT-FIELDNAME = 'POSNR'.
X_FIELDCAT-SELTEXT_L = 'ITEM'.
X_FIELDCAT-TABNAME = 'IT_LIPS'.
X_FIELDCAT-COL_POS = 2.
APPEND X_FIELDCAT TO IT_FIELDCAT1.
CLEAR X_FIELDCAT.
X_FIELDCAT-FIELDNAME = 'VGBEL'.
X_FIELDCAT-SELTEXT_M = 'SO #'.
X_FIELDCAT-TABNAME = 'IT_LIPS'.
X_FIELDCAT-COL_POS = 3.
APPEND X_FIELDCAT TO IT_FIELDCAT1.
CLEAR X_FIELDCAT.
X_FIELDCAT-FIELDNAME = 'VGPOS'.
X_FIELDCAT-SELTEXT_M = 'SO ITEM'.
X_FIELDCAT-TABNAME = 'IT_LIPS'.
X_FIELDCAT-COL_POS = 4.
APPEND X_FIELDCAT TO IT_FIELDCAT1.
CLEAR X_FIELDCAT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = IT_FIELDCAT1
TABLES
T_OUTTAB = IT_LIPS
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC = 0.
ENDIF.
ENDFORM. " interactive_report
For More Examples go thru the following Thread,
Regards,
Pavan
2007 Jul 21 3:04 PM
Hi raj,
To make the ALV report interactive all we do is capture the user commands on the report and do the necessary actions... so to capture the user action we use the callback function of the alv....
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = ZTEMP <Name of program that captures user event>
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STAUS' <Name of Subroutine that sets the PF status of the ALV - Used to overwrite the standard one by copying from the standard program and making necessary changes to the copied pf-status>
I_CALLBACK_USER_COMMAND = 'FRM_HANDLE_USER_COMMAND'
<Name of the subroutine in the callback program ZTEMP which handles the user events>
I_GRID_TITLE = LW_ALV_TITLE <Title of the ALV grid>
IS_LAYOUT = LTH_LAYOUT <The display can be optimised here... any color or enhacements can be done from here>
IT_FIELDCAT = IT_FIELDCAT < field catalog - the internal table that holds the header information - i.e the fields to be displayed on the screen>
IT_EVENTS = IT_EVENT < Any event capture can be done here>
IT_EVENT_EXIT = IT_EXIT[] < Any back/cancel/exit events can be captured>
IMPORTING
E_EXIT_CAUSED_BY_CALLER = WA_EXIT <The structure that is to be displayed>
TABLES
T_OUTTAB = IT_MATERIAL < The values to be passed from this table>
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
So this is how you call the ALV grid for an interactive display...
The capture of the user command is done as follows...
FORM FRM_HANDLE_USER_COMMAND USING U_UCOMM LIKE SY-UCOMM
UH_SELFIELD TYPE SLIS_SELFIELD.
< This form in the program captures the user command in the U_UCOMM variable and the UH_SELFIELD has the details about the field on the screen on which user action was performed and so on - You may debug and find the values this table has... you ll find lot of useful information...>
CASE U_UCOMM. " Now using this case you can handle user events
WHEN '&F03'. " This is to check back command - find ucomm values by debugging
PERFORM POPUP_DIALOG.
IF GW_ANSWER <> '1'.
LEAVE SCREEN.
ELSE.
LEAVE TO SCREEN 0.
ENDIF.
WHEN 'CLER'.
double click a line
WHEN '&IC1'. " On double click on alv user command is &IC1
<code>
WHEN '&REF'. " refresh
ENDCASE.
ENDFORM. " FRM_HANDLE_USER_COMMAND
Hope this helps!!!!
Revert for further queries...
Reward useful answers
edited by,
Naveenan.
2007 Jul 21 5:02 PM
Find the below code..
-
&----
*& Report ZZ_22038_22098_002 *
*& *
&----
*& This is an Interactive ALV report, where on line slection we can see
*& the secondry list
*&
*& *
&----
report zz_22038_22098_002 no standard page heading line-size 650
message-id zz_9838 .
type-pools: slis.
*type declaration for values from ekko
types: begin of i_ekko,
ebeln like ekko-ebeln,
aedat like ekko-aedat,
bukrs like ekko-bukrs,
bsart like ekko-bsart,
lifnr like ekko-lifnr,
end of i_ekko.
data: it_ekko type standard table of i_ekko initial size 0,
wa_ekko type i_ekko.
*type declaration for values from ekpo
types: begin of i_ekpo,
ebeln like ekpo-ebeln,
ebelp like ekpo-ebelp,
matnr like ekpo-matnr,
menge like ekpo-menge,
meins like ekpo-meins,
netpr like ekpo-netpr,
end of i_ekpo.
data: it_ekpo type standard table of i_ekpo initial size 0,
wa_ekpo type i_ekpo .
*variable for Report ID
data: v_repid like sy-repid .
*declaration for fieldcatalog
data: i_fieldcat type slis_t_fieldcat_alv,
wa_fieldcat type slis_fieldcat_alv,
i_fieldcat1 type slis_t_fieldcat_alv,
wa_fieldcat1 type slis_fieldcat_alv.
data: it_listheader type slis_t_listheader.
declaration for events table where user comand or set PF status will
be defined
data: v_events type slis_t_event,
wa_event type slis_alv_event.
declartion for layout
data: alv_layout type slis_layout_alv.
declaration for variant(type of display we want)
data: i_variant type disvariant,
i_variant1 type disvariant,
i_save(1) type c.
*PARAMETERS : p_var TYPE disvariant-variant.
*Title displayed when the alv list is displayed
data: i_title_ekko type lvc_title value 'FIRST LIST DISPLAYED'.
data: i_title_ekpo type lvc_title value 'SECONDRY LIST DISPLAYED'.
parameters : p_ebeln type ekko-ebeln.
initialization.
V_REPID = SY-REPID.
PERFORM EVENT_CALL.
PERFORM POPULATE_EVENT.
start-of-selection.
perform data_retrieval.
perform build_listheader using it_listheader.
perform build_fieldcatlog.
perform display_alv_report.
&----
*& Form USER_COMMAND
&----
Calling secondary lists in ALV, where as we call these list's we use
SY_LSIND command in normal Intractive reports
----
-->R_UCOMM text
-->, text
-->RS_SLEFIELDtext
----
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
case r_ucomm.
when '&IC1'.
READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
perform data_retrieval_ekpo.
PERFORM EVENT_CALL_EKPO.
PERFORM POPULATE_EVENT_EKPO.
PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.
perform build_fieldcatlog_ekpo.
perform display_alv_ekpo.
endcase.
endform. "user_command
&----
*& Form TOP_OF_PAGE
&----
text
----
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = it_listheader
i_logo =
I_END_OF_LIST_GRID =
.
endform. "TOP_OF_PAGE
&----
*& Form BUILD_FIELDCATLOG
&----
Fieldcatalog has all the field details from ekko
----
form build_fieldcatlog.
wa_fieldcat-tabname = 'IT_EKKO'.
wa_fieldcat-fieldname = 'EBELN'.
wa_fieldcat-seltext_m = 'PO NO.'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'IT_EKKO'.
wa_fieldcat-fieldname = 'AEDAT'.
wa_fieldcat-seltext_m = 'DATE.'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'IT_EKKO'.
wa_fieldcat-fieldname = 'BUKRS'.
wa_fieldcat-seltext_m = 'COMPANY CODE'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'IT_EKKO'.
wa_fieldcat-fieldname = 'BUKRS'.
wa_fieldcat-seltext_m = 'DOCMENT TYPE'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'IT_EKKO'.
wa_fieldcat-fieldname = 'LIFNR'.
wa_fieldcat-no_out = 'X'.
wa_fieldcat-seltext_m = 'VENDOR CODE'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
endform. "BUILD_FIELDCATLOG
&----
*& Form EVENT_CALL
&----
we get all events - TOP OF PAGE or USER COMMAND in table v_events
----
form event_call.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = v_events
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.
endform. "EVENT_CALL
&----
*& Form POPULATE_EVENT
&----
Events populated for TOP OF PAGE & USER COMAND
----
form populate_event.
read table v_events into wa_event with key name = 'TOP_OF_PAGE'.
if sy-subrc eq 0.
wa_event-form = 'TOP_OF_PAGE'.
modify v_events from wa_event transporting form where name =
wa_event-form.
endif.
read table v_events into wa_event with key name = 'USER_COMMAND'.
if sy-subrc eq 0.
wa_event-form = 'USER_COMMAND'.
modify v_events from wa_event transporting form where name =
wa_event-name.
endif.
endform. "POPULATE_EVENT
&----
*& Form data_retrieval
&----
retreiving values from the database table ekko
----
form data_retrieval.
select ebeln aedat bukrs bsart lifnr from ekko into table it_ekko
where
ebeln = p_ebeln.
endform. "data_retrieval
&----
*& Form bUild_listheader
&----
text
----
-->I_LISTHEADEtext
----
form build_listheader using i_listheader type slis_t_listheader.
data hline type slis_listheader.
hline-info = 'this is my first alv pgm'.
hline-typ = 'H'.
endform. "build_listheader
&----
*& Form display_alv_report
&----
text
----
form display_alv_report.
v_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
i_callback_user_command = 'USER_COMMAND'
i_callback_top_of_page = 'TOP_OF_PAGE'
i_grid_title = 'FIRST LIST DISPLAY'
I_GRID_SETTINGS =
IS_LAYOUT = ALV_LAYOUT
it_fieldcat = i_fieldcat[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
i_default = 'ZLAY1'
i_save = 'A'
is_variant = i_variant
it_events = v_events
tables
t_outtab = it_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.
refresh i_fieldcat.
endform. "display_alv_report
&----
*& Form BUILD_FIELDCATLOG_EKPO
&----
text
----
form build_fieldcatlog_ekpo.
wa_fieldcat1-tabname = 'IT_EKPO'.
wa_fieldcat1-fieldname = 'EBELN'.
wa_fieldcat1-seltext_m = 'PO NO.'.
wa_fieldcat1-col_pos = 1.
append wa_fieldcat1 to i_fieldcat1.
clear wa_fieldcat1.
wa_fieldcat1-tabname = 'IT_EKPO'.
wa_fieldcat1-fieldname = 'EBELP'.
wa_fieldcat1-seltext_m = 'LINE NO'.
wa_fieldcat1-col_pos = 2.
append wa_fieldcat1 to i_fieldcat1.
clear wa_fieldcat1.
wa_fieldcat1-tabname = 'I_EKPO'.
wa_fieldcat1-fieldname = 'MATNR'.
wa_fieldcat1-seltext_m = 'MATERIAL NO.'.
wa_fieldcat1-col_pos = 3.
append wa_fieldcat1 to i_fieldcat1.
clear wa_fieldcat1.
wa_fieldcat1-tabname = 'I_EKPO'.
wa_fieldcat1-fieldname = 'MENGE'.
wa_fieldcat1-seltext_m = 'QUANTITY'.
wa_fieldcat1-col_pos = 4.
append wa_fieldcat1 to i_fieldcat1.
clear wa_fieldcat1.
wa_fieldcat1-tabname = 'I_EKPO'.
wa_fieldcat1-fieldname = 'MEINS'.
wa_fieldcat1-seltext_m = 'UOM'.
wa_fieldcat1-col_pos = 5.
append wa_fieldcat1 to i_fieldcat1.
clear wa_fieldcat1.
wa_fieldcat1-tabname = 'I_EKPO'.
wa_fieldcat1-fieldname = 'NETPR'.
wa_fieldcat1-seltext_m = 'PRICE'.
wa_fieldcat1-col_pos = 6.
wa_fieldcat1-do_sum = 'X'.
append wa_fieldcat1 to i_fieldcat1.
clear wa_fieldcat1.
endform. "BUILD_FIELDCATLOG_EKPO
&----
*& Form event_call_ekpo
&----
we get all events - TOP OF PAGE or USER COMMAND in table v_events
----
form event_call_ekpo.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = v_events
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.
endform. "event_call_ekpo
&----
*& Form POPULATE_EVENT
&----
Events populated for TOP OF PAGE & USER COMAND
----
form populate_event_ekpo.
read table v_events into wa_event with key name = 'TOP_OF_PAGE'.
if sy-subrc eq 0.
wa_event-form = 'TOP_OF_PAGE'.
modify v_events from wa_event transporting form where name =
wa_event-form.
endif.
endform. "POPULATE_EVENT
&----
*& Form TOP_OF_PAGE
&----
text
----
*FORM F_TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
i_logo =
I_END_OF_LIST_GRID =
.
*ENDFORM. "TOP_OF_PAGE
&----
*& Form USER_COMMAND
&----
text
----
-->R_UCOMM text
-->, text
-->RS_SLEFIELDtext
----
*retreiving values from the database table ekko
form data_retrieval_ekpo.
select ebeln ebelp matnr menge meins netpr from ekpo into table it_ekpo
where
ebeln = p_ebeln.
endform.
form build_listheader_ekpo using i_listheader type slis_t_listheader.
data: hline1 type slis_listheader.
hline1-typ = 'H'.
hline1-info = 'CHECKING PGM'.
endform.
form display_alv_ekpo.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
i_callback_user_command = 'USER_COMMAND'
i_callback_top_of_page = 'TOP_OF_PAGE'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
i_grid_title = i_title_ekpo
I_GRID_SETTINGS =
IS_LAYOUT =
it_fieldcat = i_fieldcat1
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT =
i_save = 'A'
IS_VARIANT =
it_events = v_events
tables
t_outtab = it_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.
endform.
-
Hope this will help for you..
Reward the points if it is usefull for you.