Go on link..

link us with ...

Thursday, December 30, 2010

BATCHWISE STOCK REPORT IN MM Module



*-------------------------------------------------------------*
* BATCHWISE STOCK REPORT
*-------------------------------------------------------------*
* 1. Functional area : MM
* 2. Name of Client :
* 3. Program details :
* 4. Program Description :
*--------------------------------------------------------------*
* Batchwise Stock Report.
*--------------------------------------------------------------*
* Content : Batchwise Stock Report..
*--------------------------------------------------------------*
* MODULE : MM .
*--------------------------------------------------------------*
* Title
* -----
* Calculation of Batchwise Stock for given Material , Plant ,
* Date and Batch combination.
*--------------------------------------------------------------*
* Description
* -----------
*
* This report calculates Batchwise Stock for given user input.
* User can get Physical Batchwise Stock , Intransit Batchwise Stock
* or Physical and Intransit Batchwise Stock.
* Batch is 8 char code having each char a significant meaning.
* First Char is Manufacturing Plant.
* Second Char is MRP Set.
* Third and Fourth Char are Manufacturing Month.
* Fifth and Sixth Char are Manufacturing Year.
*
* User can filter output on these parameters also.
*
* Output shows Plant and its Description, Material and its Descrition,
* Batch NO, Batch Quantity and Batch details.
*
* Calculation of Batch Physical Stock-
* Current Batchwise stock is in table MSLB.
* Then considering all the transactions from given date to system date
* Batchwise Physical Stock is Calculated for given date.
*
* Calculation of Batch Intransit Stock -
* For Calculating Batchwise Intransit Stock it considers all the
* transaction from mseg for user input . Then it calcultes stock as
* transactions of 641 and 642 movement type -
* transactions of 101, 102, 801, 802 movement type.
*
*
*--------------------------------------------------------------*
* Transaction Code : ZBATCHSTOCK
*--------------------------------------------------------------*

REPORT ZMMRO_BATCHSTOCKT
NO STANDARD PAGE HEADING
LINE-SIZE 150
LINE-COUNT 65(1).

*-------------
* Tables used
*-------------

TABLES: mseg,mara,mkpf.

DATA : BEGIN OF i_char OCCURS 0,
char1 TYPE c,
char2(2) TYPE c,
END OF i_char.

SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_matnr FOR mseg-matnr,
s_werks FOR mseg-werks,
s_budat FOR mkpf-budat,
s_matkl FOR mara-matkl,
s_charg FOR mseg-charg,
s_lgort FOR mseg-lgort.

SELECTION-SCREEN SKIP 1.

SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE text-003.
SELECT-OPTIONS: char1 FOR i_char-char1,
char2 FOR i_char-char1,
char3 FOR i_char-char2,
char4 FOR i_char-char2.
SELECTION-SCREEN END OF BLOCK blk2 .

PARAMETER: pd_meins LIKE mseg-meins OBLIGATORY.
SELECTION-SCREEN END OF BLOCK blk1 .

SELECTION-SCREEN SKIP 1.

SELECTION-SCREEN BEGIN OF BLOCK blk3 WITH FRAME TITLE text-002.
PARAMETER : pstock RADIOBUTTON GROUP grp, "physical stock
transit RADIOBUTTON GROUP grp, " transit stock
phyintr RADIOBUTTON GROUP grp. " physical + intransit
SELECTION-SCREEN END OF BLOCK blk3 .


DATA : BEGIN OF i_batch OCCURS 0,
sign(1),
option(2),
low(6),
high(6),
END OF i_batch.

DATA : BEGIN OF i_mchb OCCURS 0,
matnr LIKE mseg-matnr,
werks LIKE mseg-werks,
charg LIKE mseg-charg,
clabs LIKE mchb-clabs,
cspem LIKE mchb-cspem,
END OF i_mchb.

DATA : BEGIN OF i_mseg OCCURS 0,
mblnr LIKE mseg-mblnr,
zeile LIKE mseg-zeile,
matnr LIKE mseg-matnr,
werks LIKE mseg-werks,
charg LIKE mseg-charg,
bwart LIKE mseg-bwart,
shkzg LIKE mseg-shkzg,
budat LIKE mkpf-budat,
menge LIKE mseg-menge,
END OF i_mseg.

DATA : BEGIN OF i_intransit OCCURS 0,
mblnr LIKE mseg-mblnr,
zeile LIKE mseg-zeile,
matnr LIKE mseg-matnr,
werks LIKE mseg-werks,
charg LIKE mseg-charg,
bwart LIKE mseg-bwart,
shkzg LIKE mseg-shkzg,
budat LIKE mkpf-budat,
menge LIKE mseg-menge,
END OF i_intransit.


DATA : BEGIN OF i_matnr OCCURS 0,
werks LIKE mseg-werks,
matnr LIKE mseg-matnr,
END OF i_matnr.

DATA : BEGIN OF i_umatnr OCCURS 0,
matnr LIKE mseg-matnr,
maktx LIKE makt-maktx,
END OF i_umatnr.

DATA : BEGIN OF i_werks OCCURS 0,
werks LIKE mseg-werks,
name1 LIKE t001w-name1,
END OF i_werks.

DATA : BEGIN OF i_charg OCCURS 0,
werks LIKE mseg-werks,
matnr LIKE mseg-matnr,
charg LIKE mseg-charg,
END OF i_charg.

DATA : BEGIN OF i_fintab OCCURS 0,
werks LIKE mseg-werks,
name1 LIKE t001w-name1,
matnr LIKE mseg-matnr,
maktx LIKE makt-maktx,
charg LIKE mseg-charg,
menge LIKE mseg-menge,
END OF i_fintab.

DATA : BEGIN OF i_marm OCCURS 0,
matnr LIKE mseg-matnr,
umren LIKE marm-umren,
umrez LIKE marm-umrez,
END OF i_marm.

DATA : BEGIN OF regio_tab OCCURS 0,
regio LIKE zmrp_sku-zregio,
END OF regio_tab.

DATA : sysdate LIKE mkpf-budat,
tempmenge LIKE mseg-menge,
tempmenge1 LIKE mseg-menge,
t_menge LIKE mseg-menge,
w_zmrp_price LIKE zmrp_sku-zmrp_price,
w_value LIKE zmrp_sku-zmrp_price,
v_mblnr LIKE mseg-mblnr,
v_zeile LIKE mseg-zeile.

AT SELECTION-SCREEN.

INITIALIZATION.


START-OF-SELECTION.

* IF NOT ( char1-low IS INITIAL ).
* i_batch-sign = 'I'.
*
* IF ( char1-high IS INITIAL ).
* i_batch-option = 'EQ'.
* ELSE.
* i_batch-option = 'BT'.
* ENDIF.
*
* i_batch-low+0(1) = char1-low.
* i_batch-low+1(1) = char2-low.
* i_batch-low+2(2) = char3-low.
* i_batch-low+4(2) = char4-low.
*
* i_batch-high+0(1) = char1-high.
* i_batch-high+1(1) = char2-high.
* i_batch-high+2(2) = char3-high.
* i_batch-high+4(2) = char4-high.
*
* APPEND i_batch.
* ENDIF.

PERFORM extractdata.

PERFORM process1.

PERFORM process2.

PERFORM output.

* WRITE: 'samir'.
*---------------------------------------------------------------------*
* FORM extractdata *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM extractdata.

SELECT a~matnr a~werks a~charg a~clabs a~cspem
INTO CORRESPONDING FIELDS OF TABLE i_mchb
FROM mchb AS a
INNER JOIN mara AS b
ON a~matnr = b~matnr
WHERE a~matnr IN s_matnr
AND a~werks IN s_werks
AND a~charg IN s_charg
AND b~matkl IN s_matkl
AND a~lgort IN s_lgort.

sysdate = sy-datum.

SELECT a~mblnr a~zeile a~matnr a~werks
a~charg a~bwart a~shkzg b~budat a~menge
INTO CORRESPONDING FIELDS OF TABLE i_mseg
FROM mseg AS a
INNER JOIN mkpf AS b
ON a~mblnr = b~mblnr
INNER JOIN mara AS c
ON a~matnr = c~matnr
WHERE a~matnr IN s_matnr
AND a~werks IN s_werks
AND a~charg IN s_charg
AND b~budat >= s_budat-low
AND b~budat <= sysdate
AND c~matkl IN s_matkl
AND a~lgort IN s_lgort.

LOOP AT i_mseg.
IF ( i_mseg-charg = space ).

CLEAR : v_mblnr, v_zeile.
v_mblnr = i_mseg-mblnr.
v_zeile = i_mseg-zeile.
v_zeile = v_zeile - 1.
SELECT SINGLE charg INTO i_mseg-charg
FROM mseg
WHERE mblnr = v_mblnr
AND zeile = v_zeile.
MODIFY i_mseg TRANSPORTING charg.
ENDIF.
ENDLOOP.


LOOP AT i_mchb.

IF NOT ( char1 IS INITIAL ) .
IF NOT ( i_mchb-charg+0(1) IN char1 ).
DELETE i_mchb.
CONTINUE.
ENDIF.
ENDIF.

IF NOT ( char2 IS INITIAL ) .
IF NOT ( i_mchb-charg+1(1) IN char2 ).
DELETE i_mchb.
CONTINUE.
ENDIF.
ENDIF.

IF NOT ( char3 IS INITIAL ) .
IF NOT ( i_mchb-charg+2(2) IN char3 ).
DELETE i_mchb.
CONTINUE.
ENDIF.
ENDIF.

IF NOT ( char4 IS INITIAL ) .
IF NOT ( i_mchb-charg+4(2) IN char4 ).
DELETE i_mchb.
CONTINUE.
ENDIF.
ENDIF.

ENDLOOP.


LOOP AT i_mseg.

IF NOT ( char1 IS INITIAL ) .
IF NOT ( i_mseg-charg+0(1) IN char1 ).
DELETE i_mseg.
CONTINUE.
ENDIF.
ENDIF.

IF NOT ( char2 IS INITIAL ) .
IF NOT ( i_mseg-charg+1(1) IN char2 ).
DELETE i_mseg.
CONTINUE.
ENDIF.
ENDIF.

IF NOT ( char3 IS INITIAL ) .
IF NOT ( i_mseg-charg+2(2) IN char3 ).
DELETE i_mseg.
CONTINUE.
ENDIF.
ENDIF.

IF NOT ( char4 IS INITIAL ) .
IF NOT ( i_mseg-charg+4(2) IN char4 ).
DELETE i_mseg.
CONTINUE.
ENDIF.
ENDIF.

ENDLOOP.


i_intransit[] = i_mseg[].

ENDFORM.

*---------------------------------------------------------------------*
* FORM process1 *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM process1.

LOOP AT i_mchb.

i_matnr-werks = i_mchb-werks.
i_matnr-matnr = i_mchb-matnr.
APPEND i_matnr.

i_werks-werks = i_mchb-werks.
APPEND i_werks.

i_charg-werks = i_mchb-werks.
i_charg-matnr = i_mchb-matnr.
i_charg-charg = i_mchb-charg.
APPEND i_charg.

i_umatnr-matnr = i_mchb-matnr.
APPEND i_umatnr.

ENDLOOP.


LOOP AT i_mseg.

i_matnr-werks = i_mseg-werks.
i_matnr-matnr = i_mseg-matnr.
APPEND i_matnr.

i_werks-werks = i_mseg-werks.
APPEND i_werks.

i_charg-werks = i_mseg-werks.
i_charg-matnr = i_mseg-matnr.
i_charg-charg = i_mseg-charg.
APPEND i_charg.

i_umatnr-matnr = i_mseg-matnr.
APPEND i_umatnr.

ENDLOOP.

SORT i_matnr BY werks matnr.
SORT i_werks BY werks.
SORT i_charg BY werks matnr charg.
SORT i_umatnr BY matnr.

DELETE ADJACENT DUPLICATES FROM i_matnr COMPARING werks matnr.
DELETE ADJACENT DUPLICATES FROM i_werks COMPARING werks.
DELETE ADJACENT DUPLICATES FROM i_charg COMPARING werks matnr charg.
DELETE ADJACENT DUPLICATES FROM i_umatnr COMPARING matnr.

LOOP AT i_werks.
SELECT SINGLE name1
INTO i_werks-name1
FROM t001w
WHERE werks = i_werks-werks.
MODIFY i_werks.
ENDLOOP.

LOOP AT i_umatnr.
SELECT SINGLE maktx
FROM makt
INTO i_umatnr-maktx
WHERE matnr = i_umatnr-matnr.
MODIFY i_umatnr.
ENDLOOP.

LOOP AT i_umatnr.
SELECT matnr umren umrez
APPENDING TABLE i_marm
FROM marm
WHERE matnr = i_umatnr-matnr
AND meinh = pd_meins.
ENDLOOP.


ENDFORM.


*---------------------------------------------------------------------*
* FORM process2 *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM process2.

IF ( pstock = 'X' ).

LOOP AT i_werks.
LOOP AT i_matnr WHERE werks = i_werks-werks.
LOOP AT i_charg WHERE werks = i_werks-werks
AND matnr = i_matnr-matnr.

CLEAR : tempmenge,
i_marm,
i_umatnr.

LOOP AT i_mchb WHERE werks = i_werks-werks
AND matnr = i_matnr-matnr
AND charg = i_charg-charg.

tempmenge = tempmenge + i_mchb-clabs
+ i_mchb-cspem.

ENDLOOP.

LOOP AT i_mseg WHERE werks = i_werks-werks
AND matnr = i_matnr-matnr
AND charg = i_charg-charg
AND budat > s_budat-high.

IF ( i_mseg-shkzg = 'S' ).
tempmenge = tempmenge - i_mseg-menge.
ELSE.
tempmenge = tempmenge + i_mseg-menge.
ENDIF.
ENDLOOP.

READ TABLE i_marm WITH KEY matnr = i_matnr-matnr.

READ TABLE i_umatnr WITH KEY matnr = i_matnr-matnr.

tempmenge = tempmenge * i_marm-umren / i_marm-umrez.

IF ( tempmenge < 0 ).
tempmenge = 0.
ENDIF.


i_fintab-werks = i_werks-werks.
i_fintab-name1 = i_werks-name1.
i_fintab-matnr = i_matnr-matnr.
i_fintab-maktx = i_umatnr-maktx.
i_fintab-charg = i_charg-charg.
i_fintab-menge = tempmenge.
APPEND i_fintab.
ENDLOOP.
ENDLOOP.
ENDLOOP.

ENDIF.

IF ( transit = 'X' ).

LOOP AT i_werks.
LOOP AT i_matnr WHERE werks = i_werks-werks.
LOOP AT i_charg WHERE werks = i_werks-werks
AND matnr = i_matnr-matnr.

CLEAR : tempmenge1,
i_marm ,
i_umatnr.


LOOP AT i_intransit WHERE werks = i_werks-werks
AND matnr = i_matnr-matnr
AND charg = i_charg-charg
AND budat IN s_budat.

IF ( i_intransit-bwart = '641' AND i_intransit-shkzg = 'S' ).
tempmenge1 = tempmenge1 + i_intransit-menge.
ELSEIF ( i_intransit-bwart = '642'
AND i_intransit-shkzg = 'H' ).
tempmenge1 = tempmenge1 - i_intransit-menge.
ENDIF.

IF ( i_intransit-bwart = '101' OR i_intransit-bwart = '102'
OR i_intransit-bwart = '801' OR i_intransit-bwart = '802' )
.

IF ( i_intransit-shkzg = 'S' ).
tempmenge1 = tempmenge1 - i_intransit-menge.
ELSE.
tempmenge1 = tempmenge1 + i_intransit-menge.
ENDIF.
ENDIF.

ENDLOOP.

READ TABLE i_marm WITH KEY matnr = i_matnr-matnr.

READ TABLE i_umatnr WITH KEY matnr = i_matnr-matnr.

tempmenge1 = tempmenge1 * i_marm-umren / i_marm-umrez.

IF ( tempmenge1 < 0 ).
tempmenge1 = 0.
ENDIF.

i_fintab-werks = i_werks-werks.
i_fintab-name1 = i_werks-name1.
i_fintab-matnr = i_matnr-matnr.
i_fintab-maktx = i_umatnr-maktx.
i_fintab-charg = i_charg-charg.
i_fintab-menge = tempmenge1.
APPEND i_fintab.
ENDLOOP.
ENDLOOP.
ENDLOOP.


ENDIF.

IF ( phyintr = 'X' ).

LOOP AT i_werks.
LOOP AT i_matnr WHERE werks = i_werks-werks.
LOOP AT i_charg WHERE werks = i_werks-werks
AND matnr = i_matnr-matnr.

CLEAR : tempmenge,
tempmenge1,
i_marm,
i_umatnr.

LOOP AT i_mchb WHERE werks = i_werks-werks
AND matnr = i_matnr-matnr
AND charg = i_charg-charg.

tempmenge = tempmenge + i_mchb-clabs
+ i_mchb-cspem.

ENDLOOP.

LOOP AT i_mseg WHERE werks = i_werks-werks
AND matnr = i_matnr-matnr
AND charg = i_charg-charg
AND budat > s_budat-high.

IF ( i_mseg-shkzg = 'S' ).
tempmenge = tempmenge - i_mseg-menge.
ELSE.
tempmenge = tempmenge + i_mseg-menge.
ENDIF.
ENDLOOP.

LOOP AT i_intransit WHERE werks = i_werks-werks
AND matnr = i_matnr-matnr
AND charg = i_charg-charg
AND budat IN s_budat.

IF ( i_intransit-bwart = '641' AND i_intransit-shkzg = 'S' ).
tempmenge1 = tempmenge1 + i_intransit-menge.
ELSEIF ( i_intransit-bwart = '642'
AND i_intransit-shkzg = 'H' ).
tempmenge1 = tempmenge1 - i_intransit-menge.
ENDIF.

IF ( i_intransit-bwart = '101' OR i_intransit-bwart = '102'
OR i_intransit-bwart = '801' OR
i_intransit-bwart = '802' ).

IF ( i_intransit-shkzg = 'S' ).
tempmenge1 = tempmenge1 - i_intransit-menge.
ELSE.
tempmenge1 = tempmenge1 + i_intransit-menge.
ENDIF.
ENDIF.

ENDLOOP.

IF ( tempmenge1 < 0 ).
tempmenge1 = 0.
ENDIF.

tempmenge = tempmenge + tempmenge1.

READ TABLE i_marm WITH KEY matnr = i_matnr-matnr.

READ TABLE i_umatnr WITH KEY matnr = i_matnr-matnr.

tempmenge = tempmenge * i_marm-umren / i_marm-umrez.

i_fintab-werks = i_werks-werks.
i_fintab-name1 = i_werks-name1.
i_fintab-matnr = i_matnr-matnr.
i_fintab-maktx = i_umatnr-maktx.
i_fintab-charg = i_charg-charg.
i_fintab-menge = tempmenge.
APPEND i_fintab.
ENDLOOP.
ENDLOOP.
ENDLOOP.


ENDIF.

ENDFORM.

*---------------------------------------------------------------------*
* FORM output *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM output.
FORMAT COLOR COL_NORMAL.

DELETE i_fintab WHERE menge = 0.

LOOP AT i_fintab.
WRITE:/1 sy-vline.
WRITE:2 i_fintab-werks.
WRITE:10 sy-vline.
WRITE:11 i_fintab-name1.
WRITE:25 sy-vline.
WRITE:26 i_fintab-matnr.
WRITE:35 sy-vline.
WRITE:36 i_fintab-maktx.
WRITE:55 sy-vline.
WRITE:56 i_fintab-charg.
WRITE:65 sy-vline.
WRITE:66 i_fintab-menge LEFT-JUSTIFIED.

t_menge = t_menge + i_fintab-menge.

