*&---------------------------------------------------------------------*
*&Report ZISU_MET_RESULTS_TEST
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZVIJAY_MTR_READ_RESULT.
TYPE-POOLS: SLIS.
TABLES : EANL,ERCH.
***********SELECTION SCREEN************************
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : S_INST FOR EANL-ANLAGE, "Installation number
S_CONT FOR ERCH-VERTRAG, "Contarct
S_PORT FOR ERCH-PORTION, "Portion
S_PART FOR ERCH-GPARTNER. "Business Partner
SELECTION-SCREEN END OF BLOCK B1.
***********END OF SELECTION SCREEN*****************
TYPES : BEGIN OF TY_ERCH ,
BELNR TYPE ERCH-BELNR, " Billing doc no
GPARTNER TYPE ERCH-GPARTNER, " Businee partner
VERTRAG TYPE ERCH-VERTRAG, " Contract
PORTION TYPE ERCH-PORTION, "Portinon
ABLEINH TYPE ERCH-ABLEINH, " Meter reading Unit
END OF TY_ERCH.
TYPES : BEGIN OF TY_EABL,
ABLBELNR TYPE EABL-ABLBELNR, " Internal MR doc num
GERNR TYPE EABL-GERNR, " Device
EQUNR TYPE EABL-EQUNR, " Euipment
ZWNUMMER TYPE EABL-ZWNUMMER, "Register
ADAT TYPE EABL-ADAT, " MR date
ADATSOLL TYPE EABL-ADATSOLL, " Scheduled MRD
V_ZWSTAND TYPE EABL-V_ZWSTAND, " Pd MR Reading
N_ZWSTAND TYPE EABL-N_ZWSTAND, "Pd MR Reading
END OF TY_EABL.
TYPES : BEGIN OF TY_EABLG,
ABLBELNR TYPE EABLG-ABLBELNR, " Internal MR doc num
ANLAGE TYPE EABLG-ANLAGE, " Installation
ABLESGR TYPE EABLG-ABLESGR, " MR Reason
ABLEINH TYPE EABLG-ABLEINH, " MR Unit
END OF TY_EABLG.
TYPES : BEGIN OF TY_EVER,
VERTRAG TYPE EVER-VERTRAG, "Contract
ANLAGE TYPE EVER-ANLAGE, " Installation
END OF TY_EVER.
TYPES : BEGIN OF TY_FINAL,
PORTION TYPE ERCH-PORTION, "Portion
MRUNIT TYPE ERCH-ABLEINH, "MR Unit
BP TYPE GPARTNER, "Business Partner
CONTRACT TYPE VERTRAG, "Contract
INSTALLATION TYPE ANLAGE, "Installation
DEVICE TYPE GERAET, "Device
EQUIPMENT TYPE EQUNR, "Equipment
REGISTER TYPE E_ZWNUMMER, "Register
MR_DATE TYPE ADAT, "Meter Reading date
SCHEDULED_MRD TYPE ADATSOLL, "Scheduled MR Date
METER_REASON TYPE ABLESGR, "MR REason
METER_READING TYPE READINGRESULT, "Metre Reading
END OF TY_FINAL.
*****************Internal Table Decleration********************
DATA : IT_EVER TYPE TABLE OF TY_EVER.
DATA : IT_ERCH TYPE TABLE OF TY_ERCH, "Billing Doc. Data Internal Table
WA_ERCH TYPE TY_ERCH. "Billing Doc. Data Work area
DATA : IT_EABL TYPE TABLE OF TY_EABL, " MR Document Internal Table
WA_EABL TYPE TY_EABL. " MR Document Work area
DATA : IT_EABLG TYPE TABLE OF TY_EABLG, " MR Reasons in MR Document Internal Table
WA_EABLG TYPE TY_EABLG. " MR Reasons in MR Document Work area
DATA : IT_FINAL TYPE TABLE OF TY_FINAL, " Final Internal Table
WA_FINAL TYPE TY_FINAL. " Final Work area
DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FCAT TYPE SLIS_FIELDCAT_ALV.
****************End Of Decleration******************************
PERFORM GET_DATA.
PERFORM FCAT.
PERFORM DISPLAY.
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DATA .
IF S_INST IS NOT INITIAL .
SELECT VERTRAG
ANLAGE
FROM EVER
INTO TABLE IT_EVER
WHERE ANLAGE IN S_INST .
IF S_INST IS NOT INITIAL AND S_CONT IS NOT INITIAL.
CLEAR IT_EVER.
SELECT VERTRAG
ANLAGE
FROM EVER
INTO TABLE IT_EVER
WHERE ANLAGE IN S_INST AND VERTRAG IN S_CONT.
ENDIF.
IF IT_EVER IS NOT INITIAL .
SELECT ABLBELNR
ANLAGE " INSTALLATION
ABLESGR " MR REASON
ABLEINH
FROM EABLG
INTO TABLE IT_EABLG
FOR ALL ENTRIES IN IT_EVER
WHERE ANLAGE = IT_EVER-ANLAGE.
**** WHERE ANLAGE IN S_INST AND ABLESGR = '01'.
ENDIF.
IF IT_EABLG IS NOT INITIAL.
SELECT ABLBELNR
GERNR
EQUNR
ZWNUMMER
ADAT
ADATSOLL
V_ZWSTAND
N_ZWSTAND
FROM EABL
INTO TABLE IT_EABL
FOR ALL ENTRIES IN IT_EABLG
WHERE ABLBELNR = IT_EABLG-ABLBELNR.
ENDIF.
IF IT_EVER IS NOT INITIAL.
SELECT BELNR
GPARTNER
VERTRAG
PORTION
ABLEINH
FROM ERCH
INTO TABLE IT_ERCH FOR ALL ENTRIES IN IT_EVER
WHERE VERTRAG = IT_EVER-VERTRAG
AND SIMULATION = '' .
ENDIF.
ELSEIF S_CONT IS NOT INITIAL.
SELECT VERTRAG
ANLAGE
FROM EVER
INTO TABLE IT_EVER
WHERE VERTRAG IN S_CONT.
IF IT_EVER IS NOT INITIAL.
PERFORM MR_DATA.
ENDIF.
SELECT BELNR
GPARTNER
VERTRAG
PORTION
ABLEINH
FROM ERCH
INTO TABLE IT_ERCH FOR ALL ENTRIES IN IT_EVER
WHERE VERTRAG = IT_EVER-VERTRAG
AND SIMULATION = '' .
ENDIF.
*********** portion ***************************
IF S_PORT IS NOT INITIAL.
SELECT BELNR
GPARTNER
VERTRAG
PORTION
ABLEINH
FROM ERCH
INTO TABLE IT_ERCH "#EC CI_NOFIELD
WHERE PORTION IN S_PORT.
IF S_PORT IS NOT INITIAL AND S_PART IS NOT INITIAL .
CLEAR it_erch.
SELECT BELNR
GPARTNER
VERTRAG
PORTION
ABLEINH "#EC CI_NOFIELD
FROM ERCH
INTO TABLE IT_ERCH
WHERE PORTION IN S_PORT
AND GPARTNER IN S_PART.
ENDIF.
IF S_PORT IS NOT INITIAL AND S_INST IS NOT INITIAL.
SELECT BELNR
GPARTNER
VERTRAG
PORTION
ABLEINH
FROM ERCH
INTO TABLE IT_ERCH FOR ALL ENTRIES IN IT_EVER
WHERE VERTRAG = IT_EVER-VERTRAG
AND SIMULATION = ''
AND PORTION IN S_PORT
AND GPARTNER IN S_PART.
ENDIF.
CLEAR :IT_EVER,IT_EABLG,IT_EABL.
IF IT_ERCH IS NOT INITIAL .
SELECT VERTRAG
ANLAGE
FROM EVER
INTO TABLE IT_EVER
FOR ALL ENTRIES IN IT_ERCH WHERE VERTRAG = IT_ERCH-VERTRAG.
ENDIF.
IF IT_EVER IS NOT INITIAL.
PERFORM MR_DATA.
ENDIF.
ELSEIF S_PART IS NOT INITIAL. """""""""" partnter
CLEAR :it_ever,it_eablg,it_eabl.
SELECT BELNR
GPARTNER
VERTRAG
PORTION
ABLEINH
FROM ERCH
INTO TABLE IT_ERCH
WHERE GPARTNER IN S_PART.
""#EC CI_NOFIELD
IF IT_ERCH IS NOT INITIAL .
SELECT VERTRAG
ANLAGE FROM EVER
INTO TABLE IT_EVER
FOR ALL ENTRIES IN IT_ERCH
WHERE VERTRAG = IT_ERCH-VERTRAG.
ENDIF.
IF IT_EVER IS NOT INITIAL.
PERFORM MR_DATA.
ENDIF.
ENDIF.
LOOP AT IT_EABL INTO WA_EABL.
WA_FINAL-DEVICE = WA_EABL-GERNR.
WA_FINAL-EQUIPMENT = WA_EABL-EQUNR.
WA_FINAL-REGISTER = WA_EABL-ZWNUMMER.
WA_FINAL-MR_DATE = WA_EABL-ADAT.
WA_FINAL-SCHEDULED_MRD = WA_EABL-ADATSOLL.
WA_FINAL-METER_READING = WA_EABL-V_ZWSTAND + WA_EABL-N_ZWSTAND.
READ TABLE IT_EABLG INTO WA_EABLG WITH KEY ABLBELNR = WA_EABL-ABLBELNR.
WA_FINAL-INSTALLATION = WA_EABLG-ANLAGE.
WA_FINAL-METER_REASON = WA_EABLG-ABLESGR.
WA_FINAL-MRUNIT = WA_EABLG-ABLEINH.
READ TABLE IT_ERCH INTO WA_ERCH WITH KEY ABLEINH = WA_EABLG-ABLEINH.
WA_FINAL-PORTION = WA_ERCH-PORTION.
WA_FINAL-BP = WA_ERCH-GPARTNER.
WA_FINAL-CONTRACT = WA_ERCH-VERTRAG.
APPEND WA_FINAL TO IT_FINAL.
CLEAR WA_FINAL.
ENDLOOP.
ENDFORM. " GET_DATA
*&---------------------------------------------------------------------*
*& Form FCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FCAT .
WA_FCAT-COL_POS = '1'.
WA_FCAT-TABNAME = 'IT_FINAL'.
* WA_FCAT-REF_TABNAME = 'ERCH'.
WA_FCAT-FIELDNAME = 'PORTION'.
WA_FCAT-SELTEXT_M = 'PORTION'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '2'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-FIELDNAME = 'MRUNIT'.
WA_FCAT-SELTEXT_M = 'MR UNIT'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '3'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-REF_TABNAME = 'ERCH'.
WA_FCAT-FIELDNAME = 'BP'.
WA_FCAT-SELTEXT_M = 'BUSPAR'
.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '4'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-REF_TABNAME = 'ERCH'.
WA_FCAT-FIELDNAME = 'CONTRACT'.
WA_FCAT-SELTEXT_M = 'CONTRACT'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '5'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-REF_TABNAME = 'DBERCHZ1'.
WA_FCAT-FIELDNAME = 'INSTALLATION'.
WA_FCAT-SELTEXT_M = 'INSTALLATION NUM'.
WA_FCAT-OUTPUTLEN = 15.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '6'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-REF_TABNAME = 'DBERCHZ3'.
WA_FCAT-FIELDNAME = 'DEVICE'.
WA_FCAT-SELTEXT_M = 'DEVICE'.
WA_FCAT-OUTPUTLEN = 18.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '7'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-REF_TABNAME = 'DBERCHZ3'.
WA_FCAT-FIELDNAME = 'EQUIPMENT'.
WA_FCAT-SELTEXT_M = 'EQUIPMENT'.
WA_FCAT-OUTPUTLEN = 18.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '8'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-REF_TABNAME = 'DBERCHZ3'.
WA_FCAT-FIELDNAME = 'REGISTER'.
WA_FCAT-SELTEXT_M = 'REGISTER'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '9'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-REF_TABNAME = 'DBERCHZ3'.
WA_FCAT-FIELDNAME = 'MR_DATE'.
WA_FCAT-SELTEXT_M = 'MR DATE'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '10'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-REF_TABNAME = 'DBERCHZ3'.
WA_FCAT-FIELDNAME = 'SCHEDULED_MRD'.
WA_FCAT-SELTEXT_M = 'SHEDULE MRDATE'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '11'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-REF_TABNAME = 'DBERCHZ3'.
WA_FCAT-FIELDNAME = 'METER_REASON'.
WA_FCAT-SELTEXT_M = 'MR REASON'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '12'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-REF_TABNAME = 'DBERCHZ3'.
WA_FCAT-FIELDNAME = 'METER_READING'.
WA_FCAT-SELTEXT_M = 'METER READ'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
ENDFORM. " FCAT
*&---------------------------------------------------------------------*
*& Form DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY .
IF IT_FINAL IS NOT INITIAL.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = IT_FCAT
TABLES
T_OUTTAB = IT_FINAL
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
.
ELSE.
MESSAGE TEXT-002 TYPE 'I'.
ENDIF.
ENDFORM. " DISPLAY
" mr_data
*&---------------------------------------------------------------------*
*& Form mr_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM MR_DATA .
CLEAR : it_eablg,it_eabl.
SELECT ABLBELNR
ANLAGE " INSTALLATION
ABLESGR " MR REASON
ABLEINH " MR UNIT
FROM EABLG
INTO TABLE IT_EABLG
FOR ALL ENTRIES IN IT_EVER
WHERE ANLAGE = IT_EVER-ANLAGE ."AND ABLESGR = '01'.
IF IT_EABLG IS NOT INITIAL.
SELECT ABLBELNR " INTERNAL MR ID
GERNR "DEVICE
EQUNR "EUIPMENT NUMBER
ZWNUMMER "REGISTER
ADAT " MR DATE
ADATSOLL " SCHEDULED MR DATE
V_ZWSTAND " PD METRE READING
N_ZWSTAND " DEC METER READING
FROM EABL INTO TABLE IT_EABL
FOR ALL ENTRIES IN IT_EABLG
WHERE ABLBELNR = IT_EABLG-ABLBELNR.
ENDIF.
ENDFORM. " mr_data
*&Report ZISU_MET_RESULTS_TEST
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZVIJAY_MTR_READ_RESULT.
TYPE-POOLS: SLIS.
TABLES : EANL,ERCH.
***********SELECTION SCREEN************************
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : S_INST FOR EANL-ANLAGE, "Installation number
S_CONT FOR ERCH-VERTRAG, "Contarct
S_PORT FOR ERCH-PORTION, "Portion
S_PART FOR ERCH-GPARTNER. "Business Partner
SELECTION-SCREEN END OF BLOCK B1.
***********END OF SELECTION SCREEN*****************
TYPES : BEGIN OF TY_ERCH ,
BELNR TYPE ERCH-BELNR, " Billing doc no
GPARTNER TYPE ERCH-GPARTNER, " Businee partner
VERTRAG TYPE ERCH-VERTRAG, " Contract
PORTION TYPE ERCH-PORTION, "Portinon
ABLEINH TYPE ERCH-ABLEINH, " Meter reading Unit
END OF TY_ERCH.
TYPES : BEGIN OF TY_EABL,
ABLBELNR TYPE EABL-ABLBELNR, " Internal MR doc num
GERNR TYPE EABL-GERNR, " Device
EQUNR TYPE EABL-EQUNR, " Euipment
ZWNUMMER TYPE EABL-ZWNUMMER, "Register
ADAT TYPE EABL-ADAT, " MR date
ADATSOLL TYPE EABL-ADATSOLL, " Scheduled MRD
V_ZWSTAND TYPE EABL-V_ZWSTAND, " Pd MR Reading
N_ZWSTAND TYPE EABL-N_ZWSTAND, "Pd MR Reading
END OF TY_EABL.
TYPES : BEGIN OF TY_EABLG,
ABLBELNR TYPE EABLG-ABLBELNR, " Internal MR doc num
ANLAGE TYPE EABLG-ANLAGE, " Installation
ABLESGR TYPE EABLG-ABLESGR, " MR Reason
ABLEINH TYPE EABLG-ABLEINH, " MR Unit
END OF TY_EABLG.
TYPES : BEGIN OF TY_EVER,
VERTRAG TYPE EVER-VERTRAG, "Contract
ANLAGE TYPE EVER-ANLAGE, " Installation
END OF TY_EVER.
TYPES : BEGIN OF TY_FINAL,
PORTION TYPE ERCH-PORTION, "Portion
MRUNIT TYPE ERCH-ABLEINH, "MR Unit
BP TYPE GPARTNER, "Business Partner
CONTRACT TYPE VERTRAG, "Contract
INSTALLATION TYPE ANLAGE, "Installation
DEVICE TYPE GERAET, "Device
EQUIPMENT TYPE EQUNR, "Equipment
REGISTER TYPE E_ZWNUMMER, "Register
MR_DATE TYPE ADAT, "Meter Reading date
SCHEDULED_MRD TYPE ADATSOLL, "Scheduled MR Date
METER_REASON TYPE ABLESGR, "MR REason
METER_READING TYPE READINGRESULT, "Metre Reading
END OF TY_FINAL.
*****************Internal Table Decleration********************
DATA : IT_EVER TYPE TABLE OF TY_EVER.
DATA : IT_ERCH TYPE TABLE OF TY_ERCH, "Billing Doc. Data Internal Table
WA_ERCH TYPE TY_ERCH. "Billing Doc. Data Work area
DATA : IT_EABL TYPE TABLE OF TY_EABL, " MR Document Internal Table
WA_EABL TYPE TY_EABL. " MR Document Work area
DATA : IT_EABLG TYPE TABLE OF TY_EABLG, " MR Reasons in MR Document Internal Table
WA_EABLG TYPE TY_EABLG. " MR Reasons in MR Document Work area
DATA : IT_FINAL TYPE TABLE OF TY_FINAL, " Final Internal Table
WA_FINAL TYPE TY_FINAL. " Final Work area
DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FCAT TYPE SLIS_FIELDCAT_ALV.
****************End Of Decleration******************************
PERFORM GET_DATA.
PERFORM FCAT.
PERFORM DISPLAY.
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DATA .
IF S_INST IS NOT INITIAL .
SELECT VERTRAG
ANLAGE
FROM EVER
INTO TABLE IT_EVER
WHERE ANLAGE IN S_INST .
IF S_INST IS NOT INITIAL AND S_CONT IS NOT INITIAL.
CLEAR IT_EVER.
SELECT VERTRAG
ANLAGE
FROM EVER
INTO TABLE IT_EVER
WHERE ANLAGE IN S_INST AND VERTRAG IN S_CONT.
ENDIF.
IF IT_EVER IS NOT INITIAL .
SELECT ABLBELNR
ANLAGE " INSTALLATION
ABLESGR " MR REASON
ABLEINH
FROM EABLG
INTO TABLE IT_EABLG
FOR ALL ENTRIES IN IT_EVER
WHERE ANLAGE = IT_EVER-ANLAGE.
**** WHERE ANLAGE IN S_INST AND ABLESGR = '01'.
ENDIF.
IF IT_EABLG IS NOT INITIAL.
SELECT ABLBELNR
GERNR
EQUNR
ZWNUMMER
ADAT
ADATSOLL
V_ZWSTAND
N_ZWSTAND
FROM EABL
INTO TABLE IT_EABL
FOR ALL ENTRIES IN IT_EABLG
WHERE ABLBELNR = IT_EABLG-ABLBELNR.
ENDIF.
IF IT_EVER IS NOT INITIAL.
SELECT BELNR
GPARTNER
VERTRAG
PORTION
ABLEINH
FROM ERCH
INTO TABLE IT_ERCH FOR ALL ENTRIES IN IT_EVER
WHERE VERTRAG = IT_EVER-VERTRAG
AND SIMULATION = '' .
ENDIF.
ELSEIF S_CONT IS NOT INITIAL.
SELECT VERTRAG
ANLAGE
FROM EVER
INTO TABLE IT_EVER
WHERE VERTRAG IN S_CONT.
IF IT_EVER IS NOT INITIAL.
PERFORM MR_DATA.
ENDIF.
SELECT BELNR
GPARTNER
VERTRAG
PORTION
ABLEINH
FROM ERCH
INTO TABLE IT_ERCH FOR ALL ENTRIES IN IT_EVER
WHERE VERTRAG = IT_EVER-VERTRAG
AND SIMULATION = '' .
ENDIF.
*********** portion ***************************
IF S_PORT IS NOT INITIAL.
SELECT BELNR
GPARTNER
VERTRAG
PORTION
ABLEINH
FROM ERCH
INTO TABLE IT_ERCH "#EC CI_NOFIELD
WHERE PORTION IN S_PORT.
IF S_PORT IS NOT INITIAL AND S_PART IS NOT INITIAL .
CLEAR it_erch.
SELECT BELNR
GPARTNER
VERTRAG
PORTION
ABLEINH "#EC CI_NOFIELD
FROM ERCH
INTO TABLE IT_ERCH
WHERE PORTION IN S_PORT
AND GPARTNER IN S_PART.
ENDIF.
IF S_PORT IS NOT INITIAL AND S_INST IS NOT INITIAL.
SELECT BELNR
GPARTNER
VERTRAG
PORTION
ABLEINH
FROM ERCH
INTO TABLE IT_ERCH FOR ALL ENTRIES IN IT_EVER
WHERE VERTRAG = IT_EVER-VERTRAG
AND SIMULATION = ''
AND PORTION IN S_PORT
AND GPARTNER IN S_PART.
ENDIF.
CLEAR :IT_EVER,IT_EABLG,IT_EABL.
IF IT_ERCH IS NOT INITIAL .
SELECT VERTRAG
ANLAGE
FROM EVER
INTO TABLE IT_EVER
FOR ALL ENTRIES IN IT_ERCH WHERE VERTRAG = IT_ERCH-VERTRAG.
ENDIF.
IF IT_EVER IS NOT INITIAL.
PERFORM MR_DATA.
ENDIF.
ELSEIF S_PART IS NOT INITIAL. """""""""" partnter
CLEAR :it_ever,it_eablg,it_eabl.
SELECT BELNR
GPARTNER
VERTRAG
PORTION
ABLEINH
FROM ERCH
INTO TABLE IT_ERCH
WHERE GPARTNER IN S_PART.
""#EC CI_NOFIELD
IF IT_ERCH IS NOT INITIAL .
SELECT VERTRAG
ANLAGE FROM EVER
INTO TABLE IT_EVER
FOR ALL ENTRIES IN IT_ERCH
WHERE VERTRAG = IT_ERCH-VERTRAG.
ENDIF.
IF IT_EVER IS NOT INITIAL.
PERFORM MR_DATA.
ENDIF.
ENDIF.
LOOP AT IT_EABL INTO WA_EABL.
WA_FINAL-DEVICE = WA_EABL-GERNR.
WA_FINAL-EQUIPMENT = WA_EABL-EQUNR.
WA_FINAL-REGISTER = WA_EABL-ZWNUMMER.
WA_FINAL-MR_DATE = WA_EABL-ADAT.
WA_FINAL-SCHEDULED_MRD = WA_EABL-ADATSOLL.
WA_FINAL-METER_READING = WA_EABL-V_ZWSTAND + WA_EABL-N_ZWSTAND.
READ TABLE IT_EABLG INTO WA_EABLG WITH KEY ABLBELNR = WA_EABL-ABLBELNR.
WA_FINAL-INSTALLATION = WA_EABLG-ANLAGE.
WA_FINAL-METER_REASON = WA_EABLG-ABLESGR.
WA_FINAL-MRUNIT = WA_EABLG-ABLEINH.
READ TABLE IT_ERCH INTO WA_ERCH WITH KEY ABLEINH = WA_EABLG-ABLEINH.
WA_FINAL-PORTION = WA_ERCH-PORTION.
WA_FINAL-BP = WA_ERCH-GPARTNER.
WA_FINAL-CONTRACT = WA_ERCH-VERTRAG.
APPEND WA_FINAL TO IT_FINAL.
CLEAR WA_FINAL.
ENDLOOP.
ENDFORM. " GET_DATA
*&---------------------------------------------------------------------*
*& Form FCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FCAT .
WA_FCAT-COL_POS = '1'.
WA_FCAT-TABNAME = 'IT_FINAL'.
* WA_FCAT-REF_TABNAME = 'ERCH'.
WA_FCAT-FIELDNAME = 'PORTION'.
WA_FCAT-SELTEXT_M = 'PORTION'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '2'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-FIELDNAME = 'MRUNIT'.
WA_FCAT-SELTEXT_M = 'MR UNIT'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '3'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-REF_TABNAME = 'ERCH'.
WA_FCAT-FIELDNAME = 'BP'.
WA_FCAT-SELTEXT_M = 'BUSPAR'
.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '4'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-REF_TABNAME = 'ERCH'.
WA_FCAT-FIELDNAME = 'CONTRACT'.
WA_FCAT-SELTEXT_M = 'CONTRACT'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '5'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-REF_TABNAME = 'DBERCHZ1'.
WA_FCAT-FIELDNAME = 'INSTALLATION'.
WA_FCAT-SELTEXT_M = 'INSTALLATION NUM'.
WA_FCAT-OUTPUTLEN = 15.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '6'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-REF_TABNAME = 'DBERCHZ3'.
WA_FCAT-FIELDNAME = 'DEVICE'.
WA_FCAT-SELTEXT_M = 'DEVICE'.
WA_FCAT-OUTPUTLEN = 18.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '7'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-REF_TABNAME = 'DBERCHZ3'.
WA_FCAT-FIELDNAME = 'EQUIPMENT'.
WA_FCAT-SELTEXT_M = 'EQUIPMENT'.
WA_FCAT-OUTPUTLEN = 18.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '8'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-REF_TABNAME = 'DBERCHZ3'.
WA_FCAT-FIELDNAME = 'REGISTER'.
WA_FCAT-SELTEXT_M = 'REGISTER'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '9'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-REF_TABNAME = 'DBERCHZ3'.
WA_FCAT-FIELDNAME = 'MR_DATE'.
WA_FCAT-SELTEXT_M = 'MR DATE'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '10'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-REF_TABNAME = 'DBERCHZ3'.
WA_FCAT-FIELDNAME = 'SCHEDULED_MRD'.
WA_FCAT-SELTEXT_M = 'SHEDULE MRDATE'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '11'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-REF_TABNAME = 'DBERCHZ3'.
WA_FCAT-FIELDNAME = 'METER_REASON'.
WA_FCAT-SELTEXT_M = 'MR REASON'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
WA_FCAT-COL_POS = '12'.
WA_FCAT-TABNAME = 'IT_FINAL'.
WA_FCAT-REF_TABNAME = 'DBERCHZ3'.
WA_FCAT-FIELDNAME = 'METER_READING'.
WA_FCAT-SELTEXT_M = 'METER READ'.
APPEND WA_FCAT TO IT_FCAT.
CLEAR WA_FCAT.
ENDFORM. " FCAT
*&---------------------------------------------------------------------*
*& Form DISPLAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY .
IF IT_FINAL IS NOT INITIAL.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = IT_FCAT
TABLES
T_OUTTAB = IT_FINAL
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
.
ELSE.
MESSAGE TEXT-002 TYPE 'I'.
ENDIF.
ENDFORM. " DISPLAY
" mr_data
*&---------------------------------------------------------------------*
*& Form mr_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM MR_DATA .
CLEAR : it_eablg,it_eabl.
SELECT ABLBELNR
ANLAGE " INSTALLATION
ABLESGR " MR REASON
ABLEINH " MR UNIT
FROM EABLG
INTO TABLE IT_EABLG
FOR ALL ENTRIES IN IT_EVER
WHERE ANLAGE = IT_EVER-ANLAGE ."AND ABLESGR = '01'.
IF IT_EABLG IS NOT INITIAL.
SELECT ABLBELNR " INTERNAL MR ID
GERNR "DEVICE
EQUNR "EUIPMENT NUMBER
ZWNUMMER "REGISTER
ADAT " MR DATE
ADATSOLL " SCHEDULED MR DATE
V_ZWSTAND " PD METRE READING
N_ZWSTAND " DEC METER READING
FROM EABL INTO TABLE IT_EABL
FOR ALL ENTRIES IN IT_EABLG
WHERE ABLBELNR = IT_EABLG-ABLBELNR.
ENDIF.
ENDFORM. " mr_data
No comments:
Post a Comment