Monday, November 5, 2007

Classical Report Using Condition Types

REPORT Z_SD_RP_BILLING_PERIOD NO STANDARD PAGE HEADING
MESSAGE-ID Z_MSGCLASS " Message class
LINE-SIZE 80 " Width of Report display
LINE-COUNT 65. " No.of lines in page

************************************************************************
* Program Name : Z_SD_RP_BILLING_PERIOD *
* Description : This Report displays Billing Invoice *
* based on the selection criterion Billing *
* Document No. *
* The Output Is: *
* 1) Billing Document No. *
* 2) Date *
* 3) Billing Period *
* 4) Meter Reading Date *
* 5) Billed Units in KWhrs *
* 6) Monthly Settlement Periods *
* 7) Due date of payment *
* 8) 2.5% Rebate if payment made by date *
* 9) 1% Rebate if payment made by date *
* 10) Late Charges interest if payment made after *
* date *
* 11) Capacity Charges – FDSC *
* 12) Capacity Charges – OFC *
* 13) Energy Charges *
* 14) Adjustment for FDSC of Bill No.66 *
* 15) Total *
* 16) Total in words *
* Functional : *
* Developer : *
* Development class : *
* *
************************************************************************
*----------------------------------------------------------------------*
* Request No. Created Date Developer name *
*----------------------------------------------------------------------*
* LD1K900601 21/03/2006 Harini
*----------------------------------------------------------------------*

*---------------------------------------------------------------------*
* TABLES *
*---------------------------------------------------------------------*
TABLES VBRK.

*---------------------------------------------------------------------*
* DATA DECLARATIONS *
*---------------------------------------------------------------------*
DATA: V_TOT_FDSC LIKE KONV-KWERT, " Total Capacity Charges FDSC
V_TOT_OFC LIKE KONV-KWERT, " Total Capacity Charges OFC
V_ADJ_FDSC LIKE KONV-KWERT, " Total Adj for FDSC of Bill No
V_TOTAL LIKE PC207-BETRG, " HR Payroll: Amount
V_FKDAT LIKE VBRK-FKDAT, " Billing date for billing index and printout
V_STL_PRD TYPE I, " Billed Settlement Period
V_DAYS LIKE VTBBEWE-ATAGE, " No. of days
V_DATE TYPE D, " Date
V_BP_FROM LIKE VTBBEWE-DBERVON, " Billing Period from
V_BP_TO LIKE VTBBEWE-DBERBIS, " Billing Period to
V_MESG TYPE STRING, " Message
V_TOTAL_WORDS(210), " String for Total No Of Words
VAR1(72) TYPE C, " String 1 for Total No Of Words
VAR2(72) TYPE C, " String 2 for Total No Of Words
V_MONTHNAME(12), " Month Name
PAY_DATE(12), " Rebate if payment made
BILL_YEAR(4), " Year of Billing
BILL_MONTH(2), " Month of Billing
BILL_DATE(12), " Date of Billing
V_VBELN LIKE VBRK-VBELN, " Previous Billing Doc No
V_ENRG_CHG LIKE VBRK-NETWR, " Auxiliary Consumption
V_TOT_ICP TYPE P DECIMALS 2, " Total Units at ICP
V_UNITS_IMP LIKE KONV-KBETR, " Units Imported
V_NET_UNITS LIKE KONV-KBETR, " Net Units Billed
V_MON_TRAN_CHG LIKE KONV-KWERT, " Monthly Transmission
V_ADJ_ENRG_CHG LIKE VBRK-NETWR, " Adj. of Energy Charges
V_ADD_ENRG_CHG LIKE KONV-KWERT, " Adj. Additional Energy Charges
V_COMP_CHG LIKE KONV-KWERT, " Compression Charges
V_MISC1_CHG LIKE KONV-KBETR, " Misc.1 Adjustments
V_MISC2_CHG LIKE KONV-KBETR, " Misc.2 Adjustments
V_MISC3_CHG LIKE KONV-KBETR, " Misc.3 Adjustments
V_MISC4_CHG LIKE KONV-KBETR, " Misc.4 Adjustments
V_PLF_CHG LIKE KONV-KBETR, " PLF Bonus
V_BAK_CHG LIKE KONV-KBETR, " Backdown
V_TOT_ENRG_CHG LIKE KONV-KWERT. " Total Energy Charges

DATA : LV_SERIAL TYPE I,
LV_CHAR TYPE C.
*---------------------------------------------------------------------*
* CONSTANTS *
*---------------------------------------------------------------------*
CONSTANTS: C_ZDEL LIKE KONV-KSCHL VALUE 'ZDEL', " Total Delivery
C_ZIMP LIKE KONV-KSCHL VALUE 'ZIMP', " Total Imported Units
C_ZFDP LIKE KONV-KSCHL VALUE 'ZFDP', " FDSC Payments
C_ZOFC LIKE KONV-KSCHL VALUE 'ZOFC', " OFC Payments
C_ZR00 LIKE KONV-KSCHL VALUE 'ZR00', " EnergyCharges(Price)
C_ZMTQ LIKE KONV-KSCHL VALUE 'ZMTQ', " Monthly Transmission
C_ZAEC LIKE KONV-KSCHL VALUE 'ZAEC', " Adj. Energy Charges
C_ZAAT LIKE KONV-KSCHL VALUE 'ZAAT', " Adj. Additional Transmission Charges
C_ZCOC LIKE KONV-KSCHL VALUE 'ZCOC', " Compression Charges
C_ZAD1 LIKE KONV-KSCHL VALUE 'ZAD1', " Misc. Adjustments 1
C_ZAD2 LIKE KONV-KSCHL VALUE 'ZAD2', " Misc. Adjustments 2
C_ZAD3 LIKE KONV-KSCHL VALUE 'ZAD3', " Misc. Adjustments 3
C_ZAD4 LIKE KONV-KSCHL VALUE 'ZAD4', " Misc. Adjustments 4
C_ZPLF LIKE KONV-KSCHL VALUE 'ZPLF', " PLF Bonus
C_ZBAK LIKE KONV-KSCHL VALUE 'ZBAK', " Backdown
C_ZCUR LIKE KONV-KSCHL VALUE 'ZCUR'. " Currency Adjustment

*---------------------------------------------------------------------*
* FLAGS *
*---------------------------------------------------------------------*
DATA: F_STOP. " Indicator Flag

*---------------------------------------------------------------------*
* INTERNAL TABLE DECLARATIONS *
*---------------------------------------------------------------------*
*--- Internal table to hold Month name and short text
DATA: IT_MONTHS LIKE T247 OCCURS 0 WITH HEADER LINE.

**--- Work Area to hold Billing Document: Header Data
DATA: WA_VBRK LIKE VBRK.

**--- Internal table to hold Billing Document: Header Data
DATA: BEGIN OF IT_VBRK OCCURS 0,
VBELN LIKE VBRK-VBELN, " Billing Document
ERDAT LIKE VBRK-ERDAT, " Date on which the record was created
END OF IT_VBRK.

*--- Internal table to hold Billing: Item Data
DATA: BEGIN OF IT_VBRP OCCURS 0,
VBELN LIKE VBRP-VBELN, " Billing Document
POSNR LIKE VBRP-POSNR, " Billing item
END OF IT_VBRP.

*--- Internal table to hold Conditions (Transaction Data)
DATA: BEGIN OF IT_KONV OCCURS 0,
KNUMV LIKE KONV-KNUMV, " No. of the doc. condition
KPOSN LIKE KONV-KPOSN, " Condition item number
STUNR LIKE KONV-STUNR, " Step number
ZAEHK LIKE KONV-ZAEHK, " Condition counter
KAPPL LIKE KONV-KAPPL, " Application
KSCHL LIKE KONV-KSCHL, " Condition type
KAWRT LIKE KONV-KAWRT, " Condition Base Value
KBETR LIKE KONV-KBETR, " Rate (cond. amount or %)
KWERT LIKE KONV-KWERT, " Condition value
END OF IT_KONV.

**--- Internal table to hold Billing document dates
DATA: BEGIN OF IT_ZBILLDATES OCCURS 0,
VBELN LIKE ZBILLDATES-VBELN, " Billing Document
FKART LIKE ZBILLDATES-FKART, " Billing Type
FRDAT LIKE ZBILLDATES-FRDAT, " From Date
TODAT LIKE ZBILLDATES-TODAT, " To Date
END OF IT_ZBILLDATES.
*---------------------------------------------------------------------*
* SELECTION-SCREEN *
*---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK SCLSCR WITH FRAME TITLE TEXT-001.
PARAMETERS: P_VBELN LIKE VBRK-VBELN MATCHCODE OBJECT VMCF OBLIGATORY. " Billing Document
SELECTION-SCREEN END OF BLOCK SCLSCR.
*---------------------------------------------------------------------*
* AT SELECTION-SCREEN *
*---------------------------------------------------------------------*

AT SELECTION-SCREEN ON P_VBELN.
*--- Perform to validate Billing document
PERFORM VALIDATE_BILL_DOC.
*---------------------------------------------------------------------*
* TOP-OF-PAGE *
*---------------------------------------------------------------------*
TOP-OF-PAGE.
*--- Perform to display the report header
PERFORM BUILD_HEADER.
*---------------------------------------------------------------------*
* START-OF-SELECTION *
*---------------------------------------------------------------------*
START-OF-SELECTION.

*--- Perform to populate Billing Document: Header Data
PERFORM GET_VBRK_DATA.
*--- Perform to populate Billing Document: Item Data
PERFORM GET_VBRP_DATA.
IF F_STOP = SPACE.
*--- Perform to populate Conditions
PERFORM GET_KONV_DATA.
*--- Perform to populate Billing document dates
PERFORM GET_ZBILLDATES_DATA.
*--- Perform to get values of Bill Settlement Periods
PERFORM GET_VALUES .
*--- Perform to get the Values of Conditions & corresponding Condition Values
PERFORM GET_CON_VALUE.
*--- Perform to get the Previous Billing Document No
PERFORM GET_PREVIOUS_BILL_DOC.
ENDIF.
*---------------------------------------------------------------------*
* END-OF-SELECTION *
*---------------------------------------------------------------------*
END-OF-SELECTION.

IF F_STOP = SPACE.
*--- Perform to display the report
PERFORM DISPLAY_REPORT.
*----- Perform to display the Footer Data
PERFORM FOOTER.
ENDIF.
*---------------------------------------------------------------------*
* Form VALIDATE_BILL_DOC *
*---------------------------------------------------------------------*
* Validates Billing document *
*---------------------------------------------------------------------*
FORM VALIDATE_BILL_DOC.

DATA: LV_VBELN LIKE VBRK-VBELN.

IF NOT P_VBELN IS INITIAL.
*--- Select Construct to check P_VBELN against VBELN from VBRK
SELECT SINGLE VBELN
INTO LV_VBELN
FROM VBUK
WHERE VBELN = P_VBELN.
IF SY-SUBRC <> 0.
*--- Display message and stop processing in case of invalid field entry
MESSAGE E002(Z_MSGCLASS)
WITH 'Enter a valid Billing Document'(002).
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_BILL_DOC
*&---------------------------------------------------------------------*
*& Form GET_VBRK_DATA
*&---------------------------------------------------------------------*
* To populate Billing Document: Header Data
*----------------------------------------------------------------------*
FORM GET_VBRK_DATA .
*--- Select Construct to retrieve Billing Document and No. of the doc.
*--- condition from VBRK
SELECT SINGLE * "VBELN KNUMV FKDAT
INTO WA_VBRK
FROM VBRK
WHERE VBELN = P_VBELN.
IF SY-SUBRC = 0.
*--Do Nothing
ELSE.
*--- Display message and stop processing in case of absence of data
V_MESG = 'No data exists with the selection criteria'(067).
MESSAGE S002(Z_MSGCLASS) WITH V_MESG.
F_STOP = 'X'.
STOP.
ENDIF.

ENDFORM. " GET_VBRK_DATA
*&---------------------------------------------------------------------*
*& Form GET_VBRP_DATA
*&---------------------------------------------------------------------*
* To populate Billing: Item Data
*----------------------------------------------------------------------*
FORM GET_VBRP_DATA .
*--- Checking whether Billing Document is populated
IF NOT WA_VBRK IS INITIAL.
*--- Select Construct to retrieve Billing Document, Billing item
*--- Actual billed quantity from VBRP
SELECT VBELN POSNR
INTO TABLE IT_VBRP
FROM VBRP
WHERE VBELN = P_VBELN.
IF SY-SUBRC = 0.
*--- Sort Billing: Item Data
SORT IT_VBRP BY VBELN POSNR.
ENDIF.
ENDIF.
ENDFORM. " GET_VBRP_DATA
*&---------------------------------------------------------------------*
*& Form GET_KONV_DATA
*&---------------------------------------------------------------------*
* To populate Conditions (Transaction Data)
*----------------------------------------------------------------------*
FORM GET_KONV_DATA .
*--- Checking whether Billing Document is populated
IF NOT WA_VBRK IS INITIAL.
*--- Select construct to get No. of the doc. condition
*--- Condition value and Condition type from KONV
SELECT KNUMV KPOSN STUNR ZAEHK KAPPL KSCHL KAWRT KBETR KWERT
INTO TABLE IT_KONV
FROM KONV
WHERE KNUMV = WA_VBRK-KNUMV.
IF SY-SUBRC = 0.
*--- Sort Conditions
SORT IT_KONV BY KSCHL. " KNUMV.
ENDIF.
ENDIF.
ENDFORM. " GET_KONV_DATA
*&---------------------------------------------------------------------*
*
*& Form GET_ZBILLDATES_DATA
*&---------------------------------------------------------------------*
*
* To populate Billing document dates
*----------------------------------------------------------------------*
FORM GET_ZBILLDATES_DATA .
*--- Checking whether Billing Document is populated
IF NOT WA_VBRK IS INITIAL.
*--- Select Construct to retrieve Billing Document, Billing Type
*--- From Date and To Date from ZBILLDATES
SELECT VBELN FKART FRDAT TODAT
INTO TABLE IT_ZBILLDATES
FROM ZBILLDATES
WHERE VBELN = WA_VBRK-VBELN.
IF SY-SUBRC = 0.
*--- Sort Billing document dates
SORT IT_ZBILLDATES BY VBELN.
ENDIF.
ENDIF.
ENDFORM. " GET_ZBILLDATES_DATA
*&---------------------------------------------------------------------*
*& Form GET_VALUES
*&---------------------------------------------------------------------*
* To get the bill settlement dates.
*----------------------------------------------------------------------*
FORM GET_VALUES .

V_FKDAT = WA_VBRK-FKDAT.
V_DATE = SY-DATUM.
BILL_YEAR = V_FKDAT+0(4).
BILL_MONTH = V_FKDAT+4(2).

*--- Perform to get the bill settlement dates.
PERFORM BILL_SETTLE_DATE.

ENDFORM. " GET_VALUES
*&---------------------------------------------------------------------*
*& Form GET_OUTPUT
*&---------------------------------------------------------------------*
* To get the Values of Conditions and corresponding Condition Values
*----------------------------------------------------------------------*
FORM GET_CON_VALUE .

DATA: LV_CNT TYPE SY-INDEX.
CLEAR: V_TOT_ICP,V_NET_UNITS,V_TOT_FDSC, V_TOT_OFC,V_ENRG_CHG,V_MON_TRAN_CHG,V_ADJ_ENRG_CHG,
V_ADD_ENRG_CHG,V_COMP_CHG,V_MISC1_CHG,V_MISC2_CHG,V_MISC3_CHG,V_MISC4_CHG,
V_PLF_CHG,V_BAK_CHG,V_ADJ_FDSC,V_TOTAL.

*--- Loop to get the Values of Conditions and corresponding Condition Values
LOOP AT IT_VBRP.

LOOP AT IT_KONV WHERE KNUMV = WA_VBRK-KNUMV
AND KPOSN = IT_VBRP-POSNR.

CASE IT_KONV-KSCHL.

WHEN C_ZDEL.
*--- Billed Uints in Kwhrs.
V_TOT_ICP = V_TOT_ICP + IT_KONV-KWERT.
WHEN C_ZIMP.
*--- Total Imported Units
V_UNITS_IMP = IT_KONV-KBETR.
WHEN C_ZFDP.
*--- For Capacity Charges FDSC
V_TOT_FDSC = V_TOT_FDSC + IT_KONV-KWERT.
WHEN C_ZOFC.
*--- For Capacity Charges OFC
V_TOT_OFC = V_TOT_OFC + IT_KONV-KWERT.
WHEN C_ZR00.
*--- For Energy Charges(Price)
V_ENRG_CHG = V_ENRG_CHG + IT_KONV-KWERT.
WHEN C_ZMTQ.
*--- For Monthly Transmission
V_MON_TRAN_CHG = V_MON_TRAN_CHG + IT_KONV-KWERT.
WHEN C_ZAEC.
*--- For Adj. Energy Charges
V_ADJ_ENRG_CHG = V_ADJ_ENRG_CHG + IT_KONV-KWERT.
* V_ADJ_ENRG_CHG = IT_KONV-KBETR.
WHEN C_ZAAT.
*--- For Adj. Additional Transmission Charges
V_ADD_ENRG_CHG = V_ADD_ENRG_CHG + IT_KONV-KWERT.
*--- For Compression Charges
WHEN C_ZCOC.
V_COMP_CHG = V_COMP_CHG + IT_KONV-KWERT.
WHEN C_ZAD1.
*--- For Misc. Adjustments 1
V_MISC1_CHG = V_MISC1_CHG + IT_KONV-KWERT.
WHEN C_ZAD2.
*--- For Misc. Adjustments 2
V_MISC2_CHG = V_MISC2_CHG + IT_KONV-KWERT.
WHEN C_ZAD3.
*--- For Misc. Adjustments 3
V_MISC3_CHG = V_MISC3_CHG + IT_KONV-KWERT.
WHEN C_ZAD4.
*--- For Misc. Adjustments 4
V_MISC4_CHG = V_MISC4_CHG + IT_KONV-KWERT.
WHEN C_ZPLF.
*--- For PLF Bonus
V_PLF_CHG = V_PLF_CHG + IT_KONV-KWERT.
WHEN C_ZBAK.
*--- For Backdown
V_BAK_CHG = V_BAK_CHG + IT_KONV-KWERT.
WHEN C_ZCUR.
*--- For Adjustment for FDSC
V_ADJ_FDSC = V_ADJ_FDSC + IT_KONV-KWERT.

ENDCASE.
ENDLOOP.
ENDLOOP.

*--- Calculate the Value of Total Energy Charges
V_TOT_ENRG_CHG = V_ENRG_CHG + V_MON_TRAN_CHG +
V_ADJ_ENRG_CHG + V_ADD_ENRG_CHG +
V_COMP_CHG + V_MISC1_CHG +
V_MISC2_CHG + V_MISC3_CHG +
V_MISC4_CHG + V_PLF_CHG +
V_BAK_CHG.

*--- For Total
V_TOTAL = V_TOT_FDSC + V_TOT_OFC + V_TOT_ENRG_CHG + V_ADJ_FDSC.
*--- Perform to get Changes of INR amount to words
PERFORM CONVERT_TOTAL USING V_TOTAL CHANGING V_TOTAL_WORDS.

*--- For Period from, Period to and Metering date
READ TABLE IT_ZBILLDATES WITH KEY VBELN = WA_VBRK-VBELN.
IF SY-SUBRC = 0.
V_BP_FROM = IT_ZBILLDATES-FRDAT.
V_BP_TO = IT_ZBILLDATES-TODAT.
ENDIF.

