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: 

function module FKK_CREATE_DOC_AND_CLEAR

Former Member
0 Kudos

I'm trying to use the function FKK_CREATE_DOC_AND_CLEAR, but it complains about an unblocked partner or account.

I don't kkonw how to block a partner (GPART) or account (VKONT).

I tried functions FKK_ENQ_INTERVAL_SET, ENQUEUE_EFKKCLEGP, ENQUEUE_EFKKCLEVK, DEQUEUE_EFKKCLEGP and DEQUEUE_EFKKCLEVK, but does not seem to work, or at least I don't know how tu use them.

the message is

Diagnosis

You tried to clear or change an open item for business partner 400000561

and contract account 100000320 in company code XXXX. This is only

permitted if business partner and contract account are locked for other

processing. The corresponding locks do not exist in the case in

question.

System Response

Error message. The posting or the document change is not executed.

Procedure

As this is a program error, you must cancel processing. In mass

processing, processing of the current transaction is automatically canceled.

help me

E.B.

13 REPLIES 13

Former Member
0 Kudos

What are you trying to do? Please do not use function modules that are closer to the database. You should always use function modules that are closer to the application so that all user exits and the application logic is executed including locking, validations etc. The closer you get to the database updates, the more assumptions system makes about the quality and integrity of the data.

0 Kudos

Hi Srinivas Adavi,

Can you detail about how to identify a function module whether it is closer to application layer or database layer...

Regards,

Konakanchi

Former Member
0 Kudos

Try using this BAPI "BAPI_CTRACCONTRACTACCOUNT_CLR"

wont get any errors.

Regards,

Prajakta

0 Kudos

HI

I am using this BAPI but I have a problem. I am following the note 603021.

Error is :

Balance in Document currency is not zero, posting not possible

can u help me?

another problem

in note 603021

there is

Set CLEARING_AMOUNT to AMOUNT

Set CLEARING_AMOUNT_LOC to AMOUNT_LOC_CURR

Set CLEARING_AMOUNT_PAR2 to AMOUNT_PAR2_CURR

Set CLEARING_AMOUNT_PAR3 to AMOUNT_PAR3_CURR

How should I set them?

can u help me???

thank you

0 Kudos

HI

I am using this BAPI but I have a problem. I am following the note 603021.

Error is :

Balance in Document currency is not zero, posting not possible

can u help me?

another problem

in note 603021

there is

Set CLEARING_AMOUNT to AMOUNT

Set CLEARING_AMOUNT_LOC to AMOUNT_LOC_CURR

Set CLEARING_AMOUNT_PAR2 to AMOUNT_PAR2_CURR

Set CLEARING_AMOUNT_PAR3 to AMOUNT_PAR3_CURR

How should I set them?

can u help me???

thank you

**************************************************************************************************

This is a test code to test the BAPI :

**************************************************************************************************

PARAMETERS: fikey LIKE bapidfkksumc-fikey OBLIGATORY,

bp LIKE bapifkkopselhead-buspartner OBLIGATORY,

ca LIKE bapifkkopselhead-cont_acct OBLIGATORY,

docu LIKE bapifkkopseltxt-from_value OBLIGATORY.

DATA: st_bapifkkopselhead LIKE bapifkkopselhead,

tb_bapifkkopselhead LIKE STANDARD TABLE OF bapifkkopselhead,

st_bapidfkkcl LIKE bapidfkkcl,

tb_bapidfkkcl LIKE STANDARD TABLE OF bapidfkkcl,

va_bapiflag LIKE bapiflag,

st_bapifkkopseltxt LIKE bapifkkopseltxt,

tb_bapifkkopseltxt LIKE STANDARD TABLE OF bapifkkopseltxt,

st_bapidfkkko LIKE bapidfkkko,

va_documentnumber LIKE bapidfkkko-doc_no,

st_return LIKE bapiret2.

st_bapifkkopselhead-selection_number = '0001'.

st_bapifkkopselhead-buspartner = bp.

st_bapifkkopselhead-cont_acct = ca.

APPEND st_bapifkkopselhead TO tb_bapifkkopselhead.

va_bapiflag = 'X'.

st_bapifkkopseltxt-selection_number = '0001'.

st_bapifkkopseltxt-field_name = 'DOC_NO'.

st_bapifkkopseltxt-from_value = docu.

APPEND st_bapifkkopseltxt TO tb_bapifkkopseltxt.

CALL FUNCTION 'BAPI_CTRACCONTRACTACCOUNT_GOI'

EXPORTING

  • CLEARINGCURRENCY =

  • CLEARINGCURRENCYISO =

clearingdate = sy-datum

enqueue = va_bapiflag

IMPORTING

return = st_return

TABLES

mainselections = tb_bapifkkopselhead

openitems = tb_bapidfkkcl

  • ITEMCURRENCIES =

valueselections = tb_bapifkkopseltxt

  • AMOUNTSELECTIONS =

  • CLEARINGRESTRICTIONS =

  • EXTENSIONOUT =

  • EXTENSIONIN =

.

BREAK-POINT.

WRITE / st_return-message.

LOOP AT tb_bapidfkkcl INTO st_bapidfkkcl.

st_bapidfkkcl-item_activated = 'X'.

st_bapidfkkcl-clear_reas = '01'.

st_bapidfkkcl-clrg_curr = 'EUR'.

st_bapidfkkcl-clearing_amount = st_bapidfkkcl-amount.

st_bapidfkkcl-clearing_amount_loc = st_bapidfkkcl-amount_loc_curr.

st_bapidfkkcl-clearing_amount_par2 = st_bapidfkkcl-amount_par2_curr.

st_bapidfkkcl-clearing_amount_par3 = st_bapidfkkcl-amount_par3_curr.

MODIFY tb_bapidfkkcl FROM st_bapidfkkcl.

EXIT.

ENDLOOP.

CALL FUNCTION 'BAPI_CTRACRECKEY_EXISTCHECK'

EXPORTING

reconciliationkey = fikey

IMPORTING

return = st_return.

IF st_return-message IS INITIAL.

CALL FUNCTION 'BAPI_CTRACRECKEY_CREATE'

EXPORTING

newreconciliationkey = fikey

  • OBJECTCATEGORY = ' '

  • OBJECTKEY = ' '

  • IMPORTING

  • RECONCILIATIONKEY =

  • RETURN =

.

ENDIF.

COMMIT WORK AND WAIT.

st_bapidfkkko-fikey = fikey.

st_bapidfkkko-appl_area = 'T'.

st_bapidfkkko-doc_type = 'CR'.

st_bapidfkkko-doc_source_key = '05'.

st_bapidfkkko-currency = 'EUR'.

st_bapidfkkko-currency_iso = 'EUR'.

st_bapidfkkko-doc_date = '20091003'.

st_bapidfkkko-post_date = '20091003'.

CALL FUNCTION 'BAPI_CTRACCONTRACTACCOUNT_CLR'

EXPORTING

documentheader = st_bapidfkkko

IMPORTING

return = st_return

documentnumber = va_documentnumber

TABLES

openitems = tb_bapidfkkcl

  • EXTENSIONIN =

.

WRITE / st_return-message.

BREAK-POINT.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

  • IMPORTING

  • RETURN =

.

WRITE va_documentnumber.

0 Kudos

Can you please use the code tags above in your message window (icon with <\> signs) so that the code is readable?

0 Kudos
PARAMETERS: fikey LIKE bapidfkksumc-fikey OBLIGATORY,
            bp    LIKE bapifkkopselhead-buspartner OBLIGATORY,
            ca    LIKE bapifkkopselhead-cont_acct OBLIGATORY,
            docu  LIKE bapifkkopseltxt-from_value OBLIGATORY.

DATA: st_bapifkkopselhead LIKE bapifkkopselhead,
      tb_bapifkkopselhead LIKE STANDARD TABLE OF bapifkkopselhead,
      st_bapidfkkcl       LIKE bapidfkkcl,
      tb_bapidfkkcl       LIKE STANDARD TABLE OF bapidfkkcl,
      va_bapiflag         LIKE bapiflag,
      st_bapifkkopseltxt  LIKE bapifkkopseltxt,
      tb_bapifkkopseltxt  LIKE STANDARD TABLE OF bapifkkopseltxt,
      st_bapidfkkko       LIKE bapidfkkko,
      va_documentnumber   LIKE bapidfkkko-doc_no,
      st_return           LIKE bapiret2.


st_bapifkkopselhead-selection_number = '0001'.
st_bapifkkopselhead-buspartner       = bp.
st_bapifkkopselhead-cont_acct        = ca.

APPEND st_bapifkkopselhead TO tb_bapifkkopselhead.

va_bapiflag = 'X'.

st_bapifkkopseltxt-selection_number = '0001'.
st_bapifkkopseltxt-field_name       = 'DOC_NO'.
st_bapifkkopseltxt-from_value       = docu.

APPEND st_bapifkkopseltxt TO tb_bapifkkopseltxt.

CALL FUNCTION 'BAPI_CTRACCONTRACTACCOUNT_GOI'
 EXPORTING
*   CLEARINGCURRENCY           =
*   CLEARINGCURRENCYISO        =
   clearingdate               = sy-datum
   enqueue                    = va_bapiflag
 IMPORTING
   return                     = st_return
  TABLES
    mainselections             = tb_bapifkkopselhead
    openitems                  = tb_bapidfkkcl
*   ITEMCURRENCIES             =
   valueselections             = tb_bapifkkopseltxt
*   AMOUNTSELECTIONS           =
*   CLEARINGRESTRICTIONS       =
*   EXTENSIONOUT               =
*   EXTENSIONIN                =
          .

BREAK-POINT.
WRITE / st_return-message.

LOOP AT tb_bapidfkkcl INTO st_bapidfkkcl.

  st_bapidfkkcl-item_activated       = 'X'.
  st_bapidfkkcl-clear_reas           = '01'.
  st_bapidfkkcl-clrg_curr            = 'EUR'.
  st_bapidfkkcl-clearing_amount      = st_bapidfkkcl-amount.
  st_bapidfkkcl-clearing_amount_loc  = st_bapidfkkcl-amount_loc_curr.
  st_bapidfkkcl-clearing_amount_par2 = st_bapidfkkcl-amount_par2_curr.
  st_bapidfkkcl-clearing_amount_par3 = st_bapidfkkcl-amount_par3_curr.

  MODIFY tb_bapidfkkcl FROM st_bapidfkkcl.

  EXIT.

ENDLOOP.

CALL FUNCTION 'BAPI_CTRACRECKEY_EXISTCHECK'
  EXPORTING
    reconciliationkey = fikey
  IMPORTING
    return            = st_return.


IF st_return-message IS INITIAL.
  CALL FUNCTION 'BAPI_CTRACRECKEY_CREATE'
    EXPORTING
      newreconciliationkey       = fikey
*   OBJECTCATEGORY             = ' '
*   OBJECTKEY                  = ' '
* IMPORTING
*   RECONCILIATIONKEY          =
*   RETURN                     =
            .
ENDIF.

COMMIT WORK AND WAIT.

st_bapidfkkko-fikey           = fikey.
st_bapidfkkko-appl_area       = 'T'.
st_bapidfkkko-doc_type        = 'CR'.
st_bapidfkkko-doc_source_key  = '05'.
st_bapidfkkko-currency        = 'EUR'.
st_bapidfkkko-currency_iso    = 'EUR'.
st_bapidfkkko-doc_date        = '20091003'.
st_bapidfkkko-post_date       = '20091003'.

CALL FUNCTION 'BAPI_CTRACCONTRACTACCOUNT_CLR'
  EXPORTING
    documentheader       = st_bapidfkkko
 IMPORTING
   return               = st_return
   documentnumber       = va_documentnumber
  TABLES
    openitems            = tb_bapidfkkcl
*   EXTENSIONIN          =
          .

WRITE / st_return-message.
BREAK-POINT.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
*   WAIT          =
* IMPORTING
*   RETURN        =
          .

WRITE va_documentnumber.

0 Kudos

Dear Edo,

You have to pass items in the table ' tb_bapidfkkcl ; ( st_bapidfkkcl-amount ) those sum must be 0 .

like one amount is 500 then another amount must be -500.

first try with BP having two open items like this , it will work fine and then extend your code for futher selection

of items and checks on clearing

regards

Deepak

Former Member
0 Kudos

For FKK_CREATE_DOC_AND_CLEAR: We need to populate the save tables/structures/parameters those we have populated for u2018FKK_CREATE_DOCu2019. But along with the above fields we need to populate one more tables parameter u2018T_FKKCLu2019.

To populate this call the FM u2018FKK_OPEN_ITEM_SELECTu2019. This will populate the FKKCL internal table.

For FKK_CREATE_DOC: We need to populate the following tables/structures/parameters

u2022 I_FKKKO (Exporting)

u2022 I_FKKOPL_CF (Exporting - Value u2018Xu2019)

u2022 I_DIALOG (Exporting - Value u2018Xu2019)

u2022 T_FKKOP (Tables)

u2022 T_FKKOPK (Tables)

u2022 E_OPBEL (This is the importing/returning parameter)

In I_FKKKO populate the following fields:

u2022 FIKEY

u2022 APPLK

u2022 BLART

u2022 HERKF

u2022 WAERS

u2022 BLDAT

u2022 BUDAT

In I_FKKOP populate the following fields:

u2022 OPUPK

u2022 BUKRS

u2022 GPART

u2022 VTREF

u2022 VKONT

u2022 APPLK

u2022 BLART

u2022 HVORG

u2022 TVORG

u2022 FAEDN (Use FM u2018FKK_GET_DUE_DATEu2019 to determine Due Date)

u2022 KOFIZ

u2022 SPART

u2022 HKONT (Use FM u2018FKK_ACCOUNT_DETERMINEu2019 to determine G/L Acc)

u2022 MWSKZ

u2022 BLDAT

u2022 BUDAT

u2022 WAERS

u2022 BETRH

u2022 BETRW

Regards,

Siva Bontha

friedrich_keller
Contributor
0 Kudos

Hi,

The function module FKK_CREATE_DOC_AND_CLEAR is a function module that must be called in a certain context. Moreover, this function module is not released to be used by customers/project. Just check the 'released' flag on the general data sub screen of the attributes of a function module in order to identify the 'released'-status.

Konakanchi, you will need to talk to the SAP developer to find out whether a function module is closer to the app than to the db layer.

Prajakta's advice is correct: you should use a BAPI instead of using SAP internal function modules which can be changed without further notice (correction, support package etc.).

Edoardo, you may want to check-out the function module ISU_M_PAYMENT_CREATE to see how to wrap the function module FKK_CREATE_DOC_(MASS_)AND_CLEAR correctly. Please mind, that also the function module ISU_M_PAYMENT_CREATE is not released for an external usage ;o)

Kind regards,

Fritz

Former Member
0 Kudos

BAPI I have suggested should solve you problem

Avoid using FM which you have mentioned.

Regards,

Prajakta

Former Member
0 Kudos

i see in your code :

you have only document, you need add 1 other document.

example : you have 2 doc :

- first : document number 000000000001, amount 100

- second : document number 000000000002, amount -100

you should using call FM BAPI_CTRACCONTRACTACCOUNT_GOI1 second time. because function module BAPI_CTRACCONTRACTACCOUNT_GOI1 has a problem.

Edited by: Hoang Hung on Nov 26, 2009 7:54 AM

Former Member
0 Kudos

Hi,

While using FM FKK_CREATE_DOC_AND_CLEAR, you can lock using FM 'FKK_OPEN_ITEM_ENQUEUE' using tables parameter t_enqtab and unlock using FM 'FKK_OPEN_ITEM_DEQUEUE'.

You can find a sample code in standard SAP include program LFKK_SECF20.

Regards,

Mukul Sharma.