Normally, when we search about Dunning procedures we do get our solution in bits and pieces.
This document would provide a full solution if you want to code as well as configure your dunning procedure with smartforms.
What is Dunning?
Dunning is the process of methodically communicating with customers to ensure the collection of accounts receivable. Communications progress from gentle reminders to threatening letters and phone calls and more or less intimidating location visits as accounts become more overdue.
To automate the procedure for dunning we would need to find our BTE.
What is BTE?
For this the documents are readily available on SCN. Below is the link for the same: http://wiki.scn.sap.com/wiki/display/ABAP/BTE+-+Business+Transaction+Event
The most important step for us is to check if all the configurations are in place or not.
Step 1: Configuration of the process and the BTE.
T-code: BF44
Here we would provide our process which is indeed needed for our coding.
The product assignment should also be done here.
Step 2: Activating the customer product
Next is T-code: BF24where our product would have a text assigned and it should be activated (Activate Customer Product indicator).
Step 3: Configure the FM
T-code: FIBF
The FM here would be the one from which the standard code for smartform would be triggered.
In case of smartform you should put FM as : FI_PRINT_DUNNING_NOTICE_SMARTF
And in case you would want that to be a script the FM would be: FI_PRINT_DUNNING_NOTICE.
Under the SAP application you would be able to give the name of your BTE.
Step 4: Configure the Smartform created
This can be done using the below path in SPRO:
Financial Accounting -> Accounts Receivable and Accounts Payable -> Business Transactions -> Dunning -> Assign Dunning Forms.
Select your respective procedure. This would prompt you to provide for the company code, enter as required.
Below section is the one in which you would provide your smartform name:
Now your configuration is complete.
Technical side for the Dunning procedure.
Scenario: The case would be that at each Dunning level a mail format has to be send to the customer with an attachment. This should be automated for each dunning level.
Coding in BTE.
The first step for this would be to make a copy of the sample BTE already present.
1040 is the BTE in which the coding for mailing the customer should be done.
The event for sending mail and attachment is done from the event 1720, for which Sap has already provided the coding under FM ‘PRINT_DUNNING_NOTICE_SF’.
The below structures are readily available in the FM “SAMPLE_PROCESS_00001040”. And so they would be in your FM copied from the sample BTE.
Explanations for each structure in order to code.
I_MHNK: This would have all the data for dunning. The most important ones would be the dunning date(LAUFD), ID(LAUFI), Account type(KOART), Company code and customer.
I_T047E: This would be the structure from which the form name would be passed to the standard FM for customizing the Dunning.
Structures for sending mail and attachment parameter are below:
C_FINNA: Data for Transmission Medium for Correspondence.
All the parameter required to send a mail are passed in here.
Important fields of this structure:
1.Intad: This is the field in which you would be able to pass the email address.
In most of the cases we would require multiple email ids to be sent. This can be done using the below code:
IF lw_email IS NOT INITIAL. "customer
c_finaa-intad = lw_email.
ENDIF.
* sales representative
IF lsw_proceed2 = abap_true.
IF lw_email1 IS NOT INITIAL.
IF c_finaa-intad IS NOT INITIAL.
CONCATENATE c_finaa-intad lw_email1 INTO c_finaa-intad SEPARATED BY space.
ELSEIF c_finaa-intad IS INITIAL.
c_finaa-intad = lw_email1.
ENDIF.
ENDIF.
ENDIF.
* send to admin also
IF lsw_proceed1 = abap_true.
IF ls1_dunn_1040-email IS NOT INITIAL.
CONCATENATE c_finaa-intad ls1_dunn_1040-email INTO c_finaa-intad
SEPARATED BY space.
ENDIF.
ENDIF.
2. Namep: This field would be used to pass a text name( SO10 Text), which would be used to pass the mail body of the email.
In our BTE we should pass the name and the “READ_TEXT” would be automatically done by the code in SAP.
IF NOT lw_namep IS INITIAL.
c_finaa-namep = lw_namep .
c_finaa-mail_body_text = ls_dunn_text-namep.
ENDIF.
Also the field mail_body_text can be used for same purpose.
SAP standard would take this value in the changing parameter and do the below:
Always remember to create a SO10 text with “FIKO” as ID.
3. Mail_send_addr: This field is used to specify the sender of the mail.
4. Nacha: This field would be passed for Transmission Medium for Correspondence.
Values:
1 - Printout
2 – Fax
I - mail
C_ITCPO: SAPscript output interface
Fields:
1. TDTITLE: This field would be used for the subject of the email and the attached document name.
If we try to change the Document name and subject we would not be able to do that for below code.
2. All the spool/archive parameters can be set with this structure – TDCOPIES, TDDEST, TDPREVIEW, TDARMOD.
Coding in smartforms.
Although we can create a new smartform according to our requirement but in this case we must always remember to pass a parameter in the Import Tab: IS_SFPARAM. Else there would also be an error for “ Parameter missing”.
So even assigning a new smartform created by us in possible.
In case of dunning scenario we would want many dynamic data to be placed in our smartform.
For this we would have to fetch the data in our smartform itself.
This would be possible with the parameter IS_SFPARAM. The dunning date and id could be captured with help of the SFPARAM-CONTENT field, where we would need to get the data by using offsets.
This smartform would now be sent as the PDF attachment in the mail.