*--- To get No. of days between From & To Dates
PERFORM GET_DAYS_DIFF USING V_BP_FROM V_BP_TO.
* V_DAYS = V_DAYS + 1.
V_STL_PRD = V_DAYS * 24.

*--- Net Units Billed
V_NET_UNITS = V_TOT_ICP - V_UNITS_IMP.

ENDFORM. " GET_OUTPUT
*&---------------------------------------------------------------------*
*& Form GET_PREVIOUS_BILL_DOC
*&---------------------------------------------------------------------*
* To get the Previous Billing Document No
*----------------------------------------------------------------------*
FORM GET_PREVIOUS_BILL_DOC .

DATA: LV_TABIX LIKE SY-TABIX.

SELECT VBELN ERDAT
INTO TABLE IT_VBRK
FROM VBRK
WHERE FKSTO = SPACE.

IF SY-SUBRC = 0.
*--Sort Billing Document No
SORT IT_VBRK DESCENDING BY VBELN ERDAT DESCENDING.
*--- Read for Billing Document No
READ TABLE IT_VBRK WITH KEY VBELN = P_VBELN.
IF SY-SUBRC = 0.
LV_TABIX = SY-TABIX + 1.
*--- Read for Billing Document No to get index no
READ TABLE IT_VBRK INDEX LV_TABIX.
IF SY-SUBRC = 0.
V_VBELN = IT_VBRK-VBELN.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " GET_PREVIOUS_BILL_DOC
*&---------------------------------------------------------------------*
*& Form BUILD_HEADER
*&---------------------------------------------------------------------*
* To build the Header Data for the Report
*----------------------------------------------------------------------*
FORM BUILD_HEADER.

*--- Lanco Kondapalli Power Private Limited Heading
WRITE : /5(80) SY-ULINE,
/5(01) SY-VLINE,
22(40) ' LANCO KONDAPALLI POWER PRIVATE LIMITED'(008) CENTERED COLOR 4,
80(01) SY-VLINE,
/5(01) SY-VLINE,
20(47) 'Regd. Office: "LANCO HOUSE", 141, Avenue # 8,'(009),
80(01) SY-VLINE,
/5(01) SY-VLINE,
20(50) 'Banjara Hills,Hyderabad-500034,AP,India'(010),
80(01) SY-VLINE,
/5(01) SY-VLINE,
18(56) ' Tel # +91-40-23540697, 23540703,Fax # +91-40-23540698'(011),
80(01) SY-VLINE,
/5(01) SY-VLINE,
18(55) ' APGST # TIN No.28150199007;CST # PJT/10/1/1981/99-00'(012),
80(01) SY-VLINE,
/5(80) SY-ULINE.

ENDFORM. "BUILD_HEADER.
*&---------------------------------------------------------------------*
*& Form DISPLAY_REPORT
*&---------------------------------------------------------------------*
*--- To display the Output Data
*----------------------------------------------------------------------*
FORM DISPLAY_REPORT.
DATA: LV_CHAR(80) TYPE C,
LV_VAL(20),
LV_MONTH(2), " Local variables to hold Report Display
LV_MONTH1(2),
LV_MONTH2(2),
LV_PERIOD_FROM(20),
LV_PERIOD_TO(20).

*--- Bill Date Heading.
CLEAR LV_MONTH.
LV_MONTH = SY-DATUM+4(2).

*--- Perform to get Names of the month
PERFORM GET_MONTH_NAME USING LV_MONTH.
CLEAR: LV_CHAR, LV_VAL.
CONCATENATE 'Date:'(066) V_MONTHNAME SY-DATUM+6(2) SY-DATUM+0(4)
INTO LV_CHAR
SEPARATED BY SPACE.
CONDENSE LV_CHAR.

*--- To Display Billing Document No
WRITE:/05(01) SY-VLINE,
08(09) ' BILL #'(015),
15(15) P_VBELN,
40(01) SY-VLINE,
42(30) LV_CHAR,
80(01) SY-VLINE,
/05(80) SY-ULINE.

*--- To Andhra Pradesh.
WRITE: /5(01) SY-VLINE,
08(3) 'To:'(003),
15(51) 'Andhra Pradesh Power Coordination Commitee (APPCC)'(013),
80(01) SY-VLINE,
/5(01) SY-VLINE,
23(34) 'Vidyut Soudha, Hyderabad - 500 082'(014),
80(01) SY-VLINE,
/5(80) SY-ULINE.

*---Billing Period
* To obtain Period: From
CLEAR: LV_MONTH, LV_CHAR, LV_PERIOD_FROM, LV_PERIOD_TO.
LV_MONTH1 = V_BP_FROM+4(2).
V_BP_FROM+6(2) = V_BP_FROM+6(2) + 1.
*--- Perform to get the month name
PERFORM GET_MONTH_NAME USING LV_MONTH1.

*--- Concatenation to generate period-from
CONCATENATE V_MONTHNAME V_BP_FROM+6(2)
INTO LV_PERIOD_FROM SEPARATED BY SPACE.
CONCATENATE LV_PERIOD_FROM V_BP_FROM+0(4) INTO LV_PERIOD_FROM SEPARATED BY SPACE.
*--- To obtain Period: To
LV_MONTH2 = V_BP_TO+4(2).

