*&---------------------------------------------------------------------* *& Report ZZ_SAMPLE_ALV_RPT *& *&---------------------------------------------------------------------* *======================================================================* * Program Title : Sample for making an arbitrary ALV Report * * Author : Neal Wilhite * * Date : 07/24/2013 * * Initial SAP Change Request #: NA *----------------------------------------------------------------------* * Program Name : ZZ_SAMPLE_ALV_RPT * * Description : Simple starter program for an ALV. I'll do * * something simple with Sales Orders as an example. * * Type: : ALV Report * * Run Frequency: : As needed * *----------------------------------------------------------------------* * * * MODIFICATION HISTORY * *----------------------------------------------------------------------* * * * Request Date ID Descriptioncription * *----------------------------------------------------------------------* * DV1K9XXXXX XX/XX/XXXX XXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX * ************************************************************************ REPORT zz_sample_alv_rpt NO STANDARD PAGE HEADING MESSAGE-ID zsd LINE-SIZE 200 LINE-COUNT 65. *INCLUDE ZZ_SAMPLE_ALV_RPT_top. TABLES: vbak, vbap. * Sales Order data type TYPES: BEGIN OF ty_so. TYPES: vbeln LIKE vbak-vbeln, "Ship From audat LIKE vbak-audat, "Document Date vbtyp LIKE vbak-vbtyp, "SD document category auart LIKE vbak-auart, "Sales Document Type posnr LIKE vbap-posnr, "Sales Document Item matnr LIKE vbap-matnr, "Material Number charg LIKE vbap-charg, "Batch Number kwmeng LIKE vbap-kwmeng, "Cumulative Order Quantity in Sales Units meins LIKE vbap-meins. "Base Unit of Measure types: END OF ty_so. TYPES : tt_so TYPE STANDARD TABLE OF ty_so. ** Internal tables. DATA: it_so TYPE tt_so. * transfer structure DATA: wa_so TYPE ty_so. INCLUDE z_otc_broker_edi867_rpt_scr. INCLUDE zz_alv_mast_incl. ************************************************************************ START-OF-SELECTION. ************************************************************************ PERFORM select_data TABLES it_so. *********************************************************************** * END-OF-SELECTION *********************************************************************** END-OF-SELECTION. * routine for building layout PERFORM layout_build USING st_layout. * routine for the building the field catalog PERFORM fieldcat_init USING it_fieldcat[]. * Get top-of-page. PERFORM events. PERFORM z_comment_build USING it_top_of_page. IF it_so[] IS NOT INITIAL. * Perform alv display PERFORM alv_list_display. ELSE. MESSAGE s017. "No data available for output display EXIT. ENDIF. *&---------------------------------------------------------------------* *& Form SELECT_DATA *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_IT_NEW_SDF text *----------------------------------------------------------------------* FORM select_data TABLES p_it_so TYPE tt_so. SELECT a~vbeln a~audat a~vbtyp a~auart b~posnr b~matnr b~charg b~kwmeng b~meins INTO CORRESPONDING FIELDS OF TABLE p_it_so FROM ( vbak AS a INNER JOIN vbap AS b ON a~vbeln = b~vbeln ) WHERE a~vbtyp = 'C'. ENDFORM. " SELECT_DATA *&--------------------------------------------------------------------* *& Form Build Field Catalog *&--------------------------------------------------------------------* FORM fieldcat_init USING fieldcat TYPE slis_t_fieldcat_alv. DATA: pv_lt_fieldcat TYPE slis_fieldcat_alv. *-- CLEAR pv_lt_fieldcat. pv_lt_fieldcat-col_pos = 1. pv_lt_fieldcat-fieldname = 'VBELN'. pv_lt_fieldcat-seltext_l = 'SO DOC #'. pv_lt_fieldcat-emphasize = 'C41'. pv_lt_fieldcat-outputlen = 10. APPEND pv_lt_fieldcat TO fieldcat. *-- CLEAR pv_lt_fieldcat. pv_lt_fieldcat-col_pos = 2. pv_lt_fieldcat-fieldname = 'AUDAT'. pv_lt_fieldcat-seltext_l = 'Doc Date'. pv_lt_fieldcat-emphasize = 'C41'. pv_lt_fieldcat-outputlen = 10. APPEND pv_lt_fieldcat TO fieldcat. *-- CLEAR pv_lt_fieldcat. pv_lt_fieldcat-col_pos = 3. pv_lt_fieldcat-fieldname = 'VBTYP'. pv_lt_fieldcat-seltext_l = 'SO Cat.'. pv_lt_fieldcat-emphasize = 'C41'. pv_lt_fieldcat-no_out = 'X' ."g_no_out. pv_lt_fieldcat-outputlen = 7. APPEND pv_lt_fieldcat TO fieldcat. *-- CLEAR pv_lt_fieldcat. pv_lt_fieldcat-col_pos = 4. pv_lt_fieldcat-fieldname = 'AUART'. pv_lt_fieldcat-seltext_l = 'SO Type'. pv_lt_fieldcat-emphasize = 'C41'. pv_lt_fieldcat-outputlen = 7. APPEND pv_lt_fieldcat TO fieldcat. *-- CLEAR pv_lt_fieldcat. pv_lt_fieldcat-col_pos = 5. pv_lt_fieldcat-fieldname = 'POSNR'. pv_lt_fieldcat-seltext_l = 'SO Item'. pv_lt_fieldcat-emphasize = 'C41'. pv_lt_fieldcat-outputlen = 7. APPEND pv_lt_fieldcat TO fieldcat. *-- CLEAR pv_lt_fieldcat. pv_lt_fieldcat-col_pos = 6. pv_lt_fieldcat-fieldname = 'MATNR'. pv_lt_fieldcat-seltext_l = 'Material #'. pv_lt_fieldcat-emphasize = 'C41'. pv_lt_fieldcat-outputlen = 18. APPEND pv_lt_fieldcat TO fieldcat. *-- CLEAR pv_lt_fieldcat. pv_lt_fieldcat-col_pos = 7. pv_lt_fieldcat-fieldname = 'CHARG'. pv_lt_fieldcat-seltext_l = 'Batch #'. pv_lt_fieldcat-emphasize = 'C41'. pv_lt_fieldcat-outputlen = 10. APPEND pv_lt_fieldcat TO fieldcat. *-- CLEAR pv_lt_fieldcat. pv_lt_fieldcat-col_pos = 8. pv_lt_fieldcat-fieldname = 'KWMENG'. pv_lt_fieldcat-seltext_l = 'Wk.End Dt.'. pv_lt_fieldcat-emphasize = 'C31'. pv_lt_fieldcat-outputlen = 19. APPEND pv_lt_fieldcat TO fieldcat. *-- CLEAR pv_lt_fieldcat. pv_lt_fieldcat-col_pos = 9. pv_lt_fieldcat-fieldname = 'MEINS'. pv_lt_fieldcat-seltext_l = 'OUM'. pv_lt_fieldcat-emphasize = 'C30'. pv_lt_fieldcat-outputlen = 2. APPEND pv_lt_fieldcat TO fieldcat. ENDFORM. "pv_FIELDCAT_INIT
↧
ZZ_SAMPLE_ALV_RPT - base code
↧