ā2013 Jan 07 11:17 AM
Hello All,
We have developed a Z report In MB51.
add some file in mb5b report. my report is working propelly but Rate /KG filed is not
working pls correct my code
Rate / kg = ( Balance Amount / Closing Qty )
Exp: Balance Amount = 100
Closing Qty = 50
100 / 50 = 2
2 is rate per kg...
===============================================================================================
DATA: CLS_STK TYPE MSEG-MENGE,
BAL_AMO TYPE MSEG-DMBTR.
CLEAR: CLS_STK.
CLS_STK = G_S_BESTAND_DETAIL-ANFMENGE.
BAL_AMO = G_S_BESTAND_DETAIL-ANFWERT.
loop at G_T_BELEGE1.
if G_T_BELEGE1-SHKZG = 'H'.
G_T_BELEGE1-ZAMOLC = G_T_BELEGE1-DMBTR. " Amount in LC
G_T_BELEGE1-ZYOUTWORD2 = G_T_BELEGE1-MENGE. " OutWard qty
CLS_STK = CLS_STK + G_T_BELEGE1-ZYOUTWORD2. " Closing Qty
BAL_AMO = BAL_AMO + G_T_BELEGE1-DMBTR. " Balance Amount
G_T_BELEGE1-ZRATKG1 = BAL_AMO / CLS_STK. " Rate / Kg
else.
G_T_BELEGE1-ZAMOLC = G_T_BELEGE1-DMBTR. " Amount in LC
G_T_BELEGE1-ZYINWORD1 = G_T_BELEGE1-menge. " Inward Qty
CLS_STK = CLS_STK + G_T_BELEGE1-ZYINWORD1. " Closing Qty
BAL_AMO = BAL_AMO + G_T_BELEGE1-DMBTR. " Balance Amount
G_T_BELEGE1-ZRATKG1 = BAL_AMO / CLS_STK. " Rate / Kg
ENDIF.
IF CLS_STK IS NOT INITIAL.
G_T_BELEGE1-ZYCLOSE1 = CLS_STK.
G_T_BELEGE1-ZAMOUNT1 = BAL_AMO .
ENDIF.
modify G_T_BELEGE1 TRANSPORTING ZYOUTWORD2 ZYINWORD1
ZYCLOSE1 ZAMOUNT1 ZAMOLC ZRATKG1.
ENDLOOP.
================================================================================
Thanks in Advance
Richa
ā2013 Jan 07 11:38 AM
Hello Richa,
1) I would suggest, to use field-symbols for the loop at gt_belege1:
LOOP AT GT_BELEGE1 ASSIGNING <BELEG>.
...
ENDLOOP.
Then, you do not need the modify-statement anymore and you have clear structure inside your loop without the header-line.
2) Use variables for CLS_STK and BAL_AMO with a hight precision, so you will not have the rounding problems inside there. For example something with Decimal 17 with 5 decimals.
3) Also check for 0 values inside your calculation, so you cannot have a rate/kg when no stock amount and no quantity is available.
Kind regards,
Hendrik
ā2013 Jan 07 11:31 AM
ā2013 Jan 07 11:38 AM
Hello Richa,
1) I would suggest, to use field-symbols for the loop at gt_belege1:
LOOP AT GT_BELEGE1 ASSIGNING <BELEG>.
...
ENDLOOP.
Then, you do not need the modify-statement anymore and you have clear structure inside your loop without the header-line.
2) Use variables for CLS_STK and BAL_AMO with a hight precision, so you will not have the rounding problems inside there. For example something with Decimal 17 with 5 decimals.
3) Also check for 0 values inside your calculation, so you cannot have a rate/kg when no stock amount and no quantity is available.
Kind regards,
Hendrik
ā2013 Jan 07 12:13 PM
Dear Hendrik,
Thanks for the response.
My problem is not solve. pls correct my code if you have required all code then use MB5B...
other wise pls give me suitable exp.
Thanks
Message was edited by: Richa Tripathi
ā2013 Jan 07 11:49 AM
Hi Richa,
For rate use data element: SNETWR in your internal table (for G_T_BELEGE1-ZRATKG1.).
ZRATKG1 type SNETWR
With regards,
ā2013 Jan 07 12:46 PM
Regards,
Raymond