Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Delete serial numbers from production order

maria_merino
Active Participant
0 Kudos

Hi experts,

I am triing to delete serial numbers from a production order.

That's what i've done, sy-subrc is initial but the order is not being modified:

SELECT *
FROM ser05
INTO TABLE li_ser05
WHERE ppaufnr = i_planning-aufnr.
IF sy-subrc = 0.
LOOP AT li_ser05.
SELECT sernr
FROM objk
APPENDING CORRESPONDING FIELDS OF TABLE gt_sernos
WHERE obknr = li_ser05-obknr.
DESCRIBE TABLE gt_sernos LINES l_num_serno.
ENDLOOP.

CALL FUNCTION 'SERNR_DEL_FROM_PP'
EXPORTING
material = i_planning-plnbez
j_vorgang = 'PMP2'
ppaufnr = i_planning-aufnr
ppposnr = gs_afpod_po-posnr
IMPORTING
anzsn = l_num_serno
* ZEILEN_ID =
* SERIAL_COMMIT =
TABLES
sernos = gt_sernos
EXCEPTIONS
serialnumber_errors = 1
serialnumber_warnings = 2
OTHERS = 3.

IF sy-subrc = 0.
* CALL FUNCTION 'CO_BI_AFPO_UPD'
* EXPORTING
* afpowa = gs_afpod_po
* EXCEPTIONS
* error_read_afpo = 1
* OTHERS = 2.

CALL FUNCTION 'SERIAL_LISTE_POST_PP'
EXPORTING
memory_id_status = 'SN_STATS'.

ENDIF.

Thanks in advance !!

María

1 ACCEPTED SOLUTION

maria_merino
Active Participant
0 Kudos

Solved.

That's what I did:

LOOP AT lt_sernos.
CALL FUNCTION 'DEQUEUE_EIEQSE'
EXPORTING
mandt = sy-mandt
matnr = i_planning-plnbez
sernr = lt_sernos-sernr
_scope = '3'.
ENDLOOP.
IF lt_sernos[] IS NOT INITIAL.
CALL FUNCTION 'SERNR_DEL_FROM_PP'
EXPORTING
material = i_planning-plnbez
j_vorgang = 'PMP2'
ppaufnr = i_planning-aufnr
ppposnr = p_posnr
IMPORTING
anzsn = l_num_serno
* ZEILEN_ID =
* SERIAL_COMMIT =
TABLES
sernos = lt_sernos
EXCEPTIONS
serialnumber_errors = 1
serialnumber_warnings = 2
OTHERS = 3.

IF sy-subrc = 0.
CALL FUNCTION 'SERIAL_LISTE_POST_PP'
EXPORTING
memory_id_status = 'SN_STATS'.
IF sy-subrc = 0.
COMMIT WORK AND WAIT.
ENDIF.
ENDIF.
ENDIF.

3 REPLIES 3

Lakshmipathi
Active Contributor

Not sure why you want to delete from Production Order. If it is wrongly assigned, then you need to first make the necessary change in material master as recommended in OSS note 71997

maria_merino
Active Participant
0 Kudos

In CO02 there is the possibility to change serial numbers, that's what the user needs to do be done in the program, assign a new serial number.

I'm able to add new serial numbers but not to delete them.

maria_merino
Active Participant
0 Kudos

Solved.

That's what I did:

LOOP AT lt_sernos.
CALL FUNCTION 'DEQUEUE_EIEQSE'
EXPORTING
mandt = sy-mandt
matnr = i_planning-plnbez
sernr = lt_sernos-sernr
_scope = '3'.
ENDLOOP.
IF lt_sernos[] IS NOT INITIAL.
CALL FUNCTION 'SERNR_DEL_FROM_PP'
EXPORTING
material = i_planning-plnbez
j_vorgang = 'PMP2'
ppaufnr = i_planning-aufnr
ppposnr = p_posnr
IMPORTING
anzsn = l_num_serno
* ZEILEN_ID =
* SERIAL_COMMIT =
TABLES
sernos = lt_sernos
EXCEPTIONS
serialnumber_errors = 1
serialnumber_warnings = 2
OTHERS = 3.

IF sy-subrc = 0.
CALL FUNCTION 'SERIAL_LISTE_POST_PP'
EXPORTING
memory_id_status = 'SN_STATS'.
IF sy-subrc = 0.
COMMIT WORK AND WAIT.
ENDIF.
ENDIF.
ENDIF.