Posted: Sat Jan 26, 2008 5:13 pm Post subject: Demo of FM REUSE_ALV_LIST_DISPLAY - Several Lists
Code:
REPORT z_alv_list_block_2.
*---------------------------------------------------------------------*
* Demo of FM REUSE_ALV_LIST_DISPLAY - Several Lists *
*---------------------------------------------------------------------*
* Author : Michel PIOUD - Updated 21-Dec-07 *
* HomePage : http://www.geocities.com/mpioud *
*---------------------------------------------------------------------*
CONSTANTS :
c_x VALUE 'X'.
*---------------------------------------------------------------------*
* Macro definition
DEFINE m_fieldcat.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = &2.
ls_fieldcat-tabname = &3.
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
DEFINE m_sort.
ls_sort-fieldname = &1.
ls_sort-up = c_x.
append ls_sort to lt_sort.
END-OF-DEFINITION.
*---------------------------------------------------------------------*
TYPE-POOLS: slis. " ALV Global types
TYPES:
* 1st Table
BEGIN OF ty_kna1,
kunnr TYPE kna1-kunnr, " Customer number
ernam TYPE kna1-ernam, " Name of Person who Created
erdat TYPE kna1-erdat, " Creation date
name1 TYPE kna1-name1, " Name 1 .
END OF ty_kna1,
* 2nd Table
BEGIN OF ty_mara,
matnr TYPE mara-matnr, " Material number
ernam TYPE mara-ernam, " Name of Person who Created
ersda TYPE mara-ersda, " Creation date
mtart TYPE mara-mtart, " Material type
matkl TYPE mara-matkl, " Material group
END OF ty_mara,
* 3rd Table
BEGIN OF ty_vbak,
vbeln TYPE vbak-vbeln, " Sales document
vkorg TYPE vbak-vkorg, " Sales organization
vtweg TYPE vbak-vtweg, " Distribution channel
kunnr TYPE vbak-kunnr, " Sold-to party
erdat TYPE vbak-erdat, " Creation date
END OF ty_vbak.
*---------------------------------------------------------------------*
DATA:
gs_layout TYPE slis_layout_alv,
gt_kna1 TYPE TABLE OF ty_kna1,
gt_mara TYPE TABLE OF ty_mara,
gt_vbak TYPE TABLE OF ty_vbak.
*---------------------------------------------------------------------*
SELECTION-SCREEN :
SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max. "#EC NEEDED
PARAMETERS p_max(2) TYPE n DEFAULT '02' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
*---------------------------------------------------------------------*
INITIALIZATION.
*---------------------------------------------------------------------*
* FORM USER_COMMAND *
*---------------------------------------------------------------------*
FORM user_command USING u_ucomm TYPE sy-ucomm
us_selfield TYPE slis_selfield. "#EC CALLED
DATA:
ls_vbak TYPE ty_vbak.
CASE u_ucomm.
WHEN '&IC1'. " Pick
CASE us_selfield-tabname.
WHEN 'GT_MARA'.
WHEN 'GT_KNA1'.
WHEN 'GT_VBAK'.
READ TABLE gt_vbak INDEX us_selfield-tabindex INTO ls_vbak.
IF sy-subrc EQ 0.
SET PARAMETER ID 'AUN' FIELD ls_vbak-vbeln.
CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDCASE.
ENDFORM. " USER_COMMAND
*---------------------------------------------------------------------*
* Form f_display_data
*---------------------------------------------------------------------*
FORM f_display_data.
DATA :
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv, " Field catalog
ls_sort TYPE slis_sortinfo_alv,
lt_sort TYPE slis_t_sortinfo_alv, " Sort table
lt_events TYPE slis_t_event,
ls_event TYPE slis_alv_event.
* Build Event Table
MOVE 'TOP_OF_PAGE' TO ls_event-name.
MOVE 'TOP_OF_PAGE' TO ls_event-form.
APPEND ls_event TO lt_events.
MOVE 'END_OF_LIST' TO ls_event-name.
MOVE 'END_OF_LIST' TO ls_event-form.
APPEND ls_event TO lt_events.
ENDFORM. " F_DISPLAY_DATA
*---------------------------------------------------------------------*
* FORM top_of_page *
*---------------------------------------------------------------------*
FORM top_of_page. "#EC CALLED
ENDFORM. " TOP_OF_PAGE
*---------------------------------------------------------------------*
* FORM End_of_list *
*---------------------------------------------------------------------*
FORM end_of_list. "#EC CALLED
DATA :
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv, " Field catalog
ls_sort TYPE slis_sortinfo_alv,
lt_sort TYPE slis_t_sortinfo_alv, " Sort table
lt_events TYPE slis_t_event,
ls_event TYPE slis_alv_event.
ENDFORM. " END_OF_LIST
*---------------------------------------------------------------------*
* FORM End_of_list_2 *
*---------------------------------------------------------------------*
FORM end_of_list_2. "#EC CALLED
DATA :
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv, " Field catalog
ls_sort TYPE slis_sortinfo_alv,
lt_sort TYPE slis_t_sortinfo_alv, " Sort table
lt_events TYPE slis_t_event,
ls_event TYPE slis_alv_event.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.