*&---------------------------------------------------------------------*
*& Report ZVVF_MR038_RG3 *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZVVF_MR038_RG3 no standard page heading line-size 195
MESSAGE-ID ZMM .
*---------------------------------------------------------------------*
* MODULE MM. *
*---------------------------------------------------------------------*
* Objective : Report RG3
*
*
*
* Technical Spec No .
* Date Created
* Author
* Location
* LDB Nil
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Amendment History *
*---------------------------------------------------------------------*
* Who Change ID Reason *
* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ *
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Tables *
*---------------------------------------------------------------------*
tables : mseg, "Document Segment: Material
makt, "Material Descriptions
mkpf,
ekpo,
MCHBH,
MCHB,
mara.
*---------------------------------------------------------------------*
* Types Begin with TY_ *
*---------------------------------------------------------------------*
Types : begin of ty_display,
matnr like mseg-matnr,
WERKS LIKE mseg-WERKS,
date type dats,
charg_r like mseg-charg,
menge_r like mseg-menge,
meins_r like mseg-meins,
strngt_r like mseg-menge,
actve_r like mseg-menge,
charg_e like mseg-charg,
menge_e like mseg-menge,
meins_e like mseg-meins,
strngt_e like mseg-menge,
actve_e like mseg-menge,
charg_m like mseg-charg,
MATNR_B like mseg-matnr,
maktx like makt-maktx,
menge_m like mseg-menge,
meins_m like mseg-meins,
remarks(20) type c,
end of ty_display.
types : begin of ty_mseg,
WERKS LIKE Mseg-WERKS,
budat like mkpf-budat,
mblnr like mseg-mblnr,
matnr like mseg-matnr,
charg like mseg-charg,
BWART like mseg-BWART,
SHKZG like mseg-SHKZG,
lifnr like mseg-lifnr,
ebeln like mseg-ebeln,
ebelp like mseg-ebelp,
bednr like ekpo-bednr,
menge like mseg-menge,
meins like mseg-meins,
sgtxt like mseg-sgtxt,
aufnr like mseg-aufnr,
end of ty_mseg.
types : begin of ty_recve,
matnr like mseg-matnr,
WERKS LIKE MCHBH-WERKS,
budat like mkpf-budat,
charg like mseg-charg,
menge like mseg-menge,
meins like mseg-meins,
strngt like mseg-menge,
actve like mseg-menge,
end of ty_recve.
types : begin of ty_recve1,
matnr like mseg-matnr,
WERKS LIKE MCHBH-WERKS,
budat like mkpf-budat,
mblnr like mseg-mblnr,
end of ty_recve1.
types : begin of ty_expend,
matnr like mseg-matnr,
WERKS LIKE MCHBH-WERKS,
budat like mkpf-budat,
charg like mseg-charg,
menge like mseg-menge,
meins like mseg-meins,
strngt like mseg-menge,
actve like mseg-menge,
end of ty_expend.
types : begin of ty_manf,
matnr like mseg-matnr,
WERKS LIKE MSEG-WERKS,
budat like mkpf-budat,
charg like mseg-charg,
menge like mseg-menge,
meins like mseg-meins,
end of ty_manf.
types : begin of ty_MAKT,
matnr like mseg-matnr,
MAKTX LIKE MAKT-MAKTX,
end of ty_MAKT.
**---------------------------------------------------------------------*
* Constants Begin with C_
**---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Internal tables Begin with IT_ *
*---------------------------------------------------------------------*
data : it_mseg type standard table of ty_mseg with header line,
it_mseg1 type standard table of ty_mseg with header line,
it_mseg2 type standard table of ty_mseg with header line,
it_recve type standard table of ty_recve with header line,
it_recve1 type standard table of ty_recve1 with header line,
it_expend type standard table of ty_expend with header line,
it_manf type standard table of ty_maNF with header line,
it_maKT type standard table of ty_maKT with header line,
it_display type standard table of ty_display with header line,
it_display1 type standard table of ty_display with header line.
*---------------------------------------------------------------------*
* Work Area Begin with WA_ *
*---------------------------------------------------------------------*
data : wa_mseg like line of it_mseg,
wa_recve like line of it_recve,
wa_recve1 like line of it_recve1,
wa_exPend like line of it_exPend,
wa_manf like line of it_manf,
wa_maKT like line of it_maKT,
wa_display1 like line of it_display,
wa_display like line of it_display.
*---------------------------------------------------------------------*
* Data Begin with W_ *
*---------------------------------------------------------------------*
DATA : W_KEY LIKE INOB-OBJEK,
W_STRENGTH LIKE AUSP-ATFLV.
*---------------------------------------------------------------------*
* Select Options Begin with SO_ *
*---------------------------------------------------------------------*
selection-screen : begin of block b1 with frame title text-000.
PARAMETERS : PR_plant LIKE mseg-werks ."default 'P001' .
select-options : so_matnr for mseg-matnr obligatory. "Material code
select-options : so_date for sy-datum obligatory no-extension.
selection-screen : end of block b1.
************************************************************************
*---------------------------------------------------------------------*
* Ranges Begin with R_ *
*---------------------------------------------------------------------*
ranges : r_movtype for mseg-bwart. "Movement type
*---------------------------------------------------------------------*
* Initialisation *
*---------------------------------------------------------------------*
initialization.
*---------------------------------------------------------------------*
* At selection-screen *
*---------------------------------------------------------------------*
at selection-screen output.
***********************************************************************
* S T A R T O F S E L E C T I O N *
***********************************************************************
start-of-selection.
***Dates should be from the similar month of the similar year
if ( so_date-high+4(2) ne so_date-low+4(2) )
or ( so_date-high+0(4) ne so_date-low+0(4) ).
message e119(zmm) .
endif.
perform Get_movetype.
perform get_mseg.
perform get_MAKT.
end-of-selection.
PERFORM DATA_SUM.
perform list_display.
*&---------------------------------------------------------------------*
*& Form get_mchb
*&---------------------------------------------------------------------*
form Get_movetype.
r_movtype-sign = 'I'.
r_movtype-option = 'EQ'.
r_movtype-low = '311'.
r_movtype-high = ' '.
append r_movtype.
r_movtype-sign = 'I'.
r_movtype-option = 'EQ'.
r_movtype-low = '312'.
r_movtype-high = ' '.
append r_movtype.
r_movtype-sign = 'I'.
r_movtype-option = 'EQ'.
r_movtype-low = '261'.
r_movtype-high = ' '.
append r_movtype.
r_movtype-sign = 'I'.
r_movtype-option = 'EQ'.
r_movtype-low = '262'.
r_movtype-high = ' '.
append r_movtype.
r_movtype-sign = 'I'.
r_movtype-option = 'EQ'.
r_movtype-low = '101'.
r_movtype-high = ' '.
append r_movtype.
r_movtype-sign = 'I'.
r_movtype-option = 'EQ'.
r_movtype-low = '102'.
r_movtype-high = ' '.
append r_movtype.
endform.
*&---------------------------------------------------------------------*
*& Form get_mseg
*&---------------------------------------------------------------------*
form get_mseg.
select mseg~WERKS
mkpf~budat
mseg~mblnr
mseg~matnr
mseg~charg
mseg~bwart
mseg~SHKZG
mseg~lifnr
mseg~ebeln
mseg~ebelp
mseg~menge
mseg~meins
mseg~sgtxt
mseg~aufnr
into corresponding
fields of
table it_mseg
from mseg inner join mkpf
on mkpf~mblnr = mseg~mblnr and
mkpf~mjahr = mseg~mjahr
where
mseg~werks = PR_plant and
* mseg~matnr in so_matnr and
mseg~bwart in r_movtype and
mkpf~budat in so_date .
IF SY-SUBRC = 0.
it_mseg2[] = it_mseg[].
delete it_mseg where not matnr in so_matnr.
loop at it_mseg into wa_mseg where ( bwart = '311' and SHKZG = 'S' )
or ( bwart = '312' and SHKZG = 'H' ).
if wa_mseg-SHKZG = 'H'.
wa_mseg-menge = wa_mseg-menge * ( -1 ).
endif.
move-corresponding wa_mseg to wa_recve.
collect wa_recve into it_recve.
endloop.
loop at it_mseg into wa_mseg where bwart = '261' or
bwart = '262' .
if wa_mseg-bwart = '261'.
move-corresponding wa_mseg to wa_recve1.
collect wa_recve1 into it_recve1.
endif.
if wa_mseg-SHKZG = 'H'.
wa_mseg-menge = wa_mseg-menge * ( -1 ).
endif.
move-corresponding wa_mseg to wa_expend.
collect wa_expend into it_expend.
endloop.
* loop at it_mseg into wa_mseg where bwart = '101' or
* bwart = '102' .
* if wa_mseg-SHKZG = 'H'.
* wa_mseg-menge = wa_mseg-menge * ( -1 ).
* endif.
* move-corresponding wa_mseg to wa_recve1.
* collect wa_recve1 into it_recve1.
* endloop.
loop at it_recve1 into wa_recve1.
loop at it_mseg2 into wa_mseg where WERKS = wa_recve1-WERKS and
budat = wa_recve1-budat and
mblnr = wa_recve1-mblnr and
( bwart = '101' or
bwart = '102' ).
if wa_mseg-SHKZG = 'H'.
wa_mseg-menge = wa_mseg-menge * ( -1 ).
endif.
move-corresponding wa_mseg to wa_manf.
collect wa_manf into it_manf.
endloop.
endloop.
it_mseg1[] = it_mseg[].
sort it_mseg1 stable by werks budat matnr charg.
delete adjacent duplicates from it_mseg1
comparing werks budat matnr charg.
ELSE.
MESSAGE E006.
ENDIF.
endform. "get_mseg
*&---------------------------------------------------------------------*
*& Form DATA_SUM
*&---------------------------------------------------------------------*
FORM DATA_SUM.
loop at it_mseg1 into wa_mseg.
wa_display-date = wa_mseg-budat.
wa_display-matnr = wa_mseg-matnr.
read table it_recve into wa_recve with key
matnr = wa_mseg-matnr
WERKS = wa_mseg-WERKS
budat = wa_mseg-budat
charg = wa_mseg-charg.
if sy-subrc = 0.
wa_display-charg_r = wa_recve-charg.
wa_display-menge_r = wa_recve-menge.
wa_display-meins_r = wa_recve-meins.
IF NOT WA_DISPLAY-menge_R = 0.
CONCATENATE WA_DISPLAY-MATNR PR_plant wa_display-charg_r INTO W_KEY .
PERFORM STRENGTH_CALC USING W_KEY
CHANGING W_STRENGTH.
WA_DISPLAY-strngt_r = ( W_STRENGTH / 100 ) * WA_DISPLAY-menge_r.
CLEAR : W_KEY.
ENDIF.
PERFORM GET_CONTENT USING WA_DISPLAY-MATNR
WA_DISPLAY-meins_R
WA_DISPLAY-menge_R
WA_DISPLAY-charg_r
CHANGING WA_DISPLAY-actve_R.
endif.
read table it_expend into wa_expend with key
matnr = wa_mseg-matnr
WERKS = wa_mseg-WERKS
budat = wa_mseg-budat
charg = wa_mseg-charg.
if sy-subrc = 0.
wa_display-charg_e = wa_expend-charg.
wa_display-menge_e = wa_expend-menge.
wa_display-meins_e = wa_expend-meins.
IF NOT WA_DISPLAY-menge_e = 0.
CONCATENATE WA_DISPLAY-MATNR PR_plant wa_display-charg_e INTO W_KEY .
PERFORM STRENGTH_CALC USING W_KEY
CHANGING W_STRENGTH.
WA_DISPLAY-strngt_e = ( W_STRENGTH / 100 ) * WA_DISPLAY-menge_e.
CLEAR : W_KEY.
ENDIF.
PERFORM GET_CONTENT USING WA_DISPLAY-MATNR
WA_DISPLAY-meins_e
WA_DISPLAY-menge_e
WA_DISPLAY-charg_e
CHANGING WA_DISPLAY-actve_e.
endif.
read table it_manf into wa_manf with key
WERKS = wa_mseg-WERKS
budat = wa_mseg-budat.
if sy-subrc = 0.
loop at it_manf into wa_manf where
WERKS = wa_mseg-WERKS and
budat = wa_mseg-budat.
wa_display-charg_m = wa_manf-charg.
wa_display-menge_m = wa_manf-menge.
wa_display-meins_m = wa_manf-meins.
wa_display-maTNR_B = wa_manf-matnr.
read table it_makt into wa_makt with key
matnr = wa_manf-matnr.
if sy-subrc = 0.
wa_display-maktx = wa_makt-maktx.
ENDIF.
append wa_display to it_display.
ENDloop.
else.
append wa_display to it_display.
endif.
clear wa_display.
endloop.
DELETE it_display WHERE ( menge_R = 0 AND
menge_E = 0 AND
menge_M = 0 ).
ENDFORM. "DATA_SUM
*&---------------------------------------------------------------------*
*& Form GET_MAKT
*&---------------------------------------------------------------------*
FORM GET_MAKT.
SELECT MATNR MAKTX INTO CORRESPONDING FIELDS OF TABLE IT_MAKT FROM MAKT
for all entries in it_manf WHERE MATNR = it_manf-matnr AND
SPRAS = SY-LANGU.
IF SY-SUBRC NE 0.
MESSAGE W120.
ENDIF.
ENDFORM. "GET_MAKT
*&--------------------------------------------------------------------*
*& Form GET_CONTENT
*&--------------------------------------------------------------------*
*---------------------------------------------------------------------*
FORM GET_CONTENT USING WA_MCHB-MATNR
WA_DISPLAY-meins_h
WA_DISPLAY-menge_h
WA_DISPLAY-charg_h
CHANGING WA_DISPLAY-actve_h.
.
CALL FUNCTION 'MB_UNIT_CONVERSION'
EXPORTING
ERFME = 'LAI'
MATNR = WA_MCHB-MATNR
MEINS = WA_DISPLAY-meins_h
MENGE = WA_DISPLAY-menge_h
CHARG = WA_DISPLAY-charg_h
WERKS = pr_plant
IMPORTING
O_ERFMG = WA_DISPLAY-actve_h.
ENDFORM. "GET_CONTENT
*&--------------------------------------------------------------------*
*& Form list_display
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
form list_display.
WRITE : /90 'FORM R.G.3',
/85 '(Rule 31,33 and 50)',
/70 'Register of Transactions in the Bonded Manufactory'.
skip 3.
skip 1.
write : sy-uline(194) .
write : / '|' ,12 '|' ,25 'Received from Spirit Store',62 '|' ,
78 'Quantity Expended',
112 '|' ,
125 'Preparation Manufactured' ,169 '|',
194 '|'.
write : sy-uline(194) .
write : / '|' ,4 'Date', 12 '|' ,'Quantity' , 22 '|','UOM',
27 '|' ,'Batch' , 38 '|' ,'Strength%' ,49
'|' ,'Alc.Content',
62 '|' ,'Batch' , 73
'|' ,'Quantity' ,
83 '|' ,'UOM' , 88 '|' ,'Strength%' ,99
'|' ,'Alc.Content' ,
112 '|' ,'Batch' ,123 '|' ,'Material',
134 '|' ,144 'Name of Product' ,
169 '|' ,'Quantity' ,180
'|' ,'UOM',
185 '|' ,187 'Remarks' ,194 '|'.
write : sy-uline(194) .
loop at it_display into wa_display.
perform Get_positive.
write : / '|' ,2 wa_display-date , 12 '|',
wa_display-menge_r left-justified,
22 '|',wa_display-meins_r,
27 '|' ,wa_display-charg_r ,
38 '|' ,wa_display-strngt_r left-justified,
49 '|' ,wa_display-actve_r left-justified,
62 '|',wa_display-charg_e ,
73 '|',wa_display-menge_e left-justified,
83 '|',wa_display-meins_e ,
88 '|', wa_display-strngt_e left-justified,
99 '|',wa_display-actve_e left-justified,
112 '|',wa_display-charg_m,
123 '|',wa_display-matnr_b,
134 '|',wa_display-maktx,
169 '|',wa_display-menge_m left-justified,
180 '|',wa_display-meins_m ,
185 '|',"wa_display-remarks ,
194 '|'.
write : sy-uline(194) .
endloop.
endform. "list_display
*&--------------------------------------------------------------------*
*& Form STRENGTH_CALC
*&--------------------------------------------------------------------*
FORM STRENGTH_CALC USING W_KEY
CHANGING W_STRENGTH.
DATA : W_CUOBJ LIKE INOB-CUOBJ,
W_KLART LIKE INOB-KLART.
SELECT SINGLE CUOBJ KLART INTO (W_CUOBJ,W_KLART) FROM INOB WHERE
OBTAB = 'MCHA' AND
OBJEK = W_KEY.
IF SY-SUBRC = 0.
SELECT SINGLE ATFLV INTO W_STRENGTH FROM AUSP WHERE
OBJEK = W_CUOBJ AND
KLART = W_KLART.
ENDIF.
CLEAR : W_CUOBJ,W_KLART.
ENDFORM. "STRENGTH_CALC
form Get_positive.
if wa_display-menge_r lt 0.
wa_display-menge_r = wa_display-menge_r * ( -1 ).
endif.
if wa_display-strngt_r lt 0.
wa_display-strngt_r = wa_display-strngt_r * ( -1 ).
endif.
if wa_display-actve_r lt 0.
wa_display-actve_r = wa_display-actve_r * ( -1 ).
endif.
if wa_display-menge_e lt 0.
wa_display-menge_e = wa_display-menge_e * ( -1 ).
endif.
if wa_display-strngt_e lt 0.
wa_display-strngt_e = wa_display-strngt_e * ( -1 ).
endif.
if wa_display-actve_e lt 0.
wa_display-actve_e = wa_display-actve_e * ( -1 ).
endif.
endform. "Get_positive
No comments:
Post a Comment