Go on link..

link us with ...

Thursday, December 30, 2010

QUALITY_REGISTER IN MM

*&---------------------------------------------------------------------*
*& Report ZVVF_MMRO_QUALITY_REGISTER *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*

REPORT ZVVF_MMRO_QUALITY_REGISTER no standard page heading line-count 65(1) line-size 750.

*---------------
* COMMENT HEADER
*---------------

* PROGRAMMED BY :
* STARTING DATE :
* ENDING DATE : .


*------------------
* TABLE DESCRIPTION
*------------------
tables :
mseg, "Document Segment: Material
ekko, "Purchasing Document Header
adrc, "Addresses (central address admin.)
adrreggrpt, "Grouping of the regional structure (long texts)
lfa1, "Vendor Master (General Section)
qals, "Inspection lot record
qamv, "characteristic specs for inspection processing
mkpf,
qamr. "characteristic results during inspection processing

*-----------------
* DATA DECLARATION
*-----------------


data :
v_adrnr like lfa1-adrnr, "Adrress number to get Panel
v_regio like adrc-regiogroup, "Panel Code
v_descript like adrreggrpt-descript, "Panel Name
v_sumqty type p decimals 0. "Panelwise subtotal for qty

* Internal table for storing Inspection characteristic data
data : begin of itab_inspchar ,
inspcharname like qamv-verwmerkm,
inspcharvalue type f, "qamr-ANZWERTG
end of itab_inspchar.


* Internal table for storing Inspcharacteristic data heading
data : begin of itab_inspchar_heading occurs 0,
inspcharname(14),
colpos type i, "Column position to print data
sumqty like mseg-menge, "Sum of quantity Characterist
"wise for calculating wt avg
sumvalue type f , "Sum of Characteristic value
"for calculating wt avg
end of itab_inspchar_heading.

* Internal table for storing mseg table data
data : begin of itab_mseg occurs 10 ,
pono like mseg-ebeln, "Purchase Order Number
poitem like mseg-ebelp, "Purchase Order Item Number
grno like mseg-mblnr, "GR Number
qty like mseg-menge, "Quantity
plant like mseg-werks, "Plant
vendorcd like mseg-lifnr, "Vendor Code
mjahr like mseg-mjahr, "Material doc. year
zeile like mseg-zeile, "Item in material document
matnr like mseg-matnr,
lgort like mseg-lgort,
WERKS LIKE MSEG-WERKS,
CHARG LIKE MSEG-CHARG,
end of itab_mseg.

***--- Internal table for ekbe i.e. 102 and 122
data: begin of i_ekbe occurs 0,
ebeln like ekbe-ebeln,
belnr like ekbe-belnr,
bwart like ekbe-bwart,
lfbnr like ekbe-lfbnr,
matnr like ekbe-matnr,
werks like ekbe-werks,
end of i_ekbe.

* MAIN TABLE WHICH CONTAINS ALL THE RECORD DETAILS AND WHICH IS USED TO
* DISPLAY THE RECORD.
data : begin of itab_main occurs 10 ,
pono like mseg-ebeln, "Purchase Order Number
poitem like mseg-ebelp, "Purchase Order Item Number
grno like mseg-mblnr, "GR Number
qty like mseg-menge, "Quantity
plant like mseg-werks, "Plant
vendorcd like mseg-lifnr, "Vendor Code
mjahr like mseg-mjahr, "Material doc. year
zeile like mseg-zeile, "Item in material document
podt like ekko-bedat, "Purchase Order Date
grdt like mkpf-budat, "GR Date
vendornm like lfa1-name1, "Vendor Name
panelcd like adrc-regiogroup, "Panel Code
panelnm like adrreggrpt-descript, "Panel Name
menge like ekpo-menge,
kwert like konv-kwert,
meins like ekpo-meins,
lgort like mseg-lgort,
itab_inspchar like itab_inspchar occurs 0,
frbnr like mkpf-frbnr, " Truck No
bldat like mkpf-bldat, "By Mandar (Doc. Date)
WERKS LIKE MSEG-WERKS,
MATNR LIKE MSEG-MATNR,
PRUEFLOS LIKE QALS-PRUEFLOS,
CHARG LIKE MSEG-CHARG,
end of itab_main .

