Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *&---------------------------------------------------------------------*
- *& Report Z_YY_DISPOSAL_REQ_INQ
- *&
- *&---------------------------------------------------------------------*
- *&
- *&
- *&---------------------------------------------------------------------*
- *----------------------------------------------------------------------*
- * Author : <Yara Mohamed/Developer user ID>
- * Creation Date : <09-03-2017>
- * Transaction : <Transaction code if attached>
- * Technical design: <Assets Disposal Request Inquiry Screen>
- * Description : < Show Disposal Request Information>
- *----------------------------------------------------------------------*
- REPORT Z_YY_DISPOSAL_REQ_INQ.
- ******************************************************************************************************
- *Internal table which will be used in filling the alv by returning the data from the fm inquiry.
- TYPES : BEGIN OF IT_req,
- zzsr_number TYPE ZFI_DISPOSAL_REQ-ZZSR_NUMBER,
- zzcompany_code TYPE ZFI_DISPOSAL_REQ-ZZCOMPANY_CODE,
- zzcost_center TYPE ZFI_DISPOSAL_REQ-ZZCOST_CENTER,
- zzdate TYPE ZFI_DISPOSAL_REQ-ZZDATE,
- s_zzdesc TYPE ZFI_LOOKUP-ZZDESC,
- rs_zzdesc TYPE ZFI_LOOKUP-ZZDESC,
- crea_user TYPE ZFI_DISPOSAL_REQ-CREA_USER,
- crea_time TYPE ZFI_DISPOSAL_REQ-CREA_TIME,
- chng_user TYPE ZFI_DISPOSAL_REQ-CHNG_USER,
- chng_time TYPE ZFI_DISPOSAL_REQ-CHNG_TIME,
- END OF IT_req.
- *Internal Table & work area for it.
- DATA : it_reqs TYPE TABLE OF it_req,
- wa_reqs TYPE it_req.
- DATA columns TYPE REF TO cl_salv_columns_table.
- DATA column TYPE REF TO cl_salv_column.
- ********************************************************************************************************************************************************
- *Internal tables we will need for the search help filtering
- *Cost Center
- TYPES: BEGIN OF ty_req,
- company_code TYPE ZFI_DISPOSAL_REQ-ZZCOMPANY_CODE,
- cost_center TYPE ZFI_DISPOSAL_REQ-ZZCOST_CENTER,
- END OF ty_req.
- * Request Status & Service
- TYPES: BEGIN OF ty_lookup,
- code TYPE ZFI_LOOKUP-ZZCODE,
- END OF ty_lookup.
- DATA: gwa_req TYPE ty_req,
- gt_req TYPE TABLE OF ty_req,
- gwa_lookup TYPE ty_lookup,
- gt_lookup TYPE TABLE OF ty_lookup,
- gt_return TYPE TABLE OF ddshretval,
- gwa_return TYPE ddshretval,
- gwa_dynpfields TYPE dynpread,
- gt_dynpfields TYPE TABLE OF dynpread,
- gv_company_code TYPE ZFI_DISPOSAL_REQ-ZZCOMPANY_CODE,
- gv_type TYPE ZFI_LOOKUP-ZZTYPE.
- *Working area for the three tables we will need to work on .
- DATA: wa_req TYPE ZFI_DISPOSAL_REQ,
- wa_service TYPE ZFI_LOOKUP,
- wa_req_status TYPE ZFI_LOOKUP.
- ********************************************************************************************************************************************************
- * local data for the docking , gui_container , and the cl_salv
- * DATA: lo_dock TYPE REF TO cl_gui_docking_container,
- * lo_cont TYPE REF TO cl_gui_container,
- * lo_alv TYPE REF TO cl_salv_table.
- *
- *----------------------------------------------------------------------*
- * Local class for report
- *----------------------------------------------------------------------*
- CLASS lcl_report DEFINITION.
- *
- PUBLIC SECTION.
- DATA: t_data TYPE STANDARD TABLE OF it_req. " Output data
- *
- METHODS:
- get_data,
- *
- generate_output.
- *
- ENDCLASS. "lcl_report DEFINITION
- *
- DATA: lo_report TYPE REF TO lcl_report.
- *
- *********************************************************************************************************************************************************
- ** Selection Screen
- SELECTION-SCREEN BEGIN OF BLOCK SELECTION WITH FRAME TITLE text-001.
- *Company Code Default(1200)
- SELECTION-SCREEN BEGIN OF LINE.
- SELECTION-SCREEN COMMENT (20) text-002 FOR FIELD COM_CODE .
- PARAMETERS : COM_CODE LIKE ZFI_DISPOSAL_REQ-ZZCOMPANY_CODE DEFAULT '1200'.
- SELECTION-SCREEN POSITION 35.
- *Cost Center - Search Help depending on the value for the company code
- SELECTION-SCREEN COMMENT (20) text-003 FOR FIELD COST_CNT .
- PARAMETERS : COST_CNT LIKE ZFI_DISPOSAL_REQ-ZZCOST_CENTER.
- SELECTION-SCREEN POSITION 70.
- SELECTION-SCREEN END OF LINE.
- *Serial Number
- SELECTION-SCREEN BEGIN OF LINE.
- SELECTION-SCREEN COMMENT (20) text-004 FOR FIELD SER_NO .
- PARAMETERS : SER_NO LIKE ZFI_DISPOSAL_REQ-ZZSR_NUMBER.
- *SELECTION-SCREEN POSITION 10.
- *Service Type - Search Help
- SELECTION-SCREEN COMMENT (20) text-005 FOR FIELD SRV_TYPE .
- PARAMETERS : SRV_TYPE LIKE ZFI_LOOKUP-ZZCODE .
- SELECTION-SCREEN POSITION 70.
- SELECTION-SCREEN END OF LINE.
- *Date
- SELECTION-SCREEN BEGIN OF LINE.
- SELECTION-SCREEN COMMENT (20) text-006 FOR FIELD DATE .
- PARAMETERS : DATE LIKE ZFI_DISPOSAL_REQ-ZZDATE.
- *SELECTION-SCREEN POSITION 35.
- *Request Status - Search Help
- SELECTION-SCREEN COMMENT (20) text-007 FOR FIELD REQ_STS .
- PARAMETERS : REQ_STS LIKE ZFI_LOOKUP-ZZCODE.
- *Search Button
- SELECTION-SCREEN PUSHBUTTON (10) BUT1 USER-COMMAND SEARCH.
- *Reset Button
- SELECTION-SCREEN PUSHBUTTON (10) BUT2 USER-COMMAND RESET.
- SELECTION-SCREEN END OF LINE.
- SELECTION-SCREEN END OF BLOCK SELECTION.
- *
- *********************************************************************************************************************************************************
- *On Value Request for cost center - filter it depending on company code
- AT SELECTION-SCREEN ON VALUE-REQUEST FOR COST_CNT.
- REFRESH gt_dynpfields.
- *Field i will filter upon
- gwa_dynpfields-fieldname = 'COM_CODE'.
- APPEND gwa_dynpfields TO gt_dynpfields.
- CALL FUNCTION 'DYNP_VALUES_READ'
- EXPORTING
- DYNAME = sy-repid
- DYNUMB = sy-dynnr
- TABLES
- DYNPFIELDS = gt_dynpfields
- EXCEPTIONS
- INVALID_ABAPWORKAREA = 1
- INVALID_DYNPROFIELD = 2
- INVALID_DYNPRONAME = 3
- INVALID_DYNPRONUMMER = 4
- INVALID_REQUEST = 5
- NO_FIELDDESCRIPTION = 6
- INVALID_PARAMETER = 7
- UNDEFIND_ERROR = 8
- DOUBLE_CONVERSION = 9
- STEPL_NOT_FOUND = 10
- OTHERS = 11
- .
- READ TABLE gt_dynpfields INTO gwa_dynpfields
- WITH KEY fieldname = 'COM_CODE'.
- *If there are no errors , assign the company code the value returned.
- IF SY-SUBRC = 0.
- gv_company_code = gwa_dynpfields-fieldvalue.
- ENDIF.
- *Select statement to get the cost center depending on the dynamic value for the company code & assign it to the table we created.
- SELECT ZZCOMPANY_CODE ZZCOST_CENTER
- INTO TABLE gt_req
- FROM ZFI_DISPOSAL_REQ
- WHERE ZZCOMPANY_CODE = gv_company_code.
- *Get cost center search help values depending on the company code.
- CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
- EXPORTING
- RETFIELD = 'COST_CENTER'
- VALUE_ORG = 'S'
- TABLES
- VALUE_TAB = gt_req
- RETURN_TAB = gt_return
- EXCEPTIONS
- PARAMETER_ERROR = 1
- NO_VALUES_FOUND = 2
- OTHERS = 3
- .
- READ TABLE gt_return INTO gwa_return INDEX 1.
- *If there are no errors , assign the returned table to the cost_cnt selection paramter.
- IF SY-SUBRC = 0.
- COST_CNT = gwa_return-fieldval.
- ENDIF.
- *********************************************************************************************************************************************************
- *On Value Request for Request Status
- AT SELECTION-SCREEN ON VALUE-REQUEST FOR REQ_STS.
- REFRESH gt_dynpfields.
- SELECT ZZCODE
- INTO TABLE gt_lookup
- FROM ZFI_LOOKUP
- WHERE ZZTYPE = '1'.
- CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
- EXPORTING
- RETFIELD = 'TYPE'
- VALUE_ORG = 'S'
- TABLES
- VALUE_TAB = gt_lookup
- RETURN_TAB = gt_return
- EXCEPTIONS
- PARAMETER_ERROR = 1
- NO_VALUES_FOUND = 2
- OTHERS = 3
- .
- READ TABLE gt_return INTO gwa_return INDEX 1.
- IF SY-SUBRC = 0.
- REQ_STS = gwa_return-fieldval.
- ENDIF.
- *********************************************************************************************************************************************************
- *On Value Request for Service Type
- AT SELECTION-SCREEN ON VALUE-REQUEST FOR SRV_TYPE.
- REFRESH gt_dynpfields.
- SELECT ZZCODE
- INTO TABLE gt_lookup
- FROM ZFI_LOOKUP
- WHERE ZZTYPE = '2'.
- CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
- EXPORTING
- RETFIELD = 'TYPE'
- VALUE_ORG = 'S'
- TABLES
- VALUE_TAB = gt_lookup
- RETURN_TAB = gt_return
- EXCEPTIONS
- PARAMETER_ERROR = 1
- NO_VALUES_FOUND = 2
- OTHERS = 3
- .
- READ TABLE gt_return INTO gwa_return INDEX 1.
- IF SY-SUBRC = 0.
- SRV_TYPE = gwa_return-fieldval.
- ENDIF.
- *********************************************************************************************************************************************************
- ** Initialization
- INITIALIZATION.
- *Buttons Text
- BUT1 = 'Search'.
- BUT2 = 'Reset'.
- AT SELECTION-SCREEN.
- *Handle on Button Click
- CASE sy-ucomm.
- when 'SEARCH'.
- * CLEAR lo_alv.
- PERFORM SEARCH.
- *Create object of class lc_report.
- CREATE OBJECT lo_report.
- *Generate output & get data
- lo_report->generate_output( ).
- lo_report->get_data( ).
- WHEN 'RESET'.
- PERFORM RESET.
- ENDCASE.
- *
- *----------------------------------------------------------------------*
- * Local Class Implementation
- *----------------------------------------------------------------------*
- CLASS lcl_report IMPLEMENTATION.
- *
- METHOD get_data.
- *
- * data selection
- me->t_data = it_reqs.
- IF sy-dbcnt IS INITIAL.
- MESSAGE s398(00) WITH 'No data selected'.
- ENDIF.
- *
- * export to memory
- EXPORT data = me->t_data TO MEMORY ID sy-cprog.
- *
- ENDMETHOD. "get_data
- *
- METHOD generate_output.
- *
- * local data for the docking , gui_container , and the cl_salv
- DATA: lo_dock TYPE REF TO cl_gui_docking_container,
- lo_cont TYPE REF TO cl_gui_container,
- lo_alv TYPE REF TO cl_salv_table.
- * lo_dock->free( ).
- * lo_cont->free( ).
- * import output table from the memory and free afterwards
- IMPORT data = me->t_data FROM MEMORY ID sy-cprog.
- FREE MEMORY ID sy-cprog.
- *
- * Only if there is some data
- CHECK me->t_data IS NOT INITIAL.
- *
- * Create a docking control at bottom
- CHECK lo_dock IS INITIAL.
- CREATE OBJECT lo_dock
- EXPORTING
- repid = sy-cprog
- dynnr = sy-dynnr
- ratio = 80
- side = cl_gui_docking_container=>dock_at_bottom
- name = 'DOCK_CONT'.
- IF sy-subrc <> 0.
- MESSAGE 'Error in the Docking control' TYPE 'S'.
- ENDIF.
- *
- * Create a SALV for output
- CHECK lo_alv IS INITIAL.
- TRY.
- * Narrow Casting: To initialize custom container from
- * docking container
- lo_cont ?= lo_dock.
- *
- * SALV Table Display on the Docking container
- CALL METHOD cl_salv_table=>factory(
- EXPORTING
- list_display = if_salv_c_bool_sap=>false
- r_container = lo_cont
- * container_name = 'DOCK_CONT'
- IMPORTING
- r_salv_table = lo_alv
- CHANGING
- t_table = it_reqs[] ).
- *Get columns of the ALV to be able to edit them
- columns = lo_alv->get_columns( ).
- *Call the forms that will edit each column.
- PERFORM set_service_type_column.
- PERFORM set_request_status_column.
- PERFORM set_create_user_column.
- PERFORM set_create_time_column.
- PERFORM set_change_user_column.
- PERFORM set_change_time_column.
- *Catch errors if there are
- CATCH cx_salv_msg .
- ENDTRY.
- *
- * Pf status
- DATA: lo_functions TYPE REF TO cl_salv_functions_list.
- lo_functions = lo_alv->get_functions( ).
- lo_functions->set_default( abap_true ).
- *
- * output display
- lo_alv->display( ).
- *
- ENDMETHOD. "generate_output
- *
- ENDCLASS.
- *********************************************************************************************************************************************************
- *Search Function to get data required from the database.
- FORM SEARCH.
- *Internal Table Fields that will be passed to FM
- wa_req-ZZCOMPANY_CODE = COM_CODE.
- wa_req-ZZCOST_CENTER = COST_CNT.
- wa_req-ZZSR_NUMBER = SER_NO.
- wa_req-ZZDATE = DATE.
- wa_req_status-ZZCODE = REQ_STS.
- wa_service-ZZCODE = SRV_TYPE.
- * MESSAGE ID 'ZALV_ERRORS' TYPE 'I' NUMBER '000' WITH wa_req_status-ZZCODE.
- * MESSAGE ID 'ZALV_ERRORS' TYPE 'I' NUMBER '000' WITH wa_service-ZZCODE.
- CALL FUNCTION 'Z_REQ_FN_INQUIRY'
- EXPORTING
- WA_REQ = WA_REQ
- WA_REQ_STATUS = WA_REQ_STATUS
- WA_SERVICE = WA_SERVICE
- TABLES
- QT_REQ = it_reqs
- .
- ENDFORM.
- *********************************************************************************************************************************************************
- *Reset Function - Clear all input fields.
- FORM RESET.
- *Clear all input fields.
- * lo_alv->free( ).
- CLEAR COST_CNT.
- CLEAR SER_NO.
- CLEAR DATE.
- CLEAR REQ_STS.
- CLEAR SRV_TYPE.
- ENDFORM.
- *********************************************************************************************************************************************************
- *Change service type column name
- FORM set_service_type_column.
- DATA not_found TYPE REF TO cx_salv_not_found.
- TRY.
- column = columns->get_column( columnname = 'S_ZZDESC' ).
- * column->set_short_text( 'S. Type' ).
- * column->set_medium_text( 'Ser. Type' ).
- column->set_long_text( 'Service Type' ).
- column->set_optimized( ).
- CATCH cx_salv_not_found INTO not_found.
- " error handling
- ENDTRY.
- ENDFORM.
- *********************************************************************************************************************************************************
- *Change request status column name
- FORM set_request_status_column.
- DATA not_found TYPE REF TO cx_salv_not_found.
- TRY.
- column = columns->get_column( columnname = 'RS_ZZDESC' ).
- column->set_short_text( 'R. Status' ).
- column->set_medium_text( 'Req. Status' ).
- column->set_long_text( 'Request Status' ).
- column->set_optimized( ).
- CATCH cx_salv_not_found INTO not_found.
- " error handling
- ENDTRY.
- ENDFORM.
- *********************************************************************************************************************************************************
- *Change create user column name.
- FORM set_create_user_column.
- DATA not_found TYPE REF TO cx_salv_not_found.
- TRY.
- column = columns->get_column( columnname = 'CREA_USER' ).
- column->set_short_text( 'C. User' ).
- column->set_medium_text( 'CREA. User' ).
- column->set_long_text( 'Create User' ).
- CATCH cx_salv_not_found INTO not_found.
- " error handling
- ENDTRY.
- ENDFORM.
- *********************************************************************************************************************************************************
- *Change create time column name.
- FORM set_create_time_column.
- DATA not_found TYPE REF TO cx_salv_not_found.
- TRY.
- column = columns->get_column( columnname = 'CREA_TIME' ).
- column->set_short_text( 'C. Time' ).
- column->set_medium_text( 'CREA. Time' ).
- column->set_long_text( 'Create Time' ).
- CATCH cx_salv_not_found INTO not_found.
- " error handling
- ENDTRY.
- ENDFORM.
- *********************************************************************************************************************************************************
- *Change Change User column name.
- FORM set_change_user_column.
- DATA not_found TYPE REF TO cx_salv_not_found.
- TRY.
- column = columns->get_column( columnname = 'CHNG_USER' ).
- column->set_short_text( 'C. User' ).
- column->set_medium_text( 'Chan. User' ).
- column->set_long_text( 'Change User' ).
- CATCH cx_salv_not_found INTO not_found.
- " error handling
- ENDTRY.
- ENDFORM.
- *********************************************************************************************************************************************************
- *Change Change time column name.
- FORM set_change_time_column.
- DATA not_found TYPE REF TO cx_salv_not_found.
- TRY.
- column = columns->get_column( columnname = 'CHNG_TIME' ).
- column->set_short_text( 'C. Time' ).
- column->set_medium_text( 'Chan. Time' ).
- column->set_long_text( 'Change Time' ).
- CATCH cx_salv_not_found INTO not_found.
- " error handling
- ENDTRY.
- ENDFORM.
- *********************************************************************************************************************************************************
- FORM optimize_column_width.
- columns->set_optimize( ).
- ENDFORM.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement