REPORT zmmr_perf_eval_vend.
"Types Declaration
TYPES:BEGIN OFt_disp,
lifnrTYPElifnr,
name1TYPEname1_gp,
bedatTYPEbedat,
rfq TYPE I,
quot TYPE I,
po TYPE I,
cont TYPE I,
sch TYPE I,
END OFt_disp,
BEGIN OFt_temp,
lifnrTYPElifnr,
CNT TYPE I,
END OFt_temp,
BEGIN OFt_lfa1,
lifnrTYPElifnr,
name1TYPEname1_gp,
END OFt_lfa1.
"For ALV {
DATA:"it_layout TYPE lvc_s_layo,
gr_tableTYPE REF TOcl_salv_table,
gr_functionsTYPE REF TOcl_salv_functions,
gr_columnsTYPE REF TOcl_salv_columns_table,
gr_columnTYPE REF TOcl_salv_column_table,
gr_displayTYPE REF TOcl_salv_display_settings,
lr_grid TYPE REF TOcl_salv_form_layout_grid,
lr_gridxTYPE REF TOcl_salv_form_layout_grid,
lr_logo TYPE REF TOcl_salv_form_layout_logo,
lr_labelTYPE REF TOcl_salv_form_label,
lr_text TYPE REF TOcl_salv_form_text,
lr_footer TYPE REF TOcl_salv_form_layout_grid,
ls_colorTYPElvc_s_colo
.
" For ALV }
DATA:it_dispTYPE TABLE OFt_disp,
wa_dispLIKE LINE OFit_disp,
it_tempTYPE TABLE OFt_temp,
wa_tempLIKE LINE OFit_temp,
it_lfa1TYPE TABLE OFt_lfa1,
wa_lfa1LIKE LINE OFit_lfa1.
SELECTION-SCREEN BEGIN OF BLOCKb1WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: s_lifnrFORwa_disp-lifnr,
s_bedatFORwa_disp-bedat.
SELECTION-SCREEN END OF BLOCKb1.
*----------------------------------------------------------------------*
* CLASS lcl_Perf_Eval DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASSlcl_perf_evalDEFINITION.
PUBLIC SECTION.
METHODS: constructor,
fill_disp.
METHODSbuild_fc.
METHODSdisp_alv.
METHODSset_tol.
METHODSend_of_page.
ENDCLASS. "lcl_perf_eval DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_perf_eval IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASSlcl_perf_evalIMPLEMENTATION.
METHODconstructor.
TRY.
cl_salv_table=>factory(IMPORTINGr_salv_table=gr_tableCHANGINGt_table=it_disp)."Calling Factory Obj of Cl_ALV_TABLE
CATCHcx_salv_msg.
ENDTRY.
IFgr_tableIS INITIAL.
MESSAGE TEXT-002TYPE'I'DISPLAYLIKE'E'.
EXIT.
ENDIF.
ENDMETHOD. "constructor
METHODfill_disp.
"RFQ
SELECTa~lifnrCOUNT( DISTINCTa~ebeln)ASrfqFROMekkoASa
JOINekpoASbONa~ebeln=b~ebeln
INTOCORRESPONDINGFIELDS OF TABLEit_disp
WHEREa~lifnrINs_lifnrANDbedatINs_bedat
ANDb~loekzNE'X'
ANDa~bstyp='A'
GROUP BYa~lifnr.
"WRITE sy-dbcnt.
"Quot
SELECTlifnrCOUNT(DISTINCTebeln)AS CNT FROMekko
APPENDINGCORRESPONDINGFIELDS OF TABLEit_temp
WHERElifnrINs_lifnrANDbedatINs_bedat
ANDloekzEQspace
AND(bstyp='A'ANDstatu='A')
GROUP BYlifnr.
LOOP ATit_tempINTOwa_temp.
wa_disp-lifnr=wa_temp-lifnr.
wa_disp-quot=wa_temp-CNT.
MODIFYit_dispFROMwa_dispTRANSPORTINGlifnr quotWHERElifnr=wa_temp-lifnr.
CLEAR:wa_disp,wa_temp.
ENDLOOP.
" PO
REFRESHit_temp.
SELECTlifnrCOUNT(DISTINCTa~ebeln)AS CNT FROMekkoASaJOINekpoASbONa~ebeln=b~ebeln
APPENDINGCORRESPONDINGFIELDS OF TABLEit_temp
WHERElifnrINs_lifnrANDbedatINs_bedat
ANDb~loekzEQspace
ANDbsartNE'UB'
AND(a~bstyp='F')
GROUP BYlifnr.
LOOP ATit_tempINTOwa_temp.
wa_disp-lifnr=wa_temp-lifnr.
wa_disp-po=wa_temp-CNT.
MODIFYit_dispFROMwa_dispTRANSPORTINGlifnr poWHERElifnr=wa_temp-lifnr.
IFsy-subrcNE0.
APPENDwa_dispTOit_disp.
ENDIF.
CLEAR:wa_disp,wa_temp.
ENDLOOP.
"Cont. Created
REFRESHit_temp.
SELECTlifnrCOUNT(DISTINCTa~ebeln)AS CNT FROMekkoASaJOINekpoASbONa~ebeln=b~ebeln
APPENDINGCORRESPONDINGFIELDS OF TABLEit_temp
WHERElifnrINs_lifnrANDbedatINs_bedat
ANDb~loekzEQspace
AND(a~bstyp='K')
GROUP BYlifnr.
LOOP ATit_tempINTOwa_temp.
wa_disp-lifnr=wa_temp-lifnr.
wa_disp-cont=wa_temp-CNT.
MODIFYit_dispFROMwa_dispTRANSPORTINGlifnr contWHERElifnr=wa_temp-lifnr.
IFsy-subrcNE0.
APPENDwa_dispTOit_disp.
ENDIF.
CLEAR:wa_disp,wa_temp.
ENDLOOP.
"Sch Aggre
REFRESHit_temp.
SELECTlifnrCOUNT(DISTINCTa~ebeln)AS CNT FROMekkoASaJOINekpoASbONa~ebeln=b~ebeln
APPENDINGCORRESPONDINGFIELDS OF TABLEit_temp
WHERElifnrINs_lifnrANDbedatINs_bedat
ANDb~loekzEQspace
AND(a~bstyp='L')
GROUP BYlifnr.
LOOP ATit_tempINTOwa_temp.
wa_disp-lifnr=wa_temp-lifnr.
wa_disp-sch=wa_temp-CNT.
MODIFYit_dispFROMwa_dispTRANSPORTINGlifnr schWHERElifnr=wa_temp-lifnr.
IFsy-subrcNE0.
APPENDwa_dispTOit_disp.
ENDIF.
CLEAR:wa_disp,wa_temp.
ENDLOOP.
SELECTlifnr name1FROMlfa1
INTOCORRESPONDINGFIELDS OF TABLEit_lfa1
FOR ALLENTRIESINit_disp
WHERElifnr=it_disp-lifnr.
LOOP ATit_dispINTOwa_disp.
READ TABLEit_lfa1INTOwa_lfa1WITH KEYlifnr=wa_disp-lifnr.
IFsy-subrcEQ0.
wa_disp-name1=wa_lfa1-name1.
MODIFYit_dispFROMwa_dispTRANSPORTINGlifnr name1WHERElifnr=wa_disp-lifnr.
ENDIF.
ENDLOOP.
SORTit_dispBYlifnr.
ENDMETHOD. "fill_disp
METHODbuild_fc.
INCLUDE<color>.
TRY.
gr_columns=gr_table->get_columns( ).
gr_columns->set_optimize(abap_true).
gr_column ?= gr_columns->get_column('LIFNR').
ls_color-col=3.
gr_column->set_color(ls_color).
CATCHcx_salv_not_found.
ENDTRY.
TRY.
gr_column ?= gr_columns->get_column('NAME1').
gr_column->set_long_text('Vendor Name').
gr_column->set_short_text('V.Name').
gr_column->set_medium_text('Vendor Name').
ls_color-col=3.
gr_column->set_color(ls_color).
CATCHcx_salv_not_found.
ENDTRY.
TRY.
gr_column ?= gr_columns->get_column('BEDAT').
gr_column->set_visible(abap_false).
gr_column->set_technical(VALUE=if_salv_c_bool_sap=>true).
CATCHcx_salv_not_found.
ENDTRY.
TRY.
gr_column ?= gr_columns->get_column('RFQ').
gr_column->set_short_text('RFQ').
gr_column->set_medium_text('RFQ Created').
CATCHcx_salv_not_found.
ENDTRY.
TRY.
gr_column ?= gr_columns->get_column('QUOT').
gr_column->set_short_text('Quot.').
gr_column->set_medium_text('Quotation Maintained').
CATCHcx_salv_not_found.
ENDTRY.
TRY.
gr_column ?= gr_columns->get_column('PO').
gr_column->set_short_text('PO Created').
CATCHcx_salv_not_found.
ENDTRY.
TRY.
gr_column ?= gr_columns->get_column('CONT').
gr_column->set_short_text('Cont.').
gr_column->set_medium_text('Contract Created').
CATCHcx_salv_not_found.
ENDTRY.
TRY.
gr_column ?= gr_columns->get_column('SCH').
gr_column->set_short_text('Sch. Crea.').
gr_column->set_medium_text('Sch. Agr. Created').
gr_column->set_long_text('Schedule Agreement Created').
CATCHcx_salv_not_found.
ENDTRY.
ENDMETHOD. "build_fc
METHODdisp_alv.
set_tol( ).
build_fc( ).
end_of_page( ).
gr_functions=gr_table->get_functions( ).
gr_functions->set_all(abap_true).
gr_table->set_top_of_list(lr_logo).
gr_table->set_end_of_list(lr_footer).
gr_display=gr_table->get_display_settings( ).
gr_display->set_striped_pattern(cl_salv_display_settings=>true).
gr_table->display( ).
ENDMETHOD. "disp_alv
METHODset_tol.
DATA:lv_text(30)TYPE C,
lv_dateTYPE CLENGTH10.
CREATEOBJECT lr_grid.
lr_grid->create_header_information(row=1 column=1
TEXT='MM: Vendor Evaluation'
tooltip='MM: Vendor Evaluation').
lr_gridx=lr_grid->create_grid(row=2 column=1 ).
lr_label=lr_gridx->create_label(row=2column=1
TEXT='Vendor No # :'tooltip='Vendor #.').
IFs_lifnrIS NOT INITIAL.
lv_text=s_lifnr-low.
IFs_lifnr-highIS NOT INITIAL.
CONCATENATElv_text' to 's_lifnr-highINTOlv_textSEPARATED BYspace.
ENDIF.
ELSE.
lv_text='Not Provided'.
ENDIF.
lr_text =lr_gridx->create_text( row=2column=2
TEXT=lv_text tooltip=lv_text).
"Vendor
lr_label=lr_gridx->create_label(row=3column=1
TEXT='Posting Date:'tooltip='Posting Date').
IFs_bedatIS NOT INITIAL.
WRITEs_bedat-low DD/MM/YYYYTOlv_text .
IFs_bedat-highIS NOT INITIAL.
WRITEs_bedat-high DD/MM/YYYYTOlv_date.
CONCATENATElv_text' to 'lv_dateINTOlv_textSEPARATED BYspace.
ENDIF.
ELSE.
lv_text='Not Provided'.
ENDIF.
lr_text =lr_gridx->create_text( row=3column=2
TEXT=lv_text tooltip=lv_text).
lr_label=lr_gridx->create_label(row=4column=1
TEXT='Run Date:'tooltip='Run Date').
lr_text =lr_gridx->create_text( row=4column=2
TEXT=sy-datum tooltip=sy-datum).
lr_label=lr_gridx->create_label(row=5column=1).
lr_label=lr_gridx->create_label(row=6column=1).
lr_label=lr_gridx->create_label(row=7column=1).
lr_label=lr_gridx->create_label(row=8column=1).
* Create logo layout, set grid content on left and logo image on right
CREATEOBJECT lr_logo.
lr_logo->set_left_content(lr_grid).
lr_logo->set_right_logo('ZCHEM_N_LOGO_SMALL')." Image From OAER T.code
ENDMETHOD. "set_Tol
METHODend_of_page.
DATA:lf_linesTYPEsy-tfill.
DATA:"lr_label TYPE REF TO cl_salv_form_label,
lf_flow TYPE REF TOcl_salv_form_layout_flow.
CREATEOBJECT lr_footer.
*--get total lines in internal table
lf_lines=LINES(it_disp).
lr_label=lr_footer->create_label(row=1column=1).
lr_label->set_text('Information:').
lf_flow=lr_footer->create_flow(row=2 column=1).
lf_flow->create_text(TEXT='Total Number of Entries').
lf_flow=lr_footer->create_flow(row=2 column=2).
lf_flow->create_text(TEXT=lf_lines).
ENDMETHOD. "end_of_page
ENDCLASS. "lcl_perf_eval IMPLEMENTATION
START-OF-SELECTION.
DATA:obj_repTYPE REF TOlcl_perf_eval." Declaring Object for Class
CREATEOBJECT:obj_rep." Creating Object
obj_rep->fill_disp( )." Calling class Methods
obj_rep->disp_alv( ).
↧
Simple OO ALV report in full screen mode example
↧