data : begin of i_qamv occurs 0,
prueflos like qals-prueflos,
merknr like qamv-merknr,
verwmerkm like qamv-verwmerkm,
end of i_qamv.

data : begin of i_qamr occurs 0,
mittelwert like qamr-mittelwert,
anzwertg like qamr-anzwertg,
end of i_qamr.

data: begin of i_ekpo occurs 0,
ebeln like ekpo-ebeln,
* ebelp LIKE ekpo-ebelp,
kposn like konv-kposn,
knumv like ekko-knumv,
menge like ekpo-menge,
meins like ekpo-meins,
end of i_ekpo.

data : begin of i_konv occurs 0,
knumv like konv-knumv,
kposn like konv-kposn,
kschl like konv-kschl,
kwert like konv-kwert,
end of i_konv.

data: v_col type i,
w_string(30).

start-of-selection.

*---------------
* SELECT OPTIONS
*---------------

select-options :
s_plant for mseg-werks, " Plant
s_lgort for mseg-lgort, " Storage location
s_matno for mseg-matnr, " Material
s_date for ekko-bedat, " PO date
s_grdt for mkpf-budat, " GR Date
s_vncd for mseg-lifnr, " Vendor
s_panel for adrc-regiogroup. " Panel Code
parameters: p_check as checkbox, " mass balancing
r_check as checkbox. " Rejection loads

* To get PO number, PO Item number, Material, Vendor, Quantity & Plant
* from mseg.

select ebeln ebelp mblnr menge werks lifnr mjahr zeile matnr lgort WERKS CHARG
from mseg
into table itab_mseg
where werks in s_plant and matnr in s_matno and
lifnr in s_vncd and bwart = '101'
and lgort in s_lgort.


***---------------
***--- Changes by Samira on 30 May 2002
***--- Changes to exclude those 101 GR that are cancelled by 102 and 122
if ( p_check = 'X' ).
select ebeln belnr bwart lfbnr matnr werks
into table i_ekbe
from ekbe
where matnr in s_matno and
werks in s_plant and
( bwart = '102' or bwart = '122' ).

loop at i_ekbe.
delete itab_mseg where grno = i_ekbe-lfbnr
and matnr = i_ekbe-matnr.
endloop.


endif.
***---------------

***---------------
***--- Changes by Samira on 10 June 2002
***--- Changes to show rejectiuon loads only
if ( r_check = 'X' ).
select ebeln belnr bwart lfbnr matnr werks
into table i_ekbe
from ekbe
where matnr in s_matno and
werks in s_plant and
bwart = '122' .

loop at itab_mseg.
read table i_ekbe with key lfbnr = itab_mseg-grno
matnr = itab_mseg-matnr.
if ( sy-subrc ne 0 ).
delete itab_mseg.
endif.

endloop.

endif.
***---------------



* To get PO date, GR Date, Vendor Name, Panel Code, Panel Name and
* Inspection characteristic from the tables.

loop at itab_mseg.
move-corresponding itab_mseg to itab_main.

SELECT SINGLE PRUEFLOS INTO ITAB_MAIN-PRUEFLOS FROM QALS WHERE MATNR = ITAB_MAIN-MATNR AND
CHARG = ITAB_MAIN-CHARG.

* To get PO Date.
select single bedat into itab_main-podt from ekko where
ebeln = itab_main-pono.

* To get GR Date.
select single budat into itab_main-grdt from mkpf where
mblnr = itab_main-grno.

**************************Mandar*******************************
* To get GR Date.
select single bldat into itab_main-bldat from mkpf where
mblnr = itab_main-grno.
***************************************************************

