*&---------------------------------------------------------------------*
*& Report ZFLIFMR
*&---------------------------------------------------------------------*
REPORT ZFLIFMR MESSAGE-ID ZMC_FLIFM
LINE-SIZE 120.

*----------------------------------------------------------------------*
* CLASS declaration.
*----------------------------------------------------------------------*
INCLUDE ZFLIFM_IFMR_SCREEN_CLASS.
INCLUDE ZFLIFM_IFMR_MAIN_CLASS.

*----------------------------------------------------------------------*
* TABLES declaration.
*----------------------------------------------------------------------*
TABLES: ZFLIFMT_GL_TOT,
        ZFLIFMT_SETTING,
        FAGLFLEXT.

*----------------------------------------------------------------------*
* Data declaration.
*----------------------------------------------------------------------*
DATA GO_MAIN TYPE REF TO ZCL_FLIFM_MAIN.

DATA LX_EXCEPTION TYPE REF TO ZCX_FLIFM_EXCEPTION.

DATA LV_GJAHR TYPE GJAHR.

*----------------------------------------------------------------------*
* SELECTION SCREEN.
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK BL1 WITH FRAME TITLE TBLOCK1.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (31) GJA_I18N.
PARAMETERS: P_GJAHR LIKE ZFLIFMT_GL_TOT-GJAHR OBLIGATORY.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (31) MON_I18N.
PARAMETERS:     P_MONAT LIKE ZFLIFMT_GL_TOT-MONAT OBLIGATORY.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (28) BUK_I18N.
SELECT-OPTIONS: S_BUKRS FOR ZFLIFMT_GL_TOT-BUKRS NO INTERVALS.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (28) RFA_I18N.
SELECT-OPTIONS: S_RFAREA FOR FAGLFLEXT-RFAREA NO INTERVALS.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK BL1.

SELECTION-SCREEN BEGIN OF BLOCK BL2 WITH FRAME TITLE TBLOCK2.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (31) CJA_I18N.
PARAMETERS: P_CGJAHR LIKE ZFLIFMT_GL_TOT-GJAHR OBLIGATORY.
SELECTION-SCREEN END OF LINE.

PARAMETERS: P_CHK LIKE ZFLIFMT_GL_TOT-GJAHR NO-DISPLAY.

SELECTION-SCREEN END OF BLOCK BL2.

SELECTION-SCREEN BEGIN OF BLOCK BL3 WITH FRAME TITLE TBLOCK3.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (31) LEV_I18N.
PARAMETERS: P_LEVEL  LIKE SNODETEXT-TLEVEL OBLIGATORY DEFAULT '02'.
SELECTION-SCREEN END OF LINE.

PARAMETERS: P_ZERO LIKE RFPDO-BILANULL DEFAULT SPACE.

SELECTION-SCREEN END OF BLOCK BL3.

*---------------------------------------------------------------------*
* INITIALIZATION.
*---------------------------------------------------------------------*
INITIALIZATION.

  TBLOCK1 = ZCL_FLIFM_I18N=>GET_INSTANCE( )->BLOCK1.
  TBLOCK2 = ZCL_FLIFM_I18N=>GET_INSTANCE( )->BLOCK2.
  TBLOCK3 = ZCL_FLIFM_I18N=>GET_INSTANCE( )->BLOCK3.

  GJA_I18N = ZCL_FLIFM_I18N=>GET_INSTANCE( )->REPORTING_YEAR.
  MON_I18N = ZCL_FLIFM_I18N=>GET_INSTANCE( )->REPORTING_PERIOD.
  BUK_I18N = ZCL_FLIFM_I18N=>GET_INSTANCE( )->COMPANY_CODE.
  CJA_I18N = ZCL_FLIFM_I18N=>GET_INSTANCE( )->COMPARISON_YEAR.
  LEV_I18N = ZCL_FLIFM_I18N=>GET_INSTANCE( )->TREE_DISPLAY_LEVEL.
  RFA_I18N = ZCL_FLIFM_I18N=>GET_INSTANCE( )->FUNCTIONAL_AREA.

  ZCL_FLIFM_SELECTION=>INITIALIZE( IMPORTING
                                    EV_GJAHR     = P_GJAHR
                                    EV_MONAT     = P_MONAT
                                    EV_CMP_GJAHR = P_CGJAHR
                                    ER_RFAREA    = S_RFAREA[] ).

  P_CHK = P_GJAHR.

*----------------------------------------------------------------------*
* AT SELECTION-SCREEN ON.
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON P_MONAT.
  ZCL_FLIFM_SELECTION=>VALIDATE_INPUT( P_MONAT ).

*----------------------------------------------------------------------*
* AT SELECTION-SCREEN.
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
  IF P_GJAHR <> P_CHK.
    P_CGJAHR = P_GJAHR - 1.
    P_CHK = P_GJAHR.
  ENDIF.

*----------------------------------------------------------------------*
* START-OF-SELECTION
*----------------------------------------------------------------------*
START-OF-SELECTION.

  ZCL_FLIFM_SELECTION=>SET_DATA(
    IR_BUKRS     = S_BUKRS[]
    IR_RFAREA    = S_RFAREA[]
    IV_GJAHR     = P_GJAHR
    IV_MONAT     = P_MONAT
    IV_CMP_GJAHR = P_CGJAHR
    IV_LEVEL     = P_LEVEL
    IV_ZERO      = P_ZERO ).

  TRY.
      ZCL_FLIFM_FETCH=>GET_INSTANCE( )->SET_DATA_INIT( ).
      ZCL_FLIFM_FETCH=>GET_INSTANCE( )->FETCH_DATA( ).
    CATCH ZCX_FLIFM_EXCEPTION INTO LX_EXCEPTION.
      MESSAGE LX_EXCEPTION TYPE 'S' DISPLAY LIKE 'E'.
      RETURN.
  ENDTRY.

*----------------------------------------------------------------------*
* END-OF-SELECTION
*----------------------------------------------------------------------*
END-OF-SELECTION.
  TRY.
      CREATE OBJECT GO_MAIN
        EXPORTING
          IV_DYNNR = '0100'.
    CATCH ZCX_FLIFM_EXCEPTION INTO LX_EXCEPTION.
      MESSAGE LX_EXCEPTION TYPE 'S' DISPLAY LIKE 'E'.
      RETURN.
  ENDTRY.

*----------------------------------------------------------------------*
*  MODULE pbo OUTPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE PBO OUTPUT.
  GO_MAIN->PBO( ).
ENDMODULE.                 " PBO  OUTPUT

*----------------------------------------------------------------------*
*  MODULE pai INPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE PAI INPUT.
  GO_MAIN->PAI( SY-UCOMM ).
ENDMODULE.                 " PAI  INPUT
