SAP for Utilities Discussions
Connect with fellow SAP users to share best practices, troubleshoot challenges, and collaborate on building a sustainable energy future. Join the discussion.
cancel
Showing results for 
Search instead for 
Did you mean: 

Custom FM for dunning activity

former_member190606
Participant
0 Kudos

Dear All,

I want to post a document in customer account after dunning activity. I am trying to do this through ABAP. What i did was that i made a copy of the standard dunning activity FM Z_ISU_DUNNING_EMPTY_ACTIVI_0350. In this FM i added my code which would post a simple document in a customer account.

When i test this function module using se37 the FM works perfectly well and posts a document. However when i put this FM for my dunning activity(Using SPRO>> Configure Dunning activities) and run the dunning proposal and activity, the document does not get posted. I dont know why. Can anyone please help. Would really appreciate

Here is how the code looks like after i added my code for posting a simple document

FUNCTION ZISU_DUNNING_EMPTY_ACTIVI_0350.

*"----


""Local Interface:

*" IMPORTING

*" VALUE(I_TFK047L) LIKE TFK047L STRUCTURE TFK047L

*" TABLES

*" T_FKKMAZE STRUCTURE FKKMAZE

*" T_FKKMAKT STRUCTURE FKKMAKT

*" T_FKKOP STRUCTURE FKKOP

*" T_FKKOPK STRUCTURE FKKOPK

*" T_FIMSG STRUCTURE FIMSG

*" CHANGING

*" VALUE(C_FKKMAKO) LIKE FKKMAKO STRUCTURE FKKMAKO

*" VALUE(C_FKKKO) LIKE FKKKO STRUCTURE FKKKO

*"----


  • only write success message into job log

DATA:

documentheader like bapidfkkko,

partnerpositions type standard table of bapidfkkop with header line,

genledgerpositions type standard table of bapidfkkopk with header line,

documentnumber like bapidfkkko-doc_no,

return type standard table of bapiret2 with header line.

documentheader-fikey = '100915-001'.

documentheader-appl_area = 'R'.

documentheader-doc_type = 'AB'.

documentheader-doc_source_key = '01'.

documentheader-currency = 'UNI'.

documentheader-doc_date = sy-datum.

documentheader-post_date = sy-datum.

partnerpositions-item = '0001'.

partnerpositions-comp_code = 'UNI'.

partnerpositions-buspartner = '0000014044'.

partnerpositions-cont_acct = '10000416133X'.

partnerpositions-main_trans = '6000'.

partnerpositions-sub_trans = 'AD01'.

partnerpositions-g_l_acct = '0000140000'.

partnerpositions-doc_date = sy-datum.

partnerpositions-post_date = sy-datum.

partnerpositions-net_date = sy-datum.

partnerpositions-currency = 'UNI'.

partnerpositions-amount = '99'.

APPEND partnerpositions.

genledgerpositions-item = '0001'.

genledgerpositions-comp_code = 'UNI'.

genledgerpositions-g_l_acct = '0000299000'.

genledgerpositions-amount = '-99'.

genledgerpositions-profit_ctr = 'IBC'.

APPEND genledgerpositions.

CALL FUNCTION 'BAPI_CTRACDOCUMENT_CREATE'

EXPORTING

testrun = ''

documentheader = documentheader

IMPORTING

documentnumber = documentnumber

return = return

TABLES

partnerpositions = partnerpositions

genledgerpositions = genledgerpositions.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

CALL FUNCTION 'FKK_DUNNING_MESSAGE_APPEND'

EXPORTING

MSGID = 'EK'

MSGNO = '345'

MSGPR = '2'

TABLES

T_FIMSG = T_FIMSG.

IF 1 = 0. MESSAGE S345(EK). ENDIF.

ENDFUNCTION.

6 REPLIES 6

Former Member
0 Kudos

Did you check the log after you ran dunning proposal and activity? What does your log say?

0 Kudos

The log displays the same message as the one it showed when i had not changed the code.

I also tried to do the same thing with the dunning activity that deactivates the installment plan. i made a copy of the function module ISU_DUNNING_DEACT_INSTPL_0350. In that new func module i copied my code that posts a simple document. then i assigned the new ZISU_DUNNING_DEACT_INSTPL_0350 activity to the dunning procedure in SPRO. I created an installment plan for a business partner and ran the dunning activity. The installment got de activated but no document was posted!

for your help i am providing the code of the ZISU_DUNNING_DEACT_INSTPL_0350

FUNCTION ZISU_DUNNING_DEACT_INSTPL_0350.

*"----

-


""Local Interface:

*" IMPORTING

*" VALUE(I_TFK047L) LIKE TFK047L STRUCTURE TFK047L

*" EXPORTING

*" VALUE(TEMP) TYPE OPTXT

*" TABLES

*" T_FKKMAZE STRUCTURE FKKMAZE

*" T_FKKMAKT STRUCTURE FKKMAKT

*" T_FKKOP STRUCTURE FKKOP

*" T_FKKOPK STRUCTURE FKKOPK

*" T_FIMSG STRUCTURE FIMSG

*" CHANGING

*" VALUE(C_FKKMAKO) LIKE FKKMAKO STRUCTURE FKKMAKO

*" VALUE(C_FKKKO) LIKE FKKKO STRUCTURE FKKKO

*"----

-


DATA: BEGIN OF T_OPBEL OCCURS 1,

OPBEL LIKE FKKOP-OPBEL,

END OF T_OPBEL.

DATA: H_ATEXT(100).

DATA: OPBEL_C(12).

DATA: H_UPDATE.

DATA: H_FKKMAHNV LIKE FKKMAHNV.

DATA: H_TFK033D LIKE TFK033D.

DATA: H_DEAGD LIKE RFKN1-DEAGD,

documentheader like bapidfkkko,

partnerpositions type standard table of bapidfkkop with header line,

genledgerpositions type standard table of bapidfkkopk with header line,

documentnumber like bapidfkkko-doc_no,

return type standard table of bapiret2 with header line.

documentheader-fikey = '100915-001'.

documentheader-appl_area = 'R'.

documentheader-doc_type = 'AB'.

documentheader-doc_source_key = '01'.

documentheader-currency = 'UNI'.

documentheader-doc_date = sy-datum.

documentheader-post_date = sy-datum.

partnerpositions-item = '0001'.

partnerpositions-comp_code = 'UNI'.

partnerpositions-buspartner = '0000014030'.

partnerpositions-cont_acct = '10000416119X'.

partnerpositions-main_trans = '6000'.

partnerpositions-sub_trans = 'AD01'.

partnerpositions-g_l_acct = '0000140000'.

partnerpositions-doc_date = sy-datum.

partnerpositions-post_date = sy-datum.

partnerpositions-net_date = sy-datum.

partnerpositions-currency = 'UNI'.

partnerpositions-amount = '66'.

APPEND partnerpositions.

genledgerpositions-item = '0001'.

genledgerpositions-comp_code = 'UNI'.

genledgerpositions-g_l_acct = '0000299000'.

genledgerpositions-amount = '-66'.

genledgerpositions-profit_ctr = 'IBC'.

APPEND genledgerpositions.

CALL FUNCTION 'BAPI_CTRACDOCUMENT_CREATE'

EXPORTING

testrun = ''

documentheader = documentheader

IMPORTING

documentnumber = documentnumber

return = return

TABLES

partnerpositions = partnerpositions

genledgerpositions = genledgerpositions.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

temp = return-message.

temp = documentnumber.

CALL FUNCTION 'ISU_DUNNING_DEACT_INSTPL_LOAN'

EXPORTING

I_LOAN = space

TABLES

T_FKKMAZE = T_FKKMAZE

T_FKKMAKT = T_FKKMAKT

T_FIMSG = T_FIMSG

CHANGING

C_FKKMAKO = C_FKKMAKO.

exit.

  • get update flag from global memory

  • Parameter, ob Testdruck vorgesehen ist, aus dem globalen Memory holen

CALL FUNCTION 'FKK_DUNNING_PARAMETER_GET'

IMPORTING

E_UPDATE = H_UPDATE

E_FKKMAHNV = H_FKKMAHNV.

  • new: reason for deactivation of installment plan in

  • business area 1102

CALL FUNCTION 'FKK_ACCOUNT_DETERMINE_1102'

EXPORTING

I_APPLK = H_FKKMAHNV-APPLK

IMPORTING

E_TFK033D = H_TFK033D

EXCEPTIONS

OTHERS = 3.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

H_DEAGD = H_TFK033D-FUN01.

  • inside the dunned items, look if there installments in the highest

  • dunning level

  • innerhalb der gemahnten Forderungen nach Raten suchen, die die

  • höchste Mahnstufe erreicht haben

LOOP AT T_FKKMAZE

WHERE STAKZ = 'R'

and xinfo = ' '.

  • AND MAHNS = C_FKKMAKO-MAHNS. "Note 182489

READ TABLE T_OPBEL WITH KEY OPBEL = T_FKKMAZE-OPBEL.

  • if the document number is new, go on

  • Nur weitermachen, wenn die Nummer noch nicht geprüft wurde

CHECK SY-SUBRC NE 0.

T_OPBEL-OPBEL = T_FKKMAZE-OPBEL.

APPEND T_OPBEL.

WRITE T_OPBEL-OPBEL TO OPBEL_C NO-ZERO.

  • deactivate installment plan only in update mode

  • Ratenplan nur im UPDATE-Modus deaktivieren

IF H_UPDATE = 'X'.

CALL FUNCTION 'FKK_S_INSTPLAN_DEACTIVATE'

EXPORTING

I_OPBEL = T_OPBEL-OPBEL

I_DEAGD = H_DEAGD

I_DEADT = sy-datum

EXCEPTIONS

OTHERS = 1.

else.

clear sy-subrc.

ENDIF.

IF SY-SUBRC = 0.

  • success message in job log

  • Nachricht, daß Ratenplan deaktiviert wurde, ins Protokoll :News that installment plan has been disabled, the log

CALL FUNCTION 'FKK_DUNNING_MESSAGE_APPEND'

EXPORTING

MSGID = 'EK'

MSGNO = '304'

MSGV1 = OPBEL_C

MSGPR = '2'

TABLES

T_FIMSG = t_fimsg.

IF 1 = 0. MESSAGE S304(EK) with OPBEL_C. ENDIF.

  • Create an entry in dunning history for deactivating an installmt plan

  • Für das Deaktivieren des Ratenplans wird noch eine Mahnaktivität

  • definiert.

CLEAR T_FKKMAKT.

MOVE-CORRESPONDING C_FKKMAKO TO T_FKKMAKT.

H_ATEXT = 'Ratenplan & wurde deaktiviert'(001).

REPLACE '&' WITH OPBEL_C INTO H_ATEXT.

CONDENSE H_ATEXT.

T_FKKMAKT-ATEXT = H_ATEXT.

  • concatenate 'Ratenplan'(001)

  • t_opbel-opbel

  • 'wurde deaktiviert'(002)

  • into t_fkkmakt-atext separated by space.

APPEND T_FKKMAKT.

ELSE.

  • Write error in job log

  • Fehlermeldung aus dem Funktionsbaustein wird in Tabelle geschrieben,

  • sie kommt dann nach der Abbruch-Meldung ins Protokoll.

CALL FUNCTION 'FKK_DUNNING_SYST_MESSAGE_APP'

TABLES

T_FIMSG = T_FIMSG.

  • error message in case of error

  • Dann wird die Abbruchmeldung direkt ausgegeben

MESSAGE E305(EK) WITH OPBEL_C.

ENDIF.

ENDLOOP.

ENDFUNCTION.

0 Kudos

Have you debugged your function? The log wont say anything since you are not writing anything to it based on your document call.

You should also test the bapi with the exact parameters you are using - it is possible that your values are not correct, but there is no way for any of us to know that here, as it would be totally based on your system design.

After testing the bapi or debugging - you should get more info about the error - and then someone here can assist.

regards,

bill.

0 Kudos

Dear Experts,

Debugging reveals that the Create document BAPI is returning the error 'Formal Error:Invalid calling sequence for the function modules'

As far as the parameters are concerned, i have hardcoded them so there shouldnt be any problems with parameters. Plus the FM is working fine in the function builder test(se37)

The error occurs only once i execute dunning and the custom FM is called. can you kindly help

0 Kudos

Dear Experts,

The error id is 174. 'Formal Error : Invalid calling sequence for functional module'

I dont think there is a problem with the parameters i am giving because when i test this FM with the same parameters in se37 it is working perfectly fine. The code works well in a program. The problem only occurs when i run it in an FM. Has anyone encountered this before?

Can someone kindly give a sample snippet of the code they have used to post a document through BAPI_CTRACTDOC_CREATE ?

Would really appreciate any help.

Thanks!

0 Kudos

Hi Adil,

Please try to develop workflow instead of using user exit. Looks like some of the Document master data getting locked when your function module is getting called.

Regards

Avinash