*&---------------------------------------------------------------------*
*& Report Z_HRA
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT Z_HRA.
tables: pa0000, pa0001.
parameters: p_chk1 as checkbox user-command rusr,
p_chk2 as checkbox user-command rusr,
p_chk3 as checkbox user-command rusr,
p_chk4 as checkbox user-command rusr,
p_chk5 as checkbox user-command rusr.
selection-screen: begin of block blk1 with frame.
select-options: s_pernr for pa0000-pernr modif id ABC no-extension no intervals,
s_stat2 for pa0000-stat2 modif id DEF,
s_werks for pa0001-werks modif id GHI,
s_persg for pa0001-persg modif id JKL,
s_persk for pa0001-persk modif id MNO.
selection-screen: end of block blk1.
AT SELECTION-SCREEN output.
LOOP AT SCREEN.
IF SCREEN-GROUP1 = 'ABC'.
IF p_chk1 = 'X'.
SCREEN-ACTIVE = 1.
ELSE.
SCREEN-ACTIVE = 0.
ENDIF.
MODIFY SCREEN.
ENDIF.
IF SCREEN-GROUP1 = 'DEF'.
IF p_chk2 = 'X'.
SCREEN-ACTIVE = 1.
ELSE.
SCREEN-ACTIVE = 0.
ENDIF.
MODIFY SCREEN.
ENDIF.
IF SCREEN-GROUP1 = 'GHI'.
IF p_chk3 = 'X'.
SCREEN-ACTIVE = 1.
ELSE.
SCREEN-ACTIVE = 0.
ENDIF.
MODIFY SCREEN.
ENDIF.
IF SCREEN-GROUP1 = 'JKL'.
IF p_chk4 = 'X'.
SCREEN-ACTIVE = 1.
ELSE.
SCREEN-ACTIVE = 0.
ENDIF.
MODIFY SCREEN.
ENDIF.
IF SCREEN-GROUP1 = 'MNO'.
IF p_chk5 = 'X'.
SCREEN-ACTIVE = 1.
ELSE.
SCREEN-ACTIVE = 0.
ENDIF.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
*Titles for check boxes and select options
*P_CHK1 Personal Number
*P_CHK2 Employment Status
*P_CHK3 Personnel Area
*P_CHK4 Employee Group
*P_CHK5 Employee Sub group
*S_PERNR Personal Number
*S_PERSG Employee Group
*S_PERSK Employee Sub group
*S_STAT2 Employment Status
*S_WERKS Personnel Area
Thursday, November 15, 2007
Thursday, November 8, 2007
SNRO Number Range Object - Step by Step
Go to transaction SNRO (Simple way to remember is SapNumberRangeObject).
2. Enter the number range object name and press CREATE.
3. Enter the description, Long text and Number Length domain andWarning % as shown below
3. Enter the description, Long text and Number Length domain andWarning % as shown below
Warning: Assume that an interval is defined from 1 to 1000. If you want to issue a warning at the number 900, enter 10 (%) here.
4. Press SAVE. You would get a prompt as shown below:
4. Press SAVE. You would get a prompt as shown below:
5. Press YES and assign the object to a local class.
6. Now click on “Number Ranges” button on the application toolbar.
7. Click on “Change Intervals”.
8. Click on “Insert Interval”.
9. Enter the values as shown below:
Try this Demo program:
*&---------------------------------------------------------------------*
*& Report ZGURU_SNRO_DEMO
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZGURU_SNRO_DEMO.
DATA:
NUMBER TYPE I.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = '01'
object = 'ZDEMO'
IMPORTING
NUMBER = NUMBER
EXCEPTIONS
INTERVAL_NOT_FOUND = 1
NUMBER_RANGE_NOT_INTERN = 2
OBJECT_NOT_FOUND = 3
QUANTITY_IS_0 = 4
QUANTITY_IS_NOT_1 = 5
INTERVAL_OVERFLOW = 6
BUFFER_OVERFLOW = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Write :/ 'Next Range Number is: ', Number.
Monday, November 5, 2007
Interactive Using REUSE_ALV_HIERSEQ_LIST_DISPLAY
REPORT Z_FI_RP_PROFIT_CENTER_DOCS NO STANDARD PAGE HEADING
MESSAGE-ID Z_MSGCLASS.
************************************************************************
* Program Name : Z_FI_RP_PROFIT_CENTER_DOCS *
* Description : This program displays the Accounting documents *
* and their corresponding line items based on the *
* posting keys. *
* 1. Accouting Document *
* 2. Company code *
* 3. Fiscal Year *
* 4. Document date *
* 5. Posting date *
* 6. User name *
* Functional : *
* Developer : *
* Development class : *
* *
************************************************************************
*----------------------------------------------------------------------*
* Request No. Created Date Developer name *
*----------------------------------------------------------------------*
* LD1K900601 15/07/2007
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* TYPE-POOLS *
*----------------------------------------------------------------------*
TYPE-POOLS: SLIS. " ALV Global types
*----------------------------------------------------------------------*
* TABLES *
*----------------------------------------------------------------------*
TABLES: BKPF,
FAGLFLEXA.
*---------------------------------------------------------------------*
* DATA DECLARATIONS *
*---------------------------------------------------------------------*
DATA:LS_LAYOUT TYPE SLIS_LAYOUT_ALV,
LS_KEYINFO TYPE SLIS_KEYINFO_ALV,
LS_SORT TYPE SLIS_SORTINFO_ALV,
LT_SORT TYPE SLIS_T_SORTINFO_ALV," Sort table
LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV," Field catalog
GT_SORT TYPE SLIS_T_SORTINFO_ALV.
DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
DATA:FCAT TYPE slis_t_fieldcat_alv.
DATA:LAYOUT TYPE slis_layout_alv.
DATA:EVENT TYPE slis_t_event WITH HEADER LINE.
DATA:HEAD TYPE slis_t_listheader WITH HEADER LINE.
DATA:ITEM TYPE slis_t_listheader WITH HEADER LINE.
DATA:SORT TYPE slis_t_sortinfo_alv WITH HEADER LINE.
*---------------------------------------------------------------------*
* CONSTANTS *
*---------------------------------------------------------------------*
CONSTANTS :C_X TYPE C VALUE 'X',
C_IT_HEAD TYPE SLIS_TABNAME VALUE 'IT_HEAD',
C_IT_ITEM TYPE SLIS_TABNAME VALUE 'IT_ITEM',
C_K TYPE C VALUE 'K',
C_D TYPE C VALUE 'D',
C_BLN(03) TYPE C VALUE 'BLN',
C_BUK(03) TYPE C VALUE 'BUK',
C_GJR(03) TYPE C VALUE 'GJR',
C_FB03(04) TYPE C VALUE 'FB03'.
CONSTANTS:GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
*---------------------------------------------------------------------*
* INTERNAL TABLE DECLARATIONS *
*---------------------------------------------------------------------*
*--- Internal table declaration to hold the Accounting Document Header data
DATA: BEGIN OF IT_BKPF OCCURS 0,
BUKRS LIKE BKPF-BUKRS,
BELNR LIKE BKPF-BELNR,
GJAHR LIKE BKPF-GJAHR,
BLDAT LIKE BKPF-BLDAT,
BUDAT LIKE BKPF-BUDAT,
cpudt like bkpf-cpudt,
USNAM LIKE BKPF-USNAM,
END OF IT_BKPF.
*--- Internal table declaration to hold the General Ledger: Actual Line Items
DATA: BEGIN OF IT_FAGLFLEXA OCCURS 0,
DOCNR LIKE FAGLFLEXA-DOCNR,
BUDAT LIKE FAGLFLEXA-BUDAT,
RYEAR LIKE FAGLFLEXA-RYEAR,
RBUKRS LIKE FAGLFLEXA-RBUKRS,
PRCTR LIKE FAGLFLEXA-PRCTR,
BUZEI LIKE FAGLFLEXA-BUZEI,
TSL LIKE FAGLFLEXA-TSL,
HSL LIKE FAGLFLEXA-HSL,
DRCRK LIKE FAGLFLEXA-DRCRK,
BSCHL LIKE FAGLFLEXA-BSCHL,
RMVCT LIKE FAGLFLEXA-RMVCT,
RTCUR LIKE FAGLFLEXA-RTCUR,
RCNTR LIKE FAGLFLEXA-RCNTR,
KOKRS LIKE FAGLFLEXA-KOKRS,
SEGMENT LIKE FAGLFLEXA-SEGMENT,
RASSC LIKE FAGLFLEXA-RASSC,
POPER LIKE FAGLFLEXA-POPER,
BSTAT LIKE FAGLFLEXA-BSTAT,
USNAM LIKE FAGLFLEXA-USNAM,
END OF IT_FAGLFLEXA.
*--- Internal table declaration to hold the Posting Keys
DATA: BEGIN OF IT_TBSL OCCURS 0,
BSCHL LIKE TBSL-BSCHL,
KOART LIKE TBSL-KOART,
END OF IT_TBSL.
*--- Internal table declaration to hold Accounting: Secondary Index for Vendors
DATA: BEGIN OF IT_BSIK OCCURS 0,
BUKRS LIKE BSIK-BUKRS,
LIFNR LIKE BSIK-LIFNR,
UMSKZ LIKE BSIK-UMSKZ,
GJAHR LIKE BSIK-GJAHR,
BELNR LIKE BSIK-BELNR,
BUZEI LIKE BSIK-BUZEI,
END OF IT_BSIK.
*--- Internal table declaration to hold Accounting: Secondary Index for Vendors (Cleared Items)
DATA: BEGIN OF IT_BSAK OCCURS 0,
BUKRS LIKE BSAK-BUKRS,
LIFNR LIKE BSAK-LIFNR,
UMSKZ LIKE BSAK-UMSKZ,
GJAHR LIKE BSAK-GJAHR,
BELNR LIKE BSAK-BELNR,
BUZEI LIKE BSAK-BUZEI,
END OF IT_BSAK.
*--- Internal table declaration to hold Accounting: Secondary Index for Customers
DATA: BEGIN OF IT_BSID OCCURS 0,
BUKRS LIKE BSID-BUKRS,
KUNNR LIKE BSID-KUNNR,
UMSKZ LIKE BSID-UMSKZ,
GJAHR LIKE BSID-GJAHR,
BELNR LIKE BSID-BELNR,
BUZEI LIKE BSID-BUZEI,
END OF IT_BSID.
*--- Internal table declaration to hold Accounting: Secondary Index for Customers (Cleared Items)
DATA: BEGIN OF IT_BSAD OCCURS 0,
BUKRS LIKE BSAD-BUKRS,
KUNNR LIKE BSAD-KUNNR,
UMSKZ LIKE BSAD-UMSKZ,
GJAHR LIKE BSAD-GJAHR,
BELNR LIKE BSAD-BELNR,
BUZEI LIKE BSAD-BUZEI,
END OF IT_BSAD.
*--- Internal table declaration to hold Accounting: Secondary Index for G/L Accounts
DATA: BEGIN OF IT_BSIS OCCURS 0,
BUKRS LIKE BSIS-BUKRS,
HKONT LIKE BSIS-HKONT,
GJAHR LIKE BSIS-GJAHR,
BELNR LIKE BSIS-BELNR,
BUZEI LIKE BSIS-BUZEI,
END OF IT_BSIS.
*--- Internal table declaration to hold Accounting: Secondary Index for G/L Accounts (Cleared Items)
DATA: BEGIN OF IT_BSAS OCCURS 0,
BUKRS LIKE BSAS-BUKRS,
HKONT LIKE BSAS-HKONT,
GJAHR LIKE BSAS-GJAHR,
BELNR LIKE BSAS-BELNR,
BUZEI LIKE BSAS-BUZEI,
END OF IT_BSAS.
*--- Internal table to hold the Header data
DATA: BEGIN OF IT_HEAD OCCURS 0,
BUKRS LIKE BKPF-BUKRS,
BELNR LIKE BKPF-BELNR,
GJAHR LIKE BKPF-GJAHR,
BLDAT LIKE BKPF-BLDAT,
BUDAT LIKE BKPF-BUDAT,
cpudt like bkpf-cpudt,
USNAM LIKE BKPF-USNAM,
END OF IT_HEAD.
*--- Internal table to hold the Item data
DATA: BEGIN OF IT_ITEM OCCURS 0.
INCLUDE STRUCTURE IT_FAGLFLEXA.
DATA: LIFNR LIKE BSIK-LIFNR,
UMSKZ LIKE BSIK-UMSKZ,
KUNNR LIKE BSID-KUNNR,
HKONT LIKE BSIS-HKONT,
*DATA: ACCNT_NUM(10) TYPE C,
ACCNT_NAME LIKE SKAT-TXT50,
END OF IT_ITEM.
*--- Internal table to hold Vendor descriptions
DATA: BEGIN OF IT_LFA1 OCCURS 0,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
END OF IT_LFA1.
*--- Internal table to hold Customer descriptions
DATA: BEGIN OF IT_KNA1 OCCURS 0,
KUNNR LIKE KNA1-KUNNR,
NAME1 LIKE KNA1-NAME1,
END OF IT_KNA1.
*--- Internal table to hold GL descriptions
DATA: BEGIN OF IT_SKAT OCCURS 0,
SAKNR LIKE SKAT-SAKNR,
TXT50 LIKE SKAT-TXT50,
END OF IT_SKAT.
*---------------------------------------------------------------------*
* SELECTION-SCREEN *
*---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK SCLSCR1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_BUKRS FOR BKPF-BUKRS OBLIGATORY NO-EXTENSION, " Company Code
S_BELNR FOR BKPF-BELNR, " Accounting Document Number
S_GJAHR FOR BKPF-GJAHR OBLIGATORY NO-EXTENSION, " Fiscal Year
S_BLART FOR BKPF-BLART, " Document Type
S_BLDAT FOR BKPF-BLDAT, " Document Date in Document
S_BUDAT FOR BKPF-BUDAT, " Posting Date in the Document
s_cpudt for bkpf-cpudt,
S_USNAM FOR BKPF-USNAM NO-EXTENSION, " User Name
S_PRCTR FOR FAGLFLEXA-PRCTR OBLIGATORY. " Profit Center
SELECTION-SCREEN END OF BLOCK SCLSCR1.
*---------------------------------------------------------------------*
* AT SELECTION-SCREEN *
*---------------------------------------------------------------------*
AT SELECTION-SCREEN ON S_BUKRS.
*--- Perform to validate Company code
PERFORM VALIDATE_BUKRS.
AT SELECTION-SCREEN ON S_BELNR.
*--- Perform to validate Accounting Document Number
PERFORM VALIDATE_BELNR.
AT SELECTION-SCREEN ON S_GJAHR.
*--- Perform to validate Fiscal Year
PERFORM VALIDATE_GJAHR.
AT SELECTION-SCREEN ON S_BLART.
*--- Perform to validate Document Type
PERFORM VALIDATE_BLART.
AT SELECTION-SCREEN ON S_USNAM.
*--- Perform to validate User Name
PERFORM VALIDATE_USNAM.
AT SELECTION-SCREEN ON S_PRCTR.
*--- Perform to validate User Name
PERFORM VALIDATE_PRCTR.
*---------------------------------------------------------------------*
* TOP-OF-PAGE *
*---------------------------------------------------------------------*
TOP-OF-PAGE.
*---------------------------------------------------------------------*
* START-OF-SELECTION *
*---------------------------------------------------------------------*
START-OF-SELECTION.
*--- Perform to get the Accounting Document Header data
PERFORM GET_BKPF_DATA.
*--- Perform to get the General Ledger: Actual Line Items
PERFORM GET_FAGLFLEXA_DATA.
*--- Perform to get the Posting Keys
PERFORM GET_TBSL_DATA.
*--- Perform to get the Account Information based on Posting key
PERFORM GET_ACCOUNT_INFO.
*--- Perform to get the Vendor Descriptions
PERFORM GET_LFA1_DATA.
*--- Perform to get the Customer Descriptions
PERFORM GET_KNA1_DATA.
*--- Perform to get the GL Descriptions
PERFORM GET_SKAT_DATA.
*---------------------------------------------------------------------*
* END-OF-SELECTION *
*---------------------------------------------------------------------*
END-OF-SELECTION.
*--- Perform to get the Output data
PERFORM GET_OUTPUT.
*--- Perform to Build the fieldcat to display the output in ALV format
PERFORM BUILD_FIELDCAT_ALV.
*--- Perform to display the Hierarchial ALV List
PERFORM DISPLAY_ALV_OUTPUT.
*&---------------------------------------------------------------------*
*& Form GET_BKPF_DATA
*&---------------------------------------------------------------------*
* To get the Accounting Document Header data
*----------------------------------------------------------------------*
FORM GET_BKPF_DATA.
*--- Select construct to get the Accounting Document Header data
SELECT BUKRS BELNR GJAHR BLDAT BUDAT cpudt USNAM
FROM BKPF
INTO TABLE IT_BKPF
WHERE BUKRS IN S_BUKRS
AND BELNR IN S_BELNR
AND GJAHR IN S_GJAHR
AND BLART IN S_BLART
AND BLDAT IN S_BLDAT
AND BUDAT IN S_BUDAT
and cpudt in s_cpudt
AND USNAM IN S_USNAM.
IF SY-SUBRC = 0.
SORT IT_BKPF BY BELNR.
ELSE.
*--- Display message if an invalid Profit Center is entered
MESSAGE S002(Z_MSGCLASS)
WITH 'No data exists with selection criteria'.
ENDIF.
ENDFORM. " GET_BKPF_DATA
*&---------------------------------------------------------------------*
*& Form GET_FAGLFLEXA_DATA
*&---------------------------------------------------------------------*
* To get the General Ledger: Actual Line Items
*----------------------------------------------------------------------*
FORM GET_FAGLFLEXA_DATA .
IF NOT IT_BKPF[] IS INITIAL.
*--- Select construct to get the General Ledger: Actual Line Items
SELECT DOCNR " Document NUmber
BUDAT " Posting Date
RYEAR " Fiscal Year
RBUKRS " Company code
PRCTR " Profit center
BUZEI " Line Item
TSL " Value in Transaction Currency
HSL " Value in Local Currency
DRCRK " Debit/Credit Indicator
BSCHL " Posting Key
RMVCT " Transaction Type
RTCUR " Currency Key
RCNTR " Cost Center
KOKRS " Controlling Area
SEGMENT " Segment for Segmental Reporting
RASSC " Company ID of trading partner
POPER " Posting period
BSTAT " Document status
USNAM " User name
FROM FAGLFLEXA
INTO TABLE IT_FAGLFLEXA
FOR ALL ENTRIES IN IT_BKPF
WHERE RYEAR = IT_BKPF-GJAHR
AND DOCNR = IT_BKPF-BELNR
AND RBUKRS = IT_BKPF-BUKRS
AND PRCTR IN S_PRCTR.
IF SY-SUBRC = 0.
SORT IT_FAGLFLEXA BY DOCNR.
ENDIF.
ENDIF.
ENDFORM. " GET_FAGLFLEXA_DATA
*&---------------------------------------------------------------------*
*& Form GET_TBSL_DATA
*&---------------------------------------------------------------------*
* To get the Posting Keys
*----------------------------------------------------------------------*
FORM GET_TBSL_DATA.
IF NOT IT_FAGLFLEXA[] IS INITIAL.
*--- Select construct to get the Posting keys
SELECT BSCHL KOART
FROM TBSL
INTO TABLE IT_TBSL
FOR ALL ENTRIES IN IT_FAGLFLEXA
WHERE BSCHL = IT_FAGLFLEXA-BSCHL.
IF SY-SUBRC = 0.
ENDIF.
ENDIF.
ENDFORM. " GET_TBSL_DATA
*&---------------------------------------------------------------------*
*& Form GET_ACCOUNT_INFO
*&---------------------------------------------------------------------*
* To get the Vendor/Customer/GL Account Information
*----------------------------------------------------------------------*
FORM GET_ACCOUNT_INFO .
*--- Loop to get the Vendor, Customer, G/L related data based on posting key
LOOP AT IT_TBSL.
*--- If posting key relates to Vendor
IF IT_TBSL-KOART = C_K.
PERFORM GET_BSIK_DATA.
*--- If posting key relates to Customer
ELSEIF IT_TBSL-KOART = C_D.
PERFORM GET_BSID_DATA.
*--- If posting key relates to G/L
ELSE.
PERFORM GET_BSIS_DATA.
ENDIF.
ENDLOOP.
ENDFORM. " GET_ACCOUNT_INFO
*&---------------------------------------------------------------------*
*& Form GET_BSIK_DATA
*&---------------------------------------------------------------------*
* To get the Vendor data
*----------------------------------------------------------------------*
FORM GET_BSIK_DATA .
IF NOT IT_FAGLFLEXA[] IS INITIAL.
*--- Select construct to get the Vendor and document number from BSIK
SELECT BUKRS LIFNR UMSKZ GJAHR BELNR BUZEI
FROM BSIK
INTO TABLE IT_BSIK
FOR ALL ENTRIES IN IT_FAGLFLEXA
WHERE BUKRS = IT_FAGLFLEXA-RBUKRS
AND GJAHR = IT_FAGLFLEXA-RYEAR
AND BELNR = IT_FAGLFLEXA-DOCNR
AND BUZEI = IT_FAGLFLEXA-BUZEI.
IF SY-SUBRC <> 0.
*--- If document does not exist in BSIK get from BSAK
*--- Select construct to get the Vendor and document number from BSIK
SELECT BUKRS LIFNR UMSKZ GJAHR BELNR BUZEI
FROM BSAK
INTO TABLE IT_BSAK
FOR ALL ENTRIES IN IT_FAGLFLEXA
WHERE BUKRS = IT_FAGLFLEXA-RBUKRS
AND GJAHR = IT_FAGLFLEXA-RYEAR
AND BELNR = IT_FAGLFLEXA-DOCNR
AND BUZEI = IT_FAGLFLEXA-BUZEI.
ENDIF.
ENDIF.
ENDFORM. " GET_BSIK_DATA
*&---------------------------------------------------------------------*
*& Form GET_BSID_DATA
*&---------------------------------------------------------------------*
* To get the Customer data
*----------------------------------------------------------------------*
FORM GET_BSID_DATA .
IF NOT IT_FAGLFLEXA[] IS INITIAL.
*--- Select construct to get the Vendor and document number from BSID
SELECT BUKRS KUNNR UMSKZ GJAHR BELNR BUZEI
FROM BSID
INTO TABLE IT_BSID
FOR ALL ENTRIES IN IT_FAGLFLEXA
WHERE BUKRS = IT_FAGLFLEXA-RBUKRS
AND GJAHR = IT_FAGLFLEXA-RYEAR
AND BELNR = IT_FAGLFLEXA-DOCNR
AND BUZEI = IT_FAGLFLEXA-BUZEI.
IF SY-SUBRC <> 0.
*--- If document does not exist in BSID get from BSAD
*--- Select construct to get the Vendor and document number from BSAD
SELECT BUKRS KUNNR UMSKZ GJAHR BELNR BUZEI
FROM BSAD
INTO TABLE IT_BSAD
FOR ALL ENTRIES IN IT_FAGLFLEXA
WHERE BUKRS = IT_FAGLFLEXA-RBUKRS
AND GJAHR = IT_FAGLFLEXA-RYEAR
AND BELNR = IT_FAGLFLEXA-DOCNR
AND BUZEI = IT_FAGLFLEXA-BUZEI.
ENDIF.
ENDIF.
ENDFORM. " GET_BSID_DATA
*&---------------------------------------------------------------------*
*& Form GET_BSIS_DATA
*&---------------------------------------------------------------------*
* To get the G/L data
*----------------------------------------------------------------------*
FORM GET_BSIS_DATA .
IF NOT IT_FAGLFLEXA[] IS INITIAL.
*--- Select construct to get the Vendor and document number from BSID
SELECT BUKRS HKONT GJAHR BELNR BUZEI
FROM BSIS
INTO TABLE IT_BSIS
FOR ALL ENTRIES IN IT_FAGLFLEXA
WHERE BUKRS = IT_FAGLFLEXA-RBUKRS
AND GJAHR = IT_FAGLFLEXA-RYEAR
AND BELNR = IT_FAGLFLEXA-DOCNR
AND BUZEI = IT_FAGLFLEXA-BUZEI.
IF SY-SUBRC <> 0.
*--- If document does not exist in BSID get from BSAD
*--- Select construct to get the Vendor and document number from BSAD
SELECT BUKRS HKONT GJAHR BELNR BUZEI
FROM BSAS
INTO TABLE IT_BSAS
FOR ALL ENTRIES IN IT_FAGLFLEXA
WHERE BUKRS = IT_FAGLFLEXA-RBUKRS
AND GJAHR = IT_FAGLFLEXA-RYEAR
AND BELNR = IT_FAGLFLEXA-DOCNR
AND BUZEI = IT_FAGLFLEXA-BUZEI.
ENDIF.
ENDIF.
ENDFORM. " GET_BSIS_DATA
*&---------------------------------------------------------------------*
*& Form GET_LFA1_DATA
*&---------------------------------------------------------------------*
* To get the Vendor Descriptions
*----------------------------------------------------------------------*
FORM GET_LFA1_DATA.
IF NOT IT_BSIK[] IS INITIAL.
*--- Select construct to get the Vendor Names
SELECT LIFNR NAME1
FROM LFA1
INTO TABLE IT_LFA1
FOR ALL ENTRIES IN IT_BSIK
WHERE LIFNR = IT_BSIK-LIFNR.
IF SY-SUBRC <> 0.
ENDIF.
ENDIF.
ENDFORM. " GET_LFA1_DATA
*&---------------------------------------------------------------------*
*& Form GET_KNA1_DATA
*&---------------------------------------------------------------------*
* To get the Customer descriptions
*----------------------------------------------------------------------*
FORM GET_KNA1_DATA .
IF NOT IT_BSID[] IS INITIAL.
*--- Select construct to get the Vendor Names
SELECT KUNNR NAME1
FROM KNA1
INTO TABLE IT_KNA1
FOR ALL ENTRIES IN IT_BSID
WHERE KUNNR = IT_BSID-KUNNR.
IF SY-SUBRC <> 0.
ENDIF.
ENDIF.
ENDFORM. " GET_KNA1_DATA
*&---------------------------------------------------------------------*
*& Form GET_SKAT_DATA
*&---------------------------------------------------------------------*
* To get the GL Descriptions
*----------------------------------------------------------------------*
FORM GET_SKAT_DATA .
IF NOT IT_BSIS[] IS INITIAL.
*--- Select construct to get the GL Account descriptions
SELECT SAKNR TXT50
FROM SKAT
INTO TABLE IT_SKAT
FOR ALL ENTRIES IN IT_BSIS
WHERE SAKNR = IT_BSIS-HKONT
AND SPRAS = 'EN'.
if sy-subrc <> 0.
endif.
ENDIF.
ENDFORM. " GET_SKAT_DATA
*&---------------------------------------------------------------------*
*& Form GET_OUTPUT
*&---------------------------------------------------------------------*
* To get the Output data
*----------------------------------------------------------------------*
FORM GET_OUTPUT.
DATA: L_LIFNR LIKE BSIK-LIFNR,
L_KUNNR LIKE BSID-KUNNR,
L_SAKNR LIKE SKAT-SAKNR.
DATA: FG_DOC TYPE C.
LOOP AT IT_BKPF.
FG_DOC = SPACE.
LOOP AT IT_FAGLFLEXA WHERE DOCNR = IT_BKPF-BELNR.
*--- Get the documents pertaining to profit center
IF FG_DOC = SPACE.
IT_HEAD-BUKRS = IT_BKPF-BUKRS.
IT_HEAD-BELNR = IT_BKPF-BELNR.
IT_HEAD-GJAHR = IT_BKPF-GJAHR.
IT_HEAD-BLDAT = IT_BKPF-BLDAT.
IT_HEAD-BUDAT = IT_BKPF-BUDAT.
it_head-cpudt = it_bkpf-cpudt.
IT_HEAD-USNAM = IT_BKPF-USNAM.
APPEND IT_HEAD.
CLEAR IT_HEAD.
FG_DOC = 'X'.
ENDIF.
IT_ITEM = IT_FAGLFLEXA.
*--- Read tables BSIk or BSAK to get the Vendor data
READ TABLE IT_BSIK WITH KEY BELNR = IT_FAGLFLEXA-DOCNR
BUZEI = IT_FAGLFLEXA-BUZEI.
IF SY-SUBRC = 0.
IT_ITEM-LIFNR = IT_BSIK-LIFNR.
IT_ITEM-UMSKZ = IT_BSIK-UMSKZ.
L_LIFNR = IT_BSIK-LIFNR.
ELSE.
READ TABLE IT_BSAK WITH KEY BELNR = IT_FAGLFLEXA-DOCNR
BUZEI = IT_FAGLFLEXA-BUZEI.
IF SY-SUBRC = 0.
IT_ITEM-LIFNR = IT_BSAK-LIFNR.
IT_ITEM-UMSKZ = IT_BSAK-UMSKZ.
L_LIFNR = IT_BSAK-LIFNR.
ENDIF.
ENDIF.
*---- Get the Vendor description into output table
READ TABLE IT_LFA1 WITH KEY LIFNR = L_LIFNR.
IF SY-SUBRC = 0.
IT_ITEM-ACCNT_NAME = IT_LFA1-NAME1.
ENDIF.
*--- Read tables BSID or BSAD to get the Customer data
READ TABLE IT_BSID WITH KEY BELNR = IT_FAGLFLEXA-DOCNR
BUZEI = IT_FAGLFLEXA-BUZEI.
IF SY-SUBRC = 0.
IT_ITEM-KUNNR = IT_BSID-KUNNR.
IT_ITEM-UMSKZ = IT_BSID-UMSKZ.
L_KUNNR = IT_BSID-KUNNR.
ELSE.
READ TABLE IT_BSAD WITH KEY BELNR = IT_FAGLFLEXA-DOCNR
BUZEI = IT_FAGLFLEXA-BUZEI.
IF SY-SUBRC = 0.
IT_ITEM-KUNNR = IT_BSAD-KUNNR.
IT_ITEM-UMSKZ = IT_BSAD-UMSKZ.
L_KUNNR = IT_BSAD-KUNNR.
ENDIF.
ENDIF.
*---- Get the Customer description into output table
READ TABLE IT_KNA1 WITH KEY KUNNR = L_KUNNR.
IF SY-SUBRC = 0.
IT_ITEM-ACCNT_NAME = IT_KNA1-NAME1.
ENDIF.
*--- Read tables BSIS or BSAS to get the G/L data
READ TABLE IT_BSIS WITH KEY BELNR = IT_FAGLFLEXA-DOCNR
BUZEI = IT_FAGLFLEXA-BUZEI.
IF SY-SUBRC = 0.
L_SAKNR = IT_BSIS-HKONT.
ELSE.
READ TABLE IT_BSAS WITH KEY BELNR = IT_FAGLFLEXA-DOCNR
BUZEI = IT_FAGLFLEXA-BUZEI.
IF SY-SUBRC = 0.
L_SAKNR = IT_BSAS-HKONT.
ENDIF.
ENDIF.
*--- Get the GL Account descrition into Output table
READ TABLE IT_SKAT WITH KEY SAKNR = L_SAKNR.
IF SY-SUBRC = 0.
IT_ITEM-HKONT = L_SAKNR.
IT_ITEM-ACCNT_NAME = IT_SKAT-TXT50.
ENDIF.
APPEND: IT_ITEM.
CLEAR: IT_ITEM,
L_LIFNR,
L_KUNNR,
L_SAKNR.
ENDLOOP.
ENDLOOP.
ENDFORM. " GET_OUTPUT
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCAT_ALV
*&---------------------------------------------------------------------*
* Format and display the output
*----------------------------------------------------------------------*
FORM BUILD_FIELDCAT_ALV .
DATA: LS_SORT TYPE SLIS_SORTINFO_ALV.
*--- Set Layout properties
LS_LAYOUT-GROUP_CHANGE_EDIT = C_X.
LS_LAYOUT-COLWIDTH_OPTIMIZE = SPACE.
LS_LAYOUT-ZEBRA = C_X.
LS_LAYOUT-DETAIL_POPUP = C_X.
LS_LAYOUT-GET_SELINFOS = C_X.
**--- Build field catalog and sort table
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'BELNR'.
s_fieldcatalog-tabname = 'IT_HEAD'.
s_fieldcatalog-rollname = 'BELNR_D'.
s_fieldcatalog-outputlen = '10'.
s_fieldcatalog-SP_GROUP = 'A'.
s_fieldcatalog-EMPHASIZE = 'C71'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'BUKRS'.
s_fieldcatalog-tabname = 'IT_HEAD'.
s_fieldcatalog-rollname = 'BUKRS'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '3'.
s_fieldcatalog-fieldname = 'GJAHR'.
s_fieldcatalog-tabname = 'IT_HEAD'.
s_fieldcatalog-rollname = 'GJAHR'.
s_fieldcatalog-outputlen = '12'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '4'.
s_fieldcatalog-fieldname = 'BLDAT'.
s_fieldcatalog-tabname = 'IT_HEAD'.
s_fieldcatalog-rollname = 'BLDAT'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '5'.
s_fieldcatalog-fieldname = 'BUDAT'.
s_fieldcatalog-tabname = 'IT_HEAD'.
s_fieldcatalog-rollname = 'BUDAT'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '6'.
s_fieldcatalog-fieldname = 'CPUDT'.
s_fieldcatalog-tabname = 'IT_HEAD'.
s_fieldcatalog-rollname = 'CPUDT'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '7'.
s_fieldcatalog-fieldname = 'USNAM'.
s_fieldcatalog-tabname = 'IT_HEAD'.
s_fieldcatalog-rollname = 'USNAM'.
s_fieldcatalog-outputlen = '12'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'DOCNR'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'BELNR_D'.
s_fieldcatalog-outputlen = '10'.
s_fieldcatalog-EMPHASIZE = 'C11'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'BUDAT'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'BUDAT'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '3'.
s_fieldcatalog-fieldname = 'RYEAR'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'RYEAR'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '4'.
s_fieldcatalog-fieldname = 'RBUKRS'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'BUKRS'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '5'.
s_fieldcatalog-fieldname = 'PRCTR'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'PRCTR'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '6'.
s_fieldcatalog-fieldname = 'BUZEI'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'BUZEI'.
s_fieldcatalog-outputlen = '3'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '7'.
s_fieldcatalog-fieldname = 'TSL'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'VTCUR12'.
s_fieldcatalog-outputlen = '15'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '8'.
s_fieldcatalog-fieldname = 'HSL'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'VLCUR12'.
s_fieldcatalog-outputlen = '15'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '9'.
s_fieldcatalog-fieldname = 'DRCRK'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'DRCRK'.
s_fieldcatalog-outputlen = '2'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '10'.
s_fieldcatalog-fieldname = 'BSCHL'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'BSCHL'.
s_fieldcatalog-outputlen = '4'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '11'.
s_fieldcatalog-fieldname = 'LIFNR'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'LIFNR'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '12'.
s_fieldcatalog-fieldname = 'UMSKZ'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'UMSKZ'.
s_fieldcatalog-outputlen = '3'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '13'.
s_fieldcatalog-fieldname = 'KUNNR'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'KUNNR'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '14'.
s_fieldcatalog-fieldname = 'HKONT'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'HKONT'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '15'.
s_fieldcatalog-fieldname = 'ACCNT_NAME'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'NAME1_GP'.
s_fieldcatalog-outputlen = '50'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '16'.
s_fieldcatalog-fieldname = 'RMVCT'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'RMVCT'.
s_fieldcatalog-outputlen = '4'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '17'.
s_fieldcatalog-fieldname = 'RTCUR'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'RTCUR'.
s_fieldcatalog-outputlen = '5'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '18'.
s_fieldcatalog-fieldname = 'RCNTR'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'RCNTR'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '19'.
s_fieldcatalog-fieldname = 'KOKRS'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'KOKRS'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '20'.
s_fieldcatalog-fieldname = 'SEGMENT'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'SEGMENT'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '21'.
s_fieldcatalog-fieldname = 'RASSC'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'RASSC'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '22'.
s_fieldcatalog-fieldname = 'POPER'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'POPER'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '23'.
s_fieldcatalog-fieldname = 'BSTAT'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'BSTAT'.
s_fieldcatalog-outputlen = '4'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '24'.
s_fieldcatalog-fieldname = 'USNAM'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'USNAM'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
DATA: s_layout TYPE slis_layout_alv.
s_layout-subtotals_text = 'SUBTOTAL TEXT'.
s_layout-key_hotspot = 'X'.
s_layout-expand_fieldname = 'EXPAND'.
*--- Add events for the Hierarchial List
EVENT-NAME = 'TOP_OF_PAGE'.
EVENT-FORM = 'TOP_OF_PAGE'.
APPEND EVENT.
*--- Specifying the Key field information
LS_KEYINFO-HEADER01 = 'BELNR'.
LS_KEYINFO-ITEM01 = 'DOCNR'.
LS_KEYINFO-ITEM02 = 'RYEAR'.
ENDFORM. " BUILD_FIELDCAT_ALV
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV_OUTPUT
*&---------------------------------------------------------------------*
* To display the ALV list output
*----------------------------------------------------------------------*
FORM DISPLAY_ALV_OUTPUT .
*--- Call function to display Hierarchical list
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_EVENTS = EVENT[]
IS_LAYOUT = LS_LAYOUT
IT_FIELDCAT = t_fieldcatalog
I_TABNAME_HEADER = C_IT_HEAD
I_TABNAME_ITEM = C_IT_ITEM
IS_KEYINFO = LS_KEYINFO
TABLES
T_OUTTAB_HEADER = IT_HEAD
T_OUTTAB_ITEM = IT_ITEM
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_ALV_OUTPUT
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
* To navigate to the Document display - transaction FB03
*----------------------------------------------------------------------*
FORM USER_COMMAND USING I_UCOMM TYPE SY-UCOMM
IS_SELFIELD TYPE SLIS_SELFIELD. "#EC CALLED
DATA: LS_HEAD LIKE IT_HEAD,
LS_ITEM LIKE IT_ITEM.
*--- Check the User command
CASE I_UCOMM.
WHEN '&IC1'. " Pick
CASE IS_SELFIELD-TABNAME.
*--- Check whether selection is from HEADER data
WHEN C_IT_HEAD.
*--- Get the Values from the Header table matching the selected values
READ TABLE IT_HEAD INDEX IS_SELFIELD-TABINDEX INTO LS_HEAD.
IF SY-SUBRC EQ 0.
*--- Set the parameter IDs for BELNR and BUKRS and fill values
SET PARAMETER ID C_BLN FIELD LS_HEAD-BELNR.
SET PARAMETER ID C_BUK FIELD LS_HEAD-BUKRS.
SET PARAMETER ID C_GJR FIELD LS_HEAD-GJAHR.
*--- Call transaction for the corresponding value selected
CALL TRANSACTION C_FB03 AND SKIP FIRST SCREEN.
ENDIF.
*--- Check whether selection is from ITEM data
WHEN C_IT_ITEM.
*--- Get the Values from the Header table matching the selected values
READ TABLE IT_ITEM INDEX IS_SELFIELD-TABINDEX INTO LS_ITEM.
IF SY-SUBRC EQ 0.
*--- Set the parameter IDs for BELNR and BUKRS and fill values
SET PARAMETER ID C_BLN FIELD LS_ITEM-DOCNR.
SET PARAMETER ID C_BUK FIELD LS_ITEM-RBUKRS.
SET PARAMETER ID C_GJR FIELD LS_ITEM-RYEAR.
*--- Call transaction for the corresponding value selected
CALL TRANSACTION C_FB03 AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDCASE.
ENDFORM. " USER_COMMAND
*&---------------------------------------------------------------------*
*& Form VALIDATE_BUKRS
*&---------------------------------------------------------------------*
* To validate Company code against the check table T001
*----------------------------------------------------------------------*
FORM VALIDATE_BUKRS.
DATA: L_BUKRS LIKE BKPF-BUKRS.
IF NOT S_BUKRS[] IS INITIAL.
*--- Select Construct to check S_BUKRS against BUKRS from T001
SELECT SINGLE BUKRS
INTO L_BUKRS
FROM T001
WHERE BUKRS IN S_BUKRS.
IF SY-SUBRC <> 0.
*--- Display message if an invalid Billing Document is entered
MESSAGE E002(Z_MSGCLASS)
WITH 'Enter a valid Company code'.
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_BUKRS
*&---------------------------------------------------------------------*
*& Form VALIDATE_BELNR
*&---------------------------------------------------------------------*
* Validating the Document No. against the check table BKPF
*----------------------------------------------------------------------*
FORM VALIDATE_BELNR .
DATA: L_BELNR LIKE BKPF-BELNR.
IF NOT S_BELNR[] IS INITIAL.
*--- Select Construct to check S_BELNR against BELNR from BKPF
SELECT SINGLE BELNR
INTO L_BELNR
FROM BKPF
WHERE BELNR IN S_BELNR.
IF SY-SUBRC <> 0.
*--- Display message if an invalid Document Number is entered
MESSAGE E002(Z_MSGCLASS)
WITH 'Enter a valid Document Number'.
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_BELNR
*&---------------------------------------------------------------------*
*& Form VALIDATE_GJAHR
*&---------------------------------------------------------------------*
* Validating the Fiscal Year against the check table BKPF
*----------------------------------------------------------------------*
FORM VALIDATE_GJAHR.
DATA: L_GJAHR LIKE BKPF-GJAHR.
IF NOT S_GJAHR[] IS INITIAL.
*--- Select Construct to check S_GJAHR against GJAHR from BKPF
SELECT SINGLE GJAHR
INTO L_GJAHR
FROM BKPF
WHERE GJAHR IN S_GJAHR.
IF SY-SUBRC <> 0.
*--- Display message if an invalid Fiscal Year is entered
MESSAGE E002(Z_MSGCLASS)
WITH 'Enter a valid Fiscal Year'.
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_GJAHR
*&---------------------------------------------------------------------*
*& Form VALIDATE_BLART
*&---------------------------------------------------------------------*
* Validating the Document Type against T003
*----------------------------------------------------------------------*
FORM VALIDATE_BLART .
DATA: L_BLART LIKE T003-BLART.
IF NOT S_BLART[] IS INITIAL.
*--- Select Construct to check S_BELNR against BELNR from BKPF
SELECT SINGLE BLART
INTO L_BLART
FROM T003
WHERE BLART IN S_BLART.
IF SY-SUBRC <> 0.
*--- Display message if an invalid Document Type is entered
MESSAGE E002(Z_MSGCLASS)
WITH 'Enter a valid Document Type'.
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_BLART
*&---------------------------------------------------------------------*
*& Form VALIDATE_USNAM
*&---------------------------------------------------------------------*
* Validating the Username against the check table BKPF
*----------------------------------------------------------------------*
FORM VALIDATE_USNAM .
DATA: L_USNAM LIKE BKPF-USNAM.
IF NOT S_USNAM[] IS INITIAL.
*--- Select Construct to check S_USNAM against USNAM from BKPF
SELECT SINGLE USNAM
INTO L_USNAM
FROM BKPF
WHERE USNAM IN S_USNAM.
IF SY-SUBRC <> 0.
*--- Display message if an invalid User Name is entered
MESSAGE E002(Z_MSGCLASS)
WITH 'Enter a valid User Name'.
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_USNAM
*&---------------------------------------------------------------------*
*& Form VALIDATE_PRCTR
*&---------------------------------------------------------------------*
* Validating the Profit against the check table CEPC
*----------------------------------------------------------------------*
FORM VALIDATE_PRCTR .
DATA: L_PRCTR LIKE CEPC-PRCTR.
IF NOT S_PRCTR[] IS INITIAL.
*--- Select Construct to check S_PRCTR against PRCTR from CEPC
SELECT SINGLE PRCTR
INTO L_PRCTR
FROM CEPC
WHERE PRCTR IN S_PRCTR.
IF SY-SUBRC <> 0.
*--- Display message if an invalid Profit Center is entered
MESSAGE E002(Z_MSGCLASS)
WITH 'Enter a valid Profit Center'.
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_PRCTR
*---------------------------------------------------------------------*
* FORM TOP_OF_PAGE *
*---------------------------------------------------------------------*
* TOP OF PAGE *
*---------------------------------------------------------------------*
FORM TOP_OF_PAGE.
DATA: V_COUNT(05) TYPE n.
data: l_count(05) type c.
DATA: V_HEADER(100) TYPE C.
*--- Get the number of Documents to be displayed
DESCRIBE TABLE IT_HEAD LINES V_COUNT.
v_count = v_count.
l_count = v_count.
CONCATENATE ' Profit center wise documents'
'Number of Documents'
V_COUNT
INTO V_HEADER SEPARATED BY ':'.
REFRESH HEAD.
HEAD-TYP = 'H'.
HEAD-INFO = V_HEADER.
APPEND HEAD.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = HEAD[]
* I_LOGO =
* I_END_OF_LIST_GRID =
.
ENDFORM.
MESSAGE-ID Z_MSGCLASS.
************************************************************************
* Program Name : Z_FI_RP_PROFIT_CENTER_DOCS *
* Description : This program displays the Accounting documents *
* and their corresponding line items based on the *
* posting keys. *
* 1. Accouting Document *
* 2. Company code *
* 3. Fiscal Year *
* 4. Document date *
* 5. Posting date *
* 6. User name *
* Functional : *
* Developer : *
* Development class : *
* *
************************************************************************
*----------------------------------------------------------------------*
* Request No. Created Date Developer name *
*----------------------------------------------------------------------*
* LD1K900601 15/07/2007
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* TYPE-POOLS *
*----------------------------------------------------------------------*
TYPE-POOLS: SLIS. " ALV Global types
*----------------------------------------------------------------------*
* TABLES *
*----------------------------------------------------------------------*
TABLES: BKPF,
FAGLFLEXA.
*---------------------------------------------------------------------*
* DATA DECLARATIONS *
*---------------------------------------------------------------------*
DATA:LS_LAYOUT TYPE SLIS_LAYOUT_ALV,
LS_KEYINFO TYPE SLIS_KEYINFO_ALV,
LS_SORT TYPE SLIS_SORTINFO_ALV,
LT_SORT TYPE SLIS_T_SORTINFO_ALV," Sort table
LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
LT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV," Field catalog
GT_SORT TYPE SLIS_T_SORTINFO_ALV.
DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
DATA:FCAT TYPE slis_t_fieldcat_alv.
DATA:LAYOUT TYPE slis_layout_alv.
DATA:EVENT TYPE slis_t_event WITH HEADER LINE.
DATA:HEAD TYPE slis_t_listheader WITH HEADER LINE.
DATA:ITEM TYPE slis_t_listheader WITH HEADER LINE.
DATA:SORT TYPE slis_t_sortinfo_alv WITH HEADER LINE.
*---------------------------------------------------------------------*
* CONSTANTS *
*---------------------------------------------------------------------*
CONSTANTS :C_X TYPE C VALUE 'X',
C_IT_HEAD TYPE SLIS_TABNAME VALUE 'IT_HEAD',
C_IT_ITEM TYPE SLIS_TABNAME VALUE 'IT_ITEM',
C_K TYPE C VALUE 'K',
C_D TYPE C VALUE 'D',
C_BLN(03) TYPE C VALUE 'BLN',
C_BUK(03) TYPE C VALUE 'BUK',
C_GJR(03) TYPE C VALUE 'GJR',
C_FB03(04) TYPE C VALUE 'FB03'.
CONSTANTS:GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
*---------------------------------------------------------------------*
* INTERNAL TABLE DECLARATIONS *
*---------------------------------------------------------------------*
*--- Internal table declaration to hold the Accounting Document Header data
DATA: BEGIN OF IT_BKPF OCCURS 0,
BUKRS LIKE BKPF-BUKRS,
BELNR LIKE BKPF-BELNR,
GJAHR LIKE BKPF-GJAHR,
BLDAT LIKE BKPF-BLDAT,
BUDAT LIKE BKPF-BUDAT,
cpudt like bkpf-cpudt,
USNAM LIKE BKPF-USNAM,
END OF IT_BKPF.
*--- Internal table declaration to hold the General Ledger: Actual Line Items
DATA: BEGIN OF IT_FAGLFLEXA OCCURS 0,
DOCNR LIKE FAGLFLEXA-DOCNR,
BUDAT LIKE FAGLFLEXA-BUDAT,
RYEAR LIKE FAGLFLEXA-RYEAR,
RBUKRS LIKE FAGLFLEXA-RBUKRS,
PRCTR LIKE FAGLFLEXA-PRCTR,
BUZEI LIKE FAGLFLEXA-BUZEI,
TSL LIKE FAGLFLEXA-TSL,
HSL LIKE FAGLFLEXA-HSL,
DRCRK LIKE FAGLFLEXA-DRCRK,
BSCHL LIKE FAGLFLEXA-BSCHL,
RMVCT LIKE FAGLFLEXA-RMVCT,
RTCUR LIKE FAGLFLEXA-RTCUR,
RCNTR LIKE FAGLFLEXA-RCNTR,
KOKRS LIKE FAGLFLEXA-KOKRS,
SEGMENT LIKE FAGLFLEXA-SEGMENT,
RASSC LIKE FAGLFLEXA-RASSC,
POPER LIKE FAGLFLEXA-POPER,
BSTAT LIKE FAGLFLEXA-BSTAT,
USNAM LIKE FAGLFLEXA-USNAM,
END OF IT_FAGLFLEXA.
*--- Internal table declaration to hold the Posting Keys
DATA: BEGIN OF IT_TBSL OCCURS 0,
BSCHL LIKE TBSL-BSCHL,
KOART LIKE TBSL-KOART,
END OF IT_TBSL.
*--- Internal table declaration to hold Accounting: Secondary Index for Vendors
DATA: BEGIN OF IT_BSIK OCCURS 0,
BUKRS LIKE BSIK-BUKRS,
LIFNR LIKE BSIK-LIFNR,
UMSKZ LIKE BSIK-UMSKZ,
GJAHR LIKE BSIK-GJAHR,
BELNR LIKE BSIK-BELNR,
BUZEI LIKE BSIK-BUZEI,
END OF IT_BSIK.
*--- Internal table declaration to hold Accounting: Secondary Index for Vendors (Cleared Items)
DATA: BEGIN OF IT_BSAK OCCURS 0,
BUKRS LIKE BSAK-BUKRS,
LIFNR LIKE BSAK-LIFNR,
UMSKZ LIKE BSAK-UMSKZ,
GJAHR LIKE BSAK-GJAHR,
BELNR LIKE BSAK-BELNR,
BUZEI LIKE BSAK-BUZEI,
END OF IT_BSAK.
*--- Internal table declaration to hold Accounting: Secondary Index for Customers
DATA: BEGIN OF IT_BSID OCCURS 0,
BUKRS LIKE BSID-BUKRS,
KUNNR LIKE BSID-KUNNR,
UMSKZ LIKE BSID-UMSKZ,
GJAHR LIKE BSID-GJAHR,
BELNR LIKE BSID-BELNR,
BUZEI LIKE BSID-BUZEI,
END OF IT_BSID.
*--- Internal table declaration to hold Accounting: Secondary Index for Customers (Cleared Items)
DATA: BEGIN OF IT_BSAD OCCURS 0,
BUKRS LIKE BSAD-BUKRS,
KUNNR LIKE BSAD-KUNNR,
UMSKZ LIKE BSAD-UMSKZ,
GJAHR LIKE BSAD-GJAHR,
BELNR LIKE BSAD-BELNR,
BUZEI LIKE BSAD-BUZEI,
END OF IT_BSAD.
*--- Internal table declaration to hold Accounting: Secondary Index for G/L Accounts
DATA: BEGIN OF IT_BSIS OCCURS 0,
BUKRS LIKE BSIS-BUKRS,
HKONT LIKE BSIS-HKONT,
GJAHR LIKE BSIS-GJAHR,
BELNR LIKE BSIS-BELNR,
BUZEI LIKE BSIS-BUZEI,
END OF IT_BSIS.
*--- Internal table declaration to hold Accounting: Secondary Index for G/L Accounts (Cleared Items)
DATA: BEGIN OF IT_BSAS OCCURS 0,
BUKRS LIKE BSAS-BUKRS,
HKONT LIKE BSAS-HKONT,
GJAHR LIKE BSAS-GJAHR,
BELNR LIKE BSAS-BELNR,
BUZEI LIKE BSAS-BUZEI,
END OF IT_BSAS.
*--- Internal table to hold the Header data
DATA: BEGIN OF IT_HEAD OCCURS 0,
BUKRS LIKE BKPF-BUKRS,
BELNR LIKE BKPF-BELNR,
GJAHR LIKE BKPF-GJAHR,
BLDAT LIKE BKPF-BLDAT,
BUDAT LIKE BKPF-BUDAT,
cpudt like bkpf-cpudt,
USNAM LIKE BKPF-USNAM,
END OF IT_HEAD.
*--- Internal table to hold the Item data
DATA: BEGIN OF IT_ITEM OCCURS 0.
INCLUDE STRUCTURE IT_FAGLFLEXA.
DATA: LIFNR LIKE BSIK-LIFNR,
UMSKZ LIKE BSIK-UMSKZ,
KUNNR LIKE BSID-KUNNR,
HKONT LIKE BSIS-HKONT,
*DATA: ACCNT_NUM(10) TYPE C,
ACCNT_NAME LIKE SKAT-TXT50,
END OF IT_ITEM.
*--- Internal table to hold Vendor descriptions
DATA: BEGIN OF IT_LFA1 OCCURS 0,
LIFNR LIKE LFA1-LIFNR,
NAME1 LIKE LFA1-NAME1,
END OF IT_LFA1.
*--- Internal table to hold Customer descriptions
DATA: BEGIN OF IT_KNA1 OCCURS 0,
KUNNR LIKE KNA1-KUNNR,
NAME1 LIKE KNA1-NAME1,
END OF IT_KNA1.
*--- Internal table to hold GL descriptions
DATA: BEGIN OF IT_SKAT OCCURS 0,
SAKNR LIKE SKAT-SAKNR,
TXT50 LIKE SKAT-TXT50,
END OF IT_SKAT.
*---------------------------------------------------------------------*
* SELECTION-SCREEN *
*---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK SCLSCR1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_BUKRS FOR BKPF-BUKRS OBLIGATORY NO-EXTENSION, " Company Code
S_BELNR FOR BKPF-BELNR, " Accounting Document Number
S_GJAHR FOR BKPF-GJAHR OBLIGATORY NO-EXTENSION, " Fiscal Year
S_BLART FOR BKPF-BLART, " Document Type
S_BLDAT FOR BKPF-BLDAT, " Document Date in Document
S_BUDAT FOR BKPF-BUDAT, " Posting Date in the Document
s_cpudt for bkpf-cpudt,
S_USNAM FOR BKPF-USNAM NO-EXTENSION, " User Name
S_PRCTR FOR FAGLFLEXA-PRCTR OBLIGATORY. " Profit Center
SELECTION-SCREEN END OF BLOCK SCLSCR1.
*---------------------------------------------------------------------*
* AT SELECTION-SCREEN *
*---------------------------------------------------------------------*
AT SELECTION-SCREEN ON S_BUKRS.
*--- Perform to validate Company code
PERFORM VALIDATE_BUKRS.
AT SELECTION-SCREEN ON S_BELNR.
*--- Perform to validate Accounting Document Number
PERFORM VALIDATE_BELNR.
AT SELECTION-SCREEN ON S_GJAHR.
*--- Perform to validate Fiscal Year
PERFORM VALIDATE_GJAHR.
AT SELECTION-SCREEN ON S_BLART.
*--- Perform to validate Document Type
PERFORM VALIDATE_BLART.
AT SELECTION-SCREEN ON S_USNAM.
*--- Perform to validate User Name
PERFORM VALIDATE_USNAM.
AT SELECTION-SCREEN ON S_PRCTR.
*--- Perform to validate User Name
PERFORM VALIDATE_PRCTR.
*---------------------------------------------------------------------*
* TOP-OF-PAGE *
*---------------------------------------------------------------------*
TOP-OF-PAGE.
*---------------------------------------------------------------------*
* START-OF-SELECTION *
*---------------------------------------------------------------------*
START-OF-SELECTION.
*--- Perform to get the Accounting Document Header data
PERFORM GET_BKPF_DATA.
*--- Perform to get the General Ledger: Actual Line Items
PERFORM GET_FAGLFLEXA_DATA.
*--- Perform to get the Posting Keys
PERFORM GET_TBSL_DATA.
*--- Perform to get the Account Information based on Posting key
PERFORM GET_ACCOUNT_INFO.
*--- Perform to get the Vendor Descriptions
PERFORM GET_LFA1_DATA.
*--- Perform to get the Customer Descriptions
PERFORM GET_KNA1_DATA.
*--- Perform to get the GL Descriptions
PERFORM GET_SKAT_DATA.
*---------------------------------------------------------------------*
* END-OF-SELECTION *
*---------------------------------------------------------------------*
END-OF-SELECTION.
*--- Perform to get the Output data
PERFORM GET_OUTPUT.
*--- Perform to Build the fieldcat to display the output in ALV format
PERFORM BUILD_FIELDCAT_ALV.
*--- Perform to display the Hierarchial ALV List
PERFORM DISPLAY_ALV_OUTPUT.
*&---------------------------------------------------------------------*
*& Form GET_BKPF_DATA
*&---------------------------------------------------------------------*
* To get the Accounting Document Header data
*----------------------------------------------------------------------*
FORM GET_BKPF_DATA.
*--- Select construct to get the Accounting Document Header data
SELECT BUKRS BELNR GJAHR BLDAT BUDAT cpudt USNAM
FROM BKPF
INTO TABLE IT_BKPF
WHERE BUKRS IN S_BUKRS
AND BELNR IN S_BELNR
AND GJAHR IN S_GJAHR
AND BLART IN S_BLART
AND BLDAT IN S_BLDAT
AND BUDAT IN S_BUDAT
and cpudt in s_cpudt
AND USNAM IN S_USNAM.
IF SY-SUBRC = 0.
SORT IT_BKPF BY BELNR.
ELSE.
*--- Display message if an invalid Profit Center is entered
MESSAGE S002(Z_MSGCLASS)
WITH 'No data exists with selection criteria'.
ENDIF.
ENDFORM. " GET_BKPF_DATA
*&---------------------------------------------------------------------*
*& Form GET_FAGLFLEXA_DATA
*&---------------------------------------------------------------------*
* To get the General Ledger: Actual Line Items
*----------------------------------------------------------------------*
FORM GET_FAGLFLEXA_DATA .
IF NOT IT_BKPF[] IS INITIAL.
*--- Select construct to get the General Ledger: Actual Line Items
SELECT DOCNR " Document NUmber
BUDAT " Posting Date
RYEAR " Fiscal Year
RBUKRS " Company code
PRCTR " Profit center
BUZEI " Line Item
TSL " Value in Transaction Currency
HSL " Value in Local Currency
DRCRK " Debit/Credit Indicator
BSCHL " Posting Key
RMVCT " Transaction Type
RTCUR " Currency Key
RCNTR " Cost Center
KOKRS " Controlling Area
SEGMENT " Segment for Segmental Reporting
RASSC " Company ID of trading partner
POPER " Posting period
BSTAT " Document status
USNAM " User name
FROM FAGLFLEXA
INTO TABLE IT_FAGLFLEXA
FOR ALL ENTRIES IN IT_BKPF
WHERE RYEAR = IT_BKPF-GJAHR
AND DOCNR = IT_BKPF-BELNR
AND RBUKRS = IT_BKPF-BUKRS
AND PRCTR IN S_PRCTR.
IF SY-SUBRC = 0.
SORT IT_FAGLFLEXA BY DOCNR.
ENDIF.
ENDIF.
ENDFORM. " GET_FAGLFLEXA_DATA
*&---------------------------------------------------------------------*
*& Form GET_TBSL_DATA
*&---------------------------------------------------------------------*
* To get the Posting Keys
*----------------------------------------------------------------------*
FORM GET_TBSL_DATA.
IF NOT IT_FAGLFLEXA[] IS INITIAL.
*--- Select construct to get the Posting keys
SELECT BSCHL KOART
FROM TBSL
INTO TABLE IT_TBSL
FOR ALL ENTRIES IN IT_FAGLFLEXA
WHERE BSCHL = IT_FAGLFLEXA-BSCHL.
IF SY-SUBRC = 0.
ENDIF.
ENDIF.
ENDFORM. " GET_TBSL_DATA
*&---------------------------------------------------------------------*
*& Form GET_ACCOUNT_INFO
*&---------------------------------------------------------------------*
* To get the Vendor/Customer/GL Account Information
*----------------------------------------------------------------------*
FORM GET_ACCOUNT_INFO .
*--- Loop to get the Vendor, Customer, G/L related data based on posting key
LOOP AT IT_TBSL.
*--- If posting key relates to Vendor
IF IT_TBSL-KOART = C_K.
PERFORM GET_BSIK_DATA.
*--- If posting key relates to Customer
ELSEIF IT_TBSL-KOART = C_D.
PERFORM GET_BSID_DATA.
*--- If posting key relates to G/L
ELSE.
PERFORM GET_BSIS_DATA.
ENDIF.
ENDLOOP.
ENDFORM. " GET_ACCOUNT_INFO
*&---------------------------------------------------------------------*
*& Form GET_BSIK_DATA
*&---------------------------------------------------------------------*
* To get the Vendor data
*----------------------------------------------------------------------*
FORM GET_BSIK_DATA .
IF NOT IT_FAGLFLEXA[] IS INITIAL.
*--- Select construct to get the Vendor and document number from BSIK
SELECT BUKRS LIFNR UMSKZ GJAHR BELNR BUZEI
FROM BSIK
INTO TABLE IT_BSIK
FOR ALL ENTRIES IN IT_FAGLFLEXA
WHERE BUKRS = IT_FAGLFLEXA-RBUKRS
AND GJAHR = IT_FAGLFLEXA-RYEAR
AND BELNR = IT_FAGLFLEXA-DOCNR
AND BUZEI = IT_FAGLFLEXA-BUZEI.
IF SY-SUBRC <> 0.
*--- If document does not exist in BSIK get from BSAK
*--- Select construct to get the Vendor and document number from BSIK
SELECT BUKRS LIFNR UMSKZ GJAHR BELNR BUZEI
FROM BSAK
INTO TABLE IT_BSAK
FOR ALL ENTRIES IN IT_FAGLFLEXA
WHERE BUKRS = IT_FAGLFLEXA-RBUKRS
AND GJAHR = IT_FAGLFLEXA-RYEAR
AND BELNR = IT_FAGLFLEXA-DOCNR
AND BUZEI = IT_FAGLFLEXA-BUZEI.
ENDIF.
ENDIF.
ENDFORM. " GET_BSIK_DATA
*&---------------------------------------------------------------------*
*& Form GET_BSID_DATA
*&---------------------------------------------------------------------*
* To get the Customer data
*----------------------------------------------------------------------*
FORM GET_BSID_DATA .
IF NOT IT_FAGLFLEXA[] IS INITIAL.
*--- Select construct to get the Vendor and document number from BSID
SELECT BUKRS KUNNR UMSKZ GJAHR BELNR BUZEI
FROM BSID
INTO TABLE IT_BSID
FOR ALL ENTRIES IN IT_FAGLFLEXA
WHERE BUKRS = IT_FAGLFLEXA-RBUKRS
AND GJAHR = IT_FAGLFLEXA-RYEAR
AND BELNR = IT_FAGLFLEXA-DOCNR
AND BUZEI = IT_FAGLFLEXA-BUZEI.
IF SY-SUBRC <> 0.
*--- If document does not exist in BSID get from BSAD
*--- Select construct to get the Vendor and document number from BSAD
SELECT BUKRS KUNNR UMSKZ GJAHR BELNR BUZEI
FROM BSAD
INTO TABLE IT_BSAD
FOR ALL ENTRIES IN IT_FAGLFLEXA
WHERE BUKRS = IT_FAGLFLEXA-RBUKRS
AND GJAHR = IT_FAGLFLEXA-RYEAR
AND BELNR = IT_FAGLFLEXA-DOCNR
AND BUZEI = IT_FAGLFLEXA-BUZEI.
ENDIF.
ENDIF.
ENDFORM. " GET_BSID_DATA
*&---------------------------------------------------------------------*
*& Form GET_BSIS_DATA
*&---------------------------------------------------------------------*
* To get the G/L data
*----------------------------------------------------------------------*
FORM GET_BSIS_DATA .
IF NOT IT_FAGLFLEXA[] IS INITIAL.
*--- Select construct to get the Vendor and document number from BSID
SELECT BUKRS HKONT GJAHR BELNR BUZEI
FROM BSIS
INTO TABLE IT_BSIS
FOR ALL ENTRIES IN IT_FAGLFLEXA
WHERE BUKRS = IT_FAGLFLEXA-RBUKRS
AND GJAHR = IT_FAGLFLEXA-RYEAR
AND BELNR = IT_FAGLFLEXA-DOCNR
AND BUZEI = IT_FAGLFLEXA-BUZEI.
IF SY-SUBRC <> 0.
*--- If document does not exist in BSID get from BSAD
*--- Select construct to get the Vendor and document number from BSAD
SELECT BUKRS HKONT GJAHR BELNR BUZEI
FROM BSAS
INTO TABLE IT_BSAS
FOR ALL ENTRIES IN IT_FAGLFLEXA
WHERE BUKRS = IT_FAGLFLEXA-RBUKRS
AND GJAHR = IT_FAGLFLEXA-RYEAR
AND BELNR = IT_FAGLFLEXA-DOCNR
AND BUZEI = IT_FAGLFLEXA-BUZEI.
ENDIF.
ENDIF.
ENDFORM. " GET_BSIS_DATA
*&---------------------------------------------------------------------*
*& Form GET_LFA1_DATA
*&---------------------------------------------------------------------*
* To get the Vendor Descriptions
*----------------------------------------------------------------------*
FORM GET_LFA1_DATA.
IF NOT IT_BSIK[] IS INITIAL.
*--- Select construct to get the Vendor Names
SELECT LIFNR NAME1
FROM LFA1
INTO TABLE IT_LFA1
FOR ALL ENTRIES IN IT_BSIK
WHERE LIFNR = IT_BSIK-LIFNR.
IF SY-SUBRC <> 0.
ENDIF.
ENDIF.
ENDFORM. " GET_LFA1_DATA
*&---------------------------------------------------------------------*
*& Form GET_KNA1_DATA
*&---------------------------------------------------------------------*
* To get the Customer descriptions
*----------------------------------------------------------------------*
FORM GET_KNA1_DATA .
IF NOT IT_BSID[] IS INITIAL.
*--- Select construct to get the Vendor Names
SELECT KUNNR NAME1
FROM KNA1
INTO TABLE IT_KNA1
FOR ALL ENTRIES IN IT_BSID
WHERE KUNNR = IT_BSID-KUNNR.
IF SY-SUBRC <> 0.
ENDIF.
ENDIF.
ENDFORM. " GET_KNA1_DATA
*&---------------------------------------------------------------------*
*& Form GET_SKAT_DATA
*&---------------------------------------------------------------------*
* To get the GL Descriptions
*----------------------------------------------------------------------*
FORM GET_SKAT_DATA .
IF NOT IT_BSIS[] IS INITIAL.
*--- Select construct to get the GL Account descriptions
SELECT SAKNR TXT50
FROM SKAT
INTO TABLE IT_SKAT
FOR ALL ENTRIES IN IT_BSIS
WHERE SAKNR = IT_BSIS-HKONT
AND SPRAS = 'EN'.
if sy-subrc <> 0.
endif.
ENDIF.
ENDFORM. " GET_SKAT_DATA
*&---------------------------------------------------------------------*
*& Form GET_OUTPUT
*&---------------------------------------------------------------------*
* To get the Output data
*----------------------------------------------------------------------*
FORM GET_OUTPUT.
DATA: L_LIFNR LIKE BSIK-LIFNR,
L_KUNNR LIKE BSID-KUNNR,
L_SAKNR LIKE SKAT-SAKNR.
DATA: FG_DOC TYPE C.
LOOP AT IT_BKPF.
FG_DOC = SPACE.
LOOP AT IT_FAGLFLEXA WHERE DOCNR = IT_BKPF-BELNR.
*--- Get the documents pertaining to profit center
IF FG_DOC = SPACE.
IT_HEAD-BUKRS = IT_BKPF-BUKRS.
IT_HEAD-BELNR = IT_BKPF-BELNR.
IT_HEAD-GJAHR = IT_BKPF-GJAHR.
IT_HEAD-BLDAT = IT_BKPF-BLDAT.
IT_HEAD-BUDAT = IT_BKPF-BUDAT.
it_head-cpudt = it_bkpf-cpudt.
IT_HEAD-USNAM = IT_BKPF-USNAM.
APPEND IT_HEAD.
CLEAR IT_HEAD.
FG_DOC = 'X'.
ENDIF.
IT_ITEM = IT_FAGLFLEXA.
*--- Read tables BSIk or BSAK to get the Vendor data
READ TABLE IT_BSIK WITH KEY BELNR = IT_FAGLFLEXA-DOCNR
BUZEI = IT_FAGLFLEXA-BUZEI.
IF SY-SUBRC = 0.
IT_ITEM-LIFNR = IT_BSIK-LIFNR.
IT_ITEM-UMSKZ = IT_BSIK-UMSKZ.
L_LIFNR = IT_BSIK-LIFNR.
ELSE.
READ TABLE IT_BSAK WITH KEY BELNR = IT_FAGLFLEXA-DOCNR
BUZEI = IT_FAGLFLEXA-BUZEI.
IF SY-SUBRC = 0.
IT_ITEM-LIFNR = IT_BSAK-LIFNR.
IT_ITEM-UMSKZ = IT_BSAK-UMSKZ.
L_LIFNR = IT_BSAK-LIFNR.
ENDIF.
ENDIF.
*---- Get the Vendor description into output table
READ TABLE IT_LFA1 WITH KEY LIFNR = L_LIFNR.
IF SY-SUBRC = 0.
IT_ITEM-ACCNT_NAME = IT_LFA1-NAME1.
ENDIF.
*--- Read tables BSID or BSAD to get the Customer data
READ TABLE IT_BSID WITH KEY BELNR = IT_FAGLFLEXA-DOCNR
BUZEI = IT_FAGLFLEXA-BUZEI.
IF SY-SUBRC = 0.
IT_ITEM-KUNNR = IT_BSID-KUNNR.
IT_ITEM-UMSKZ = IT_BSID-UMSKZ.
L_KUNNR = IT_BSID-KUNNR.
ELSE.
READ TABLE IT_BSAD WITH KEY BELNR = IT_FAGLFLEXA-DOCNR
BUZEI = IT_FAGLFLEXA-BUZEI.
IF SY-SUBRC = 0.
IT_ITEM-KUNNR = IT_BSAD-KUNNR.
IT_ITEM-UMSKZ = IT_BSAD-UMSKZ.
L_KUNNR = IT_BSAD-KUNNR.
ENDIF.
ENDIF.
*---- Get the Customer description into output table
READ TABLE IT_KNA1 WITH KEY KUNNR = L_KUNNR.
IF SY-SUBRC = 0.
IT_ITEM-ACCNT_NAME = IT_KNA1-NAME1.
ENDIF.
*--- Read tables BSIS or BSAS to get the G/L data
READ TABLE IT_BSIS WITH KEY BELNR = IT_FAGLFLEXA-DOCNR
BUZEI = IT_FAGLFLEXA-BUZEI.
IF SY-SUBRC = 0.
L_SAKNR = IT_BSIS-HKONT.
ELSE.
READ TABLE IT_BSAS WITH KEY BELNR = IT_FAGLFLEXA-DOCNR
BUZEI = IT_FAGLFLEXA-BUZEI.
IF SY-SUBRC = 0.
L_SAKNR = IT_BSAS-HKONT.
ENDIF.
ENDIF.
*--- Get the GL Account descrition into Output table
READ TABLE IT_SKAT WITH KEY SAKNR = L_SAKNR.
IF SY-SUBRC = 0.
IT_ITEM-HKONT = L_SAKNR.
IT_ITEM-ACCNT_NAME = IT_SKAT-TXT50.
ENDIF.
APPEND: IT_ITEM.
CLEAR: IT_ITEM,
L_LIFNR,
L_KUNNR,
L_SAKNR.
ENDLOOP.
ENDLOOP.
ENDFORM. " GET_OUTPUT
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCAT_ALV
*&---------------------------------------------------------------------*
* Format and display the output
*----------------------------------------------------------------------*
FORM BUILD_FIELDCAT_ALV .
DATA: LS_SORT TYPE SLIS_SORTINFO_ALV.
*--- Set Layout properties
LS_LAYOUT-GROUP_CHANGE_EDIT = C_X.
LS_LAYOUT-COLWIDTH_OPTIMIZE = SPACE.
LS_LAYOUT-ZEBRA = C_X.
LS_LAYOUT-DETAIL_POPUP = C_X.
LS_LAYOUT-GET_SELINFOS = C_X.
**--- Build field catalog and sort table
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'BELNR'.
s_fieldcatalog-tabname = 'IT_HEAD'.
s_fieldcatalog-rollname = 'BELNR_D'.
s_fieldcatalog-outputlen = '10'.
s_fieldcatalog-SP_GROUP = 'A'.
s_fieldcatalog-EMPHASIZE = 'C71'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'BUKRS'.
s_fieldcatalog-tabname = 'IT_HEAD'.
s_fieldcatalog-rollname = 'BUKRS'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '3'.
s_fieldcatalog-fieldname = 'GJAHR'.
s_fieldcatalog-tabname = 'IT_HEAD'.
s_fieldcatalog-rollname = 'GJAHR'.
s_fieldcatalog-outputlen = '12'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '4'.
s_fieldcatalog-fieldname = 'BLDAT'.
s_fieldcatalog-tabname = 'IT_HEAD'.
s_fieldcatalog-rollname = 'BLDAT'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '5'.
s_fieldcatalog-fieldname = 'BUDAT'.
s_fieldcatalog-tabname = 'IT_HEAD'.
s_fieldcatalog-rollname = 'BUDAT'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '6'.
s_fieldcatalog-fieldname = 'CPUDT'.
s_fieldcatalog-tabname = 'IT_HEAD'.
s_fieldcatalog-rollname = 'CPUDT'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '7'.
s_fieldcatalog-fieldname = 'USNAM'.
s_fieldcatalog-tabname = 'IT_HEAD'.
s_fieldcatalog-rollname = 'USNAM'.
s_fieldcatalog-outputlen = '12'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'DOCNR'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'BELNR_D'.
s_fieldcatalog-outputlen = '10'.
s_fieldcatalog-EMPHASIZE = 'C11'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'BUDAT'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'BUDAT'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '3'.
s_fieldcatalog-fieldname = 'RYEAR'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'RYEAR'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '4'.
s_fieldcatalog-fieldname = 'RBUKRS'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'BUKRS'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '5'.
s_fieldcatalog-fieldname = 'PRCTR'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'PRCTR'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '6'.
s_fieldcatalog-fieldname = 'BUZEI'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'BUZEI'.
s_fieldcatalog-outputlen = '3'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '7'.
s_fieldcatalog-fieldname = 'TSL'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'VTCUR12'.
s_fieldcatalog-outputlen = '15'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '8'.
s_fieldcatalog-fieldname = 'HSL'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'VLCUR12'.
s_fieldcatalog-outputlen = '15'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '9'.
s_fieldcatalog-fieldname = 'DRCRK'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'DRCRK'.
s_fieldcatalog-outputlen = '2'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '10'.
s_fieldcatalog-fieldname = 'BSCHL'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'BSCHL'.
s_fieldcatalog-outputlen = '4'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '11'.
s_fieldcatalog-fieldname = 'LIFNR'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'LIFNR'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '12'.
s_fieldcatalog-fieldname = 'UMSKZ'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'UMSKZ'.
s_fieldcatalog-outputlen = '3'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '13'.
s_fieldcatalog-fieldname = 'KUNNR'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'KUNNR'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '14'.
s_fieldcatalog-fieldname = 'HKONT'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'HKONT'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '15'.
s_fieldcatalog-fieldname = 'ACCNT_NAME'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'NAME1_GP'.
s_fieldcatalog-outputlen = '50'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '16'.
s_fieldcatalog-fieldname = 'RMVCT'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'RMVCT'.
s_fieldcatalog-outputlen = '4'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '17'.
s_fieldcatalog-fieldname = 'RTCUR'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'RTCUR'.
s_fieldcatalog-outputlen = '5'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '18'.
s_fieldcatalog-fieldname = 'RCNTR'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'RCNTR'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '19'.
s_fieldcatalog-fieldname = 'KOKRS'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'KOKRS'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '20'.
s_fieldcatalog-fieldname = 'SEGMENT'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'SEGMENT'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '21'.
s_fieldcatalog-fieldname = 'RASSC'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'RASSC'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '22'.
s_fieldcatalog-fieldname = 'POPER'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'POPER'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '23'.
s_fieldcatalog-fieldname = 'BSTAT'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'BSTAT'.
s_fieldcatalog-outputlen = '4'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '24'.
s_fieldcatalog-fieldname = 'USNAM'.
s_fieldcatalog-tabname = 'IT_ITEM'.
s_fieldcatalog-rollname = 'USNAM'.
s_fieldcatalog-outputlen = '10'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
DATA: s_layout TYPE slis_layout_alv.
s_layout-subtotals_text = 'SUBTOTAL TEXT'.
s_layout-key_hotspot = 'X'.
s_layout-expand_fieldname = 'EXPAND'.
*--- Add events for the Hierarchial List
EVENT-NAME = 'TOP_OF_PAGE'.
EVENT-FORM = 'TOP_OF_PAGE'.
APPEND EVENT.
*--- Specifying the Key field information
LS_KEYINFO-HEADER01 = 'BELNR'.
LS_KEYINFO-ITEM01 = 'DOCNR'.
LS_KEYINFO-ITEM02 = 'RYEAR'.
ENDFORM. " BUILD_FIELDCAT_ALV
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV_OUTPUT
*&---------------------------------------------------------------------*
* To display the ALV list output
*----------------------------------------------------------------------*
FORM DISPLAY_ALV_OUTPUT .
*--- Call function to display Hierarchical list
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_EVENTS = EVENT[]
IS_LAYOUT = LS_LAYOUT
IT_FIELDCAT = t_fieldcatalog
I_TABNAME_HEADER = C_IT_HEAD
I_TABNAME_ITEM = C_IT_ITEM
IS_KEYINFO = LS_KEYINFO
TABLES
T_OUTTAB_HEADER = IT_HEAD
T_OUTTAB_ITEM = IT_ITEM
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_ALV_OUTPUT
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
* To navigate to the Document display - transaction FB03
*----------------------------------------------------------------------*
FORM USER_COMMAND USING I_UCOMM TYPE SY-UCOMM
IS_SELFIELD TYPE SLIS_SELFIELD. "#EC CALLED
DATA: LS_HEAD LIKE IT_HEAD,
LS_ITEM LIKE IT_ITEM.
*--- Check the User command
CASE I_UCOMM.
WHEN '&IC1'. " Pick
CASE IS_SELFIELD-TABNAME.
*--- Check whether selection is from HEADER data
WHEN C_IT_HEAD.
*--- Get the Values from the Header table matching the selected values
READ TABLE IT_HEAD INDEX IS_SELFIELD-TABINDEX INTO LS_HEAD.
IF SY-SUBRC EQ 0.
*--- Set the parameter IDs for BELNR and BUKRS and fill values
SET PARAMETER ID C_BLN FIELD LS_HEAD-BELNR.
SET PARAMETER ID C_BUK FIELD LS_HEAD-BUKRS.
SET PARAMETER ID C_GJR FIELD LS_HEAD-GJAHR.
*--- Call transaction for the corresponding value selected
CALL TRANSACTION C_FB03 AND SKIP FIRST SCREEN.
ENDIF.
*--- Check whether selection is from ITEM data
WHEN C_IT_ITEM.
*--- Get the Values from the Header table matching the selected values
READ TABLE IT_ITEM INDEX IS_SELFIELD-TABINDEX INTO LS_ITEM.
IF SY-SUBRC EQ 0.
*--- Set the parameter IDs for BELNR and BUKRS and fill values
SET PARAMETER ID C_BLN FIELD LS_ITEM-DOCNR.
SET PARAMETER ID C_BUK FIELD LS_ITEM-RBUKRS.
SET PARAMETER ID C_GJR FIELD LS_ITEM-RYEAR.
*--- Call transaction for the corresponding value selected
CALL TRANSACTION C_FB03 AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDCASE.
ENDFORM. " USER_COMMAND
*&---------------------------------------------------------------------*
*& Form VALIDATE_BUKRS
*&---------------------------------------------------------------------*
* To validate Company code against the check table T001
*----------------------------------------------------------------------*
FORM VALIDATE_BUKRS.
DATA: L_BUKRS LIKE BKPF-BUKRS.
IF NOT S_BUKRS[] IS INITIAL.
*--- Select Construct to check S_BUKRS against BUKRS from T001
SELECT SINGLE BUKRS
INTO L_BUKRS
FROM T001
WHERE BUKRS IN S_BUKRS.
IF SY-SUBRC <> 0.
*--- Display message if an invalid Billing Document is entered
MESSAGE E002(Z_MSGCLASS)
WITH 'Enter a valid Company code'.
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_BUKRS
*&---------------------------------------------------------------------*
*& Form VALIDATE_BELNR
*&---------------------------------------------------------------------*
* Validating the Document No. against the check table BKPF
*----------------------------------------------------------------------*
FORM VALIDATE_BELNR .
DATA: L_BELNR LIKE BKPF-BELNR.
IF NOT S_BELNR[] IS INITIAL.
*--- Select Construct to check S_BELNR against BELNR from BKPF
SELECT SINGLE BELNR
INTO L_BELNR
FROM BKPF
WHERE BELNR IN S_BELNR.
IF SY-SUBRC <> 0.
*--- Display message if an invalid Document Number is entered
MESSAGE E002(Z_MSGCLASS)
WITH 'Enter a valid Document Number'.
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_BELNR
*&---------------------------------------------------------------------*
*& Form VALIDATE_GJAHR
*&---------------------------------------------------------------------*
* Validating the Fiscal Year against the check table BKPF
*----------------------------------------------------------------------*
FORM VALIDATE_GJAHR.
DATA: L_GJAHR LIKE BKPF-GJAHR.
IF NOT S_GJAHR[] IS INITIAL.
*--- Select Construct to check S_GJAHR against GJAHR from BKPF
SELECT SINGLE GJAHR
INTO L_GJAHR
FROM BKPF
WHERE GJAHR IN S_GJAHR.
IF SY-SUBRC <> 0.
*--- Display message if an invalid Fiscal Year is entered
MESSAGE E002(Z_MSGCLASS)
WITH 'Enter a valid Fiscal Year'.
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_GJAHR
*&---------------------------------------------------------------------*
*& Form VALIDATE_BLART
*&---------------------------------------------------------------------*
* Validating the Document Type against T003
*----------------------------------------------------------------------*
FORM VALIDATE_BLART .
DATA: L_BLART LIKE T003-BLART.
IF NOT S_BLART[] IS INITIAL.
*--- Select Construct to check S_BELNR against BELNR from BKPF
SELECT SINGLE BLART
INTO L_BLART
FROM T003
WHERE BLART IN S_BLART.
IF SY-SUBRC <> 0.
*--- Display message if an invalid Document Type is entered
MESSAGE E002(Z_MSGCLASS)
WITH 'Enter a valid Document Type'.
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_BLART
*&---------------------------------------------------------------------*
*& Form VALIDATE_USNAM
*&---------------------------------------------------------------------*
* Validating the Username against the check table BKPF
*----------------------------------------------------------------------*
FORM VALIDATE_USNAM .
DATA: L_USNAM LIKE BKPF-USNAM.
IF NOT S_USNAM[] IS INITIAL.
*--- Select Construct to check S_USNAM against USNAM from BKPF
SELECT SINGLE USNAM
INTO L_USNAM
FROM BKPF
WHERE USNAM IN S_USNAM.
IF SY-SUBRC <> 0.
*--- Display message if an invalid User Name is entered
MESSAGE E002(Z_MSGCLASS)
WITH 'Enter a valid User Name'.
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_USNAM
*&---------------------------------------------------------------------*
*& Form VALIDATE_PRCTR
*&---------------------------------------------------------------------*
* Validating the Profit against the check table CEPC
*----------------------------------------------------------------------*
FORM VALIDATE_PRCTR .
DATA: L_PRCTR LIKE CEPC-PRCTR.
IF NOT S_PRCTR[] IS INITIAL.
*--- Select Construct to check S_PRCTR against PRCTR from CEPC
SELECT SINGLE PRCTR
INTO L_PRCTR
FROM CEPC
WHERE PRCTR IN S_PRCTR.
IF SY-SUBRC <> 0.
*--- Display message if an invalid Profit Center is entered
MESSAGE E002(Z_MSGCLASS)
WITH 'Enter a valid Profit Center'.
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_PRCTR
*---------------------------------------------------------------------*
* FORM TOP_OF_PAGE *
*---------------------------------------------------------------------*
* TOP OF PAGE *
*---------------------------------------------------------------------*
FORM TOP_OF_PAGE.
DATA: V_COUNT(05) TYPE n.
data: l_count(05) type c.
DATA: V_HEADER(100) TYPE C.
*--- Get the number of Documents to be displayed
DESCRIBE TABLE IT_HEAD LINES V_COUNT.
v_count = v_count.
l_count = v_count.
CONCATENATE ' Profit center wise documents'
'Number of Documents'
V_COUNT
INTO V_HEADER SEPARATED BY ':'.
REFRESH HEAD.
HEAD-TYP = 'H'.
HEAD-INFO = V_HEADER.
APPEND HEAD.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = HEAD[]
* I_LOGO =
* I_END_OF_LIST_GRID =
.
ENDFORM.
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
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
Subscribe to:
Posts (Atom)