Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
Showing results for 
Search instead for 
Did you mean: 
Former Member

I have read many question from peoples about how to create many profitability Analysis Document which is reference to one G/L Account under one accounting document, as we know we can't create PA ( Profitability Analysis ) document on one G/L Account more than one PA Document using SAP Standard Transaction.

Solution for this problem can be solved using POSTING_INTERFACE_DOCUMENT  and  BAPI_COPAACTUALS_POSTCOSTDATA ( this moment i'm only discuss using this function and bapi ) the reason using POSTING_INTERFACE_DOCUMENT is about Tax Calculation and easy to use - SAP will calculate tax automatically. Let's started how to entry one COPA Data first.

1. Create One PA Document using POSTING_INTERFACE_DOCUMENT

Using FB01 , COPA entry is required to entry if G/L Account has been assignment to COPA Object .

Now the question is how to create program using POSTING_INTERFACE_DOCUMENT to posting PA Document ?? ( i suppose  you know to use POSTING_INTERFACE_DOCUMENT.



       i_function = 'C'.




       i_tcode  = 'FB01'


       e_subrc  = subrc

       e_msgid  = msgid

       e_msgty  = msgty

       e_msgno  = msgno

       e_msgv1  = msgv1

       e_msgv2  = msgv2

       e_msgv3  = msgv3

       e_msgv4  = msgv4


       t_ftpost = gi_ftpost

       t_fttax  = gi_fttax

       t_blntab = gi_xblntab.



1. Populating gi_ftpost with header data

Ex :

gi_ftpost-count = lv_line.

   gi_ftpost-stype = 'K'.

   gi_ftpost-fnam = 'BKPF-BUKRS'.

   gi_ftpost-fval = gi_header-bldat.

   APPEND gi_ftpost.   < ...... >>

2. Populating gi_ftpost with item data.


   gi_ftpost-stype = 'P'.

   gi_ftpost-fnam = 'RF05A-NEWBS'.

   gi_ftpost-fval = gi_input_summ-newbs.

   APPEND gi_ftpost.  < ........ >>

3. Populating gi_ftpost with COPA Data.

gi_ftpost-fnam = 'BSEG-RKE_BUKRS'.

       gi_ftpost-fval = gi_input-bukrs.

       APPEND gi_ftpost.  < ..... >>>

gi_ftpost-fnam = 'BSEG-RKE_ERLOS'.

       gi_ftpost-fval = gi_input-erlos.

       APPEND gi_ftpost.  < ..... >>>

Note : Company Code is mandatory entry in COPA,

Now take a look difference between BUKRS on item data and BUKRS on COPA Data, yes the answer is we must populate itab with pattern BSEG-RKE_<field ..> why ? the answer is located inside POSTING_INTERFACE_CODE in LFIPIF00 Include.

Ok discussing about create one COPA is finished, let's continue discussing about how to create many COPA Document reference to one G/L Account on accounting document.

1. After Accounting Document has been created using POSTING_INTERFACE_DOCUMENT. ( Read t_blntab = gi_xblntab to get generated accounting document ). then use BAPI_COPAACTUALS_POSTCOSTDATA our next step.

2. Suppose you know how to use this BAPI .

The most important step is you must fill these field ( note : you can entry other field as needed ) :

  • BUKRS   ( Company Code )
  • PRCTR   ( Profit Center )
  • KOKRS  ( Controlling Area )
  • BUDAT   ( Posting Date )
  • VRGAR  ( Record Type ) fill with B  ( Direct Posting from FI )
  • RBELN   ( Reference Accounting Document )  - entry this field with your accounting document . Note : COPA Data will display on FB03 -> Document Environment
  • KSTAR   ( Cost Element ) fill with G/L Account from FI ( FB01 )
  • RPOSN  ( Item number from reference document (CO-PA))  Get from FI ( Item Number G/L Account on KSTAR ).

<.... >>

gi_bapi_copa_data-record_id = lv_recordidc.

       gi_bapi_copa_data-fieldname = 'BUKRS'.

       gi_bapi_copa_data-value = gi_input-bukrs.             "'5010'.

       APPEND gi_bapi_copa_data.

gi_bapi_copa_data-record_id = lv_recordidc.

       gi_bapi_copa_data-fieldname = 'KSTAR'.

       gi_bapi_copa_data-value = gi_input-newko.

       APPEND gi_bapi_copa_data.  <......>>>

Now this is the result. :

Result : 1 GL Account 3100101001 have 4 COPA Data ( Profitability Analysis Document ).

Labels in this area