2008 Mar 18 3:27 AM
hi,
in dis report i am able to display the stock accoring half month wise i.e. if date < = 15 then it i will display the stock previous month last date and if date >= 16 then it will display the stock of present month last date.
and now,i want to do add data that if it <= 15 (date) then i will be able to add data from mseg and if it is >= 16 (date) then it will subtract the data from zstocksum from the value coming from mseg.
plzz abppaers help me out its my job on he online as help will be definately rewarded.
********NEW CHANGE AS ON 16.03.2008*******
SELECT ASTLDATE AMATNR AWERKS ALGORT ASTDEBIT ASTCREDIT
BMEINS BMTART BMATKL BNTGEW B~GEWEI
FROM ZSTOCKSUM AS A
INNER JOIN MARA AS B ON AMATNR = BMATNR
INTO TABLE STIT
WHERE AWERKS = P_WERKS AND MTART IN MAT_TYPE AND AMATNR IN P_MATNR AND STLDATE <= P_DATE
AND ( MTART = 'FERT' OR MTART = 'HALB' OR MTART = 'ZBOP' OR MTART = 'ZSCR' OR MTART = 'ROH' )
AND A~LGORT IN P_STLOC.
SELECT BBUDAT AMATNR AWERKS ALGORT AMENGE AERFMG
CMEINS CMTART CMATKL CNTGEW CGEWEI AMJAHR
FROM MSEG AS A INNER JOIN MKPF AS B ON AMBLNR = BMBLNR AND AMJAHR = BMJAHR
INNER JOIN MARA AS C ON AMATNR = CMATNR
INTO TABLE ITMSEG WHERE AWERKS = P_WERKS AND MTART IN MAT_TYPE AND AMATNR IN P_MATNR AND BUDAT <= P_DATE
AND ( MTART = 'FERT' OR MTART = 'HALB' OR MTART = 'ZBOP' OR MTART = 'ZSCR' OR MTART = 'ROH' )
AND A~LGORT IN P_STLOC.
INSERT LINES OF ITMSEG INTO TABLE STIT.
******************************************
ITAB] = STIT[.
SORT ITAB BY MATNR WERKS LGORT MEINS MTART MATKL NTGEW GEWEI NTGEW.
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING MATNR WERKS LGORT MEINS MTART MATKL NTGEW GEWEI NTGEW.
SORT STIT BY MATNR LGORT.
SORT ITAB BY MATNR LGORT.
LOOP AT ITAB.
V_QTY = 0.
V_QTY1 = 0.
*************************NEW*****************************
LOOP AT STIT WHERE MATNR = ITAB-MATNR AND LGORT = ITAB-LGORT.
V_QTY = V_QTY + STIT-STDEBIT - STIT-STCREDIT.
ENDLOOP.
********************************************************************
IF V_QTY 0.
ITAB-STOCK = V_QTY.
IF ITAB-NTGEW 0 AND ITAB-GEWEI 'KG'.
CALL FUNCTION 'ZGET_ITEM_WEIGHT'
EXPORTING
P_BUID = ITAB-WERKS
P_ITEMID = ITAB-MATNR
P_QTY = ITAB-NTGEW
P_UOM = ITAB-GEWEI
P_UOM1 = 'KG'
IMPORTING
P_RETVAL = ITAB-WTKG.
ENDIF.
ENDIF.
CONVERTING ITEM QTY IN KG
ITAB-WT = ITAB-STOCK.
IF ITAB-MEINS = 'G'.
ITAB-WT = ITAB-STOCK / 1000000.
ELSEIF ITAB-MEINS = 'KG'.
ITAB-WT = ITAB-STOCK / 1000.
ELSEIF ITAB-MEINS 'TO'.
ITAB-WT = ITAB-STOCK * ITAB-WTKG / 1000.
ENDIF.
MODIFY ITAB.
ENDIF.
ENDLOOP.
endform. " GET_INI_DATA
&----
*& Form GET_GRP_DATA
&----
text
-
--> p1 text
<-- p2 text
-
form GET_GRP_DATA .
SELECT LGORT LGOBE FROM T001L INTO TABLE SLIT WHERE WERKS = P_WERKS.
SORT SLIT BY LGORT.
SORT ITAB BY LGORT MTART.
LOOP AT SLIT.
LOOP AT ITAB WHERE MTART = 'ROH' AND LGORT = SLIT-LGORT AND STOCK <> 0.
SLIT-ROH = SLIT-ROH + ITAB-WT.
ENDLOOP.
LOOP AT ITAB WHERE MTART = 'ZBOP' AND LGORT = SLIT-LGORT AND STOCK 0.
SLIT-ZBOP = SLIT-ZBOP + ITAB-WT.
ENDLOOP.
LOOP AT ITAB WHERE MTART = 'HALB' AND LGORT = SLIT-LGORT AND STOCK 0.
SLIT-HALB = SLIT-HALB + ITAB-WT.
ENDLOOP.
LOOP AT ITAB WHERE MTART = 'FERT' AND LGORT = SLIT-LGORT AND STOCK 0.
SLIT-FERT = SLIT-FERT + ITAB-WT.
ENDLOOP.
LOOP AT ITAB WHERE MTART = 'ZSCR' AND LGORT = SLIT-LGORT AND STOCK 0.
SLIT-ZSCR = SLIT-ZSCR + ITAB-WT.
ENDLOOP.
SLIT-TOT = SLIT-ROH + SLIT-ZBOP + SLIT-HALB + SLIT-FERT + SLIT-ZSCR.
IF SLIT-TOT = 0.
DELETE SLIT.
ELSE.
MODIFY SLIT.
ENDIF.
ENDLOOP.
endform. " GET_GRP_DATA
&----
*& Form PRN_ITSTOCK
&----
text
-
--> p1 text
<-- p2 text
-
form PRN_ITSTOCK .
Data : hdr type c length 100,
V_PTYPE LIKE MARA-MTART,
V_PSTLOC LIKE MSEG-LGORT,
V_ITEM LIKE MAKT-MAKTX,
T_QTY1 TYPE P LENGTH 12 DECIMALS 3,
T_QTY2 TYPE P LENGTH 12 DECIMALS 3,
T_QTY3 TYPE P LENGTH 12 DECIMALS 3,
T_WT1 TYPE P LENGTH 12 DECIMALS 3,
T_WT2 TYPE P LENGTH 12 DECIMALS 3,
T_WT3 TYPE P LENGTH 12 DECIMALS 3.
hdr = 'INVENTORY REPORT '.
IF V_CHDR = 'ROH'.
CONCATENATE HDR '(RAW MATERIAL) ' INTO HDR.
ELSEIF V_CHDR = 'ZBOP'.
CONCATENATE HDR '(BOP) ' INTO HDR.
ELSEIF V_CHDR = 'HALB'.
CONCATENATE HDR '(SEMI-FININSHED GOODS) ' INTO HDR.
ELSEIF V_CHDR = 'FERT'.
CONCATENATE HDR '(FINISHED GOODS) ' INTO HDR.
ELSEIF V_CHDR = 'ZSCR'.
CONCATENATE HDR '(SCRAP) ' INTO HDR.
ENDIF.
WRITE : / HDR.
uline.
*WRITE : / ' ITEM ID DESCRIPTION UOM GRP ITEM WT (KG.) STOCK QTY. STOCK TONS'.
WRITE : / ' ITEM ID DESCRIPTION UOM GROUP NET.WT. STOCK QTY. STOCK (TONS)'.
ULINE.
SORT ITAB BY MTART LGORT MATNR.
T_QTY1 = 0.
T_WT1 = 0.
LOOP AT ITAB1.
WRITE : / 'MATERIAL TYPE : ', ITAB1-MTART.
T_QTY2 = 0.
T_WT2 = 0.
LOOP AT ITAB2.
WRITE : / ' STORAGE LOCATION : ' , ITAB2-LGORT.
T_QTY3 = 0.
T_WT3 = 0.
LOOP AT ITAB WHERE MTART = ITAB1-MTART AND LGORT = ITAB2-LGORT.
SELECT SINGLE MAKTX FROM MAKT INTO V_ITEM WHERE MATNR = ITAB-MATNR.
WRITE : / ' ' ,(8) ITAB-MATNR,(40) V_ITEM,(3) ITAB-MEINS,' ', ITAB-MATKL, ' ',(10) ITAB-WTKG,(13) ITAB-STOCK, (13) ITAB-WT.
T_QTY3 = T_QTY3 + ITAB-STOCK.
T_WT3 = T_WT3 + ITAB-WT.
ENDLOOP.
T_QTY2 = T_QTY2 + T_QTY3.
T_WT2 = T_WT2 + T_WT3.
WRITE : / ' -
'.
WRITE : / ' TOTAL : ',(13) T_QTY3, (13) T_WT3.
WRITE : / ' -
'.
ENDLOOP.
T_QTY1 = T_QTY1 + T_QTY2.
T_WT1 = T_WT1 + T_WT2.
WRITE : / ' ----------------------------'.
WRITE : / ' TOTAL : ',(13) T_QTY2, (13) T_WT2.
WRITE : / ' -
'.
ENDLOOP.
*WRITE : / ' -
'.
WRITE : / ' GRAND TOTAL : ',(13) T_QTY1, (13) T_WT1.
WRITE : / ' -
'.
endform. " PRN_ITSTOCK
&----
*& Form PRN_SMSTOCK
&----
text
-
--> p1 text
<-- p2 text
-
form PRN_SMSTOCK_TXT .
DATA : Q TYPE P LENGTH 12 DECIMALS 3,
TROH TYPE P LENGTH 12 DECIMALS 3,
TBOP TYPE P LENGTH 12 DECIMALS 3,
THALB TYPE P LENGTH 12 DECIMALS 3,
TFERT TYPE P LENGTH 12 DECIMALS 3,
TSCR TYPE P LENGTH 12 DECIMALS 3,
TSL TYPE P LENGTH 12 DECIMALS 3.
WRITE : / 'INVENTORY REPORT AS ON : ', aa , ' PLANT : ', P_WERKS, ' PRINTING DATE : ', SY-DATUM, ' CONTROL NO.: FM 888 REV-00'.
WRITE : / '(in Tons)', 121 'DATE : 20.11.07'.
ULINE.
FORMAT COLOR COL_GROUP ON.
WRITE : / SY-VLINE,(10) 'ST.LOC.', SY-VLINE, (25) 'ST. LOCATION ', SY-VLINE, (15) 'RAW MATERIAL', SY-VLINE, (15) ' BOP', SY-VLINE, (15) 'FIN. GOODS',
SY-VLINE, (15) 'WIP GOODS', SY-VLINE, (15) 'SCRAPS', SY-VLINE, (15) ' TOTAL ', SY-VLINE.
ULINE.
TROH = 0.
TBOP = 0.
THALB = 0.
TFERT = 0.
TSCR = 0.
FORMAT COLOR COL_NORMAL ON.
LOOP AT SLIT.
Q = SLIT-ROH + SLIT-ZBOP + SLIT-FERT + SLIT-HALB + SLIT-ZSCR.
IF Q 0.
TSL = SLIT-ROH + SLIT-ZBOP + SLIT-HALB + SLIT-FERT + SLIT-ZSCR.
WRITE : / SY-VLINE,(10) SLIT-LGORT, SY-VLINE, (25) SLIT-LGOBE, SY-VLINE, (13) SLIT-ROH,' ', SY-VLINE, (13) SLIT-ZBOP, ' ', SY-VLINE, (13) SLIT-FERT, ' ',
SY-VLINE,(13) SLIT-HALB, ' ', SY-VLINE,(13) SLIT-ZSCR, ' ',SY-VLINE,(13) SLIT-TOT, ' ',SY-VLINE.
ULINE.
TROH = TROH + SLIT-ROH.
TBOP = TBOP + SLIT-ZBOP.
THALB = THALB + SLIT-HALB.
TFERT = TFERT + SLIT-FERT.
TSCR = TSCR + SLIT-ZSCR.
SLIT-CRROW = SY-LINNO - 2.
MODIFY SLIT.
V_MAXROW = SLIT-CRROW.
WRITE : SLIT-FERT, SLIT-HALB, SLIT-ZSCR.
ENDIF.
ENDLOOP.
TSL = TROH + TBOP + THALB + TFERT + TSCR.
WRITE : / SY-VLINE, (38) 'T O T A L ', SY-VLINE, (13) TROH,' ', SY-VLINE, (13) TBOP, ' ', SY-VLINE, (13) TFERT, ' ',
SY-VLINE,(13) THALB, ' ', SY-VLINE,(13) TSCR, ' ',SY-VLINE,(13) TSL, ' ',SY-VLINE.
ULINE.
endform. " PRN_SMSTOCK
&----
*& Form PRN_SMSTOCK_ALV
&----
text
-
--> p1 text
<-- p2 text
-
form PRN_SMSTOCK_ALV .
endform.
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
ENDFORM.
&----
*& Form GET_PARM
&----
text
-
--> p1 text
<-- p2 text
-
form GET_PARM .
CLEAR ITAB1.
REFRESH ITAB1.
IF V_COL > 44.
IF V_COL >= 44 AND V_COL <= 60.
V_CHDR = 'ROH'.
ITAB1-MTART = V_CHDR.
APPEND ITAB1.
ELSEIF V_COL >= 62 AND V_COL <= 78.
V_CHDR = 'ZBOP'.
ITAB1-MTART = V_CHDR.
APPEND ITAB1.
ELSEIF V_COL >= 80 AND V_COL <= 96.
V_CHDR = 'FERT'.
ITAB1-MTART = V_CHDR.
APPEND ITAB1.
ELSEIF V_COL >= 98 AND V_COL <= 114.
V_CHDR = 'HALB'.
ITAB1-MTART = V_CHDR.
APPEND ITAB1.
ELSEIF V_COL >= 116 AND V_COL <= 132.
V_CHDR = 'ZSCR'.
ITAB1-MTART = V_CHDR.
APPEND ITAB1.
ELSEIF V_COL >= 134 AND V_COL <= 160.
V_CHDR = 'TOT'.
ITAB1-MTART = 'ROH'.
APPEND ITAB1.
ITAB1-MTART = 'ZBOP'.
APPEND ITAB1.
ITAB1-MTART = 'FERT'.
APPEND ITAB1.
ITAB1-MTART = 'HALB'.
APPEND ITAB1.
ITAB1-MTART = 'ZSCR'.
APPEND ITAB1.
ENDIF.
CLEAR ITAB2.
REFRESH ITAB2.
READ TABLE SLIT WITH KEY CRROW = V_ROW.
IF SY-SUBRC = 0.
V_RHDR = SLIT-LGORT.
ITAB2-LGORT = V_RHDR.
APPEND ITAB2.
ELSE.
IF V_ROW > V_MAXROW.
IF V_CHDR 'TOT'.
DATA : PTXT LIKE MSEG-LGORT.
SORT ITAB BY MTART LGORT.
PTXT = ''.
LOOP AT ITAB WHERE MTART = V_CHDR AND STOCK 0.
IF PTXT ITAB-LGORT.
ITAB2-LGORT = ITAB-LGORT.
APPEND ITAB2.
PTXT = ITAB-LGORT.
ENDIF.
ENDLOOP.
ELSE.
V_ROW = 999.
ENDIF.
ELSE.
V_ROW = 999.
CLEAR ITAB1.
REFRESH ITAB1.
ENDIF.
ENDIF.
ELSE.
V_CHDR = ''.
V_RHDR = ''.
ENDIF.
endform. " GET_PARM
Edited by: ric .s on Mar 18, 2008 4:39 AM
Edited by: ric .s on Mar 18, 2008 5:18 AM
2008 Mar 18 4:31 AM
Hi,
The problem is with this statement.
INSERT LINES OF ITMSEG INTO TABLE STIT
You cant insert one internal table to other if they have different structures. Change ur logic accordingly.
Reward if helpful.
regards,
Ramya
2008 Mar 18 4:43 AM
HI,
I had checked the structure of it and now it is working ok .
I had written commit work after insertion of lines and corrected my itabs as there was 1 extra field in 1 itab whihc is not allowing the work to do.
and now,i want to do add data that if it <= 15 (p_date) then i will be able to add data from mseg and if it is >= 16 (p_date) then it will subtract the data from zstocksum from the value coming from mseg.
how should i do dis?
Edited by: ric .s on Mar 18, 2008 6:08 AM
Edited by: ric .s on Mar 18, 2008 6:41 AM
Edited by: ric .s on Mar 18, 2008 7:51 AM