REPORT z_alv_list_block.
TYPE-POOLS: slis. " ALV Global types
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.
DATA:
* 1st Table
BEGIN OF gt_kna1 OCCURS 0, " Data displayed
kunnr LIKE kna1-kunnr, " Customer number
ernam LIKE kna1-ernam, " Name of Person who Created
erdat LIKE kna1-erdat, " Creation date
name1 LIKE kna1-name1, " Name 1
END OF gt_kna1,
* 2nd Table
BEGIN OF gt_mara OCCURS 0,
ernam LIKE mara-ernam, " Name of Person who Created
matnr LIKE mara-matnr, " Material number
ersda LIKE mara-e rsda, " Creation date
brgew LIKE mara-brgew, " Gross weight
END OF gt_mara,
* 3rd Table
BEGIN OF gt_vbak OCCURS 0,
vkorg LIKE vbak-vkorg, " Sales organization
kunnr LIKE vbak-kunnr, " Sold-to party
vbeln LIKE vbak-vbeln, " Sales document
netwr LIKE vbak-netwr, " Net Value of the Sales Order
waerk LIKE vbak-waerk, " SD document currency
END OF gt_vbak.
*---------------------------------------------------------------------*
INITIALIZATION.
v_1 = 'Maximum of records to read'.
*---------------------------------------------------------------------*
START-OF-SELECTION.
* Read data
SELECT * FROM kna1
UP TO p_max ROWS
INTO CORRESPONDING FIELDS OF TABLE gt_kna1.
SELECT * FROM mara
UP TO p_max ROWS
INTO CORRESPONDING FIELDS OF TABLE gt_mara.
SELECT * FROM vbak
UP TO p_max ROWS
INTO CORRESPONDING FIELDS OF TABLE gt_vbak.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
i_callback_program = sy-cprog
i_callback_user_command = 'USER_COMMAND'.
PERFORM list_append TABLES gt_kna1
USING '1'
'GT_KNA1'.
PERFORM list_append TABLES gt_mara
USING '2'
'GT_MARA'.
PERFORM list_append TABLES gt_vbak
USING '3'
'GT_VBAK'.
PERFORM f_list_display.
*---------------------------------------------------------------------*
* FORM USER_COMMAND *
*---------------------------------------------------------------------*
FORM user_command USING i_ucomm LIKE sy-ucomm
is_selfield TYPE slis_selfield. "#EC CALLED
CASE i_ucomm.
WHEN '&IC1'. " Pick
CASE is_selfield-tabname.
WHEN 'GT_MARA'.
WHEN 'GT_KNA1'.
WHEN 'GT_VBAK'.
READ TABLE gt_vbak INDEX is_selfield-tabindex.
IF sy-subrc EQ 0.
* Sales order number
SET PARAMETER ID 'AUN' FIELD gt_vbak-vbeln.
* Display Sales Order
CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDCASE.
ENDFORM. " USER_COMMAND
*---------------------------------------------------------------------*< /div>
* Form list_append
*---------------------------------------------------------------------*
FORM list_append TABLES ut_table
USING u_no TYPE char1
u_tabname TYPE slis_tabname.
* Macro definition
DEFINE m_fieldcat.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = &2.
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
DEFINE m_sort.
ls_sort-fieldname = &1.
ls_sort-up = 'X'.
append ls_sort to lt_sort.
END-OF-DEFINITION.
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
DATA:
lt_events TYPE slis_t_event,
ls_event TYPE slis_alv_event,
ls_layout TYPE slis_layout_alv.
ls_layout-group_change_edit = 'X'.
ls_layout-colwidth_optimize = 'X'.
ls_layout-zebra = 'X'.
ls_layout-detail_popup = 'X'.
ls_layout-get_selinfos = 'X'.
ls_layout-max_linesize = '200'.
CASE u_no.
WHEN '1'.
* Build field catalog and sort table
m_fieldcat 'KUNNR' 'KNA1'.
m_fieldcat 'ERNAM' 'KNA1'.
m_fieldcat 'ERDAT' 'KNA1'.
m_fieldcat 'NAME1' 'KNA1'.
m_sort 'KUNNR'.
WHEN '2'.
m_fieldcat 'MATNR' 'MARA'.
m_fieldcat 'ERNAM' 'MARA'.
m_fieldcat 'ERSDA' 'MARA'.
m_fieldcat 'BRGEW' 'MARA'.
m_sort 'MATNR'.
WHEN '3'.
m_fieldcat 'VBELN' 'VBAK'.
m_fieldcat 'VKORG' 'VBAK'.
m_fieldcat 'KUNNR' 'VBAK'.
m_fieldcat 'NETWR' 'VBAK'.
m_fieldcat 'WAERK' 'VBAK'.
m_sort 'VBELN'.
ENDCASE.
IF u_no CA '13'.
MOVE 'TOP_OF_PAGE' TO ls_event-name.
CONCATENATE 'TOP_OF_PAGE' u_no INTO ls_event-form.
APPEND ls_event TO lt_events.
ELSE.
MOVE 'TOP_OF_LIST' TO ls_event-name.
CONCATENATE 'TOP_OF_LIST' u_no INTO ls_event-form.
APPEND ls_event TO lt_events.
ENDIF.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
it_fieldcat = lt_fieldcat
is_layout = ls_layout
i_tabname = u_tabname
it_events = lt_events
it_sort = lt_sort
* i_text =
TABLES
t_outtab = ut_table
EXCEPTIONS
program_error = 1
maximum_of_appends_reached = 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.
ENDFORM. " LIST_APPEND
*---------------------------------------------------------------------*
* Form f_list_display
*---------------------------------------------------------------------*
FORM f_list_display.
DATA ls_print TYPE slis_print_alv.
ls_print-no_print_selinfos = 'X'. " Display no selection infos
ls_print-no_print_listinfos = 'X'. " Display no listinfos
ls_print-reserve_lines = 2. " Lines reserved for end of page
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
EXPORTING
i_interface_check = ' '
is_print = ls_print
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. " F_LIST_DISPLAY
*---------------------------------------------------------------------*
* FORM top_of_page1 *
*---------------------------------------------------------------------*
FORM top_of_page1. "#EC CALLED
PERFORM top_of_page.
ENDFORM.
*---------------------------------------------------------------------*
* FORM top_of_page3 *
*---------------------------------------------------------------------*
FORM top_of_page3. "#EC CALLED
PERFORM top_of_page.
ENDFORM.
*---------------------------------------------------------------------*
* FORM top_of_page *
*---------------------------------------------------------------------*
FORM top_of_page.
ULINE.
WRITE : sy-uname, sy-title(56) CENTERED, sy-datum.
ULINE.
ENDFORM.
*---------------------------------------------------------------------*
* FORM top_of_list2 *
*---------------------------------------------------------------------*
FORM top_of_list2. "#EC CALLED
WRITE 'TOP OF LIST2'.
ENDFORM.
************** END OF PROGRAM Z_ALV_LIST_BLOCK *********************
Friday, November 23, 2007
ALV Reporting - REUSE_ALV_BLOCK_LIST_DISPLAY
Labels:
ALV sample programs
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2007
(952)
-
▼
November
(716)
- SAP Paper Documents
- SAP Repository
- SAP R/3 Implementation and Maintenance Tips
- ABAP/4 programming language overview
- The interactive eLearning system for ABAP™
- Helpful System Administration ABAPS
- free download abap programmin pdf book
- examples of real time objects in sap abap(1)
- examples of real time objects in sap abap
- work flow example2
- Workflow tips
- Miscellaneous sap abap faq
- BDC , LSMW, Conversions faq in abap
- Sap Scripts & Smart forms faqs in abap
- performance tuning in abap faqs
- Real Time BDC & LSMW faqs
- Real Time ABAP Internal Tables faqs
- Real Time ABAP Reports faqs
- Real Time questions ..in sap ABAP
- SAP ABAP FAQ (Technical)
- ABAP and Unicode
- ABAP and JavaScript
- ABAP Objects
- ABAP Database Access
- Running ABAP Programs
- ABAP User Dialogs
- The ABAP Programming Language
- Creating and Changing ABAP Programs
- Overview of the Components of Application Programs
- Introduction to ABAP
- ABAP Programming Documentation
- FREE DOWNLOAD ALE, EDI & IDOCS
- Conversion of IDOCs to XML.pdf
- FREE DOWNLOAD IDOC Interface Technology
- FREE DOWNLOAD EDI, IDOC Interface
- FREE DOWNLOAD IDOC BOOK
- FREE DOWNLOAD LSMW - Idoc Inbound Processing
- FREE DOWNLOAD SAP ABAP Idoc Interface
- FREE DOWNLOAD Java for SAP
- FREE DOWNLOAD Java for ABAP Programmers
- FREE DOWNLOAD Java and BAPI technology for EP
- free download Building Web Services with Java and ...
- free download Enable SAP with the power of Javascript
- FREE DOWNLOAD ABAP Training Simulator
- FREE DOWNLOAD SAP Accounting Training Simulators
- free download SAPScripts Made Easy
- CONDENSE
- CONSTANTS
- ABAP Quick Viewer
- sap abap XXL (EXtended Export of Lists)
- Some ABAP/4 Query header line variable
- Understanding SAP Query
- ABAP/4 Query
- ABAP/4 Query Hints and Tips
- SAP Website Links Exchange for ABAP, Basis or Cons...
- sap abap Program for Generate IDoc
- sap abap program for Reads an existing Idoc and di...
- List of ABAP Function modules
- sap abap FTP programming
- sap abap program for Issuing an Unix Command from ...
- sap abap program for RFC call to get Server List
- sap abap program for A SAP Pop-out Calculator
- sap ABAP program for Timers and Auto-refresh
- sap abap program for WS_EXECUTE to called External...
- sap abap programming Execute DOS Command from ABAP...
- To execute a dos command from ABAP
- sap abap program for Make your SAPGUI Disappear an...
- sap abap program for Using Function Modules F4_FIL...
- abp program for How to Restrict the Select Options
- sap abap program for Take Values from Selection-Sc...
- sap abap program for Change Text Into Password
- sap abap program for Function Module for Encryptio...
- sap abap program for FM VRM_SET_VALUE To List Box
- sap abap program for Value Request For Parameter
- sap abap program for Pop a Message to specific SAP...
- ABAP Pop-out box for user confirmation
- sap ABAP program for POP-UP Window
- sap abap program Sample XML Source Code For SAP
- sap abap XML file to word document through SAP
- sap abap program for How to Write Web Reports in SAP
- sap abap conversion Program to Test Line Selection...
- sap abap program for String Handling in ABAP - Rem...
- sap abap program for Split String into two parts a...
- sap abap conversion Program For Printing Prime Number
- sap abap program for How can I get Ascii value of ...
- sap abap program for Figure to Words for India but...
- sap abap conversion program for Print Number Value...
- sap abap conversion program for Insert a special T...
- sap abap program for String Handling in ABAP - Rem...
- sap abap program for Split String into two parts a...
- sap abap conversion Program For Printing Prime Number
- sap abap program for How can I get Ascii value of ...
- sap abap program for Figure to Words for India but...
- sap abap conversion program for Print Number Value...
- sap abap conversion program for Insert a special T...
- sap abap program for Convert SAP Spool List to HTML
- sap program for Convert Month to Word in ABAP
- ABAP function to convert Number to Words
- sap abap program for How to Create Tree Control
- sap abap A sample Tree Programming
-
▼
November
(716)
No comments:
Post a Comment