ALV REPORTS Report for header window and template *&--------------------------------------------------------------------* *& Report ZALV * *& * *&--------------------------------------------------------------------* *& * *& * *&--------------------------------------------------------------------* Report ZALV . TABLES:
ekko.
type-pools: slis. *Data Declaration *---------------TYPES: BEGIN OF t_ekko, ebeln TYPE ekpo-ebeln, ebelp TYPE ekpo-ebelp, statu TYPE ekpo-statu, aedat TYPE ekpo-aedat, matnr TYPE ekpo-matnr, menge TYPE ekpo-menge, meins TYPE ekpo-meins, netpr TYPE ekpo-netpr, peinh TYPE ekpo-peinh, END OF t_ekko.
"ALV Declarations
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0, wa_ekko TYPE t_ekko. *ALV data declarations data: fieldcatalog type slis_t_fieldcat_alv with header line, gd_tab_group type slis_t_sp_group_alv, gd_layout type slis_layout_alv, gd_repid like sy-repid, gt_events type slis_t_event, gd_prntparams type slis_print_alv.
******************************************************************** **** *Start-of-selection. START-OF-SELECTION. perform perform perform perform perform perform
data_retrieval. build_fieldcatalog. build_layout. build_events. build_print_params. display_alv_report.
*&--------------------------------------------------------------------* *& Form BUILD_FIELDCATALOG *&--------------------------------------------------------------------* * Build Fieldcatalog for ALV Report *---------------------------------------------------------------------* form build_fieldcatalog. * There are a number of ways to create a fieldcat. * For the purpose of this example i will build the fieldcatalog manualy * by populating the internal table fields individually and then * appending the rows. This method can be the most time consuming but can * also allow you more control of the final product. * Beware though, you need to ensure that all fields required are * populated. When using some of functionality available via ALV, such as * total. You may need to provide more information than if you were * simply displaying the result * I.e. Field type may be required in-order for * the 'TOTAL' function to work. fieldcatalog-fieldname = 'EBELN'. fieldcatalog-seltext_m = 'Purchase Order'. fieldcatalog-col_pos = 0. fieldcatalog-outputlen = 10. fieldcatalog-emphasize = 'X'. fieldcatalog-key = 'X'. * fieldcatalog-do_sum = 'X'. * fieldcatalog-no_zero = 'X'. append fieldcatalog to fieldcatalog. clear fieldcatalog. fieldcatalog-fieldname fieldcatalog-seltext_m fieldcatalog-col_pos
= 'EBELP'. = 'PO Item'. = 1.
append fieldcatalog to fieldcatalog. clear fieldcatalog. fieldcatalog-fieldname = 'STATU'. fieldcatalog-seltext_m = 'Status'. fieldcatalog-col_pos = 2. append fieldcatalog to fieldcatalog. clear fieldcatalog. fieldcatalog-fieldname = 'AEDAT'. fieldcatalog-seltext_m = 'Item change date'. fieldcatalog-col_pos = 3. append fieldcatalog to fieldcatalog. clear fieldcatalog. fieldcatalog-fieldname = 'MATNR'. fieldcatalog-seltext_m = 'Material Number'. fieldcatalog-col_pos = 4. append fieldcatalog to fieldcatalog. clear fieldcatalog. fieldcatalog-fieldname = 'MENGE'. fieldcatalog-seltext_m = 'PO quantity'. fieldcatalog-col_pos = 5. append fieldcatalog to fieldcatalog. clear fieldcatalog. fieldcatalog-fieldname = 'MEINS'. fieldcatalog-seltext_m = 'Order Unit'. fieldcatalog-col_pos = 6. append fieldcatalog to fieldcatalog. clear fieldcatalog. fieldcatalog-fieldname = 'NETPR'. fieldcatalog-seltext_m = 'Net Price'. fieldcatalog-col_pos = 7. fieldcatalog-outputlen = 15. fieldcatalog-datatype = 'CURR'. append fieldcatalog to fieldcatalog. clear fieldcatalog. fieldcatalog-fieldname = 'PEINH'. fieldcatalog-seltext_m = 'Price Unit'. fieldcatalog-col_pos = 8. append fieldcatalog to fieldcatalog. clear fieldcatalog. endform. " BUILD_FIELDCATALOG *&--------------------------------------------------------------------* *& Form BUILD_LAYOUT
*&--------------------------------------------------------------------* * Build layout for ALV grid report *---------------------------------------------------------------------* form build_layout. gd_layout-no_input = 'X'. gd_layout-colwidth_optimize = 'X'. gd_layout-totals_text = 'Totals'(201). * gd_layout-totals_only = 'X'. * gd_layout-f2code = 'DISP'. "Sets fcode for when double * "click(press f2) * gd_layout-zebra = 'X'. * gd_layout-group_change_edit = 'X'. * gd_layout-header_text = 'helllllo'. endform. " BUILD_LAYOUT *&--------------------------------------------------------------------* *& Form DISPLAY_ALV_REPORT *&--------------------------------------------------------------------* * Display report using ALV grid *---------------------------------------------------------------------* form display_alv_report. gd_repid = sy-repid. call function 'REUSE_ALV_GRID_DISPLAY' exporting i_callback_program = gd_repid i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM i_callback_user_command = 'USER_COMMAND' * i_grid_title = outtext is_layout = gd_layout it_fieldcat = fieldcatalog[] * it_special_groups = gd_tabgroup it_events = gt_events is_print = gd_prntparams i_save = 'X' * is_variant = z_template 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 DATA_RETRIEVAL *&--------------------------------------------------------------------* * Retrieve data form EKPO table and populate itab it_ekko *---------------------------------------------------------------------* form data_retrieval. select up to from into
ebeln ebelp statu aedat matnr menge meins netpr peinh 10 rows ekpo table it_ekko.
endform.
" DATA_RETRIEVAL
*------------------------------------------------------------------* * Form TOP-OF-PAGE * *------------------------------------------------------------------* * ALV Report Header * *------------------------------------------------------------------* Form top-of-page. *ALV Header declarations data: t_header type slis_t_listheader, wa_header type slis_listheader, t_line like wa_header-info, ld_lines type i, ld_linesc(10) type c. * Title wa_header-typ = 'H'. wa_header-info = 'EKKO Table Report'. append wa_header to t_header. clear wa_header. * Date wa_header-typ = 'S'. wa_header-key = 'Date: '. CONCATENATE sy-datum+6(2) '.' sy-datum+4(2) '.' sy-datum(4) INTO wa_header-info. append wa_header to t_header.
"todays date
clear: wa_header. * Total No. of Records Selected describe table it_ekko lines ld_lines. ld_linesc = ld_lines. concatenate 'Total No. of Records Selected: ' ld_linesc into t_line separated by space. wa_header-typ = 'A'. wa_header-info = t_line. append wa_header to t_header. clear: wa_header, t_line. call function 'REUSE_ALV_COMMENTARY_WRITE' exporting it_list_commentary = t_header. * i_logo = 'Z_LOGO'. endform. *------------------------------------------------------------------* * FORM USER_COMMAND * *------------------------------------------------------------------* * --> R_UCOMM * * --> RS_SELFIELD * *------------------------------------------------------------------* FORM user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield. * Check function code CASE r_ucomm. WHEN '&IC1'. * Check field clicked on within ALVgrid report IF rs_selfield-fieldname = 'EBELN'. * Read data table, using index of row user clicked on READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex. * Set parameter ID for transaction screen field SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln. * Sxecute transaction ME23N, and skip initial data entry screen CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN. ENDIF. ENDCASE. ENDFORM. *&--------------------------------------------------------------------* *& Form BUILD_EVENTS *&--------------------------------------------------------------------* * Build events table *---------------------------------------------------------------------* form build_events.
data: ls_event type slis_alv_event. call function 'REUSE_ALV_EVENTS_GET' exporting i_list_type = 0 importing et_events = gt_events[]. read table gt_events with key name = slis_ev_end_of_page into ls_event. if sy-subrc = 0. move 'END_OF_PAGE' to ls_event-form. append ls_event to gt_events. endif. read table gt_events with key name = slis_ev_end_of_list into ls_event. if sy-subrc = 0. move 'END_OF_LIST' to ls_event-form. append ls_event to gt_events. endif. endform. " BUILD_EVENTS *&--------------------------------------------------------------------* *& Form BUILD_PRINT_PARAMS *&--------------------------------------------------------------------* * Setup print parameters *---------------------------------------------------------------------* form build_print_params. gd_prntparams-reserve_lines = '3'. "Lines reserved for footer gd_prntparams-no_coverpage = 'X'. endform. " BUILD_PRINT_PARAMS *&--------------------------------------------------------------------* *& Form END_OF_PAGE *&--------------------------------------------------------------------* form END_OF_PAGE. data: listwidth type i, ld_pagepos(10) type c, ld_page(10) type c. write: sy-uline(50). skip. write:/40 'Page:', sy-pagno . endform.
*&--------------------------------------------------------------------* *& Form END_OF_LIST *&--------------------------------------------------------------------* form END_OF_LIST. data: listwidth type i, ld_pagepos(10) type c, ld_page(10) type c. skip. write:/40 'Page:', sy-pagno . endform.
Report for different type of layout *&--------------------------------------------------------------------* *& Report ZALV1 * *& * *&--------------------------------------------------------------------* *& * *& * *&--------------------------------------------------------------------* REPORT
ZALV1
.
type-pools: slis. data: begin of head occurs 0, matnr type ekpo-matnr, maktx type makt-maktx, EXPAND type c, end of head. data: begin of detail occurs 0, aufnr type afpo-aufnr, matnr type afpo-matnr, werks type aufk-werks, pwerk type afpo-pwerk, psmng type afpo-psmng, end of detail. start-of-selection. select * into corresponding fields of table detail from afpo
inner join aufk on afpo~aufnr = aufk~aufnr inner join afko on afpo~aufnr = afko~aufnr up to 500 rows where aufk~auart = 'G2P1'. if not detail[] is initial. sort detail ascending by matnr. select distinct * into corresponding fields of table head from makt for all entries in detail where matnr = detail-matnr and spras = sy-langu. endif. perform call_alv. *--------------------------------------------------------------------* * FORM call_alv * *--------------------------------------------------------------------* * ........ * *--------------------------------------------------------------------* form call_alv. data: gt_fieldcat gs_keyinfo gs_layout . data: ls_fieldcat
type slis_t_fieldcat_alv, type slis_keyinfo_alv, type slis_layout_alv. type slis_fieldcat_alv.
clear gs_keyinfo. gs_keyinfo-header01 = 'MATNR'. gs_keyinfo-item01 = 'MATNR'. clear ls_fieldcat. ls_fieldcat-fieldname = 'MATNR'. ls_fieldcat-reptext_ddic = 'Material'. ls_fieldcat-tabname = 'HEAD'. ls_fieldcat-outputlen = 18. append ls_fieldcat to gt_fieldcat. clear ls_fieldcat. ls_fieldcat-fieldname = 'MAKTX'. ls_fieldcat-reptext_ddic = 'Description'. ls_fieldcat-tabname = 'HEAD'.
ls_fieldcat-outputlen = 40. append ls_fieldcat to gt_fieldcat. clear ls_fieldcat. ls_fieldcat-fieldname = 'AUFNR'. ls_fieldcat-reptext_ddic = 'Production Order'. ls_fieldcat-tabname = 'DETAIL'. ls_fieldcat-outputlen = 12. append ls_fieldcat to gt_fieldcat. clear ls_fieldcat. ls_fieldcat-fieldname = 'WERKS'. ls_fieldcat-reptext_ddic = 'Production Plant'. ls_fieldcat-tabname = 'DETAIL'. ls_fieldcat-outputlen = 4. append ls_fieldcat to gt_fieldcat. clear ls_fieldcat. ls_fieldcat-fieldname = 'PWERK'. ls_fieldcat-reptext_ddic = 'Planning Plant'. ls_fieldcat-tabname = 'DETAIL'. ls_fieldcat-outputlen = 4. append ls_fieldcat to gt_fieldcat. clear ls_fieldcat. ls_fieldcat-fieldname = 'PSMNG'. ls_fieldcat-reptext_ddic = 'Quantity'. ls_fieldcat-tabname = 'DETAIL'. ls_fieldcat-outputlen = 20. append ls_fieldcat to gt_fieldcat. gs_layout-expand_fieldname = 'EXPAND'. call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY' exporting it_fieldcat = gt_fieldcat[] is_layout = gs_layout i_tabname_header = 'HEAD' i_tabname_item = 'DETAIL' is_keyinfo = gs_keyinfo tables t_outtab_header = head t_outtab_item = detail. endform.
To display different colors in alv *&--------------------------------------------------------------------* *& Report ZALVCOLOR * *& * *&--------------------------------------------------------------------* *& * *& * *&--------------------------------------------------------------------* REPORT
ZALVCOLOR
.
DATA : mara TYPE mara.
" General Material Data
TYPE-POOLS: slis.
" ALV Global types
FIELD-SYMBOLS : TYPE table.
" Data to display
SELECT-OPTIONS : s_matnr FOR mara-matnr.
" Material number
SELECTION-SCREEN : SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max. NEEDED PARAMETERS p_max(2) TYPE n DEFAULT '50' OBLIGATORY. SELECTION-SCREEN END OF LINE.
"#EC
*--------------------------------------------------------------------* INITIALIZATION. v_1 = 'Maximum of lines to display'. *--------------------------------------------------------------------* START-OF-SELECTION. PERFORM f_read_data. PERFORM f_display_data. *--------------------------------------------------------------------* * Form f_read_data *--------------------------------------------------------------------*
FORM f_read_data. FIELD-SYMBOLS : TYPE TYPE TYPE TYPE TYPE
ANY, ANY, ANY, ANY, table.
DATA: lp_struct lp_struct2 lp_table lp_table2 ls_lvc_cat lt_lvc_cat
REF TO data, REF TO data, REF TO data, REF TO data, lvc_s_fcat, lvc_t_fcat.
TYPE TYPE TYPE TYPE TYPE TYPE
" Data read from DB
" Pointer to dynamic table " Pointer to dynamic table " Field catalog
* First column CLEAR ls_lvc_cat. ls_lvc_cat-fieldname = 'MATNR'. ls_lvc_cat-ref_table = 'MARA'. APPEND ls_lvc_cat TO lt_lvc_cat. * 2nd column CLEAR ls_lvc_cat. ls_lvc_cat-fieldname = 'MAKTX'. ls_lvc_cat-ref_table = 'MAKT'. APPEND ls_lvc_cat TO lt_lvc_cat. * 3rd column CLEAR ls_lvc_cat. ls_lvc_cat-fieldname = 'MATKL'. ls_lvc_cat-ref_table = 'MARA'. APPEND ls_lvc_cat TO lt_lvc_cat. * Create 1st internal table CALL METHOD cl_alv_table_create=>create_dynamic_table EXPORTING it_fieldcatalog = lt_lvc_cat IMPORTING ep_table = lp_table. ASSIGN lp_table->* TO . * Read data into 1st internal table SELECT matnr maktx matkl INTO TABLE FROM v_matnr UP TO p_max ROWS WHERE matnr IN s_matnr. * Create 2nd internal table * Checkbox CLEAR ls_lvc_cat. ls_lvc_cat-fieldname = 'CHECKBOX'.
APPEND ls_lvc_cat TO lt_lvc_cat. * Table color CLEAR ls_lvc_cat. ls_lvc_cat-fieldname ls_lvc_cat-ref_table ls_lvc_cat-ref_field APPEND ls_lvc_cat TO
= 'TABCOLOR'. = 'CALENDAR_TYPE'. = 'COLTAB'. lt_lvc_cat.
* Create 2nd internal table CALL METHOD cl_alv_table_create=>create_dynamic_table EXPORTING it_fieldcatalog = lt_lvc_cat IMPORTING ep_table = lp_table2. ASSIGN lp_table2->* TO . * Create structure = structure of the 1st internal table CREATE DATA lp_struct LIKE LINE OF . ASSIGN lp_struct->* TO . * Create structure = structure of the 2nd internal table CREATE DATA lp_struct2 LIKE LINE OF . ASSIGN lp_struct2->* TO . * Move data from 1st internal table --> 2nd internal table LOOP AT ASSIGNING . DESCRIBE TABLE lt_lvc_cat. CLEAR . * *
*
Fill the internal to display DO sy-tfill TIMES. READ TABLE lt_lvc_cat INTO ls_lvc_cat INDEX sy-index. For each field of lt_lvc_cat. ASSIGN COMPONENT ls_lvc_cat-fieldname OF STRUCTURE TO . IF sy-subrc NE 0. EXIT .ENDIF. ASSIGN COMPONENT ls_lvc_cat-fieldname OF STRUCTURE TO . IF sy-subrc NE 0. EXIT .ENDIF. = . ENDDO. Modify color ASSIGN COMPONENT 'TABCOLOR' OF STRUCTURE TO . IF sy-subrc EQ 0. PERFORM f_modify_color USING 'MAKTX' . PERFORM f_modify_color USING 'MATKL' . ENDIF. APPEND TO . ENDLOOP.
ENDFORM. " f_read_data *--------------------------------------------------------------------* * Form F_DISPLAY_DATA *--------------------------------------------------------------------* FORM f_display_data. * Macro definition DEFINE m_sort. add 1 to ls_sort-spos. ls_sort-fieldname = &1. ls_sort-down = 'X'. append ls_sort to lt_sort. END-OF-DEFINITION. DATA: ls_layout lt_sort ls_sort ls_fieldcat lt_fieldcat
TYPE TYPE TYPE TYPE TYPE
slis_layout_alv, slis_t_sortinfo_alv, slis_sortinfo_alv, slis_fieldcat_alv, slis_t_fieldcat_alv.
" Field catalog
* Build Fieldcatalog - First column CLEAR ls_fieldcat. ls_fieldcat-fieldname = 'MATNR'. ls_fieldcat-ref_tabname = 'MARA'. ls_fieldcat-key = 'X'. APPEND ls_fieldcat TO lt_fieldcat. * Build Fieldcatalog - 2nd column CLEAR ls_fieldcat. ls_fieldcat-fieldname = 'MAKTX'. ls_fieldcat-ref_tabname = 'MAKT'. APPEND ls_fieldcat TO lt_fieldcat. * Build Fieldcatalog - 3rd column CLEAR ls_fieldcat. ls_fieldcat-fieldname = 'MATKL'. ls_fieldcat-ref_tabname = 'MARA'. APPEND ls_fieldcat TO lt_fieldcat. * Layout ls_layout-zebra = 'X'. ls_layout-colwidth_optimize = 'X'. ls_layout-box_fieldname = 'CHECKBOX'. ls_layout-coltab_fieldname = 'TABCOLOR'. m_sort 'MATNR'.
" Sort by creation date
* Display data CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING is_layout it_fieldcat it_sort TABLES t_outtab
= ls_layout = lt_fieldcat = lt_sort = .
ENDFORM. " F_DISPLAY_DATA *--------------------------------------------------------------------* * Form F_modify_color *--------------------------------------------------------------------* FORM f_modify_color USING u_fieldname TYPE lvc_fname ut_tabcolor TYPE table. DATA: l_rnd_value TYPE datatype-integer2, ls_tabcolor TYPE lvc_s_scol. * Random value CALL FUNCTION 'RANDOM_I2' EXPORTING rnd_min = 0 rnd_max = 3 IMPORTING rnd_value = l_rnd_value. CLEAR ls_tabcolor. ls_tabcolor-fname = u_fieldname. CASE l_rnd_value. WHEN 0. ls_tabcolor-color-col ls_tabcolor-color-int ls_tabcolor-color-inv WHEN 1. ls_tabcolor-color-col ls_tabcolor-color-int ls_tabcolor-color-inv WHEN 2. ls_tabcolor-color-col ls_tabcolor-color-int ls_tabcolor-color-inv WHEN 3. ls_tabcolor-color-col ls_tabcolor-color-int ls_tabcolor-color-inv ENDCASE.
= 1. = 0. = 0.
" Blue.
= 3. = 0. = 0.
" Yellow.
= 5. = 0. = 0.
" Green.
= 6. = 0. = 0.
" Red.
INSERT ls_tabcolor INTO TABLE ut_tabcolor. ENDFORM.
" F_MODIFY_COLOR
Alv grid to print logo on the header with radio buttons *&--------------------------------------------------------------------* *& Report ZALVDEMO * *& * *&--------------------------------------------------------------------* *& * *& * *&--------------------------------------------------------------------* REPORT
ZALVDEMO.
TABLES : J_1IEXCHDR, " header table J_1IEXCDTL, " item table J_1IPART2, " Excise Part II details LFA1, " vendor master table J_1IMOVEND, " vendor excise details table MSEG, " Document Segment: Material MKPF, " Header: Material Document DD07T, " domain text table T001W. " Plant and Branch Details DATA : BEGIN OF IT_CHDR OCCURS 100, DOCNO LIKE J_1IEXCHDR-DOCNO, DOCYR LIKE J_1IEXCHDR-DOCYR, EXNUM LIKE J_1IEXCHDR-EXNUM, EXDAT LIKE J_1IEXCHDR-EXDAT, WERKS LIKE J_1IEXCHDR-WERKS, EXBED LIKE J_1IEXCHDR-EXBED, EXCCD LIKE J_1IEXCHDR-EXCCD, ECS LIKE J_1IEXCHDR-ECS, END OF IT_CHDR. DATA : BEGIN OF IT_CDTL OCCURS 100, DOCYR LIKE J_1IEXCDTL-DOCYR, DOCNO LIKE J_1IEXCDTL-DOCNO, EXNUM LIKE J_1IEXCDTL-EXNUM, EXDAT LIKE J_1IEXCDTL-EXDAT, LIFNR LIKE J_1IEXCDTL-LIFNR, MATNR LIKE J_1IEXCDTL-MATNR, MAKTX LIKE J_1IEXCDTL-MAKTX, CHAPID LIKE J_1IEXCDTL-CHAPID, EXBAS LIKE J_1IEXCDTL-EXBAS,
EXBED LIKE J_1IEXCDTL-EXBED, ECS LIKE J_1IEXCDTL-ECS, MENGE LIKE J_1IEXCDTL-MENGE, MEINS LIKE J_1IEXCDTL-MEINS, RDOC2 LIKE J_1IEXCDTL-RDOC2, END OF IT_CDTL. DATA TEXT(10). DATA : BEGIN OF IT_OUT OCCURS 0, SERIALNO LIKE J_1IPART2-SERIALNO, TEXT1 LIKE TEXT, EXNUM LIKE J_1IEXCDTL-EXNUM, EXDAT LIKE J_1IEXCDTL-EXDAT, NAME LIKE LFA1-NAME1, DDTEXT LIKE DD07T-DDTEXT, EXCCD LIKE J_1IEXCHDR-EXCCD, BUDAT LIKE MKPF-BUDAT, EXBAS LIKE IT_CDTL-EXBAS, EXBED LIKE IT_CDTL-EXBED, ECS LIKE IT_CDTL-ECS, MATNR LIKE IT_CDTL-MATNR, MAKTX LIKE IT_CDTL-MAKTX, CHAPID LIKE IT_CDTL-CHAPID, MENGE LIKE IT_CDTL-MENGE, MEINS LIKE IT_CDTL-MEINS, DEL_IND(1), END OF IT_OUT. DATA IT_PART2 LIKE J_1IPART2 OCCURS 0 WITH HEADER LINE. DATA S_NO(4) . DATA DB_CNT LIKE SY-TABIX. DATA EBELN_T LIKE MSEG-EBELN . *-----------------------------------TYPE-POOLS : SLIS. DATA : AFIELD TYPE SLIS_FIELDCAT_ALV. DATA : LIST_HEADER TYPE SLIS_T_LISTHEADER, FIELDCAT TYPE SLIS_T_FIELDCAT_ALV, LS_FTCAT TYPE LVC_S_FCAT, SORTCAT TYPE SLIS_T_SORTINFO_ALV, SORTCAT_LN LIKE LINE OF SORTCAT, G_REPID LIKE SY-REPID, G_BACK_GROUND(70), "like bapibds01-objkey, GS_VARIANT LIKE DISVARIANT, G_SAVE , GT_EVENTS TYPE SLIS_T_EVENT, ALV_EVENT TYPE SLIS_ALV_EVENT, EVENTCAT TYPE SLIS_T_EVENT, EVENTCAT_LN LIKE LINE OF EVENTCAT,
LAYOUT_IN TYPE SLIS_LAYOUT_ALV, LAYOUT_IN1 TYPE SLIS_LAYOUT_ALV. CONSTANTS : GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE', GC_FORMNAME_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND', GC_FORMNAME_BEFORE_OUTPUT TYPE SLIS_FORMNAME VALUE 'BEFORE_OUTPUT'. * ALV_EVENT TYPE SLIS_ALV_EVENT, *------------------------------------DATA EX_NO LIKE IT_CHDR-EXNUM VALUE 0. DATA REGTYP_1 LIKE J_1IPART2-REGTYP. SELECTION-SCREEN BEGIN OF BLOCK B WITH FRAME. PARAMETERS WERKS TYPE J_1IEXCHDR-WERKS. SELECT-OPTIONS : BUDAT FOR J_1IEXCHDR-EXDAT. PARAMETERS : R1 RADIOBUTTON GROUP GRP DEFAULT 'X', R2 RADIOBUTTON GROUP GRP. SELECTION-SCREEN END OF BLOCK B. INITIALIZATION. G_REPID = SY-REPID. G_SAVE = 'A'. * PERFORM BUILD_EVENT USING GT_EVENTS[]. PERFORM ALV_EVENT_INIT. AT SELECTION-SCREEN. REFRESH LIST_HEADER. PERFORM TOP_OF_PAGE_LIST_HEADER USING LIST_HEADER. START-OF-SELECTION. * PERFORM ALV_EVENT_INIT. G_REPID = SY-REPID. G_BACK_GROUND = ' ' . IF R1 = 'X'. CLEAR R2. CLEAR : REGTYP_1. REGTYP_1 = 'A'. ELSEIF R2 = 'X'. CLEAR R1.CLEAR : REGTYP_1. REGTYP_1 = 'C'. ENDIF. SELECT * FROM J_1IPART2 INTO CORRESPONDING FIELDS OF TABLE IT_PART2 WHERE REGTYP = REGTYP_1 AND TRNTYP = 'GRPO' AND BUDAT IN BUDAT. * DOCYR = IT_CDTL-DOCYR AND
* DOCNO = IT_CDTL-DOCNO. LOOP AT IT_PART2. SELECT SINGLE * FROM J_1IEXCHDR INTO CORRESPONDING FIELDS OF IT_CHDR WHERE TRNTYP = 'GRPO' AND DOCYR = IT_PART2-DOCYR AND DOCNO = IT_PART2-DOCNO AND WERKS = WERKS AND exdat IN BUDAT. * ORDER BY EXDAT. IF SY-SUBRC = 0. APPEND IT_CHDR. ELSE. CONTINUE. ENDIF. * IF SY-SUBRC <> 0. * MESSAGE E084. * ENDIF. ENDLOOP. LOOP AT IT_CHDR. SELECT * FROM J_1IEXCDTL INTO CORRESPONDING FIELDS OF IT_CDTL * FOR ALL ENTRIES IN IT_CHDR WHERE TRNTYP = 'GRPO' AND DOCNO = IT_CHDR-DOCNO AND DOCYR = IT_CHDR-DOCYR AND EXNUM = IT_CHDR-EXNUM AND EXDAT = IT_CHDR-EXDAT AND WERKS = IT_CHDR-WERKS. IF SY-SUBRC = 0. APPEND IT_CDTL. ELSE. CONTINUE. ENDIF. ENDSELECT. ENDLOOP. LOOP AT IT_CDTL. CLEAR TEXT. DB_CNT = DB_CNT + 1. READ TABLE IT_CHDR WITH KEY EXNUM = IT_CDTL-EXNUM. READ TABLE IT_PART2 WITH KEY DOCNO = IT_CDTL-DOCNO . IT_OUT-SERIALNO = IT_PART2-SERIALNO. SELECT SINGLE NAME1 FROM LFA1 INTO IT_OUT-NAME WHERE LIFNR = IT_CDTL-LIFNR. SELECT SINGLE * FROM LFA1 WHERE LIFNR = IT_CDTL-LIFNR. IF LFA1-LAND1 EQ 'IN'.
TEXT = 'INVOICE'. IT_OUT-TEXT1 = TEXT. ELSE. TEXT = 'BOE'. IT_OUT-TEXT1 = TEXT. ENDIF. SELECT SINGLE * FROM J_1IMOVEND WHERE LIFNR = IT_CDTL-LIFNR. SELECT SINGLE * FROM DD07T * INTO IT_OUT-DDTEXT WHERE DOMNAME = 'J_1IVTYP' AND DDLANGUAGE = 'EN' AND DOMVALUE_L = J_1IMOVEND-J_1IVTYP. IF DD07T-DDTEXT = 'First Stage Dealer of indigenous excisable goods' OR DD07T-DDTEXT = 'Second Stage Dealer of indigenous excisablegoods'. DD07T-DDTEXT = 'Dealer'. ENDIF. IT_OUT-DDTEXT = DD07T-DDTEXT. * ELSEIF DD07T-DDTEXT = 'Second Stage Dealer of indigenous excisable *goods'. * DD07T-DDTEXT = CLEAR EBELN_T. SELECT SINGLE LFBNR FROM MSEG INTO EBELN_T WHERE MBLNR = IT_CDTL-RDOC2 . SELECT SINGLE * FROM MSEG WHERE BWART = '106' AND LFBNR = EBELN_T ."and * ebeln = ebeln_t. IF SY-SUBRC = 0. IT_OUT-DEL_IND = 'X'. ELSE. IT_OUT-DEL_IND = ' '. ENDIF. SELECT SINGLE BUDAT FROM MKPF INTO IT_OUT-BUDAT WHERE MBLNR = EBELN_T ."MSEG-LFBNR. IT_OUT-EXNUM IT_OUT-EXDAT IT_OUT-EXCCD IT_OUT-EXBAS
= = = =
IT_CDTL-EXNUM. IT_CDTL-EXDAT. IT_CHDR-EXCCD. IT_CDTL-EXBAS.
IT_OUT-EXBED = IT_CDTL-EXBED. IT_OUT-ECS = IT_CDTL-ECS. IT_OUT-MATNR = IT_CDTL-MATNR. IT_OUT-MAKTX = IT_CDTL-MAKTX. IT_OUT-CHAPID = IT_CDTL-CHAPID. IT_OUT-MENGE = IT_CDTL-MENGE. IT_OUT-MEINS = IT_CDTL-MEINS. APPEND IT_OUT. * EX_NO = IT_CDTL-EXNUM. ENDLOOP. *-------------------------------------------------------* Title Portion IF REGTYP_1 = 'A'. SET TITLEBAR 'PAVAN' WITH DB_CNT. ELSEIF REGTYP_1 = 'C'. SET TITLEBAR 'PAVAN1' WITH DB_CNT. ENDIF. *--------------------------------------------------------AFIELD-COL_POS = 1. AFIELD-FIELDNAME = 'SERIALNO'. AFIELD-SELTEXT_L = 'INPUTS'. AFIELD-JUST = 'L'. APPEND AFIELD TO FIELDCAT. AFIELD-COL_POS = 2. AFIELD-FIELDNAME = 'TEXT1'. AFIELD-SELTEXT_L = 'TYPE OF DOC'. AFIELD-JUST = 'L'. AFIELD-DECIMALS_OUT = '0'. AFIELD-NO_ZERO = 'X'. APPEND AFIELD TO FIELDCAT. AFIELD-COL_POS = 3. AFIELD-FIELDNAME = 'EXNUM'. AFIELD-SELTEXT_L = 'DOC.NO'. AFIELD-JUST = 'L'. APPEND AFIELD TO FIELDCAT. AFIELD-COL_POS = 4. AFIELD-FIELDNAME = 'EXDAT'. AFIELD-SELTEXT_L = 'DOC.DATE'. AFIELD-JUST = 'C'. APPEND AFIELD TO FIELDCAT. AFIELD-COL_POS = 5. AFIELD-FIELDNAME = 'NAME'. AFIELD-SELTEXT_L = 'NAME OF THE SUPPLIER'. AFIELD-NO_ZERO = 'X'. AFIELD-JUST = 'L'.
APPEND AFIELD TO FIELDCAT. AFIELD-COL_POS = 6. AFIELD-FIELDNAME = 'DDTEXT'. AFIELD-SELTEXT_L = 'TYPE-OF-SUPPLIER'. AFIELD-JUST = 'L'. APPEND AFIELD TO FIELDCAT. AFIELD-COL_POS = 7. AFIELD-FIELDNAME = 'EXCCD'. AFIELD-SELTEXT_L = 'ECC OF THE SUPPLIER'. AFIELD-NO_ZERO = 'X'. AFIELD-JUST = 'L'. APPEND AFIELD TO FIELDCAT. AFIELD-COL_POS = 8. AFIELD-FIELDNAME = 'BUDAT'. AFIELD-SELTEXT_L = 'INPUT RECV DATE'. AFIELD-JUST = 'C'. APPEND AFIELD TO FIELDCAT. AFIELD-COL_POS = 9. AFIELD-FIELDNAME = 'EXBAS'. AFIELD-SELTEXT_L = 'ASSESSABLE-VALUE'. AFIELD-DO_SUM = 'X'. AFIELD-JUST = 'R'. AFIELD-DECIMALS_OUT = '2'. APPEND AFIELD TO FIELDCAT. AFIELD-COL_POS = 10. AFIELD-FIELDNAME = 'EXBED'. AFIELD-SELTEXT_L = 'DET OF CREDIT TAKEN CENVAT'. AFIELD-JUST = 'R'. APPEND AFIELD TO FIELDCAT. AFIELD-COL_POS = 11. AFIELD-FIELDNAME = 'ECS'. AFIELD-SELTEXT_L = 'DET OF CREDIT TAKEN E-CESS'. AFIELD-JUST = 'R'. APPEND AFIELD TO FIELDCAT. AFIELD-COL_POS = 12. AFIELD-FIELDNAME = 'MATNR'. AFIELD-SELTEXT_L = 'MATERIAL-CODE'. AFIELD-JUST = 'L'. APPEND AFIELD TO FIELDCAT. AFIELD-COL_POS = 13. AFIELD-FIELDNAME = 'MAKTX'. AFIELD-SELTEXT_L = 'DESCRIPTION'. AFIELD-JUST = 'L'. APPEND AFIELD TO FIELDCAT.
AFIELD-COL_POS = 14. AFIELD-FIELDNAME = 'CHAPID'. AFIELD-SELTEXT_L = 'TARIFF-ID'. AFIELD-JUST = 'L'. APPEND AFIELD TO FIELDCAT. AFIELD-COL_POS = 15. AFIELD-FIELDNAME = 'MENGE'. AFIELD-SELTEXT_L = 'QUANTITY'. AFIELD-JUST = 'R'. AFIELD-DO_SUM = ' '. APPEND AFIELD TO FIELDCAT. AFIELD-COL_POS = 16. AFIELD-FIELDNAME = 'MEINS'. AFIELD-SELTEXT_L = 'UOM'. AFIELD-JUST = 'C'. APPEND AFIELD TO FIELDCAT. AFIELD-COL_POS = 17. AFIELD-FIELDNAME = 'DEL_IND'. AFIELD-SELTEXT_L = 'Deleted'. AFIELD-JUST = 'C'. APPEND AFIELD TO FIELDCAT. * * LAYOUT FOR ZEBRA CATLOG LAYOUT_IN-COLWIDTH_OPTIMIZE = 'X'. LAYOUT_IN-ZEBRA = 'X'. LAYOUT_IN-GET_SELINFOS = 'X'. LAYOUT_IN-CONFIRMATION_PROMPT = 'X'. LAYOUT_IN-DETAIL_POPUP = 'X' . * SORTCAT-decimals = '0'. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING I_CALLBACK_PROGRAM = G_REPID I_CALLBACK_USER_COMMAND = 'USER_COMMAND' I_SAVE = G_SAVE IS_VARIANT = GS_VARIANT IT_FIELDCAT = FIELDCAT IT_SORT = SORTCAT IS_LAYOUT = LAYOUT_IN IT_EVENTS = EVENTCAT * I_BACKGROUND_ID = g_back_ground TABLES T_OUTTAB = IT_OUT. *&-------------------------------------------------------------------* *& Form TOP_OF_PAGE_LIST_HEADER
*&-------------------------------------------------------------------* * text *--------------------------------------------------------------------* * -->LIST_HEADERtext *--------------------------------------------------------------------* FORM TOP_OF_PAGE_LIST_HEADER USING LIST_HEADER TYPE SLIS_T_LISTHEADER. DATA : HLINE TYPE SLIS_LISTHEADER, TEXT(60) TYPE C. CLEAR : HLINE,TEXT. HLINE-TYP = 'H'. * WRITE 'ROOTS INDUSTRIES LTD' TO TEXT. HLINE-INFO = TEXT. APPEND HLINE TO LIST_HEADER. SELECT SINGLE * FROM T001W WHERE WERKS = WERKS. CLEAR : HLINE,TEXT. HLINE-TYP = 'H'. WRITE 'PLANT :' TO TEXT. WRITE WERKS TO TEXT+8. HLINE-INFO = TEXT. APPEND HLINE TO LIST_HEADER. CLEAR : HLINE,TEXT. HLINE-TYP = 'H'. WRITE T001W-NAME1 TO TEXT. HLINE-INFO = TEXT. APPEND HLINE TO LIST_HEADER. CLEAR : HLINE,TEXT. HLINE-TYP = 'H'. WRITE T001W-STRAS TO TEXT. HLINE-INFO = TEXT. APPEND HLINE TO LIST_HEADER. CLEAR : HLINE,TEXT. HLINE-TYP = 'H'. WRITE T001W-ORT01 TO TEXT. HLINE-INFO = TEXT. APPEND HLINE TO LIST_HEADER. CLEAR : HLINE,TEXT. HLINE-TYP = 'H'. WRITE 'DATE :' TO TEXT. WRITE BUDAT-LOW TO TEXT+7.
IF BUDAT-HIGH NE ''. WRITE 'TO' TO TEXT+18. WRITE BUDAT-HIGH TO TEXT+22. ENDIF. HLINE-INFO = TEXT. APPEND HLINE TO LIST_HEADER. ENDFORM. "TOP_OF_PAGE_LIST_HEADER *&-------------------------------------------------------------------* *& Form ALV_EVENT_INIT *&-------------------------------------------------------------------* * text *--------------------------------------------------------------------* FORM ALV_EVENT_INIT . CLEAR ALV_EVENT. ALV_EVENT-NAME = SLIS_EV_TOP_OF_PAGE. ALV_EVENT-FORM = 'ALV_TOP_OF_PAGE'. APPEND ALV_EVENT TO EVENTCAT. CLEAR ALV_EVENT. ALV_EVENT-NAME = SLIS_EV_TOP_OF_LIST. ALV_EVENT-FORM = 'ALV_TOP_OF_LIST'. APPEND ALV_EVENT TO EVENTCAT. * * * *
CLEAR ALV_EVENT. ALV_EVENT-NAME = SLIS_EV_END_OF_LIST. ALV_EVENT-FORM = 'ALV_END_OF_LIST'. APPEND ALV_EVENT TO GT_EVENTS.
* * * *
CLEAR ALV_EVENT. ALV_EVENT-NAME = SLIS_EV_END_OF_PAGE. ALV_EVENT-FORM = 'ALV_END_OF_PAGE'. APPEND ALV_EVENT TO GT_EVENTS.
ENDFORM. "ALV_EVENT_INIT *&-------------------------------------------------------------------* *& Form ALV_TOP_OF_PAGE *&-------------------------------------------------------------------* * text *--------------------------------------------------------------------* FORM ALV_TOP_OF_PAGE. CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING IT_LIST_COMMENTARY = LIST_HEADER I_LOGO = 'ENJOYSAP_LOGO'. ENDFORM. "ALV_TOP_OF_PAGE *&--------------------------------------------------------------------* *& Form BUILD_EVENT *&--------------------------------------------------------------------* * text *---------------------------------------------------------------------* * -->P_GT_EVENTS[] text *---------------------------------------------------------------------* FORM BUILD_EVENT USING P_EVENTS TYPE SLIS_T_EVENT. CALL FUNCTION 'REUSE_ALV_EVENTS_GET' EXPORTING I_LIST_TYPE = 0 IMPORTING ET_EVENTS = P_EVENTS EXCEPTIONS LIST_TYPE_WRONG = 1 OTHERS = 2. READ TABLE P_EVENTS WITH KEY NAME = SLIS_EV_USER_COMMAND INTO ALV_EVENT. IF SY-SUBRC = 0. MOVE GC_FORMNAME_USER_COMMAND TO ALV_EVENT-FORM. APPEND ALV_EVENT TO P_EVENTS. ENDIF. READ TABLE P_EVENTS WITH KEY NAME = SLIS_EV_BEFORE_LINE_OUTPUT INTO ALV_EVENT. IF SY-SUBRC = 0. MOVE GC_FORMNAME_BEFORE_OUTPUT TO ALV_EVENT-FORM. APPEND ALV_EVENT TO P_EVENTS. ENDIF. ENDFORM. " BUILD_EVENT
Alv grid display
report zalvg. TABLES: EKPO. TYPES: BEGIN OF t_ekko, ebeln TYPE ekpo-ebeln, ebelp TYPE ekpo-ebelp, statu TYPE ekpo-statu, aedat TYPE ekpo-aedat, matnr TYPE ekpo-matnr, menge TYPE ekpo-menge, meins TYPE ekpo-meins, netpr TYPE ekpo-netpr, peinh TYPE ekpo-peinh, END OF t_ekko. DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0, wa_ekko TYPE t_ekko. type-pools: slis. data: fieldcatalog type slis_t_fieldcat_alv with header line, gd_tab_group type slis_t_sp_group_alv, gd_layout type slis_layout_alv, gd_repid like sy-repid, gt_events type slis_t_event, gd_prntparams type slis_print_alv. perform data_retrieval. perform build_fieldcatalog. perform display_alv_report.
form build_fieldcatalog. * There are a number of ways to create a fieldcat. * For the purpose of this example i will build the fieldcatalog manualy * by populating the internal table fields individually and then * appending the rows. This method can be the most time consuming but can * also allow you more control of the final product. * Beware though, you need to ensure that all fields required are * populated. When using some of functionality available via ALV, such as * total. You may need to provide more information than if you were * simply displaying the result * I.e. Field type may be required in-order for
*
the 'TOTAL' function to work.
fieldcatalog-fieldname = 'EBELN'. fieldcatalog-seltext_m = 'Purchase Order'. fieldcatalog-col_pos = 0. fieldcatalog-outputlen = 10. fieldcatalog-emphasize = 'X'. fieldcatalog-key = 'X'. * fieldcatalog-do_sum = 'X'. * fieldcatalog-no_zero = 'X'. append fieldcatalog to fieldcatalog. clear fieldcatalog. fieldcatalog-fieldname = 'EBELP'. fieldcatalog-seltext_m = 'PO Item'. fieldcatalog-col_pos = 1. append fieldcatalog to fieldcatalog. clear fieldcatalog. fieldcatalog-fieldname = 'STATU'. fieldcatalog-seltext_m = 'Status'. fieldcatalog-col_pos = 2. append fieldcatalog to fieldcatalog. clear fieldcatalog. fieldcatalog-fieldname = 'AEDAT'. fieldcatalog-seltext_m = 'Item change date'. fieldcatalog-col_pos = 3. append fieldcatalog to fieldcatalog. clear fieldcatalog. fieldcatalog-fieldname = 'MATNR'. fieldcatalog-seltext_m = 'Material Number'. fieldcatalog-col_pos = 4. append fieldcatalog to fieldcatalog. clear fieldcatalog. fieldcatalog-fieldname = 'MENGE'. fieldcatalog-seltext_m = 'PO quantity'. fieldcatalog-col_pos = 5. append fieldcatalog to fieldcatalog. clear fieldcatalog. fieldcatalog-fieldname = 'MEINS'. fieldcatalog-seltext_m = 'Order Unit'. fieldcatalog-col_pos = 6. append fieldcatalog to fieldcatalog. clear fieldcatalog. fieldcatalog-fieldname fieldcatalog-seltext_m fieldcatalog-col_pos fieldcatalog-outputlen
= = = =
'NETPR'. 'Net Price'. 7. 15.
fieldcatalog-datatype = 'CURR'. append fieldcatalog to fieldcatalog. clear fieldcatalog. fieldcatalog-fieldname = 'PEINH'. fieldcatalog-seltext_m = 'Price Unit'. fieldcatalog-col_pos = 8. append fieldcatalog to fieldcatalog. clear fieldcatalog. endform. " BUILD_FIELDCATALOG form display_alv_report. gd_repid = sy-repid. call function 'REUSE_ALV_GRID_DISPLAY' exporting i_callback_program = gd_repid i_callback_top_of_page = 'TOP-OF-PAGE' i_callback_user_command = 'USER_COMMAND' * i_grid_title = outtext is_layout = gd_layout it_fieldcat = fieldcatalog[] * it_special_groups = gd_tabgroup it_events = gt_events is_print = gd_prntparams i_save = 'X' * is_variant = z_template 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.
"see FORM
form data_retrieval. select ebeln ebelp statu aedat matnr menge meins netpr peinh from ekpo into table it_ekko. endform.
Alv grid with radio buttons *&--------------------------------------------------------------------* *& Report ZALVGRID_WITH_RADIOBUTTONS * *& * *&--------------------------------------------------------------------* *& * *& * *&--------------------------------------------------------------------* REPORT
ZALVGRID_WITH_RADIOBUTTONS
.
TYPE-POOLS: abap, icon. " INCLUDE . for releases < 6.20 TYPES: BEGIN OF ty_s_sflight. INCLUDE TYPE sflight. TYPES: button1 TYPE iconname. TYPES: button2 TYPE iconname. TYPES: button3 TYPE iconname. TYPES: button4 TYPE iconname. TYPES: END OF ty_s_sflight. DATA:gt_sflight TYPE STANDARD TABLE OF ty_s_sflight, gs_layout TYPE lvc_s_layo, gt_fcat TYPE lvc_t_fcat. DATA:gd_okcode TYPE ui_func, go_docking TYPE REF TO cl_gui_docking_container, go_grid TYPE REF TO cl_gui_alv_grid. *icon_wd_radio_button_empty TYPE REF TO icon_wd_radio_button_empty. *--------------------------------------------------------------------* * CLASS lcl_eventhandler DEFINITION *--------------------------------------------------------------------* * *--------------------------------------------------------------------* CLASS lcl_eventhandler DEFINITION. PUBLIC SECTION. CLASS-METHODS: handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid IMPORTING e_row_id e_column_id
es_row_no sender. ENDCLASS. "lcl_eventhandler DEFINITION *--------------------------------------------------------------------* * CLASS lcl_eventhandler IMPLEMENTATION *--------------------------------------------------------------------* * *--------------------------------------------------------------------* CLASS lcl_eventhandler IMPLEMENTATION. METHOD handle_hotspot_click. * define local data FIELD-SYMBOLS: TYPE ty_s_sflight, TYPE ANY. READ TABLE gt_sflight ASSIGNING INDEX es_row_no-row_id. CHECK ( IS ASSIGNED ). * Set all radio buttons "unselected" -button1 = icon_wd_radio_button_empty. -button2 = icon_wd_radio_button_empty. -button3 = icon_wd_radio_button_empty. -button4 = icon_wd_radio_button_empty. ASSIGN COMPONENT e_column_id-fieldname OF STRUCTURE TO . IF ( IS ASSIGNED ). * Set selected radio button "selected". = icon_wd_radio_button. ENDIF. * Force PAI followed by refresh of table display in PBO CALL METHOD cl_gui_cfw=>set_new_ok_code EXPORTING new_code = 'REFRESH' * IMPORTING * RC = . ENDMETHOD. "handle_hotspot_click ENDCLASS. "lcl_eventhandler IMPLEMENTATION *--------------------------------------------------------------------* * MAIN * *--------------------------------------------------------------------* START-OF-SELECTION. PERFORM select_data. PERFORM init_controls. PERFORM build_fieldcatalog. PERFORM set_layout. CALL METHOD go_grid->set_table_for_first_display EXPORTING * i_structure_name = 'SFLIGHT' is_layout = gs_layout
CHANGING it_fieldcatalog = gt_fcat it_outtab = gt_sflight. * Link docking container to dynpro CALL METHOD go_docking->link EXPORTING repid = syst-repid dynnr = '0100' * CONTAINER = EXCEPTIONS cntl_error = 1 cntl_system_error = 2 lifetime_dynpro_dynpro_link = 3 OTHERS = 4. IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. CALL SCREEN 100. END-OF-SELECTION. *--------------------------------------------------------------------* * MODULE PBO OUTPUT * *--------------------------------------------------------------------* MODULE pbo OUTPUT. SET PF-STATUS 'MAIN100'. SET TITLEBAR 'MAIN100'. ENDMODULE. "PBO OUTPUT *--------------------------------------------------------------------* * MODULE PAI INPUT * *--------------------------------------------------------------------* MODULE pai INPUT. * Leave report CASE gd_okcode. WHEN 'BACK' OR 'EXIT' OR 'CANC'. SET SCREEN 0. LEAVE SCREEN. * Refresh table display WHEN 'REFRESH'. PERFORM refresh_display. WHEN OTHERS. * do nothing ENDCASE. CLEAR gd_okcode. ENDMODULE. "PAI INPUT *&--------------------------------------------------------------------* *& Form BUILD_FIELDCATALOG
*&--------------------------------------------------------------------* * text *---------------------------------------------------------------------* * --> p1 text * <-- p2 text *---------------------------------------------------------------------* FORM build_fieldcatalog . * define local data DATA: ls_fcat TYPE lvc_s_fcat. CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' EXPORTING * I_BUFFER_ACTIVE = i_structure_name = 'ICON' * I_CLIENT_NEVER_DISPLAY = 'X' * I_BYPASSING_BUFFER = * I_INTERNAL_TABNAME = CHANGING ct_fieldcat = gt_fcat EXCEPTIONS inconsistent_interface = 1 program_error = 2 OTHERS = 3. IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. DELETE gt_fcat WHERE ( fieldname <> 'NAME' ). * NOTE: field ICON-NAME has data element ICONNAME. CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' EXPORTING * I_BUFFER_ACTIVE = i_structure_name = 'SFLIGHT' * I_CLIENT_NEVER_DISPLAY = 'X' * I_BYPASSING_BUFFER = * I_INTERNAL_TABNAME = CHANGING ct_fieldcat = gt_fcat EXCEPTIONS inconsistent_interface = 1 program_error = 2 OTHERS = 3. IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. READ TABLE gt_fcat INTO ls_fcat WITH KEY fieldname = 'NAME'. IF ( syst-subrc = 0 ). DELETE gt_fcat INDEX syst-tabix.
ENDIF. ls_fcat-fieldname = 'BUTTON4'. ls_fcat-coltext = ls_fcat-fieldname. ls_fcat-icon = 'X'. ls_fcat-hotspot = 'X'. INSERT ls_fcat INTO gt_fcat INDEX 5. * ls_fcat-fieldname = 'BUTTON3'. ls_fcat-coltext = ls_fcat-fieldname. INSERT ls_fcat INTO gt_fcat INDEX 5. * ls_fcat-fieldname = 'BUTTON2'. ls_fcat-coltext = ls_fcat-fieldname. INSERT ls_fcat INTO gt_fcat INDEX 5. * ls_fcat-fieldname = 'BUTTON1'. ls_fcat-coltext = ls_fcat-fieldname. INSERT ls_fcat INTO gt_fcat INDEX 5. * Renumbering of the columns LOOP AT gt_fcat INTO ls_fcat. ls_fcat-col_pos = syst-tabix. MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix. ENDLOOP. ENDFORM. " BUILD_FIELDCATALOG *&--------------------------------------------------------------------* *& Form SELECT_DATA *&--------------------------------------------------------------------* * text *---------------------------------------------------------------------* * --> p1 text * <-- p2 text *---------------------------------------------------------------------* FORM select_data . * define local data DATA: ls_sflight TYPE ty_s_sflight. SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE gt_sflight. ls_sflight-button1 = icon_wd_radio_button. " selected radiobutton ls_sflight-button2 = icon_wd_radio_button_empty. ls_sflight-button3 = icon_wd_radio_button_empty. ls_sflight-button4 = icon_wd_radio_button_empty. * Alternatively: create icons using function module 'ICON_CREATE' * on SAP releases where these icons are not available. MODIFY gt_sflight FROM ls_sflight TRANSPORTING button1 button2 button3 button4 WHERE ( carrid IS NOT INITIAL ). ENDFORM. " SELECT_DATA *&--------------------------------------------------------------------*
*& Form INIT_CONTROLS *&--------------------------------------------------------------------* * text *---------------------------------------------------------------------* * --> p1 text * <-- p2 text *---------------------------------------------------------------------* FORM init_controls . CHECK ( go_docking IS NOT BOUND ). * Create docking container CREATE OBJECT go_docking EXPORTING parent = cl_gui_container=>screen0 * REPID = * DYNNR = * SIDE = DOCK_AT_LEFT * EXTENSION = 50 * STYLE = * LIFETIME = lifetime_default * CAPTION = * METRIC = 0 ratio = 90 * NO_AUTODEF_PROGID_DYNNR = * NAME = EXCEPTIONS cntl_error = 1 cntl_system_error = 2 create_error = 3 lifetime_error = 4 lifetime_dynpro_dynpro_link = 5 OTHERS = 6. IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. * Size of container = full screen size CALL METHOD go_docking->set_extension EXPORTING extension = 99999 EXCEPTIONS cntl_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. * Create ALV grid instance CREATE OBJECT go_grid EXPORTING * I_SHELLSTYLE = 0
* I_LIFETIME = i_parent = go_docking * I_APPL_EVENTS = space * I_PARENTDBG = * I_APPLOGPARENT = * I_GRAPHICSPARENT = * I_NAME = * I_FCAT_COMPLETE = SPACE EXCEPTIONS error_cntl_create = 1 error_cntl_init = 2 error_cntl_link = 3 error_dp_create = 4 OTHERS = 5. IF sy-subrc <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. * Set event handler for event HOTSPOT_CLICK SET HANDLER: lcl_eventhandler=>handle_hotspot_click FOR go_grid. ENDFORM. " INIT_CONTROLS *&--------------------------------------------------------------------* *& Form REFRESH_DISPLAY *&--------------------------------------------------------------------* * Refresh table display after switching the radiobuttons *---------------------------------------------------------------------* * --> p1 text * <-- p2 text *---------------------------------------------------------------------* FORM refresh_display . * define local data DATA: ls_stable TYPE lvc_s_stbl. ls_stable-row = abap_true. ls_stable-col = abap_true. CALL METHOD go_grid->refresh_table_display EXPORTING is_stable = ls_stable * I_SOFT_REFRESH = EXCEPTIONS finished = 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. " REFRESH_DISPLAY
*&--------------------------------------------------------------------* *& Form SET_LAYOUT *&--------------------------------------------------------------------* * Set layout for ALV list *---------------------------------------------------------------------* * --> p1 text * <-- p2 text *---------------------------------------------------------------------* FORM set_layout . CLEAR: gs_layout. gs_layout-cwidth_opt = abap_true. " optimize column width gs_layout-zebra = abap_true. ENDFORM. " SET_LAYOUT
Simple alv report *&--------------------------------------------------------------------* *& Report ZALVTEST * *& * *&--------------------------------------------------------------------* *& * *& * *&--------------------------------------------------------------------* REPORT
ZALVTEST.
TABLES: mara, makt. TYPE-POOLS: slis. TYPES: BEGIN OF tab, matnr TYPE matnr, matkl TYPE matkl, maktx TYPE maktx, END OF tab. DATA: itab TYPE TABLE OF tab, wa LIKE LINE OF itab.
*ALV data declarations data: fieldcatalog type gd_tab_group type gd_layout type gd_repid like
slis_t_fieldcat_alv with header line, slis_t_sp_group_alv, slis_layout_alv, sy-repid.
******************************************************************** **** *Start-of-selection. START-OF-SELECTION. perform perform perform perform
data_retrieval. build_fieldcatalog. build_layout. display_alv_report.
*&--------------------------------------------------------------------*
*& Form BUILD_FIELDCATALOG *&--------------------------------------------------------------------* * Build Fieldcatalog for ALV Report *---------------------------------------------------------------------* form build_fieldcatalog. * There are a number of ways to create a fieldcat. * For the purpose of this example i will build the fieldcatalog manualy * by populating the internal table fields individually and then * appending the rows. This method can be the most time consuming but can * also allow you more control of the final product. * Beware though, you need to ensure that all fields required are * populated. When using some of functionality available via ALV, such as * total. You may need to provide more information than if you were * simply displaying the result * I.e. Field type may be required in-order for * the 'TOTAL' function to work. fieldcatalog-fieldname = 'MATNR'. fieldcatalog-seltext_m = 'Material No'. fieldcatalog-col_pos = 0. fieldcatalog-outputlen = 10. fieldcatalog-emphasize = 'X'. append fieldcatalog to fieldcatalog. clear fieldcatalog. fieldcatalog-fieldname = 'MATKL'. fieldcatalog-seltext_m = 'Group'. fieldcatalog-col_pos = 2. fieldcatalog-outputlen = 5. append fieldcatalog to fieldcatalog. clear fieldcatalog. fieldcatalog-fieldname = 'MAKTX'. fieldcatalog-seltext_m = 'Description'. fieldcatalog-col_pos = 1. fieldcatalog-outputlen = 8. append fieldcatalog to fieldcatalog. clear fieldcatalog. endform.
" BUILD_FIELDCATALOG
*&--------------------------------------------------------------------* *& Form BUILD_LAYOUT
*&--------------------------------------------------------------------* * Build layout for ALV grid report *---------------------------------------------------------------------* form build_layout. gd_layout-no_input = 'X'. gd_layout-colwidth_optimize = 'X'. endform. " BUILD_LAYOUT *&--------------------------------------------------------------------* *& Form DISPLAY_ALV_REPORT *&--------------------------------------------------------------------* * Display report using ALV grid *---------------------------------------------------------------------* form display_alv_report. gd_repid = sy-repid. call function 'REUSE_ALV_GRID_DISPLAY' exporting i_callback_program = gd_repid * i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM * i_callback_user_command = 'USER_COMMAND' * i_grid_title = outtext is_layout = gd_layout it_fieldcat = fieldcatalog[] * it_special_groups = gd_tabgroup * IT_EVENTS = GT_XEVENTS i_save = 'X' * is_variant = z_template tables t_outtab = itab 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 DATA_RETRIEVAL *&--------------------------------------------------------------------* * Retrieve data form EKPO table and populate itab it_ekko
*---------------------------------------------------------------------* form data_retrieval. SELECT F~matnr F~matkl P~maktx INTO table itab FROM mara AS F INNER JOIN makt AS P ON F~matnr = P~matnr. endform.
" DATA_RETRIEVAL
Alv report with Total & Subtotal and also you can restrict number of lines to display *&--------------------------------------------------------------------* *& Report ZALVTOTAL * *& * *&--------------------------------------------------------------------* *& * *& * *&--------------------------------------------------------------------* REPORT
ZALVTOTAL
TYPES : BEGIN OF ty_vbak, vkorg TYPE vbak-vkorg, kunnr TYPE vbak-kunnr, vbeln TYPE vbak-vbeln, netwr TYPE vbak-netwr, Order waerk TYPE vbak-waerk, END OF ty_vbak.
.
" " " "
Sales organization Sold-to party Sales document Net Value of the Sales
" Document currency
DATA: vbak TYPE vbak, gt_vbak TYPE TABLE OF ty_vbak. SELECT-OPTIONS : s_vkorg FOR vbak-vkorg, s_kunnr FOR vbak-kunnr, s_vbeln FOR vbak-vbeln.
" Sales organization " Sold-to party " Sales document
SELECTION-SCREEN : SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max. PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY. SELECTION-SCREEN END OF LINE. *--------------------------------------------------------------------* INITIALIZATION. v_1 = 'Maximum of records to read'. *--------------------------------------------------------------------*
START-OF-SELECTION. PERFORM f_read_data. PERFORM f_display_data. *--------------------------------------------------------------------* * Form f_read_data *--------------------------------------------------------------------* FORM f_read_data. SELECT UP INTO FROM WHERE AND AND
vkorg kunnr vbeln netwr waerk TO p_max ROWS TABLE gt_vbak vbak kunnr IN s_kunnr vbeln IN s_vbeln vkorg IN s_vkorg.
ENDFORM. " F_READ_DATA *--------------------------------------------------------------------* * Form f_display_data *--------------------------------------------------------------------* FORM f_display_data. TYPE-POOLS: slis.
" ALV Global types
DEFINE m_fieldcat. add 1 to ls_fieldcat-col_pos. ls_fieldcat-fieldname = &1. ls_fieldcat-ref_tabname = 'VBAK'. ls_fieldcat-do_sum = &2. ls_fieldcat-cfieldname = &3. append ls_fieldcat to lt_fieldcat. END-OF-DEFINITION. DEFINE m_sort. add 1 to ls_sort-spos. ls_sort-fieldname = &1. ls_sort-up = 'X'. ls_sort-subtot = &2. append ls_sort to lt_sort. END-OF-DEFINITION. DATA: ls_fieldcat lt_fieldcat lt_sort ls_sort
TYPE TYPE TYPE TYPE
slis_fieldcat_alv, slis_t_fieldcat_alv, slis_t_sortinfo_alv, slis_sortinfo_alv,
ls_layout m_fieldcat m_fieldcat m_fieldcat m_fieldcat m_fieldcat
TYPE slis_layout_alv.
'VKORG' 'KUNNR' 'VBELN' 'NETWR' 'WAERK'
'' '' '' 'X' ''
''. ''. ''. 'WAERK'. ''.
m_sort 'VKORG' 'X'. m_sort 'KUNNR' 'X'. m_sort 'VBELN' ''.
" Sort by vkorg and subtotal " Sort by kunnr and subtotal " Sort by vbeln
ls_layout-cell_merge = 'X'. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING is_layout = ls_layout it_fieldcat = lt_fieldcat it_sort = lt_sort TABLES t_outtab = gt_vbak. ENDFORM.
" F_DISPLAY_DATA
Alv report with Radiobuttons and multiple selection option on selection screen *&--------------------------------------------------------------------* *& Report ZALV_DEMO * *& * *&--------------------------------------------------------------------* *& * *& * *&--------------------------------------------------------------------* REPORT
ZALV_DEMO
TYPE-POOLS:
.
SLIS.
TABLES: iloa,INET. * Internal table for field catalog DATA: LFIELD TYPE SLIS_T_FIELDCAT_ALV. DATA: XFIELD TYPE SLIS_T_FIELDCAT_ALV. DATA: YFIELD TYPE SLIS_T_FIELDCAT_ALV. DATA: ZFIELD TYPE SLIS_T_FIELDCAT_ALV. DATA: HFIELD TYPE SLIS_T_FIELDCAT_ALV. * Headline to the field catalog DATA: AFIELD TYPE SLIS_FIELDCAT_ALV. * Special Groups DATA: GT_SP_GROUPS TYPE SLIS_T_SP_GROUP_ALV WITH HEADER LINE. * Intermediate totals and assortment DATA: GT_ZSUM TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE. * Filter conditions DATA: GT_FILTER TYPE SLIS_T_FILTER_ALV WITH HEADER LINE. *iTab for head information to the list DATA: XHEADER TYPE SLIS_T_LISTHEADER WITH HEADER LINE. * Layoutstruktur DATA: GS_LAYOUT TYPE SLIS_LAYOUT_ALV. DATA: X_LAYOUT TYPE SLIS_LAYOUT_ALV. DATA: Y_LAYOUT TYPE SLIS_LAYOUT_ALV. DATA: Z_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA: H_LAYOUT TYPE SLIS_LAYOUT_ALV. DATA: L_LAYOUT TYPE SLIS_LAYOUT_ALV. * Keyinfo DATA: GS_KEYINFO TYPE SLIS_KEYINFO_ALV. * Excludingtabelle DATA: GT_EXTAB TYPE slis_T_EXTAB WITH HEADER LINE. * Layoutstruktur DATA: XISETAB TYPE SLIS_SELDIS_ALV. * Events DATA: GT_XEVENTS TYPE SLIS_T_EVENT. DATA: GT_YEVENTS TYPE SLIS_T_EVENT. DATA: GT_ZEVENTS TYPE SLIS_T_EVENT. DATA: GT_HEVENTS TYPE SLIS_T_EVENT. DATA: GT_LEVENTS TYPE SLIS_T_EVENT. data : XS_EVENT TYPE SLIS_ALV_EVENT. DATA: GT_PRINT TYPE SLIS_PRINT_ALV. * OK_Code für Layoutpopup DATA: OK_CODE LIKE SY-UCOMM. DATA: FLG_EXIT(1) TYPE C.
" Abbruch des Layoutpopups.
* Farbtabelle für Zelleneinfärbungen DATA: GT_COLOR TYPE SLIS_T_SPECIALCOL_ALV WITH HEADER LINE. DATA: WA TYPE VIQMEL, TM(8) TYPE C. DATA: BEGIN OF ITAB, * ILOAN LIKE VIQMEL-ILOAN, QMNUM LIKE VIQMEL-QMNUM, QMDAT LIKE VIQMEL-QMDAT, AUSVN LIKE VIQMEL-AUSVN, " START DATE OF MAL FUNCTION AUZTV LIKE VIQMEL-AUZTV, " START TIME OF MAL FUNCTION AUSZT LIKE VIQMEL-AUSZT, " BREAK DOWN TIME AUSBS LIKE VIQMEL-AUSBS, " END DATE OF MAL FUNCTION AUZTB LIKE VIQMEL-AUZTB, " END TIME OF MAL FUNCTION * NETID LIKE INET-NETID, TPLNR LIKE ILOA-TPLNR, END OF ITAB, ITAB1 LIKE STANDARD TABLE OF ITAB WITH HEADER LINE. DATA: BEGIN OF WA_INETTAB, DATVA LIKE INET-DATVA, " START DATE OF LINK CREATED (VALIDITY) DATVB LIKE INET-DATVB, " END DATE OF LINK CREATED TPKANT LIKE INET-TPKANT, " FUNCTIONAL OBJECT NETID LIKE INET-NETID, " NETWORD ID TPVON LIKE INET-TPVON, " LINK FROM FUNCT LOC TPNACH LIKE INET-TPNACH, " LINK TO FUNCT LOC END OF WA_INETTAB, INETTAB LIKE STANDARD TABLE OF WA_INETTAB WITH HEADER LINE. *------------------------------------------------------------------*& header data
DATA: HDATA LIKE inettab OCCURS 0 WITH HEADER LINE. *----------------------------------------------------------DATA: BEGIN OF WA_FINALTAB, * ILOAN LIKE VIQMEL-ILOAN, QMNUM LIKE VIQMEL-QMNUM, QMDAT LIKE VIQMEL-QMDAT, AUSVN LIKE VIQMEL-AUSVN, " START DATE OF MAL FUNCTION AUZTV LIKE VIQMEL-AUZTV, " START TIME OF MAL FUNCTION AUSZT LIKE VIQMEL-AUSZT, " BREAK DOWN TIME AUSBS LIKE VIQMEL-AUSBS, " END DATE OF MAL FUNCTION AUZTB LIKE VIQMEL-AUZTB, " END TIME OF MAL FUNCTION TPLNR LIKE ILOA-TPLNR, DATVA LIKE INET-DATVA, " START DATE OF LINK CREATED (VALIDITY) DATVB LIKE INET-DATVB, " END DATE OF LINK CREATED * TPKANT LIKE INET-TPKANT, " FUNCTIONAL OBJECT NETID LIKE INET-NETID, " NETWORD ID TPVON LIKE INET-TPVON, " LINK FROM FUNCT LOC TPNACH LIKE INET-TPNACH, " LINK TO FUNCT LOC END OF WA_FINALTAB, FINALTAB LIKE STANDARD TABLE OF WA_FINALTAB WITH HEADER LINE. * item data DATA: IDATA LIKE FINALTAB occurs 0 WITH HEADER LINE. DATA: REPID LIKE SY-REPID. * Report selection SELECT-OPTIONS NET_ID FOR INET-NETID NO INTERVALS. SELECT-OPTIONS DATE FOR WA-AUSVN OBLIGATORY NO-EXTENSION. SELECT-OPTIONS FUNC_LOC FOR ILOA-TPLNR NO INTERVALS. PARAMETERS: RPT_TYP1 RADIOBUTTON GROUP RAD1, RPT_TYP2 RADIOBUTTON GROUP RAD1. * *---------------------------------------------------------------------INITIALIZATION. MOVE: 'I' TO DATE-SIGN, 'EQ' TO DATE-OPTION, '20050101' TO DATE-LOW, SY-DATUM TO DATE-HIGH. APPEND DATE. REPID = SY-REPID. * AT SELECTION-SCREEN OUTPUT. IF DATE-HIGH IS INITIAL. REFRESH DATE. MOVE: SY-DATUM TO DATE-HIGH. APPEND DATE.
ENDIF. START-OF-SELECTION. IF DATE-HIGH IS INITIAL. REFRESH DATE. MOVE: SY-DATUM TO DATE-HIGH. APPEND DATE. ENDIF. *IF NOT ( FUNC_LOC IS INITIAL ). SELECT V~QMNUM V~QMDAT V~AUSVN V~AUSBS V~AUZTV V~AUZTB V~AUSZT I~TPLNR INTO CORRESPONDING FIELDS OF TABLE ITAB1 FROM ( VIQMEL AS V INNER JOIN ILOA AS I ON V~ILOAN = I~ILOAN ) WHERE ( V~AUSVN in DATE and V~AUSBS in DATE ) AND V~MSAUS EQ 'X' AND V~EQUNR EQ SPACE AND V~QMART IN ('S1','S2','S3') AND I~TPLNR in FUNC_LOC.
SELECT NETID TPKANT TPVON TPNACH DATVA DATVB INTO CORRESPONDING FIELDS OF TABLE INETTAB FROM INET WHERE NETID IN NET_ID AND TPKANT IN FUNC_LOC. HDATA[] = INETTAB[]. SORT INETTAB BY NETID TPKANT DATVA DATVB. SORT ITAB1 BY TPLNR AUSVN AUZTV. IF RPT_TYP1 EQ 'X'. LOOP AT INETTAB. LOOP AT ITAB1 WHERE TPLNR EQ INETTAB-TPKANT AND AUSVN GT INETTAB-DATVA AND AUSBS LT INETTAB-DATVB. CLEAR FINALTAB. MOVE-CORRESPONDING INETTAB TO FINALTAB. MOVE-CORRESPONDING ITAB1 TO FINALTAB. APPEND FINALTAB. ENDLOOP. ENDLOOP. SORT FINALTAB BY NETID. IDATA[] = FINALTAB[]. ELSE. LOOP AT ITAB1. LOOP AT INETTAB WHERE TPKANT EQ ITAB1-TPLNR AND DATVA LE ITAB1AUSVN AND DATVB GE ITAB1-AUSBS. CLEAR FINALTAB.
MOVE-CORRESPONDING ITAB1 TO FINALTAB. MOVE-CORRESPONDING INETTAB TO FINALTAB. APPEND FINALTAB. ENDLOOP. ENDLOOP. SORT FINALTAB BY TPLNR. ENDIF. * IF SY-SUBRC EQ 0. * LOOP AT FINALTAB INTO WA_FINALTAB. * WRITE:/(14) WA_FINALTAB-TPLNR, (8) WA_FINALTAB-NETID, (15) * WA_FINALTAB-TPVON, (10) WA_FINALTAB-TPNACH, (10) WA_FINALTABDATVA, * (10) WA_FINALTAB-DATVB, (10) WA_FINALTAB-AUSBS , * (10) WA_FINALTAB-AUSVN, (10) WA_FINALTAB-QMNUM,(10) * WA_FINALTAB-QMDAT, * (15) WA_FINALTAB-AUSZT. * ENDLOOP. * ENDIF. * PERFORM FIELDS.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY' EXPORTING I_CALLBACK_PROGRAM = REPID IS_LAYOUT = H_LAYOUT IT_FIELDCAT = HFIELD IS_KEYINFO = GS_KEYINFO I_TABNAME_HEADER = 'HDATA' I_TABNAME_ITEM = 'IDATA' IT_EVENTS = GT_HEVENTS TABLES T_OUTTAB_HEADER = HDATA T_OUTTAB_ITEM = IDATA.
END-OF-SELECTION. *&-------------------------------------------------------------------* *& Form FIELDS *&-------------------------------------------------------------------* * text *--------------------------------------------------------------------* FORM FIELDS. DATA: L_COUNT TYPE I. * CLEAR AFIELD.
L_COUNT = L_COUNT + 1. AFIELD-COL_POS = L_COUNT. AFIELD-FIELDNAME = 'NETID'. * AFIELD-TABNAME = 'inettab'. AFIELD-REF_TABNAME = 'INET'. AFIELD-KEY = 'X'. APPEND AFIELD TO XFIELD. AFIELD-TABNAME = 'HDATA'. APPEND AFIELD TO HFIELD. * AFIELD-TABNAME = 'LDATA'. * APPEND AFIELD TO LFIELD. CLEAR AFIELD. L_COUNT = L_COUNT + 1. AFIELD-COL_POS = L_COUNT. AFIELD-FIELDNAME = 'TPKANT'. * AFIELD-TABNAME = 'inettab'. AFIELD-REF_TABNAME = 'INET'. AFIELD-KEY = 'X'. APPEND AFIELD TO XFIELD. AFIELD-TABNAME = 'HDATA'. APPEND AFIELD TO HFIELD. CLEAR AFIELD. L_COUNT = L_COUNT + 1. AFIELD-COL_POS = L_COUNT. AFIELD-FIELDNAME = 'NETID'. AFIELD-TABNAME = 'FINALTAB'. * AFIELD-REF_TABNAME = ''. AFIELD-KEY = 'X'. APPEND AFIELD TO XFIELD. AFIELD-TABNAME = 'IDATA'. APPEND AFIELD TO HFIELD.
CLEAR AFIELD. L_COUNT = L_COUNT + 1. AFIELD-COL_POS = L_COUNT. AFIELD-FIELDNAME = 'TPKANT'. AFIELD-TABNAME = 'FINALTAB'. * AFIELD-REF_TABNAME = ''. AFIELD-KEY = 'X'. APPEND AFIELD TO XFIELD. AFIELD-TABNAME = 'IDATA'. APPEND AFIELD TO HFIELD.
CLEAR AFIELD. L_COUNT = L_COUNT + 1. AFIELD-COL_POS = L_COUNT.
"define field as key
"define field as key
"define field as key
"define field as key
AFIELD-FIELDNAME = 'QMNUM'. AFIELD-TABNAME = 'FINALTAB'. * AFIELD-REF_TABNAME = ''. AFIELD-KEY = 'X'. APPEND AFIELD TO XFIELD. AFIELD-TABNAME = 'IDATA'. APPEND AFIELD TO HFIELD. CLEAR AFIELD. L_COUNT = L_COUNT + 1. AFIELD-COL_POS = L_COUNT. AFIELD-FIELDNAME = 'QMDAT'. AFIELD-TABNAME = 'FINALTAB'. * AFIELD-REF_TABNAME = ''. AFIELD-KEY = 'X'. APPEND AFIELD TO XFIELD. AFIELD-TABNAME = 'IDATA'. APPEND AFIELD TO HFIELD. CLEAR AFIELD. L_COUNT = L_COUNT + 1. AFIELD-COL_POS = L_COUNT. AFIELD-FIELDNAME = 'AUSVN'. AFIELD-TABNAME = 'FINALTAB'. * AFIELD-REF_TABNAME = ''. AFIELD-KEY = 'X'. APPEND AFIELD TO XFIELD. AFIELD-TABNAME = 'IDATA'. APPEND AFIELD TO HFIELD. CLEAR AFIELD. L_COUNT = L_COUNT + 1. AFIELD-COL_POS = L_COUNT. AFIELD-FIELDNAME = 'AUZTV'. AFIELD-TABNAME = 'FINALTAB'. * AFIELD-REF_TABNAME = ''. AFIELD-KEY = 'X'. APPEND AFIELD TO XFIELD. AFIELD-TABNAME = 'IDATA'. APPEND AFIELD TO HFIELD.
"define field as key
"define field as key
"define field as key
"define field as key
ENDFORM.
FORM ZEVENTS. CLEAR XS_EVENT. XS_EVENT-NAME = slis_ev_item_data_expand. XS_EVENT-FORM = 'ITEM_DATA_EXPAND'. APPEND XS_EVENT TO GT_HEVENTS. endform.