* To get Truck No.
select single frbnr into itab_main-frbnr from mkpf where
mblnr = itab_main-grno.


* To get Vendor Name.
select single name1 into itab_main-vendornm from lfa1 where
lifnr = itab_main-vendorcd.

* To get Panel Code and Name.
perform getpaneldetail.

* To calculate Inspection characteristic value.
perform getinspchar.

append itab_main.
clear itab_main.
endloop.


* To filter the PO Date as specified in selection criteria.
sort itab_main by podt.
delete itab_main where not podt in s_date.

* To filter the Panel as specified in selection criteria.
sort itab_main by panelcd.
delete itab_main where not panelcd in s_panel.

* To filter GR date as specified in selection criteria.
sort itab_main by grdt.
delete itab_main where not grdt in s_grdt.

if not ( itab_main[] is initial ).
select a~ebeln a~ebelp b~knumv a~menge a~meins
into table i_ekpo
from ekpo as a
inner join ekko as b
on a~ebeln = b~ebeln
for all entries in itab_main
where a~ebeln = itab_main-pono
and a~ebelp = itab_main-poitem.
endif.

sort i_ekpo by ebeln kposn.
delete adjacent duplicates from i_ekpo comparing ebeln kposn.

if not ( i_ekpo[] is initial ).

select knumv kposn kschl kwert
into table i_konv
from konv
for all entries in i_ekpo
where knumv = i_ekpo-knumv
and kposn = i_ekpo-kposn.
endif.

sort i_konv by knumv kposn.

sort itab_main by pono poitem.


loop at itab_main.
read table i_ekpo with key ebeln = itab_main-pono
kposn = itab_main-poitem.
itab_main-menge = i_ekpo-menge.
itab_main-meins = i_ekpo-meins.

loop at i_konv where knumv = i_ekpo-knumv
and kposn = i_ekpo-kposn.
at end of kposn.
sum.
if ( i_ekpo-menge ne 0 ).
itab_main-kwert = i_konv-kwert / i_ekpo-menge.
endif.
endat.

endloop.
modify itab_main.
clear i_ekpo.
endloop.

sort itab_main by panelcd pono grno.

loop at itab_main.
perform print_detail_data.
endloop.
perform total_data.

*-------------
* Panel detail
*-------------
form getpaneldetail.
v_adrnr = ''.
v_regio = ''.
v_descript = ''.

* Steps below gets the ADDRESS NUMBER to arrive at the PANEL of the
* VENDOR
select single adrnr from lfa1 into (v_adrnr)
where lifnr = itab_main-vendorcd.

* BASED on the ADDRESS NUMBER GET THE PANEL CODE
select single regiogroup from adrc into v_regio
where addrnumber = v_adrnr.

* To get the Panel name from Panel Code.
select single descript from adrreggrpt into v_descript
where regiogroup = v_regio.

itab_main-panelcd = v_regio.
itab_main-panelnm = v_descript.

endform.


*---------------------------------
* Inspection characteristic detail
*---------------------------------
form getinspchar.

data: v_plnnr like qals-plnnr,
v_insplot like qals-prueflos,
v_product like mseg-menge,
v_itab_inspchar like itab_inspchar occurs 0 with header line.

select single plnnr prueflos into (v_plnnr, v_insplot) from qals
where mblnr = itab_main-grno
and zeile = itab_main-zeile
and mjahr = itab_main-mjahr.

* Selecting the Inspection Characteristic No
* Merknr : Characterstic properties e.g. Moisture, .....
clear i_qamv.
refresh i_qamv.

select prueflos merknr verwmerkm into table i_qamv
from qamv where prueflos = v_insplot.


* Finding the Mean Value and Actual Weight for that Material Document
loop at i_qamv.
clear v_product.
clear i_qamr.
refresh i_qamr.

select mittelwert anzwertg
into table i_qamr from qamr
where merknr = i_qamv-merknr
and prueflos = i_qamv-prueflos.
sort i_qamr by anzwertg.
read table i_qamr index 1.



* editor-call for i_qamr display-mode.

v_product = i_qamr-mittelwert * i_qamr-anzwertg.



v_itab_inspchar-inspcharname = i_qamv-verwmerkm.
v_itab_inspchar-inspcharvalue = v_product.
append v_itab_inspchar.
clear v_itab_inspchar.

* To store Inspection characteristic heading.
itab_inspchar_heading-inspcharname = i_qamv-verwmerkm.
collect itab_inspchar_heading.
clear itab_inspchar_heading.

endloop.
itab_main-itab_inspchar[] = v_itab_inspchar[].
refresh v_itab_inspchar.
endform.

*-------------
* PAGE HEADER
*-------------
top-of-page.
perform print_header_data.
perform print_title_data.

*-------------
* PAGE FOOTER
*-------------
end-of-page.


*-------------
* HEADER DATA
*-------------
form print_header_data.

write:/4 'User ID '.
write:25 sy-uname.

write: 60 'Date '.
write: 80 sy-datum.

write:/4 'From Plant '.
write:25 s_plant-low.

write: 60 'To Plant '.
write: 80 s_plant-high.

write:/4 'From Material '.
write:25 s_matno-low.

write: 60 'To Material'.
write: 80 s_matno-high.

write: /4 'From Date '.
write: 25 s_date-low.

write: 60 'To Date '.
write: 80 s_date-high.

write: /4 'From Vendor '.
write: 25 s_vncd-low.

write: 60 'To Vendor '.
write: 80 s_vncd-high.

write:/4 'From Panel '.
write:25 s_panel-low.

write: 60 'To Panel '.
write: 80 s_panel-high.
endform.

*-------------
* TITLE DATA
*-------------
form print_title_data.

data: v_col type i value 200.
format color col_heading.

write :/ sy-uline.
WRITE :/2 'PLANT',
8 'MATERIAL',
28 'PO NO',
39 'GR NO',
50 'PO DATE',
61 'GR DATE',
72 'Doc Date',
83 'VENDOR',
90 'VENDOR NAME',
127 'PANEL NAME',
147 'GR QUANTITY',
161 'INSPEC LOTNO',
185 'BATCH NO'.

sort itab_inspchar_heading by inspcharname.
* To print the heading of Inspection characteristic value.
loop at itab_inspchar_heading.
v_col = v_col + 15.


w_string = itab_inspchar_heading-inspcharname.
translate w_string to upper case.
if w_string cs 'FUNGUS'.
itab_inspchar_heading-inspcharname = 'GREEN COPRA'.
endif.
write at v_col(14) itab_inspchar_heading-inspcharname.


itab_inspchar_heading-colpos = v_col.
modify itab_inspchar_heading transporting colpos.
endloop.

v_col = v_col + 15.
write at v_col(10) 'PLANT'.

v_col = v_col + 15.
write at v_col(10) 'PO QTY'.

v_col = v_col + 15.
write at v_col(10) 'PRICE'.

v_col = v_col + 15.
write at v_col(10) 'UNIT'.

v_col = v_col + 5.
write at v_col(6) 'SLOC'.

v_col = v_col + 10.
write at v_col(10) 'TRUCK No.'.


perform print_vertical_lines.

format reset.
set left scroll-boundary column 56.
write:/ sy-uline.
endform.


* TO DISPLAY THE VERTICLE LINES FOR THE REPORTS
*---------------
* VERTICAL LINES
*---------------
form print_vertical_lines.
write :1 sy-vline,
7 sy-vline,
27 sy-vline,
38 sy-vline,
49 sy-vline,
60 sy-vline,
71 sy-vline,
82 sy-vline,
89 sy-vline,
126 sy-vline,
146 sy-vline,
160 sy-vline,
184 sy-vline.

