Go on link..

link us with ...

Tuesday, December 21, 2010

Material Requirement List With Pending Orders

REPORT zmat_req.
*REPORT z62mr023_mat_req_list .

*---------------------------------------------------------------------*
* MODULE : MM. *
*---------------------------------------------------------------------*
* Material Requirement List With Pending Orders *
* *
* *
* Date Created 20/08/2002 *
* Consultant Mr. Suruchiraj *
* Author
* Location EMIL/Mumbai. *
* LDB ..... *
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Amendment History *
*---------------------------------------------------------------------*
* Who/date Reason *
* ¯¯¯¯¯¯¯¯¯¯ ¯¯¯¯¯¯ *
* XXXXDDMMYYYY Where xxxx = developers initials...................... *
* ...................................................... *
* *
* XXXXDDMMYYYY ..................................................... *
* ...................................................... *
*---------------------------------------------------------------------*

*---------------------------------------------------------------------*
* Tables *
*---------------------------------------------------------------------*
TABLES: resb,
mbew,
marc,
mara,
makt,
ekpo,
eket,
lfa1,
t023,
ekko.

*---------------------------------------------------------------------*
* Data Statments *
*---------------------------------------------------------------------*
*---Internal table to select requirements data
DATA: BEGIN OF it_init_data OCCURS 10,
matnr LIKE resb-matnr,
werks LIKE resb-werks,
ekgrp LIKE resb-ekgrp,
bdter LIKE resb-bdter,
bdmng LIKE resb-bdmng,
enmng LIKE resb-enmng,
lbkum LIKE mbew-lbkum,
meins LIKE mara-meins,
maktx LIKE makt-maktx,
rsnum LIKE resb-rsnum,
END OF it_init_data.

DATA: BEGIN OF it_repo OCCURS 10,
matnr LIKE resb-matnr,
werks LIKE resb-werks,
ekgrp LIKE resb-ekgrp,
bdter LIKE resb-bdter,
w_month1(6),
bdmng LIKE resb-bdmng,
enmng LIKE resb-enmng,
lbkum LIKE mbew-lbkum,
maktx LIKE makt-maktx,
short LIKE resb-bdmng,
rsnum LIKE resb-rsnum,
ebeln LIKE eket-ebeln,
ebelp LIKE eket-ebelp,
eindt LIKE eket-eindt,
menge LIKE eket-menge,
meins LIKE ekpo-meins,
lifnr LIKE ekko-lifnr,
name1 LIKE lfa1-name1,
banfn LIKE eban-banfn,
bnfpo LIKE eban-bnfpo,
menge_req LIKE eban-menge,
lfdat LIKE eban-lfdat,
END OF it_repo.

DATA: BEGIN OF it_eket OCCURS 10,
lifnr LIKE ekko-lifnr,
ebeln LIKE eket-ebeln,
ebelp LIKE eket-ebelp,
eindt LIKE eket-eindt,
menge LIKE eket-menge,
wemng LIKE eket-wemng,
meins LIKE ekpo-meins,
END OF it_eket.

DATA: BEGIN OF it_eban OCCURS 10,
banfn LIKE eban-banfn,
bnfpo LIKE eban-bnfpo,
menge LIKE eban-menge,
lfdat LIKE eban-lfdat,
bsmng LIKE eban-bsmng,
meins LIKE eban-meins,
END OF it_eban.

DATA: w_lin TYPE i,
w_month(2),
w_month1(3),
w_bal LIKE mbew-lbkum,
w_req LIKE resb-bdmng,
w_iss LIKE resb-enmng,
w_bdmng LIKE resb-bdmng,
w_bdmng1 LIKE resb-bdmng,
w_bal_qty LIKE eket-wemng,
w_req_qty LIKE eban-menge,
w_matnr LIKE ekpo-matnr,
w_werks LIKE ekpo-werks,
w_count TYPE i,
flag.

* Begin of Addition Nigel D'Souza 22.01.03(SBS, S'pore )
DATA : w_year(4).
* End of Addition Nigel D'Souza


*---------------------------------------------------------------------*
* INITIALIZATION *
*---------------------------------------------------------------------*
INITIALIZATION.