*--- Perform to get the month name
PERFORM GET_MONTH_NAME USING LV_MONTH2.

*--- Concatenation to generate period-from
CONCATENATE V_MONTHNAME V_BP_TO+6(2)
INTO LV_PERIOD_TO SEPARATED BY SPACE.
CONCATENATE LV_PERIOD_TO V_BP_TO+0(4) INTO LV_PERIOD_TO SEPARATED BY SPACE.

* Period: From & To
CONCATENATE 'Billing Period:'(016) LV_PERIOD_FROM 'To' LV_PERIOD_TO
INTO LV_CHAR SEPARATED BY SPACE.
CONDENSE LV_CHAR.

*--- To Display Billing Period
WRITE: 05(80) SY-ULINE,
/05(01) SY-VLINE,
20(50) LV_CHAR CENTERED,
80(01) SY-VLINE,
/05(80) SY-ULINE,

*--- Contract: Power Purchase.
/05(01) SY-VLINE,
08(09) 'Contract:'(017),
23(58) 'Power Purchase Agreement (PPA) dated March 31, 1997'(018),
80(01) SY-VLINE,
/05(80) SY-ULINE,

*--- Particulars.
/05(01) SY-VLINE,
36(13) 'Particulars'(019) COLOR 4,
80(01) SY-VLINE,
/05(80) SY-ULINE.

*--- To Display Metering Date
WRITE: /05(01) SY-VLINE,
08(01) '1.'(020),
13(01) SY-VLINE,
15(18) 'Meter Reading Date'(021),
63(01) SY-VLINE,
64 LV_PERIOD_TO,
80(01) SY-VLINE,
/05(80) SY-ULINE,

*--- 2 a Present Meter Reading Units MWhrs
/05(01) SY-VLINE,
08(05) '2. a)'(022),
13(01) SY-VLINE,
15(40) 'Present Meter Reading Units MWhrs'(023),
05(01) SY-VLINE,
63(01) SY-VLINE,
05(01) SY-VLINE,
80(01) SY-VLINE,
65(16) 'As per Annexure'(024),
80(01) SY-VLINE,
/05(01) SY-VLINE,
65(16) '# B',
13(01) SY-VLINE,
63(01) SY-VLINE,
80(01) SY-VLINE,
/05(58) SY-ULINE,
63(01) SY-VLINE,
80(01) SY-VLINE,

*--- 2 b Previous Meter Reading Units MWhrs
/05(01) SY-VLINE,
08(05) ' b)'(025),
13(01) SY-VLINE,
15(40) 'Previous Meter Reading Units MWhrs'(023),
63(01) SY-VLINE,
80(01) SY-VLINE,
/5(80) SY-ULINE,

*--- 2 c Billed Units in KWhrs
/05(01) SY-VLINE,
08(05) ' c)'(026),
13(01) SY-VLINE,
15(40) 'Billed Units in KWhrs'(027),
63(01) SY-VLINE,
65(16) V_NET_UNITS CURRENCY 'CUR' LEFT-JUSTIFIED,
80(01) SY-VLINE,
/05(80) SY-ULINE,

*--- 3 a Monthly Settlement Periods
/05(01) SY-VLINE,
08(05) '3. a)'(033),
13(01) SY-VLINE,
15(40) 'Monthly Settlement Periods'(028),
63(01) SY-VLINE,
65(04) V_STL_PRD,'hrs'(029),
80(01) SY-VLINE,
/05(80) SY-ULINE,

*--- 3 b Force Majeure Settlement Periods
/05(01) SY-VLINE,
08(05) ' b)'(025),
13(01) SY-VLINE,
15(40) 'Force Majeure Settlement Periods'(030),
63(01) SY-VLINE,
65(04) 'Nil'(031),
80(01) SY-VLINE,
/05(80) SY-ULINE,

*--- 3 c Billed Settlement Periods
/05(01) SY-VLINE,
08(05) ' c)'(026),
13(01) SY-VLINE,
15(40) 'Billed Settlement Periods'(032),
63(01) SY-VLINE,
65(04) V_STL_PRD,'hrs'(029),
80(01) SY-VLINE,
/05(80) SY-ULINE,

*--- 4 a Due Date of payment
/05(01) SY-VLINE,
08(05) '4. a)'(034),
13(01) SY-VLINE,
15(30) 'Due Date of payment'(035),
63(01) SY-VLINE,
65(10) BILL_DATE,
80(01) SY-VLINE,
/05(80) SY-ULINE,

*--- 4 b 2.5% Rebate if payment made by date
/05(01) SY-VLINE,
08(05) ' b)'(025),
13(01) SY-VLINE,
15(40) '2.5% Rebate if payment made by date'(036),
63(01) SY-VLINE,
65(10) PAY_DATE,
80(01) SY-VLINE,
/05(80) SY-ULINE,

