cancel
Showing results for 
Search instead for 
Did you mean: 

Deletion of sales orders does not delete serial number assignment

rinrosglo
Explorer
0 Kudos

Hi,

I have created sales order using BAPI_SALESORDER_CREATEFROMDAT2 and then added serial numbers to it using SERNR_ADD_TO_AU and SERIAL_LISTE_POST_AU. Now the serial numbers are visible in VA03->extras->technical data, also an entry is added in SER02 table.

Now when I manually delete the sales order in VA02, though the sales order is deleted, the entry in SER02 remains.

Whereas if the sales order is created using VA01 with Serial numbers added and then when i delete the sales order in VA02, the corresponding entry in SER02 also gets deleted.

I am using SERNR_ADD_TO_AU as below. Any pointers on why the SER02 entry is not getting deleted and how the issue can be fixed will be very helpful. This logic is required to make sure multiple sales orders are not created for the same serial numbers.

Thanks in Advance.

CALL FUNCTION 'SERNR_ADD_TO_AU'

EXPORTING

SERNR = <sernr>

PROFILE = <marc-sernp>

MATERIAL = <mara-matnr>

QUANTITY = <quantity>

DOCUMENT = <vbak-vbeln>

ITEM = <vbap-posnr>

DEBITOR = <shipto>

VBTYP = 'C'

SD_AUART = 'KE'

SD_POSTYP = 'KEN'

I_BAPI = ' '

* IMPORTING

* ANZSN =

* ZEILEN_ID =

* SERIAL_COMMIT =

EXCEPTIONS

KONFIGURATIONS_ERROR = 1

SERIALNUMBER_ERRORS = 2

SERIALNUMBER_WARNINGS = 3

NO_PROFILE_OPERATION = 4

OTHERS = 5

.

View Entire Topic
raymond_giuseppi
Active Contributor
juan_suros
Contributor
0 Kudos

The warning in note 1795864 is interesting. It might be safer to make a class implementing a

CALL TRANSACTION 'VA02' USING lt_bdcdata

approach to attach the serial numbers. You would then expect the serial assignments to be reversed when the Sales Order is deleted in VA02.


rinrosglo
Explorer
0 Kudos

Thank you Juan and Raymond for your response.

Yes BDC will be an option I might have to use. But before that I am trying to figure out if the BAPI approach can be made to work.

During my several tries when I passed I_BAPI = 'X', it worked the first time. Then later when I passed I_BAPI = ' ' and again I_BAPI = 'X' (basically to confirm my finding) the SER02 table clearing did not work. I am not clear on the internal memory usage of the function group and the parameter I_BAPI usage. Any light on this would be very helpful.

Thank you.