SKIP 2.
SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE text-001.

*---------------------------------------------------------------------*
* SELECTION-OPTION *
*---------------------------------------------------------------------*
SELECT-OPTIONS:
* Start of Changes - Giri (2002/12/20)
* so_matnr FOR resb-matnr OBLIGATORY,
so_matnr FOR resb-matnr ,
so_matkl FOR t023-matkl,
so_baugr FOR resb-baugr,
* End of Changes - Giri (2002/12/20)
so_werks FOR resb-werks OBLIGATORY
NO-EXTENSION NO INTERVALS,
so_bdter FOR resb-bdter,
so_ekgrp FOR resb-ekgrp,
so_dispo FOR marc-dispo,
so_mtart FOR mara-mtart.


SELECTION-SCREEN END OF BLOCK 1.

* begin of changes Nigel 10.01.2003
SELECTION-SCREEN BEGIN OF BLOCK 2 WITH FRAME TITLE text-100.
PARAMETERS : p_ar RADIOBUTTON GROUP type,
p_sb RADIOBUTTON GROUP type,
p_bt RADIOBUTTON GROUP type.


SELECTION-SCREEN END OF BLOCK 2.
* end of Change Nigel 10.01.2003
*---------------------------------------------------------------------*
* START-OF-SELECTION *
*---------------------------------------------------------------------*
START-OF-SELECTION.

PERFORM data_collction.
PERFORM build_disp_table.
PERFORM data_display.

*----------------------------------------------------------------------*
* TOP-OF-PAGE *
*----------------------------------------------------------------------*

TOP-OF-PAGE.

WRITE : sy-uline.
FORMAT COLOR COL_HEADING INTENSIFIED OFF.
WRITE :/ sy-vline NO-GAP,
'Plnt',
'Material/Desc',
26 'Month',
37 'Current Stock',
58 'Requirements',
76 'Cummulative Shortages',
100 sy-vline.
FORMAT COLOR COL_HEADING INTENSIFIED OFF.
WRITE :/ sy-vline NO-GAP,
7 'Pending PO',
26 'Srno.',
37 'Pend.PO Quantity',
58 'Schd Del. Date',
100 sy-vline.
WRITE : sy-uline.

*---------------------------------------------------------------------*
* AT LINE-SELECTION *
*---------------------------------------------------------------------*
AT LINE-SELECTION.

*---Change Purchase Order (ME22N)
IF NOT it_repo-ebeln IS INITIAL.
SET PARAMETER ID 'BES' FIELD it_repo-ebeln.
* Start of Changes - Giri (2002/12/20)
* CALL TRANSACTION 'ME22N' AND SKIP FIRST SCREEN.
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
* End of Changes - Giri (2002/12/20)
CLEAR: it_repo-ebeln.
ENDIF.

*---Change Purchase Requisition (ME53N)
IF NOT it_repo-banfn IS INITIAL.
SET PARAMETER ID 'BAN' FIELD it_repo-banfn.
CALL TRANSACTION 'ME53N' AND SKIP FIRST SCREEN.
CLEAR: it_repo-banfn.
ENDIF.

*---Stock Overview (MMBE)
IF NOT it_repo-matnr IS INITIAL AND
NOT it_repo-werks IS INITIAL.
SET PARAMETER ID 'MAT' FIELD it_repo-matnr.
SET PARAMETER ID 'WRK' FIELD it_repo-werks.
CALL TRANSACTION 'MMBE' AND SKIP FIRST SCREEN.
CLEAR: it_repo-matnr, it_repo-werks.
ENDIF.


*&---------------------------------------------------------------------*
*& Form data_collction
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text *----------------------------------------------------------------------* FORM data_collction. * begin of CHange Nigel 10.01.2003 IF p_ar = 'X'. SELECT matnr werks bdter bdmng enmng rsnum meins FROM resb CLIENT SPECIFIED INTO CORRESPONDING FIELDS OF TABLE it_init_data WHERE mandt EQ sy-mandt AND matnr IN so_matnr AND werks EQ so_werks-low * Start of Changes - Giri (2002/12/20) AND baugr IN so_baugr AND xloek EQ space AND kzear EQ space * End of Changes - Giri (2002/12/20) AND bdter IN so_bdter * bEGIN OF CHANGE NIGEL 10.01.2003 AND bdart = 'AR'. * END OF CHANGE NIGEL 10.01.2003 ELSEIF p_sb = 'X'. SELECT matnr werks bdter bdmng enmng rsnum meins FROM resb CLIENT SPECIFIED INTO CORRESPONDING FIELDS OF TABLE it_init_data WHERE mandt EQ sy-mandt AND matnr IN so_matnr AND werks EQ so_werks-low * Start of Changes - Giri (2002/12/20) AND baugr IN so_baugr AND xloek EQ space AND kzear EQ space * End of Changes - Giri (2002/12/20) AND bdter IN so_bdter * bEGIN OF CHANGE NIGEL 10.01.2003 AND bdart = 'SB'. * END OF CHANGE NIGEL 10.01.2003 ELSEIF p_bt = 'X'. SELECT matnr werks bdter bdmng enmng rsnum meins FROM resb CLIENT SPECIFIED INTO CORRESPONDING FIELDS OF TABLE it_init_data WHERE mandt EQ sy-mandt AND matnr IN so_matnr AND werks EQ so_werks-low * Start of Changes - Giri (2002/12/20) AND baugr IN so_baugr AND xloek EQ space AND kzear EQ space * End of Changes - Giri (2002/12/20) AND bdter IN so_bdter * BEGIN OF CHANGE NIGEL 10.01.2003 AND ( bdart = 'AR' OR bdart = 'SB' ) . * END OF CHANGE NIGEL 10.01.2003 ENDIF. * END OF CHANGE NIGEL 10.01.2003 DESCRIBE TABLE it_init_data LINES w_lin. IF w_lin EQ 0. MESSAGE e398(00) WITH 'No data exists for given selection' space space space. ENDIF. LOOP AT it_init_data. *---Remove records for non matching of MRP Controller * and purchasing group SELECT SINGLE * FROM marc CLIENT SPECIFIED WHERE mandt EQ sy-mandt AND matnr EQ it_init_data-matnr AND werks EQ it_init_data-werks AND dispo IN so_dispo AND ekgrp IN so_ekgrp. IF sy-subrc <> 0.
DELETE it_init_data.
CONTINUE.
ENDIF.

*---Remove records for non matching of Material Type
SELECT SINGLE * FROM mara CLIENT SPECIFIED
WHERE mandt EQ sy-mandt
AND matnr EQ it_init_data-matnr
* Start of Changes - Giri (2002/12/20)
AND mtart IN so_matkl
* End of Changes - Giri (2002/12/20)
AND mtart IN so_mtart.
IF sy-subrc <> 0.
DELETE it_init_data.
CONTINUE.
ENDIF.

*---Find the material description
SELECT SINGLE * FROM makt CLIENT SPECIFIED
WHERE mandt EQ sy-mandt
AND matnr EQ it_init_data-matnr
AND spras EQ 'EN'.
MOVE makt-maktx TO it_init_data-maktx.
MODIFY it_init_data.

ENDLOOP.