*--- 4 c 1% Rebate if payment made by date
/05(01) SY-VLINE,
08(05) ' c)'(026),
13(01) SY-VLINE,
15(40) '1% Rebate if payment made by date'(037),
63(01) SY-VLINE,
65(10) BILL_DATE,
80(01) SY-VLINE,
/05(80) SY-ULINE,

*--- 4 d Late Charges interest if payment made after date
/05(01) SY-VLINE,
08(05) ' d)'(038),
13(01) SY-VLINE,
15(48) 'Late Charges interest if payment made after date'(039),
63(01) SY-VLINE,
65(10) BILL_DATE,
80(01) SY-VLINE,
/05(80) SY-ULINE,

*--- Abstract Of Charges
/05(80) SY-ULINE,
/05(01) SY-VLINE,
36(22) 'ABSTRACT OF CHARGES'(040) COLOR 4,
80(01) SY-VLINE,
/05(80) SY-ULINE.
LV_SERIAL = 1.

IF V_TOT_FDSC <> 0.
LV_CHAR = LV_SERIAL.
*-- Condense Capacity Charges # FDSC
CONDENSE LV_CHAR.
*--- 1 Capacity Charges # FDSC
WRITE: /05(01) SY-VLINE,
08(03) LV_CHAR ,
13(01) SY-VLINE,
15(40) 'Capacity Charges # FDSC'(041),
63(01) SY-VLINE,
65(16) V_TOT_FDSC CURRENCY 'CUR' LEFT-JUSTIFIED,
80(01) SY-VLINE,
/05(80) SY-ULINE.
LV_SERIAL = LV_SERIAL + 1.
ENDIF.

IF V_TOT_OFC <> 0.
LV_CHAR = LV_SERIAL.
*-- Condense Capacity Charges # OFC
CONDENSE LV_CHAR.
*--- 2 Capacity Charges # OFC
WRITE: /05(01) SY-VLINE,
08(03) LV_CHAR,
13(01) SY-VLINE,
15(40) 'Capacity Charges # OFC'(042),
63(01) SY-VLINE,
65(16) V_TOT_OFC CURRENCY 'CUR' LEFT-JUSTIFIED,
80(01) SY-VLINE,
/05(80) SY-ULINE.
LV_SERIAL = LV_SERIAL + 1.
ENDIF.

IF V_TOT_ENRG_CHG <> 0.
LV_CHAR = LV_SERIAL.
*-- Condense Energy Charges
CONDENSE LV_CHAR.
*--- 3. Energy Charges
WRITE: /05(01) SY-VLINE,
08(03) LV_CHAR,
13(01) SY-VLINE,
15(40) 'Energy Charges'(043),
63(01) SY-VLINE,
65(16) V_TOT_ENRG_CHG CURRENCY 'CUR' RIGHT-JUSTIFIED,
80(01) SY-VLINE,
/05(80) SY-ULINE.
LV_SERIAL = LV_SERIAL + 1.
ENDIF.

IF V_ADJ_FDSC <> 0.
LV_CHAR = LV_SERIAL.
*-- Condense Adjustment for FDSC
CONDENSE LV_CHAR.
*--- 4 Adjustment for FDSC of Bill No. 66
WRITE: /05(01) SY-VLINE,
08(03) LV_CHAR,
13(01) SY-VLINE,
15(31) 'Adjustment for FDSC of Bill No.'(045),
46(10) V_VBELN LEFT-JUSTIFIED,
63(01) SY-VLINE,
65(16) V_ADJ_FDSC CURRENCY 'CUR' LEFT-JUSTIFIED,
80(01) SY-VLINE,
/05(80) SY-ULINE.
ENDIF.
*--- Total
WRITE: /05(01) SY-VLINE,
13(01) SY-VLINE,
15(07) 'Total'(046) COLOR 4,
63(01) SY-VLINE,
65(16) V_TOTAL CURRENCY 'CUR' LEFT-JUSTIFIED COLOR 4 ,
80(01) SY-VLINE,
/05(80) SY-ULINE.

*--- Total in words.
DATA: V_LEN(2) TYPE N VALUE 72.
IF V_TOTAL_WORDS+72(1) = SPACE.
VAR1 = V_TOTAL_WORDS+0(72).
VAR2 = V_TOTAL_WORDS+72(72).
ELSE.
DO.
V_LEN = V_LEN - 1.
IF V_TOTAL_WORDS+V_LEN(1) = SPACE.
VAR1 = V_TOTAL_WORDS+0(V_LEN).
VAR2 = V_TOTAL_WORDS+V_LEN(72).
EXIT.
ENDIF.
ENDDO.
ENDIF.
*--- Display Total in words.
WRITE: /05(01) SY-VLINE,
07 VAR1,
80(01) SY-VLINE,
/05(01) SY-VLINE,
07 VAR2,
80(01) SY-VLINE,
/05(01) SY-VLINE,
80(01) SY-VLINE,
/05(80) SY-ULINE.

ENDFORM. " DISPLAY_REPORT

