You are on page 1of 6

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

*& Report YCMIM040


*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
*&--------------------------------------------------------------------&*
*& Object Id : TS-MM-PUR-226 &*
*& Object Name : Invalid Schedule Agreement contain open schedule &*
*& lines which results in incorrect planning APO &*
*& run.Therefore for ZLP type of Agreements delivery&*
*& comleted indicator will be set and for ZLU type &*
*& of Agreements open order qty will be reset to &*
*& delivery created quantity. &*
*& Program Name : YCMIM040 &*
*& Author : Sarbari Maity &*
*& Module Name : MM &*
*& Sub-Module : IM &*
*& Program Type : INTERACTIVE REPORT Create Date :27.08.2008 &*
*& SAP Release : 5.0 Transport No :RD1K924377 &*
*& Description : There is a need to develop a utility that can be &*
*& used to close SAs which are old or partly &*
*& processed because existence of such SAs will &*
*& result in incorrect planning results. The utility&*
*& should be flexible so that SAs could be selected &*
*& based on various parameters like:Company Code, &*
*& Plant, Material Type, Material Group, &*
*& Sch. Agreement No, Validity Start, Vendor, &*
*& Material.SAs with open line items will be reset &*
*& to 0 by updating delivery completed indicator for&*
*& ZLP type of SAs and for ZLU type of SAs Open &*
*& Order quantity will be reset to Delivered &*
*& Quantity. &*
*& SSMS No. : ECC MM-HO#107/104
*&--------------------------------------------------------------------&*
REPORT ycmim040 NO STANDARD PAGE HEADING.
INCLUDE ycmim040top.
************************************************************************
* A T S E L E C T I O N S C R E E N
************************************************************************
AT SELECTION-SCREEN.
* Validation for the Elements in Selection Screen
PERFORM sub_validation.
************************************************************************
* S T A R T O F S E L E C T I O N
************************************************************************
START-OF-SELECTION.
* Select Sch. Agreement No Header from Table EKKO
PERFORM sub_retrieve_data_from_ekko.
* Select Sch. Agreement No Item from Table EKKO
PERFORM sub_retrieve_data_from_ekpo.
* Select Material no. and Material type from Table MARA
* based on Material no. retreieve from IT_EKPO
PERFORM sub_retrieve_data_from_mara.
* Select Scheduling Agreement Schedule Lines from Table EKET
PERFORM sub_retrieve_data_from_eket.
************************************************************************
* E N D O F S E L E C T I O N
************************************************************************
END-OF-SELECTION.
* Populate Summary Table
PERFORM sub_populate_summary.
*PF-Status for Summary Report
SET PF-STATUS 'SUMMARY' .
* Print the Summary List
PERFORM sub_summary_list.
************************************************************************
* A T U S E R C O M M A N D
************************************************************************
AT USER-COMMAND.
CASE sy-ucomm.
* Select All
WHEN 'SALL'.
w_tabix = 5.
LOOP AT it_summary INTO is_summary.
w_tabix = w_tabix + 1.
READ LINE w_tabix.
IF sy-subrc = 0.
is_summary-chk = c_x.
MODIFY LINE w_tabix FIELD VALUE is_summary-chk.
MODIFY it_summary FROM is_summary INDEX sy-tabix TRANSPORTING chk.
ENDIF.
ENDLOOP.
* De-Select All
WHEN 'DALL'.
w_tabix = 5.
LOOP AT it_summary INTO is_summary.
w_tabix = w_tabix + 1.
READ LINE w_tabix.
IF sy-subrc = 0.
is_summary-chk = ' '.
MODIFY LINE w_tabix FIELD VALUE is_summary-chk.
MODIFY it_summary FROM is_summary INDEX sy-tabix TRANSPORTING chk.
ENDIF.
ENDLOOP.
* Sort Up for Validity Start Date and Validity End Date
WHEN 'SORT_UP'.
IF sy-lilli = 3
OR sy-lilli = 4.
* Validity Start Date
IF sy-cucol >= 37
AND sy-cucol <= 50.
SORT it_summary BY kdatb ASCENDING.
* Call the Basic List
sy-lsind = 0.
* Print the Summary List
PERFORM sub_summary_list.
ENDIF.
* Validity End Date
IF sy-cucol >= 52
AND sy-cucol <= 65.
SORT it_summary BY kdate ASCENDING.
* Call the Basic List
sy-lsind = 0.
* Print the Summary List
PERFORM sub_summary_list.
ENDIF.
ENDIF.
* Sort Down for Validity Start Date and Validity End Date
WHEN 'SORT_DOWN'.
IF sy-lilli = 3
OR sy-lilli = 4.
* Validity Start Date
IF sy-cucol >= 37
AND sy-cucol <= 50.
SORT it_summary BY kdatb DESCENDING.
* Call the Basic List
sy-lsind = 0.
* Print the Summary List
PERFORM sub_summary_list.
ENDIF.
* Validity End Date
IF sy-cucol >= 52
AND sy-cucol <= 65.
SORT it_summary BY kdate DESCENDING.
* Call the Basic List
sy-lsind = 0.
* Print the Summary List
PERFORM sub_summary_list.
ENDIF.
ENDIF.
* Execute to get the Detail report
WHEN 'EXE'.
REFRESH: it_detail, it_bdc_zlp, it_bdc_zlu, it_maintain_zlu.
w_tabix = 5.
DESCRIBE TABLE it_summary LINES w_lines.
DO w_lines TIMES.
w_tabix = w_tabix + 1.
READ LINE w_tabix FIELD VALUE is_summary-chk
is_summary-ebeln.
* Get the Item detail and Schedule Line info of the
* Agreement No
IF is_summary-chk = c_x.
w_flag_sel = c_x.
CLEAR: is_ekpo, is_detail, is_bdc_zlp.
LOOP AT it_ekpo INTO is_ekpo WHERE ebeln = is_summary-ebeln.
* Filling the table for displaying Detail Report
is_detail-ebeln = is_ekpo-ebeln. " Schd. Agreeme
nt No.
is_detail-ebelp = is_ekpo-ebelp. " Item Number
is_detail-matnr = is_ekpo-matnr. " Material Numb
er
is_detail-werks = is_ekpo-werks. " Plant
is_detail-ktmng = is_ekpo-ktmng. " Target quanti
ty
* Populating 'ZLP' Order to update in ME32L transaction
IF is_summary-bsart = c_zlp.
is_bdc_zlp-ebeln = is_ekpo-ebeln. " Schd. Agreeme
nt No.
is_bdc_zlp-ebelp = is_ekpo-ebelp. " Item Number
APPEND is_bdc_zlp TO it_bdc_zlp.
ENDIF.
CLEAR: is_eket, is_bdc_zlu, is_maintain_zlu.
READ TABLE it_eket INTO is_eket WITH KEY ebeln = is_ekpo-ebeln
ebelp = is_ekpo-ebelp
BINARY SEARCH.
IF sy-subrc = 0.
is_detail-wemng = is_eket-wemng. " Quantity of g
oods received
* Segregrating 'ZLU' order, based on schedule quantity sum at item level
* for the Schedule Agreement No.
* Check the existence of open order quantity
IF is_summary-bsart = c_zlu AND is_eket-menge IS INITIAL.
is_bdc_zlu-ebeln = is_eket-ebeln. " Schd. Agreeme
nt No.
is_bdc_zlu-ebelp = is_eket-ebelp. " Item Number
APPEND is_bdc_zlu TO it_bdc_zlu.
* In case schedule quantity >0 and delivered quantity >=0 and not same
ELSEIF is_summary-bsart = c_zlu AND is_eket-menge <> is_eket-glmng
AND is_eket-menge > 0 AND is_eket-glmng >= 0.
CLEAR is_eket_tmp.
LOOP AT it_eket_tmp INTO is_eket_tmp WHERE ebeln = is_eket-ebeln
AND ebelp = is_eket-ebelp
.
is_maintain_zlu-ebeln = is_eket_tmp-ebeln. " Schd. Agreeme
nt No.
is_maintain_zlu-ebelp = is_eket_tmp-ebelp. " Item Number
is_maintain_zlu-etenr = is_eket_tmp-etenr. " Delivery Sche
dule Line Counter
is_maintain_zlu-eindt = is_eket_tmp-eindt. " Item delivery
date
is_maintain_zlu-menge = is_eket_tmp-menge. " Scheduled qua
ntity
is_maintain_zlu-glmng = is_eket_tmp-glmng. " Quantity deli
vered (stock transfer)
APPEND is_maintain_zlu TO it_maintain_zlu.
ENDLOOP.
ENDIF.
ENDIF.
APPEND is_detail TO it_detail.
CLEAR is_detail.
ENDLOOP.
ENDIF.
ENDDO.
* If no line item is selected
IF w_flag_sel IS INITIAL.
MESSAGE i000(ymmm) WITH text-025.
EXIT.
ENDIF.
CLEAR w_flag_sel.
IF it_detail[] IS INITIAL.
MESSAGE i000(ymmm) WITH text-009.
ELSE.
* Display the detail Report in the Secondary List
PERFORM sub_display_detail_report.
ENDIF.
* For Scheduling Agreement No., Delivery Completed Indicator
* is updated using ME32L transaction for 'ZLP' Order
* and 'ZLU' Order with open order quantity.
* Update Delivery Quantity with Schedule Quantity for ZLU Order
* where schedule quantity >0 and delivered quantity >=0 and not same
WHEN 'ENT'.
PERFORM sub_update_delivery_ind.
* Clicking 'BACK' in the Detail List
WHEN 'BACK1'.
sy-lsind = 0.
*PF-Status for Summary Report
SET PF-STATUS 'SUMMARY' .
* Print the Summary List
PERFORM sub_summary_list.
ENDCASE.
************************************************************************
* T O P O F P A G E
************************************************************************
TOP-OF-PAGE.
* Top Of Page for the Summary report
PERFORM sub_top_of_page_summ.
************************************************************************
* T O P O F P A G E D U R I N G L I N E S E L E C T I O N
************************************************************************
TOP-OF-PAGE DURING LINE-SELECTION.
IF sy-lsind = 1.
* Top Of Page for the Detail report
PERFORM sub_top_of_page_details.
ELSEIF sy-lsind = 0.
* Top Of Page for the Summary report
PERFORM sub_top_of_page_summ.
ENDIF.
INCLUDE ycmim040form.
*Text elements
*----------------------------------------------------------
* 001 Data Selection
* 002 Please enter a valid Company Code
* 003 Please enter a valid Plant
* 004 Please enter a valid Material type
* 005 Please enter a valid Material group
* 006 Please enter a valid Sch. Agreement No
* 007 Please enter a valid Vendor
* 008 Please enter a valid Material
* 009 No Suitable items found
* 010 Schedule Agreement are updated
* 011 Company
* 012 Document
* 013 Agreement No
* 014 Validity End
* 015 Code
* 016 Type
* 017 Date
* 018 Line item
* 019 Material Code
* 020 Plant
* 021 Sch. Ag Target Qty
* 022 Cum. GR Qty
* 023 Please enter Validity Start Date
* 024 Please enter Validity End Date
* 025 Please select at least one item
* 026 Processing Items
*Selection texts
*----------------------------------------------------------
* P_BUKRS D Company Code
* S_EBELN Sch. Agreement No
* S_KDATB Validity Start Date
* S_KDATE Validity End Date
* S_LIFNR D Vendor
* S_MATKL D Material group
* S_MATNR D Material
* S_MTART D Material type
* S_WERKS D Plant
*Messages
*----------------------------------------------------------
*
* Message class: YMMM
*000 & & & &
--------------------------------------------------------------------------------
--

You might also like