WRITE:85 sy-vline.
WRITE:86 pd_meins.
WRITE:90 sy-vline.
WRITE:91 i_fintab-charg+0(1).
WRITE:100 sy-vline.
WRITE:101 i_fintab-charg+5(1). "1(1)
WRITE:110 sy-vline.
WRITE:111 i_fintab-charg+1(2). "2(2)
WRITE:120 sy-vline.
WRITE:121 i_fintab-charg+3(2). "3(2)
WRITE:130 sy-vline.
* - Bijoy - 22/05/2002 - MRP addition
CLEAR : w_zmrp_price, w_value.
* --- Price extraction routine
PERFORM getprice
USING
i_fintab-matnr
i_fintab-werks
CHANGING
w_zmrp_price.



w_value = ( w_zmrp_price * i_fintab-menge ) .

WRITE:131(11) w_zmrp_price.
WRITE:142 sy-vline.


SET LEFT SCROLL-BOUNDARY COLUMN 66.
ENDLOOP.

WRITE:/(142) sy-uline.
WRITE:/1 sy-vline.
WRITE:2 'TOTAL:'.
WRITE:65 t_menge LEFT-JUSTIFIED.
WRITE:142 sy-vline.
WRITE:/(142) sy-uline.

ENDFORM.


*WRITE:'samir'.
*-------------------*
TOP-OF-PAGE.
*-------------------*

IF ( sy-pagno = 1 ).

WRITE:/(80) sy-uline.

WRITE:/1 sy-vline.
WRITE:2 'From Material:'.
WRITE:30 s_matnr-low.
WRITE:50 'To:'.
WRITE:60 s_matnr-high.
WRITE:80 sy-vline.

WRITE:/1 sy-vline.
WRITE:2 'From Plant:'.
WRITE:30 s_werks-low.
WRITE:50 'To'.
WRITE:60 s_werks-high.
WRITE:80 sy-vline.

WRITE:/1 sy-vline.
WRITE:2 'From Date:'.
WRITE:30 s_budat-low.
WRITE:50 'To:'.
WRITE:60 s_budat-high.
WRITE:80 sy-vline.

WRITE:/1 sy-vline.
WRITE:2 'From Material Group:'.
WRITE:30 s_matkl-low.
WRITE:50 'To:'.
WRITE:60 s_matkl-high.
WRITE:80 sy-vline.

WRITE:/1 sy-vline.
WRITE:2 'From Batch:'.
WRITE:30 s_charg-low.
WRITE:50 'To:'.
WRITE:60 s_charg-high.
WRITE:80 sy-vline.

WRITE:/1 sy-vline.
WRITE:2 'From Manufacturing Plant:'.
WRITE:30 char1-low.
WRITE:50 'To:'.
WRITE:60 char1-high.
WRITE:80 sy-vline.

WRITE:/1 sy-vline.
WRITE:2 'From MRP Set:'.
WRITE:30 char2-low.
WRITE:50 'To:'.
WRITE:60 char2-high.
WRITE:80 sy-vline.

WRITE:/1 sy-vline.
WRITE:2 'From Manufacturing Month:'.
WRITE:30 char3-low.
WRITE:50 'To'.
WRITE:60 char3-high.
WRITE:80 sy-vline.

WRITE:/1 sy-vline.
WRITE:2 'From Manufacturing Year:'.
WRITE:30 char4-low.
WRITE:50 'To'.
WRITE:60 char4-high.
WRITE:80 sy-vline.

WRITE:/1 sy-vline.
IF ( pstock = 'X' ).
WRITE:30 'PHYSICAL STOCK'.
ENDIF.

IF ( transit = 'X' ).
WRITE:30 'INTRANSIT STOCK'.
ENDIF.

IF ( phyintr = 'X' ).
WRITE:30 'PHYSICAL + INTRANSIT STOCK'.
ENDIF.

WRITE:80 sy-vline.
WRITE:/(80) sy-uline.

