Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Quantity of stock calculation.

pritam_baboo
Participant
0 Kudos
155

Hi All,

In my custom report I have available stock as below.

now box quantity for this material is 180 (maintained in custom table). and no of box is entered by user in input screen as 5. so total quantity to to be transferred will be 180*5 = 900. In above quantity for different batches is different so 900 quantity should be transferred according to batch. in my final internal table i want the below calculation:

kindly correct my logic:

 DATA: tot_qtytr LIKE ls_mchd-clabs,
* qty(10) TYPE c,
qty1 LIKE ls_mchd-clabs,
qty2 LIKE ls_mchd-clabs,
lv_newgen TYPE string.
LOOP AT lt_mchd INTO ls_mchd.
IF lv_zboxqty < ls_mchd-clabs.
DATA(qty) = ls_mchd-clabs / lv_zboxqty.
qty1 = ls_mchd-clabs.
DO qty TIMES.
IF qty1 > lv_zboxqty.
lv_cnt = lv_cnt + 1.
gs_zauto-zcount = lv_cnt.
CONCATENATE ls_mchd-charg '-' gs_zauto-zcount INTO lv_newgen.
gs_zauto-zbatch = lv_newgen.
gs_zauto-matnr = p_matnr.
gs_zauto-zqty = lv_zboxqty.
gs_zauto-charg = ls_mchd-charg.
gs_zauto-mandt = sy-mandt.
gs_zauto-zdate = sy-datum.
gs_zauto-ztime = sy-timlo.
gs_zauto-zusername = sy-uname.
APPEND gs_zauto TO gt_zauto.
CLEAR: gs_zauto.


            qty1 = qty1 - lv_zboxqty.
qty2 = qty2 + lv_zboxqty.
ELSE.
lv_cnt = lv_cnt + 1.
gs_zauto-zcount = lv_cnt.
CONCATENATE ls_mchd-charg '-' gs_zauto-zcount INTO lv_newgen.
gs_zauto-zbatch = lv_newgen.
gs_zauto-matnr = p_matnr.
gs_zauto-zqty = qty1.
gs_zauto-charg = ls_mchd-charg.
gs_zauto-mandt = sy-mandt.
gs_zauto-zdate = sy-datum.
gs_zauto-ztime = sy-timlo.
gs_zauto-zusername = sy-uname.
APPEND gs_zauto TO gt_zauto.
CLEAR: gs_zauto.
qty2 = qty2 + qty1.
qty1 = qty1 - qty1.
IF qty1 = 0.
EXIT.
ENDIF.
ENDIF.
ENDDO.
ENDIF.
ENDLOOP.
0 REPLIES 0