Example program - posting accounting document,  Idoc ( ACC_DOCUMENT )

Hi fellows developers,
here is an example of  usage of the IDOC, directly in program for an accounting document
(ALE message type ACC_DOCUMENT, bapi BAPI_ACC_DOCUMENT_POST )).
It was inspired  by the lack of a flexible usage of this IDOC in LSMW
(f.e. booking of Gl and Vendor from the same file).
Both cases inbound and outbound are covered, although the outbound idoc was delivered in state
for furthere dispatching and was further not tested.
You can adapt this example to any idoc type (bapi type) and load data from anywhere ( file, table, etc.).
If you have question please ask.
On my system works !!!:)))
I hope it will help you in your daily work.
Regards,
Miroslaw
*& Report  Z_MKPR87
*& Version 1.0 - creates idoc for accounting document with status
*&  64 - inbound and 30 - outbound.
*& Then you need to execute program RBDAPP01 for this message type (inbound),
*& for outbound further dispatching with appropriate tool is required (not tested here).
*& For inbound, complete booking of document was tested. For outbound
*& only to the stage 30 - 'Idoc ready for dispatch'.
*& Program does not require any additional DDIC objects.
*& The solution gives you possibility for example to book document G/L + Vendor items,
*& strictly speaking the whole power of this bapi in IDOC can be used. Unfortunately
*& in LSMW its not the case.:)
*& Data for idoc is takken from internal table, but can be loaded from anywhere.
REPORT  Z_MKPR87.
INCLUDE Z_MKPPR87_TOP.
INCLUDE Z_MKPPR87_SEL.
INCLUDE Z_MKPPR87_EVN.
INCLUDE Z_MKPPR87_IDOC.
*&  Include           Z_MKPPR87_TOP
CONSTANTS:
input structure for idoc ***
Achtung! don't use BAPI input structures
they are similar but not flat ( the casting cannot occure, since idoc
needs flat data - see 'sdata' field in edidd )
gc_idoc_structure1(27) TYPE c VALUE 'E1BPACHE09',
gc_idoc_structure2(27) TYPE c VALUE 'E1BPACGL09',
gc_idoc_structure3(27) TYPE c VALUE 'E1BPACCR09'.
Structrures for IDOC : ALE message type - ACC_DOCUMENT
                     BAPI - BAPI_ACC_DOCUMENT_POST
NOTE!  The E1BPXXXXXX structures are flat (char type), opposite to
BAPI structures (BAPIACHE09. etc. )
DATA:      gs_DOCUMENTHEADER  TYPE E1BPACHE09,
                gt_ACCOUNTGL  TYPE TABLE OF E1BPACGL09,
           gt_CURRENCYAMOUNT  TYPE TABLE OF E1BPACCR09,
            gt_idoc_str_names TYPE TABLE OF char15,
                 gs_edidc     LIKE edidc,
           gt_idoc_data TYPE  TABLE OF       edidd,
           gt_comm_idoc_control TYPE TABLE OF edidc.
*&  Include           Z_MKPPR87_SEL
SELECTION-SCREEN BEGIN OF BLOCK bk2 WITH FRAME TITLE text-002.
PARAMETERS:
          p_itype TYPE char15 DEFAULT 'ACC_DOCUMENT03',
*'CREMAS04',
          p_mtype TYPE EDIDC-mestyp  DEFAULT 'ACC_DOCUMENT',
          p_rport TYPE EDIDC-rcvpor DEFAULT 'LSMW',
          p_rtype TYPE EDIDC-rcvprt DEFAULT 'US',
          p_rname TYPE EDIDC-rcvprn  DEFAULT 'Z_MKARAS',
          p_inbd    TYPE c DEFAULT 'X'.  " C - inbound (2), space - outbound (1)
SELECTION-SCREEN END OF BLOCK bk2.
*&  Include           Z_MKPPR87_EVN
INITIALIZATION.
PERFORM initialize_idoc_const.
START-OF-SELECTION.
PERFORM create_idoc.
*&  Include           Z_MKPPR87_IDOC
*&      Form  create_idoc
      text
FORM create_idoc.
  PERFORM set_bussines_data
              USING
                 gs_documentheader
                 gt_accountgl
                 gt_currencyamount.
  PERFORM build_idoc_from_bus_dat
              USING
                 gs_documentheader
                 gt_accountgl
                 gt_currencyamount
              CHANGING
                 gt_idoc_data.
CASE p_inbd.
WHEN 'X'.
   PERFORM create_inbound_idoc.
WHEN space.
   PERFORM create_outbound_idoc.
ENDCASE.
ENDFORM.                    "create_idoc
*&      Form  create_inbound_idoc
      text
FORM create_inbound_idoc.
  PERFORM set_idoc_control_inbound CHANGING gs_edidc.
  CALL FUNCTION 'IDOC_WRITE_AND_START_INBOUND'
    EXPORTING
      i_edidc = gs_edidc
    TABLES
      i_edidd = gt_idoc_data.
  IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
   MESSAGE 'Inbound idoc(s) created, check in TAC WE02' TYPE 'I'.
  ENDIF.
ENDFORM.                    "create_inbound_idoc
*&      Form  create_outbound_idoc
      text
FORM create_outbound_idoc.
  PERFORM set_idoc_control_outbound   CHANGING   gs_edidc.
  CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
    EXPORTING
      master_idoc_control        = gs_edidc
    TABLES
      communication_idoc_control = gt_comm_idoc_control
      master_idoc_data           = gt_idoc_data.
  IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ELSE.
   MESSAGE 'Outbound idoc(s) created, check in TAC WE02' TYPE 'I'.
  ENDIF.
ENDFORM.                    "create_outbound_idoc
*&      Form  set_idoc_control_inbound
      text
     -->CT_EDIDC   text
FORM set_idoc_control_inbound CHANGING cs_edidc LIKE gs_edidc.
  DATA: ls_edidc TYPE  edidc.
  cs_edidc-direct = '2'.
  cs_edidc-idoctp = p_itype.
  cs_edidc-mestyp = p_mtype.
  cs_edidc-rcvpor = 'SAPECI'.
  cs_edidc-rcvprt = p_rtype.
  cs_edidc-rcvprn = p_rname.
  cs_edidc-sndpor = p_rport.
  cs_edidc-sndprt = p_rtype.
  cs_edidc-sndprn = p_rname.
  cs_edidc-credat = sy-datum.
  cs_edidc-cretim = sy-uzeit.
ENDFORM.                    "set_idoc_control
*&      Form  set_idoc_control_outbound
      text
     -->CS_EDIDC   text
FORM set_idoc_control_outbound CHANGING cs_edidc LIKE gs_edidc.
  DATA: ls_edidc TYPE  edidc.
  cs_edidc-direct = '1'.
  cs_edidc-idoctp = p_itype.
  cs_edidc-mestyp = p_mtype.
  cs_edidc-rcvpor = p_rport.
  cs_edidc-rcvprt = p_rtype.
  cs_edidc-rcvprn = p_rname.
  cs_edidc-sndpor = 'SAPECI'.
  cs_edidc-sndprt = p_rtype.
  cs_edidc-sndprn = p_rname.
  cs_edidc-credat = sy-datum.
  cs_edidc-cretim = sy-uzeit.
ENDFORM.                    "set_idoc_control_outbound
*&      Form  set_bussines_data
      text
     -->CS_DOCUMENTHEADER  text
     -->CT_ACCOUNTGL       text
     -->CT_CURRENCYAMOUNT  text
FORM set_bussines_data USING cs_documentheader LIKE gs_documentheader
                             ct_accountgl      LIKE gt_accountgl
                             ct_currencyamount LIKE gt_currencyamount.
                        CHANGING ct_idoc_data LIKE edidd.
  DATA:
         ls_documentheader TYPE e1bpache09,
         ls_accountgl      LIKE LINE OF  gt_accountgl,
         ls_currencyamount LIKE LINE OF gt_currencyamount.
HEADER **
  cs_documentheader-bus_act =  'RFBU'.
  cs_documentheader-username = 'RNOWAK'.
  cs_documentheader-comp_code = '1000'.
  cs_documentheader-doc_date = '20071205'.
  cs_documentheader-pstng_date = '20071205'.
  cs_documentheader-fisc_year =  '2007'.
  cs_documentheader-fis_period = '12'.
  cs_documentheader-doc_type = 'JE'.
POSITIONS ***
111111111 ****
  ls_accountgl-itemno_acc = '0000000001'.
  ls_accountgl-gl_account = '0000473110'.
  ls_accountgl-item_text = 'MIK test dokumentu GL z programu IUE'.
  ls_accountgl-comp_code = '1000'.
  ls_accountgl-tax_code = '0I'.
  ls_accountgl-costcenter = '0000001000'.
  ls_currencyamount-itemno_acc = '0000000001'.
  ls_currencyamount-currency = 'PLN'.
  ls_currencyamount-amt_doccur = '496'.
  APPEND ls_accountgl TO ct_accountgl.
  APPEND ls_currencyamount TO ct_currencyamount.
2222222222 ****
  ls_accountgl-itemno_acc = '0000000002'.
  ls_accountgl-gl_account = '0000113302'.
  ls_accountgl-item_text = 'MIK test dokumentu GL z programu IUE'.
  ls_accountgl-comp_code = '1000'.
  ls_accountgl-tax_code = ''.
  ls_accountgl-costcenter = ''.
  ls_currencyamount-itemno_acc = '0000000002'.
  ls_currencyamount-currency = 'PLN'.
  ls_currencyamount-amt_doccur = '-496'.
  APPEND ls_accountgl TO ct_accountgl.
  APPEND ls_currencyamount TO ct_currencyamount.
ENDFORM.                    "set_bussines_data
*&      Form  build_idoc_from_bus_dat
      text
     -->IS_DOCUMENTHEADER  text
     -->IT_ACCOUNTGL       text
     -->IT_CURRENCYAMOUNT  text
     -->CT_IDOC_DATA       text
FORM build_idoc_from_bus_dat USING is_documentheader LIKE gs_documentheader
                                        it_accountgl LIKE gt_accountgl
                                   it_currencyamount LIKE gt_currencyamount
                               CHANGING ct_idoc_data LIKE gt_idoc_data.
  DATA:
  ls_documentheader LIKE is_documentheader,
  ls_accountgl     LIKE LINE OF it_accountgl ,
  ls_currencyamount LIKE LINE OF  it_currencyamount,
  ls_idoc_data LIKE LINE OF ct_idoc_data.
Document header *****
  ls_documentheader = is_documentheader.
  ls_idoc_data-segnam = gc_idoc_structure1.
  ls_idoc_data-sdata = ls_documentheader.
  APPEND ls_idoc_data TO ct_idoc_data.
Positions G/L part ************
  LOOP AT it_accountgl INTO ls_accountgl.
    ls_idoc_data-segnam = gc_idoc_structure2.
    ls_idoc_data-sdata = ls_accountgl.
    APPEND ls_idoc_data TO ct_idoc_data.
  ENDLOOP.
Currency Items part ******
  LOOP AT  it_currencyamount INTO  ls_currencyamount.
    ls_idoc_data-segnam = gc_idoc_structure3.
    ls_idoc_data-sdata = ls_currencyamount.
    APPEND ls_idoc_data TO ct_idoc_data.
  ENDLOOP.
ENDFORM.                    "build_idoc_from_bus_dat
*&      Form  initialize_idoc_const
      text
FORM initialize_idoc_const.
  APPEND gc_idoc_structure1 TO gt_idoc_str_names.
  APPEND gc_idoc_structure2 TO gt_idoc_str_names.
  APPEND gc_idoc_structure3 TO gt_idoc_str_names.
ENDFORM.                    "initialize_idoc_const

I summarized postings and posted again into the same system.  Yes, you can save an IDOC in your own system...There's an IDOC FM that will do just that...  In my case, I did:
after receipt of IDOC and posting,
process the idoc tables, rebuilding the input into tables.
Summarize the tables, as needed.
Create a new IDOC with a specific function code.
Save the IDOC in my own system, using IDOC_INBOUND_ASYNCHRONOUS, as I recall.
I had a custom process code that fired off the standard FM to process the JE posting.  I don't remember all the variables, but I have this stored as my example:
DATA : p_sndprn TYPE edi_sndpn3.
* Control Record Build.
  CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
    IMPORTING
      own_logical_system = p_sndprn
    EXCEPTIONS
      OTHERS             = 0.
  iedidc-direct   =  '2'.
  iedidc-idoctyp  =  'FIDCCP02'.
  iedidc-mestyp   =  'FIDCC2'.
  iedidc-mesfct   =  'ACC'.  <customer made up....used to control which process codes fire off when for standard message.
  iedidc-sndprt   =  'LS'.
  iedidc-sndprn   =   p_sndprn.
  iedidc-rcvprn   =   wa-rcvprn.
  iedidc-rcvprt   =  'LS'.
  iedidc-sndpor   =  'SAP_EDI_SC'.
  iedidc-credat   =  sy-datum.
  iedidc-cretim   =  sy-uzeit.
  APPEND iedidc.
* IDOC store routine...must commit work
* to get IDOC transferred to the IDOC processor.
  CALL FUNCTION 'IDOC_INBOUND_ASYNCHRONOUS'
    TABLES
      idoc_control_rec_40 = iedidc
      idoc_data_rec_40    = iedidd.
ENDFORM.                    " send_idoc
Edited by: DaveL on Oct 25, 2011 8:15 PM

Similar Messages

  • Not able to post accounting document from CRM to ECC.

    I am tring to post accounting document through BDOC but it is not posting . Can any one have idea how we can post accounting document to ECC from CRM with out use of Bdoc .  Thanks

    Hi,
    Check if any of the condition types which has the account is having a tax code.. That tax code shouldn't have defined as EC tax code.
    When you double click on the line item condition type which will be posted to accounts, you could see the G/L account and tax code. Ask you FI consultant to check how that tax code has been defined.
    Btw, it is always good if you open a new thread.. But you can refer the old thread inside your post.
    Regards, Sai Krishna.

  • Posting accounting documents into G/L accounts

    HI friends,
    what are the tables involved in posting accounting documents in G/L accounts.
    Please let me know.
    Thanks in advance.
    Roberts.K

    <b>Do check this out</b>
    http://www.erpgenie.com/abap/tables_fi.htm

  • Posting accounting documents in G/L accounts.

    HI friends,
    what are the tables involved in posting accounting documents in G/L accounts.
    Please let me know.
    Thanks in advance.
    Roberts.K

    Hi Roberts,
    BKPF and BSEG are your tables for the accounting documents.
    Regards,
    Srinivas

  • BTE while posting accounting document through MIRO

    Hi All,
    I am doing MIRO posting with PO,while MIRO posting accounting document is getting created for it.  I need a BTE while posting accounting document through MIRO to trigger workflow(through event).
    For direct accounting document posting I found the BTE 1030 to trigger workflow.
    Thanks
    Sree

    Hello !
          The BTE required is "00001120     DOCUMENT POSTING:  Field substitution header/items".
          Double click on this entry at FIBF transaction and you will find the function module SAMPLE_PROCESS_00001120
          Take a copy of this function module and go ahead.It is not possible to change the tables T_BKPF and T_BSEG. So, use the tables T_BKPFSUB and T_BSEGSUB.
    Regards,
    S.Suresh

  • Profit center change in posted accounting document

    Hello,
    please, is it possible to change the profit center in already posted accounting document?
    We DTO'd open customer balance with wrong profit center. PC document has been created as well. Please, what is the proper way to change the PC?? Or how to proceed?
    Thanks a lot
    Kind regards
    Marcela

    It is not possible to change profit center, for that matter any other CO assignment cannot be changed. You can try transfering to correct profit center through 9ke0

  • After post accounting document user cannot change Reference Field

    Hi,
    I have a issue. After post accounting document user cannot change Reference field value. Please suggest .     
    Thanks & Regards,
    Hemant Maurya

    Hi Hemanth,
    Mr. ajay's solution solve your issue.
    If you activate it will applicable to entaire client (it is not comp code specific)
    For Activation USe T.Code: OB32 maintain Field (BKPF-XBLNR), Account Type & Transaction Type Blank
    Remove Field Can be change Check Box
    Regards
    Viswa

  • Validation of a reference field when posting accounting document using FB50

    Hi all,
    We hada requirement to restrict the users from entering japanese caharaceters in the reference field of a accounting document. The validation for this was done using the transaction OB28. when the user posts the accounting document using transaction FB01 or changes the accounting document using transaction FB02, the validation provided in OB28 does work(it throws an error restricting the user from entering japanese characters if he has done so). But whenthe user pots the accounting document using the transaction FB50, the same error message comes as information message although the coding is for giving an error message.
    This however does not happen when the user logs on in English. In English logon the error mesage does appear.
    When the user logs on in Japanese the message comes as an information message but at the same time does not allow posting of the document.
    Debugging this revealed that the OSS note 197329 has been applied to the standard SAP program SAPMF05A.
    Any pointers to how this can be rectifiied would be appreciated.
    Thanks in advance.

    I think it would be best if you opened an OSS message on this.
    Rob

  • Posted Accounting documents not showing line items

    Hi!
    I facing a problem that has been created during the posting of accounting documents.
    The Problem:
    A Number of  accounting documents were posted but there are no entries for them in BSIS, where as the header exists in BKPF and the detail exists in BSEG. So although it is showing the document as posted. It is not reporting it against the relevant G/L Account. Since cheques have already been issued against these documents, we are trying to avoid a reversal of these documents.
    Our Analysis of the problem
    We think that the problem has arose due to an error in the master data of G/L Account.
    Some new G/L Accounts were created and the person creating it forgot to check the 'Line Item Display' Check in fs00->Control Data Tab.
    New Documents were meanwhile created with line items using these G/L Accounts and were then posted.
    When the mistake was realized the 'Line item Display' was checked for these Accounts. This however occured after the documents were posted.

    Ashan,
    1) entries come only in BSIS/BSAS when Field "Indicator: Open Item Management" = X (SKB1-XOPVW)
    2) For line item display, the system stores an entry per line item in an index table which contains the link between line item and account.  
    -> I think you've to run a "correction-program" but
       plz only in agreement with SAP (OSS)
    Andreas

  • Error in Posting Accounting Document from invoice

    Hi,
    When i create invoice, the system gives error while creating accounting document as,
    "Tax code Y1 does not appear in any G/L account item".
    In my pricing procedure. i have two tax condition types. MWST and ZSED (copy of mwst). when i delete ZSED from my pricing procedure and then i create a sales order/delivery & finally invoice...then it works fine (Accuonting document is created successfully).
    i have assigned the gl accounts in vkoa. and MWST & ZSED goes to same gl account via MWS accounting key.
    although i have searched the forum for this issue, but that didnt resolved my issue.
    seeking your guidance.

    Dear Robert,
    I'm having same issue as yours.
    The requirement for us is if return sales in some order reason codes, then tax should be posted to different G/L other than the G/L defined in OB40(transaction MWS).
    After several test, found the system only recognize the G/L in OB40, won't touch setting in VKOA. As if I delete the GL in table T030R, SAP will issue an error requesting GL assignment.
    Please let me know if you have solved your issue! If yes, please share your solution! 
    Thanks in advance!

  • Movement type 941 is not posting accounting document

    While postig post goods issue for replacement order no accounting document is being created, only PCA document is being created. Numbers are zero on PCAdocument, thats probably the reson whuy accounting document is not being generated. Is there any configuration that drives the passing of cost to FI?  I see that material is valued at 100 ncurrency units.

    Hello Pankaj,
    In OMJJ transaction, you can set customizing for movement type 941.
    If you want to create FI document when you post metarial document, you must set valuation update check in Account Grouping node on OMJJ customizing.
    Regards,
    Burak

  • T. Code to view Purchase Order and posted Accounting Document

    Hi,
    Is there any single SAP standard T.Code from which I can get  Accounting Document(posted) and its Purchase Order No.
    Dont sent any Table name plz.
    Regards,
    Vivek Kumar

    Run Standard Reports with Scope of List : ALLES
    ME2M  Material Wise report
    ME2N  PO Number wise Report
    ME2L  Vendor Wise report
    You can also Check MB51 / MR51 Reports.
    Regards,
    Ashok

  • Posting Account document

    Hi Friends,
                 Inside a user-exit I have to create a document.First of all is it possible to post document inside an exit ? If possible then here is my requirement.
    A document with the following debit/credit details has to be created in BSEG or BSIS.
    H(Cr) 101002(G/l acc) 20141434(Doc number) 20(Amt/dmbtr)
    S(Dr) 822001(G/l)     20141434(Doc No)     20(Amt/dmbtr)
    What function module should I use to create above document in BSEG or BSIS table ?
    I have tried with BAPI_ACC_DOCUMENT_POST and BAPI_ACC_DOCUMENT_POST. But of no use.
    Please advise me how to post this document inside the exit EXIT_RFEBBU10_001.
    thanks for any help.
    Vinod.

    Hi Ganesh,
                   Please find the following code which I used.
    Thanks
    Vinod.
    data: v_dmbtr like bsis-dmbtr,
          v_kfmod(10),
          v_amt like bsis-dmbtr,
          febep_amt like bsis-dmbtr,
          bseg_amt like bsis-dmbtr,
          ws_documentheader like bapiache09,
          it_accountgl like table of bapiacgl09 with header line,
          it_currencyamount like table of bapiaccr09 with header line,
          it_return like table of bapiret2 with header line,
          commit_ret like table of bapiret2 with header line,
          l_type like ws_documentheader-obj_type,
          l_key like ws_documentheader-obj_key,
          l_sys like ws_documentheader-obj_sys.
    if i_febep-vgint eq 'Y699'.
          unpack i_febep-kfmod to v_kfmod.
         select single dmbtr from bsis into v_dmbtr where
             bukrs eq i_febko-bukrs and hkont eq v_kfmod
                and belnr eq i_febep-zuonr.
         if sy-subrc eq 0.
            v_amt = abs( i_febep-kwbtr - v_dmbtr ).
              if i_febep-kwbtr > v_dmbtr.
                 febep_amt = -1 * v_amt.
                 bseg_amt = v_amt.
              elseif v_dmbtr > i_febep-kwbtr.
                 bseg_amt = -1 * v_amt.
                 febep_amt = v_amt.
              endif.
         endif.
         if v_amt ne space.
        posting code
        filling header
             clear ws_documentheader.
             ws_documentheader-bus_act = 'RFBU'.
             ws_documentheader-username = sy-uname.
             ws_documentheader-header_txt = 'BAPI Test'.
             ws_documentheader-comp_code = i_febko-bukrs.
             ws_documentheader-doc_date = sy-datum.
             ws_documentheader-pstng_date = sy-datum.
        ws_documentheader-fisc_year = '2006'.
             ws_documentheader-doc_type = 'ZB'.
            filling GL A/c
             clear it_accountgl.
             it_accountgl-itemno_acc = 1.
             it_accountgl-gl_account = '0000822000'.
             it_accountgl-doc_type = 'ZB'.
             it_accountgl-comp_code = i_febko-bukrs.
             it_accountgl-pstng_date = sy-datum.
             it_accountgl-value_date = sy-datum.
             append it_accountgl.
             clear it_accountgl.
             it_accountgl-itemno_acc = 2.
             it_accountgl-gl_account = v_kfmod.
            it_accountgl-gl_account = '0000101002'.
             it_accountgl-doc_type = 'ZB'.
             it_accountgl-comp_code = i_febko-bukrs.
             it_accountgl-pstng_date = sy-datum.
             it_accountgl-value_date = sy-datum.
             append it_accountgl.
            fillilng Currency amt
             clear it_currencyamount.
             it_currencyamount-itemno_acc = 1.
    *it_currencyamount-curr_type = '10'.
             it_currencyamount-currency = i_febep-kwaer.
             it_currencyamount-amt_doccur = febep_amt.
    it_currencyamount-amt_base = '0.0000'.
    it_currencyamount-disc_base = '0.0000'.
    it_currencyamount-disc_amt = '0.0000'.
             append it_currencyamount.
             clear it_currencyamount.
             it_currencyamount-itemno_acc = 2.
    *it_currencyamount-curr_type = '10'.
             it_currencyamount-currency = i_febep-kwaer.
             it_currencyamount-amt_doccur = bseg_amt.
    it_currencyamount-amt_base = '0.0000'.
    it_currencyamount-disc_base = '0.0000'.
    it_currencyamount-disc_amt = '0.0000'.
             append it_currencyamount.
    *calling bapi
         call function 'BAPI_ACC_DOCUMENT_POST'
            exporting
               documentheader = ws_documentheader
            importing
               obj_type = l_type
               obj_key = l_key
               obj_sys = l_sys
            tables
              accountgl = it_accountgl
              currencyamount = it_currencyamount
            return = it_return.
         read table it_return with key type = 'S'.
          if sy-subrc = 0.
            clear commit_ret.
            refresh commit_ret.
            call function 'BAPI_TRANSACTION_COMMIT'
              exporting
                wait = 'X'
              importing
              return = commit_ret.
           endif.
         endif.
    endif.

  • BAPI for posting accounting documents

    Hi,
    Can anyone please provide me with the BAPI to be used for GL postings with example.

    Hi,
    Use  the BAPI   BAPI_ACC_DOCUMENT_POST for posting Documents.
    Check the sample code related to posting.
    REPORT  acc_bapi_document                  .
    selection-screen begin of block bl01 .
    parameters:
      check_l             radiobutton group rb1,
      check_a default 'X' radiobutton group rb1,
      post                radiobutton group rb1.
    selection-screen uline.
    parameters:
      rev_c               radiobutton group rb1,
      rev_p               radiobutton group rb1.
    selection-screen uline.
    parameters:
      ref_key like bapiache01-obj_key default 'TEST000001BAPICALL',
      dest    like bdi_logsys-logsys  default '          '.
    selection-screen end   of block bl01 .
    data:
      gd_documentheader    like bapiache09,
      gd_customercpd       like bapiacpa09,
      gd_fica_hd           like bapiaccahd,
      it_accountreceivable like table of bapiacar09 with header line,
      it_accountgl         like table of bapiacgl09 with header line,
      it_accounttax        like table of bapiactx09 with header line,
      it_criteria          like table of bapiackec9 with header line,
      it_valuefield        like table of bapiackev9 with header line,
      it_currencyamount    like table of bapiaccr09 with header line,
      it_return            like table of bapiret2   with header line,
      it_receivers         like table of bdi_logsys with header line,
      it_fica_it           like table of bapiaccait with header line,
      it_accountpayable    like table of bapiacap09 with header line,
      it_paymentcard       like table of bapiacpc09 with header line,
      it_ext               like table of bapiacextc with header line.
    it_re                LIKE TABLE OF bapiacre09 WITH HEADER LINE,
    it_ext2              LIKE TABLE OF bapiparex  WITH HEADER LINE.
    perform fill_internal_tables.
    if check_l = 'X'.
      call function 'BAPI_ACC_DOCUMENT_CHECK'
           destination dest
           exporting
                documentheader    = gd_documentheader
                customercpd       = gd_customercpd
                contractheader    = gd_fica_hd
           tables
                accountgl         = it_accountgl
                accountreceivable = it_accountreceivable
                accountpayable    = it_accountpayable
                accounttax        = it_accounttax
               currencyamount    = it_currencyamount
                criteria          = it_criteria
                valuefield        = it_valuefield
                extension1        = it_ext
                return            = it_return
                paymentcard       = it_paymentcard
                contractitem      = it_fica_it.
               extension2        = it_ext2
               realestate        = it_re.
      write: / 'Result of check lines:'.                        "#EC NOTEXT
      perform show_messages.
    endif.
    if check_a = 'X'.
      call function 'BAPI_ACC_DOCUMENT_CHECK'
        destination dest
        exporting
          documentheader    = gd_documentheader
          customercpd       = gd_customercpd
          contractheader    = gd_fica_hd
        tables
          accountgl         = it_accountgl
          accountreceivable = it_accountreceivable
          accountpayable    = it_accountpayable
          accounttax        = it_accounttax
          currencyamount    = it_currencyamount
          criteria          = it_criteria
          valuefield        = it_valuefield
          extension1        = it_ext
          return            = it_return
          paymentcard       = it_paymentcard
          contractitem      = it_fica_it.
         extension2        = it_ext2
         realestate        = it_re.
      write: / 'Result of check all:'.                          "#EC NOTEXT
      perform show_messages.
    endif.
    if post = 'X'.
      data: l_type like gd_documentheader-obj_type,
            l_key  like gd_documentheader-obj_key,
            l_sys  like gd_documentheader-obj_sys.
      if dest = space or
         dest = gd_documentheader-obj_sys.
       post synchron
        call function 'BAPI_ACC_DOCUMENT_POST'
          exporting
            documentheader    = gd_documentheader
            customercpd       = gd_customercpd
            contractheader    = gd_fica_hd
          importing
            obj_type          = l_type
            obj_key           = l_key
            obj_sys           = l_sys
          tables
            accountgl         = it_accountgl
            accountreceivable = it_accountreceivable
            accountpayable    = it_accountpayable
            accounttax        = it_accounttax
            currencyamount    = it_currencyamount
            criteria          = it_criteria
            valuefield        = it_valuefield
            extension1        = it_ext
            return            = it_return
            paymentcard       = it_paymentcard
            contractitem      = it_fica_it.
           extension2        = it_ext2
           realestate        = it_re.
        write: / 'Result of post:'.                             "#EC NOTEXT
        perform show_messages.
      else.
      create Idoc
        it_receivers-logsys = dest.
        append it_receivers.
        call function 'ALE_ACC_DOCUMENT_POST'
          exporting
            documentheader    = gd_documentheader
            customercpd       = gd_customercpd
            contractheader    = gd_fica_hd
          tables
            accountgl         = it_accountgl
            accountreceivable = it_accountreceivable
            accountpayable    = it_accountpayable
            accounttax        = it_accounttax
            currencyamount    = it_currencyamount
            criteria          = it_criteria
            valuefield        = it_valuefield
            extension1        = it_ext
            paymentcard       = it_paymentcard
            contractitem      = it_fica_it
           extension2        = it_ext2
           realestate        = it_re
            receivers         = it_receivers
          COMMUNICATION_DOCUMENTS =
          APPLICATION_OBJECTS     =
          exceptions
            error_creating_idocs    = 1
            others                  = 2  .
        if sy-subrc = 0.
          write: / 'IDoc created'.                              "#EC NOTEXT
        else.
          write: sy-msgid.
        endif.
      endif.
    endif.
    if rev_p = 'X' or rev_c = 'X'.
      data: rev like bapiacrev,
            rev_key like ref_key.
      rev_key       = ref_key.
      rev_key(1)    = 'R'.
      rev-obj_type  = gd_documentheader-obj_type.
      rev-obj_key   = rev_key.
      rev-obj_sys   = gd_documentheader-obj_sys.
      rev-obj_key_r = ref_key.
      if rev_c is initial.
        if dest = space or
           dest = gd_documentheader-obj_sys.
          call function 'BAPI_ACC_DOCUMENT_REV_POST'
            exporting
              reversal = rev
              bus_act  = gd_documentheader-bus_act
            tables
              return   = it_return.
        else.
          it_receivers-logsys = dest.
          append it_receivers.
          call function 'ALE_ACC_DOCUMENT_REV_POST'
            exporting
              reversal                      = rev
              busact                        = gd_documentheader-bus_act
            OBJ_TYPE                      = 'BUS6035'
            SERIAL_ID                     = '0'
            tables
              receivers                     = it_receivers
            COMMUNICATION_DOCUMENTS       =
            APPLICATION_OBJECTS           =
            exceptions
              error_creating_idocs          = 1
              others                        = 2
          if sy-subrc  0.
            message id sy-msgid type sy-msgty number sy-msgno
                    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          else.
            write: / 'IDoc created'.                            "#EC NOTEXT
          endif.
        endif.
      else.
        call function 'BAPI_ACC_DOCUMENT_REV_CHECK'
          exporting
            reversal = rev
            bus_act  = gd_documentheader-bus_act
          tables
            return   = it_return.
      endif.
      write: / 'Result of Reversal Posting:'.                   "#EC NOTEXT
      perform show_messages.
    endif.
    commit work.
         Form  fill_internal_tables
    form fill_internal_tables.
      perform fill_header.
      perform fill_accountgl.
    perform fill_accountar.
      perform fill_accountap.
      perform fill_accounttax.
      perform fill_currencyamount.
    perform fill_criteria.
    perform fill_valuefield.
    perform fill_re.
    perform fill_cpd.
    perform fill_contractitem.
    perform fill_contractheader.
    perform fill_paymentcard.
    perform fill_extension.
    endform.                               " fill_internal_tables
         Form  Show_messages
    form show_messages.
      if it_return[] is initial.
        write: / 'no messages'.
      else.
        skip 1.
        loop at it_return.
          write: /    it_return-type,
                 (2)  it_return-id,
                      it_return-number,
                 (80) it_return-message,
                    IT_RETURN-LOG_NO
                    IT_RETURN-LOG_MSG_NO
                      it_return-message_v1,
                    IT_RETURN-MESSAGE_V2
                    IT_RETURN-MESSAGE_V3
                    IT_RETURN-MESSAGE_V4
                 (20) it_return-parameter,
                 (3)  it_return-row,
                      it_return-field.
                    IT_RETURN-SYSTEM
        endloop.
      endif.
      uline.
    endform.                               " Show_messages
          FORM fill_accountgl                                           *
    form fill_accountgl.
      clear it_accountgl.
      it_accountgl-itemno_acc     = 2.
      it_accountgl-gl_account     = '0021510201'.
      it_accountgl-item_text      = 'BAPI Test G/L line item'.  "#EC NOTEXT
    it_accountgl-bus_area       = '01'.
    it_accountgl-profit_ctr     = '0000010101'.
    it_accountgl-comp_code      = 'SLOC'.
      append it_accountgl.
      clear it_accountgl.
      it_accountgl-itemno_acc     = 3.
      it_accountgl-gl_account     = '0082000201'.
      it_accountgl-item_text      = 'BAPI Test G/L line item'.  "#EC NOTEXT
      it_accountgl-bus_area       = '01'.
      it_accountgl-profit_ctr     = '0000010101'.
      it_accountgl-comp_code      = 'SLOC'.
      it_accountgl-tax_code       = 'A3'.
      append it_accountgl.
      clear it_accountgl.
      it_accountgl-itemno_acc     = 5.
      it_accountgl-gl_account     = '0021510201'.
      it_accountgl-item_text      = 'BAPI Test G/L line item'.  "#EC NOTEXT
    it_accountgl-bus_area       = '01'.
    it_accountgl-profit_ctr     = '0000010301'.
    it_accountgl-comp_code      = 'SLOC'.
      append it_accountgl.
      clear it_accountgl.
      it_accountgl-itemno_acc     = 6.
      it_accountgl-gl_account     = '0082000201'.
      it_accountgl-item_text      = 'BAPI Test G/L line item'.  "#EC NOTEXT
      it_accountgl-bus_area       = '01'.
      it_accountgl-profit_ctr     = '0000010301'.
      it_accountgl-comp_code      = 'SLOC'.
      it_accountgl-tax_code       = 'A3'.
      append it_accountgl.
      clear it_accountgl.
      it_accountgl-itemno_acc     = 7.
    it_accountgl-itemno_acc     = 8.
      it_accountgl-gl_account     = '0021510201'.
      it_accountgl-item_text      = 'BAPI Test G/L line item'.  "#EC NOTEXT
    it_accountgl-bus_area       = '90'.
    it_accountgl-profit_ctr     = '0000900008'.
    it_accountgl-comp_code      = 'CORP'.
      append it_accountgl.
      clear it_accountgl.
      it_accountgl-itemno_acc     = 8.
    it_accountgl-itemno_acc     = 9.
      it_accountgl-gl_account     = '0082000201'.
      it_accountgl-item_text      = 'BAPI Test G/L line item'.  "#EC NOTEXT
      it_accountgl-bus_area       = '90'.
      it_accountgl-profit_ctr     = '0000900008'.
      it_accountgl-comp_code      = 'CORP'.
    it_accountgl-tax_code       = 'A3'.
      append it_accountgl.
    endform.                    "fill_accountgl
          FORM fill_header                                              *
    form fill_header.
    CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
       IMPORTING
         own_logical_system = gd_documentheader-obj_sys.
    OBJ_TYPE has to be replaced by customers object key (Y* or Z*)
    gd_documentheader-obj_type   = 'IDOC'.
    gd_documentheader-obj_key    = ref_key.
      gd_documentheader-username   = sy-uname.
      gd_documentheader-header_txt = 'BAPI Test'.               "#EC NOTEXT
    gd_documentheader-obj_key_r  =
    GD_DOCUMENTHEADER-reason_rev =
    gd_documentheader-comp_code  = 'SLOC'.
    GD_DOCUMENTHEADER-AC_DOC_NO  =
      gd_documentheader-fisc_year  = sy-datum(4).
      gd_documentheader-doc_date   = sy-datum.
      gd_documentheader-pstng_date = sy-datum.
    GD_DOCUMENTHEADER-TRANS_DATE =
    GD_DOCUMENTHEADER-VALUE_DATE =
    GD_DOCUMENTHEADER-FIS_PERIOD =
    gd_documentheader-doc_type   = 'KR'.
    gd_documentheader-ref_doc_no = 'xxxx'.
    GD_DOCUMENTHEADER-COMPO_ACC  =
      gd_documentheader-bus_act    = 'RFBU'.
    endform.                    "fill_header
          FORM fill_contractheader                                     *
    form fill_contractheader.
    gd_fica_hd-doc_no           =
    gd_fica_hd-doc_type_ca      =
    gd_fica_hd-res_key          =
    gd_fica_hd-fikey            =
    gd_fica_hd-payment_form_ref =
    endform.                    "fill_contractheader
          FORM fill_cpd                                                 *
    form fill_cpd.
    gd_customercpd-name
    gd_customercpd-name_2
    gd_customercpd-name_3
    gd_customercpd-name_4
    gd_customercpd-postl_code
    gd_customercpd-city
    gd_customercpd-country
    gd_customercpd-country_iso
    gd_customercpd-street
    gd_customercpd-po_box
    gd_customercpd-pobx_pcd
    gd_customercpd-pobk_curac
    gd_customercpd-bank_acct
    gd_customercpd-bank_no
    gd_customercpd-bank_ctry
    gd_customercpd-bank_ctry_iso
    gd_customercpd-tax_no_1
    gd_customercpd-tax_no_2
    gd_customercpd-tax
    gd_customercpd-equal_tax
    gd_customercpd-region
    gd_customercpd-ctrl_key
    gd_customercpd-instr_key
    gd_customercpd-dme_ind
    gd_customercpd-langu_iso
    endform.                    "fill_cpd
          FORM fill_ar                                                  *
    form fill_accountar.
    CLEAR it_accountreceivable.
    it_accountreceivable-itemno_acc =
    it_accountreceivable-customer   =
    IT_ACCOUNTRECEIVABLE-REF_KEY_1  =
    IT_ACCOUNTRECEIVABLE-REF_KEY_2  =
    IT_ACCOUNTRECEIVABLE-REF_KEY_3  =
    IT_ACCOUNTRECEIVABLE-PMNTTRMS   =
    IT_ACCOUNTRECEIVABLE-BLINE_DATE =
    IT_ACCOUNTRECEIVABLE-DSCT_DAYS1 =
    IT_ACCOUNTRECEIVABLE-DSCT_DAYS2 =
    IT_ACCOUNTRECEIVABLE-NETTERMS   =
    IT_ACCOUNTRECEIVABLE-DSCT_PCT1  =
    IT_ACCOUNTRECEIVABLE-DSCT_PCT2  =
    IT_ACCOUNTRECEIVABLE-PYMT_METH  =
    IT_ACCOUNTRECEIVABLE-DUNN_KEY   =
    IT_ACCOUNTRECEIVABLE-DUNN_BLOCK =
    IT_ACCOUNTRECEIVABLE-PMNT_BLOCK =
    IT_ACCOUNTRECEIVABLE-VAT_REG_NO =
    IT_ACCOUNTRECEIVABLE-ALLOC_NMBR =
    it_accountreceivable-item_text  =
    IT_ACCOUNTRECEIVABLE-PARTNER_BK =
    IT_ACCOUNTRECEIVABLE-GL_ACCOUNT =
    it_accountreceivable-comp_code
    it_accountreceivable-bus_area
    it_accountreceivable-pmtmthsupl
    it_accountreceivable-paymt_ref
    it_accountreceivable-scbank_ind
    it_accountreceivable-businessplace
    it_accountreceivable-sectioncode
    it_accountreceivable-branch
    it_accountreceivable-pymt_cur
    it_accountreceivable-pymt_cur_iso
    it_accountreceivable-pymt_amt
    it_accountreceivable-c_ctr_area
    it_accountreceivable-bank_id
    it_accountreceivable-supcountry
    it_accountreceivable-supcountry_iso
    it_accountreceivable-tax_code
    it_accountreceivable-taxjurcode
    it_accountreceivable-tax_date
    it_accountreceivable-sp_gl_ind
    it_accountreceivable-partner_guid = '1465464654'.
    APPEND it_accountreceivable.
    endform.                    "fill_accountar
          FORM fill_ap                                                  *
    form fill_accountap.
      clear it_accountpayable.
      it_accountpayable-itemno_acc = 1.
    it_accountpayable-vendor_no  = '0000060259'.
      it_accountpayable-vendor_no  = '0000060693'.
    it_accountpayable-gl_account
    it_accountpayable-ref_key_1
    it_accountpayable-ref_key_2
    it_accountpayable-ref_key_3
    it_accountpayable-comp_code = 'SLOC'.
    it_accountpayable-bus_area = '01'.
    it_accountpayable-pmnttrms = 'A000'.
    it_accountpayable-bline_date
    it_accountpayable-dsct_days1
    it_accountpayable-dsct_days2
    it_accountpayable-netterms
    it_accountpayable-dsct_pct1
    it_accountpayable-dsct_pct2
    it_accountpayable-pymt_meth
    it_accountpayable-pmtmthsupl
    it_accountpayable-pmnt_block
    it_accountpayable-scbank_ind
    it_accountpayable-supcountry
    it_accountpayable-supcountry_iso
    it_accountpayable-bllsrv_ind
    it_accountpayable-alloc_nmbr
      it_accountpayable-item_text  = 'BAPI Test A/P line item'. "#EC NOTEXT
    it_accountpayable-po_sub_no
    it_accountpayable-po_checkdg
    it_accountpayable-po_ref_no
    it_accountpayable-w_tax_code
    it_accountpayable-businessplace
    it_accountpayable-sectioncode
    it_accountpayable-instr1
    it_accountpayable-instr2
    it_accountpayable-instr3
    it_accountpayable-instr4
    it_accountpayable-branch
    it_accountpayable-pymt_cur
    it_accountpayable-pymt_amt
    it_accountpayable-pymt_cur_iso
    it_accountpayable-sp_gl_ind
      append it_accountpayable.
    endform.                    "fill_accountap
          FORM fill_tax                                                 *
    form fill_accounttax.
      clear it_accounttax.
      it_accounttax-itemno_acc = 4.
      it_accounttax-gl_account = '0011361502'.
      it_accounttax-tax_code   = 'A3'.
      it_accounttax-acct_key   = 'VST'.
      it_accounttax-cond_key   = 'MWVS'.
    it_accounttax-itemno_tax = 8.
      append it_accounttax.
    clear it_accounttax.
    it_accounttax-itemno_acc = 7.
    it_accounttax-gl_account = '0011361502'.
    it_accounttax-tax_code   = 'A3'.
    it_accounttax-acct_key   = 'VST'.
    it_accounttax-COND_KEY   = 'MWVS'.
    append it_accounttax.
    clear it_accounttax.
    it_accounttax-itemno_acc = 10.
    it_accounttax-itemno_acc = 9.
    it_accounttax-gl_account = '0011361502'.
    it_accounttax-tax_code   = 'A3'.
    it_accounttax-acct_key   = 'VST'.
    it_accounttax-cond_key   = 'MWVS'.
    it_accounttax-itemno_tax = 4.
    append it_accounttax.
    endform.                    "fill_accounttax
          FORM fill_currencyamount                                      *
    form fill_currencyamount.
      clear it_currencyamount.
      it_currencyamount-itemno_acc   = 1.
      it_currencyamount-curr_type    = '00'.
      it_currencyamount-currency     = 'MXN'.
      it_currencyamount-amt_doccur   = '-7408036.2'.
      append it_currencyamount.
      clear it_currencyamount.
      it_currencyamount-itemno_acc   = 2.
      it_currencyamount-curr_type    = '00'.
      it_currencyamount-currency     = 'MXN'.
      it_currencyamount-amt_doccur   = '5336472.00'.
      append it_currencyamount.
      clear it_currencyamount.
      it_currencyamount-itemno_acc   = 3.
      it_currencyamount-curr_type    = '00'.
      it_currencyamount-currency     = 'MXN'.
      it_currencyamount-amt_doccur   = '3840.00'.
      append it_currencyamount.
      clear it_currencyamount.
      it_currencyamount-itemno_acc   = 4.
      it_currencyamount-curr_type    = '00'.
      it_currencyamount-currency     = 'MXN'.
      it_currencyamount-amt_base   = '5548.00'.
      it_currencyamount-amt_doccur   = '832.2'.
    it_currencyamount-amt_doccur   = '576.00'.
    it_currencyamount-amt_base   = '3840.00'.
      append it_currencyamount.
      clear it_currencyamount.
      it_currencyamount-itemno_acc   = 5.
      it_currencyamount-curr_type    = '00'.
      it_currencyamount-currency     = 'MXN'.
      it_currencyamount-amt_doccur   = '2051279.00'.
      append it_currencyamount.
      clear it_currencyamount.
      it_currencyamount-itemno_acc   = 6.
      it_currencyamount-curr_type    = '00'.
      it_currencyamount-currency     = 'MXN'.
      it_currencyamount-amt_doccur   = '1690.00'.
      append it_currencyamount.
    clear it_currencyamount.
    it_currencyamount-itemno_acc   = 7.
    it_currencyamount-curr_type    = '00'.
    it_currencyamount-currency     = 'MXN'.
    it_currencyamount-amt_base     = '1690.00'.
    it_currencyamount-amt_doccur   = '253.5'.
    append it_currencyamount.
      clear it_currencyamount.
    it_currencyamount-itemno_acc   = 8.
      it_currencyamount-itemno_acc   = 7.
      it_currencyamount-curr_type    = '00'.
      it_currencyamount-currency     = 'MXN'.
      it_currencyamount-amt_doccur   = '13905.00'.
      append it_currencyamount.
      clear it_currencyamount.
    it_currencyamount-itemno_acc   = 9.
      it_currencyamount-itemno_acc   = 8.
      it_currencyamount-curr_type    = '00'.
      it_currencyamount-currency     = 'MXN'.
    it_currencyamount-amt_base     = '2.70'.
      it_currencyamount-amt_doccur   = '18.00'.
      append it_currencyamount.
    clear it_currencyamount.
    it_currencyamount-itemno_acc   = 10.
    it_currencyamount-itemno_acc   = 9.
    it_currencyamount-curr_type    = '00'.
    it_currencyamount-currency     = 'MXN'.
    it_currencyamount-amt_doccur   = '2.70'.
    it_currencyamount-amt_base     = '18.00'.
    append it_currencyamount.
    endform.                    "fill_currencyamount
          FORM fill_criteria                                            *
    form fill_criteria.
    CLEAR it_criteria.
    it_criteria-itemno_acc = 2.
    it_criteria-fieldname = 'BZIRK'.
    it_criteria-character = '000001'.
    append it_criteria.
    endform.                    "fill_criteria
          FORM fill_valuefield                                          *
    form fill_valuefield.
    CLEAR it_valuefield.
    it_valuefield-itemno_acc = 2.
    it_valuefield-fieldname = 'VV010'.
    it_valuefield-curr_type
    it_valuefield-currency = 'EUR'.
    it_valuefield-currency_iso
    it_valuefield-amt_valcom
    it_valuefield-base_uom
    it_valuefield-base_uom_iso
    it_valuefield-qua_valcom
    append it_valuefield.
    endform.                    "fill_valuefield
          FORM fill_extension                                           *
    form fill_extension.
    CLEAR it_ext.
    it_ext-field1
    it_ext-field2
    it_ext-field3
    it_ext-field4
    APPEND it_ext.
    DATA: ls_zzz TYPE ZZZ_ACCIT.
    CLEAR it_ext2.
    it_ext2-structure = 'ZZZ_ACCIT'.
    ls_zzz-posnr = 2.
    ls_zzz-awref_reb = '123654'.
    ls_zzz-aworg_reb = '654654'.
    ls_zzz-grant_nbr = '0022002'.
    MOVE ls_zzz TO it_ext2-valuepart1.
    APPEND it_ext2.
    endform.                    "fill_extension
          FORM fill_paymentcard                                         *
    form fill_paymentcard.
    CLEAR it_paymentcard.
    it_paymentcard-itemno_acc = 1.
    it_paymentcard-cc_glaccount
    it_paymentcard-cc_type
    it_paymentcard-cc_number
    it_paymentcard-cc_seq_no
    it_paymentcard-cc_valid_f
    it_paymentcard-cc_valid_t
    it_paymentcard-cc_name
    it_paymentcard-dataorigin
    it_paymentcard-authamount = '100'.
    it_paymentcard-currency = 'EUR'.
    it_paymentcard-currency_iso
    it_paymentcard-cc_autth_no
    it_paymentcard-auth_refno
    it_paymentcard-auth_date
    it_paymentcard-auth_time
    it_paymentcard-merchidcl
    it_paymentcard-point_of_receipt
    it_paymentcard-terminal
    it_paymentcard-cctyp = '1'.
    APPEND it_paymentcard.
    endform.                    "fill_paymentcard
          FORM fill_contractitem                                        *
    form fill_contractitem.
    CLEAR it_fica_it.
    it_fica_it-itemno_acc
    it_fica_it-cont_acct
    it_fica_it-main_trans
    it_fica_it-sub_trans
    it_fica_it-func_area
    it_fica_it-fm_area
    it_fica_it-cmmt_item
    it_fica_it-funds_ctr
    it_fica_it-fund
    append it_fica_it.
    endform.                    "fill_contractitem
    *&      Form  fill_re
    form fill_re .
    CLEAR it_re.
    it_re-itemno_acc      =
    it_re-business_entity =
    it_re-building        =
    it_re-property        =
    it_re-rental_object   =
    it_re-serv_charge_key =
    it_re-settlement_unit =
    it_re-contract_no     =
    APPEND it_re.
    endform.                    "fill_re
    Please check these links
    http://sap4.com/wiki/index.php?title=BAPI_ACC_DOCUMENT_POST
    http://www.sapfans.com/forums/viewtopic.php?p=76232&sid=b6519d31b5097f49dc303d03b35eed43
    http://sap.ittoolbox.com/groups/technical-functional/sap-dev/bapi_acc_document_post-622561
    Regards,
    Raj.

  • Unable to Post accounting document(URGENT)

    I am unable to push to accounting from the billing document. I created oreder with one line item and in delivery I entered text item, then I did billing but it is not posting to accounting by giving error message "Field Bus. Area is a required field for G/L account xyz 121000. Neither it is allowing to delete the particular text item in deliver nor it is allowing me to cancel the billing document in VF11 it is giving error message that Data inconsistency during processing of document and another error message is Cancellation document is not the same as the original billing doc. I checked everything is fine. How to rectify the error.

    Hi
    This problem can be solved in two way.
    1. Go to T-Code FS00 Enter the G/L 121000 and enter the Company Code  Then Click on Display Mode..then In Create and Bank interest Tab find the Field Status Group.. Aftet that Go TO T-Code Select Field Status Variant as 0001 and click on Field status  Gropus and You will find field status group here.. then Double click on that Field status group.. There in Select Group you have Businees area which made and Mandatory entry .. Make that entry as optional and save it.. then do the billing .. 
    OR
    2. Go to T-Code OBY6 and double click on your company code .. in that screen you have business area financial statement screen which is checked.. you uncheck this one and save it.. then do the billing
    How to give points: Mark your thread as a question while creating it. In the answers you get, you can assign the points by clicking on the stars to the left. You also get a point yourself for rewarding (one per thread).
    Enjoy Buddy...
    Regards
    MBS

Maybe you are looking for