Delete items (BSEG) from a parked FI document with FM PRELIMINARY_POSTING_DOC_WRITE

Hi all,

I’m struggling with the function module PRELIMINARY_POSTING_DOC_WRITE, when I try to delete lines from VBSEG. I have to do so because I need to apply changes to the parked document coming from an interface outside of SAP where I cannot determine the needed changes on field level. Or: Let’s say it can happen that the existing document has one vendor and 2 GL lines (split posting on different GL accounts) but now only one GL account line is needed or vice versa.

My approach is the following: I first read the document with FM PRELIMINARY_POSTING_DOC_READ. Then I would delete all existing lines and create all lines needed after the update from the beginning. For the deletion of the existing lines I tried so set VBSEG-KZ to ‘D’ and set VBSEG-BZALT to the old VBSEG-BUZEI value. For the insert I tried to set VBSEG-KZ to ‘I’ and set BUZEI to new values starting with the highest old VBSEG-BUZEI + 1 value. Unfortunately that did not work. I also tried other approaches using the import parameter i_bstat = ‘U’ or setting the value (WRBTR) in the lines to be deleted to zero. Either I got dumps with duplicate key errors or the old lines have not been deleted and the new lines have been added to the document (occasionally with redundant BUZEI values).

Does anyone have a solution for this?

Regards, Oliver

Scroll to Top