ENDFORM. " data_collction
*&---------------------------------------------------------------------*
*& Form BUILD_DISP_TABLE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text *----------------------------------------------------------------------* FORM build_disp_table. SORT it_init_data BY werks matnr bdter rsnum. CLEAR: w_month, w_iss, w_count. LOOP AT it_init_data. AT NEW matnr. READ TABLE it_init_data INDEX sy-tabix. *---Find the total stock for the material SELECT SINGLE * FROM mbew CLIENT SPECIFIED WHERE mandt EQ sy-mandt AND matnr EQ it_init_data-matnr AND bwkey EQ it_init_data-werks. w_bal = mbew-lbkum. *---Find the material description SELECT SINGLE * FROM makt CLIENT SPECIFIED WHERE mandt EQ sy-mandt AND matnr EQ it_init_data-matnr AND spras EQ 'EN'. CLEAR it_repo. MOVE: it_init_data-matnr TO it_repo-matnr, it_init_data-werks TO it_repo-werks, it_init_data-meins TO it_repo-meins, mbew-lbkum TO it_repo-lbkum, makt-maktx TO it_repo-maktx. flag = 'X'. ENDAT. IF it_init_data-bdter+4(2) NE w_month * AND W_COUNT <= 3 AND flag = ' '. *---This perform is added to convert month in words PERFORM month_in_word. * Begin of Change Nigel D'Souza 22.01.03(SBS, S'pore ) * it_repo-w_month1 = w_month1. CONCATENATE w_year w_month1 INTO it_repo-w_month1. * End of Change Nigel D'Souza it_repo-bdmng = w_req - w_iss. it_repo-short = it_repo-bdmng - w_bal. IF it_repo-short < short =" 0." short =" it_repo-short" w_bal =" w_bal" w_count =" w_count" w_month =" it_init_data-bdter+4(2)." w_year =" it_init_data-bdter+0(4)." w_req =" w_req" w_iss =" w_iss" flag =" '" w_matnr =" it_init_data-matnr." w_werks =" it_init_data-werks." w_month1 =" w_month1." bdmng =" w_req" short =" it_repo-bdmng" short =" 0." short =" it_repo-short" w_bal_qty =" it_eket-menge" w_req_qty =" it_eban-menge"> p1 text
* <-- p2 text *----------------------------------------------------------------------* FORM data_display. LOOP AT it_repo. IF it_repo-matnr NE ' '. WRITE:/ sy-vline NO-GAP, 100 sy-vline NO-GAP. FORMAT COLOR COL_HEADING INTENSIFIED OFF. WRITE:/ sy-vline NO-GAP, it_repo-werks. FORMAT HOTSPOT ON. WRITE: it_repo-matnr. FORMAT HOTSPOT OFF. WRITE: it_repo-maktx, 100 sy-vline NO-GAP. HIDE: it_repo-matnr, it_repo-werks. ENDIF. IF it_repo-w_month1 NE ' '. IF it_repo-short <> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM month_in_word.

* begin of CHange - Nigel D'Souza 27.01.03
* IF w_month = '01'.
* w_month1 = 'Jan'.
* ELSEIF w_month = '02'.
* w_month1 = 'Feb'.
* ELSEIF w_month = '03'.
* w_month1 = 'Mar'.
* ELSEIF w_month = '04'.
* w_month1 = 'Apr'.
* ELSEIF w_month = '05'.
* w_month1 = 'May'.
* ELSEIF w_month = '06'.
* w_month1 = 'Jun'.
* ELSEIF w_month = '07'.
* w_month1 = 'Jul'.
* ELSEIF w_month = '08'.
* w_month1 = 'Aug'.
* ELSEIF w_month = '09'.
* w_month1 = 'Sep'.
* ELSEIF w_month = '10'.
* w_month1 = 'Oct'.
* ELSEIF w_month = '11'.
* w_month1 = 'Nov'.
* ELSEIF w_month = '12'.
* w_month1 = 'Dec'.
* ENDIF.

IF w_month = '01'.
w_month1 = '01'.
ELSEIF w_month = '02'.
w_month1 = '02'.
ELSEIF w_month = '03'.
w_month1 = '03'.
ELSEIF w_month = '04'.
w_month1 = '04'.
ELSEIF w_month = '05'.
w_month1 = '05'.
ELSEIF w_month = '06'.
w_month1 = '06'.
ELSEIF w_month = '07'.
w_month1 = '07'.
ELSEIF w_month = '08'.
w_month1 = '08'.
ELSEIF w_month = '09'.
w_month1 = '09'.
ELSEIF w_month = '10'.
w_month1 = '10'.
ELSEIF w_month = '11'.
w_month1 = '11'.
ELSEIF w_month = '12'.
w_month1 = '12'.
ENDIF.

* end of change - Nigel D'Souza

ENDFORM. " MONTH_IN_WORD

No comments:

link us...

For Visitors

if you want to publish or Add something on ERP, SAP , SAP FUNCTIONAL, SAP ABAP then mail us along with your email-id. contain must be yours

email-id :- avinashkr_raj@yahoo.com(any email)

email-id :- avinaskr_raj.abap@blogger.com ( use only gmail)