Business Scenario
As we know, the Cash journal is an online cash book in SAP system. It allows you to post cash documents viz. Receipts, Payments, etc. After the posting of that journal it calculates the balance of cash remaining on hand.
Business Requirement
The company has multiple project sites and each project site is having its own Petty cash box, where day to day cash transactions are being posted. The project sites are quite far from the HO. So they want to have a proactive measure in order to keep their cashbox full to meet their expenses. So the requirement are as follows:
- Minimum Balance for each cash journal (based on the project site)
- Alert to HO when it reaches the Minimum Balance
- Daily Cashbook report to HO
How We Implemented
1. Define the minimum balance in Cash Journal itself.
2. Function to get the Balance
3. Report Program and Put it background to send it as email.
1. Define the minimum balance in Cash Journal itself.
As such there is no place to define the minimum balance, we used the Cash journal table 'Additional Data' field as my minimum balance data.
Go To SPRO and
Financial Accounting (New) --> Bank Accounting --> Business Transactions --> Cash Journal --> Setup Cash Journal
There you will find a column called 'Additional Text'
2. Function to Get Balance
Use the following function to get the latest balance (as on date).
a) Get a table of all Cash journal defined.
SELECT a~comp_code a~cajo_number b~cajo_name a~text
FROM TCJ_C_JOURNALS as a INNER JOIN tcj_cj_names as b on a~comp_code = b~comp_code and a~cajo_number = b~cajo_number
INTO CORRESPONDING FIELDS OF TABLE it_output where a~comp_code = '1000' and b~langu = 'EN'.
b) Update in the internal table
Loot at it_output into wa_output.
wa_minbal = wa_output-text. "wa_output-text stores the minimum value you defined in cash journal (additional text).
CALL FUNCTION 'FCJ_GET_BALANCE'
EXPORTING
I_COMP_CODE = wa_output-comp_code
I_CAJO_NUMBER = wa_output-cajo_number
I_DATE = sy-datum
IMPORTING
E_BALANCE = wa_balance.
Update the internal table with actual balance (wa_balance) and minimum balance (wa_minbal).
Endloop.
3. Report program and Put it in a background to send it as mail.
Write the following logic in your report program. Define that program in SM36 in order to execute on a defined interval ( say daily ).
LOOP at it_output INTO wa_output.
wa_balance = 0.
wa_output-limit = wa_output-text.
CALL FUNCTION 'FCJ_GET_BALANCE'
EXPORTING
I_COMP_CODE = wa_output-comp_code
I_CAJO_NUMBER = wa_output-cajo_number
I_DATE = sy-datum
IMPORTING
E_BALANCE = wa_balance.
wa_output-balance = wa_balance.
if wa_output-balance <= wa_output-limit.
APPEND wa_output to it_output_final.
endif.
ENDLOOP.
Using the Mail function - 'SO_DOCUMENT_SEND_API1' send it to the defined recipients.