Posted: Mon Jun 02, 2008 3:28 pm Post subject: Displays Bank Vouchers
Code:
REPORT Z_FI_RP_BANK_VOUCHERS NO STANDARD PAGE HEADING
MESSAGE-ID Z_MSGCLASS
LINE-SIZE 200.
************************************************************************
* Program Name : Z_FI_RP_BANK_VOUCHERS *
* Description : Bank Vouchers *
* Development class : Z_DEVELOPMENT *
* Description : The report displays Bank Vouchers *
*----------------------------------------------------------------------*
* Request No. Created Date Developer name *
*----------------------------------------------------------------------*
* SRDK900081 28/09/2006 Ashok Kumar.N
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* INCLUDES *
*----------------------------------------------------------------------*
INCLUDE <LIST>. " Include for symbols
*----------------------------------------------------------------------*
* INTERNAL TABLE DECLARATIONS *
*----------------------------------------------------------------------*
*--- Internal table to hold the Accounting document data
DATA: BEGIN OF IT_BKPF OCCURS 0,
BELNR LIKE BKPF-BELNR, " Accounting Doc. No
GJAHR LIKE BKPF-GJAHR, " Fiscal Year
BLART LIKE BKPF-BLART, " Document Type
BUDAT LIKE BKPF-BUDAT, " Posting date
XBLNR LIKE BKPF-XBLNR, " Refrence document
BKTXT LIKE BKPF-BKTXT, " Text
END OF IT_BKPF.
*--- Internal table to hold the Acc. Doc. Details
DATA: BEGIN OF IT_BSEG OCCURS 0,
BELNR LIKE BSEG-BELNR, " Accounting Document Number
GJAHR LIKE BSEG-GJAHR, " Fiscal Year
BSCHL LIKE BSEG-BSCHL, " Posting Key
KOART LIKE BSEG-KOART, " Document type
SHKZG LIKE BSEG-SHKZG, " Debit/Credit Indicator
DMBTR LIKE BSEG-DMBTR, " Amount in local currency
WRBTR LIKE BSEG-WRBTR, " Amount in document currency
PSWBT LIKE BSEG-PSWBT, " Amount for Updating in General Ledger
SGTXT LIKE BSEG-SGTXT, " Text
KOSTL LIKE BSEG-KOSTL, " Cost Center
PRCTR LIKE BSEG-PRCTR, " Profit Center
HKONT LIKE BSEG-HKONT, " General Ledger Account
KUNNR LIKE BSEG-KUNNR, " Customer
LIFNR LIKE BSEG-LIFNR, " Account Number of Vendor or Creditor
END OF IT_BSEG.
*--- Internal table to hold the Accounting: Secondary Index for Vendors (Cleared Items)
DATA: BEGIN OF IT_BSAK OCCURS 0,
BUKRS LIKE BSAK-BUKRS, " Company Code
AUGBL LIKE BSAK-AUGBL, " Cleared Doc. Number
BELNR LIKE BSAK-BELNR, " Accounting Doc. No
BUDAT LIKE BSAK-BUDAT, " Posting date
XBLNR LIKE BSAK-XBLNR, " Refrence document
BLART LIKE BSAD-BLART, " document TYPE
MONAT LIKE BSAK-MONAT,
DMBTR LIKE BSAK-DMBTR, " Amount in LC
END OF IT_BSAK.
*--- Internal table to hold Accounting: Secondary Index for Customers (Cleared Items)
DATA: BEGIN OF IT_BSAD OCCURS 0,
BUKRS LIKE BSAD-BUKRS, " Company Code
AUGBL LIKE BSAD-AUGBL, " Cleared Doc. Number
BELNR LIKE BSAD-BELNR, " Accounting Doc. No
BUDAT LIKE BSAD-BUDAT, " Posting date
XBLNR LIKE BSAD-XBLNR, " Refrence document
BLART LIKE BSAD-BLART, " document TYPE
MONAT LIKE BSAD-MONAT,
DMBTR LIKE BSAD-DMBTR, " Amount in LC
END OF IT_BSAD.
DATA: IT_TEMP LIKE IT_BSAK OCCURS 0 WITH HEADER LINE.
DATA: IT_BSAK1 LIKE IT_BSAK OCCURS 0 WITH HEADER LINE.
DATA: IT_BSAD1 LIKE IT_BSAD OCCURS 0 WITH HEADER LINE.
*--- Internal table to hold the data for printing
DATA: IT_PRINT_DOC LIKE IT_BKPF OCCURS 0 WITH HEADER LINE.
*--- Internal table to hold the function codes.
DATA: BEGIN OF IT_FCODE OCCURS 0,
FCODE(5),
END OF IT_FCODE.
*----------------------------------------------------------------------*
* CONSTANTS *
*----------------------------------------------------------------------*
CONSTANTS: C_X TYPE C VALUE 'X',
C_HEAD1(25) VALUE 'COMPANY LTD.,',
C_HEAD2(25) VALUE 'B.C 105,Havelock Road',
C_HEAD3(20) VALUE 'CANTONMENT',
C_HEAD4(30) VALUE '(O)13215487',
C_TITLE(50) VALUE 'CASH VOUCHERS',
C_SIGN1(35) VALUE 'Company,',
C_SIGN2(25) VALUE 'Authorised Signatory',
C_FOOT1(12) VALUE 'Prepared By',
C_FOOT2(12) VALUE 'Passed By',
C_FOOT3(12) VALUE 'Authorised',
C_FOOT4(10) VALUE 'Reciever'.
*--- Constants for Document Types
CONSTANTS: C_BP(2) TYPE C VALUE 'BP',
C_BR(2) TYPE C VALUE 'BR'.
*----------------------------------------------------------------------*
* DATA DECLARATIONS *
*----------------------------------------------------------------------*
DATA: F_COLOR, " For color
V_SELKZ, " To select the Check Box
G_MESG(100), " Message
V_TXT(50).
*----------------------------------------------------------------------*
* SELECTION SCREEN. *
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
PARAMETERS: P_BUKRS LIKE BKPF-BUKRS OBLIGATORY, " Company code
P_PRCTR LIKE CEPC-PRCTR, " Profit Center
P_BLART LIKE BKPF-BLART OBLIGATORY. " Document type
SELECT-OPTIONS: S_BELNR FOR BKPF-BELNR, " Document Number
S_BUDAT FOR BKPF-BUDAT OBLIGATORY. " Posting date
PARAMETERS: P_GJAHR LIKE BKPF-GJAHR OBLIGATORY. " Fiscal year
SELECTION-SCREEN END OF BLOCK BLK1.
*---------------------------------------------------------------------*
* AT SELECTION-SCREEN *
*---------------------------------------------------------------------*
AT SELECTION-SCREEN ON P_BUKRS.
*--- Perform to validate the company code
PERFORM VALIDATE_COMPANY_CODE.
AT SELECTION-SCREEN ON P_PRCTR.
*--- Perform to validate the profit center
PERFORM VALIDATE_PROFIT_CENTER.
AT SELECTION-SCREEN ON P_BLART.
*--- Perform to validate the profit center
PERFORM VALIDATE_DOC_TYPE.
AT SELECTION-SCREEN ON S_BELNR.
*--- Perform to validate the profit center
PERFORM VALIDATE_ACC_DOC_NO.
*---------------------------------------------------------------------*
* INITIALIZATION *
*---------------------------------------------------------------------*
INITIALIZATION.
P_BLART = 'BP'.
*---------------------------------------------------------------------*
* START-OF-SELECTION *
*---------------------------------------------------------------------*
START-OF-SELECTION.
SET PF-STATUS 'BNKPR'.
*--- Perform to get the data
PERFORM GET_DATA.
*--- Perform to display the report
PERFORM DISPLAY_REPORT.
*---------------------------------------------------------------------*
* TOP-OF-PAGE *
*---------------------------------------------------------------------*
TOP-OF-PAGE DURING LINE-SELECTION.
*--- Perform display_header.
PERFORM DISPLAY_HEADER.
*----------------------------------------------------------------------*
* AT USER-COMMAND *
*----------------------------------------------------------------------*
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'SALL'.
V_SELKZ = 'X'.
*--- Perform to select all the PO'S
PERFORM SET_CHKBOXES USING V_SELKZ.
WHEN 'DSALL'.
CLEAR V_SELKZ.
*--- Perform to select all the PO'S
PERFORM SET_CHKBOXES USING V_SELKZ.
WHEN 'DISP'.
CLEAR IT_PRINT_DOC. REFRESH IT_PRINT_DOC.
*--- Perform to get the PO's
PERFORM GET_SELECTED_DOCS_TOPRINT.
IF IT_PRINT_DOC[] IS INITIAL.
MESSAGE S001(Z_MSGCLASS) WITH 'Select atleast one document'.
ENDIF.
PERFORM DISPLAY_VOUCHERS.
ENDCASE.
*&---------------------------------------------------------------------*
*& Form VALIDATE_COMPANY_CODE
*&---------------------------------------------------------------------*
*--- To validate the company code against the check table 'T001'
*----------------------------------------------------------------------*
FORM VALIDATE_COMPANY_CODE .
DATA: L_BUKRS LIKE BKPF-BUKRS. " Company code
*--- Select construct against the check table for a valid Company Code
SELECT SINGLE BUKRS
INTO L_BUKRS
FROM T001
WHERE BUKRS = P_BUKRS.
IF SY-SUBRC <> 0.
*--- Display Message if invalid Company Code has been entered
MESSAGE S001(Z_MSGCLASS) WITH 'Enter a valid Company Code'(002).
ENDIF.
ENDFORM. " VALIDATE_COMPANY_CODE
*&---------------------------------------------------------------------*
*& Form VALIDATE_PROFIT_CENTER
*&---------------------------------------------------------------------*
*--- To validate the profit center against the check table 'CEPC'
*----------------------------------------------------------------------*
FORM VALIDATE_PROFIT_CENTER .
DATA: L_PRCTR LIKE CEPC-PRCTR. " Profit center
*--- Select construct to validate the profit center
IF NOT P_PRCTR IS INITIAL.
SELECT SINGLE PRCTR
INTO L_PRCTR
FROM CEPC
WHERE PRCTR = P_PRCTR.
IF SY-SUBRC <> 0.
*--- Display Message if invalid Profit center has been entered
MESSAGE S001(Z_MSGCLASS) WITH 'Enter a valid Profit center'(003).
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_PROFIT_CENTER
*&---------------------------------------------------------------------*
*& Form VALIDATE_DOC_TYPE
*&---------------------------------------------------------------------*
*--- To Validate
*----------------------------------------------------------------------*
FORM VALIDATE_DOC_TYPE .
DATA: L_BLART LIKE T003-BLART. " Profit center
*--- Select construct to validate the profit center
IF NOT P_PRCTR IS INITIAL.
SELECT SINGLE BLART
INTO L_BLART
FROM T003
WHERE BLART = P_BLART.
IF SY-SUBRC <> 0.
*--- Display Message if invalid Profit center has been entered
MESSAGE S001(Z_MSGCLASS) WITH 'Enter a valid Document Type'(003).
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_DOC_TYPE
*&---------------------------------------------------------------------*
*& Form VALIDATE_ACC_DOC_NO
*&---------------------------------------------------------------------*
*--- To validate the accounting document no
*----------------------------------------------------------------------*
FORM VALIDATE_ACC_DOC_NO .
DATA: L_BELNR LIKE BKPF-BELNR. " Acc. Doc. No
*--- Select construct to validate the Acc. Doc. No
IF NOT S_BELNR[] IS INITIAL.
SELECT SINGLE BELNR
INTO L_BELNR
FROM BKPF
WHERE BELNR IN S_BELNR.
IF SY-SUBRC <> 0.
*--- Display Message if invalid Profit center has been entered
MESSAGE S001(Z_MSGCLASS) WITH 'Enter a Accounting doc. No'(004).
ENDIF.
ENDIF.
ENDFORM. " VALIDATE_ACC_DOC_NO
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
*--- To get the data
*----------------------------------------------------------------------*
FORM GET_DATA .
*--- Perform to get the accounting document numbers
PERFORM GET_ACC_DOC_NOS.
*--- Perform to get the Acc. Doc. Details
PERFORM GET_ACC_DOC_DETAILS.
*--- Perform to get the Cleared Doc. Details
* PERFORM GET_CLEARED_DOC_DETAILS.
IF P_BLART = C_BP.
PERFORM GET_CLEARED_DOC_DATA.
ELSEIF P_BLART = C_BR.
PERFORM GET_CLEARED_DOC_DATA.
ENDIF.
PERFORM GET_CREDIT_DEBIT_DATA.
ENDFORM. " GET_DATA
*&---------------------------------------------------------------------*
*& Form GET_ACC_DOC_NOS
*&---------------------------------------------------------------------*
*--- To get the accounting document data
*----------------------------------------------------------------------*
FORM GET_ACC_DOC_NOS .
DATA: L_MESG(80). " Message
*--- Select construct to get the Accounting document numbers
SELECT BELNR GJAHR
BLART BUDAT XBLNR BKTXT
INTO TABLE IT_BKPF
FROM BKPF
WHERE BUKRS = P_BUKRS
AND BELNR IN S_BELNR
AND GJAHR = P_GJAHR
AND BLART = P_BLART
AND BUDAT IN S_BUDAT.
IF SY-SUBRC = 0.
*--- Sort internal table by Acc. Doc. No based
SORT IT_BKPF BY BELNR.
ELSE.
L_MESG = 'No data exists for the selection criteria'(004).
MESSAGE S001(Z_MSGCLASS) WITH L_MESG.
ENDIF.
ENDFORM. " GET_ACC_DOC_NOS
*&---------------------------------------------------------------------*
*& Form GET_ACC_DOC_DETAILS
*&---------------------------------------------------------------------*
*--- To get the accounting doc details
*----------------------------------------------------------------------*
FORM GET_ACC_DOC_DETAILS .
DATA: L_MESG(80). " Message
IF NOT IT_BKPF[] IS INITIAL.
IF NOT P_PRCTR IS INITIAL.
SELECT BELNR GJAHR BSCHL KOART SHKZG DMBTR WRBTR
PSWBT SGTXT KOSTL PRCTR HKONT KUNNR LIFNR
INTO TABLE IT_BSEG FROM BSEG
FOR ALL ENTRIES IN IT_BKPF
WHERE BUKRS = P_BUKRS
AND BELNR = IT_BKPF-BELNR
AND GJAHR = IT_BKPF-GJAHR
AND PRCTR = P_PRCTR.
ELSE.
SELECT BELNR GJAHR BSCHL KOART SHKZG DMBTR WRBTR
PSWBT SGTXT KOSTL PRCTR HKONT KUNNR LIFNR
INTO TABLE IT_BSEG FROM BSEG
FOR ALL ENTRIES IN IT_BKPF
WHERE BUKRS = P_BUKRS
AND BELNR = IT_BKPF-BELNR
AND GJAHR = IT_BKPF-GJAHR.
ENDIF.
IF SY-SUBRC = 0.
SORT IT_BSEG BY BELNR GJAHR.
ELSE.
L_MESG = 'No data exists for the selection criteria'(004).
MESSAGE S001(Z_MSGCLASS) WITH L_MESG.
ENDIF.
ENDIF.
ENDFORM. " GET_ACC_DOC_DETAILS
*&---------------------------------------------------------------------*
*& Form GET_CLEARED_DOC_DETAILS
*&---------------------------------------------------------------------*
*--- To get the Cleared document data
*----------------------------------------------------------------------*
FORM GET_CLEARED_DOC_DETAILS .
DATA: L_MESG(80). " Message
CLEAR: IT_TEMP[],
IT_TEMP.
IF NOT P_BUKRS IS INITIAL AND
NOT S_BUDAT[] IS INITIAL.
IF P_BLART = C_BP.
*--- Select construct to get the Accounting document numbers
SELECT BUKRS AUGBL BELNR BUDAT XBLNR DMBTR
INTO TABLE IT_TEMP
FROM BSAK
WHERE BUKRS = P_BUKRS
AND BUDAT IN S_BUDAT.
IF SY-SUBRC = 0.
*--- Sort internal table by Acc. Doc. No based
SORT IT_BSAK BY BELNR.
LOOP AT IT_TEMP.
IF IT_TEMP-AUGBL <> IT_TEMP-BELNR.
MOVE IT_TEMP TO IT_BSAK.
APPEND IT_BSAK.
ENDIF.
ENDLOOP.
ELSE.
L_MESG = 'No data exists for the selection criteria'(004).
MESSAGE S001(Z_MSGCLASS) WITH L_MESG.
ENDIF.
ELSEIF P_BLART = C_BR.
*--- Select construct to get the Accounting document numbers
SELECT BUKRS AUGBL BELNR BUDAT XBLNR DMBTR
INTO TABLE IT_TEMP
FROM BSAD
WHERE BUKRS = P_BUKRS
AND BUDAT IN S_BUDAT.
IF SY-SUBRC = 0.
*--- Sort internal table by Acc. Doc. No based
SORT IT_BSAD BY BELNR.
LOOP AT IT_TEMP.
IF IT_TEMP-AUGBL <> IT_TEMP-BELNR.
MOVE IT_TEMP TO IT_BSAD.
APPEND IT_BSAD.
ENDIF.
ENDLOOP.
ELSE.
L_MESG = 'No data exists for the selection criteria'(004).
MESSAGE S001(Z_MSGCLASS) WITH L_MESG.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " GET_CLEARED_DOC_DETAILS
*&---------------------------------------------------------------------*
*& Form DISPLAY_REPORT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM DISPLAY_REPORT .
DATA: V_CKBOX.
IF NOT IT_BKPF[] IS INITIAL.
WRITE: 1(45) SY-ULINE.
* /1(1) SY-VLINE.
FORMAT COLOR 5.
* WRITE: 40(30) 'Released Purchase Orders',
* 109(01) SY-VLINE,
* /1(109) SY-ULINE.
FORMAT COLOR INTENSIFIED OFF.
FORMAT COLOR 3.
WRITE: /1(1) SY-VLINE,
2(2) 'Ck',
4(1) SY-VLINE,
5(10)'Acc.Doc.No',
15(01) SY-VLINE,
16(04)'Year',
20(01) SY-VLINE,
21(02) 'Ty',
23(01) SY-VLINE,
24(10) 'Post. Date',
34(01) SY-VLINE,
35(10) 'Ref. Doc',
45(01) SY-VLINE,
/1(45) SY-ULINE.
ENDFORM. " DISPLAY_REPORT
*&---------------------------------------------------------------------*
*& Form COLOR_FILL
*&---------------------------------------------------------------------*
*--- To display the background color
*----------------------------------------------------------------------*
FORM COLOR_FILL.
IF F_COLOR = SPACE.
FORMAT INTENSIFIED OFF.
FORMAT COLOR 2.
F_COLOR = 'X'.
ELSE.
FORMAT INTENSIFIED ON.
FORMAT COLOR 2.
CLEAR F_COLOR.
ENDIF.
ENDFORM. " COLOR_FILL
*&---------------------------------------------------------------------*
*& Form set_chkboxes
*&---------------------------------------------------------------------*
*--- To select all the PO's
*----------------------------------------------------------------------*
FORM SET_CHKBOXES USING F_SELKZ.
DATA: LV_BELNR LIKE BKPF-BELNR,
LV_FLAG,
LV_INDEX LIKE SY-INDEX.
CLEAR IT_BKPF.
DO.
READ LINE SY-INDEX.
IF SY-SUBRC = 0.
LV_BELNR = SY-LISEL+4(10).
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = LV_BELNR
IMPORTING
OUTPUT = LV_BELNR.
IF LV_FLAG = SPACE.
READ TABLE IT_BKPF WITH KEY BELNR = LV_BELNR.
IF SY-SUBRC = 0.
LV_FLAG = 'X'.
ENDIF.
ENDIF.
IF LV_FLAG = 'X'.
SY-LISEL+1(1) = F_SELKZ.
MODIFY LINE SY-INDEX.
ENDIF.
ELSE.
SY-LISEL+1(1) = '-'.
LV_INDEX = SY-INDEX - 1.
MODIFY LINE LV_INDEX.
EXIT.
ENDIF.
ENDDO.
ENDFORM. " set_chkboxes
*&---------------------------------------------------------------------*
*& Form GET_SELECTED_DOCS_TOPRINT
*&---------------------------------------------------------------------*
*--- To hold the selected documents from the list
*----------------------------------------------------------------------*
FORM GET_SELECTED_DOCS_TOPRINT .
DATA: LV_BELNR LIKE BKPF-BELNR,
LV_FLAG,
LV_CHK,
LV_TABIX LIKE SY-TABIX,
LV_INDEX LIKE SY-INDEX.
DO.
READ LINE SY-INDEX.
IF SY-SUBRC = 0.
LV_BELNR = SY-LISEL+4(10).
LV_CHK = SY-LISEL+1(1).
IF LV_CHK = C_X.
*--- Padding zeros for ebeln
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = LV_BELNR
IMPORTING
OUTPUT = LV_BELNR.
ENDFORM. " GET_SELECTED_DOCS_TOPRINT
*&---------------------------------------------------------------------*
*& Form display_vouchers
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM DISPLAY_VOUCHERS .
DATA: LV_FLAG,
LV_KSCHL LIKE BSEG-BSCHL,
LV_TXT(50),
V_KTOPL LIKE T001-KTOPL,
L_BSCHL LIKE BSEG-BSCHL,
L_TOTAL LIKE BSEG-WRBTR,
L_TOTAL_WORDS(190),
L_WRBTR_DR LIKE BSEG-WRBTR,
L_WRBTR_CR LIKE BSEG-WRBTR.
DATA: L_TEMP(10),
L_WRBTR LIKE PC207-BETRG. " HR Payroll: Amount
*--- Perform to exclude the pf-status
PERFORM EXCLUDE_PF_STATUS.
IF P_BLART = C_BP OR
P_BLART = C_BR.
LOOP AT IT_PRINT_DOC.
*--- Check for Documents BP or BR
IF IT_PRINT_DOC-BLART = C_BP.
LV_KSCHL = '50'.
L_BSCHL = '40'.
ELSEIF IT_PRINT_DOC-BLART = C_BR.
LV_KSCHL = '40'.
L_BSCHL = '50'.
ENDIF.
CLEAR V_TXT.
READ TABLE IT_BSEG WITH KEY BELNR = IT_PRINT_DOC-BELNR
BSCHL = LV_KSCHL.
IF SY-SUBRC = 0.
CLEAR V_KTOPL.
SELECT SINGLE KTOPL FROM T001 INTO V_KTOPL WHERE BUKRS = P_BUKRS.
IF SY-SUBRC = 0.
SELECT SINGLE TXT50 FROM SKAT INTO V_TXT
WHERE SPRAS = SY-LANGU
AND KTOPL = V_KTOPL
AND SAKNR = IT_BSEG-HKONT.
ENDIF.
ENDIF.
IF LV_FLAG = 'X'.
NEW-PAGE.
ENDIF.
LOOP AT IT_BSEG WHERE BELNR = IT_PRINT_DOC-BELNR.
IF IT_BSEG-BSCHL = LV_KSCHL.
L_WRBTR = IT_BSEG-WRBTR.
*--- Call function HR_IN_CHG_INR_WRDS to convert Amount into Words
CALL FUNCTION 'HR_IN_CHG_INR_WRDS'
EXPORTING
AMT_IN_NUM = L_WRBTR
IMPORTING
AMT_IN_WORDS = L_TOTAL_WORDS.
L_TOTAL = IT_BSEG-WRBTR.
*--- Splitting the Amount in Words at 'Rupees' (Not Required)
SPLIT L_TOTAL_WORDS AT 'Rupees' INTO L_TOTAL_WORDS L_TEMP.
ENDIF.
IF IT_BSEG-BSCHL NE LV_KSCHL.
WRITE: /03(01) SY-VLINE.
CASE IT_BSEG-KOART.
WHEN 'K'.
WRITE: 04(10) IT_BSEG-LIFNR.
SELECT SINGLE NAME1 INTO LV_TXT FROM LFA1 WHERE LIFNR = IT_BSEG-LIFNR.
WRITE: 14(01) SY-VLINE.
WRITE: 15(50) LV_TXT.
WHEN 'D'.
WRITE: 04(10) IT_BSEG-KUNNR.
SELECT SINGLE NAME1 INTO LV_TXT FROM KNA1 WHERE KUNNR = IT_BSEG-KUNNR.
WRITE: 14(01) SY-VLINE.
WRITE: 15(50) LV_TXT.
WHEN OTHERS.
WRITE: 04(10) IT_BSEG-HKONT.
WRITE: 14(01) SY-VLINE.
CLEAR V_KTOPL.
SELECT SINGLE KTOPL FROM T001 INTO V_KTOPL WHERE BUKRS = P_BUKRS.
IF SY-SUBRC = 0.
SELECT SINGLE TXT50 FROM SKAT INTO LV_TXT
WHERE SPRAS = SY-LANGU
AND KTOPL = V_KTOPL
AND SAKNR = IT_BSEG-HKONT.
IF SY-SUBRC = 0.
WRITE: 15(50) LV_TXT.
ENDIF.
ENDIF.
ENDCASE.
ENDIF.
SKIP 3.
WRITE: 15(06) 'Total:'. " 22 L_TOTAL.
ENDLOOP.
ELSEIF P_BLART = 'SA'.
LOOP AT IT_PRINT_DOC.
CLEAR V_TXT.
READ TABLE IT_BSEG WITH KEY BELNR = IT_PRINT_DOC-BELNR
BSCHL = LV_KSCHL.
IF SY-SUBRC = 0.
CLEAR V_KTOPL.
SELECT SINGLE KTOPL FROM T001 INTO V_KTOPL WHERE BUKRS = P_BUKRS.
IF SY-SUBRC = 0.
SELECT SINGLE TXT50 FROM SKAT INTO V_TXT
WHERE SPRAS = SY-LANGU
AND KTOPL = V_KTOPL
AND SAKNR = IT_BSEG-HKONT.
ENDIF.
ENDIF.
IF LV_FLAG = 'X'.
NEW-PAGE.
ENDIF.
LOOP AT IT_BSEG WHERE BELNR = IT_PRINT_DOC-BELNR.
* IF IT_BSEG-BSCHL = LV_KSCHL.
* L_WRBTR = IT_BSEG-WRBTR.
**--- Call function HR_IN_CHG_INR_WRDS to convert Amount into Words
* CALL FUNCTION 'HR_IN_CHG_INR_WRDS'
* EXPORTING
* AMT_IN_NUM = L_WRBTR
* IMPORTING
* AMT_IN_WORDS = L_TOTAL_WORDS.
* L_TOTAL = IT_BSEG-WRBTR.
**--- Splitting the Amount in Words at 'Rupees' (Not Required)
* SPLIT L_TOTAL_WORDS AT 'Rupees' INTO L_TOTAL_WORDS L_TEMP.
* ENDIF.
* IF IT_BSEG-BSCHL NE LV_KSCHL.
WRITE: /03(01) SY-VLINE.
CASE IT_BSEG-KOART.
WHEN 'K'.
WRITE: 04(10) IT_BSEG-LIFNR.
SELECT SINGLE NAME1 INTO LV_TXT FROM LFA1 WHERE LIFNR = IT_BSEG-LIFNR.
WRITE: 14(01) SY-VLINE.
WRITE: 15(50) LV_TXT.
WHEN 'D'.
WRITE: 04(10) IT_BSEG-KUNNR.
SELECT SINGLE NAME1 INTO LV_TXT FROM KNA1 WHERE KUNNR = IT_BSEG-KUNNR.
WRITE: 14(01) SY-VLINE.
WRITE: 15(50) LV_TXT.
WHEN OTHERS.
WRITE: 04(10) IT_BSEG-HKONT.
WRITE: 14(01) SY-VLINE.
CLEAR V_KTOPL.
SELECT SINGLE KTOPL FROM T001 INTO V_KTOPL WHERE BUKRS = P_BUKRS.
IF SY-SUBRC = 0.
SELECT SINGLE TXT50 FROM SKAT INTO LV_TXT
WHERE SPRAS = SY-LANGU
AND KTOPL = V_KTOPL
AND SAKNR = IT_BSEG-HKONT.
IF SY-SUBRC = 0.
WRITE: 15(50) LV_TXT.
ENDIF.
ENDIF.
ENDCASE.
ENDFORM. " EXCLUDE_PF_STATUS
*&---------------------------------------------------------------------*
*& Form DISPLAY_HEADER
*&---------------------------------------------------------------------*
* To display the Header Text for the report
*----------------------------------------------------------------------*
FORM DISPLAY_HEADER .
*--- If Document type is 'BP' display document description
IF P_BLART = C_BP.
WRITE: 82(20) 'Bank Payment posting'.
ENDIF.
*--- If Document type is 'BR' display document description
IF P_BLART = C_BR.
WRITE: 82(20) 'Bank Receipt posting'.
ENDIF.
*&---------------------------------------------------------------------*
*& Form GET_BSAK_DATA
*&---------------------------------------------------------------------*
* To get Accounting:Vendors (Cleared Items) data
*----------------------------------------------------------------------*
FORM GET_CLEARED_DOC_DATA.
IF P_BLART = C_BP.
*---Select Construct to get Accounting:Vendors (Cleared Items) data
SELECT BUKRS AUGBL BELNR BUDAT XBLNR BLART MONAT DMBTR
FROM BSAK
INTO TABLE IT_TEMP
WHERE BUKRS = P_BUKRS.
IF SY-SUBRC = 0.
*--- Get the Header level document data
LOOP AT IT_TEMP WHERE BUDAT IN S_BUDAT.
*--- Read table IT_BKPF to get the Document data related data
READ TABLE IT_BKPF WITH KEY BUDAT = IT_TEMP-BUDAT
BELNR = IT_TEMP-BELNR.
IF SY-SUBRC = 0.
MOVE IT_TEMP TO IT_BSAK.
APPEND IT_BSAK.
ENDIF.
ENDLOOP.
ELSE.
*--- Display Message if no values found
G_MESG = 'No Entries found for the selection criteria!!!'.
MESSAGE S001(Z_MSGCLASS) WITH G_MESG.
ENDIF.
ELSEIF P_BLART = C_BR.
SELECT BUKRS AUGBL BELNR BUDAT XBLNR BLART MONAT DMBTR
FROM BSAD
INTO TABLE IT_TEMP
WHERE BUKRS = P_BUKRS.
IF SY-SUBRC = 0.
*--- Get the Header level document data
LOOP AT IT_TEMP WHERE BUDAT IN S_BUDAT.
*--- Read table IT_BKPF to get the Document data related data
READ TABLE IT_BKPF WITH KEY BUDAT = IT_TEMP-BUDAT
BELNR = IT_TEMP-BELNR.
IF SY-SUBRC = 0.
MOVE IT_TEMP TO IT_BSAD.
APPEND IT_BSAD.
ENDIF.
ENDLOOP.
ELSE.
*--- Display Message if no values found
G_MESG = 'No Entries found for the selection criteria!!!'.
MESSAGE S001(Z_MSGCLASS) WITH G_MESG.
ENDIF.
ENDIF.
ENDFORM. " GET_BSAK_DATA
*&---------------------------------------------------------------------*
*& Form GET_CREDIT_DEBIT_DATA
*&---------------------------------------------------------------------*
* To get the Debit and Credit data
*----------------------------------------------------------------------*
FORM GET_CREDIT_DEBIT_DATA.
IF P_BLART = C_BP.
*--- Loop to get the Item level document data
LOOP AT IT_TEMP.
READ TABLE IT_BSAK WITH KEY BUKRS = IT_TEMP-BUKRS
AUGBL = IT_TEMP-AUGBL.
IF SY-SUBRC = 0.
IF IT_TEMP-AUGBL <> IT_BSAK-BELNR AND
IT_TEMP-BLART <> C_BP.
MOVE IT_TEMP TO IT_BSAK1.
APPEND IT_BSAK1.
ELSEIF IT_TEMP-AUGBL = IT_BSAK-BELNR.
MOVE IT_TEMP TO IT_BSAK1.
APPEND IT_BSAK1.
ENDIF.
ENDIF.
ENDLOOP.
ELSEIF P_BLART = C_BR.
*--- Loop to get the Item level document data
LOOP AT IT_TEMP WHERE BLART <> C_BR.
READ TABLE IT_BSAD WITH KEY BUKRS = IT_TEMP-BUKRS
AUGBL = IT_TEMP-AUGBL
BLART = IT_TEMP-BLART.
IF SY-SUBRC = 0.
IF IT_TEMP-AUGBL <> IT_BSAD-BELNR.
MOVE IT_TEMP TO IT_BSAD1.
APPEND IT_BSAD1.
* ELSEIF IT_TEMP-AUGBL = IT_BSAD-BELNR.
* MOVE IT_TEMP TO IT_BSAD1.
* APPEND IT_BSAD1.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. " GET_CREDIT_DEBIT_DATA
*Selection texts
*----------------------------------------------------------
* P_BLART Document Type
* P_BUKRS Company Code
* P_GJAHR Fiscal Year
* P_PRCTR Profit Center
* S_BELNR Document No.
* S_BUDAT Posting Date
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.