Sie sind auf Seite 1von 3

*&---------------------------------------------------------------------*

*& Report ZEAM_ORDER_OPER_FIX


*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT ZEAM_ORDER_OPER_FIX.

* This report check for one order if any related information for
* operations exist. If so and the corresponding operation do not
* exist the report will list them.
* In case of parameter P_TEST = ' ' the report will also delete
* the associated orphaned records
* Following status tables will be checked :
* JSTO
* JEST
* JCDO
* JCDS
* ONR00
* ONROK
* AFVV
* AFVU
*
* Parameter P_TEST :
* - P_TEST = SPACE -> update mode
* - P_TEST <> SPACE -> test mode
* - only in update mode the report will make database changes
* - set text "Test Mode" for this text element*
*
* Parameter P_ORDER :
* - you can restrict by order number
* - set flag dictionary reference for this text element

tables: JSTO,JEST,JCDO,JCDS,ONR00,ONROK,afko,afvc, afvv, afvu.

parameters : p_order like afko-aufnr.

parameters : p_test(1) type c default 'X'.

data : gv_objnr_low like jsto-objnr,


gv_objnr_high like jsto-objnr.

data: gt_afvc like afvc occurs 0 with header line,


gt_jsto like jsto occurs 0 with header line,
gt_jest like jest occurs 0 with header line,
gt_jcdo like jcdo occurs 0 with header line,
gt_jcds like jcds occurs 0 with header line,
gt_onr00 like onr00 occurs 0 with header line,
gt_onrov like onrov occurs 0 with header line,
gt_afvv like afvv occurs 0 with header line,
gt_afvu like afvu occurs 0 with header line.

select single * from afko where aufnr = p_order.


if sy-subrc <> 0.
write : / 'Order',p_order,' Does not exist'.
stop.
endif.

gv_objnr_low = 'OV'.
gv_objnr_low+2 = afko-aufpl.
gv_objnr_low+12 = '00000000'.

gv_objnr_high = 'OV'.
gv_objnr_high+2 = afko-aufpl.
gv_objnr_high+12 = '99999999'.

select * from afvc into table gt_afvc where aufpl = afko-aufpl.


sort gt_afvc by objnr.

select * from jsto into table gt_jsto where objnr between gv_objnr_low and
gv_objnr_high.

select * from jest into table gt_jest where objnr between gv_objnr_low and
gv_objnr_high.

select * from jcdo into table gt_jcdo where objnr between gv_objnr_low and
gv_objnr_high.

select * from jcds into table gt_jcds where objnr between gv_objnr_low and
gv_objnr_high.

select * from onr00 into table gt_onr00 where objnr between gv_objnr_low and
gv_objnr_high.

select * from onrov into table gt_onrov where objnr between gv_objnr_low and
gv_objnr_high.

select * from afvv into table gt_afvv where aufpl = afko-aufpl.

select * from afvu into table gt_afvu where aufpl = afko-aufpl.

loop at gt_afvc.
delete gt_jsto where objnr = gt_afvc-objnr.
delete gt_jest where objnr = gt_afvc-objnr.
delete gt_jcdo where objnr = gt_afvc-objnr.
delete gt_jcds where objnr = gt_afvc-objnr.
delete gt_onr00 where objnr = gt_afvc-objnr.
delete gt_onrov where objnr = gt_afvc-objnr.
delete gt_afvv where APLZL = GT_AFVC-APLZL.
delete gt_afvu where APLZL = GT_AFVC-APLZL.
endloop.

if gt_jsto[] is initial and gt_jest[] is initial and


gt_jcdo[] is initial and gt_jcds[] is initial and
gt_onr00[] is initial and gt_onrov[] is initial and
gt_afvv[] is initial and gt_afvu[] is initial.
write : / 'No associated records to be deleted'.
stop.
else.
if p_test = ' '.
write : / 'UPDATE mode for order', p_order.
else.
write : / 'Test mode for order', p_order.
endif.

skip 2.
write : / 'Records to be DELETED:'.
skip 1.

loop at gt_jsto.
write : / 'JSTO :',gt_jsto-objnr.
if p_test = ' '.
delete from jsto where objnr = gt_jsto-objnr.
endif.
endloop.
loop at gt_jest.
write : / 'JEST :',gt_jest-objnr, gt_jest-stat.
if p_test = ' '.
delete from jest where objnr = gt_jest-objnr and stat = gt_jest-stat.
endif.
endloop.
loop at gt_jcdo.
write : / 'JCDO :',gt_jcdo-objnr, gt_jcdo-chgnr.
if p_test = ' '.
delete from jcdo where objnr = gt_jcdo-objnr and chgnr = gt_jcdo-chgnr.
endif.
endloop.
loop at gt_jcds.
write : / 'JCDS :',gt_jcds-objnr, gt_jcds-stat, gt_jcds-chgnr.
if p_test = ' '.
delete from jcds where objnr = gt_jcds-objnr and stat = gt_jcds-stat and
chgnr = gt_jcds-chgnr.
endif.
endloop.
loop at gt_onr00.
write : / 'ONR00 :',gt_onr00-objnr.
if p_test = ' '.
delete from onr00 where objnr = gt_onr00-objnr.
endif.
endloop.
loop at gt_onrov.
write : / 'ONROV :',gt_onrov-objnr.
if p_test = ' '.
delete from onrov where objnr = gt_onrov-objnr.
endif.
endloop.
loop at gt_afvv.
write : / 'AFVV :',GT_AFVV-AUFPL, ' ', GT_AFVV-APLZL.
if p_test = ' '.
delete from afvv where aufpl = gt_afvv-aufpl and aplzl = gt_afvv-aplzl.
endif.
endloop.
loop at gt_afvu.
write : / 'AFVU :', GT_AFVU-AUFPL, ' ', GT_AFVU-APLZL.
if p_test = ' '.
delete from afvu where aufpl = gt_afvu-aufpl and aplzl = gt_afvu-aplzl.
endif.
endloop.
endif.