*&---------------------------------------------------------------------*
*& Report ZVVF_MMRO_BATCHSTOCK *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
*-------------------------------------------------------------*
* 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.
*
*--------------------------------------------------------------*
* Amendent History
*--------------------------------------------------------------*
*--------------------------------------------------------------*
* Transaction Code : ZBATCHSTOCK
*--------------------------------------------------------------*
REPORT ZVVF_MMRO_BATCHSTOCK
NO STANDARD PAGE HEADING
LINE-SIZE 150
LINE-COUNT 65(1)
MESSAGE-ID zfi.
*-------------
* 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 < tempmenge =" 0." werks =" i_werks-werks." name1 =" i_werks-name1." matnr =" i_matnr-matnr." maktx =" i_umatnr-maktx." charg =" i_charg-charg." menge =" tempmenge." transit =" 'X'" werks =" i_werks-werks." werks =" i_werks-werks" matnr =" i_matnr-matnr." werks =" i_werks-werks" matnr =" i_matnr-matnr" charg =" i_charg-charg" bwart =" '641'" shkzg =" 'S'" tempmenge1 =" tempmenge1" bwart =" '642'" shkzg =" 'H'" tempmenge1 =" tempmenge1" bwart =" '101'" bwart =" '102'" bwart =" '801'" bwart =" '802'" shkzg =" 'S'" tempmenge1 =" tempmenge1" tempmenge1 =" tempmenge1" matnr =" i_matnr-matnr." matnr =" i_matnr-matnr." tempmenge1 =" tempmenge1" tempmenge1 =" 0." werks =" i_werks-werks." name1 =" i_werks-name1." matnr =" i_matnr-matnr." maktx =" i_umatnr-maktx." charg =" i_charg-charg." menge =" tempmenge1." phyintr =" 'X'" werks =" i_werks-werks." werks =" i_werks-werks" matnr =" i_matnr-matnr." werks =" i_werks-werks" matnr =" i_matnr-matnr" charg =" i_charg-charg." tempmenge =" tempmenge" werks =" i_werks-werks" matnr =" i_matnr-matnr" charg =" i_charg-charg"> 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 < tempmenge1 =" 0." tempmenge =" tempmenge" matnr =" i_matnr-matnr." matnr =" i_matnr-matnr." tempmenge =" tempmenge" werks =" i_werks-werks." name1 =" i_werks-name1." matnr =" i_matnr-matnr." maktx =" i_umatnr-maktx." charg =" i_charg-charg." menge =" tempmenge." menge =" 0." t_menge =" t_menge" w_value =" (" pagno =" 1" pstock =" 'X'" transit =" 'X'" phyintr =" 'X'" w_gotrate =" 'N'." zmatnr =" i_fintab-matnr" zdel_plant =" i_fintab-werks" zmrp_ind =" i_fintab-charg+1(1)" zyear =" i_fintab-charg+4(2)." zmatnr =" i_fintab-matnr" zdel_plant =" i_fintab-werks" mrp_ind =" i_fintab-charg+1(1)" zyear =" i_fintab-charg+4(2)." w_gotrate =" 'Y'." werks =" i_fintab-werks." zmatnr =" i_fintab-matnr" zregio =" regio_tab-regio" zmrp_ind =" i_fintab-charg+1(1)" zyear =" i_fintab-charg+4(2)." zmatnr =" i_fintab-matnr" zregio =" regio_tab-regio" mrp_ind =" i_fintab-charg+1(1)" zyear =" i_fintab-charg+4(2)." w_gotrate =" 'Y'." zmatnr =" i_fintab-matnr" zcountry =" 'IN'" zmrp_ind =" i_fintab-charg+1(1)" zyear =" i_fintab-charg+4(2)." zmatnr =" i_fintab-matnr" zcountry =" 'IN'" mrp_ind =" i_fintab-charg+1(1)" zyear =" i_fintab-charg+4(2).">
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
Go on link..
link us with ...
Thursday, December 30, 2010
Batchwise Stock for given Material , Plant , Date and Batch combination. in MM module
Labels:
MM Reports
Subscribe to:
Post Comments (Atom)
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)
email-id :- avinashkr_raj@yahoo.com(any email)
email-id :- avinaskr_raj.abap@blogger.com ( use only gmail)
No comments:
Post a Comment