‎2007 Sep 04 11:59 AM
Hi,
I am working on a report in which there are 5 fields gl account(hkont),vendor code(lifnr),vendor name(name1),aging details,currency(document currency-waers).Here the requirement is I have to split the aging details column into 4 columns(current,31-60,61-90,>90).The document currency has to be summed up according to vendor name and currency key and split into these 4 columns accordingly.I am not getting the logic how can i split the document currency into these 4 columns.There is a form statement to sum up the document currency(f_get_sum_from_bfok_a).There is a form for splitting the document currency(f_split_wrbtr_in_bsik).I am not getting the logic how can i split the document currency into these 4 columns.Can anyone suggest me the proper solution for this?I am sending the program on which I am working.
REPORT zfir087_accounts_payables NO STANDARD PAGE HEADING
LINE-SIZE 85
LINE-COUNT 65
MESSAGE-ID zfi.
***********************************************************************
INCLUDEs *
***********************************************************************
***THE FOLLOWING INCLUDE CONTAINS HEADER FOOTER DETAILS
INCLUDE zca_standard_header_footer1.
***THE FOLLOWING INCLUDE CONTAINS ALL THE DATA DECLARATIONS AND
***SELECTION SCREEN DETAILS
INCLUDE zfir087_accounts_payables_top.
***THE FOLLOWING INCLUDE CONTAINS ALL THE SUBROUTINES
INCLUDE zfir087_accounts_payables_sub.
***********************************************************************
AT SELECTION SCREEN *
***********************************************************************
AT SELECTION-SCREEN .
Validate the profit center entered on selection screen.
PERFORM f_valiate_profit_center.
Validate Recon Account entered on selection screen.
PERFORM f_validate_recon_account.
Validate Partner profit center entered on selection screen
PERFORM f_val_part_profit_center.
*Begin of SRR-17677
*----
*At Selection Screen Output
*----
AT SELECTION-SCREEN OUTPUT.
PERFORM screen_changes.
*End of SRR-17677
START-OF-SELECTION.
*--SIR-07541 Begin
SELECT * FROM t001 INTO TABLE t_t001.
*--SIR-07541 End
Get data from bsik table
GET bsik.
MOVE-CORRESPONDING bsik TO t_ldb_data. "#EC ENHOK
MOVE:bsik-bukrs TO d_ldb_data-bukrs,
bsik-lifnr TO d_ldb_data-lifnr,
bsik-belnr TO d_ldb_data-belnr,
bsik-bldat TO d_ldb_data-bldat,
bsik-blart TO d_ldb_data-blart,
bsik-gjahr TO d_ldb_data-gjahr,
bsik-buzei TO d_ldb_data-buzei,
bsik-xblnr TO d_ldb_data-xblnr,
bsik-dmbtr TO d_ldb_data-dmbtr,
bsik-waers TO d_ldb_data-waers,
bsik-wrbtr TO d_ldb_data-wrbtr,
bsik-dmbe2 TO d_ldb_data-dmbe2,
bsik-vbund TO d_ldb_data-vbund,
bsik-ebeln TO d_ldb_data-ebeln,
bsik-augdt TO d_ldb_data-augdt,
bsik-augbl TO d_ldb_data-augbl,
bsik-zuonr TO d_ldb_data-zuonr,
bsik-budat TO d_ldb_data-budat,
bsik-sgtxt TO d_ldb_data-sgtxt,
bsik-hkont TO d_ldb_data-hkont,
bsik-zlsch TO d_ldb_data-zlsch,
bsik-zlspr TO d_ldb_data-zlspr,
bsik-filkd TO d_ldb_data-filkd,
bsik-shkzg TO d_ldb_data-shkzg,
Begin of SRR-22879 APARMAA
bsik-zfbdt TO d_ldb_data-zfbdt,
bsik-zbd1t TO d_ldb_data-zbd1t,
bsik-zbd2t TO d_ldb_data-zbd2t,
bsik-zbd3t TO d_ldb_data-zbd3t,
bsik-rebzg TO d_ldb_data-rebzg.
End of SRR-22879 APARMAA
APPEND d_ldb_data TO t_ldb_data.
Get data from bkpf table
GET bkpf.
MOVE:bkpf-bukrs TO d_bkpf-bukrs,
bkpf-belnr TO d_bkpf-belnr,
bkpf-gjahr TO d_bkpf-gjahr,
bkpf-awkey TO d_bkpf-awkey,
bkpf-hwae2 TO d_bkpf-hwae2.
APPEND d_bkpf TO t_bkpf.
END-OF-SELECTION.
Get purchasing information from rseg table
IF NOT t_bkpf[] IS INITIAL.
PERFORM f_get_ebeln_from_rseg.
ENDIF.
Get profit center and partner profit center from bfok_a table
IF NOT t_ldb_data[] IS INITIAL.
PERFORM f_get_data_from_bfok_a.
ENDIF.
Begin of SRR-22879 APARMAA
IF NOT t_ldb_data[] IS INITIAL.
PERFORM f_get_data_from_lfa1.
ENDIF.
End of SRR-22879 APARMAA
Calculate the sum of the dmbtr field
PERFORM f_get_sum_from_bfok_a.
Split the amount in doc currency(wrbtr) in bsik
PERFORM f_split_wrbtr_in_bsik.
IF NOT t_final[] IS INITIAL.
LOGO FOR ALV GRID
v_logo = c_logo.
v_title = sy-title.
v_repid = sy-repid.
BUILD PRINT SETTINGS
PERFORM f_build_print_settings USING f_print_settings.
BUILD LAYOUT
PERFORM f_build_layout USING f_grid_layout v_title.
BUILD EVENTS
PERFORM f_build_events USING t_events[] .
*DISPLAY REPORT
IF p_disp EQ 'X'. "SRR-17677
PERFORM f_display_data.
ENDIF. "SRR-17677
Begin of SRR-17677
Begin of SRR-22879 APARMAA
IF p_expo = 'X'.
EXPORT T_R087 FROM T_FINAL TO MEMORY ID 'R087'.
ENDIF.
IF p_expo = 'X'.
MOVE-CORRESPONDING t_final TO t_final1. "SRR-24422
t_final1[] = t_final[]. "SRR-24422
EXPORT t_r087 FROM t_final1 TO MEMORY ID 'R087'.
ENDIF.
End of SRR-22879 APARMAA
End of SRR-17677
Refresh and Clear all internal tables.
PERFORM f_free_and_clear.
ELSE.
NO RECORDS MATCH THE SELECTION CRITERIA
IF p_disp EQ 'X'. "SRR-17677
MESSAGE i000 WITH
'No data exists for the given selection criteria'(050).
ENDIF. "SRR-17677
EXIT.
ENDIF.
SET EXTENDED CHECK OFF.
TYPE-POOLS: slis.
*global variables
DATA: v_logo(20) TYPE c, " logo for alv grid
t_header TYPE slis_t_listheader,
t_header_g TYPE slis_t_listheader. " haeder for grid
&----
*& Form create_header
&----
This perform need to be called in top of page event of a report.
This creates a page heading
----
CONSTANTS :
c_createdby(14) TYPE c VALUE 'Created by: ', "#EC NOTEXT "Created by
c_jci(22) TYPE c VALUE 'Johnson Controls, Inc.', "#EC NOTEXT name
c_on(2) VALUE 'on', "#EC NOTEXT "date
c_at(2) VALUE 'at', "#EC NOTEXT "time
c_at1(5) VALUE 'At : ', "#EC NOTEXT "time
c_abap(14) VALUE 'Program Name: ', "#EC NOTEXT
c_in(14) VALUE 'In System : ', "#EC NOTEXT
c_page(14) VALUE 'Page : ', "#EC NOTEXT
c_of(2) VALUE 'of',
c_colon VALUE ':',
c_slash VALUE '/',
c_s VALUE 'S',
c_eor(19) TYPE c VALUE '**End of Report**'.
&----
*& Form create_header
&----
text
----
FORM create_header. "#EC CALLED
*constants :
c_createdby(14) type c value 'Created by: ', "Created by
c_jci(22) type c value 'Johnson Controls, Inc.',"company
*name
c_on(2) value 'on', "date
c_at(2) value 'at', "time
c_abap(14) value 'Program Name: ',
c_in(14) value 'In System : ',
c_page(14) value 'Page : ',
c_of(2) value 'of'.
DATA: v_system(15).
CONCATENATE sy-sysid sy-mandt INTO v_system SEPARATED BY '/'.
WRITE : c_jci.
WRITE 😕 c_createdby, sy-uname, c_on, sy-datum, c_at, sy-uzeit.
WRITE 😕 c_in, v_system.
WRITE 😕 c_abap, sy-repid LEFT-JUSTIFIED.
SKIP.
WRITE 😕 sy-title LEFT-JUSTIFIED.
IF sy-batch NE 'X'.
WRITE 😕 c_page, sy-pagno, c_of, '*****'.
ELSE.
WRITE 😕 c_page, sy-pagno.
ENDIF.
ULINE.
ENDFORM. "create_header
&----
*& Form create_footer
&----
This perform need to be called in end of list event of a report.
This creates a page footer and the page count initially set as
'*****' and this will be replace by the form reset_pagecount.
----
FORM create_footer.
DATA : v_linsz TYPE i.
CONSTANTS : c_eor(19) TYPE c VALUE '**End of Report**'.
v_linsz = ( sy-linsz / 2 ) - 5.
ULINE.
WRITE AT /v_linsz c_eor CENTERED.
ENDFORM. "create_footer
&----
*& Form prepare_alv_header
&----
*
----
FORM prepare_alv_header. "#EC CALLED
DATA:
t_header TYPE slis_t_listheader,
t_header_g TYPE slis_t_listheader, "#EC NEEDED
wa_header TYPE slis_listheader.
DATA: v_pagno(5) TYPE n, "#EC NEEDED
v_year(4),
v_month(2),
v_day(2),
v_hour(2),
v_minute(2),
v_second(2),
v_date LIKE sy-datum,
v_time LIKE sy-uzeit,
v_ftime(8),
v_fdate(10),
v_system(10).
DATA: l_text(60) TYPE c.
v_pagno = sy-pagno.
wa_header-typ = c_s.
wa_header-info = c_jci .
APPEND wa_header TO t_header.
CLEAR wa_header.
wa_header-typ = c_s.
v_date = sy-datum.
**Formatting Date
v_year = v_date+0(4).
v_month = v_date+4(2).
v_day = v_date+6(2).
CONCATENATE v_day v_month v_year INTO v_fdate
SEPARATED BY c_slash.
v_time = sy-uzeit.
*Formatting time
v_hour = v_time+0(2).
v_minute = v_time+2(2).
v_second = v_time+4(2).
CONCATENATE v_hour v_minute v_second INTO v_ftime
SEPARATED BY c_colon .
CONCATENATE sy-sysid sy-mandt INTO v_system SEPARATED BY c_slash.
CONCATENATE c_createdby sy-uname c_on v_fdate c_at v_ftime
INTO wa_header-info SEPARATED BY space .
APPEND wa_header TO t_header.
CLEAR wa_header.
added by tarun
wa_header-typ = c_s.
CONCATENATE c_createdby sy-uname c_on v_fdate
INTO wa_header-info SEPARATED BY space .
APPEND wa_header TO t_header_g.
CLEAR wa_header.
wa_header-typ = c_s.
CONCATENATE c_at v_ftime
INTO wa_header-info SEPARATED BY space .
APPEND wa_header TO t_header_g.
CLEAR wa_header.
wa_header-typ = c_s.
CONCATENATE c_in v_system INTO wa_header-info
SEPARATED BY space.
APPEND wa_header TO t_header_g.
CLEAR wa_header.
wa_header-typ = c_s.
CONCATENATE c_abap sy-repid INTO wa_header-info
SEPARATED BY space.
APPEND wa_header TO t_header_g.
CLEAR wa_header.
*****
wa_header-typ = c_s.
CONCATENATE c_in v_system INTO wa_header-info
SEPARATED BY space.
APPEND wa_header TO t_header.
CLEAR wa_header.
wa_header-typ = c_s.
CONCATENATE c_abap sy-repid INTO wa_header-info
SEPARATED BY space.
APPEND wa_header TO t_header.
CLEAR wa_header.
wa_header-typ = c_s.
wa_header-info = space.
APPEND wa_header TO t_header.
CLEAR wa_header.
wa_header-typ = c_s.
wa_header-info = sy-title.
APPEND wa_header TO t_header.
CLEAR wa_header.
wa_header-typ = 'A'.
concatenate 'Page:' v_pagno 'of' '*****' into wa_header-info
separated by space.
append wa_header to t_header.
clear wa_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = v_logo
it_list_commentary = t_header.
REFRESH t_header.
ENDFORM. "prepare_alv_header
&----
*& Form prepare_alv_header FOR GRID
&----
*
----
FORM prepare_alv_header_g. "#EC CALLED
DATA:
t_header_g TYPE slis_t_listheader, " haeder for grid
wa_header TYPE slis_listheader.
DATA: v_pagno(5) TYPE n, "#EC NEEDED
v_year(4),
v_month(2),
v_day(2),
v_hour(2),
v_minute(2),
v_second(2),
v_date LIKE sy-datum,
v_time LIKE sy-uzeit,
v_ftime(8),
v_fdate(10),
v_system(10).
DATA: l_text TYPE i,
l_repid LIKE sy-repid.
CONSTANTS : c_abap1(9) TYPE c VALUE 'Pg:',
c_abap2(4) TYPE c VALUE 'Pg:'.
v_pagno = sy-pagno.
v_date = sy-datum.
**Formatting Date
v_year = v_date+0(4).
v_month = v_date+4(2).
v_day = v_date+6(2).
CONCATENATE v_day v_month v_year INTO v_fdate
SEPARATED BY c_slash.
v_time = sy-uzeit.
*Formatting time
v_hour = v_time+0(2).
v_minute = v_time+2(2).
v_second = v_time+4(2).
CONCATENATE v_hour v_minute v_second INTO v_ftime
SEPARATED BY c_colon .
CONCATENATE sy-sysid sy-mandt INTO v_system SEPARATED BY c_slash.
wa_header-typ = c_s.
CONCATENATE c_createdby sy-uname c_on v_fdate
INTO wa_header-info SEPARATED BY space .
APPEND wa_header TO t_header_g.
CLEAR wa_header.
wa_header-typ = c_s.
CONCATENATE c_at1 v_ftime
INTO wa_header-info SEPARATED BY space .
APPEND wa_header TO t_header_g.
CLEAR wa_header.
wa_header-typ = c_s.
CONCATENATE c_in v_system INTO wa_header-info
SEPARATED BY space.
APPEND wa_header TO t_header_g.
CLEAR wa_header.
wa_header-typ = c_s.
wa_header-info = sy-repid.
APPEND wa_header TO t_header_g.
CONCATENATE l_REPID INTO WA_HEADER-INFO
SEPARATED BY SPACE.
L_TEXT = STRLEN( WA_HEADER-INFO ).
IF L_TEXT LE 35.
APPEND WA_HEADER TO T_HEADER_G.
ELSE.
CONCATENATE C_ABAP1 SY-REPID INTO WA_HEADER-INFO
SEPARATED BY SPACE.
ENDIF.
CLEAR wa_header.
wa_header-typ = c_s.
wa_header-info = space.
APPEND wa_header TO t_header_g.
CLEAR wa_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = v_logo
it_list_commentary = t_header_g.
REFRESH t_header_g .
ENDFORM. "prepare_alv_header_g
&----
*& Form prepare_alv_footer
&----
*
----
FORM prepare_alv_footer. "#EC CALLED
DATA: t_footer TYPE slis_t_listheader.
DATA: wa_footer TYPE slis_listheader.
wa_footer-typ = c_s.
wa_footer-info = c_eor.
APPEND wa_footer TO t_footer. CLEAR wa_footer.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_footer.
REFRESH t_footer.
ENDFORM. "prepare_alv_footer
&----
*& Form reset_pagecount
&----
This perform need to be called in end of selection event of a report.
This resets the page count in the entire report
----
FORM reset_pagecount USING p_page_count TYPE i. "#EC *
DATA : l_page_count(5) TYPE c, "Total no of pages
l_ind LIKE sy-index, "loop index
l_ind1 LIKE sy-tabix, "#EC * "loop index
l_lines TYPE i, "#EC NEEDED "list index
l_totpages TYPE i. "#EC *
CONSTANTS : c_pagecount(5) TYPE c VALUE '*****',
c_eor(17) TYPE c VALUE '**End of Report**'. "#EC *
l_page_count = sy-pagno .
*-- process for resetting the pagecount in the existing list
DO l_page_count TIMES.
CLEAR l_lines.
l_lines = sy-linct - p_pagefooter.
l_lines = l_lines + 1.
l_ind = sy-index.
do p_pagefooter times.
read line l_lines of page l_ind.
replace c_pagecount with l_page_count into sy-lisel.
if sy-subrc = 0.
modify line l_lines of page l_ind.
endif.
*
if l_ind <> l_page_count.
*
replace c_eor with '' into sy-lisel.
if sy-subrc = 0.
modify line l_lines of page l_ind.
endif.
*
endif.
*
l_lines = l_lines + 1.
enddo.
DO 10 TIMES.
READ LINE sy-index OF PAGE l_ind.
REPLACE c_pagecount WITH l_page_count INTO sy-lisel.
IF sy-subrc = 0.
MODIFY LINE sy-index OF PAGE l_ind.
EXIT.
ENDIF.
if l_ind <> l_page_count.
*
replace c_eor with '' into sy-lisel.
if sy-subrc = 0.
modify line l_lines of page l_ind.
endif.
*
endif.
*
l_lines = l_lines + 1.
ENDDO.
ENDDO.
ENDFORM. "reset_pagecount
*perform reset_gridpage.
*
*DATA : l_page_count(5) type c, "Total no of pages
l_ind like sy-index, "loop index
l_ind1 like sy-tabix, "loop index
l_lines type i, "list index
l_totpages type i.
*
constants : c_pagecount(5) type c value '****',
c_eor(17) type c value '*End of Report*'.
*
*
*l_page_count = sy-pagno .
*
*
*Endform.
SET EXTENDED CHECK ON.
***********************************************************************
DICTIONARY TABLES
***********************************************************************
TABLES :bfok_a, lfa1, lfb1, bsik, bkpf,cepc. "#EC NEEDED
***********************************************************************
TYPES
***********************************************************************
*TYPES:
DATA:
Type like bsik table
BEGIN OF d_ldb_data,
bukrs LIKE bsik-bukrs, "COMPANY CODE
lifnr LIKE bsik-lifnr, "Account Number of Vendor or Creditor
belnr LIKE bsik-belnr, "ACCOUNTING DOCUMENT NUMBER
bldat LIKE bsik-bldat, "DOCUMENT DATE IN DOCUMENT
blart LIKE bsik-blart, "DOCUMENT TYPE
gjahr LIKE bsik-gjahr, "FISCAL YEAR
buzei LIKE bsik-buzei,
"NUMBER OF LINE ITEM WITHIN ACCOUNTING DOCUMENT
xblnr LIKE bsik-xblnr, "REFERENCE DOCUMENT NUMBER
dmbtr LIKE bsik-dmbtr, "AMOUNT IN LOCAL CURRENCY
*--SIR-07541 Begin
lwaer LIKE t001-waers, "LOCAL CURRENCY KEY
hwae2 LIKE bkpf-hwae2, "2ND LOCAL CURRENCY KEY
*--SIR-07541 End
waers LIKE bsik-waers, "CURRENCY KEY
wrbtr LIKE bsid-wrbtr, "AMOUNT IN DOCUMENT CURRENCY
dmbe2 LIKE bsik-dmbe2, "AMOUNT IN SECOND LOCAL CURRENCY
vbund LIKE bsik-vbund, "COMPANY ID OF TRADING PARTNER
ebeln LIKE bsik-ebeln, "BILLING DOCUMENT
augdt LIKE bsik-augdt, "CLEARING DATE
augbl LIKE bsik-augbl, "DOCUMENT NUMBER OF THE CLEARING
"DOCUMENT
zuonr LIKE bsik-zuonr, "ASSIGNMENT NUMBER
budat LIKE bsik-budat, "POSTING DATE IN THE DOCUMENT
sgtxt LIKE bsik-sgtxt, "ITEM TEXT
hkont LIKE bsik-hkont, "GENERAL LEDGER ACCOUNT
zlsch LIKE bsik-zlsch, "PAYMENT METHOD
zlspr LIKE bsik-zlspr, "PAYMENT BLOCK KEY
filkd LIKE bsik-filkd, "ACCOUNT NUMBER OF THE BRANCH
shkzg LIKE bsik-shkzg, "Debit/Credit Indicator
awkey LIKE bkpf-awkey, "Reference Key
prctr LIKE bfok_a-prctr, "Profit Center
pprct LIKE bfok_a-pprct, "Partner Profit Center
status TYPE c, "Status indicator
korrk LIKE bfok_a-korrk, "Adjustment Account
Begin of SRR-22879 APARMAA
name1 LIKE lfa1-name1, "Vendor Name
duedate LIKE sy-datum, "Due Date
aging(5) TYPE c, "Aging Indiacator
zfbdt LIKE bsik-zfbdt,
zbd1t LIKE bsik-zbd1t,
zbd2t LIKE bsik-zbd2t,
zbd3t LIKE bsik-zbd3t,
rebzg LIKE bsik-rebzg,
End of SRR-22879 APARMAA
END OF d_ldb_data,
Type declaration of type bkpf table
BEGIN OF d_bkpf,
bukrs LIKE bkpf-bukrs, "Company Code
belnr LIKE bkpf-belnr, "Accounting Document Number
gjahr LIKE bkpf-gjahr, "Fiscal Year
awkey LIKE bkpf-awkey, "Reference Key
*--SIR-07541 Begin
hwae2 LIKE bkpf-hwae2, "@nd local currency
*--SIR-07541 End
END OF d_bkpf,
Type declaration of type rseg table
BEGIN OF d_rseg ,
belnr LIKE rseg-belnr, "Accounting Document Number
gjahr LIKE rseg-gjahr, "Fiscal Year
buzei LIKE rseg-buzei, "Document item in invoice document
ebeln LIKE rseg-ebeln, "Purchasing Document Number
bukrs LIKE rseg-bukrs, "Company Code
END OF d_rseg,
Begin of SRR-22879 APARMAA
Type declaration of type lfa1 table
BEGIN OF d_lfa1,
lifnr LIKE lfa1-lifnr,
name1 LIKE lfa1-name1,
END OF d_lfa1,
End of SRR-22879 APARMAA
Type declaration of type bfok_a table
BEGIN OF d_bfok_a,
bukrs LIKE bfok_a-bukrs, "Company Code
belnr LIKE bfok_a-belnr, "Accounting Document Numbe
gjahr LIKE bfok_a-gjahr, "Fiscal Year
buzei LIKE bfok_a-buzei, "Number of Line Item
auzei LIKE bfok_a-auzei,
"No of Breakdown by Account Assignments for FI Document
hkont LIKE bfok_a-hkont, "General Ledger Account
shkzg LIKE bfok_a-shkzg, "Debit/Credit Indicator
dmbtr LIKE bfok_a-dmbtr, "AMOUNT IN DOCUMENT CURRENCY
dmbe2 LIKE bfok_a-dmbe2, "Amount in Second Local Currency
prctr LIKE bfok_a-prctr, "Profit Center
pprct LIKE bfok_a-pprct, "Partner Profit Center
korrk LIKE bfok_a-korrk, "Adjustment Account
counter TYPE i,
END OF d_bfok_a.
Begin of SRR-22879 APARMAA
***********************************************************************
Creation of t_final1 table for export to R091.
Since t_ldb_data has been modified for this SRR, exporting of t_final
results in a short dump when R091 is executed.Hence t_final1 is
created with the original structure of t_ldb_data.This will be
exported to R091.
***********************************************************************
DATA:BEGIN OF d_final1,
bukrs LIKE bsik-bukrs, "COMPANY CODE
lifnr LIKE bsik-lifnr, "Account Number of Vendor or Creditor
belnr LIKE bsik-belnr, "ACCOUNTING DOCUMENT NUMBER
bldat LIKE bsik-bldat, "DOCUMENT DATE IN DOCUMENT
blart LIKE bsik-blart, "DOCUMENT TYPE
gjahr LIKE bsik-gjahr, "FISCAL YEAR
buzei LIKE bsik-buzei,
"NUMBER OF LINE ITEM WITHIN ACCOUNTING DOCUMENT
xblnr LIKE bsik-xblnr, "REFERENCE DOCUMENT NUMBER
dmbtr LIKE bsik-dmbtr, "AMOUNT IN LOCAL CURRENCY
*--SIR-07541 Begin
lwaer LIKE t001-waers, "LOCAL CURRENCY KEY
hwae2 LIKE bkpf-hwae2, "2ND LOCAL CURRENCY KEY
*--SIR-07541 End
waers LIKE bsik-waers, "CURRENCY KEY
wrbtr LIKE bsid-wrbtr, "AMOUNT IN DOCUMENT CURRENCY
dmbe2 LIKE bsik-dmbe2, "AMOUNT IN SECOND LOCAL CURRENCY
vbund LIKE bsik-vbund, "COMPANY ID OF TRADING PARTNER
ebeln LIKE bsik-ebeln, "BILLING DOCUMENT
augdt LIKE bsik-augdt, "CLEARING DATE
augbl LIKE bsik-augbl, "DOCUMENT NUMBER OF THE CLEARING
"DOCUMENT
zuonr LIKE bsik-zuonr, "ASSIGNMENT NUMBER
budat LIKE bsik-budat, "POSTING DATE IN THE DOCUMENT
sgtxt LIKE bsik-sgtxt, "ITEM TEXT
hkont LIKE bsik-hkont, "GENERAL LEDGER ACCOUNT
zlsch LIKE bsik-zlsch, "PAYMENT METHOD
zlspr LIKE bsik-zlspr, "PAYMENT BLOCK KEY
filkd LIKE bsik-filkd, "ACCOUNT NUMBER OF THE BRANCH
shkzg LIKE bsik-shkzg, "Debit/Credit Indicator
awkey LIKE bkpf-awkey, "Reference Key
prctr LIKE bfok_a-prctr, "Profit Center
pprct LIKE bfok_a-pprct, "Partner Profit Center
status TYPE c, "Status indicator
korrk LIKE bfok_a-korrk, "Adjustment Account
END OF d_final1.
End of SRR-22879 APARMAA
***********************************************************************
TYPE-POOLS
***********************************************************************
TYPE-POOLS: slis, " TYPE POOL FOR ALV REPORT
slist. " System: List Processor for ALV List
*
***********************************************************************
ALV SPECIFIC DECLARATIONS
***********************************************************************
DATA:
TABLES REQUIRED SPECIFICALLY FOR ALV REPORTING
t_sortcat TYPE slis_t_sortinfo_alv ,
t_field_catalog TYPE slis_t_fieldcat_alv,
t_events TYPE slis_t_event,
*----
FIELD STRINGS (Naming convention F_)
*----
f_grid_settings TYPE lvc_s_glay, "#EC *
f_grid_layout TYPE slis_layout_alv, "#EC *
f_print_settings TYPE slis_print_alv. "print settings
***********************************************************************
INTERNAL TABLES
***********************************************************************
Int table to get the data from bsik table using logical databse
DATA: t_ldb_data LIKE STANDARD TABLE OF d_ldb_data,
Int table to get the data from bkpf table
t_bkpf LIKE STANDARD TABLE OF d_bkpf,
Int table to store the data from rseg table
t_rseg LIKE STANDARD TABLE OF d_rseg,
Int table to store the data from bfok_a table
t_bfok_a LIKE STANDARD TABLE OF d_bfok_a.
*Int table to store the sum of the values of field dmbtr in t_bfok_a
*table
DATA: t_bfok_a1 LIKE STANDARD TABLE OF d_bfok_a,
t_bfok_a2 LIKE STANDARD TABLE OF d_bfok_a WITH HEADER LINE.
DATA: t_final LIKE STANDARD TABLE OF d_ldb_data WITH HEADER LINE.
*Begin of SRR-17677
Begin of SRR-22879 APARMAA
*DATA: t_r087 LIKE STANDARD TABLE OF d_ldb_data WITH HEADER LINE.
DATA: t_r087 LIKE STANDARD TABLE OF d_final1 WITH HEADER LINE.
End of SRR-22879 APARMAA
*End of SRR-17677
Begin of SRR-22879 APARMAA
DATA: t_lfa1 LIKE STANDARD TABLE OF d_lfa1.
DATA: t_ldb_data1 LIKE STANDARD TABLE OF d_ldb_data.
DATA: t_final1 LIKE STANDARD TABLE OF d_final1 WITH HEADER LINE.
End of SRR-22879 APARMAA
*--SIR-07541 Begin
DATA: wa_t001 TYPE t001,
t_t001 LIKE STANDARD TABLE OF wa_t001.
*--SIR-07541 End
********************************************************************
***********************************************************************
VARIABLES
***********************************************************************
DATA: v_title LIKE sy-title, " Variable for Report Title
v_repid LIKE sy-repid, " Variable for Report Name
v_base_amount LIKE bfok_a-dmbtr, " Base amount to be split
v_amount_sum LIKE bfok_a-dmbtr, " Base amount sum
Begin of SRR-22879 APARMAA
v_aging(5) type c. "SRR-24422
v_aging(5) type n. "SRR-24422
End of SRR-22879 APARMAA
FIELD-SYMBOLS: <ldb_data> LIKE LINE OF t_ldb_data,
<bfok_a> LIKE LINE OF t_bfok_a,
<bfok_a1> LIKE LINE OF t_bfok_a1,
<bkpf> LIKE LINE OF t_bkpf,
<rseg> LIKE LINE OF t_rseg,
Begin of SRR-22879 APARMAA
<lfa1> LIKE LINE OF t_lfa1.
End of SRR-22879 APARMAA
***********************************************************************
RANGES
***********************************************************************
***********************************************************************
CONSTANTS
***********************************************************************
CONSTANTS:c_logo(5) TYPE c VALUE 'R087',
c_flag TYPE c VALUE 'X',
c_flag1 TYPE c VALUE 'x',
c_010 TYPE p DECIMALS 6 VALUE '0.10',
c_f TYPE c VALUE 'F',
c_debit TYPE c VALUE 'H',
c_xyz(3) TYPE c VALUE 'XYZ', "SRR-17677
c_waers LIKE bsid-waers VALUE 'JPY',
Begin of SRR-22879 APARMAA
c_0to29(5) VALUE '<30',
c_30to59(5) VALUE '31-60',
c_60to89(5) VALUE '61-90',
c_90on(5) VALUE '90+'.
End of SRR-22879 APARMAA
***********************************************************************
SELECTION SCREEN
***********************************************************************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_prctr FOR cepc-prctr," Profit center
s_hkont FOR bsik-hkont,"General Ledger Account
s_pprct FOR bfok_a-pprct. "Partner Profit Center
SELECTION-SCREEN END OF BLOCK b1.
Selection screen for ALV List displat
SELECTION-SCREEN BEGIN OF BLOCK disp WITH FRAME TITLE text-004.
PARAMETERS: p_grid RADIOBUTTON GROUP r2 DEFAULT 'X'
MODIF ID abc, " Grid Display
p_list RADIOBUTTON GROUP r2 MODIF ID abc. " List Display
SELECTION-SCREEN END OF BLOCK disp.
Begin of SRR-22879 APARMAA
SELECTION-SCREEN BEGIN OF BLOCK use_new WITH FRAME TITLE text-055.
PARAMETERS: p_use AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK use_new.
End of SRR-22879 APARMAA
*Begin of SRR-17677
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-054.
PARAMETERS: p_disp AS CHECKBOX DEFAULT 'X' MODIF ID xyz,
p_expo AS CHECKBOX MODIF ID xyz.
SELECTION-SCREEN END OF BLOCK b2.
&----
*& Form f_valiate_profit_center
&----
Validate profit center on selection screen
----
FORM f_valiate_profit_center .
IF NOT s_prctr[] IS INITIAL.
Local variable for profit center(s_prctr) validation
DATA:v_prctr LIKE cepc-prctr. "#EC NEEDED
SELECT SINGLE prctr FROM cepc INTO v_prctr WHERE prctr IN s_prctr.
"#EC *
IF sy-subrc NE 0.
Message please enter valid profit center
MESSAGE e000(zfi) WITH text-002.
ENDIF.
ENDIF.
ENDFORM. " f_valiate_profit_center
&----
*& Form f_get_ebeln_from_rseg
&----
Purpose:To get the purchase doc number from the table rseg
----
FORM f_get_ebeln_from_rseg .
Select belnr,gjahr buzei ebeln fields from rseg table
SELECT belnr
gjahr
buzei
ebeln
bukrs
FROM rseg INTO TABLE t_rseg
FOR ALL ENTRIES IN t_bkpf
WHERE belnr = t_bkpf-awkey+0(10) AND
gjahr = t_bkpf-gjahr AND
bukrs = t_bkpf-bukrs .
Sort and delete the adjacent duplicates from t_rseg table
IF sy-subrc EQ 0.
SORT t_rseg BY bukrs belnr gjahr .
DELETE ADJACENT DUPLICATES FROM t_rseg COMPARING belnr gjahr bukrs.
ENDIF.
ENDFORM. " f_get_ebeln_from_rseg
&----
*& Form f_get_data_from_bfok_a
&----
Purpose:Get data from bfok_a table
----
FORM f_get_data_from_bfok_a .
Select data from bfok_a table
SELECT bukrs
belnr
gjahr
buzei
auzei
hkont
shkzg
dmbtr
dmbe2
prctr
pprct
korrk
FROM bfok_a
INTO TABLE t_bfok_a FOR ALL ENTRIES IN t_ldb_data
WHERE bukrs = t_ldb_data-bukrs AND
belnr = t_ldb_data-belnr AND
gjahr = t_ldb_data-gjahr AND
buzei = t_ldb_data-buzei AND
pprct IN s_pprct.
Sort t_bfok_a table on fields bukrs belnr gjahr buzei
IF sy-subrc EQ 0.
SORT t_bfok_a BY bukrs belnr gjahr buzei auzei ASCENDING dmbtr
DESCENDING.
ENDIF.
ENDFORM. " f_get_data_from_bfok_a
&----
*& Form f_get_sum_from_bfok_a
&----
purpose:To get the sum of the line item field of dmbtr
----
FORM f_get_sum_from_bfok_a .
Line item counter
DATA : l_index LIKE sy-tabix, "To get the index
v_counter TYPE i. "Counter to store line items
t_bfok_a2[] = t_bfok_a[].
Get the sum of all the line items dmbtr(amount) field
LOOP AT t_bfok_a2 .
MOVE:t_bfok_a TO wa_bfok_a.
Increment the line item counter
v_counter = v_counter + 1.
IF t_bfok_a2-shkzg EQ c_debit.
t_bfok_a2-dmbtr = t_bfok_a2-dmbtr * -1.
t_bfok_a2-dmbe2 = t_bfok_a2-dmbe2 * -1.
MODIFY t_bfok_a2.
ENDIF.
Find the sum of dmbtr field at end of belnr
AT END OF buzei.
SUM.
MOVE-CORRESPONDING t_bfok_a2 TO d_bfok_a.
d_bfok_a-counter = v_counter.
APPEND d_bfok_a TO t_bfok_a1.
CLEAR: v_counter.
ENDAT.
CLEAR t_bfok_a2.
ENDLOOP.
Sort t_bfok_a1 on bukrs belnr gjahr buzei
SORT t_bfok_a1 BY bukrs belnr gjahr buzei ASCENDING dmbtr DESCENDING.
SORT t_ldb_data BY bukrs belnr gjahr buzei ASCENDING .
SORT t_bfod_a1 BY bukrs belnr gjahr buzei.
t_bfok_a[] = t_bfok_a2[].
FREE t_bfok_a2[].
Find the sum of line items having single line item
LOOP AT t_bfok_a1 ASSIGNING <bfok_a1> WHERE counter = 1.
l_index = sy-tabix.
READ TABLE t_ldb_data WITH KEY bukrs = <bfok_a1>-bukrs
belnr = <bfok_a1>-belnr
gjahr = <bfok_a1>-gjahr
buzei = <bfok_a1>-buzei
ASSIGNING <ldb_data>
BINARY SEARCH.
IF sy-subrc = 0.
MOVE-CORRESPONDING <ldb_data> TO t_final.
*--SIR-07541 Begin
READ TABLE t_t001 INTO wa_t001 WITH KEY bukrs = <bfok_a1>-bukrs.
IF sy-subrc = 0.
t_final-lwaer = wa_t001-waers.
ENDIF.
READ TABLE t_bkpf INTO d_bkpf WITH KEY bukrs = <bfok_a1>-bukrs
belnr = <bfok_a1>-belnr
gjahr = <bfok_a1>-gjahr.
IF sy-subrc = 0.
t_final-hwae2 = d_bkpf-hwae2.
ENDIF.
*--SIR-07541 End
Begin of SRR-22879 APARMAA
Move Vendor Name
READ TABLE t_lfa1 WITH KEY lifnr = <ldb_data>-lifnr
ASSIGNING <lfa1>
BINARY SEARCH.
IF sy-subrc EQ 0.
MOVE:<lfa1>-name1 TO t_final-name1.
ENDIF.
Calculate Due Date
CALL FUNCTION 'NET_DUE_DATE_GET'
EXPORTING
i_zfbdt = <ldb_data>-zfbdt
i_zbd1t = <ldb_data>-zbd1t
i_zbd2t = <ldb_data>-zbd2t
i_zbd3t = <ldb_data>-zbd3t
i_shkzg = <ldb_data>-shkzg
i_rebzg = <ldb_data>-rebzg
i_koart = 'K'
IMPORTING
e_faedt = t_final-duedate.
Calculate Aging Details.
v_aging = sy-datum - <ldb_data>-zfbdt.
IF v_aging GE 0 AND
v_aging LE 29.
t_final-aging = c_0to29.
ENDIF.
IF v_aging GE 30 AND
v_aging LE 59.
t_final-aging = c_30to59.
ENDIF.
IF v_aging GE 60 AND
v_aging LE 89.
t_final-aging = c_60to89.
ENDIF.
IF v_aging GE 90.
t_final-aging = c_90on.
ENDIF.
End of SRR-22879 APARMAA
PERFORM f_check_debit_credit_indicator USING <ldb_data>-shkzg.
READ TABLE t_bfok_a WITH KEY bukrs = <bfok_a1>-bukrs
belnr = <bfok_a1>-belnr
gjahr = <bfok_a1>-gjahr
buzei = <bfok_a1>-buzei
ASSIGNING <bfok_a>
BINARY SEARCH.
IF sy-subrc EQ 0.
*--SRR-25731 Begin
IF t_final-dmbtr ne <bfok_a1>-dmbtr.
CATCH SYSTEM-EXCEPTIONS arithmetic_errors = 5.
*For other break down line items the split amount is calculated as below
t_final-wrbtr = ( <ldb_data>-wrbtr * <bfok_a>-dmbtr )
/ <ldb_data>-dmbtr.
ENDCATCH.
ENDIF.
*--SRR-25731 End
v_amount_sum = v_amount_sum + t_final-wrbtr.
Move dmbtr,bmbe2,korrk fields from t_bfok_a to t_final int table
MOVE:<bfok_a>-dmbtr TO t_final-dmbtr,
<bfok_a>-dmbe2 TO t_final-dmbe2,
<bfok_a>-korrk TO t_final-korrk.
ENDIF.
Populate the status field to t_final int table
Read t_bkpf table
READ TABLE t_bkpf WITH KEY bukrs = <ldb_data>-bukrs
belnr = <ldb_data>-belnr
gjahr = <ldb_data>-gjahr
ASSIGNING <bkpf>
BINARY SEARCH.
IF sy-subrc EQ 0.
Read table t_rseg
READ TABLE t_rseg WITH KEY bukrs = <bkpf>-bukrs
belnr = <bkpf>-awkey+0(10)
gjahr = <bkpf>-gjahr
ASSIGNING <rseg>
BINARY SEARCH.
IF sy-subrc NE 0.
Populate status field with value 'F'
t_final-status = c_f.
ENDIF.
ENDIF.
PERFORM f_check_debit_credit_indicator USING <bfok_a>-shkzg.
t_final-prctr = <bfok_a>-prctr.
t_final-pprct = <bfok_a>-pprct.
APPEND t_final.
CLEAR: t_final. "t_bfok_a.
DELETE t_bfok_a1 INDEX l_index.
ENDIF.
ENDLOOP.
ENDFORM. " f_get_sum_from_bfok_a
&----
*& Form f_build_print_settings
&----
in_print
----
FORM f_build_print_settings USING in_print TYPE slis_print_alv .
in_print-no_print_selinfos = c_flag.
in_print-no_print_listinfos = c_flag.
in_print-no_coverpage = c_flag.
ENDFORM. " f_build_print_settings
&----
*& Form f_build_layout
&----
Purpose:To build ALV layout
----
P_F_GRID_LAYOUT -Grid layout
P_V_TITLE - Title
----
FORM f_build_layout USING in_layout TYPE slis_layout_alv in_repid TYPE
any.
in_layout-zebra = 'X'.
in_layout-window_titlebar = in_repid. "Put Report Name in titlebar
in_layout-expand_fieldname = t_slis_ev_item_data_expand.
in_layout-colwidth_optimize = 'X'. "Optimize column widths
Set Grid display settings
f_grid_settings-coll_top_p = c_flag1.
f_grid_settings-coll_end_l = c_flag1.
f_grid_settings-top_p_only = c_flag1.
f_grid_settings-eol_p_only = c_flag1.
in_layout-totals_text = 'TOTAL:'(035).
in_layout-subtotals_text = 'SubTotal:'(036).
ENDFORM. " f_build_layout
&----
*& Form f_build_events
&----
To build events
----
P_T_EVENTS[] ->events
----
FORM f_build_events USING p_events TYPE slis_t_event.
DATA l_f_events TYPE slis_alv_event.
CLEAR l_f_events.
l_f_events-name = 'TOP_OF_PAGE'.
l_f_events-form = 'PREPARE_ALV_HEADER_G'.
APPEND l_f_events TO p_events.
ENDFORM. " f_build_events
&----
*& Form f_display_data
&----
To display data
----
FORM f_display_data .
BUILD FIELD CATALOG
PERFORM f_fieldcat_build :
Company code
USING 'BUKRS' 'T_FINAL' ' ' ' ' ' ' 'Comp Code'(031)
' ' ' ' ' ' ' ' ' ' '',
Customer
USING 'LIFNR' 'T_FINAL' ' ' ' ' ' ' 'Vendor'(005)
' ' ' ' ' ' ' ' ' ' '',
Account Number of the Branch
USING 'FILKD' 'T_FINAL' ' ' ' ' ' ' 'Branch'(044)
' ' ' ' ' ' ' ' ' ' '',
General Ledger Account
USING 'HKONT' 'T_FINAL' ' ' ' ' 'X' 'Genderal Ledger Account'(027)
' ' ' ' ' ' ' ' ' ' '',
Adjustment Account
USING 'KORRK' 'T_FINAL' ' ' ' ' 'X' 'Adjustment Account'(053)
' ' ' ' ' ' ' ' ' ' '',
Document Number
USING 'BELNR' 'T_FINAL' ' ' ' ' ' ' 'Document Number'(006)
' ' ' ' ' ' ' ' ' ' '',
Document date
USING 'BLDAT' 'T_FINAL' ' ' ' ' ' ' 'Document date'(007)
' ' ' ' ' ' ' ' ' ' '',
Document type
USING 'BLART' 'T_FINAL' ' ' ' ' ' ' 'Document type'(008)
' ' ' ' ' ' ' ' ' ' '',
Fiscal Year
USING 'GJAHR' 'T_FINAL' ' ' ' ' ' ' 'Fiscal Year'(009)
' ' ' ' ' ' ' ' ' ' '',
Line item
USING 'BUZEI' 'T_FINAL' ' ' ' ' ' ' 'Line item'(010)
' ' ' ' ' ' ' ' ' ' '',
Reference
USING 'XBLNR' 'T_FINAL' ' ' ' ' ' ' 'Reference'(011)
' ' ' ' ' ' ' ' ' ' '',
*--SIR-07541 Begin
Local currency
USING 'LWAER' 'T_FINAL' ' ' ' ' ' ' 'Local Currency'(040)
' ' ' ' ' ' ' ' ' ' '',
*--SIR-07541 End
Amount in local currency
USING 'DMBTR' 'T_FINAL' ' ' ' ' ' ' 'Amount in local currency'(012)
' ' ' ' ' ' 'X' 'LWAER' '',
Document Currency
USING 'WAERS' 'T_FINAL' ' ' ' ' ' ' 'Document Currency'(013)
' ' ' ' ' ' ' ' ' ' '',
Amount in document currency
USING 'WRBTR' 'T_FINAL' ' ' ' ' ' ' 'Amount in document currency'(014)
' ' ' ' ' ' 'X' 'WAERS' '',
*--SIR-07541 Begin
2nd Local Currency
USING 'HWAE2' 'T_FINAL' ' ' ' ' ' ' '2nd Local Currency'(041)
' ' ' ' ' ' ' ' ' ' '',
*--SIR-07541 End
Amount in Second Local Currency
USING 'DMBE2' 'T_FINAL' ' ' ' ' ' '
'Amount in Second Local currency'(015)
' ' ' ' ' ' 'X' 'HWAE2' '',
Profit Center
USING 'PRCTR' 'T_FINAL' ' ' ' ' ' ' 'Profit Center'(016)
' ' ' ' ' ' ' ' ' ' '',
Partner Profit Center
USING 'PPRCT' 'T_FINAL' ' ' ' ' ' ' 'Partner Profit Center'(017)
' ' ' ' ' ' ' ' ' ' '',
Trading Partner
USING 'VBUND' 'T_FINAL' ' ' ' ' ' ' 'Trading Partner'(018)
' ' ' ' ' ' ' ' ' ' '',
Purchasing doc no
USING 'EBELN' 'T_FINAL' ' ' ' ' ' ' 'Purchasing Document number'(019)
' ' ' ' ' ' ' ' ' ' '',
USING 'AWKEY' 'T_FINAL' ' ' ' ' ' ' 'Reference key'(020)
' ' ' ' ' ' ' ' ' ' '',
Status field
USING 'STATUS' 'T_FINAL' ' ' ' ' ' ' 'Status'(021)
' ' ' ' ' ' ' ' ' ' '',
Clearing date
USING 'AUGDT' 'T_FINAL' ' ' ' ' ' ' 'Clearing date'(022)
' ' 'X' ' ' ' ' ' ' '',
Document Number of the Clearing Document
USING 'AUGBL' 'T_FINAL' ' ' ' ' 'X' 'Clearing Document No'(023)
' ' 'X' ' ' ' ' ' ' '',
Assignment
USING 'ZUONR' 'T_FINAL' ' ' ' ' 'X' 'Assignment'(024)
' ' 'X' ' ' ' ' ' ' '',
Posting Date
USING 'BUDAT' 'T_FINAL' ' ' ' ' 'X' 'Posting Date'(025)
' ' 'X' ' ' ' ' ' ' '',
Item Text
USING 'SGTXT' 'T_FINAL' ' ' ' ' 'X' 'Item Text'(026)
' ' 'X' ' ' ' ' ' ' '',
Payment method
USING 'ZLSCH' 'T_FINAL' ' ' ' ' 'X' 'Payment method'(028)
' ' 'X' ' ' ' ' ' ' '',
Payment Block Key
USING 'ZLSPR' 'T_FINAL' ' ' ' ' 'X' 'Payment Block Key'(029)
' ' 'X' ' ' ' ' ' ' ''.
Begin of SRR-22879 APARMAA
IF p_use EQ 'X'.
PERFORM f_fieldcat_build :
Vendor Name
USING 'NAME1' 'T_FINAL' ' ' ' ' ' ' 'Vendor Name'(054)
' ' ' ' ' ' ' ' ' ' '',
Due Date
USING 'DUEDATE' 'T_FINAL' ' ' ' ' ' ' 'Due Date'(056)
' ' ' ' ' ' ' ' ' ' '',
BEGIN OF SRR 25449
USING 'AGING' 'T_FINAL' ' ' ' ' ' ' 'Aging Details'(057)
' ' ' ' ' ' ' ' ' ' ''.
Current
Using 'WRBTR' 'T_FINAL' ' ' ' ' ' ' 'current'(061)
' ' ' ' ' ' ' ' 'WAERS' '',
31-60
USING 'WRBTR' 'T_FINAL' ' ' ' ' ' ' '31-60'(058)
' ' ' ' ' ' ' ' 'WAERS' '',
61-90
USING 'WRBTR' 'T_FINAL' ' ' ' ' ' ' '61-90'(059)
' ' ' ' ' ' ' ' 'WAERS' '',
>90
USING 'WRBTR' 'T_FINAL' ' ' ' ' ' ' '>90'(060)
' ' ' ' ' ' ' ' 'WAERS' ''.
END OF SRR 25449
ENDIF.
End of SRR-22879 APARMAA
BUILD SORT CATALOG
PERFORM f_sortcat_build :
SORT BY COMPANY CODE
USING '01' 'BUKRS' 'T_FINAL' 'X' 'X',
SORT BY Venodr Number
USING '01' 'LIFNR' 'T_FINAL' 'X' 'X',
SORT BY Document Number
USING '01' 'BELNR' 'T_FINAL' 'X' ' ',
SORT BY Fiscal Year
USING '01' 'GJAHR' 'T_FINAL' 'X' ' '.
IF p_list = 'X'.
*GENERATE CLASSIC LIST LAYOUT
PERFORM f_call_alv_list_view1.
ELSEIF p_grid = 'X'.
*--GENERATE CLASSIC GRID LAYOUT
PERFORM f_call_alv_grid_viewer1.
ENDIF.
ENDFORM. " f_display_data
&----
*& Form f_fieldcat_build
&----
To build field catelog
----
----
FORM f_fieldcat_build USING l_fieldname TYPE slis_fieldname
l_tabname TYPE slis_tabname
l_reftab LIKE dd03p-tabname
l_reffield LIKE dd03p-fieldname
l_outputlen TYPE any
l_seltext_l LIKE dd03p-scrtext_l
l_hotspot TYPE c
l_no_out TYPE c
l_no_zero TYPE c
l_do_sum TYPE c
l_cfldname TYPE char30
l_col_pos LIKE sy-cucol.
*LOCAL DATA
DATA : l_wa_fieldcat LIKE LINE OF t_field_catalog.
l_wa_fieldcat-fieldname = l_fieldname.
l_wa_fieldcat-tabname = l_tabname.
l_wa_fieldcat-outputlen = l_outputlen.
l_wa_fieldcat-hotspot = l_hotspot.
l_wa_fieldcat-no_out = l_no_out .
l_wa_fieldcat-no_zero = l_no_zero .
l_wa_fieldcat-do_sum = l_do_sum .
l_wa_fieldcat-cfieldname = l_cfldname.
l_wa_fieldcat-col_pos = l_col_pos.
*--SIR-07541 Begin
IF l_fieldname = 'DMBTR'.
l_wa_fieldcat-cfieldname = 'LWAER'.
ENDIF.
IF l_fieldname = 'WRBTR'.
l_wa_fieldcat-cfieldname = 'WAERS'.
ENDIF.
IF l_fieldname = 'DMBE2'.
l_wa_fieldcat-cfieldname = 'HWAE2'.
ENDIF.
*--SIR-07541 End
IF NOT l_seltext_l IS INITIAL.
l_wa_fieldcat-seltext_l = l_seltext_l.
ELSE.
l_wa_fieldcat-ref_fieldname = l_reffield.
l_wa_fieldcat-ref_tabname = l_reftab.
ENDIF.
APPEND l_wa_fieldcat TO t_field_catalog.
CLEAR l_wa_fieldcat.
ENDFORM. " f_fieldcat_build
&----
*& Form f_sortcat_build
&----
To sort the catelog
----
FORM f_sortcat_build USING l_spos LIKE alvdynp-sortpos
l_fieldname TYPE slis_fieldname
l_tabname TYPE slis_tabname
l_up TYPE c
l_subtot TYPE c.
LOCAL DATA
DATA: l_sort TYPE slis_sortinfo_alv.
l_sort-spos = l_spos.
l_sort-fieldname = l_fieldname.
l_sort-tabname = l_tabname.
l_sort-up = l_up.
l_sort-subtot = l_subtot.
APPEND l_sort TO t_sortcat.
CLEAR l_sort.
ENDFORM. " f_sortcat_build
&----
*& Form f_call_alv_list_view1
&----
To call alv_list_display
----
FORM f_call_alv_list_view1 .
v_repid = sy-repid.
v_title = sy-title.
IF NOT t_final[] IS INITIAL.
DISPLAY THE REPORT
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = v_repid
i_callback_user_command = 'F_USER_COMMAND'
is_layout = f_grid_layout
it_fieldcat = t_field_catalog[]
it_sort = t_sortcat[]
i_default = 'X'
i_save = 'A'
it_events = t_events[]
is_print = f_print_settings
TABLES
t_outtab = t_final[]
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
*ALV Grid Display error
MESSAGE i000 WITH 'ALV Grid Display error'(033).
STOP.
ENDIF.
ELSE.
NO RECORDS MATCH THE SELECTION CRITERIA!'.
MESSAGE i000 WITH
'No data exists for the given selection criteria'(003).
STOP.
ENDIF.
ENDFORM. " f_call_alv_list_view1
&----
*& Form f_call_alv_grid_viewer1
&----
Purpose:To call reuse_alv_grid_display
----
FORM f_call_alv_grid_viewer1 .
IF NOT t_final[] IS INITIAL.
DISPLAY THE REPORT
CALL ABAP/4 GRID VIEWER
v_repid = sy-repid.
v_title = sy-title.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
i_callback_user_command = 'F_USER_COMMAND'
i_grid_settings = f_grid_settings
is_layout = f_grid_layout
is_print = f_print_settings
i_background_id = 'BACK'
it_events = t_events[]
it_fieldcat = t_field_catalog[]
it_sort = t_sortcat[]
i_default = 'X'
i_save = 'A'
TABLES
t_outtab = t_final[]
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
*ALV Grid Display error
MESSAGE i000 WITH 'ALV Grid Display error'(034).
STOP.
ENDIF.
ELSE.
NO RECORDS MATCH THE SELECTION CRITERIA!'.
MESSAGE i000 WITH
'No data exists for the given selection criteria'(003).
STOP.
ENDIF.
ENDFORM. " f_call_alv_grid_viewer1
&----
*& Form f_split_wrbtr_in_bsik
&----
Purpose:To split the amount in wrbtr filed
----
FORM f_split_wrbtr_in_bsik.
Counter for line item
DATA: l_countr TYPE i,
l_bfok_countr TYPE i,
l_suspend_drcr TYPE c.
wa of type t_final
DATA: wa_final LIKE t_final.
SORT t_ldb_data BY bukrs belnr gjahr buzei ASCENDING dmbtr
DESCENDING.
Split the amount in wrbtr field of ldb_dat int table
based on the no of line items in t_bfok_a int table
To split wrbtr(Amount in document currency)
LOOP AT t_bfok_a1 ASSIGNING <bfok_a1> WHERE counter > 1.
CLEAR l_countr.
CLEAR v_amount_sum.
CLEAR v_base_amount.
CLEAR l_suspend_drcr.
LOOP AT t_bfok_a ASSIGNING <bfok_a> WHERE bukrs = <bfok_a1>-bukrs
AND belnr = <bfok_a1>-belnr
AND gjahr = <bfok_a1>-gjahr
AND buzei = <bfok_a1>-buzei.
Counter for line item
l_countr = l_countr + 1.
Read t_ldb_data table
READ TABLE t_ldb_data WITH KEY bukrs = <bfok_a>-bukrs
belnr = <bfok_a>-belnr
gjahr = <bfok_a>-gjahr
buzei = <bfok_a>-buzei
ASSIGNING <ldb_data>.
IF sy-subrc = 0.
Move the header data from t_ldb_data to t_final.
MOVE-CORRESPONDING <ldb_data> TO t_final.
*--SIR-07541 Begin
READ TABLE t_t001 INTO wa_t001 WITH KEY bukrs = <bfok_a1>-bukrs.
IF sy-subrc = 0.
t_final-lwaer = wa_t001-waers.
ENDIF.
READ TABLE t_bkpf INTO d_bkpf WITH KEY bukrs = <bfok_a1>-bukrs
belnr = <bfok_a1>-belnr
gjahr = <bfok_a1>-gjahr.
IF sy-subrc = 0.
t_final-hwae2 = d_bkpf-hwae2.
ENDIF.
*--SIR-07541 End
Move dmbtr,bmbe2,korrk fields from t_bfok_a to t_final int table
MOVE:<bfok_a>-dmbtr TO t_final-dmbtr,
<bfok_a>-dmbe2 TO t_final-dmbe2,
<bfok_a>-korrk TO t_final-korrk.
v_base_amount = <ldb_data>-wrbtr.
l_bfok_countr = <bfok_a1>-counter.
Populate the status field to t_final int table
CLEAR t_bkpf.
Read t_bkpf table
READ TABLE t_bkpf WITH KEY bukrs = <ldb_data>-bukrs
belnr = <ldb_data>-belnr
gjahr = <ldb_data>-gjahr
ASSIGNING <bkpf>
BINARY SEARCH.
IF sy-subrc EQ 0.
Read table t_rseg
READ TABLE t_rseg WITH KEY bukrs = <bkpf>-bukrs
belnr = <bkpf>-awkey+0(10)
gjahr = <bkpf>-gjahr
ASSIGNING <rseg>
BINARY SEARCH.
IF sy-subrc NE 0.
Populate status field with value 'F'
t_final-status = c_f.
ENDIF.
ENDIF.
For the last break down line the split amount is calculated as below
IF l_countr = l_bfok_countr.
t_final-wrbtr = v_base_amount - v_amount_sum .
t_final-wrbtr = v_amount_sum - v_base_amount.
l_suspend_drcr = 'x'.
ELSE.
CATCH SYSTEM-EXCEPTIONS arithmetic_errors = 5.
*For other break down line items the split amount is calculated as below
t_final-wrbtr = ( <ldb_data>-wrbtr * <bfok_a>-dmbtr )
/ <bfok_a1>-dmbtr.
ENDCATCH.
v_amount_sum = v_amount_sum + t_final-wrbtr.
ENDIF.
Check for wrbtr less than 0.1
IF ABS( t_final-wrbtr ) < c_010.
SORT t_final BY bukrs belnr gjahr buzei ASCENDING wrbtr
DESCENDING.
READ TABLE t_final WITH KEY bukrs = <ldb_data>-bukrs
belnr = <ldb_data>-belnr
gjahr = <ldb_data>-gjahr
INTO wa_final.
IF sy-subrc = 0.
wa_final-wrbtr = wa_final-wrbtr + t_final-wrbtr.
MODIFY t_final FROM wa_final INDEX sy-tabix TRANSPORTING wrbtr.
t_final-prctr = <bfok_a>-prctr.
t_final-pprct = <bfok_a>-pprct.
t_final-wrbtr = space.
Check for debit and credit indicator(shkzg) field with 'H'
PERFORM f_check_debit_credit_indicator USING <bfok_a>-shkzg.
Begin of SRR-22859 APARMAA
Move Vendor Name
READ TABLE t_lfa1 WITH KEY lifnr = t_final-lifnr
ASSIGNING <lfa1>
BINARY SEARCH.
IF sy-subrc IS INITIAL.
t_final-name1 = <lfa1>-name1.
ENDIF.
Calculate Due Date
CALL FUNCTION 'NET_DUE_DATE_GET'
EXPORTING
i_zfbdt = t_final-zfbdt
i_zbd1t = t_final-zbd1t
i_zbd2t = t_final-zbd2t
i_zbd3t = t_final-zbd3t
i_shkzg = t_final-shkzg
i_rebzg = t_final-rebzg
i_koart = 'K'
IMPORTING
e_faedt = t_final-duedate.
Calculate Aging Details.
v_aging = sy-datum - t_final-zfbdt.
IF v_aging GE 0 AND
v_aging LE 29.
t_final-aging = c_0to29.
ENDIF.
IF v_aging GE 30 AND
v_aging LE 59.
t_final-aging = c_30to59.
ENDIF.
IF v_aging GE 60 AND
v_aging LE 89.
t_final-aging = c_60to89.
ENDIF.
IF v_aging GE 90.
t_final-aging = c_90on.
ENDIF.
End of SRR-22859 APARMAA
APPEND t_final.
CLEAR t_final.
CONTINUE.
ENDIF.
ENDIF.
t_final-prctr = <bfok_a>-prctr.
t_final-pprct = <bfok_a>-pprct.
Check for debit and credit indicator(shkzg) field with 'H'
IF l_suspend_drcr IS INITIAL.
PERFORM f_check_debit_credit_indicator USING <bfok_a>-shkzg.
ENDIF.
Begin of SRR-22859 APARMAA
Move Vendor Name
READ TABLE t_lfa1 WITH KEY lifnr = t_final-lifnr
ASSIGNING <lfa1>
BINARY SEARCH.
IF sy-subrc IS INITIAL.
t_final-name1 = <lfa1>-name1.
ENDIF.
Calculate Due Date
CALL FUNCTION 'NET_DUE_DATE_GET'
EXPORTING
i_zfbdt = t_final-zfbdt
i_zbd1t = t_final-zbd1t
i_zbd2t = t_final-zbd2t
i_zbd3t = t_final-zbd3t
i_shkzg = t_final-shkzg
i_rebzg = t_final-rebzg
i_koart = 'K'
IMPORTING
e_faedt = t_final-duedate.
Calculate Aging Details.
v_aging = sy-datum - t_final-zfbdt.
IF v_aging GE 0 AND
v_aging LE 29.
t_final-aging = c_0to29.
ENDIF.
IF v_aging GE 30 AND
v_aging LE 59.
t_final-aging = c_30to59.
ENDIF.
IF v_aging GE 60 AND
v_aging LE 89.
t_final-aging = c_60to89.
ENDIF.
IF v_aging GE 90.
t_final-aging = c_90on.
ENDIF.
End of SRR-22859 APARMAA
APPEND t_final.
CLEAR: t_final.
ENDIF.
AT END OF buzei.
CLEAR l_countr.
CLEAR v_amount_sum.
CLEAR v_base_amount.
CLEAR l_suspend_drcr.
ENDAT.
ENDLOOP.
ENDLOOP.
TO delete the entires whcih are not belong to profit center of *
selection screen
DELETE t_final WHERE prctr NOT IN s_prctr.
ENDFORM. " f_split_wrbtr_in_bsik
&----
*& Form f_check_debit_credit_indicator
&----
To check with credit and debit indicator with value 'H'
----
FORM f_check_debit_credit_indicator USING p_shkzg TYPE bsik-shkzg.
Multipy with 100 when currency is JPY
IF t_final-waers = c_waers.
t_final-wrbtr = t_final-wrbtr * 100.
ENDIF.
IF p_shkzg = c_debit.
These lines commented as the debit indicator is now checked in
f_get_sum_from_bfok_a because the correct signed amount are needed
in that perform
t_final-dmbtr = t_final-dmbtr * -1.
t_final-dmbe2 = t_final-dmbe2 * -1.
t_final-wrbtr = t_final-wrbtr * -1.
ENDIF.
ENDFORM. " f_check_debit_credit_indicator
&----
*& Form f_free_and_clear
&----
Purpose:To clear and free the int tales
----
FORM f_free_and_clear .
Refresh the int tables
REFRESH: t_ldb_data,t_bkpf,t_rseg,t_bfok_a,t_bfok_a1,t_final.
Free the int tables
FREE: t_ldb_data,t_bkpf,t_rseg,t_bfok_a,t_bfok_a1,t_final.
ENDFORM. " f_free_and_clear
----
FORM user_command
----
*
----
FORM f_user_command USING p_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
"#EC *
CASE p_ucomm.
WHEN '&IC1'.
WHEN OTHERS.
ENDCASE.
CLEAR rs_selfield.
ENDFORM. "f_user_command
&----
*& Form f_validate_recon_account
&----
To validate Recon account entered on selection screen
----
FORM f_validate_recon_account .
IF NOT s_hkont[] IS INITIAL.
DATA:v_hkont LIKE bsik-hkont.
SELECT SINGLE saknr INTO v_hkont FROM ska1 "#EC *
WHERE saknr IN s_hkont.
IF sy-subrc NE 0.
MESSAGE e000(zfi) WITH text-051.
ENDIF.
ENDIF.
ENDFORM. " f_validate_recon_account
&----
*& Form f_val_part_profit_center
&----
TO validate partner profit center on selection screen
----
FORM f_val_part_profit_center .
IF NOT s_pprct[] IS INITIAL.
DATA:v_pprct LIKE bsik-pprct.
SELECT SINGLE prctr INTO v_pprct FROM cepc "#EC *
WHERE prctr IN s_pprct.
IF sy-subrc NE 0.
MESSAGE e000(zfi) WITH text-052.
ENDIF.
ENDIF.
ENDFORM. " f_val_part_profit_center
&----
*& Form screen_changes
&----
text
----
--> p1 text
<-- p2 text
----
FORM screen_changes .
LOOP AT SCREEN.
IF screen-group1 = c_xyz.
screen-invisible = '1'.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
ENDFORM. " screen_changes
Begin of SRR-22879 APARMAA
&----
*& Form f_get_data_from_lfa1
&----
Purpose:Get data from lfa1 table
----
FORM f_get_data_from_lfa1 .
t_ldb_data1[] = t_ldb_data[].
SORT t_ldb_data1 BY lifnr.
DELETE ADJACENT DUPLICATES FROM t_ldb_data1 COMPARING lifnr.
SELECT lifnr
name1
FROM lfa1
INTO TABLE t_lfa1
FOR ALL ENTRIES IN t_ldb_data1
WHERE lifnr = t_ldb_data1-lifnr.
SORT t_lfa1 BY lifnr.
ENDFORM. " f_get_data_from_lfa1
Regards,
Hema
‎2007 Sep 04 12:05 PM
Hi,
Take 4 separate fields to store the new fields .then ,
FIELD1 = AGING_DETAILS+0(30).
FIELD2 = AGING_DETAILS+31(30).
FIELD3 = AGING_DETAILS+61(30).
FIELD4 = AGING_DETAILS+90(30).
Regards
Sudheer