v_col = 200.
* To print vertical lines for Inspection characteristic value.
loop at itab_inspchar_heading.
write at v_col sy-vline.
v_col = v_col + 15.
endloop.
write at v_col sy-vline.
v_col = v_col + 15.
write at v_col sy-vline.
v_col = v_col + 15.
write at v_col sy-vline.
v_col = v_col + 15.
write at v_col sy-vline.
v_col = v_col + 15.
write at v_col sy-vline.
v_col = v_col + 5.
write at v_col sy-vline.
v_col = v_col + 5.
write at v_col sy-vline.
v_col = v_col + 15.
write at v_col sy-vline.
endform.

*-------------
* DETAIL DATA
*-------------
form print_detail_data.
* data: v_col type i value 120.

format color col_normal.
on change of itab_main-panelcd.
if sy-tabix > 1.
perform total_data.
endif.
endon.

* Assigning values to variables for displaying total and average weight
v_sumqty = v_sumqty + itab_main-qty.

data: itab_inspchar_data like itab_inspchar occurs 0 with header line.
WRITE :/2 ITAB_MAIN-WERKS,
8 ITAB_MAIN-MATNR,
28 itab_main-pono,
39 itab_main-grno,
50 itab_main-podt,
61 itab_main-grdt,
72 itab_main-bldat,
83 itab_main-vendorcd,
90 itab_main-vendornm,
127 itab_main-panelnm,
147 itab_main-qty," decimals 0,
161 ITAB_MAIN-PRUEFLOS,
185(10) ITAB_MAIN-CHARG.
** 120(10) itab_main-burnt DECIMALS 2,

itab_inspchar_data[] = itab_main-itab_inspchar[].


* To print the detail of Inspection characteristic value.
sort itab_inspchar_data by inspcharname.
sort itab_inspchar_heading by inspcharname.
loop at itab_inspchar_data.

read table itab_inspchar_heading with key inspcharname =
itab_inspchar_data-inspcharname.
v_col = itab_inspchar_heading-colpos.
write at itab_inspchar_heading-colpos(14)
itab_inspchar_data-inspcharvalue exponent 0 decimals 2.

* If the characteristic quantity is greater then zero then add to
* total qty for calculating weighted average.

if itab_inspchar_data-inspcharvalue > 0.

loop at itab_inspchar_heading where inspcharname =
itab_inspchar_data-inspcharname.
itab_inspchar_heading-sumqty = itab_inspchar_heading-sumqty +
itab_main-qty.
itab_inspchar_heading-sumvalue = itab_inspchar_heading-sumvalue
+ ( itab_inspchar_data-inspcharvalue * itab_main-qty ).
modify itab_inspchar_heading.
endloop.
endif.

endloop.

v_col = v_col + 15.
write at v_col itab_main-plant.

v_col = v_col + 15.
write at v_col itab_main-menge left-justified.

v_col = v_col + 15.
write at v_col itab_main-kwert left-justified decimals 4.

v_col = v_col + 15.
write at v_col itab_main-meins.

v_col = v_col + 5.
write at v_col itab_main-lgort.

v_col = v_col + 5.
write at v_col itab_main-frbnr.

perform print_vertical_lines.

format reset.
endform.


*-------------
* TOTAL DATA
*-------------
form total_data.

data : wtavg like mseg-menge.
write :/ sy-uline.

format color 5.
write :/101 'Panel wise total : ',
121(14) v_sumqty.

write :/101 'Weighted Average : '.

loop at itab_inspchar_heading.
if itab_inspchar_heading-sumqty > 0.
wtavg = itab_inspchar_heading-sumvalue /
itab_inspchar_heading-sumqty.
write at itab_inspchar_heading-colpos(15) wtavg decimals 2.
endif.
* To Reinitialise value.
itab_inspchar_heading-sumqty = 0.
itab_inspchar_heading-sumvalue = 0.
modify itab_inspchar_heading.
endloop.

format color col_normal.
write :/ sy-uline.
v_sumqty = 0.

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)