FORMAT COLOR COL_HEADING.
WRITE:/(142) sy-uline.
WRITE:/1 sy-vline.
WRITE:2 'PLANT '.
WRITE:10 sy-vline.
WRITE:11 'PLANT DES'.
WRITE:25 sy-vline.
WRITE:26 'MATERIAL'.
WRITE:35 sy-vline.
WRITE:36 'MAT DESCRIPTION'.
WRITE:55 sy-vline.
WRITE:56 'BATCH'.
WRITE:65 sy-vline.
WRITE:66 'QUANTITY'.
WRITE:85 sy-vline.
WRITE:86 'UNIT'.
WRITE:90 sy-vline.
WRITE:91 'MFG PLANT'.
WRITE:100 sy-vline.
WRITE:101 'MRP SET'.
WRITE:110 sy-vline.
WRITE:111 'MFG MONTH'.
WRITE:120 sy-vline.
WRITE:121 'MFG YEAR'.
WRITE:130 sy-vline.
WRITE:131(11) 'MRP '.
WRITE:142 sy-vline.

WRITE:/(142) sy-uline.
FORMAT RESET.

ENDIF.
*-----------------------------------------*
FORM getprice USING i_fintab-matnr
i_fintab-werks
CHANGING w_zmrp_price.
*-----------------------------------------*
DATA : w_regio LIKE zmrp_sku-zregio,
w_gotrate(1).
*--- Check if rate is maintained at bottom most level

w_gotrate = 'N'.
* SELECT SINGLE zmrp_price INTO (w_zmrp_price)
* FROM zmrp_sku WHERE zmatnr = i_fintab-matnr
* AND zdel_plant = i_fintab-werks
* AND zmrp_ind = i_fintab-charg+1(1) " MRP Indicator
* AND zyear = i_fintab-charg+4(2). " Year of mfg.

SELECT SINGLE ZMRP_PRICE INTO (w_zmrp_price)
FROM ZVVF_VT027_ZMRP WHERE zmatnr = i_fintab-matnr
AND zdel_plant = i_fintab-werks
AND mrp_ind = i_fintab-charg+5(1) " MRP Indicator
AND zyear = i_fintab-charg+3(2). " Year of mfg.




* ZVVF_VT027_ZMRP

IF sy-subrc EQ 0.
w_gotrate = 'Y'.
ENDIF.

*-- Only move to next logical step if rate is not found
CHECK w_gotrate EQ 'N'.

*--- Check the depot belongs to which region
CLEAR : regio_tab.
SELECT regio
INTO TABLE regio_tab
FROM zwerks_region
WHERE werks = i_fintab-werks.

IF sy-subrc EQ 0. " Region exists

* check if rate is maintained at region level
LOOP AT regio_tab.
* SELECT SINGLE zmrp_price INTO (w_zmrp_price)
* FROM zmrp_sku WHERE zmatnr = i_fintab-matnr
* AND zregio = regio_tab-regio
* AND Zmrp_ind = i_fintab-charg+1(1) " MRP Indicator
* AND zyear = i_fintab-charg+4(2). " Year of mfg.

SELECT SINGLE zmrp_price INTO (w_zmrp_price)
FROM ZVVF_VT027_ZMRP WHERE zmatnr = i_fintab-matnr
AND zregio = regio_tab-regio
AND mrp_ind = i_fintab-charg+5(1) " MRP Indicator
AND zyear = i_fintab-charg+3(2)
and zdel_plant ne SPACE." ear of mfg.


IF sy-subrc EQ 0. " First record exit
w_gotrate = 'Y'.
EXIT.
ENDIF.

ENDLOOP.

ENDIF.

*-- Only move to next logical step if rate is not found
CHECK w_gotrate EQ 'N'.


* check if rate is maintained at country level
* SELECT SINGLE zmrp_price INTO (w_zmrp_price)
* FROM zmrp_sku WHERE zmatnr = i_fintab-matnr
* AND zcountry = 'IN'
* AND zmrp_ind = i_fintab-charg+1(1) " MRP Indicator
* AND zyear = i_fintab-charg+4(2). " Year of mfg.


SELECT SINGLE zmrp_price INTO (w_zmrp_price)
FROM ZVVF_VT027_ZMRP WHERE zmatnr = i_fintab-matnr
AND zcountry = 'IN'
AND mrp_ind = i_fintab-charg+5(1) " MRP Indicator
AND zyear = i_fintab-charg+3(2). " Year of mfg.


ENDFORM.

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)