Aging Report Group By
Hello,
Is it possible to group all of the results in this query by BP Code? I have applied the Group BY but it is still showing each line for each BP, rather a total cumulative value for each BP. ANy ideas on how to get one result for each BP?
Thanks and appreciate the insight!
Here is the query I am using:
select T1.cardcode 'Bp Code',T1.cardname 'Name',T1.Address, T1.ZipCode, T1.Phone1, T1.e_mail, getdate() AS 'Report Date', sysdeb 'Debit Amount',syscred 'Credit Amount', (sysdeb - syscred) as 'Balance Due',
case T0.transtype
when '13' then 'INV'
when '14' then 'AR CN'
when '24' then 'INCOMING'
else 'Other'
end 'Type',
Ref1,
fccurrency 'BP Currency',
CONVERT(VARCHAR(10), refdate, 103) 'Posting Date',
CONVERT(VARCHAR(10), duedate, 103) 'Due Date',
CONVERT(VARCHAR(10), taxdate, 103) 'Doc Date' ,
CASE
when (DATEDIFF(dd,refdate,current_timestamp))+1 < 31
then
case
when syscred <> 0 then -syscred
else sysdeb
end
end "0-30 days",
case when ((datediff(dd,refdate,current_timestamp))+1 > 30
and (datediff(dd,refdate,current_timestamp))+1< 61)
then
case
when syscred <> 0 then -syscred
else sysdeb
end
end "31 to 60 days",
case when ((datediff(dd,refdate,current_timestamp))+1 > 60
and (datediff(dd,refdate,current_timestamp))+1< 91)
then
case
when syscred <> 0 then -syscred
else sysdeb
end
end "61 to 90 days",
CASE
when (DATEDIFF(dd,refdate,current_timestamp))+1 > 90
then
case
when syscred= 0 then sysdeb
when sysdeb= 0 then -syscred
end
end "90 + days"
from dbo.JDT1 T0
INNER JOIN dbo.OCRD T1 ON T0.shortname = T1.cardcode and T1.cardtype = 'c'
where T0.intrnmatch = '0' and T0.BALDUEDEB != T0.BALDUECRED AND T1.GroupCode = '103'
group by
T1.cardcode,T1.cardname,T1.Address, T1.ZipCode, T1.Phone1, T1.e_mail, T0.sysdeb, T0.syscred, T0.transtype, T0.Ref1, T0.FCCurrency, T0.Refdate, T0.duedate, T0.taxdate
ORDER BY T1.Cardcode, T0.taxdate
If I select to group By just T1.Cardcode I get the error: is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. I do believe that is telling me that there are 2 different T1.cardcodes in the query and it does not know which one to use. I'm not sure how to separate them out
Hi,
Due to different posting date,query will separate each line for even if you group by BP code.
Thanks & Regards,
Nagarajan
Similar Messages
-
Account Group wise vendor aging report
Dear Gurus,
How can I see vedor account group wise ageing report in a company code?i.e Trade Vendors, Non Trade Vndors wise aging report
Thanks in adv.
N.M.BDear Raghavender
No need to create to variant and all.
You just go to S_ALR_87012085 then go to dynamic selections. There we can give account group whatever we want.
If u have any doubts reg. this pls ask me
Bye
Murali -
Stock Aging report Whwise & IT group wise
Hi All,
I want query for stock aging report Warehouse wise and Itemgroup wise in 0-45, 46-90 and greater then 90 days with value,
Thanks in advance.
Thanks & regards,Hi,
Check this...
SELECT distinct T0.ITEMCODE, T1.itemName,T0.ONHAND as 'Total Qty', T1.ManBtchNum,T1.ManSerNum,
CASE WHEN Datediff (day,T1.LastPurDat, Getdate ()) <45 THEN T0.ONHAND END '<45 Days (Qty)',
CASE WHEN Datediff (day,T1.LastPurDat, Getdate ()) <45 THEN T0.ONHAND * T0.Avgprice END '<45 Days (Value)',
CASE WHEN Datediff (day,T1.LastPurDat, Getdate ())>45 AND Datediff (day,T1.LastPurDat, Getdate ()) <90 THEN T0.ONHAND END '<45 T0 90 Days (Qty)',
CASE WHEN Datediff (day,T1.LastPurDat, Getdate ())>45 AND Datediff (day,T1.LastPurDat, Getdate ()) <90 THEN T0.ONHAND * T0.Avgprice END '<45 T0 90 Days (Value)',
CASE WHEN Datediff (day,T1.LastPurDat, Getdate ()) >90 THEN T0.ONHAND END '>90 Days (Qty)',
CASE WHEN Datediff (day,T1.LastPurDat, Getdate ())>90 THEN T0.ONHAND * T0.Avgprice END '>90 Days (Value)'
FROM OITW T0 INNER JOIN OITM T1 ON T0.ITEMCODE = T1.ITEMCODE
INNER JOIN OITB T2 ON T1.ITMSGRPCOD=T2.ITMSGRPCOD
left join ibt1 t3 on t3.itemcode = t0.whscode
WHERE T0.ONHAND >0 AND T0.WhsCode = '[%0]' AND T2.ItmsGrpNam ='[%1]'
Thanks
Sachin -
hi I am developing a aging report for which I am getting fields from the tables EKPO and EKKO based on
s_gjahr FOR bsid-gjahr OBLIGATORY. "Document Fiscal year
p_date TYPE vbak-aedat OBLIGATORY, "A/P Open items
p_bukrs TYPE t001-bukrs OBLIGATORY. "Company
s_ekorg FOR mepo1222-ekorg OBLIGATORY, "Purchasing Organization
s_ekgrp FOR mepo1222-ekgrp, "Purchasing group
s_zterm FOR bseg-zterm, "Terms
s_ebeln FOR bseg-ebeln, "Purchase order
s_hkont FOR bseg-hkont, "Reconciliation Account.
s_blart FOR invfo-blart OBLIGATORY, "Document type
s_date FOR bseg-zfbdt NO-DISPLAY.
SELECT * FROM ekko INTO TABLE tbl_ekko WHERE bukrs = p_bukrs
AND zterm IN s_zterm
AND ekorg IN s_ekorg
AND ekgrp IN s_ekgrp.
IF tbl_ekko[] IS NOT INITIAL.
SELECT * FROM ekpo INTO TABLE tbl_ekpo FOR ALL ENTRIES IN tbl_ekko
WHERE ebeln = tbl_ekko-ebeln
AND bukrs = p_bukrs
AND repos = 'X'
AND werks IN s_werks. "additonal.
ENDIF.
Now my problem is I need to combine the data I have selected from EKKO with a table which has EBELN, I found BSIK but that doesnt have the EBELN field filled.
Can you tell me some table other than BSEG ( performace issue ) which I can use to select my entries with Inner join... only BSIK has BLART not BSEG..
I will definitely award points for all the helpful answersHi
U need to read the EKBE table here you should fine the FI invoices linked to PO
Max -
I need a code for VENDOR AGEING REPORT
plz help me i am in urgent need of source code of
VENDOR AGEING REPORT.
if any body help me regarding this above report i will be
great ful to him/her.
bcoz deadline is today.
i need ur urgent help, i treid very much but i failed,
so hope help from anybody there.REPORT zvender_os NO STANDARD PAGE HEADING
LINE-SIZE 132
LINE-COUNT 65.
Tables
TABLES: bsik, "open items (A/C: Secondary Index for Customers)
lfa1, "customer master
lfb1,
rf140, "temp stru (Work Fields for Corrence(SAPF140*))
bsak, "cleared items (A/c Secnd Index for Cust(Clrms))
skat.
constants and variables
TYPE-POOLS: slis.
DATA: fieldcat TYPE slis_t_fieldcat_alv,
fieldcat1 TYPE slis_t_fieldcat_alv,
fieldcat_ln TYPE slis_fieldcat_alv,
layout_in TYPE slis_layout_alv,
layout_in1 TYPE slis_layout_alv,
sortcat TYPE slis_t_sortinfo_alv,
sortcat1 TYPE slis_t_sortinfo_alv,
sortcat_ln LIKE LINE OF sortcat,
eventcat1 TYPE slis_t_event,
eventcat TYPE slis_t_event,
eventcat_ln LIKE LINE OF eventcat,
col_pos TYPE i.
DATA: targ_month(2) TYPE n, "0001
targ_year(4) TYPE n, "0001
targ_mth_abs TYPE p, "0001
doc_month(2) TYPE n, "0001
doc_year(4) TYPE n, "0001
doc_mth_abs TYPE p, "0001
mth_result TYPE p, "0001
doc_days TYPE p,
targ_days TYPE p,
addl_days TYPE p,
ext_days TYPE p,
v_days(3) TYPE c,
v_kkber LIKE knkk-kkber.
DATA:
BEGIN OF inrec OCCURS 1000, "0001
lifnr LIKE bsik-lifnr,
belnr LIKE bsik-belnr,
gjahr LIKE bsik-gjahr,
bldat LIKE bsik-bldat,
xblnr LIKE bsik-xblnr,
blart LIKE bsik-blart,
sgtxt LIKE bsik-sgtxt,
shkzg LIKE bsik-shkzg,
dmbtr LIKE bsik-dmbtr,
zfbdt LIKE bsik-zfbdt,
zbd1t LIKE bsik-zbd1t,
zbd2t LIKE bsik-zbd2t,
zbd3t LIKE bsik-zbd3t,
zuonr LIKE bsik-zuonr,
END OF inrec.
DATA:
BEGIN OF inrect OCCURS 1000, "0001
lifnr LIKE bsik-lifnr,
belnr LIKE bsik-belnr,
gjahr LIKE bsik-gjahr,
bldat LIKE bsik-bldat,
xblnr LIKE bsik-xblnr,
blart LIKE bsik-blart,
sgtxt LIKE bsik-sgtxt,
shkzg LIKE bsik-shkzg,
dmbtr LIKE bsik-dmbtr,
zfbdt LIKE bsik-zfbdt,
zbd1t LIKE bsik-zbd1t,
zbd2t LIKE bsik-zbd2t,
zbd3t LIKE bsik-zbd3t,
zuonr LIKE bsik-zuonr,
END OF inrect,
BEGIN OF t_item OCCURS 1000, " 0001
lifnr LIKE bsik-lifnr,
belnr LIKE bsik-belnr,
gjahr LIKE bsik-gjahr,
bldat LIKE bsik-bldat,
xblnr LIKE bsik-xblnr,
blart LIKE bsik-blart,
sgtxt LIKE bsik-sgtxt,
zfbdt LIKE bsik-zfbdt,
dmbtr LIKE bsik-dmbtr,
days(3) TYPE c,
zuonr LIKE bsik-zuonr,
END OF t_item,
t_line LIKE t_item OCCURS 1000 WITH HEADER LINE, " 0001
BEGIN OF itab OCCURS 1000,
lifnr LIKE lfa1-lifnr,
total LIKE bsik-dmbtr,
zfuture LIKE bsik-dmbtr,
zcurrent LIKE bsik-dmbtr,
crbal LIKE bsik-dmbtr,
30days LIKE bsik-dmbtr,
60days LIKE bsik-dmbtr,
90days LIKE bsik-dmbtr,
99days LIKE bsik-dmbtr,
120days LIKE bsik-dmbtr,
180days LIKE bsik-dmbtr,
365days LIKE bsik-dmbtr,
bzirk LIKE knvv-bzirk,
vkbur LIKE knvv-vkbur,
vwerk LIKE knvv-vwerk,
vkgrp LIKE knvv-vkgrp,
klimk LIKE knkk-klimk,
cashd LIKE knkk-cashd,
grupp LIKE knkk-grupp,
erdat LIKE lfa1-erdat,
name1 LIKE lfa1-name1,
name2 LIKE lfa1-name2,
stras LIKE lfa1-stras,
ort01 LIKE lfa1-ort01,
telf1 LIKE lfa1-telf1,
psort(10),
sperr LIKE lfa1-sperr,
totsal LIKE bsik-dmbtr,
txt50 LIKE skat-txt50,
gsber LIKE bsik-gsber,
END OF itab.
DATA: sel_tab TYPE TABLE OF rsparams WITH HEADER LINE,
p_debit(1) TYPE c,
p_credit(1) TYPE c.
DATA: t_variant LIKE disvariant OCCURS 0 WITH HEADER LINE.
parameters and select-options
SELECTION-SCREEN BEGIN OF BLOCK blck0 WITH FRAME TITLE text-002.
PARAMETERS: stida LIKE sy-datum DEFAULT sy-datum OBLIGATORY,
p_bukrs LIKE t001-bukrs DEFAULT 'PIIL' MEMORY ID buk
OBLIGATORY.
P_BUKRS LIKE T001-BUKRS DEFAULT 'CC01' OBLIGATORY. "0003
SELECT-OPTIONS: s_lifnr FOR bsik-lifnr ,
s_vkbur FOR knvv-vkbur,
s_vkgrp FOR knvv-vkgrp,
s_bzirk FOR knvv-bzirk,
s_konda FOR knvv-konda,
s_kdgrp FOR knvv-kdgrp NO-DISPLAY ,
s_kvgr2 FOR knvv-kvgr2 NO-DISPLAY ,
s_kkber FOR knkk-kkber NO-DISPLAY ,
s_grupp FOR knkk-grupp NO-DISPLAY ,
s_ctlpc FOR knkk-ctlpc,
s_akont FOR lfb1-akont,
s_gsber FOR bsik-gsber.
PARAMETERS: p_future AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK blck0.
SELECTION-SCREEN BEGIN OF BLOCK blck1 WITH FRAME TITLE text-002.
PARAMETERS: p_abs RADIOBUTTON GROUP zrad,
p_due RADIOBUTTON GROUP zrad DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK blck1.
*SELECTION-SCREEN BEGIN OF BLOCK blck2 WITH FRAME TITLE text-003.
*PARAMETERS: c_run RADIOBUTTON GROUP zrac DEFAULT 'X',
c_blk RADIOBUTTON GROUP zrac,
c_all RADIOBUTTON GROUP zrac.
*SELECTION-SCREEN END OF BLOCK blck2.
*SELECTION-SCREEN BEGIN OF BLOCK blck3 WITH FRAME TITLE text-004.
*PARAMETERS: p_debit AS CHECKBOX DEFAULT 'X' ,
p_credit AS CHECKBOX DEFAULT 'X' NO-DISPLAY,
*selection-screen end of block blck3.
start-of-selection.
START-OF-SELECTION.
PERFORM BUILD_EVENTCAT.
p_debit = 'X'.
p_credit = 'X'.
PERFORM get_customer_invoices.
filter records based on selection criteria
PERFORM filter_records.
END-OF-SELECTION.
PERFORM add_sort_field.
PERFORM modify_field.
PERFORM write_report.
*& Form FILTER_RECORDS
To collect all the required data from DB and store them in
internal table.
--> p1 text
<-- p2 text
FORM filter_records.
delete records based on selection criteria
LOOP AT itab.
SELECT vkbur vkgrp vwerk erdat konda kdgrp bzirk kvgr2
INTO (itab-vkbur, itab-vkgrp, itab-vwerk, knvv-erdat,
knvv-konda, knvv-kdgrp,itab-bzirk,knvv-kvgr2)
FROM knvv WHERE lifnr = itab-lifnr
ORDER BY erdat DESCENDING.
AKS :- Not Required for PI
CASE itab-vkbur.
WHEN 'SA1'.
itab-vkbur = 'SF25'.
WHEN 'QLD1'.
itab-vkbur = 'SF23'.
WHEN 'WA1'.
itab-vkbur = 'SF26'.
ENDCASE.
AKS.
EXIT.
ENDSELECT.
IF itab-vkbur IN s_vkbur AND
itab-vkgrp IN s_vkgrp AND
knvv-konda IN s_konda AND
knvv-kdgrp IN s_kdgrp AND
itab-bzirk IN s_bzirk AND
knvv-kvgr2 IN s_kvgr2.
ELSE.
DELETE itab.
CONTINUE.
ENDIF.
SELECT SINGLE klimk grupp cashd
INTO (itab-klimk, itab-grupp, itab-cashd)
FROM knkk WHERE lifnr = itab-lifnr
AND kkber IN s_kkber
AND ctlpc IN s_ctlpc
AND grupp IN s_grupp.
IF SY-SUBRC NE 0.
DELETE ITAB.
CONTINUE.
ENDIF.
SELECT SINGLE skat~txt50
INTO (itab-txt50)
FROM lfb1 INNER JOIN skat
ON lfb1akont EQ skatsaknr
WHERE lfb1~lifnr = itab-lifnr
AND lfb1~akont IN s_akont
AND skat~spras EQ 'EN'.
IF sy-subrc NE 0.
DELETE itab.
CONTINUE.
ENDIF.
SELECT SINGLE name1 name2 telf1 erdat stras ort01 sperr
INTO (itab-name1, itab-name2, itab-telf1,
itab-erdat, itab-stras, itab-ort01, itab-sperr )
FROM lfa1
WHERE lifnr = itab-lifnr
IF sy-subrc NE 0 .
DELETE itab.
CONTINUE.
ENDIF.
AKS For Filteration of Customer base on Block Area.
IF c_all NE 'X'.
IF c_run EQ 'X' AND itab-sperr EQ 'X'.
DELETE itab.
CONTINUE.
ELSE.
IF c_blk EQ 'X' AND itab-sperr NE 'X'.
DELETE itab.
CONTINUE.
ENDIF.
ENDIF.
ENDIF.
MODIFY itab.
ENDLOOP.
ENDFORM. " FILTER_RECORDS
*& Form GET_CUSTOMER_INVOICES
text
--> p1 text
<-- p2 text
FORM get_customer_invoices.
DATA:ztotcre LIKE bsik-dmbtr.
DATA:ztotsal LIKE bsik-dmbtr.
DATA: fsdate LIKE sy-datum.
DATA: l_perio(4) TYPE c.
MOVE stida TO rf140-stida.
MOVE rf140-stida+4(2) TO targ_month.
MOVE rf140-stida+0(4) TO targ_year.
MOVE rf140-stida+6(2) TO targ_days.
targ_mth_abs = ( targ_year * 12 ) + targ_month.
CALL FUNCTION 'ZGET_PERIOD_FROM_DATE'
EXPORTING
i_date = stida
IMPORTING
e_perio = l_perio.
CONCATENATE l_perio '0401' INTO fsdate.
select open items.
IF p_due EQ 'X'.
SELECT lifnr belnr gjahr bldat xblnr blart sgtxt " 0001
shkzg dmbtr zfbdt zbd1t zbd2t zbd3t
zuonr
FROM bsik INTO TABLE inrect
WHERE bukrs = p_bukrs
AND budat LE stida
AND lifnr IN s_lifnr
AND gsber IN s_gsber
AND umskz NE 'T'
AND umskz NE 'F'
AND umskz NE 'R'
AND umskz NE 'P'
AND umskz NE 'J'
AND umskz NE 'L'.
LOOP AT INREC.
IF INREC-SHKZG = 'H'.
INREC-DMBTR = INREC-DMBTR * -1.
ENDIF.
MOVE-CORRESPONDING INREC TO T_ITEM. " 0001
PERFORM COLLECT_INVOICE USING INREC-lifnr INREC-DMBTR
INREC-ZFBDT INREC-ZBD1T
INREC-ZBD2T INREC-ZBD3T.
APPEND T_ITEM.
CLEAR T_ITEM.
ENDLOOP.
LOOP AT inrect.
inrec-lifnr = inrect-lifnr.
inrec-belnr = inrect-belnr.
inrec-gjahr = inrect-gjahr.
inrec-bldat = inrect-bldat.
inrec-xblnr = inrect-xblnr.
inrec-blart = inrect-blart.
inrec-sgtxt = inrect-sgtxt.
inrec-shkzg = inrect-shkzg.
inrec-dmbtr = inrect-dmbtr.
CALL FUNCTION 'NJ_CAL_DATE_IN_INTERVAL'
EXPORTING
date = inrect-zfbdt
days = inrect-zbd1t
months = 00
signum = '+'
years = 00
IMPORTING
calc_date = inrec-zfbdt.
inrec-zbd1t = inrect-zbd1t.
inrec-zbd2t = inrect-zbd2t.
inrec-zbd3t = inrect-zbd3t.
inrec-zuonr = inrect-zuonr.
APPEND inrec.
CLEAR inrec.
ENDLOOP.
ELSE.
SELECT lifnr belnr gjahr bldat xblnr blart sgtxt " 0001
shkzg dmbtr zfbdt zbd1t zbd2t zbd3t
zuonr
FROM bsik INTO TABLE inrec
WHERE bukrs = p_bukrs
AND budat LE stida
AND lifnr IN s_lifnr
AND gsber IN s_gsber
AND umskz NE 'T'
AND umskz NE 'F'
AND umskz NE 'R'
AND umskz NE 'P'
AND umskz NE 'J'
AND umskz NE 'L'.
ENDIF.
SORT inrec BY lifnr shkzg zfbdt .
LOOP AT inrec.
AT NEW lifnr.
For Customers Credit Balance Transaction to be display in Report
End of Credit Balance
ztotcre = 0.
ztotsal = 0.
ENDAT.
IF inrec-shkzg = 'H'.
inrec-dmbtr = inrec-dmbtr * -1.
ztotcre = ztotcre + inrec-dmbtr.
ELSE.
IF inrec-blart = 'RV'.
IF inrec-bldat GE fsdate.
ztotsal = ztotsal + inrec-dmbtr.
ENDIF.
ENDIF.
ztotcre = ztotcre + inrec-dmbtr.
endif.
IF p_debit EQ 'X'.
IF ztotcre > 0.
MOVE-CORRESPONDING inrec TO t_item. " 0001
PERFORM collect_invoice USING inrec-lifnr ztotcre
inrec-zfbdt inrec-zbd1t
inrec-zbd2t inrec-zbd3t
ztotsal.
APPEND t_item.
CLEAR t_item.
ztotcre = 0.
ztotsal = 0.
ENDIF.
ENDIF.
ENDIF.
IF p_credit EQ 'X'.
AT END OF lifnr.
IF ztotcre < 0.
MOVE-CORRESPONDING inrec TO t_item. " 0001
PERFORM collect_invoice USING inrec-lifnr ztotcre
inrec-zfbdt inrec-zbd1t
inrec-zbd2t inrec-zbd3t
ztotsal.
APPEND t_item.
CLEAR t_item.
ztotcre = 0.
ztotsal = 0.
APPEND t_item.
CLEAR t_item.
ENDIF.
ENDAT.
ENDIF.
ENDLOOP.
select cleared items
IF p_due EQ 'X'.
REFRESH inrect. CLEAR inrect.
SELECT lifnr belnr gjahr bldat xblnr blart sgtxt
shkzg dmbtr zfbdt zbd1t zbd2t zbd3t
zuonr
FROM bsak INTO TABLE inrect
WHERE bukrs = p_bukrs
AND budat LE stida
AND augdt > stida
AND lifnr IN s_lifnr
AND gsber IN s_gsber
REFRESH inrec. CLEAR inrec.
LOOP AT inrect.
inrec-lifnr = inrect-lifnr.
inrec-belnr = inrect-belnr.
inrec-gjahr = inrect-gjahr.
inrec-bldat = inrect-bldat.
inrec-xblnr = inrect-xblnr.
inrec-blart = inrect-blart.
inrec-sgtxt = inrect-sgtxt.
inrec-shkzg = inrect-shkzg.
inrec-dmbtr = inrect-dmbtr.
CALL FUNCTION 'NJ_CAL_DATE_IN_INTERVAL'
EXPORTING
date = inrect-zfbdt
days = inrect-zbd1t
months = 00
signum = '+'
years = 00
IMPORTING
calc_date = inrec-zfbdt.
inrec-zbd1t = inrect-zbd1t.
inrec-zbd2t = inrect-zbd2t.
inrec-zbd3t = inrect-zbd3t.
inrec-zuonr = inrect-zuonr.
APPEND inrec.
CLEAR inrec.
ENDLOOP.
ELSE.
REFRESH inrec. CLEAR inrec.
SELECT lifnr belnr gjahr bldat xblnr blart sgtxt
shkzg dmbtr zfbdt zbd1t zbd2t zbd3t
zuonr
FROM bsak INTO TABLE inrec
WHERE bukrs = p_bukrs
AND budat LE stida
AND augdt > stida
AND lifnr IN s_lifnr
AND gsber IN s_gsber
ENDIF.
SORT inrec BY lifnr shkzg zfbdt .
LOOP AT inrec.
AT NEW lifnr.
ztotcre = 0.
ztotsal = 0.
ENDAT.
IF inrec-shkzg = 'H'.
inrec-dmbtr = inrec-dmbtr * -1.
ztotcre = ztotcre + inrec-dmbtr.
ELSE.
IF inrec-blart = 'RV'.
IF inrec-bldat GE fsdate.
ztotsal = ztotsal + inrec-dmbtr.
ENDIF.
ENDIF.
ztotcre = ztotcre + inrec-dmbtr.
endif.
IF p_debit EQ 'X'.
IF ztotcre > 0.
MOVE-CORRESPONDING inrec TO t_item. " 0001
PERFORM collect_invoice USING inrec-lifnr ztotcre
inrec-zfbdt inrec-zbd1t
inrec-zbd2t inrec-zbd3t
ztotsal.
APPEND t_item.
CLEAR t_item.
ztotcre = 0.
ztotsal = 0.
ENDIF.
ENDIF.
ENDIF.
IF p_credit EQ 'X'.
AT END OF lifnr.
IF ztotcre < 0.
MOVE-CORRESPONDING inrec TO t_item. " 0001
PERFORM collect_invoice USING inrec-lifnr ztotcre
inrec-zfbdt inrec-zbd1t
inrec-zbd2t inrec-zbd3t
ztotsal.
APPEND t_item.
CLEAR t_item.
ztotcre = 0.
ztotsal = 0.
APPEND t_item.
CLEAR t_item.
ENDIF.
ENDAT. " 0001
ENDIF.
ENDLOOP.
ENDFORM. " GET_CUSTOMER_INVOICES
*& Form COLLECT_INVOICE
text
-->P_bsik_lifnr text
-->P_bsik_DMBTR text
-->P_bsik_ZFBDT text
-->P_bsik_ZFBDT1 text
-->P_bsik_ZFBDT2 text
-->P_bsik_ZFBDT3 text
FORM collect_invoice USING pp_lifnr
pp_dmbtr
pp_zfbdt
pp_zbd1t
pp_zbd2t
pp_zbd3t
pp_ztotsal.
doc_month = pp_zfbdt+4(2).
doc_year = pp_zfbdt+0(4).
doc_mth_abs = ( doc_year * 12 ) + doc_month.
mth_result = ( targ_mth_abs - doc_mth_abs ).
logic given by Mr. Ashok Singhvi
doc_days = pp_zfbdt+6(2).
addl_days = ( doc_days - targ_days ).
IF addl_days <= 0.
ADD 1 TO mth_result.
ENDIF.
IF NOT pp_zbd3t IS INITIAL.
MOVE pp_zbd3t TO ext_days.
ELSEIF NOT pp_zbd2t IS INITIAL.
MOVE pp_zbd2t TO ext_days.
ELSEIF NOT pp_zbd1t IS INITIAL.
MOVE pp_zbd1t TO ext_days.
ELSE.
CLEAR ext_days.
ENDIF.
CHECK with Andrew whether this is working or not
if extended payment terms exist, subtract no of mths from mth_result
IF NOT ext_days IS INITIAL.
CASE ext_days.
WHEN 30.
SUBTRACT 1 FROM mth_result.
WHEN 60.
SUBTRACT 2 FROM mth_result.
WHEN 90.
SUBTRACT 3 FROM mth_result.
WHEN 120.
SUBTRACT 4 FROM mth_result.
ENDCASE.
ENDIF.
change to key date
IF pp_dmbtr > 0.
IF p_future = 'X'. " 0001
IF mth_result <= 0.
itab-zcurrent = pp_dmbtr.
t_item-days = 'CUR'.
ELSEIF mth_result = 1.
itab-30days = pp_dmbtr.
t_item-days = '30D'.
ELSEIF mth_result = 2.
itab-60days = pp_dmbtr.
t_item-days = '60D'.
ELSEIF mth_result = 3.
itab-90days = pp_dmbtr.
t_item-days = '90D'.
ELSEIF mth_result > 3 AND mth_result <= 4 .
itab-99days = pp_dmbtr.
t_item-days = '99D'.
ELSEIF mth_result > 4 AND mth_result <= 6 .
itab-120days = pp_dmbtr.
t_item-days = '120D'.
ELSEIF mth_result > 6 AND mth_result <= 12 .
itab-180days = pp_dmbtr.
t_item-days = '180D'.
ELSEIF mth_result > 12 .
itab-365days = pp_dmbtr.
t_item-days = '365D'.
ENDIF.
ELSE.
IF mth_result < 0.
itab-zfuture = pp_dmbtr.
t_item-days = 'FUT'.
ELSEIF mth_result = 0.
itab-zcurrent = pp_dmbtr.
t_item-days = 'CUR'.
ELSEIF mth_result = 1.
itab-30days = pp_dmbtr.
t_item-days = '30D'.
ELSEIF mth_result = 2.
itab-60days = pp_dmbtr.
t_item-days = '60D'.
ELSEIF mth_result = 3.
itab-90days = pp_dmbtr.
t_item-days = '90D'.
ELSEIF mth_result > 3 AND mth_result <= 4 .
itab-99days = pp_dmbtr.
t_item-days = '99D'.
ELSEIF mth_result > 4 AND mth_result <= 6 .
itab-120days = pp_dmbtr.
t_item-days = '120D'.
ELSEIF mth_result > 6 AND mth_result <= 12 .
itab-180days = pp_dmbtr.
t_item-days = '180D'.
ELSEIF mth_result > 12 .
itab-365days = pp_dmbtr.
t_item-days = '365D'.
ENDIF.
ENDIF. " 0001
itab-crbal = 0.
itab-total = pp_dmbtr.
ELSE.
IF p_future = 'X'. " 0001
IF mth_result <= 0.
itab-zcurrent = pp_dmbtr.
t_item-days = 'CUR'.
ELSEIF mth_result = 1.
itab-30days = pp_dmbtr.
t_item-days = '30D'.
ELSEIF mth_result = 2.
itab-60days = pp_dmbtr.
t_item-days = '60D'.
ELSEIF mth_result = 3.
itab-90days = pp_dmbtr.
t_item-days = '90D'.
ELSEIF mth_result > 3 AND mth_result <= 4 .
itab-99days = pp_dmbtr.
t_item-days = '99D'.
ELSEIF mth_result > 4 AND mth_result <= 6 .
itab-120days = pp_dmbtr.
t_item-days = '120D'.
ELSEIF mth_result > 6 AND mth_result <= 12 .
itab-180days = pp_dmbtr.
t_item-days = '180D'.
ELSEIF mth_result > 12 .
itab-365days = pp_dmbtr.
t_item-days = '365D'.
ENDIF.
ELSE.
IF mth_result < 0.
itab-zfuture = pp_dmbtr.
t_item-days = 'FUT'.
ELSEIF mth_result = 0.
itab-zcurrent = pp_dmbtr.
t_item-days = 'CUR'.
ELSEIF mth_result = 1.
itab-30days = pp_dmbtr.
t_item-days = '30D'.
ELSEIF mth_result = 2.
itab-60days = pp_dmbtr.
t_item-days = '60D'.
ELSEIF mth_result = 3.
itab-90days = pp_dmbtr.
t_item-days = '90D'.
ELSEIF mth_result > 3 AND mth_result <= 4 .
itab-99days = pp_dmbtr.
t_item-days = '99D'.
ELSEIF mth_result > 4 AND mth_result <= 6 .
itab-120days = pp_dmbtr.
t_item-days = '120D'.
ELSEIF mth_result > 6 AND mth_result <= 12 .
itab-180days = pp_dmbtr.
t_item-days = '180D'.
ELSEIF mth_result > 12 .
itab-365days = pp_dmbtr.
t_item-days = '365D'.
ENDIF.
ENDIF. " 0001
itab-total = pp_dmbtr.
itab-crbal = 0.
ENDIF.
itab-lifnr = pp_lifnr.
itab-totsal = pp_ztotsal.
COLLECT itab.
CLEAR itab.
ENDFORM. " COLLECT_INVOICE
*& Form ADD_SORT_FIELD
text
--> p1 text
<-- p2 text
FORM add_sort_field.
DATA: l_amount(9) TYPE n.
IF p_future = 'X'.
LOOP AT itab.
l_amount = 999999999.
IF itab-365days > 0.
l_amount = l_amount - itab-365days.
CONCATENATE 'A' l_amount INTO itab-psort.
ELSEIF itab-180days > 0.
l_amount = l_amount - itab-180days.
CONCATENATE 'B' l_amount INTO itab-psort.
ELSEIF itab-120days > 0.
l_amount = l_amount - itab-120days.
CONCATENATE 'C' l_amount INTO itab-psort.
ELSEIF itab-99days > 0.
l_amount = l_amount - itab-99days.
CONCATENATE 'D' l_amount INTO itab-psort.
ELSEIF itab-90days > 0.
l_amount = l_amount - itab-90days.
CONCATENATE 'E' l_amount INTO itab-psort.
ELSEIF itab-60days > 0.
l_amount = l_amount - itab-60days.
CONCATENATE 'F' l_amount INTO itab-psort.
ELSEIF itab-30days > 0.
l_amount = l_amount - itab-30days.
CONCATENATE 'G' l_amount INTO itab-psort.
ELSEIF itab-zcurrent > 0.
l_amount = l_amount - itab-zcurrent.
CONCATENATE 'H' l_amount INTO itab-psort.
ELSEif itab-zfuture > 0.
L_AMOUNT = L_AMOUNT - ITAB-zfuture.
CONCATENATE 'F' L_AMOUNT INTO ITAB-PSORT.
ELSE.
l_amount = ABS( itab-total ).
CONCATENATE 'I' l_amount INTO itab-psort.
ENDIF.
MODIFY itab.
ENDLOOP.
ELSE.
LOOP AT itab.
l_amount = 999999999.
IF itab-365days > 0.
l_amount = l_amount - itab-365days.
CONCATENATE 'A' l_amount INTO itab-psort.
ELSEIF itab-180days > 0.
l_amount = l_amount - itab-180days.
CONCATENATE 'B' l_amount INTO itab-psort.
ELSEIF itab-120days > 0.
l_amount = l_amount - itab-120days.
CONCATENATE 'C' l_amount INTO itab-psort.
ELSEIF itab-99days > 0.
l_amount = l_amount - itab-99days.
CONCATENATE 'D' l_amount INTO itab-psort.
ELSEIF itab-90days > 0.
l_amount = l_amount - itab-90days.
CONCATENATE 'E' l_amount INTO itab-psort.
ELSEIF itab-60days > 0.
l_amount = l_amount - itab-60days.
CONCATENATE 'F' l_amount INTO itab-psort.
ELSEIF itab-30days > 0.
l_amount = l_amount - itab-30days.
CONCATENATE 'G' l_amount INTO itab-psort.
ELSEIF itab-zcurrent > 0.
l_amount = l_amount - itab-zcurrent.
CONCATENATE 'H' l_amount INTO itab-psort.
ELSEIF itab-zfuture > 0.
l_amount = l_amount - itab-zfuture.
CONCATENATE 'I' l_amount INTO itab-psort.
ELSE.
l_amount = ABS( itab-total ).
CONCATENATE 'J' l_amount INTO itab-psort.
ENDIF.
MODIFY itab.
ENDLOOP.
ENDIF.
ENDFORM. " ADD_SORT_FIELD
*& Form WRITE_REPORT
text
--> p1 text
<-- p2 text
FORM write_report.
PERFORM build_fieldcat.
PERFORM build_sortcat.
PERFORM build_eventcat.
PERFORM build_layout.
PERFORM start_list_viewer.
ENDFORM. " WRITE_REPORT
*& Form BUILD_FIELDCAT
text
--> p1 text
<-- p2 text
FORM build_fieldcat.
lifnr
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'lfa1'.
fieldcat_ln-fieldname = 'LIFNR'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-emphasize = 'C41'.
APPEND fieldcat_ln TO fieldcat.
Name1
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'lfa1'.
fieldcat_ln-fieldname = 'NAME1'.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-seltext_l = 'Name'.
APPEND fieldcat_ln TO fieldcat.
City Details
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'lfa1'.
fieldcat_ln-fieldname = 'ORT01'.
fieldcat_ln-seltext_l = 'City'.
fieldcat_ln-col_pos = col_pos.
APPEND fieldcat_ln TO fieldcat.
Credit Limit
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'KNKK'.
fieldcat_ln-fieldname = 'KLIMK'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-emphasize = 'C41'.
APPEND fieldcat_ln TO fieldcat.
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'bsik'.
fieldcat_ln-ref_fieldname = 'DMBTR'.
fieldcat_ln-fieldname = 'CRBAL'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-seltext_l = 'Cr. Bal.'.
fieldcat_ln-seltext_m = 'Cr. Bal.'.
fieldcat_ln-seltext_s = 'Cr. Bal.'.
APPEND fieldcat_ln TO fieldcat.
Total Amount
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'TOTAL'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-seltext_l = 'Out.St.Amt.'.
fieldcat_ln-seltext_m = 'Out.St.Amt.'.
fieldcat_ln-seltext_s = 'Out.St.Amt.'.
fieldcat_ln-ref_tabname = 'zbsik'.
fieldcat_ln-ref_fieldname = 'ZDMBTR'.
APPEND fieldcat_ln TO fieldcat.
IF p_future NE 'X'.
Future
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'bsik'.
fieldcat_ln-ref_fieldname = 'DMBTR'.
fieldcat_ln-fieldname = 'ZFUTURE'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-seltext_l = 'Future Due'.
fieldcat_ln-seltext_m = 'Future Due'.
fieldcat_ln-seltext_s = 'Future Due'.
APPEND fieldcat_ln TO fieldcat.
ENDIF.
Current
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'bsik'.
fieldcat_ln-ref_fieldname = 'DMBTR'.
fieldcat_ln-fieldname = 'ZCURRENT'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-seltext_l = 'Normal Due'.
fieldcat_ln-seltext_m = 'Normal Due'.
fieldcat_ln-seltext_s = 'Normal Due'.
APPEND fieldcat_ln TO fieldcat.
30 Days
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'bsik'.
fieldcat_ln-ref_fieldname = 'DMBTR'.
fieldcat_ln-fieldname = '30DAYS'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-seltext_l = '0-30 Days'.
fieldcat_ln-seltext_m = '0-30 Days'.
fieldcat_ln-seltext_s = '0-30 Days'.
APPEND fieldcat_ln TO fieldcat.
60 Days
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'bsik'.
fieldcat_ln-ref_fieldname = 'DMBTR'.
fieldcat_ln-fieldname = '60DAYS'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-seltext_l = '31-60 Days'.
fieldcat_ln-seltext_m = '31-60 Days'.
fieldcat_ln-seltext_s = '31-60 Days'.
APPEND fieldcat_ln TO fieldcat.
90 Days
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'bsik'.
fieldcat_ln-ref_fieldname = 'DMBTR'.
fieldcat_ln-fieldname = '90DAYS'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-seltext_l = '61-90 Days'.
fieldcat_ln-seltext_m = '61-90 Days'.
fieldcat_ln-seltext_s = '61-90 Days'.
APPEND fieldcat_ln TO fieldcat.
99 Days
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'bsik'.
fieldcat_ln-ref_fieldname = 'DMBTR'.
fieldcat_ln-fieldname = '99DAYS'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-seltext_l = '91-120 Days'.
fieldcat_ln-seltext_m = '91-120 Days'.
fieldcat_ln-seltext_s = '91-120 Days'.
APPEND fieldcat_ln TO fieldcat.
*120Days
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'bsik'.
fieldcat_ln-ref_fieldname = 'DMBTR'.
fieldcat_ln-fieldname = '120DAYS'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-seltext_l = '121-180 Days'.
fieldcat_ln-seltext_m = '121-180 Days'.
fieldcat_ln-seltext_s = '121-180 Days'.
APPEND fieldcat_ln TO fieldcat.
*180 Days
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'bsik'.
fieldcat_ln-ref_fieldname = 'DMBTR'.
fieldcat_ln-fieldname = '180DAYS'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-seltext_l = '181-365 Days'.
fieldcat_ln-seltext_m = '181-365 Days'.
fieldcat_ln-seltext_s = '181-365 Days'.
APPEND fieldcat_ln TO fieldcat.
*365 Days
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'bsik'.
fieldcat_ln-ref_fieldname = 'DMBTR'.
fieldcat_ln-fieldname = '365DAYS'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-seltext_l = '>365 Days'.
fieldcat_ln-seltext_m = '>365 Days'.
fieldcat_ln-seltext_s = '>365 Days'.
APPEND fieldcat_ln TO fieldcat.
Last Payment Date
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'KNKK'.
fieldcat_ln-fieldname = 'CASHD'.
fieldcat_ln-col_pos = col_pos.
APPEND fieldcat_ln TO fieldcat.
Street Name
ADD 1 TO COL_POS.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-REF_TABNAME = 'lfa1'.
FIELDCAT_LN-FIELDNAME = 'STRAS'.
FIELDCAT_LN-COL_POS = COL_POS.
APPEND FIELDCAT_LN TO FIELDCAT.
Telephone
ADD 1 TO COL_POS.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-REF_TABNAME = 'lfa1'.
FIELDCAT_LN-FIELDNAME = 'TELF1'.
FIELDCAT_LN-COL_POS = COL_POS.
APPEND FIELDCAT_LN TO FIELDCAT.
Credit Group
ADD 1 TO COL_POS.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-REF_TABNAME = 'KNKK'.
FIELDCAT_LN-FIELDNAME = 'GRUPP'.
FIELDCAT_LN-COL_POS = COL_POS.
APPEND FIELDCAT_LN TO FIELDCAT.
*Sales District
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'KNVV'.
fieldcat_ln-fieldname = 'BZIRK'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-seltext_l = 'S_Distt'.
fieldcat_ln-seltext_m = 'S_Distt'.
fieldcat_ln-seltext_s = 'S_Distt'.
APPEND fieldcat_ln TO fieldcat.
Sales Office
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'KNVV'.
fieldcat_ln-fieldname = 'VKBUR'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-seltext_l = 'S_Off'.
fieldcat_ln-seltext_m = 'S_Off'.
fieldcat_ln-seltext_s = 'S_Off'.
APPEND fieldcat_ln TO fieldcat.
Cust Creat Date
ADD 1 TO COL_POS.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-REF_TABNAME = 'lfa1'.
FIELDCAT_LN-FIELDNAME = 'ERDAT'.
FIELDCAT_LN-COL_POS = COL_POS.
APPEND FIELDCAT_LN TO FIELDCAT. -
Vendor liabilities customised aging report
Dear Experts,
My client needed Vendor Liabilities Report month wise for 12 Months as system Vendor Liabilities Aging report show only four months reports and rest of in cumulative bal. so client was needed a report in for almost 12 months criteria as we have some of internal vendor groups for example 'A' is head Company and 'A1' , 'A2', 'A3' are groups with 'A' and when we generate Vendor Aging Report monthly then we need to exclude these groups companies in this report and report should something like this :
report for A Company
Month, Total Liabilities, Vendor A, Vendor B, Vendor C, Bal.
April 10,00,000.00, 1,00,000.00, 50,000.00, 50,000.00, 8,00,000.00
May 15,00,000.00 , 50,000.00, 2,00,000.00, 2,00,000.00 , 10,50,000.00
as on..till selected month..
Any suggestion would be very appreciating.
Thanks in advance
RaviHi Ravi Jha,
Try with interval with days same like below. then you can get atleast for whole year ( not by months like jan, feb)
Report like:
Hope helpful. -
Customer / Vendor Aging Report
Hi,
It´s important to consider the next filter or selection criteria for the reports:
-. Customer and Vendor Aging Reports
Filters:
-. by Sales Employee (Customer Aging)
-. by Buyer (Vendor Aging)
regardsHello Humberto,
New selection criteria of Sales Employee/Buyer is part of enhancements of Aging Reports in SAP Business One 8.8 release.
When you generate the aging report in v8.8:
u2022 You can group the report by customer or sales employee in the customer receivables aging report, and by vendor or buyer in the vendor liabilities aging report.
u2022 You can specify more flexible time interval. For the time interval Days, 4 new fields are added for you to specify the duration.
u2022 You can hide the Future Remit column on the report by choosing Ignore Future Remit.
u2022 When the aging report has been generated, you can view multicustomer/multivendor detailed information in the aging report window. There is no need to double-click each customer/vendor row to view the details.
Peter Dominik
B1 Solution Management -
Vendor Ref. no. not displayed in print preview in vendor aging report
Dear SAP team,
Vendor reference number is not displayed in print preview/print on vendor liabliteis aging report,
but this vendor reference number actually show in report,We are taking report by journal postings,
vendor reference entered in NumAtCard in AP invoice get copied to Ref2 in Journal Entry,then
why it is not showing in print preview/print.
Whether this is an application error / missing functionality ?
We are using SAP Business One 2005 B (7.40.252) SP: 00 PL: 36.
Whether upgrade to latest patch 2005B PL46 will solve this issue ?
JeyakanthanHello Jeyakanthan,
I would like to draw your attention to the enhancements we delivered within Aging Report in 2007 version and plan for 8.8 release.
The primary enhancement in 2007 version is reflecting new concept of Internal Reconciliation with more convenient backward reporting.
Within the 8.8 release ...
- when you generate the aging report you can group the report by customer or sales employee in the customer receivables aging report, and by vendor or buyer in the vendor liabilities aging report;
- when the aging report has been generated, you can view multicustomer/multivendor detailed information in the aging report window. There is no need to double-click each customer/vendor row to view the details.
We would strongly to recommend you to upgrade to 2007 version or join the ramp-up of 8.8 release soon.
Peter Dominik
B1 Solution Management -
Vendor aging report ,customer aging report
hi to all
can u pls what is vendor aging report . what is the purpose of it . can u pls some theoritical description
i will definitely reward points pls its urgent pls tell if there r any standard reports exists for theese . pls give some custom reports on theese with coding.
and for customer aging also
pls.................Hi,
Check the Vendor against report code:
REPORT zvender_os NO STANDARD PAGE HEADING
LINE-SIZE 132
LINE-COUNT 65.
Tables
TABLES: bsik, "open items (A/C: Secondary Index for Customers)
lfa1, "customer master
lfb1,
rf140, "temp stru (Work Fields for Corrence(SAPF140*))
bsak, "cleared items (A/c Secnd Index for Cust(Clrms))
skat.
constants and variables
TYPE-POOLS: slis.
DATA: fieldcat TYPE slis_t_fieldcat_alv,
fieldcat1 TYPE slis_t_fieldcat_alv,
fieldcat_ln TYPE slis_fieldcat_alv,
layout_in TYPE slis_layout_alv,
layout_in1 TYPE slis_layout_alv,
sortcat TYPE slis_t_sortinfo_alv,
sortcat1 TYPE slis_t_sortinfo_alv,
sortcat_ln LIKE LINE OF sortcat,
eventcat1 TYPE slis_t_event,
eventcat TYPE slis_t_event,
eventcat_ln LIKE LINE OF eventcat,
col_pos TYPE i.
DATA: targ_month(2) TYPE n, "0001
targ_year(4) TYPE n, "0001
targ_mth_abs TYPE p, "0001
doc_month(2) TYPE n, "0001
doc_year(4) TYPE n, "0001
doc_mth_abs TYPE p, "0001
mth_result TYPE p, "0001
doc_days TYPE p,
targ_days TYPE p,
addl_days TYPE p,
ext_days TYPE p,
v_days(3) TYPE c,
v_kkber LIKE knkk-kkber.
DATA:
BEGIN OF inrec OCCURS 1000, "0001
lifnr LIKE bsik-lifnr,
belnr LIKE bsik-belnr,
gjahr LIKE bsik-gjahr,
bldat LIKE bsik-bldat,
xblnr LIKE bsik-xblnr,
blart LIKE bsik-blart,
sgtxt LIKE bsik-sgtxt,
shkzg LIKE bsik-shkzg,
dmbtr LIKE bsik-dmbtr,
zfbdt LIKE bsik-zfbdt,
zbd1t LIKE bsik-zbd1t,
zbd2t LIKE bsik-zbd2t,
zbd3t LIKE bsik-zbd3t,
zuonr LIKE bsik-zuonr,
END OF inrec.
DATA:
BEGIN OF inrect OCCURS 1000, "0001
lifnr LIKE bsik-lifnr,
belnr LIKE bsik-belnr,
gjahr LIKE bsik-gjahr,
bldat LIKE bsik-bldat,
xblnr LIKE bsik-xblnr,
blart LIKE bsik-blart,
sgtxt LIKE bsik-sgtxt,
shkzg LIKE bsik-shkzg,
dmbtr LIKE bsik-dmbtr,
zfbdt LIKE bsik-zfbdt,
zbd1t LIKE bsik-zbd1t,
zbd2t LIKE bsik-zbd2t,
zbd3t LIKE bsik-zbd3t,
zuonr LIKE bsik-zuonr,
END OF inrect,
BEGIN OF t_item OCCURS 1000, " 0001
lifnr LIKE bsik-lifnr,
belnr LIKE bsik-belnr,
gjahr LIKE bsik-gjahr,
bldat LIKE bsik-bldat,
xblnr LIKE bsik-xblnr,
blart LIKE bsik-blart,
sgtxt LIKE bsik-sgtxt,
zfbdt LIKE bsik-zfbdt,
dmbtr LIKE bsik-dmbtr,
days(3) TYPE c,
zuonr LIKE bsik-zuonr,
END OF t_item,
t_line LIKE t_item OCCURS 1000 WITH HEADER LINE, " 0001
BEGIN OF itab OCCURS 1000,
lifnr LIKE lfa1-lifnr,
total LIKE bsik-dmbtr,
zfuture LIKE bsik-dmbtr,
zcurrent LIKE bsik-dmbtr,
crbal LIKE bsik-dmbtr,
30days LIKE bsik-dmbtr,
60days LIKE bsik-dmbtr,
90days LIKE bsik-dmbtr,
99days LIKE bsik-dmbtr,
120days LIKE bsik-dmbtr,
180days LIKE bsik-dmbtr,
365days LIKE bsik-dmbtr,
bzirk LIKE knvv-bzirk,
vkbur LIKE knvv-vkbur,
vwerk LIKE knvv-vwerk,
vkgrp LIKE knvv-vkgrp,
klimk LIKE knkk-klimk,
cashd LIKE knkk-cashd,
grupp LIKE knkk-grupp,
erdat LIKE lfa1-erdat,
name1 LIKE lfa1-name1,
name2 LIKE lfa1-name2,
stras LIKE lfa1-stras,
ort01 LIKE lfa1-ort01,
telf1 LIKE lfa1-telf1,
psort(10),
sperr LIKE lfa1-sperr,
totsal LIKE bsik-dmbtr,
txt50 LIKE skat-txt50,
gsber LIKE bsik-gsber,
END OF itab.
DATA: sel_tab TYPE TABLE OF rsparams WITH HEADER LINE,
p_debit(1) TYPE c,
p_credit(1) TYPE c.
DATA: t_variant LIKE disvariant OCCURS 0 WITH HEADER LINE.
parameters and select-options
SELECTION-SCREEN BEGIN OF BLOCK blck0 WITH FRAME TITLE text-002.
PARAMETERS: stida LIKE sy-datum DEFAULT sy-datum OBLIGATORY,
p_bukrs LIKE t001-bukrs DEFAULT 'PIIL' MEMORY ID buk
OBLIGATORY.
P_BUKRS LIKE T001-BUKRS DEFAULT 'CC01' OBLIGATORY. "0003
SELECT-OPTIONS: s_lifnr FOR bsik-lifnr ,
s_vkbur FOR knvv-vkbur,
s_vkgrp FOR knvv-vkgrp,
s_bzirk FOR knvv-bzirk,
s_konda FOR knvv-konda,
s_kdgrp FOR knvv-kdgrp NO-DISPLAY ,
s_kvgr2 FOR knvv-kvgr2 NO-DISPLAY ,
s_kkber FOR knkk-kkber NO-DISPLAY ,
s_grupp FOR knkk-grupp NO-DISPLAY ,
s_ctlpc FOR knkk-ctlpc,
s_akont FOR lfb1-akont,
s_gsber FOR bsik-gsber.
PARAMETERS: p_future AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK blck0.
SELECTION-SCREEN BEGIN OF BLOCK blck1 WITH FRAME TITLE text-002.
PARAMETERS: p_abs RADIOBUTTON GROUP zrad,
p_due RADIOBUTTON GROUP zrad DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK blck1.
*SELECTION-SCREEN BEGIN OF BLOCK blck2 WITH FRAME TITLE text-003.
*PARAMETERS: c_run RADIOBUTTON GROUP zrac DEFAULT 'X',
c_blk RADIOBUTTON GROUP zrac,
c_all RADIOBUTTON GROUP zrac.
*SELECTION-SCREEN END OF BLOCK blck2.
*SELECTION-SCREEN BEGIN OF BLOCK blck3 WITH FRAME TITLE text-004.
*PARAMETERS: p_debit AS CHECKBOX DEFAULT 'X' ,
p_credit AS CHECKBOX DEFAULT 'X' NO-DISPLAY,
*selection-screen end of block blck3.
start-of-selection.
START-OF-SELECTION.
PERFORM BUILD_EVENTCAT.
p_debit = 'X'.
p_credit = 'X'.
PERFORM get_customer_invoices.
filter records based on selection criteria
PERFORM filter_records.
END-OF-SELECTION.
PERFORM add_sort_field.
PERFORM modify_field.
PERFORM write_report.
*& Form FILTER_RECORDS
To collect all the required data from DB and store them in
internal table.
--> p1 text
<-- p2 text
FORM filter_records.
delete records based on selection criteria
LOOP AT itab.
SELECT vkbur vkgrp vwerk erdat konda kdgrp bzirk kvgr2
INTO (itab-vkbur, itab-vkgrp, itab-vwerk, knvv-erdat,
knvv-konda, knvv-kdgrp,itab-bzirk,knvv-kvgr2)
FROM knvv WHERE lifnr = itab-lifnr
ORDER BY erdat DESCENDING.
AKS :- Not Required for PI
CASE itab-vkbur.
WHEN 'SA1'.
itab-vkbur = 'SF25'.
WHEN 'QLD1'.
itab-vkbur = 'SF23'.
WHEN 'WA1'.
itab-vkbur = 'SF26'.
ENDCASE.
AKS.
EXIT.
ENDSELECT.
IF itab-vkbur IN s_vkbur AND
itab-vkgrp IN s_vkgrp AND
knvv-konda IN s_konda AND
knvv-kdgrp IN s_kdgrp AND
itab-bzirk IN s_bzirk AND
knvv-kvgr2 IN s_kvgr2.
ELSE.
DELETE itab.
CONTINUE.
ENDIF.
SELECT SINGLE klimk grupp cashd
INTO (itab-klimk, itab-grupp, itab-cashd)
FROM knkk WHERE lifnr = itab-lifnr
AND kkber IN s_kkber
AND ctlpc IN s_ctlpc
AND grupp IN s_grupp.
IF SY-SUBRC NE 0.
DELETE ITAB.
CONTINUE.
ENDIF.
SELECT SINGLE skat~txt50
INTO (itab-txt50)
FROM lfb1 INNER JOIN skat
ON lfb1akont EQ skatsaknr
WHERE lfb1~lifnr = itab-lifnr
AND lfb1~akont IN s_akont
AND skat~spras EQ 'EN'.
IF sy-subrc NE 0.
DELETE itab.
CONTINUE.
ENDIF.
SELECT SINGLE name1 name2 telf1 erdat stras ort01 sperr
INTO (itab-name1, itab-name2, itab-telf1,
itab-erdat, itab-stras, itab-ort01, itab-sperr )
FROM lfa1
WHERE lifnr = itab-lifnr
IF sy-subrc NE 0 .
DELETE itab.
CONTINUE.
ENDIF.
AKS For Filteration of Customer base on Block Area.
IF c_all NE 'X'.
IF c_run EQ 'X' AND itab-sperr EQ 'X'.
DELETE itab.
CONTINUE.
ELSE.
IF c_blk EQ 'X' AND itab-sperr NE 'X'.
DELETE itab.
CONTINUE.
ENDIF.
ENDIF.
ENDIF.
MODIFY itab.
ENDLOOP.
ENDFORM. " FILTER_RECORDS
*& Form GET_CUSTOMER_INVOICES
text
--> p1 text
<-- p2 text
FORM get_customer_invoices.
DATA:ztotcre LIKE bsik-dmbtr.
DATA:ztotsal LIKE bsik-dmbtr.
DATA: fsdate LIKE sy-datum.
DATA: l_perio(4) TYPE c.
MOVE stida TO rf140-stida.
MOVE rf140-stida+4(2) TO targ_month.
MOVE rf140-stida+0(4) TO targ_year.
MOVE rf140-stida+6(2) TO targ_days.
targ_mth_abs = ( targ_year * 12 ) + targ_month.
CALL FUNCTION 'ZGET_PERIOD_FROM_DATE'
EXPORTING
i_date = stida
IMPORTING
e_perio = l_perio.
CONCATENATE l_perio '0401' INTO fsdate.
select open items.
IF p_due EQ 'X'.
SELECT lifnr belnr gjahr bldat xblnr blart sgtxt " 0001
shkzg dmbtr zfbdt zbd1t zbd2t zbd3t
zuonr
FROM bsik INTO TABLE inrect
WHERE bukrs = p_bukrs
AND budat LE stida
AND lifnr IN s_lifnr
AND gsber IN s_gsber
AND umskz NE 'T'
AND umskz NE 'F'
AND umskz NE 'R'
AND umskz NE 'P'
AND umskz NE 'J'
AND umskz NE 'L'.
LOOP AT INREC.
IF INREC-SHKZG = 'H'.
INREC-DMBTR = INREC-DMBTR * -1.
ENDIF.
MOVE-CORRESPONDING INREC TO T_ITEM. " 0001
PERFORM COLLECT_INVOICE USING INREC-lifnr INREC-DMBTR
INREC-ZFBDT INREC-ZBD1T
INREC-ZBD2T INREC-ZBD3T.
APPEND T_ITEM.
CLEAR T_ITEM.
ENDLOOP.
LOOP AT inrect.
inrec-lifnr = inrect-lifnr.
inrec-belnr = inrect-belnr.
inrec-gjahr = inrect-gjahr.
inrec-bldat = inrect-bldat.
inrec-xblnr = inrect-xblnr.
inrec-blart = inrect-blart.
inrec-sgtxt = inrect-sgtxt.
inrec-shkzg = inrect-shkzg.
inrec-dmbtr = inrect-dmbtr.
CALL FUNCTION 'NJ_CAL_DATE_IN_INTERVAL'
EXPORTING
date = inrect-zfbdt
days = inrect-zbd1t
months = 00
signum = '+'
years = 00
IMPORTING
calc_date = inrec-zfbdt.
inrec-zbd1t = inrect-zbd1t.
inrec-zbd2t = inrect-zbd2t.
inrec-zbd3t = inrect-zbd3t.
inrec-zuonr = inrect-zuonr.
APPEND inrec.
CLEAR inrec.
ENDLOOP.
ELSE.
SELECT lifnr belnr gjahr bldat xblnr blart sgtxt " 0001
shkzg dmbtr zfbdt zbd1t zbd2t zbd3t
zuonr
FROM bsik INTO TABLE inrec
WHERE bukrs = p_bukrs
AND budat LE stida
AND lifnr IN s_lifnr
AND gsber IN s_gsber
AND umskz NE 'T'
AND umskz NE 'F'
AND umskz NE 'R'
AND umskz NE 'P'
AND umskz NE 'J'
AND umskz NE 'L'.
ENDIF.
SORT inrec BY lifnr shkzg zfbdt .
LOOP AT inrec.
AT NEW lifnr.
For Customers Credit Balance Transaction to be display in Report
End of Credit Balance
ztotcre = 0.
ztotsal = 0.
ENDAT.
IF inrec-shkzg = 'H'.
inrec-dmbtr = inrec-dmbtr * -1.
ztotcre = ztotcre + inrec-dmbtr.
ELSE.
IF inrec-blart = 'RV'.
IF inrec-bldat GE fsdate.
ztotsal = ztotsal + inrec-dmbtr.
ENDIF.
ENDIF.
ztotcre = ztotcre + inrec-dmbtr.
endif.
IF p_debit EQ 'X'.
IF ztotcre > 0.
MOVE-CORRESPONDING inrec TO t_item. " 0001
PERFORM collect_invoice USING inrec-lifnr ztotcre
inrec-zfbdt inrec-zbd1t
inrec-zbd2t inrec-zbd3t
ztotsal.
APPEND t_item.
CLEAR t_item.
ztotcre = 0.
ztotsal = 0.
ENDIF.
ENDIF.
ENDIF.
IF p_credit EQ 'X'.
AT END OF lifnr.
IF ztotcre < 0.
MOVE-CORRESPONDING inrec TO t_item. " 0001
PERFORM collect_invoice USING inrec-lifnr ztotcre
inrec-zfbdt inrec-zbd1t
inrec-zbd2t inrec-zbd3t
ztotsal.
APPEND t_item.
CLEAR t_item.
ztotcre = 0.
ztotsal = 0.
APPEND t_item.
CLEAR t_item.
ENDIF.
ENDAT.
ENDIF.
ENDLOOP.
select cleared items
IF p_due EQ 'X'.
REFRESH inrect. CLEAR inrect.
SELECT lifnr belnr gjahr bldat xblnr blart sgtxt
shkzg dmbtr zfbdt zbd1t zbd2t zbd3t
zuonr
FROM bsak INTO TABLE inrect
WHERE bukrs = p_bukrs
AND budat LE stida
AND augdt > stida
AND lifnr IN s_lifnr
AND gsber IN s_gsber
REFRESH inrec. CLEAR inrec.
LOOP AT inrect.
inrec-lifnr = inrect-lifnr.
inrec-belnr = inrect-belnr.
inrec-gjahr = inrect-gjahr.
inrec-bldat = inrect-bldat.
inrec-xblnr = inrect-xblnr.
inrec-blart = inrect-blart.
inrec-sgtxt = inrect-sgtxt.
inrec-shkzg = inrect-shkzg.
inrec-dmbtr = inrect-dmbtr.
CALL FUNCTION 'NJ_CAL_DATE_IN_INTERVAL'
EXPORTING
date = inrect-zfbdt
days = inrect-zbd1t
months = 00
signum = '+'
years = 00
IMPORTING
calc_date = inrec-zfbdt.
inrec-zbd1t = inrect-zbd1t.
inrec-zbd2t = inrect-zbd2t.
inrec-zbd3t = inrect-zbd3t.
inrec-zuonr = inrect-zuonr.
APPEND inrec.
CLEAR inrec.
ENDLOOP.
ELSE.
REFRESH inrec. CLEAR inrec.
SELECT lifnr belnr gjahr bldat xblnr blart sgtxt
shkzg dmbtr zfbdt zbd1t zbd2t zbd3t
zuonr
FROM bsak INTO TABLE inrec
WHERE bukrs = p_bukrs
AND budat LE stida
AND augdt > stida
AND lifnr IN s_lifnr
AND gsber IN s_gsber
ENDIF.
SORT inrec BY lifnr shkzg zfbdt .
LOOP AT inrec.
AT NEW lifnr.
ztotcre = 0.
ztotsal = 0.
ENDAT.
IF inrec-shkzg = 'H'.
inrec-dmbtr = inrec-dmbtr * -1.
ztotcre = ztotcre + inrec-dmbtr.
ELSE.
IF inrec-blart = 'RV'.
IF inrec-bldat GE fsdate.
ztotsal = ztotsal + inrec-dmbtr.
ENDIF.
ENDIF.
ztotcre = ztotcre + inrec-dmbtr.
endif.
IF p_debit EQ 'X'.
IF ztotcre > 0.
MOVE-CORRESPONDING inrec TO t_item. " 0001
PERFORM collect_invoice USING inrec-lifnr ztotcre
inrec-zfbdt inrec-zbd1t
inrec-zbd2t inrec-zbd3t
ztotsal.
APPEND t_item.
CLEAR t_item.
ztotcre = 0.
ztotsal = 0.
ENDIF.
ENDIF.
ENDIF.
IF p_credit EQ 'X'.
AT END OF lifnr.
IF ztotcre < 0.
MOVE-CORRESPONDING inrec TO t_item. " 0001
PERFORM collect_invoice USING inrec-lifnr ztotcre
inrec-zfbdt inrec-zbd1t
inrec-zbd2t inrec-zbd3t
ztotsal.
APPEND t_item.
CLEAR t_item.
ztotcre = 0.
ztotsal = 0.
APPEND t_item.
CLEAR t_item.
ENDIF.
ENDAT. " 0001
ENDIF.
ENDLOOP.
ENDFORM. " GET_CUSTOMER_INVOICES
*& Form COLLECT_INVOICE
text
-->P_bsik_lifnr text
-->P_bsik_DMBTR text
-->P_bsik_ZFBDT text
-->P_bsik_ZFBDT1 text
-->P_bsik_ZFBDT2 text
-->P_bsik_ZFBDT3 text
FORM collect_invoice USING pp_lifnr
pp_dmbtr
pp_zfbdt
pp_zbd1t
pp_zbd2t
pp_zbd3t
pp_ztotsal.
doc_month = pp_zfbdt+4(2).
doc_year = pp_zfbdt+0(4).
doc_mth_abs = ( doc_year * 12 ) + doc_month.
mth_result = ( targ_mth_abs - doc_mth_abs ).
logic given by Mr. Ashok Singhvi
doc_days = pp_zfbdt+6(2).
addl_days = ( doc_days - targ_days ).
IF addl_days <= 0.
ADD 1 TO mth_result.
ENDIF.
IF NOT pp_zbd3t IS INITIAL.
MOVE pp_zbd3t TO ext_days.
ELSEIF NOT pp_zbd2t IS INITIAL.
MOVE pp_zbd2t TO ext_days.
ELSEIF NOT pp_zbd1t IS INITIAL.
MOVE pp_zbd1t TO ext_days.
ELSE.
CLEAR ext_days.
ENDIF.
CHECK with Andrew whether this is working or not
if extended payment terms exist, subtract no of mths from mth_result
IF NOT ext_days IS INITIAL.
CASE ext_days.
WHEN 30.
SUBTRACT 1 FROM mth_result.
WHEN 60.
SUBTRACT 2 FROM mth_result.
WHEN 90.
SUBTRACT 3 FROM mth_result.
WHEN 120.
SUBTRACT 4 FROM mth_result.
ENDCASE.
ENDIF.
change to key date
IF pp_dmbtr > 0.
IF p_future = 'X'. " 0001
IF mth_result <= 0.
itab-zcurrent = pp_dmbtr.
t_item-days = 'CUR'.
ELSEIF mth_result = 1.
itab-30days = pp_dmbtr.
t_item-days = '30D'.
ELSEIF mth_result = 2.
itab-60days = pp_dmbtr.
t_item-days = '60D'.
ELSEIF mth_result = 3.
itab-90days = pp_dmbtr.
t_item-days = '90D'.
ELSEIF mth_result > 3 AND mth_result <= 4 .
itab-99days = pp_dmbtr.
t_item-days = '99D'.
ELSEIF mth_result > 4 AND mth_result <= 6 .
itab-120days = pp_dmbtr.
t_item-days = '120D'.
ELSEIF mth_result > 6 AND mth_result <= 12 .
itab-180days = pp_dmbtr.
t_item-days = '180D'.
ELSEIF mth_result > 12 .
itab-365days = pp_dmbtr.
t_item-days = '365D'.
ENDIF.
ELSE.
IF mth_result < 0.
itab-zfuture = pp_dmbtr.
t_item-days = 'FUT'.
ELSEIF mth_result = 0.
itab-zcurrent = pp_dmbtr.
t_item-days = 'CUR'.
ELSEIF mth_result = 1.
itab-30days = pp_dmbtr.
t_item-days = '30D'.
ELSEIF mth_result = 2.
itab-60days = pp_dmbtr.
t_item-days = '60D'.
ELSEIF mth_result = 3.
itab-90days = pp_dmbtr.
t_item-days = '90D'.
ELSEIF mth_result > 3 AND mth_result <= 4 .
itab-99days = pp_dmbtr.
t_item-days = '99D'.
ELSEIF mth_result > 4 AND mth_result <= 6 .
itab-120days = pp_dmbtr.
t_item-days = '120D'.
ELSEIF mth_result > 6 AND mth_result <= 12 .
itab-180days = pp_dmbtr.
t_item-days = '180D'.
ELSEIF mth_result > 12 .
itab-365days = pp_dmbtr.
t_item-days = '365D'.
ENDIF.
ENDIF. " 0001
itab-crbal = 0.
itab-total = pp_dmbtr.
ELSE.
IF p_future = 'X'. " 0001
IF mth_result <= 0.
itab-zcurrent = pp_dmbtr.
t_item-days = 'CUR'.
ELSEIF mth_result = 1.
itab-30days = pp_dmbtr.
t_item-days = '30D'.
ELSEIF mth_result = 2.
itab-60days = pp_dmbtr.
t_item-days = '60D'.
ELSEIF mth_result = 3.
itab-90days = pp_dmbtr.
t_item-days = '90D'.
ELSEIF mth_result > 3 AND mth_result <= 4 .
itab-99days = pp_dmbtr.
t_item-days = '99D'.
ELSEIF mth_result > 4 AND mth_result <= 6 .
itab-120days = pp_dmbtr.
t_item-days = '120D'.
ELSEIF mth_result > 6 AND mth_result <= 12 .
itab-180days = pp_dmbtr.
t_item-days = '180D'.
ELSEIF mth_result > 12 .
itab-365days = pp_dmbtr.
t_item-days = '365D'.
ENDIF.
ELSE.
IF mth_result < 0.
itab-zfuture = pp_dmbtr.
t_item-days = 'FUT'.
ELSEIF mth_result = 0.
itab-zcurrent = pp_dmbtr.
t_item-days = 'CUR'.
ELSEIF mth_result = 1.
itab-30days = pp_dmbtr.
t_item-days = '30D'.
ELSEIF mth_result = 2.
itab-60days = pp_dmbtr.
t_item-days = '60D'.
ELSEIF mth_result = 3.
itab-90days = pp_dmbtr.
t_item-days = '90D'.
ELSEIF mth_result > 3 AND mth_result <= 4 .
itab-99days = pp_dmbtr.
t_item-days = '99D'.
ELSEIF mth_result > 4 AND mth_result <= 6 .
itab-120days = pp_dmbtr.
t_item-days = '120D'.
ELSEIF mth_result > 6 AND mth_result <= 12 .
itab-180days = pp_dmbtr.
t_item-days = '180D'.
ELSEIF mth_result > 12 .
itab-365days = pp_dmbtr.
t_item-days = '365D'.
ENDIF.
ENDIF. " 0001
itab-total = pp_dmbtr.
itab-crbal = 0.
ENDIF.
itab-lifnr = pp_lifnr.
itab-totsal = pp_ztotsal.
COLLECT itab.
CLEAR itab.
ENDFORM. " COLLECT_INVOICE
*& Form ADD_SORT_FIELD
text
--> p1 text
<-- p2 text
FORM add_sort_field.
DATA: l_amount(9) TYPE n.
IF p_future = 'X'.
LOOP AT itab.
l_amount = 999999999.
IF itab-365days > 0.
l_amount = l_amount - itab-365days.
CONCATENATE 'A' l_amount INTO itab-psort.
ELSEIF itab-180days > 0.
l_amount = l_amount - itab-180days.
CONCATENATE 'B' l_amount INTO itab-psort.
ELSEIF itab-120days > 0.
l_amount = l_amount - itab-120days.
CONCATENATE 'C' l_amount INTO itab-psort.
ELSEIF itab-99days > 0.
l_amount = l_amount - itab-99days.
CONCATENATE 'D' l_amount INTO itab-psort.
ELSEIF itab-90days > 0.
l_amount = l_amount - itab-90days.
CONCATENATE 'E' l_amount INTO itab-psort.
ELSEIF itab-60days > 0.
l_amount = l_amount - itab-60days.
CONCATENATE 'F' l_amount INTO itab-psort.
ELSEIF itab-30days > 0.
l_amount = l_amount - itab-30days.
CONCATENATE 'G' l_amount INTO itab-psort.
ELSEIF itab-zcurrent > 0.
l_amount = l_amount - itab-zcurrent.
CONCATENATE 'H' l_amount INTO itab-psort.
ELSEif itab-zfuture > 0.
L_AMOUNT = L_AMOUNT - ITAB-zfuture.
CONCATENATE 'F' L_AMOUNT INTO ITAB-PSORT.
ELSE.
l_amount = ABS( itab-total ).
CONCATENATE 'I' l_amount INTO itab-psort.
ENDIF.
MODIFY itab.
ENDLOOP.
ELSE.
LOOP AT itab.
l_amount = 999999999.
IF itab-365days > 0.
l_amount = l_amount - itab-365days.
CONCATENATE 'A' l_amount INTO itab-psort.
ELSEIF itab-180days > 0.
l_amount = l_amount - itab-180days.
CONCATENATE 'B' l_amount INTO itab-psort.
ELSEIF itab-120days > 0.
l_amount = l_amount - itab-120days.
CONCATENATE 'C' l_amount INTO itab-psort.
ELSEIF itab-99days > 0.
l_amount = l_amount - itab-99days.
CONCATENATE 'D' l_amount INTO itab-psort.
ELSEIF itab-90days > 0.
l_amount = l_amount - itab-90days.
CONCATENATE 'E' l_amount INTO itab-psort.
ELSEIF itab-60days > 0.
l_amount = l_amount - itab-60days.
CONCATENATE 'F' l_amount INTO itab-psort.
ELSEIF itab-30days > 0.
l_amount = l_amount - itab-30days.
CONCATENATE 'G' l_amount INTO itab-psort.
ELSEIF itab-zcurrent > 0.
l_amount = l_amount - itab-zcurrent.
CONCATENATE 'H' l_amount INTO itab-psort.
ELSEIF itab-zfuture > 0.
l_amount = l_amount - itab-zfuture.
CONCATENATE 'I' l_amount INTO itab-psort.
ELSE.
l_amount = ABS( itab-total ).
CONCATENATE 'J' l_amount INTO itab-psort.
ENDIF.
MODIFY itab.
ENDLOOP.
ENDIF.
ENDFORM. " ADD_SORT_FIELD
*& Form WRITE_REPORT
text
--> p1 text
<-- p2 text
FORM write_report.
PERFORM build_fieldcat.
PERFORM build_sortcat.
PERFORM build_eventcat.
PERFORM build_layout.
PERFORM start_list_viewer.
ENDFORM. " WRITE_REPORT
*& Form BUILD_FIELDCAT
text
--> p1 text
<-- p2 text
FORM build_fieldcat.
lifnr
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'lfa1'.
fieldcat_ln-fieldname = 'LIFNR'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-emphasize = 'C41'.
APPEND fieldcat_ln TO fieldcat.
Name1
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'lfa1'.
fieldcat_ln-fieldname = 'NAME1'.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-seltext_l = 'Name'.
APPEND fieldcat_ln TO fieldcat.
City Details
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'lfa1'.
fieldcat_ln-fieldname = 'ORT01'.
fieldcat_ln-seltext_l = 'City'.
fieldcat_ln-col_pos = col_pos.
APPEND fieldcat_ln TO fieldcat.
Credit Limit
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'KNKK'.
fieldcat_ln-fieldname = 'KLIMK'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-emphasize = 'C41'.
APPEND fieldcat_ln TO fieldcat.
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'bsik'.
fieldcat_ln-ref_fieldname = 'DMBTR'.
fieldcat_ln-fieldname = 'CRBAL'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-seltext_l = 'Cr. Bal.'.
fieldcat_ln-seltext_m = 'Cr. Bal.'.
fieldcat_ln-seltext_s = 'Cr. Bal.'.
APPEND fieldcat_ln TO fieldcat.
Total Amount
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-fieldname = 'TOTAL'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-seltext_l = 'Out.St.Amt.'.
fieldcat_ln-seltext_m = 'Out.St.Amt.'.
fieldcat_ln-seltext_s = 'Out.St.Amt.'.
fieldcat_ln-ref_tabname = 'zbsik'.
fieldcat_ln-ref_fieldname = 'ZDMBTR'.
APPEND fieldcat_ln TO fieldcat.
IF p_future NE 'X'.
Future
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'bsik'.
fieldcat_ln-ref_fieldname = 'DMBTR'.
fieldcat_ln-fieldname = 'ZFUTURE'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-seltext_l = 'Future Due'.
fieldcat_ln-seltext_m = 'Future Due'.
fieldcat_ln-seltext_s = 'Future Due'.
APPEND fieldcat_ln TO fieldcat.
ENDIF.
Current
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'bsik'.
fieldcat_ln-ref_fieldname = 'DMBTR'.
fieldcat_ln-fieldname = 'ZCURRENT'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-seltext_l = 'Normal Due'.
fieldcat_ln-seltext_m = 'Normal Due'.
fieldcat_ln-seltext_s = 'Normal Due'.
APPEND fieldcat_ln TO fieldcat.
30 Days
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'bsik'.
fieldcat_ln-ref_fieldname = 'DMBTR'.
fieldcat_ln-fieldname = '30DAYS'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-seltext_l = '0-30 Days'.
fieldcat_ln-seltext_m = '0-30 Days'.
fieldcat_ln-seltext_s = '0-30 Days'.
APPEND fieldcat_ln TO fieldcat.
60 Days
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'bsik'.
fieldcat_ln-ref_fieldname = 'DMBTR'.
fieldcat_ln-fieldname = '60DAYS'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-seltext_l = '31-60 Days'.
fieldcat_ln-seltext_m = '31-60 Days'.
fieldcat_ln-seltext_s = '31-60 Days'.
APPEND fieldcat_ln TO fieldcat.
90 Days
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'bsik'.
fieldcat_ln-ref_fieldname = 'DMBTR'.
fieldcat_ln-fieldname = '90DAYS'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-seltext_l = '61-90 Days'.
fieldcat_ln-seltext_m = '61-90 Days'.
fieldcat_ln-seltext_s = '61-90 Days'.
APPEND fieldcat_ln TO fieldcat.
99 Days
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'bsik'.
fieldcat_ln-ref_fieldname = 'DMBTR'.
fieldcat_ln-fieldname = '99DAYS'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-seltext_l = '91-120 Days'.
fieldcat_ln-seltext_m = '91-120 Days'.
fieldcat_ln-seltext_s = '91-120 Days'.
APPEND fieldcat_ln TO fieldcat.
*120Days
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'bsik'.
fieldcat_ln-ref_fieldname = 'DMBTR'.
fieldcat_ln-fieldname = '120DAYS'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-seltext_l = '121-180 Days'.
fieldcat_ln-seltext_m = '121-180 Days'.
fieldcat_ln-seltext_s = '121-180 Days'.
APPEND fieldcat_ln TO fieldcat.
*180 Days
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'bsik'.
fieldcat_ln-ref_fieldname = 'DMBTR'.
fieldcat_ln-fieldname = '180DAYS'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-seltext_l = '181-365 Days'.
fieldcat_ln-seltext_m = '181-365 Days'.
fieldcat_ln-seltext_s = '181-365 Days'.
APPEND fieldcat_ln TO fieldcat.
*365 Days
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'bsik'.
fieldcat_ln-ref_fieldname = 'DMBTR'.
fieldcat_ln-fieldname = '365DAYS'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-seltext_l = '>365 Days'.
fieldcat_ln-seltext_m = '>365 Days'.
fieldcat_ln-seltext_s = '>365 Days'.
APPEND fieldcat_ln TO fieldcat.
Last Payment Date
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'KNKK'.
fieldcat_ln-fieldname = 'CASHD'.
fieldcat_ln-col_pos = col_pos.
APPEND fieldcat_ln TO fieldcat.
Street Name
ADD 1 TO COL_POS.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-REF_TABNAME = 'lfa1'.
FIELDCAT_LN-FIELDNAME = 'STRAS'.
FIELDCAT_LN-COL_POS = COL_POS.
APPEND FIELDCAT_LN TO FIELDCAT.
Telephone
ADD 1 TO COL_POS.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-REF_TABNAME = 'lfa1'.
FIELDCAT_LN-FIELDNAME = 'TELF1'.
FIELDCAT_LN-COL_POS = COL_POS.
APPEND FIELDCAT_LN TO FIELDCAT.
Credit Group
ADD 1 TO COL_POS.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-REF_TABNAME = 'KNKK'.
FIELDCAT_LN-FIELDNAME = 'GRUPP'.
FIELDCAT_LN-COL_POS = COL_POS.
APPEND FIELDCAT_LN TO FIELDCAT.
*Sales District
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'KNVV'.
fieldcat_ln-fieldname = 'BZIRK'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-seltext_l = 'S_Distt'.
fieldcat_ln-seltext_m = 'S_Distt'.
fieldcat_ln-seltext_s = 'S_Distt'.
APPEND fieldcat_ln TO fieldcat.
Sales Office
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'KNVV'.
fieldcat_ln-fieldname = 'VKBUR'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-seltext_l = 'S_Off'.
fieldcat_ln-seltext_m = 'S_Off'.
fieldcat_ln-seltext_s = 'S_Off'.
APPEND fieldcat_ln TO fieldcat.
Cust Creat Date
ADD 1 TO COL_POS.
CLEAR FIELDCAT_LN.
FIELDCAT_LN-REF_TABNAME = 'lfa1'.
FIELDCAT_LN-FIELDNAME = 'ERDAT'.
FIELDCAT_LN-COL_POS = COL_POS.
APPEND FIELDCAT_LN TO FIELDCAT.
Del Plant
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'KNVV'.
fieldcat_ln-fieldname = 'VWERK'.
fieldcat_ln-col_pos = col_pos.
APPEND fieldcat_ln TO fieldcat.
Sales Group
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'KNVV'.
fieldcat_ln-fieldname = 'VKGRP'.
fieldcat_ln-col_pos = col_pos.
APPEND fieldcat_ln TO fieldcat.
Sort Criteria
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'bsik'.
fieldcat_ln-ref_fieldname = 'lifnr'.
fieldcat_ln-fieldname = 'PSORT'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-seltext_l = 'Sort Field'.
fieldcat_ln-seltext_m = 'Sort Field'.
fieldcat_ln-seltext_s = 'Sort Field'.
APPEND fieldcat_ln TO fieldcat.
Sales of Customer
ADD 1 TO col_pos.
CLEAR fieldcat_ln.
fieldcat_ln-ref_tabname = 'bsik'.
fieldcat_ln-ref_fieldname = 'DMBTR'.
fieldcat_ln-fieldname = 'TOTSAL'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-do_sum = 'X'.
fieldcat_ln-hotspot = 'X'.
fieldcat_ln-emphasize = 'C41'.
fieldcat_ln-seltext_l = 'Total Sales'.
fieldcat_ln-seltext_m = 'Total Sales'.
fieldcat_ln-seltext_s = 'Total Sales'.
APPEND fieldcat_ln TO fieldcat.
ENDFORM. " BUILD_FIELDCAT
*& Form BUILD_SORTCAT
text
--> p1 text
<-- p2 text
FORM build_sortcat.
SORTCAT_LN-SPOS = '1'.
sortcat_ln-spos = '2'. " 0001
sortcat_ln-fieldname = 'PSORT'.
sortcat_ln-up = 'X'. " 0001
sortcat_ln-subtot = 'X'.
APPEND sortcat_ln TO sortcat.
CLEAR sortcat_ln.
SORTCAT_LN-SPOS = '2'.
SORTCAT_LN-FIELDNAME = 'lifnr'.
sortcat_ln-spos = '1'. " 0001
sortcat_ln-fieldname = 'NAME1'. " 0001
sortcat_ln-up = 'X'.
APPEND sortcat_ln TO sortcat.
ENDFORM. " BUILD_SORTCAT
*& Form BUILD_EVENTCAT
text
--> p1 text
<-- p2 text
FORM build_eventcat.
eventcat_ln-name = 'TOP_OF_PAGE'.
eventcat_ln-form = 'PAGE_HEADER'.
APPEND eventcat_ln TO eventcat.
ENDFORM. " BUILD_EVENTCAT
*& Form BUILD_LAYOUT
text
--> p1 text
<-- p2 text
FORM build_layout.
layout_in-colwidth_optimize = 'X'.
layout_in-no_hotspot = 'X'.
layout_in-zebra = 'X'.
layout_in-get_selinfos = 'X'.
ENDFORM. " BUILD_LAYOUT
*& Form START_LIST_VIEWER
text
--> p1 text
<-- p2 text
FORM start_list_viewer.
DATA: pgm LIKE sy-repid.
pgm = sy-repid.
if t_variant[] is initial.
t_variant-report = pgm.
t_variant-variant = '/ATB'.
t_variant-TEXT = '/ATB'.
t_variant-DEPENDVARS = 'S'.
append t_variant.
clear t_variant.
endif.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = pgm
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = fieldcat
it_sort = sortcat
is_layout = layout_in
i_save = 'A'
IS_VARIANT = t_variant
it_events = eventcat
TABLES
t_outtab = itab
EXCEPTIONS
OTHERS = 2.
ENDFORM. " START_LIST_VIEWER
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
DATA l_lifnr(10) TYPE n.
READ TABLE itab INDEX selfield-tabindex.
CHECK sy-subrc = 0.
CASE ucomm.
WHEN '&IC1'.
CASE selfield-sel_tab_field.
WHEN 'ITAB-LIFNR'.
SET PARAMETER ID 'LIF' FIELD itab-lifnr.
SET PARAMETER ID 'BUK' FIELD p_bukrs.
IF itab-lifnr CO '0123456789 '.
l_lifnr = itab-lifnr.
itab-lifnr = l_lifnr.
ENDIF.
SELECT SINGLE kkber INTO knkk-kkber
FROM knkk WHERE lifnr = itab-lifnr.
IF sy-subrc EQ 0.
v_kkber = knkk-kkber.
ELSE.
CLEAR v_kkber.
ENDIF.
REFRESH sel_tab[].
MOVE: 'lifnr' TO sel_tab-selname,
'P' TO sel_tab-kind, " PARAMETER
itab-lifnr TO sel_tab-low.
APPEND sel_tab.
CLEAR sel_tab.
MOVE: 'KKBER' TO sel_tab-selname,
'P' TO sel_tab-kind, " PARAMETER
v_kkber TO sel_tab-low.
APPEND sel_tab.
CLEAR sel_tab.
SUBMIT rfdkli41
USING SELECTION-SET 'VAR1'
WITH SELECTION-TABLE sel_tab
AND RETURN.
CALL TRANSACTION 'XK03' AND SKIP FIRST SCREEN.
WHEN 'ITAB-ZCURRENT'. " 0001
v_days = 'CUR'.
PERFORM display_line_item_level.
WHEN 'ITAB-ZFUTURE'.
v_days = 'FUT'.
PERFORM display_line_item_level.
WHEN 'ITAB-30DAYS'.
v_days = '30D'.
PERFORM display_line_item_level.
WHEN 'ITAB-60DAYS'.
v_days = '60D'.
PERFORM display_line_item_level.
WHEN 'ITAB-90DAYS'.
v_days = '90D'.
PERFORM display_line_item_level.
WHEN 'ITAB-99DAYS'.
v_days = '99D'.
PERFORM display_line_item_level.
WHEN 'ITAB-120DAYS'.
v_days = '120D'.
PERFORM display_line_item_level.
WHEN 'ITAB-180DAYS'.
v_days = '180D'.
PERFORM display_line_item_level.
WHEN 'ITAB-365DAYS'.
v_days = '365D'.
PERFORM display_line_item_level.
WHEN 'ITAB-TOTAL'.
v_days = ' '.
PERFORM display_line_item_level. " 0001
ENDCASE.
ENDCASE.
ENDFORM. "USER_COMMAND
PAGE_HEADER
FORM page_header.
WRITE:/115 'Time:', sy-timlo.
WRITE: /115 'Date:', sy-datum.
WRITE: /52 'Customer Outstanding Agewise ', "0002
115 'Page:', sy-pagno.
SKIP.
IF p_abs EQ 'X'.
WRITE: /52 'Vendor Outstanding Agewise (Absolute Aging)',
115 'Page:', sy-pagno.
ELSE.
WRITE: /52 'Vendor Outstanding Agewise (Due Date Aging)',
115 'Page:', sy-pagno.
ENDIF.
SKIP.
ULINE /(132).
WRITE: /02 'Open Items as of:', stida.
IF NOT s_vkgrp[] IS INITIAL.
IF s_vkgrp-high IS INITIAL.
WRITE: 52 'Sales Group :',s_vkgrp-low.
ELSE.
WRITE: 52 'Sales Group :',s_vkgrp-low,'to',s_vkgrp-high.
ENDIF.
ELSE.
WRITE: 52 'Sales Group : All'.
ENDIF.
IF NOT s_grupp[] IS INITIAL.
IF s_grupp-high IS INITIAL.
WRITE: 107 'Credit group :',s_grupp-low.
ELSE.
WRITE: 107 'Credit group :',s_grupp-low,' to',s_grupp-high.
ENDIF.
ELSE.
WRITE: 107 'Credit Group : All'.
ENDIF.
WRITE: /02 'Comapany Code :', p_bukrs.
IF NOT s_konda[] IS INITIAL.
IF s_konda-high IS INITIAL.
WRITE: 52 'Price group :',s_konda-low.
ELSE.
WRITE: 52 'Price group :',s_konda-low,' to',s_konda-high.
ENDIF.
ELSE.
WRITE: 52 'Price Group : All'.
ENDIF.
IF NOT s_ctlpc[] IS INITIAL.
IF s_ctlpc-high IS INITIAL.
WRITE: 107 'Risk category:',s_ctlpc-low.
ELSE.
WRITE: 107 'Risk category:',s_ctlpc-low,' to',s_ctlpc-high.
ENDIF.
ELSE.
WRITE: 107 'Risk category: All'.
ENDIF.
IF NOT s_vkbur[] IS INITIAL.
IF s_vkbur-high IS INITIAL.
WRITE:/02 'Sales Office :',s_vkbur-low.
ELSE.
WRITE:/02 'Sales Office :',s_vkbur-low,' to',s_vkbur-high.
ENDIF.
ELSE.
WRITE:/02 'Sales Office : All'.
ENDIF.
IF NOT s_kdgrp[] IS INITIAL.
IF s_kdgrp-high IS INITIAL.
WRITE: 52 'Customer group :',s_kdgrp-low.
ELSE.
WRITE: 52 'Customer group :',s_kdgrp-low,' to',s_kdgrp-high.
ENDIF.
ELSE.
WRITE: 52 'Customer group : All'.
ENDIF.
IF NOT s_ktokd[] IS INITIAL.
IF s_ktokd-high IS INITIAL.
WRITE: 107 'Account Group:',s_ktokd-low.
ELSE.
WRITE: 107 'Account Group:',s_ktokd-low,' to',s_ktokd-high.
ENDIF.
ELSE.
WRITE: 107 'Account Group: All'.
ENDIF.
IF NOT s_lifnr[] IS INITIAL.
IF s_lifnr-high IS INITIAL.
WRITE: /02 'Vendor No :',s_lifnr-low.
ELSE.
WRITE: /02 'Vendor No :',s_lifnr-low,' to',s_lifnr-high.
ENDIF.
ELSE.
WRITE: /02 'Vendor No : All'.
ENDIF.
IF NOT s_kkber[] IS INITIAL.
IF s_kkber-high IS INITIAL.
WRITE: 52 'Credit Control Area:',s_kkber-low.
ELSE.
WRITE: 52 'Credit Control Area:',s_kkber-low,' to',s_kkber-high. -
Hi All
How do we get Customer and Vendor ageing report by "ItemGroup"?
I know there is a standard report in Business One which gives you the ageing report by Business Partner Group. But I dont know whether it is possible to get by "ItemGroup". Please help me and excuse me for weird requirement..
ThanksHi Gordon,
that query is actually designed for getting the purchase reports with all the excise and other tax related information per line item in the marketing document. my requirement is something different than this where the client wants to see the ageing report by Itemgroup.
Since ageing is based on the invoice due date it looks difficult to bifurcate the each individual line item, its group, its line total and their due date. means we should add all the open invoices' line items to be grouped with its total based on the due date. any other way to solve this?
thanks -
Can using query create aging report for GL Account
Hi all expert,
I have a challenge scenario which customer request print out aging report for the following GL Account.
This is not a business partner account. However, customer want display like aging report.
30 days aging report for the following GL accounts by projects:-
i) WIP (Work In Progress) account
ii) Accrued Revenue account
iii) Accrued Cost account
Examples:
Current Balance 30 day 60 day 90 day 120 day
Account WIP 10000 2000 3000 5000 0
Any idea or example given? If yes, can you provide a query here?
Regards,
Eric TanHi Eric
In standard SAP Business One this is difficult as the reports are 2 dimensional. To achieve this you will need to write multiple select statements into a temporary table and then select the final result from the temp table. Here is a sample for you to test:
USE [*DATABASE_NAME*]
GO
/****** Object: StoredProcedure [dbo].[REPORT_NAME] Script Date: 04/24/2009 13:17:21 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE proc [dbo].[*REPORT_NAME*]
as
set nocount on
begin
DECLARE @Day_no varchar(2)
DECLARE @Month_no varchar(2)
DECLARE @Year_no varchar(4)
DECLARE @Start_Date Datetime
SET @Day_no = DAY(GetDate())
SET @Month_no = MONTH(GetDate())
SET @Year_no = YEAR(GetDate())
SET @Start_Date = @Year_No + '/' + @Month_no + '/' + @Day_no -- + '/' + @Year_No
IF OBJECT_ID(N'tempdb..#CRDAGEING', N'U') IS NOT NULL
drop table #CRDAGEING
SELECT T0.[CardCode] AS [CardCode], T0.[CardName] AS [CardName], -T0.[Balance] AS [Balance], CAST(0 AS MONEY) AS [Current], CAST(0 AS MONEY) AS [1Week], CAST(0 AS MONEY) AS [2Weeks], CAST(0 AS MONEY) AS [3Weeks], CAST(0 AS MONEY) AS [4Weeks], CAST(0 AS MONEY) AS [5Weeks], CAST(0 AS MONEY) AS [6Weeks], CAST(0 AS MONEY) AS [Over6Weeks], CAST(0 AS MONEY) AS [Avg3Months], CAST (0 AS MONEY) AS [Onhand] INTO #CRDAGEING FROM OCRD T0 WHERE T0.[CardType] = 'S' -- and T0.[CardCode] <> '' --and T0.[DocDate] >= @FromDate AND T0.[DocDate] <= @ToDate
INSERT dbo.#CRDAGEING SELECT T1.[ShortName], NULL, 0, -SUM(T1.[BalDueDeb] - T1.[BalDueCred]), 0, 0, 0, 0, 0, 0, 0, 0, 0 FROM JDT1 T1, OCRD T2 WHERE T2.[CardType] = 'S' and T2.[CardCode] = T1.[ShortName] and T1.[DueDate] <= @Start_Date GROUP BY T1.[ShortName]
INSERT dbo.#CRDAGEING SELECT T1.[ShortName], NULL, 0, 0, -SUM(T1.[BalDueDeb] - T1.[BalDueCred]), 0, 0, 0, 0, 0, 0, 0, 0 FROM JDT1 T1, OCRD T2 WHERE T2.[CardType] = 'S' and T2.[CardCode] = T1.[ShortName] and T1.[DueDate] >= DATEADD(DAY,1,@Start_Date) and T1.[DueDate] <= DATEADD(DAY,8,@Start_Date) GROUP BY T1.[ShortName]
INSERT dbo.#CRDAGEING SELECT T1.[ShortName], NULL, 0, 0, 0, -SUM(T1.[BalDueDeb] - T1.[BalDueCred]), 0, 0, 0, 0, 0, 0, 0 FROM JDT1 T1, OCRD T2 WHERE T2.[CardType] = 'S' and T2.[CardCode] = T1.[ShortName] and T1.[DueDate] > DATEADD(DAY,8,@Start_Date) and T1.[DueDate] <= DATEADD(DAY,15,@Start_Date) GROUP BY T1.[ShortName]
INSERT dbo.#CRDAGEING SELECT T1.[ShortName], NULL, 0, 0, 0, 0, -SUM(T1.[BalDueDeb] - T1.[BalDueCred]), 0, 0, 0, 0, 0, 0 FROM JDT1 T1, OCRD T2 WHERE T2.[CardType] = 'S' and T2.[CardCode] = T1.[ShortName] and T1.[DueDate] > DATEADD(DAY,15,@Start_Date) and T1.[DueDate] <= DATEADD(DAY,22,@Start_Date) GROUP BY T1.[ShortName]
INSERT dbo.#CRDAGEING SELECT T1.[ShortName], NULL, 0, 0, 0, 0, 0, -SUM(T1.[BalDueDeb] - T1.[BalDueCred]), 0, 0, 0, 0, 0 FROM JDT1 T1, OCRD T2 WHERE T2.[CardType] = 'S' and T2.[CardCode] = T1.[ShortName] and T1.[DueDate] > DATEADD(DAY,22,@Start_Date) and T1.[DueDate] <= DATEADD(DAY,29,@Start_Date) GROUP BY T1.[ShortName]
INSERT dbo.#CRDAGEING SELECT T1.[ShortName], NULL, 0, 0, 0, 0, 0, 0, -SUM(T1.[BalDueDeb] - T1.[BalDueCred]), 0, 0, 0, 0 FROM JDT1 T1, OCRD T2 WHERE T2.[CardType] = 'S' and T2.[CardCode] = T1.[ShortName] and T1.[DueDate] > DATEADD(DAY,29,@Start_Date) and T1.[DueDate] <= DATEADD(DAY,36,@Start_Date) GROUP BY T1.[ShortName]
INSERT dbo.#CRDAGEING SELECT T1.[ShortName], NULL, 0, 0, 0, 0, 0, 0, 0, -SUM(T1.[BalDueDeb] - T1.[BalDueCred]), 0, 0, 0 FROM JDT1 T1, OCRD T2 WHERE T2.[CardType] = 'S' and T2.[CardCode] = T1.[ShortName] and T1.[DueDate] > DATEADD(DAY,36,@Start_Date) and T1.[DueDate] <= DATEADD(DAY,43,@Start_Date) GROUP BY T1.[ShortName]
INSERT dbo.#CRDAGEING SELECT T1.[ShortName], NULL, 0, 0, 0, 0, 0, 0, 0, 0, -SUM(T1.[BalDueDeb] - T1.[BalDueCred]), 0, 0 FROM JDT1 T1, OCRD T2 WHERE T2.[CardType] = 'S' and T2.[CardCode] = T1.[ShortName] and T1.[DueDate] > DATEADD(DAY,43,@Start_Date) GROUP BY T1.[ShortName]
SELECT SR.[CardCode], MAX(SR.[CardName]), SUM(SR.[Balance]) AS [BalanceOwing], SUM(SR.[Current]) AS [Current], SUM(SR.[1Week]) AS [1Week], SUM(SR.[2Weeks]) AS [2Weeks], SUM(SR.[3Weeks]) AS [3Weeks], SUM(SR.[4Weeks]) AS [4Weeks], SUM(SR.[5Weeks]) AS [5Weeks], SUM(SR.[6Weeks]) AS [6Weeks], SUM(SR.[Over6Weeks]) AS [Over6Weeks] FROM dbo.#CRDAGEING SR GROUP BY SR.[CardCode] ORDER BY SR.[CardCode]
END
Go to Microsoft SQL Studio manager and select your company database. Then expand the list and select Programmability > Stored Procedures. Right click on Stored Procedures and select New Stored Procedure. Copy the above code over the code in the edit window and change the database name as well as report name. Then select Execute to create the stored procedure. If you make changes, remember to change the word CREATE to ALTER (with other words CREATE for the first execute, and ALTER thereafter). Then in SAP Business One create a new query and leave everything blank. Click on execute and select the pencil to change to edit mode. Remove the words SELECT and type in EXEC REPORT_NAME (change the REPORT_NAME to the name you used in SQL). Then execute again and the results will be displayed in SAP Business One.
Let me know if you get stuck. Remember the above is an example and will need to be changed to use your tables and fields as required. The basic idea is to move across by one column with each select statement. So for example the first select statement does the CURRENT column, the second one the 30DAYS column, and so on.
Kind regards
Peter Juby -
Any Standard Aging report for MM
Hello All,
I am looking a standard aging report for Materials on my storage location.
We are following batch.
Please help
Regards
LalHi ,
I hope for your new requirement this might help you .
If you want to perform an analysis based on the key figure dead stock, proceed as follows:
From the Inventory Controlling menu, select Environment -> Document evaluations-> Dead stock.
1. The selection screen appears.
2. Specify the desired analysis criterion and selection parameters.
You can carry out the analysis for all plants, that is, for each material, data from all plants are grouped together or only for certain plants, that is, the analysis is created for every designated plant. Any period can be selected for the analysis. The system suggests 90 days as the period to analyze, the calculation starting from the current date.
The following functions can be used to process the material list.
Detailed Display
By using the function Detailed display, you can call up in a table or graph form detailed data for a material including the respective material document. You can analyze all material documents that are related to the evaluated stock of a material.
If you want to view detailed information for a certain material, proceed as follows:
Position the cursor on the desired material in the results list and select Edit ->Detailed display.
A dialog box appears in which you can choose either a graph or table display.
If you select the graphic, you can display the latest information on:
Cumulative receipts/issues
Warehouse issues
Warehouse receipts
Stock level
If you select the table, you can display the following information:
Stock movements
Cumulative stock movements
Current stock level
From the stock movement table you can drill down as far as the material document level to see detailed information. To display stock movements on a particular day, position the cursor on the relevant line and select the Choose function. A popup window appears which displays all the movements on the selected day. The individual movements for a selected date are displayed in a dialog box.
To display the document for a particular movement, position the cursor on the relevant line and select the Choose function. A popup window appears which displays the document.
Similarly you can try for the slow moving also .please let me know wether you were able to find what you were looking for .
source: SAP
cheers
KP -
Ar Aging Report based on transaction lines
Hi all,
I am trying to write a query to calculate aging report at line level. The user needs a query which calculates the aging value at at line level because the ra_customer_trx_lines_all has attribute1 populated with a value from (A,B,C,D).I need get the aging value for each group(attribute).
select sum(nvl(lines.line_recoverable,0)+nvl(adj.adj_amt,0)-nvl(rec.rec_amt,0)),lines.attribute1
from ra_customer_trx_lines_all lines,
(select CUSTOMER_TRX_LINE_ID trx_line,
sum(amount) adj_amt
from ar_adjustments_all
where status = 'A'
group by CUSTOMER_TRX_LINE_ID) adj
,(select REF_CUSTOMER_TRX_LINE_ID trx_line,
sum(nvl(amount_cr,0))-sum(nvl(amount_dr,0)) rec_amt
from ar_distributions_all
where source_table='RA'
and source_type='REC'
group by ref_customer_trx_line_id) rec
where lines.CUSTOMER_TRX_LINE_ID=adj.trx_line(+)
and lines.CUSTOMER_TRX_LINE_ID=rec.trx_line(+)
and lines.customer_trx_line_id in ('18293')
group by lines.attribute1
Also I dint yet add the as of date parameter.I suppose the tables have to change in that case.Can any one help me with that tooo.
The above query kinda generated the value I was looking for.But when I ran the query for just a few more lines included.The query took forever to run.
Can you please help me on this ASAP.
Thanks for all your tips in advance.
Mach
Edited by: krismach_85 on Oct 27, 2009 8:38 AMHi,
You can run the Transaction Register report for specific Transaction reason/ a range and see the related material transactions.
Karthik. -
How to prepare Aging report in another system
Hi,
I have seen aging report for customer in SAP B1, its okay but not serve my purpose. i want this report little difference.
i sent a link file for aging report like this way.
[Aging Report |
http://www.sendspace.com/file/v8jbt3]
if it is possible to make this report please help me about this.
Regards,
Mizan
Edited by: mizan700 on Dec 29, 2010 11:39 AMHi Mizan,
Try this as a command in Crystal Report:
SELECT T0.CardName,T0.DocNum,T0.DocDueDate, DateDiff(DD,T0.DocDueDate,getDate()) as Overdue, T0.DocTotal-T0.PaidToDate as 'Due Amount'
FROM dbo.OINV T0
where T0.DocStatus='O' AND DateDiff(DD,T0.DocDueDate,getDate())>0
UNION ALL
SELECT T0.CardName,Null,NULL, NULL, SUM(T0.DocTotal-T0.PaidToDate) as 'Due Amount'
FROM dbo.OINV T0
where T0.DocStatus='O' AND DateDiff(DD,T0.DocDueDate,getDate())>0
GROUP BY T0.CardName
Order By T0.CardName,T0.DocDueDate DESC
Rank can be by CR function.
Thanks,
Gordon -
Overdue amount in Customer Receivable Aging report
Hi all!
Got a question.
In customer receivable aging report SAP Business One displays the relevant open receivables in columns representing the specifications you made in the Interval field in the selection criteria window. But how does it counts them? I've tried to pick all total from invoices,where between doc date and aging date 30 days passed. But it displays incorrect values. Is there any specific query for that?
Please see screenshot attached for the values i need.Hi,
Try with below query.But your selection criteria for date should be week.
declare @Cust as nvarchar(20)
Declare @FromDate Datetime
Declare @ToDate Datetime
declare @Group as nvarchar(20)
set @cust = (select max(t0.cardcode) from OINV t0 where t0.cardcode = '[%0]')
Set @FromDate = (Select min(t0.Docdate) from dbo.OINV t0 where t0.Docdate >='[%1]')
Set @ToDate = (Select max(t0.Docdate) from dbo.OINV t0 where t0.Docdate <='[%2]')
set @group = (select max(t2.groupname) from OCRG t2 where t2.groupname = '[%3]')
SELECT [CustName] as CustName, [G] as CustGroup,[1] as W1, [2] as W2, [3] as W3, [4] as W4, [5] as W5, [6] as W6, [7] as W7, [8] as W8, [9] as W9, [10] as W10, [11] as W11, [12] as W12, [13] as W13, [14] as W14, [15] as W15, [16] as W16, [17] as W17, [18] as W18, [19] as W19, [20] as W20, [21] as W21, [22] as W22, [23] as W23, [24] as W24, [25] as W25, [26] as W26, [27] as W27, [28] as W28, [29] as W29, [30] as W30 , [31] as W31, [32] as W32, [33] as W33, [34] as W34, [35] as W35, [36] as W36, [37] as W37, [38] as W38, [39] as W39, [40] as W40, [41] as W41, [42] as W42, [43] as W43, [44] as W44, [45] as W45, [46] as W46, [47] asW47, [48] as W48, [49] as W49, [50] as W50, [51] as W51, [52] as W52
from
(SELECT T0.[CardName] as CustName, sum(T0.[DocTotal]) as Total, datepart(ww,T0.[DocDate]) as week, t2.groupname as G FROM OINV T0 left JOIN OCRD T1 ON T0.CardCode = T1.CardCode left JOIN OCRG T2 ON T1.GroupCode = T2.GroupCode WHERE year(T0.[DocDate]) = 2013 and T0.[CardCode] = @Cust and T0.[DocStatus] ='o' and T0.[DocDate] between @fromdate and @todate and t2.groupname = @group GROUP BY T0.[CardName],T0.[DocDate],t2.groupname
union all
(SELECT T0.[CardName] as CustName, -sum(T0.[DocTotal]) as Total, datepart(ww,T0.[DocDate]) as week,t2.groupname as G from ORIN T0 left JOIN OCRD T1 ON T0.CardCode = T1.CardCode left JOIN OCRG T2 ON T1.GroupCode = T2.GroupCode WHERE year(T0.[DocDate]) = 2013 and T0.[CardCode] = @Cust and T0.[DocStatus] ='o' and T0.[DocDate] between @fromdate and @todate and t2.groupname = @group GROUP BY T0.[CardName],T0.[DocDate],t2.groupname )) S
Pivot
(sum(S.total) For WEEK IN ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12], [13], [14],[15],[16],[17],[18],[19],[20],[21], [22], [23], [24], [25], [26], [27], [28],[29], [30], [31], [32],[33],[34],[35],[36],[37],[38],[39],[40], [41],[42],[43],[44],[45],[46],[47],[48],[49],[50],[51],[52])) P
Thanks & Regards,
Nagarajan
Maybe you are looking for
-
Safari has been crashing sometimes 20 times a day recently and I'm at a loss-.help!
This is the third time I have tried to post this because....Safari keeps crashing!!! Process: WebProcess [23501] Path: /System/Library/StagedFrameworks/Safari/WebKit2.framework/WebProcess.app/Conten ts/MacOS/WebProcess Identifier:
-
Inserting clip into sequence: aspect ratio adjustments
I just made this page Aspect Ratio Adjustments available to whoever is curious to know what is the rational behind the values of +Aspect Ratio+ and Scale evaluated by FCE whenever it inserts a clip into a sequence. This was inspired by Michael in his
-
Exclude freight from material price
Dear SAP gurus, I have requirement where there is a freight to be included in PO, however there is also a requirement that this freight should not be included as material price when we do GR. As far as I know if we have freight condition in PO, then
-
ProjectServer REST API to create Tasks and Resources
Hi I have managed to add a project using REST call https://<domain>.sharepoint.com/sites/pwa/_api/ProjectServer/Projects/Add However when I try to add Task or a Resource to the created project it gives me errors. Could you please let me know what I'
-
Question about missing tool panel
I accidently x'ed out the left tool panel, and I don't know how to restore it... I have closed and reopened. I even unistalled and reinstalled and still nothing. I am looking for a link around the corners to maybe bring it back but nothing.