Eventuell braucht es ja noch jemand, obwohl das Thema schon alt ist.
Und bitte das ganze hier nur als Beispiel betrachten auch wenn es bei meinen Arbeitgeber genau so produktiv läuft.
Gruß
H
FUNCTION z_fauf_chg_arbpl.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(I_AUFNR) TYPE AUFNR
*" VALUE(I_OLD_ARBPL) TYPE ARBPL
*" VALUE(I_NEW_ARBPL) TYPE ARBPL
*" EXPORTING
*" VALUE(E_RETURN) TYPE SYSUBRC
*"----------------------------------------------------------------------
CONSTANTS : true TYPE c LENGTH 1 VALUE 'X',
false TYPE c LENGTH 1 VALUE space.
DATA : l_objnr TYPE j_objnr,
l_srtfd TYPE indx_srtfd,
l_mandt TYPE symandt,
l_stop TYPE boolean.
DATA : l_error TYPE sysubrc,
lta_head TYPE STANDARD TABLE OF zfaufhead,
lta_upos TYPE STANDARD TABLE OF zfaufupos,
lta_tour TYPE STANDARD TABLE OF ztour,
lta_plan TYPE STANDARD TABLE OF zfaufplan,
lta_konf TYPE STANDARD TABLE OF conf_out,
lta_also TYPE STANDARD TABLE OF zfaufalso,
lta_text TYPE STANDARD TABLE OF zfauftext,
lta_komp TYPE STANDARD TABLE OF zfaufkomp,
lta_elek TYPE STANDARD TABLE OF zfaufelek,
lta_sper TYPE STANDARD TABLE OF zfaufsper.
FIELD-SYMBOLS : TYPE zfaufhead, TYPE zfaufupos, TYPE ztour, TYPE zfaufplan, TYPE conf_out, TYPE zfaufalso, TYPE zfauftext, TYPE zfaufkomp, TYPE zfaufelek, TYPE zfaufsper. DATA : ls_return TYPE bapiret2,
lta_operation TYPE cose_t_operation.
FIELD-SYMBOLS : TYPE LINE OF cose_t_operation. DEFINE chk_status.
IF l_stop = false.
FIND &1 IN -status. IF sy-subrc = 0.
l_stop = true.
ENDIF.
ENDIF.
END-OF-DEFINITION.
e_return = 9.
*----- Alle Daten da?
IF i_aufnr IS INITIAL OR i_old_arbpl IS INITIAL OR i_new_arbpl IS INITIAL.
RETURN.
ENDIF.
e_return = 8.
*----- Daten FAUF besorgen
CALL FUNCTION 'ZGET_FAUF_DATA'
EXPORTING
aufnr = i_aufnr
get_new = false
get_meister = false
get_paketinfo = false
get_matgruppe = false
get_upos = false
get_tour = false
get_also = false
get_konf = false
get_plan = true
get_komp = false
get_text = false
get_parent = false
get_children = false
IMPORTING
return = l_error
TABLES
head = lta_head
upos = lta_upos
tour = lta_tour
also = lta_also
konf = lta_konf
plan = lta_plan
komp = lta_komp
elek = lta_elek
text = lta_text
sper = lta_sper.
IF lta_head[] IS INITIAL.
RETURN.
ENDIF.
READ TABLE lta_head INDEX 1 ASSIGNING .*----- nicht mehr verschieben wenn ....
e_return = 8.
l_stop = false.
chk_status 'LÖKZ'.
chk_status 'SPER'.
chk_status 'TABG'.
chk_status 'ABGS'.
chk_status 'LÖVM'.
IF l_stop = true.
RETURN.
ENDIF.
*----- Sperre auf Auftrag
e_return = 6.
IF NOT lta_sper IS INITIAL.
RETURN.
ENDIF.
*----- Neuen Arbeitsplatz auf Gültigkeit prüfen
e_return = 5.
SELECT SINGLE mandt
INTO l_mandt
FROM crhd
CLIENT SPECIFIED
WHERE mandt = sy-mandt
AND werks = -werks AND arbpl = i_new_arbpl
AND begda <= sy-datum
AND endda >= sy-datum
AND lvorm = false.
IF sy-subrc <> 0.
RETURN.
ENDIF.
*----- Alle Vorgänge im Arbeitsplan auf neuen Platz
e_return = 4.
FREE lta_operation.
LOOP AT lta_plan ASSIGNING WHERE arbpl = i_old_arbpl. APPEND INITIAL LINE TO lta_operation ASSIGNING . -operation = -vornr. -work_center = i_new_arbpl. -work_center_x = true. ENDLOOP.
IF lta_operation[] IS INITIAL.
RETURN.
ENDIF.
*----- Versuch des Verschiebens
e_return = 3.
CALL FUNCTION 'CO_SE_PRODORD_CHANGE'
EXPORTING
iv_order_number = i_aufnr
* IS_HEADER =
* IT_HDR_USER_STATUS =
* IT_SEQUENCE =
it_operation = lta_operation
* IT_OPR_USER_STATUS =
* IT_PRT =
* IV_COMMIT =
IMPORTING
es_return = ls_return.
IF ls_return-type CA 'EA'.
ROLLBACK WORK.
RETURN.
ENDIF.
*----- Festschreiben
e_return = 2.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = true
IMPORTING
return = ls_return.
IF ls_return-type CA 'EA'.
ROLLBACK WORK.
RETURN.
ENDIF.
e_return = 0.
CALL FUNCTION 'Z_NEW_FAUFINDX'
EXPORTING
i_aufnr = i_aufnr.
ENDFUNCTION.