FD10N Debit/Credit/Balance Values
Hi all,
Thanks in advance for your time/assistance.
I am trying to get the total DEBIT/CREDIT/BALANCE values that appear in Transaction FD10N (Account Balance).
I can not see them anywhere in any tables (where used).
Any ideas as to how I can get hold of these values.
Thanks.
Bushwick
Well.. I decided to reply to my own post!!
Calculate the values from BSID etc
*---------------------------------------------------------------------*
* FORM GET_FD10N_INFORMATION *
*---------------------------------------------------------------------*
form GET_FD10N_INFORMATION tables in_tab structure itcsy
out_tab structure itcsy .
clear: in_tab, out_tab.
Data: fd10customer like vbak-kunnr, "Customer no.
ncustomer(10) type n, "Numeric customer no.
fiscalyear like bsad-GJAHR, "Fiscal Year
ccode like knc3-BUKRS, "Company Code
h_BSID like BSID-DMBTR,
s_BSID like BSID-DMBTR,
bsidsum1 like bsid-DMBTR,
bsidsum3 like bsid-DMBTR,
bsidsum2 like bsid-DMBTR,
bsadsum1 like bsad-DMBTR,
bsadsum2 like bsad-DMBTR,
Creditchar(13), "Char Value
Debitchar(13), "Char Value
Balancechar(13). "Char Value
* Get customer by layout set
read table in_tab with key 'VBDKA-KUNNR'.
if sy-subrc = 0.
fd10customer = in_tab-value.
* If customer Contains ONLY 0-9 characters, then zero fill
if fd10customer co '0123456789 '.
ncustomer = fd10customer.
fd10customer = ncustomer.
endif.
endif.
* First we set the Fiscal Year. This is the same YEAR as the SYSTEM YEAR
fiscalyear = SY-DATUM(4).
* Select from BSID - to get the final balance
* Credit
Select sum( DMBTR ) into bsidsum1
from bsid
where BUKRS = '1020'
and KUNNR = fd10customer
and GJAHR = fiscalyear
and SHKZG = 'H'.
* Debit
Select sum( DMBTR ) into bsidsum2
from bsid
where BUKRS = '1020'
and KUNNR = fd10customer
and GJAHR = fiscalyear
and SHKZG = 'S'.
* Balance
bsidsum3 = bsidsum2 - bsidsum1.
** Also need to add the BSID value
* bsadsum2 = bsadsum2 + bsidsum2.
Move bsidsum3 to Creditchar.
Move bsidsum3 to Balancechar.
* Bespoke Rules
* If the balance is +ve then display the value in the Balance Due box
* If the balance is -ve then display the value in the Credit box
if Creditchar CS '-'.
Balancechar = ' '.
ELSE.
Creditchar = ' '.
ENDIf.
* Output back to SapScript (Credit)
if sy-subrc = 0.
read table out_tab with key 'CREDIT'.
if sy-subrc = 0.
write Creditchar to out_tab-value.
modify out_tab index sy-tabix.
endif.
endif.
* Output back to SapScript (Debit)
if sy-subrc = 0.
read table out_tab with key 'DEBIT'.
if sy-subrc = 0.
write Debitchar to out_tab-value.
modify out_tab index sy-tabix.
endif.
endif.
* Output back to SapScript (Balance)
IF sy-subrc = 0.
READ TABLE out_tab WITH KEY 'BALANCE'.
IF sy-subrc = 0.
write Balancechar to out_tab-value.
MODIFY out_tab INDEX sy-tabix.
ENDIF.
ENDIF.
endform. "GET_FD10N_INFORMATION
If I were you I would use data from Table KNC1
KRK