*&---------------------------------------------------------------------*
*& Form BILL_SETTLE_DATE
*&---------------------------------------------------------------------*
* To Obtain The Bill Settlement Dates
*----------------------------------------------------------------------*
FORM BILL_SETTLE_DATE.

*--- Concatenation to generate Bill Settlement Dates
CONCATENATE '15'(061) BILL_MONTH BILL_YEAR INTO PAY_DATE SEPARATED BY '-'(062).
IF BILL_MONTH = '12'(063).
BILL_MONTH = '01'(064).
BILL_YEAR = BILL_YEAR + 1.
CONCATENATE '10'(065) BILL_MONTH BILL_YEAR INTO BILL_DATE SEPARATED BY '-'(062).
ELSE.
BILL_MONTH = BILL_MONTH + 1.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = BILL_MONTH
IMPORTING
OUTPUT = BILL_MONTH.

CONCATENATE '10'(065) BILL_MONTH BILL_YEAR INTO BILL_DATE SEPARATED BY '-'(062).

ENDIF.
ENDFORM. " BILL_SETTLE_DATE

*&---------------------------------------------------------------------*
*& Form CONVERT_TOTAL
*&---------------------------------------------------------------------*
* To get Changes of INR amount to words
*----------------------------------------------------------------------*
FORM CONVERT_TOTAL USING F_TOTAL
CHANGING F_TOTAL_WORDS.

CALL FUNCTION 'HR_IN_CHG_INR_WRDS'
EXPORTING
AMT_IN_NUM = F_TOTAL
IMPORTING
AMT_IN_WORDS = F_TOTAL_WORDS.
* EXCEPTIONS
* DATA_TYPE_MISMATCH = 1
* OTHERS = 2

ENDFORM. " CONVERT_TOTAL

*&---------------------------------------------------------------------*
*& Form GET_MONTH_NAME
*&---------------------------------------------------------------------*
* To get Names of the month
*----------------------------------------------------------------------*
FORM GET_MONTH_NAME USING F_MONTH.

DATA: RET_CODE LIKE SY-SUBRC.

CLEAR V_MONTHNAME.
CALL FUNCTION 'MONTH_NAMES_GET'
EXPORTING
LANGUAGE = SY-LANGU
IMPORTING
RETURN_CODE = RET_CODE
TABLES
MONTH_NAMES = IT_MONTHS.
IF SY-SUBRC <> 0. "#EC *
*--- Do Nothing
ENDIF.

IF RET_CODE = 0.
*--- Read table IT_MONTHS to get the Language and the month
READ TABLE IT_MONTHS WITH KEY SPRAS = SY-LANGU
MNR = F_MONTH.
IF SY-SUBRC = 0.
V_MONTHNAME = IT_MONTHS-LTX.
ENDIF.
ENDIF.

ENDFORM. " GET_MONTH_NAME
*&---------------------------------------------------------------------*
*& Form GET_DAYS_DIFF
*&---------------------------------------------------------------------*
* To get No. of days between From & To Dates
*----------------------------------------------------------------------*

FORM GET_DAYS_DIFF USING F_BP_FROM
F_BP_TO.

CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
EXPORTING
I_DATE_FROM = F_BP_FROM
I_DATE_TO = F_BP_TO
* I_FLG_SEPARATE = ' '
IMPORTING
E_DAYS = V_DAYS.

ENDFORM. " GET_DAYS_DIFF
*&---------------------------------------------------------------------*
*& Form Footer
*&---------------------------------------------------------------------*
* To get the Footer Message
*----------------------------------------------------------------------*
FORM FOOTER .
DATA: LV_FLAG.
**--- Display the Footer Text
NEW-PAGE.
SKIP.
WRITE:/05 ' Note:'(047).

WRITE:/05 ' 1) Taxes, Cess, Duties, Levies, etc, if any, applicable on the above bill'(048),
' will be claimed separately by the way of Supplementary Bill.'(049).

WRITE:/05 ' 2) Energy Charges are computed based on "Provisional Price" of Gas'(050),
' charged by GAIL.Any subsequent revision in Gas Price with'(051),
' retrospective effect will be claimed separately.'(052).


WRITE:/05 ' 3) In view of APTRANSCO’s letter N O.CE/IPC/ADE-2/F.Ravvasate/D.No. 52/03'(053),
' dated 07-04-2003, the gas supplies from Ravva Satellite Field'(054),
' to our plant are at the revised prices w.e.f. 15.04.02003.'(055),
' Energy Charges are computed accordingly.'(068).


WRITE:/05 ' 4) Government of India vide its letter L-12015/5/04-gp(I)dt. 20-06-2005'(056),
' has revised the APM price of natural gas w.e.f. 01-07-2005 to'(057),
' Rs.3200/1000 scm against the earlier price ofRs.2850/1000 scm.'(058),
' Energy Charges are computed accordingly.'(069).
SKIP.
WRITE:/05 'For Lanco Kondapalli Power Private Limited'(059) COLOR 4.

SKIP 4.
WRITE:/05 'AUTHORISED SIGNATORY'(060) COLOR 4.

ENDFORM. " Footer

No comments: