Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *&---------------------------------------------------------------------*
- *& Generates the ALV on the Selection Screen itself
- *&
- *&---------------------------------------------------------------------*
- REPORT Z_YY_DISPOSAL_REQ_INQ.
- 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.
- DATA: gwa_req TYPE ty_req,
- gt_req TYPE TABLE OF ty_req,
- 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.
- *
- *----------------------------------------------------------------------*
- * Local class for report
- *----------------------------------------------------------------------*
- CLASS lcl_report DEFINITION.
- *
- PUBLIC SECTION.
- *
- DATA: t_data TYPE STANDARD TABLE OF ZFI_DISPOSAL_REQ, " Output dat
- r_carrid TYPE RANGE OF sflight-carrid. " Select Option
- *
- METHODS:
- get_data,
- *
- generate_output.
- *
- ENDCLASS. "lcl_report DEFINITION
- *
- DATA: lo_report TYPE REF TO lcl_report.
- *
- DATA: w_carrid TYPE sflight-carrid.
- *
- ** Selection Screen
- SELECTION-SCREEN BEGIN OF BLOCK SELECTION WITH FRAME TITLE text-001.
- 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.
- 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.
- 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.
- SELECTION-SCREEN COMMENT (20) text-005 FOR FIELD SRV_TYPE .
- PARAMETERS : SRV_TYPE LIKE ZFI_DISPOSAL_REQ-ZZSERVICE_TYPE.
- SELECTION-SCREEN POSITION 70.
- SELECTION-SCREEN END OF LINE.
- 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.
- SELECTION-SCREEN COMMENT (20) text-007 FOR FIELD REQ_STS .
- PARAMETERS : REQ_STS LIKE ZFI_DISPOSAL_REQ-ZZRQSTTS.
- SELECTION-SCREEN PUSHBUTTON (10) BUT1 USER-COMMAND SEARCH.
- SELECTION-SCREEN PUSHBUTTON (10) BUT2 USER-COMMAND RESET.
- SELECTION-SCREEN END OF LINE.
- SELECTION-SCREEN END OF BLOCK SELECTION.
- *
- WRITE : / 'ERROR2'.
- AT SELECTION-SCREEN ON VALUE-REQUEST FOR COST_CNT.
- WRITE : / 'WELCOME1'.
- REFRESH gt_dynpfields.
- 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 SY-SUBRC = 0.
- gv_company_code = gwa_dynpfields-fieldvalue.
- * MESSAGE ID 'ZALV_ERRORS' TYPE 'I' NUMBER '000' WITH gv_company_code.
- ELSE.
- WRITE : / 'ERROR1'.
- ENDIF.
- SELECT ZZCOMPANY_CODE ZZCOST_CENTER
- INTO TABLE gt_req
- FROM ZFI_DISPOSAL_REQ
- WHERE ZZCOMPANY_CODE = gv_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 SY-SUBRC = 0.
- COST_CNT = gwa_return-fieldval.
- ELSE.
- WRITE : / 'ERROR2'.
- ENDIF.
- ** Initialization
- INITIALIZATION.
- BUT1 = 'Search'.
- BUT2 = 'Reset'.
- * object for the report
- CREATE OBJECT lo_report.
- * generate output
- lo_report->generate_output( ).
- *
- ** Start of Selection
- START-OF-SELECTION.
- * Get data
- * lo_report->r_carrid = s_carrid[].
- lo_report->get_data( ).
- *
- *----------------------------------------------------------------------*
- * Local Class Implementation
- *----------------------------------------------------------------------*
- CLASS lcl_report IMPLEMENTATION.
- *
- METHOD get_data.
- *
- * data selection
- SELECT * FROM ZFI_DISPOSAL_REQ
- INTO TABLE me->t_data.
- 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
- 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.
- *
- * 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 = me->t_data.
- 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. "lcl_report IMPLEMENTATION
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement