Calculate Dunning charges through BTE ‘00001071’ at the time of Dunning(Tcode-F150)

This is the scenario regarding calculate dunning charges and posting in customer line item. This calculates the charges of dunning on the basis of the dunning levels of the customers.

Following is the job log when we Dunn the customer through the transaction code F150.

Dun1.png

We can see the posted dunning charges for first level in FBL5N transaction code.

Dun2.png

This is implemented by using the BTE ‘00001071’. Following is the enhancement details.

Got o transaction code FIBF. Then Settings->Products->of a customer. Suppose we created product here as ZDUNN.

Dun3.png

Then Go to again settings->process modules->of a customer .And activate the BTE.

Create function module by coping ‘SAMPLE_PROCESS_00001071’ to Z_EVENT_001071

So assign the product ZDUNN to above created FM. This is shown as below:

Dun4.png   

Write the below code in function module Z_EVENT_001071

DATA : l_is_documentheader   TYPE bapiache09,                “Document Header
         l_is_customer        
TYPE bapiacar09,
         l_it_customer        
TYPE TABLE OF bapiacar09,  “account relievable
         l_is_currencyamount  
TYPE bapiaccr09,
         l_it_currencyamount  
TYPE TABLE OF bapiaccr09,  “Currency amount
         l_is_accountgl       
TYPE bapiacgl09,
         l_it_accountgl       
TYPE TABLE OF bapiacgl09,
         l_it_return          
TYPE TABLE OF bapiret2,  “Bapi return Messages

“Fixed G/L Account
    l_gl_account =
‘123456789’.

    “Conversion for the G/L account
   
CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT’
     
EXPORTING
       
input  = l_gl_account
     
IMPORTING
       
output = l_gl_account.

“Filling the structure of BAPI_ACC_DOCUMENT_POST
   
“Document header
    l_is_documentheader-bus_act    =
‘RFBU’.
    l_is_documentheader-username   = sy-uname.
    l_is_documentheader-header_txt =
‘Charges’.            
    l_is_documentheader-comp_code  = i_mhnk-bukrs.
    l_is_documentheader-doc_date   = i_mhnk-laufd.
    l_is_documentheader-pstng_date = i_mhnk-laufd.
    l_is_documentheader-doc_type   =
‘XY’.

    l_item_count             = l_item_count + 1.

    “Acount Recievable (Customer)
    l_is_customer-itemno_acc = l_item_count.
    l_is_customer-customer   = i_mhnk-kunnr.
    l_is_customer-comp_code  = i_mhnk-bukrs.
   
APPEND l_is_customer TO l_it_customer.

    “Currency Amount
    l_is_currencyamount-itemno_acc = l_item_count.
    l_is_currencyamount-
currency   = i_mhnk-waers.
    l_is_currencyamount-amt_doccur = c_mhngh.
   
APPEND l_is_currencyamount TO l_it_currencyamount.

    l_is_currencyamount-itemno_acc = l_item_count + 1.
    l_is_currencyamount-
currency   = i_mhnk-waers.
    l_is_currencyamount-amt_doccur = –
1 * c_mhngh.
   
APPEND l_is_currencyamount TO l_it_currencyamount.

    “GL Account
    l_is_accountgl-itemno_acc =  l_item_count +
1.
    l_is_accountgl-gl_account =  l_gl_account.
    l_is_accountgl-pstng_date = sy-datum.
   
APPEND l_is_accountgl TO l_it_accountgl.

    ” Document posting
   
CALL FUNCTION ‘BAPI_ACC_DOCUMENT_POST’
     
EXPORTING
        documentheader    = l_is_documentheader
     
TABLES
        accountgl         = l_it_accountgl
        accountreceivable = l_it_customer
        currencyamount    = l_it_currencyamount
       
return            = l_it_return.

DELETE ADJACENT DUPLICATES FROM l_it_return COMPARING type id number
                                                       message_v1 message_v2
                                                       message_v3 message_v4.


   
LOOP AT  l_it_return INTO l_is_return.
     
IF l_is_return-type EQ ‘S’.
       
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’
         
EXPORTING
           
wait = l_c_x.

      ELSEIF l_is_return-type EQ ‘E’ OR l_is_return-type EQ ‘A’.
       
CALL FUNCTION ‘BAPI_TRANSACTION_ROLLBACK’.
       
“MESSAGE ‘Error in posting the document’ TYPE ‘E’.
     
ENDIF.
   
ENDLOOP.

  ENDIF.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply