Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *&---------------------------------------------------------------------*
- *& Report Z_YYY_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_YYY_DISPOSAL_REQ_INQ.
- TABLES : ZFI_DISPOSAL_REQ , ZFI_LOOKUP.
- *---------------------------------------------------------------------*
- * W O R K A R E A S *
- *---------------------------------------------------------------------*
- *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 STANDARD TABLE OF it_req,
- wa_reqs TYPE it_req,
- WA_FIELDCAT TYPE LVC_S_FCAT,
- T_FIELDCAT TYPE LVC_T_FCAT.
- ********************************************************************************************************************************************************
- *Internal tables we will need for the search help filtering
- *Cost Center
- TYPES: BEGIN OF ty_req,
- 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_alv TYPE REF TO cl_gui_alv_grid.
- ********************************************************
- 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.
- PARAMETERS : SRV_DESC LIKE ZFI_LOOKUP-ZZDESC.
- 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.
- SELECTION-SCREEN END OF LINE.
- SELECTION-SCREEN BEGIN OF LINE.
- PARAMETERS : REQ_DESC LIKE ZFI_LOOKUP-ZZDESC.
- *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 DISTINCT 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.
- SELECT ZZDESC
- INTO REQ_DESC
- FROM ZFI_LOOKUP
- WHERE ZZCODE = REQ_STS.
- ENDSELECT.
- *********************************************************************************************************************************************************
- *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.
- SELECT ZZDESC
- INTO SRV_DESC
- FROM ZFI_LOOKUP
- WHERE ZZCODE = SRV_TYPE.
- ENDSELECT.
- *********************************************************************************************************************************************************
- ** Initialization
- INITIALIZATION.
- *Buttons Text
- BUT1 = 'Search'.
- BUT2 = 'Reset'.
- AT SELECTION-SCREEN OUTPUT.
- LOOP AT SCREEN.
- IF screen-NAME = 'COM_CODE'.
- SCREEN-REQUIRED = 1.
- SCREEN-INPUT = 0.
- MODIFY SCREEN.
- ENDIF.
- IF SCREEN-NAME = 'SRV_DESC'.
- SCREEN-REQUIRED = 1.
- SCREEN-INPUT = 0.
- MODIFY SCREEN.
- ENDIF.
- IF SCREEN-NAME = 'REQ_DESC'.
- SCREEN-REQUIRED = 1.
- SCREEN-INPUT = 0.
- MODIFY SCREEN.
- ENDIF.
- ENDLOOP.
- PERFORM DISPLAY_OUTPUT.
- PERFORM CREATE_OBJECTS.
- AT SELECTION-SCREEN.
- *Handle on Button Click
- CASE sy-ucomm.
- when 'SEARCH'.
- PERFORM SEARCH.
- WHEN 'RESET'.
- PERFORM RESET.
- ENDCASE.
- *******************************************************************************
- *Create Fieldcat
- FORM DISPLAY_OUTPUT.
- PERFORM FILL_FIELDCAT USING :
- 'ZZSR_NUMBER' 'IT_REQS' 'Serial Number' '',
- 'ZZCOMPANY_CODE' 'IT_REQS' 'Company Code' '',
- 'ZZCOST_CENTER' 'IT_REQS' 'Cost Center' '',
- 'ZZDATE' 'IT_REQS' 'Date' '',
- 'S_ZZDESC' 'IT_REQS' 'Service Type' '',
- 'RS_ZZDESC' 'IT_REQS' 'Request Status' '',
- 'CREA_USER' 'IT_REQS' 'Create User' '',
- 'CREA_TIME' 'IT_REQS' 'Create Time' '',
- 'CHNG_USER' 'IT_REQS' 'Change User' '',
- 'CHNG_TIME' 'IT_REQS' 'Change Time' ''.
- ENDFORM.
- *Fill them using parameters send to the function
- FORM FILL_FIELDCAT USING pv_field TYPE any
- pv_tabname TYPE any
- pv_coltext TYPE any
- pv_outputlen TYPE any.
- wa_fieldcat-fieldname = pv_field.
- wa_fieldcat-tabname = pv_tabname.
- wa_fieldcat-coltext = pv_coltext.
- APPEND wa_fieldcat TO t_fieldcat.
- CLEAR wa_fieldcat.
- ENDFORM.
- *Create all objects required (Docker,ALV,Grid)
- FORM create_objects.
- CHECK lo_dock is INITIAL.
- CREATE OBJECT lo_dock
- EXPORTING
- side = cl_gui_docking_container=>dock_at_bottom
- extension = 230
- caption = 'Assets Request Inquiry'
- 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. " IF sy-subrc <> 0.
- * To Create the Grid Instance
- CREATE OBJECT lo_alv
- EXPORTING
- i_parent = lo_dock
- 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. " IF sy-subrc <> 0.
- * Formatted Output Table is Sent to Control
- MESSAGE ID 'ZALV_ERRORS' TYPE 'I' NUMBER '000' WITH wa_req_status-ZZCODE.
- CALL METHOD lo_alv->set_table_for_first_display
- CHANGING
- it_outtab = it_reqs
- it_fieldcatalog = t_fieldcat
- * it_sort =
- * it_filter =
- EXCEPTIONS
- invalid_parameter_combination = 1
- program_error = 2
- too_many_lines = 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. " IF sy-subrc <> 0.
- ENDFORM.
- 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.
- 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
- .
- CALL METHOD lo_alv->refresh_table_display.
- ENDFORM.
- *Clear All fields.
- FORM RESET.
- CLEAR : COST_CNT,
- SER_NO,
- DATE,
- REQ_STS,
- SRV_TYPE,
- it_reqs.
- CALL METHOD lo_alv->refresh_table_display.
- ENDFORM.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement