Skip to Content
avatar image
Former Member

Document was wrongly cleared with itself

Dear Experts!

I have very urgent question. We did report in FI module and it was created final invoice it was automatically cleared namely it created clearing document even line items is not zero in FBL5N it has cleared positions. But it should not be, and If I want to reverse document from FBRA it gives errro as "Line items is not zero"

Dear experts is there any FM / Bapi or standart Tcode to change status of this wrongly cleared document to open

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Dec 04, 2017 at 07:03 AM

    Good morning everyone.

    I found the reason of problem and solution.

    Problem: in our development, when down payment is created or final invoice is created they were automatically clared without any clering documents. This was really strange situation that led to error " Line items is not zero ". The reason was FM which is called as 'CLEAR_DOCUMENTS' was used incorrectly.

    Solution: Thanks to some FM we were able to reset documents in order to clear them correctly. I am posting code on purpose it will be usefull for others in future.

    " Processing resetting documents
    form resetting_document using ls_rf05r type rf05r
                                  l_bukrs type bseg-bukrs.
      " Postab initialization
      data:    begin of postab occurs 50,
               xauth(1)      type c,
               xhell(1)      type c.
              include structure rfpos.
              include rfeposc9.
      data:    xbkpf(1)      type c,
               xbseg(1)      type c,
               xbsec(1)      type c,
               xbsed(1)      type c,
               xpayr(1)      type c,
               xbsegc(1)     type c,
               xbsbv(1)      type c,
               xmod(1)       type c,
               end of postab.
      " Form variables initialization
        xerlk type rfpdo1-f140xdel,
        stodt type bkpf-budat,
        xragl1 type table of ragl1,
        ls_xragl1 type ragl1,
        xragl2 type table of ragl2,
        ls_xragl2 type ragl2,
        xragl3 type table of ragl3,
        ls_xragl3 type ragl3,
        xbkorm type table of bkorm,
        ls_bkpf type bkpf,
        ls_bseg type bseg,
        xkdf(1) type c,
        xskv(1) type c.
      " Read data from BKPF table
      call function 'READ_DOCUMENT_HEADER'
          belnr     = ls_rf05r-augbl
          bstat     = space
          bukrs     = ls_rf05r-bukrs
          gjahr     = ls_rf05r-gjahr
          xarch     = space          "keine Suche im Archiv
          e_bkpf    = ls_bkpf
          exit      = 4
          not_found = 8.
      " Get cleared items
      refresh: postab, xragl1, xragl2, xragl3.
      call function 'GET_CLEARED_ITEMS'
          i_bvorg   = ls_bkpf-bvorg
          i_bukrs   = ls_rf05r-bukrs
          i_belnr   = ls_rf05r-augbl
          i_gjahr   = ls_rf05r-gjahr
          e_xkdf    = xkdf
          e_xskv    = xskv
          t_items   = postab
          not_found = 1
          others    = 2.
      " Filling out tables
      loop at postab.
        move-corresponding postab to ls_xragl1.
        append ls_xragl1 to xragl1.
      " Filling second table
      select * from bseg into corresponding fields of ls_bseg where bukrs eq ls_rf05r-bukrs and
       belnr eq ls_rf05r-augbl and gjahr eq ls_rf05r-gjahr.
        if ls_bseg-augbl eq ls_rf05r-augbl and ( ls_bseg-fdgrp eq space or ls_bseg-fdlev eq space ).
          move-corresponding ls_bseg to ls_xragl2.
          append ls_xragl2 to xragl2.
      " Reverse clearing
      call function 'REVERSE_CLEARING' in update task
          i_augbu = ls_rf05r-bukrs
          i_augbl = ls_rf05r-augbl
          i_auggj = ls_rf05r-gjahr
          i_xerlk = xerlk
          i_stodt = stodt
          t_ragl1 = xragl1
          t_ragl2 = xragl2
          t_ragl3 = xragl3
          t_bkorm = xbkorm.
      " extended withholding tax
      call function 'FI_CHECK_EXTENDED_WT'
          i_bukrs              = l_bukrs
          component_not_active = 1
          not_found            = 2
          others               = 3.
      " Reset documents FI
      call function 'FI_WT_RESET_CLEARING' in update task
          i_augbu = ls_rf05r-bukrs
          i_augbl = ls_rf05r-augbl
          i_auggj = ls_rf05r-gjahr
          t_ragl1 = xragl1.
      " Open FI
      call function 'OPEN_FI_PERFORM_00001040_E'
          i_xvbup = 'X'
          i_rf05r = ls_rf05r
          t_xragl = xragl1.
      " If everyting is ok show message and write to table
      if ls_rf05r-bvorg is initial.
        " Append to intenal table that will display logs
        ls_tickets-name = icon_led_green.
        ls_tickets-matnr = ls_ticketnumber-ticketnumber.
        ls_tickets-text = 'Successfully generated'.
        append ls_tickets to lt_tickets.
        " Apply changes to Database
        commit work.
    Add comment
    10|10000 characters needed characters exceeded

  • Nov 28, 2017 at 01:45 PM


    It is a strange situation you are describing. Can you post the screenshot of the document, including its clearing information?



    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Eli

      As you can see in picture two final invoice documents which status is open in FBL5N

      But I f I check those documents numbers from table BSEG it has already cleared document number which should not be. Thus If I want to clear documents it gives an error

      снимок.png (5.5 kB)
  • Nov 29, 2017 at 12:34 PM

    Clearing document could be there, but did you check the clearing date? If the date is in the future and you run FBL5N report with date of today, then it would still show you that the items are open. Sometimes, people who do the clearing make a typo and if the period is not closed, clearing date could be wrong.

    Add comment
    10|10000 characters needed characters exceeded