REPORT zmrp_vss_cleanup NO STANDARD PAGE HEADING LINE-SIZE90
LINE-COUNT (1).
*=======================================================================
* Copyright CommScope Inc 2009
*Name : ZMRP_VSS_CLEANUP
*Title : Vendor schedule sharing data cleanup
* Created : 02/20/09 ScottZheng
*CTS : AC3K9A0D94
* IT-Request: 157519
* T-Code :ZMM098
CONSTANTS: con_app_version(6) VALUE '1.00'.
*
*Process: Test or delete data from the ZMVR01,
* ZMVR02,ZMVR03 where plant matches user’s input.
* DBUpdating: Yes - ZMVR01,ZMVR02,ZMVR03
* AuthorityCheck: No
* Sensitive Reporting: No.
* Menu Path:
*
*=======================================================================
* C O N F I G U R A T I O N / A S S U M P T I O N S
*=======================================================================
*
*
*
*=======================================================================
* R E V I S I ON H I S T O RY
*=======================================================================
* ReleaseDate Userid
* v01.00 mm/dd/yy userid
* Program creation. Program required because/Program requestedby...
* Project/Remedy ....
*
*
*=======================================================================
* T E S T P RO C E D U R ES, D A TA, U T I L IT I E S
*=======================================================================
*
*
*
*=======================================================================
************************************************************************
* Database tables
************************************************************************
TABLES:t001w, " Plants/Branches
zmvr01, " Supplier Sharing Report Header..
zmvr02, " Supplier Sharing Report Purchase..
zmvr03. " Planned Order and Purch Req. Data..
************************************************************************
* Internal tables
************************************************************************
DATA: BEGIN OF it_zmvr01 OCCURS 0.
INCLUDE STRUCTURE zmvr01.
DATA: END OF it_zmvr01.
DATA: BEGIN OF it_zmvr02 OCCURS 0.
INCLUDE STRUCTURE zmvr02.
DATA: END OF it_zmvr02.
DATA: BEGIN OF it_zmvr03 OCCURS 0.
INCLUDE STRUCTURE zmvr03.
DATA: END OF it_zmvr03.
************************************************************************
* Selection screen information
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLEtext-t01.
* select option for Plant
SELECT-OPTIONS: s_werks FOR t001w-werks NO INTERVALS OBLIGATORY.
SELECTION-SCREEN END OF BLOCK bl1.
* Checkbox that to identify the 'Test Run' mode.
SELECTION-SCREEN BEGIN OF BLOCK bl2 WITH FRAME TITLEtext-t02.
PARAMETERS: p_test AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK bl2.
************************************************************************
* Work fields
************************************************************************
DATA:line_num01 TYPEi, " The line count of the it_zmvr01
line_num02 TYPEi, " The line count of the it_zmvr02
line_num03 TYPEi, " The line count of the it_zmvr03
totl_line_num TYPEi. " The total line count
DATA:p_answer TYPEc. " The confirmation flag
DATA: p_subtil(30) TYPEc. " Subtitle
************************************************************************
* Initialization
************************************************************************
INITIALIZATION.
p_subtil = 'VSS data cleanup'.
************************************************************************
* TOP-OF-PAGE
************************************************************************
TOP-OF-PAGE.
* Output standard header
CALL FUNCTION 'ZS_STANDARD_REPORT_HEADING'
EXPORTING
i_subheading = p_subtil.
************************************************************************
* Start-of-selection
************************************************************************
START-OF-SELECTION.
* check the mode of 'Test Run'.
IF p_test EQ 'X'.
* Test run mode
PERFORMtest_run_mode.
* Really delete the entries from table.
ELSE.
* Delete the entries from the tables
PERFORMdelete_plant_data.
ENDIF. " IFp_test EQ 'X'.
*&---------------------------------------------------------------------*
*& Form GET_TABLE_DATA
*&---------------------------------------------------------------------*
* Get the data from ZMVR01 ZMVR02 ZMVR03
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
FORM get_table_data.
* Get primary key form table ZMVR01
SELECT lifnr matnr bukrs werks
FROMzmvr01
INTOCORRESPONDING FIELDS OF TABLE it_zmvr01
WHERE werksIN s_werks.
* Get primary key form table ZMVR02
SELECT lifnr matnr bukrs werks konnr ebeln ebelpetenr
FROMzmvr02
INTOCORRESPONDING FIELDS OF TABLE it_zmvr02
WHERE werksIN s_werks.
* Get primary key form table ZMVR03
SELECT werks matnr delkz delnr delps
FROMzmvr03
INTOCORRESPONDING FIELDS OF TABLE it_zmvr03
WHERE werksIN s_werks.
* Get the line count from tables
DESCRIBE TABLE it_zmvr01 LINES line_num01.
DESCRIBE TABLE it_zmvr02 LINES line_num02.
DESCRIBE TABLE it_zmvr03 LINES line_num03.
ENDFORM. " GET_TABLE_DATA
*&---------------------------------------------------------------------*
*& Form delete_plant_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* Delete entries by the certain plant.
*----------------------------------------------------------------------*
FORM delete_plant_data.
* Confirm the subsequent operation.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = 'Warning'
text_question = 'Are you sure to delete entries?'(003)
text_button_1 = 'OK'(001)
text_button_2 = 'NO'(002)
IMPORTING
answer = p_answer
* TABLES
* PARAMETER =
* EXCEPTIONS
* TEXT_NOT_FOUND = 1
* OTHERS = 2
.
IF sy-subrc <>0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* To confirm delete the data
IF p_answer EQ '1'.
* Get data into the internal tables
PERFORMget_table_data.
* The header
WRITE: 'TheRecord Of The Entries Have Been Deleted.'(502).
SKIP.
* Delete the data fromZMVR01
DELETEzmvr01 FROM TABLE it_zmvr01.
IFsy-subrc = 0.
COMMIT WORK.
WRITE: / text-101,
line_num01.
ELSE.
ROLLBACK WORK.
WRITE: / 'Entries of ZMVR01 deleted unsuccessfully'(301).
* clear the number of entries
CLEAR line_num01.
ENDIF. " IF sy-subrc = 0
* Delete the data fromZMVR02
DELETEzmvr02 FROM TABLE it_zmvr02.
IFsy-subrc = 0.
COMMIT WORK.
WRITE: / text-102,
line_num02.
ELSE.
ROLLBACK WORK.
WRITE: / 'Entries of ZMVR02 deleted unsuccessfully'(302).
* clear the number of entries
CLEAR line_num02.
ENDIF. " IF sy-subrc = 0
* Delete the data fromZMVR03
DELETEzmvr03 FROM TABLE it_zmvr03.
IFsy-subrc = 0.
COMMIT WORK.
WRITE: / text-103,
line_num03.
ELSE.
ROLLBACK WORK.
WRITE: / 'Entries of ZMVR03 deleted unsuccessfully'(303).
* clear the number of entries
CLEAR line_num03.
ENDIF. " IF sy-subrc = 0
* Add the deleted entriesnumber
totl_line_num = line_num01 + line_num02 + line_num03.
* Display the total numberof deleted entries
WRITE: /text-104,
totl_line_num.
ELSE. " if P_answer EQ = '1'.
EXIT.
ENDIF. " ifP_answer EQ = '1'.
ENDFORM. " delete_plant_data
*&---------------------------------------------------------------------*
*& Form test_run_mode
*&---------------------------------------------------------------------*
* Test run mode
*----------------------------------------------------------------------*
* No paramters
*----------------------------------------------------------------------*
FORM test_run_mode.
* Get data into the internal tables
PERFORM get_table_data.
* Add the deleted entries number
totl_line_num = line_num01 + line_num02 +line_num03.
* Display the number of entries that would be deleted in eachtable
WRITE: 'Text Run Mode'(501).
ULINE.
WRITE: 'Entry number ofZMVR01:'(101),
line_num01,
/ 'Entry number of ZMVR02:'(102),
line_num02,
/ 'Entry number of ZMVR03:'(103),
line_num03,
/ 'Total number:'(104),
totl_line_num.
ENDFORM. " test_run_mode