*&---------------------------------------------------------------------*
*& Report ZVVF_MR037_RG2 *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZVVF_MR037_RG2 no standard page heading line-size 246
MESSAGE-ID ZMM .
*---------------------------------------------------------------------*
* MODULE MM. *
*---------------------------------------------------------------------*
* Objective : Form RG2
*
*
*
* 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, "Header: Material Document
ekpo, "Purchasing Document Item
MCHBH, "Batch Stocks: History
MCHB, "Batch Stocks
mara. "General Material Data
*---------------------------------------------------------------------*
* Types Begin with TY_ *
*---------------------------------------------------------------------*
Types : begin of ty_display,
matnr like mseg-matnr,
WERKS LIKE mseg-WERKS,
date type dats,
menge_h like mseg-menge,
meins_h like mseg-meins,
charg_h like mseg-charg,
strngt_h like mseg-menge,
actve_h like mseg-menge,
lifnr like mseg-lifnr,
ebeln like mseg-ebeln,
bednr like ekpo-bednr,
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_t like mseg-charg,
menge_t like mseg-menge,
actve_t like mseg-menge,
sgtxt like mseg-sgtxt,
charg_e like mseg-charg,
menge_e like mseg-menge,
strngt_e like mseg-menge,
actve_e like mseg-menge,
end of ty_display.
types : begin of ty_MCHB,
matnr like MCHB-matnr,
WERKS LIKE MCHB-WERKS,
charg like MCHB-charg,
ERSDA LIKE MCHB-ERSDA,
end of ty_MCHB.
types : begin of ty_MCHBH,
matnr like MCHBH-matnr,
WERKS LIKE MCHBH-WERKS,
charg like MCHBH-charg,
clabs like MCHBH-clabs,
cinsm like MCHBH-cinsm,
CEINM LIKE MCHBH-CEINM,
cspem like MCHBH-cspem,
end of ty_MCHBH.
types : begin of ty_mseg,
matnr like mseg-matnr,
WERKS LIKE MCHBH-WERKS,
budat like mkpf-budat,
BWART like mseg-BWART,
SHKZG like mseg-SHKZG,
lifnr like mseg-lifnr,
ebeln like mseg-ebeln,
ebelp like mseg-ebelp,
bednr like ekpo-bednr,
charg like mseg-charg,
menge like mseg-menge,
meins like mseg-meins,
sgtxt like mseg-sgtxt,
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,
lifnr like mseg-lifnr,
ebeln like mseg-ebeln,
bednr like ekpo-bednr,
menge like mseg-menge,
meins like mseg-meins,
strngt like mseg-menge,
actve like mseg-menge,
end of ty_recve.
types : begin of ty_extend,
matnr like mseg-matnr,
WERKS LIKE MCHBH-WERKS,
budat like mkpf-budat,
charg like mseg-charg,
menge like mseg-menge,
strngt like mseg-menge,
actve like mseg-menge,
end of ty_extend.
types : begin of ty_extend1,
matnr like mseg-matnr,
WERKS LIKE MCHBH-WERKS,
budat like mkpf-budat,
charg like mseg-charg,
BWART like mseg-BWART,
meins like mseg-meins,
menge like mseg-menge,
strngt like mseg-menge,
actve like mseg-menge,
end of ty_extend1.
types : begin of ty_total,
matnr like mseg-matnr,
DATE like mkpf-budat,
charg like mseg-charg,
meins like mseg-meins,
menge like mseg-menge,
actve like mseg-menge,
end of ty_total.
**---------------------------------------------------------------------*
* Constants Begin with C_
**---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* Internal tables Begin with IT_ *
*---------------------------------------------------------------------*
data : it_mseg type standard table of ty_mseg with header line,
it_mchb type standard table of ty_mchb with header line,
it_mchbH1 type standard table of ty_mchbH with header line,
it_mchbH type standard table of ty_mchbH with header line,
it_recve type standard table of ty_recve with header line,
it_extend type standard table of ty_extend with header line,
it_extend1 type standard table of ty_extend1 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,
it_total type standard table of ty_total with header line.
*---------------------------------------------------------------------*
* Work Area Begin with WA_ *
*---------------------------------------------------------------------*
data : wa_mseg like line of it_mseg,
wa_MCHB like line of it_MCHB,
wa_MCHBH1 like line of it_MCHBH,
wa_MCHBH like line of it_MCHBH,
wa_recve like line of it_recve,
wa_extend like line of it_extend,
wa_extend1 like line of it_extend1,
wa_display1 like line of it_display,
wa_total like line of it_total,
wa_display like line of it_display.
*---------------------------------------------------------------------*
* Data Begin with W_ *
*---------------------------------------------------------------------*
DATA : W_DATE LIKE MKPF-BUDAT,
W_DATE1 LIKE MKPF-BUDAT,
W_DATE2 LIKE MKPF-BUDAT,
W_DATE3 LIKE MKPF-BUDAT,
W_DATE4 LIKE MKPF-BUDAT,
W_BUPER LIKE T009B-POPER,
W_lfmon LIKE mchb-lfmon,
W_YEAR LIKE T009B-BDATJ,
W_RMENGE LIKE MSEG-MENGE,
W_MON(2) TYPE N,
W_INDEX TYPE SY-INDEX,
W_CNT TYPE I,
W_CNT1 TYPE I,
W_CNT2 TYPE I,
W_IMENGE LIKE MSEG-MENGE,
w_maktx like makt-maktx,
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
r_date for sy-datum. "Date
*---------------------------------------------------------------------*
* Initialisation *
*---------------------------------------------------------------------*
initialization.
*---------------------------------------------------------------------*
* At selection-screen *
*---------------------------------------------------------------------*
at selection-screen .
if not so_date-high is initial.
***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.
endif.
endif.
***********************************************************************
* S T A R T O F S E L E C T I O N *
***********************************************************************
start-of-selection.
perform get_mchb.
perform get_mseg.
end-of-selection.
PERFORM DATA_SUM.
perform list_display.
*&---------------------------------------------------------------------*
*& Form get_mchb
*&---------------------------------------------------------------------*
form get_mchb.
IF so_date-HIGH IS INITIAL.
so_date-HIGH = so_date-LOW.
ENDIF.
***Select all stock details from MCHB creation le selection screen high
***date
SELECT DISTINCT matnr WERKS charg "ERSDA
FROM MCHB INTO CORRESPONDING
FIELDS OF TABLE It_MCHB
WHERE WERKS = PR_plant
AND MATNR IN so_MATNR
AND ERSDA LE so_date-HIGH.
if sy-subrc = 0.
CONCATENATE so_date-low+0(6) '01' INTO W_DATE.
W_DATE1 = W_DATE.
W_DATE = W_DATE - 1.
***find the fiscal year and month of previous year&month
call function 'DATE_TO_PERIOD_CONVERT'
EXPORTING
i_date = W_DATE
i_periv = 'V3'
IMPORTING
e_buper = w_buper
e_gjahr = w_year.
w_lfmon = w_buper+1(2).
***current stock is taken from stock history table MCHBH
SELECT matnr WERKS charg clabs cinsm CEINM cspem
FROM MCHBH INTO CORRESPONDING
FIELDS OF TABLE It_MCHBH1
FOR ALL ENTRIES IN It_MCHB
WHERE WERKS = It_MCHB-WERKS
AND MATNR = It_MCHB-MATNR
AND CHARG = It_MCHB-CHARG
AND LFGJA = w_year
AND LFMON = w_lfmon.
if sy-subrc = 0.
LOOP AT IT_MCHBH1 INTO WA_MCHBH1.
MOVE-CORRESPONDING WA_MCHBH1 TO WA_MCHBH.
COLLECT WA_MCHBH INTO IT_MCHBH.
ENDLOOP.
endif.
else.
message e123 with 'MCHB' W_DATE1 so_date-HIGH.
endif.
endform. "get_mchb
*&---------------------------------------------------------------------*
*& Form get_mseg
*&---------------------------------------------------------------------*
form get_mseg.
select mseg~matnr
mseg~WERKS
mkpf~budat
mseg~bwart
mseg~SHKZG
mseg~lifnr
mseg~ebeln
mseg~ebelp
ekpo~bednr
mseg~charg
mseg~menge
mseg~meins
mseg~sgtxt
into corresponding
fields of
table it_mseg
from mseg inner join mkpf
on mkpf~mblnr = mseg~mblnr and
mkpf~mjahr = mseg~mjahr
LEFT OUTER join ekpo
on mseg~ebeln = ekpo~ebeln and
mseg~ebelp = ekpo~ebelp
where
mseg~werks = PR_plant and
mseg~matnr in so_matnr and
mkpf~budat BETWEEN W_DATE1 AND so_date-HIGH .
if sy-subrc = 0.
loop at it_mseg into wa_mseg where bwart = '101' or
bwart = '102' or
bwart = '105' or
bwart = '106'.
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' OR
bwart = '201'.
if wa_mseg-SHKZG = 'H'.
wa_mseg-menge = wa_mseg-menge * ( -1 ).
endif.
move-corresponding wa_mseg to wa_extend.
collect wa_extend into it_extend.
endloop.
loop at it_mseg into wa_mseg where bwart = '261' or
bwart = '262' OR
bwart = '201'.
move-corresponding wa_mseg to wa_extend1.
if wa_mseg-SHKZG = 'H'.
wa_mseg-menge = wa_mseg-menge * ( -1 ).
endif.
collect wa_extend1 into it_extend1.
endloop.
else.
message e123 with 'MSEG' W_DATE1 so_date-HIGH.
endif.
endform. "get_mseg
*&---------------------------------------------------------------------*
*& Form DATA_SUM
*&---------------------------------------------------------------------*
FORM DATA_SUM.
W_DATE2 = so_date-LOW.
W_DATE3 = so_date-LOW - 1.
* IF W_DATE2+6(2) = '01'.
* W_DATE3 = W_DATE2.
* ENDIF.
W_MON = ( so_date-HIGH+6(2) - so_date-LOW+6(2) ) + 1.
SORT IT_MCHB STABLE BY MATNR.
DO W_MON TIMES.
W_INDEX = SY-INDEX.
LOOP AT IT_MCHB INTO WA_MCHB.
WA_DISPLAY-WERKS = WA_MCHB-WERKS.
WA_DISPLAY-MATNR = WA_MCHB-MATNR.
WA_DISPLAY-DATE = W_DATE2.
IF W_INDEX = 1.
READ TABLE IT_MCHBH INTO WA_MCHBH WITH KEY WERKS = WA_MCHB-WERKS
MATNR = WA_MCHB-MATNR
CHARG = WA_MCHB-CHARG.
IF SY-SUBRC = 0.
WA_DISPLAY-menge_h = WA_MCHBH-CLABS + WA_MCHBH-CINSM +
WA_MCHBH-CEINM + WA_MCHBH-CSPEM .
ENDIF.
LOOP AT IT_RECVE INTO WA_RECVE WHERE WERKS = WA_MCHB-WERKS AND
MATNR = WA_MCHB-MATNR AND
CHARG = WA_MCHB-CHARG AND
BUDAT BETWEEN W_DATE1 AND W_DATE3.
W_RMENGE = W_RMENGE + WA_RECVE-MENGE.
ENDLOOP.
LOOP AT IT_EXTEND INTO WA_EXTEND WHERE WERKS = WA_MCHB-WERKS AND
MATNR = WA_MCHB-MATNR AND
CHARG = WA_MCHB-CHARG AND
BUDAT BETWEEN W_DATE1 AND W_DATE3.
W_IMENGE = W_IMENGE + WA_EXTEND-MENGE.
ENDLOOP.
WA_DISPLAY-menge_h = WA_DISPLAY-menge_h + ( W_RMENGE - W_IMENGE ).
* W_MENGE = WA_DISPLAY-menge_h.
READ TABLE IT_MSEG INTO WA_MSEG WITH KEY WERKS = WA_MCHB-WERKS
MATNR = WA_MCHB-MATNR.
IF SY-SUBRC = 0.
WA_DISPLAY-meins_h = WA_MSEG-MEINS.
ENDIF.
WA_DISPLAY-charg_h = WA_MCHB-CHARG.
IF NOT WA_DISPLAY-menge_h = 0.
CONCATENATE WA_MCHB-MATNR WA_MCHB-WERKS WA_MCHB-CHARG INTO W_KEY .
PERFORM STRENGTH_CALC USING W_KEY
CHANGING W_STRENGTH.
WA_DISPLAY-strngt_h = ( W_STRENGTH / 100 ) * WA_DISPLAY-menge_h.
CLEAR : W_KEY.
ENDIF.
PERFORM GET_CONTENT USING WA_MCHB-MATNR
WA_DISPLAY-meins_h
WA_DISPLAY-menge_h
WA_DISPLAY-charg_h
CHANGING WA_DISPLAY-actve_h.
APPEND WA_DISPLAY TO IT_DISPLAY.
wa_total-matnr = WA_MCHB-MATNR.
wa_total-date = WA_DISPLAY-DATE.
wa_total-charg = WA_DISPLAY-charg_h.
wa_total-meins = WA_DISPLAY-meins_h.
wa_total-menge = WA_DISPLAY-menge_h.
wa_total-actve = WA_DISPLAY-actve_h.
collect wa_total into it_total.
CLEAR : WA_DISPLAY,W_RMENGE,W_IMENGE.
ELSE.
W_DATE4 = W_DATE2 - 1.
READ TABLE IT_RECVE INTO WA_RECVE WITH KEY WERKS = WA_MCHB-WERKS
MATNR = WA_MCHB-MATNR
CHARG = WA_MCHB-CHARG
BUDAT = W_DATE4.
IF SY-SUBRC = 0.
W_RMENGE = WA_RECVE-MENGE.
ENDIF.
READ TABLE IT_EXTEND INTO WA_EXTEND WITH KEY WERKS = WA_MCHB-WERKS
MATNR = WA_MCHB-MATNR
CHARG = WA_MCHB-CHARG
BUDAT = W_DATE4.
IF SY-SUBRC = 0.
W_IMENGE = WA_EXTEND-MENGE.
ENDIF.
READ TABLE IT_DISPLAY INTO WA_DISPLAY1 WITH KEY WERKS = WA_MCHB-WERKS
MATNR = WA_MCHB-MATNR
CHARG_H = WA_MCHB-CHARG
DATE = W_DATE4.
IF SY-SUBRC = 0.
WA_DISPLAY-MENGE_H = WA_DISPLAY1-MENGE_H + ( W_RMENGE - W_IMENGE ).
ENDIF.
READ TABLE IT_MSEG INTO WA_MSEG WITH KEY WERKS = WA_MCHB-WERKS
MATNR = WA_MCHB-MATNR.
IF SY-SUBRC = 0.
WA_DISPLAY-meins_h = WA_MSEG-MEINS.
ENDIF.
WA_DISPLAY-charg_h = WA_MCHB-CHARG.
IF NOT WA_DISPLAY-menge_h = 0.
CONCATENATE WA_MCHB-MATNR PR_plant WA_MCHB-CHARG INTO W_KEY .
PERFORM STRENGTH_CALC USING W_KEY
CHANGING W_STRENGTH.
WA_DISPLAY-strngt_h = ( W_STRENGTH / 100 ) * WA_DISPLAY-menge_h.
CLEAR : W_KEY.
ENDIF.
PERFORM GET_CONTENT USING WA_MCHB-MATNR
WA_DISPLAY-meins_h
WA_DISPLAY-menge_h
WA_DISPLAY-charg_h
CHANGING WA_DISPLAY-actve_h.
APPEND WA_DISPLAY TO IT_DISPLAY.
wa_total-matnr = WA_MCHB-MATNR.
wa_total-date = WA_DISPLAY-DATE.
wa_total-charg = WA_DISPLAY-charg_h.
wa_total-menge = WA_DISPLAY-menge_h.
wa_total-actve = WA_DISPLAY-actve_h.
collect wa_total into it_total.
CLEAR : WA_DISPLAY,W_RMENGE,W_IMENGE,WA_DISPLAY1.
ENDIF.
ENDLOOP.
W_DATE2 = W_DATE2 + 1.
ENDDO.
REFRESH IT_DISPLAY1[].
clear : w_cnt1,w_cnt,WA_DISPLAY,WA_DISPLAY1.
LOOP AT IT_DISPLAY INTO WA_DISPLAY.
move-corresponding WA_DISPLAY to WA_DISPLAY1.
append WA_DISPLAY1 to it_DISPLAY1 .
w_cnt = w_cnt + 1.
w_cnt2 = w_cnt.
LOOP AT IT_RECVE INTO WA_RECVE WHERE MATNR = WA_DISPLAY1-MATNR AND
BUDAT = WA_DISPLAY1-DATE AND
CHARG = WA_DISPLAY1-CHARG_h.
w_cnt1 = w_cnt1 + 1.
WA_DISPLAY1-LIFNR = WA_RECVE-LIFNR .
WA_DISPLAY1-EBELN = WA_RECVE-EBELN .
WA_DISPLAY1-bednr = WA_RECVE-bednr.
WA_DISPLAY1-charg_r = WA_RECVE-charg .
WA_DISPLAY1-menge_r = WA_RECVE-menge.
WA_DISPLAY1-meins_r = WA_RECVE-meins .
IF NOT WA_DISPLAY1-menge_R = 0.
CONCATENATE WA_DISPLAY1-MATNR PR_plant WA_RECVE-charg INTO W_KEY .
PERFORM STRENGTH_CALC USING W_KEY
CHANGING W_STRENGTH.
WA_DISPLAY1-strngt_r = ( W_STRENGTH / 100 ) * WA_DISPLAY1-menge_r.
CLEAR : W_KEY.
ENDIF.
PERFORM GET_CONTENT USING WA_MCHB-MATNR
WA_DISPLAY1-meins_R
WA_DISPLAY1-menge_R
WA_DISPLAY1-charg_r
CHANGING WA_DISPLAY1-actve_R.
wa_total-matnr = WA_DISPLAY1-MATNR.
wa_total-date = WA_DISPLAY1-DATE.
wa_total-charg = WA_DISPLAY1-charg_r.
wa_total-meins = WA_DISPLAY1-meins_r.
wa_total-menge = WA_DISPLAY1-menge_r.
wa_total-actve = WA_DISPLAY1-actve_r.
collect wa_total into it_total.
if w_cnt1 = 1.
MODIFY IT_DISPLAY1 FROM WA_DISPLAY1 INDEX W_CNT .
else.
append WA_DISPLAY1 to it_DISPLAY1.
w_cnt = w_cnt + 1.
endif.
endloop.
clear w_cnt1.
w_cnt1 = w_cnt2.
Loop at IT_EXTEND1 INTO WA_EXTEND1 WHERE MATNR = WA_DISPLAY1-MATNR AND
BUDAT = WA_DISPLAY1-DATE AND
CHARG = WA_DISPLAY1-CHARG_h.
WA_DISPLAY1-charg_E = WA_EXTEND-charg .
WA_DISPLAY1-menge_E = WA_EXTEND-menge.
IF NOT WA_DISPLAY1-menge_E = 0.
CONCATENATE WA_DISPLAY1-DATE PR_plant WA_EXTEND1-charg INTO W_KEY.
PERFORM STRENGTH_CALC USING W_KEY
CHANGING W_STRENGTH.
WA_DISPLAY1-strngt_e = ( W_STRENGTH / 100 ) * WA_DISPLAY1-menge_e.
CLEAR : W_KEY.
ENDIF.
PERFORM GET_CONTENT USING WA_DISPLAY1-MATNR
WA_EXTEND1-meins
WA_DISPLAY1-menge_E
WA_DISPLAY1-charg_e
CHANGING WA_DISPLAY1-actve_E.
READ TABLE IT_MSEG INTO WA_MSEG WITH KEy MATNR = WA_DISPLAY1-MATNR
BWART = WA_EXTEND1-bwart
CHARG = WA_EXTEND1-charg.
IF SY-SUBRC = 0.
WA_DISPLAY1-SGTXT = WA_MSEG-SGTXT.
ENDIF.
if w_cnt1 le w_cnt.
MODIFY IT_DISPLAY1 FROM WA_DISPLAY1 INDEX w_cnt1 transporting
sgtxt charg_e menge_E strngt_e actve_E.
else.
append WA_DISPLAY1 to it_DISPLAY1.
w_cnt = w_cnt + 1.
ENDIF.
w_cnt1 = w_cnt1 + 1.
endloop.
clear w_cnt1.
w_cnt1 = w_cnt2.
LOOP AT IT_total INTO WA_total WHERE MATNR = WA_DISPLAY1-MATNR AND
DATe = WA_DISPLAY1-DATE AND
CHARG = WA_DISPLAY1-CHARG_h.
WA_DISPLAY1-charg_t = WA_total-charg .
WA_DISPLAY1-menge_t = WA_total-menge.
PERFORM GET_CONTENT USING WA_MCHB-MATNR
WA_total-meins
WA_DISPLAY1-menge_t
WA_DISPLAY1-charg_t
CHANGING WA_DISPLAY1-actve_t.
if w_cnt1 le w_cnt.
MODIFY IT_DISPLAY1 FROM WA_DISPLAY1 INDEX w_cnt1 transporting
charg_t menge_t actve_t.
else.
append WA_DISPLAY1 to it_DISPLAY1.
w_cnt = w_cnt + 1.
ENDIF.
w_cnt1 = w_cnt1 + 1.
ENDLOOP.
clear w_cnt1.
ENDLOOP.
sort it_display1 stable by matnr.
DELETE it_display1 WHERE menge_H = 0 AND
menge_R = 0 AND
menge_T = 0 AND
menge_E = 0.
clear it_display.
refresh it_display .
it_display[] = it_display1[].
ENDFORM. "DATA_SUM
*&--------------------------------------------------------------------*
*& Form GET_CONTENT
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->WA_MCHB-MATtext
* -->WA_DISPLAY-textS_H
* -->WA_DISPLAY-textE_H
* -->WA_DISPLAY-textE_H
*---------------------------------------------------------------------*
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'
* ERFMG = 0
MATNR = WA_MCHB-MATNR
MEINS = WA_DISPLAY-meins_h
MENGE = WA_DISPLAY-menge_h
* UMREN = 1
* UMREZ = 0
CHARG = WA_DISPLAY-charg_h
WERKS = pr_plant
* CUOBJ =
IMPORTING
* O_ERFME =
O_ERFMG = WA_DISPLAY-actve_h.
* O_MEINS =
* O_MENGE =
* O_UMREN =
* O_UMREZ =
* EXCEPTIONS
* CONVERSION_NOT_FOUND = 1
* DIFFERENT_DIMENSION = 2
* DIVISION_BY_ZERO = 3
* OVERFLOW = 4
* T006D_ENTRY_MISSING = 5
* T006_ENTRY_MISSING = 6
* OTHERS = 7
.
ENDFORM. "GET_CONTENT
*&--------------------------------------------------------------------*
*& Form list_display
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
form list_display.
WRITE : /126 'FORM R.G.2',
/120 '(Rule 20,30,49 and 50)',
/90'Register of Transactions in the Spirit Store of',
' Bonded/Non Bonded Manufactory'.
skip 3.
loop at it_display into wa_display1.
wa_display = wa_display1.
perform Get_positive.
at new matnr.
skip 1.
write : /7 'Material No. : ', wa_display-matnr.
select single maktx from makt into w_maktx where
matnr = wa_display-matnr and
spras = sy-langu.
if sy-subrc = 0.
write : 62 'Material Description. : ', w_maktx.
endif.
skip 1.
write : sy-uline(241) .
write : / '|' ,12 '|' ,33 'IN HAND',62 '|' , 99 'RECEIVED',
146 '|' ,
156 'TOTAL IN HAND' ,180 '|',
208 'EXPENDED',241 '|'.
write : sy-uline(241) .
write : / '|' ,4 'Date' , 12 '|' ,'Quantity' , 22 '|','UOM',
27 '|' ,'Batch' , 38 '|' ,'Strength%' ,49
'|' ,'Alc.Content',62 '|' ,'Whence' , 73 '|' ,'Indent No.' ,
85 '|' ,'Permit No.' , 96 '|' ,'Batch' , 107
'|' ,'Quantity' ,
117 '|' ,'UOM' , 122 '|' ,'Strength%' ,133
'|' ,'Alc.Content' ,
146 '|' ,'Batch' , 157 '|' ,'Quantity' ,167
'|' ,'Alc.Content',
180 '|' ,'Applicn.No.' , 196 '|' ,'Batch' ,
207 '|' ,'Quantity' ,217 '|' ,'Strength%',
228 '|' ,'Alc.Content',241 '|'.
write : sy-uline(241) .
endat.
write : / '|' ,2 wa_display-date , 12 '|',
wa_display-menge_h left-justified,
22 '|',wa_display-meins_h,
27 '|' ,wa_display-charg_h ,
38 '|' ,wa_display-strngt_h left-justified,
49 '|' ,wa_display-actve_h left-justified,
62 '|' ,wa_display-lifnr,
73 '|',wa_display-ebeln ,
85 '|',wa_display-bednr ,
96 '|',wa_display-charg_r ,
107 '|',wa_display-menge_r left-justified,
117 '|',wa_display-meins_r ,
122 '|', wa_display-strngt_r left-justified,
133 '|',wa_display-actve_r left-justified,
146 '|',wa_display-charg_t,
157 '|',wa_display-menge_t left-justified,
167 '|',wa_display-actve_t left-justified,
180 '|',wa_display-sgtxt , 196 '|',wa_display-charg_e ,
207 '|',wa_display-menge_e left-justified,
217 '|',wa_display-strngt_e left-justified,
228 '|',wa_display-actve_e left-justified,
241 '|'.
write : sy-uline(241) .
endloop.
endform. "list_display
*&--------------------------------------------------------------------*
*& Form Get_positive
*&--------------------------------------------------------------------*
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
*&--------------------------------------------------------------------*
*& 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
No comments:
Post a Comment