Go on link..

link us with ...

Thursday, December 30, 2010

Detailed Stock Statement

*&---------------------------------------------------------------------*
*& Report ZVVF_MR046_STOCK_DETAILS *
*& *
*&---------------------------------------------------------------------*

REPORT ZVVF_MR046_STOCK_DETAILS no standard page heading line-size 246
MESSAGE-ID ZMM .

*---------------------------------------------------------------------*
* MODULE MM. *
*---------------------------------------------------------------------*
* Objective : Detailed Stock Statement
*
*
*
* 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
MARDH, "Batch Stocks: History
MARD, "Batch Stocks
mara, "General Material Data
mbewh,
J_1IMTCHID.
*---------------------------------------------------------------------**
* Type-pools
*----------------------------------------------------------------------*
TYPE-POOLS : slis.

*---------------------------------------------------------------------*
* Types Begin with TY_ *
*---------------------------------------------------------------------*

Types : begin of ty_display,
matnr like mseg-matnr,
date type dats,
MAKTX LIKE MAKT-MAKTX,
WERKS LIKE MSEG-WERKS,
MENGE_O like MSEG-MENGE,
MENGE_R LIKE MSEG-MENGE,
MENGE_I LIKE MSEG-MENGE,
MENGE_C LIKE MSEG-MENGE,
VPRSV LIKE MBEWH-VPRSV,
VERPR LIKE MBEWH-VERPR,
STPRS LIKE MBEWH-STPRS,
MENGE_S LIKE MSEG-MENGE,
EXCSE(3) TYPE C,
end of ty_display.

types : begin of ty_MARD,
matnr like MCHB-matnr,
maktx LIKE makt-maktx,
* LGORT like MCHB-LGORT,
end of ty_MARD.

types : begin of ty_mara,
matnr like mara-matnr,
end of ty_mara.

types : begin of ty_MARDH,
matnr like MARDH-matnr,
WERKS LIKE MARDH-WERKS,
labst like MARDH-LABST,
insmt like MARDH-insmE,
EINMt LIKE MARDH-EINME,
spemt like MARDH-spemE,
end of ty_MARDH.

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,
menge like mseg-menge,
end of ty_recve.

types : begin of ty_extend,
matnr like mseg-matnr,
WERKS LIKE MCHBH-WERKS,
budat like mkpf-budat,
menge 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_MBEWH,
matnr like mbewh-matnr,
bwkey like mbewh-bwkey,
lbkum like mbewh-lbkum,
vprsv like mbewh-vprsv,
verpr like mbewh-verpr,
stprs like mbewh-stprs,
end of ty_MBEWH.

Types : begin of ty_MBEWH1,
matnr like mbewh-matnr,
vprsv like mbewh-vprsv,
verpr like mbewh-verpr,
stprs like mbewh-stprs,
lbkum like mbewh-lbkum,
salk3 like mbewh-salk3,
end of ty_MBEWH1.


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_
**---------------------------------------------------------------------*
*--- For ALV ----*
CONSTANTS: c_top_of_page_db TYPE slis_formname VALUE 'TOP_OF_PAGE_DB'.
*---------------------------------------------------------------------*
* Internal tables Begin with IT_ *
*---------------------------------------------------------------------*
*--- For ALV ----*
DATA: it_list_top_of_page TYPE slis_t_listheader,
it_events TYPE slis_t_event,
it_fieldcat TYPE slis_t_fieldcat_alv.

data : it_mseg type standard table of ty_mseg with header line,
it_mseg1 type standard table of ty_mseg with header line,
it_mARa type standard table of ty_MARa with header line,
it_mARD type standard table of ty_MARD with header line,
it_MARDH1 type standard table of ty_MARDH with header line,
it_MARDH type standard table of ty_MARDH with header line,
it_MBEWH type standard table of ty_MBEWH with header line,
it_MBEWH1 type standard table of ty_MBEWH1 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_MARD like line of it_MARD,
wa_MARDH1 like line of it_MARDH,
wa_MARDH like line of it_MARDH,
wa_MBEWH like line of it_MBEWH,
wa_MBEWH1 like line of it_MBEWH1,
wa_recve like line of it_recve,
wa_extend like line of it_extend,
wa_extend1 like line of it_extend1,
wa_display like line of it_display,
"wa_total like line of it_total,
"wa_display like line of it_display,
WA_layout TYPE slis_layout_alv. " For ALV


*---------------------------------------------------------------------*
* 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_MENGE LIKE MSEG-MENGE,
w_maktx like makt-maktx,
W_KEY LIKE INOB-OBJEK,
W_STRENGTH LIKE AUSP-ATFLV,
W_REPID LIKE SY-REPID.



*---------------------------------------------------------------------*
* Select Options Begin with SO_ *
*---------------------------------------------------------------------*


selection-screen : begin of block b1 with frame title text-023.
PARAMETERS : PR_plant LIKE mseg-werks default 'P001' .
select-options : so_matnr for mara-matnr obligatory. "Material code
select-options : so_mtart for mara-mtart. "Material Type
select-options : so_matkl for mara-matkl. "Material Group
select-options : so_date for sy-datum obligatory no-extension.
selection-screen : end of block b1.

*selection-screen : begin of block b2 with frame title text-002.
*PARAMETERS : PR_exc(1) type c .
*PARAMETERS : PR_nexc(1) type c.
*selection-screen : end of block b2.


************************************************************************


*---------------------------------------------------------------------*
* Ranges Begin with R_ *
*---------------------------------------------------------------------*


ranges : r_movtype for mseg-bwart, "Movement type
r_date for sy-datum, "Date
r_movrec for mseg-bwart,
r_moviss for mseg-bwart,
r_movtra for mseg-bwart.
*---------------------------------------------------------------------*
* Initialisation *
*---------------------------------------------------------------------*
initialization.
w_repid = SY-REPID.

*---------------------------------------------------------------------*
* 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 move_types.
perform get_mchb.
perform get_mseg.

end-of-selection.
PERFORM DATA_SUM.
PERFORM fieldcat_init USING it_fieldcat[].
PERFORM eventtab_build USING it_events[].
PERFORM comment_build USING it_list_top_of_page[].
PERFORM layout_build USING WA_layout.
PERFORM write_alv_grid.
*&---------------------------------------------------------------------*
*& Form get_mchb
*&---------------------------------------------------------------------*
form get_mchb.

IF so_date-HIGH IS INITIAL.
so_date-HIGH = so_date-LOW.
ENDIF.

select matnr from mara into CORRESPONDING FIELDS OF TABLE it_mara
where matnr in so_matnr and
matkl in so_matkl and
mtart in so_mtart.



CONCATENATE so_date-low+0(6) '01' INTO W_DATE.
W_DATE1 = W_DATE.
PERFORM FISCAL_PERIOD USING W_DATE1
CHANGING W_BUPER
W_YEAR.
w_lfmon = w_buper+1(2).

***Select all stock details from MCHB creation le selection screen high
***date
SELECT DISTINCT mard~matnr makt~maktx
FROM MARD inner join makt on
mard~matnr = makt~matnr
INTO CORRESPONDING
FIELDS OF TABLE It_MARD
for all entries in it_mara WHERE mard~MATNR = it_mara-MATNR
AND mard~WERKS = PR_plant
and makt~spras = sy-langu.
* AND LFGJA = W_YEAR
* AND LFMON = w_lfmon.
if sy-subrc = 0.

SELECT matnr BWKEY LBKUM VPRSV VERPR STPRS
FROM MBEWH INTO CORRESPONDING
FIELDS OF TABLE It_MBEWH1
FOR ALL ENTRIES IN It_Mard
WHERE BWKEY = pr_plant
AND MATNR = It_MARD-MATNR
AND LFGJA = w_year
AND LFMON = w_lfmon.


W_DATE = W_DATE - 1.
PERFORM FISCAL_PERIOD USING W_DATE
CHANGING W_BUPER
W_YEAR.
w_lfmon = w_buper+1(2).

***current stock is taken from stock history table MARDH
SELECT matnr WERKS labst insme EINMe speme
FROM MARDH INTO CORRESPONDING
FIELDS OF TABLE It_MARDH1
FOR ALL ENTRIES IN It_Mard
WHERE WERKS = pr_plant
AND MATNR = It_MARD-MATNR
AND LFGJA = w_year
AND LFMON = w_lfmon.
if sy-subrc = 0.
LOOP AT IT_Mardh1 INTO WA_Mardh1.
MOVE-CORRESPONDING WA_Mardh1 TO WA_MardH.
COLLECT WA_MardH INTO IT_MardH.
ENDLOOP.
endif.


SELECT matnr BWKEY LBKUM vprsv verpr stprs FROM MBEWH INTO
CORRESPONDING FIELDS OF TABLE It_MBEWH
FOR ALL ENTRIES IN It_Mard
WHERE BWKEY = pr_plant
AND MATNR = It_MARD-MATNR
AND LFGJA = w_year
AND LFMON = w_lfmon.


else.
message e123 with 'MARD' W_DATE1 so_date-HIGH pr_plant.
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
for all entries in it_mara where
mseg~werks = PR_plant and
mseg~matnr = it_mara-matnr and
mkpf~budat BETWEEN W_DATE1 AND so_date-HIGH .

if sy-subrc = 0.

loop at It_Mard into wa_mard.
it_mseg1[] = it_mseg[].
delete it_mseg1 where matnr ne wa_mard-matnr.
delete it_mseg1 where not bwart in r_movrec.

loop at it_mseg1 into wa_mseg where bwart in r_movrec and
matnr = wa_mard-matnr.
.
if wa_mseg-SHKZG = 'S'.
w_rmenge = w_rmenge + wa_mseg-menge .
endif.

if wa_mseg-SHKZG = 'H'.
w_imenge = w_imenge + wa_mseg-menge .
endif.

at end of budat.
w_imenge = w_imenge * ( -1 ).
wa_recve-matnr = wa_mard-matnr.
wa_recve-WERKS = pr_plant.
wa_recve-budat = wa_mseg-budat.
wa_recve-menge = w_rmenge - w_imenge.
collect wa_recve into it_recve.
clear : w_rmenge,w_imenge,wa_recve.
endat.
endloop.

it_mseg1[] = it_mseg[].
delete it_mseg1 where matnr ne wa_mard-matnr.
delete it_mseg1 where not bwart in r_moviss.

loop at it_mseg1 into wa_mseg where bwart in r_moviss and
matnr = wa_mard-matnr.
if wa_mseg-SHKZG = 'S'.
w_rmenge = w_rmenge + wa_mseg-menge .
endif.

if wa_mseg-SHKZG = 'H'.
w_imenge = w_imenge + wa_mseg-menge .
endif.

at end of budat.
w_imenge = w_imenge * ( -1 ).
wa_extend-matnr = wa_mard-matnr.
wa_extend-WERKS = pr_plant.
wa_extend-budat = wa_mseg-budat.
wa_extend-menge = w_rmenge - w_imenge.
collect wa_extend into it_extend.
clear : w_rmenge,w_imenge,wa_extend.
endat.
endloop.

it_mseg1[] = it_mseg[].
delete it_mseg1 where matnr ne wa_mard-matnr.
delete it_mseg1 where not bwart in r_movtra.

loop at it_mseg1 into wa_mseg where bwart in r_movTRA and
matnr = wa_mard-matnr.
if wa_mseg-SHKZG = 'H'.
move-corresponding wa_mseg to wa_extend.
collect wa_extend into it_extend.
endif.

if wa_mseg-SHKZG = 'S'.
move-corresponding wa_mseg to wa_recve.
collect wa_recve into it_recve.
ENDIF.
endloop.
clear :wa_extend,wa_recve.
endloop.

endif.
endform. "get_mseg

*&---------------------------------------------------------------------*
*& Form FISCAL_PERIOD
*&---------------------------------------------------------------------*
FORM FISCAL_PERIOD USING W_DATE
CHANGING W_BUPER
W_YEAR.
***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.
ENDFORM.

**&---------------------------------------------------------------------
**
**& Form DATA_SUM
**&---------------------------------------------------------------------
**
FORM DATA_SUM.

sort it_mard stable by matnr.

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.

LOOP AT IT_MARD INTO WA_MARD.

DO W_MON TIMES.

W_INDEX = SY-INDEX.

WA_DISPLAY-WERKS = pr_plant.
WA_DISPLAY-maktx = WA_MARD-MAktx.

WA_DISPLAY-MATNR = WA_MARD-MATNR.
WA_DISPLAY-DATE = W_DATE2.

IF W_INDEX = 1.
READ TABLE IT_MBEWH INTO WA_MBEWH WITH KEY MATNR = WA_MARD-MATNR.

IF SY-SUBRC = 0.
WA_DISPLAY-menge_o = WA_MBEWH-lbkum.
ENDIF.

LOOP AT IT_RECVE INTO WA_RECVE WHERE WERKS = pr_plant AND
MATNR = WA_Mard-MATNR 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 = pr_plant AND
MATNR = WA_Mard-MATNR AND
BUDAT BETWEEN W_DATE1 AND W_DATE3.
W_IMENGE = W_IMENGE + WA_EXTEND-MENGE.

ENDLOOP.

WA_DISPLAY-menge_c = WA_DISPLAY-menge_o + ( W_RMENGE - W_IMENGE ).


IF NOT so_date-LOW+6(2) = '01'.
WA_DISPLAY-menge_o = WA_DISPLAY-menge_c.
ENDIF.

CLEAR : W_RMENGE,W_IMENGE.
LOOP AT IT_RECVE INTO WA_RECVE WHERE WERKS = pr_plant AND
MATNR = WA_Mard-MATNR AND
BUDAT = W_DATE2.
W_RMENGE = W_RMENGE + WA_RECVE-MENGE.
ENDLOOP.

LOOP AT IT_EXTEND INTO WA_EXTEND WHERE WERKS = pr_plant AND
MATNR = WA_Mard-MATNR AND
BUDAT = W_DATE2.
W_IMENGE = W_IMENGE + WA_EXTEND-MENGE.

ENDLOOP.

WA_DISPLAY-menge_r = W_RMENGE.
WA_DISPLAY-menge_i = W_IMENGE.


W_MENGE = WA_DISPLAY-menge_c.

else.
WA_DISPLAY-menge_o = W_Menge.

LOOP AT IT_RECVE INTO WA_RECVE WHERE WERKS = pr_plant AND
MATNR = WA_Mard-MATNR AND
BUDAT = W_DATE2.
W_RMENGE = W_RMENGE + WA_RECVE-MENGE.
ENDLOOP.

LOOP AT IT_EXTEND INTO WA_EXTEND WHERE WERKS = pr_plant AND
MATNR = WA_Mard-MATNR AND
BUDAT = W_DATE2.
W_IMENGE = W_IMENGE + WA_EXTEND-MENGE.

ENDLOOP.

WA_DISPLAY-menge_r = W_RMENGE.
WA_DISPLAY-menge_i = W_IMENGE.
WA_DISPLAY-menge_c = WA_DISPLAY-menge_o + ( W_RMENGE - W_IMENGE ).

W_MENGE = WA_DISPLAY-menge_c.

endif.

READ TABLE IT_MBEWH INTO WA_MBEWH WITH KEY MATNR = WA_MARD-MATNR.


IF SY-SUBRC = 0.
WA_DISPLAY-vprsv = WA_MBEWH-vprsv.
WA_DISPLAY-verpr = WA_MBEWH-verpr.
WA_DISPLAY-stprs = WA_MBEWH-stprs.
ENDIF.

if not WA_DISPLAY-stprs = 0.
WA_DISPLAY-menge_s = WA_DISPLAY-menge_c * WA_DISPLAY-stprs.
endif.

if not WA_DISPLAY-verpr = 0.
WA_DISPLAY-menge_s = WA_DISPLAY-menge_c * WA_DISPLAY-verpr.
endif.


select single matnr into J_1IMTCHID-matnr from J_1IMTCHID
where WERKS = pr_plant and
matnr = WA_MARD-MATNR and
J_1ICAPIND NE 'N' .
if sy-subrc = 0.
WA_DISPLAY-excse = 'Yes'.
endif.
PERFORM MATNR_FORMAT.
append wa_display to it_display.
clear : WA_DISPLAY,W_IMENGE,W_RMENGE.
W_DATE2 = W_DATE2 + 1.
enddo.
W_DATE2 = so_date-LOW.
clear : W_index,W_MENGE.
endloop.

ENDFORM. "DATA_SUM


*&--------------------------------------------------------------------*
*& Form fieldcat_init
*&--------------------------------------------------------------------*
FORM fieldcat_init USING lt_fieldcat TYPE slis_t_fieldcat_alv.
DATA : wa_fieldcat TYPE slis_fieldcat_alv.
DATA :w_pos TYPE i VALUE 0.

w_pos = w_pos + 1.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = w_pos.
wa_fieldcat-tabname = 'IT_DISPLAY'.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-seltext_m = 'Material'.
wa_fieldcat-emphasize = 'C410'.
wa_fieldcat-outputlen = '10'.
APPEND wa_fieldcat TO lt_fieldcat.

w_pos = w_pos + 1.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = w_pos.
wa_fieldcat-tabname = 'IT_DISPLAY'.
wa_fieldcat-fieldname = 'DATE'.
wa_fieldcat-seltext_m = 'Date'.
wa_fieldcat-emphasize = 'C410'.
wa_fieldcat-outputlen = '10'.
APPEND wa_fieldcat TO lt_fieldcat.

w_pos = w_pos + 1.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = w_pos.
wa_fieldcat-tabname = 'IT_DISPLAY'.
wa_fieldcat-fieldname = 'MAKTX'.
wa_fieldcat-seltext_m = 'Material Description'.
wa_fieldcat-emphasize = 'C410'.
wa_fieldcat-outputlen = '25'.
APPEND wa_fieldcat TO lt_fieldcat.


w_pos = w_pos + 1.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = w_pos.
wa_fieldcat-tabname = 'IT_DISPLAY'.
wa_fieldcat-fieldname = 'WERKS'.
wa_fieldcat-seltext_m = 'Plant'.
wa_fieldcat-emphasize = 'C410'.
wa_fieldcat-outputlen = '5'.
APPEND wa_fieldcat TO lt_fieldcat.

w_pos = w_pos + 1.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = w_pos.
wa_fieldcat-tabname = 'IT_DISPLAY'.
wa_fieldcat-fieldname = 'MENGE_O'.
wa_fieldcat-seltext_m = 'Opening Balance'.
wa_fieldcat-do_sum = 'X'.
wa_fieldcat-emphasize = 'C410'.
wa_fieldcat-outputlen = '15'.
APPEND wa_fieldcat TO lt_fieldcat.


w_pos = w_pos + 1.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = w_pos.
wa_fieldcat-tabname = 'IT_DISPLAY'.
wa_fieldcat-fieldname = 'MENGE_R'.
wa_fieldcat-seltext_m = 'Receipts'.
wa_fieldcat-do_sum = 'X'.
wa_fieldcat-emphasize = 'C410'.
wa_fieldcat-outputlen = '15'.
APPEND wa_fieldcat TO lt_fieldcat.


w_pos = w_pos + 1.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = w_pos.
wa_fieldcat-tabname = 'IT_DISPLAY'.
wa_fieldcat-fieldname = 'MENGE_I'.
wa_fieldcat-seltext_m = 'Issues'.
wa_fieldcat-do_sum = 'X'.
wa_fieldcat-emphasize = 'C410'.
wa_fieldcat-outputlen = '15'.
APPEND wa_fieldcat TO lt_fieldcat.

w_pos = w_pos + 1.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = w_pos.
wa_fieldcat-tabname = 'IT_DISPLAY'.
wa_fieldcat-fieldname = 'MENGE_C'.
wa_fieldcat-seltext_m = 'Closing Balance'.
wa_fieldcat-do_sum = 'X'.
wa_fieldcat-emphasize = 'C410'.
wa_fieldcat-outputlen = '15'.
APPEND wa_fieldcat TO lt_fieldcat.


w_pos = w_pos + 1.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = w_pos.
wa_fieldcat-tabname = 'IT_DISPLAY'.
wa_fieldcat-fieldname = 'VPRSV'.
wa_fieldcat-seltext_m = 'Price Control'.
wa_fieldcat-emphasize = 'C410'.
wa_fieldcat-outputlen = '15'.
APPEND wa_fieldcat TO lt_fieldcat.



w_pos = w_pos + 1.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = w_pos.
wa_fieldcat-tabname = 'IT_DISPLAY'.
wa_fieldcat-fieldname = 'VERPR'.
wa_fieldcat-seltext_m = 'MAP'.
wa_fieldcat-do_sum = 'X'.
wa_fieldcat-emphasize = 'C410'.
wa_fieldcat-outputlen = '15'.
APPEND wa_fieldcat TO lt_fieldcat.

w_pos = w_pos + 1.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = w_pos.
wa_fieldcat-tabname = 'IT_DISPLAY'.
wa_fieldcat-fieldname = 'STPRS'.
wa_fieldcat-seltext_m = 'Standard Price'.
wa_fieldcat-emphasize = 'C410'.
wa_fieldcat-do_sum = 'X'.
wa_fieldcat-outputlen = '15'.
APPEND wa_fieldcat TO lt_fieldcat.


w_pos = w_pos + 1.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = w_pos.
wa_fieldcat-tabname = 'IT_DISPLAY'.
wa_fieldcat-fieldname = 'MENGE_S'.
wa_fieldcat-seltext_m = 'Stock Value'.
wa_fieldcat-emphasize = 'C410'.
wa_fieldcat-do_sum = 'X'.
wa_fieldcat-outputlen = '15'.
APPEND wa_fieldcat TO lt_fieldcat.


w_pos = w_pos + 1.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = w_pos.
wa_fieldcat-tabname = 'IT_DISPLAY'.
wa_fieldcat-fieldname = 'EXCSE'.
wa_fieldcat-seltext_m = 'Excisable'.
wa_fieldcat-emphasize = 'C410'.
wa_fieldcat-outputlen = '5'.
APPEND wa_fieldcat TO lt_fieldcat.


ENDFORM. " fieldcat_init

*&---------------------------------------------------------------------*
*& Form eventtab_build
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_it_EVENTS[] text
*----------------------------------------------------------------------*
FORM eventtab_build USING lt_events TYPE slis_t_event.
DATA: wa_event TYPE slis_alv_event.
DATA: c_top_of_page TYPE slis_formname.

c_top_of_page = c_top_of_page_db.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = lt_events.
READ TABLE lt_events WITH KEY name = slis_ev_top_of_page
INTO wa_event.
IF sy-subrc <> 0.
MOVE c_top_of_page TO wa_event-form.
APPEND wa_event TO lt_events.
ELSE.
MOVE c_top_of_page TO wa_event-form.
MODIFY lt_events FROM wa_event INDEX sy-tabix .
ENDIF.

ENDFORM. " eventtab_build

*&---------------------------------------------------------------------*
*& Form comment_build
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_it_LIST_TOP_OF_PAGE[] text
*----------------------------------------------------------------------*
FORM comment_build USING lt_top_of_page TYPE slis_t_listheader.
DATA: wa_line TYPE slis_listheader.
CLEAR wa_line.
wa_line-typ = 'H'.
wa_line-info = 'VVF LTD. Mumbai'.
APPEND wa_line TO lt_top_of_page.

wa_line-typ = 'H'.
wa_line-info = SY-ULINE.
APPEND wa_line TO lt_top_of_page.

wa_line-typ = 'H'.
wa_line-info = 'Detailed Stock Statement'.
APPEND wa_line TO lt_top_of_page.

ENDFORM. " comment_build

*&---------------------------------------------------------------------*
*& Form layout_build
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_WA_layout text
*----------------------------------------------------------------------*
FORM layout_build USING wa_layout TYPE slis_layout_alv.
wa_layout-zebra = 'X'.
wa_layout-colwidth_optimize = 'X'.
wa_layout-no_totalline = 'X'.
** wa_layout-edit = 'X'.
ENDFORM. " layout_build

*&---------------------------------------------------------------------*
*& Form write_alv_grid
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM write_alv_grid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = w_repid
i_background_id = 'ALV_BACKGROUND'
I_CALLBACK_TOP_OF_PAGE = c_top_of_page_db
is_layout = WA_layout
it_fieldcat = it_fieldcat[]
it_events = it_events[]
i_save = 'A'
TABLES
t_outtab = IT_DISPLAY
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.


ENDFORM. " write_alv_grid

*---------------------------------------------------------------------*
* FORM TOP_OF_PAGE_DB *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM TOP_OF_PAGE_DB.
*
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_list_top_of_page
i_logo = ' '.
ENDFORM. "top_of_page_db

*&--------------------------------------------------------------------*
*& Form MATNR_FORMAT
*&--------------------------------------------------------------------*
* MATNR FORMAT
*---------------------------------------------------------------------*
FORM MATNR_FORMAT.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = WA_DISPLAY-MATNR
IMPORTING
OUTPUT = WA_DISPLAY-MATNR.
ENDFORM.

form move_types.

*********************************
r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '101'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '102'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '105'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '106'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '161'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '162'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '501'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '502'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '511'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '512'.
r_movrec-high = ' '.

append r_movrec.
r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '531'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '532'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '561'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '562'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '563'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '564'.
r_movrec-high = ' '.

append r_movrec.
r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '565'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '566'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '901'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '902'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '903'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '904'.
r_movrec-high = ' '.

append r_movrec.
r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '501M'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '502M'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '701'.
r_movrec-high = ' '.
append r_movrec.

***********************************

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '451'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '452'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '453'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '454'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '455'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '456'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '457'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '458'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '459'.
r_movrec-high = ' '.
append r_movrec.

r_movrec-sign = 'I'.
r_movrec-option = 'EQ'.
r_movrec-low = '460'.
r_movrec-high = ' '.
append r_movrec.

***********************************
r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '201'.
r_moviss-high = ' '.
append r_moviss.

r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '202'.
r_moviss-high = ' '.
append r_moviss.


r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '231'.
r_moviss-high = ' '.
append r_moviss.

r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '232'.
r_moviss-high = ' '.
append r_moviss.

r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '241'.
r_moviss-high = ' '.
append r_moviss.

r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '242'.
r_moviss-high = ' '.
append r_moviss.


r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '261'.
r_moviss-high = ' '.
append r_moviss.

r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '262'.
r_moviss-high = ' '.
append r_moviss.

* Added by Sudhakar

r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '331'.
r_moviss-high = ' '.
append r_moviss.

r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '332'.
r_moviss-high = ' '.
append r_moviss.


* End of addition by Sudhakar




r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '333'.
r_moviss-high = ' '.
append r_moviss.

r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '334'.
r_moviss-high = ' '.
append r_moviss.


r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '335'.
r_moviss-high = ' '.
append r_moviss.

r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '336'.
r_moviss-high = ' '.
append r_moviss.

r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '551'.
r_moviss-high = ' '.
append r_moviss.

r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '552'.
r_moviss-high = ' '.
append r_moviss.


r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '601'.
r_moviss-high = ' '.
append r_moviss.

r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '602'.
r_moviss-high = ' '.
append r_moviss.

r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '641'.
r_moviss-high = ' '.
append r_moviss.

r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '642'.
r_moviss-high = ' '.
append r_moviss.


r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '643'.
r_moviss-high = ' '.
append r_moviss.

r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '644'.
r_moviss-high = ' '.
append r_moviss.

r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '702'.
r_moviss-high = ' '.
append r_moviss.

r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '961'.
r_moviss-high = ' '.
append r_moviss.


r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '962'.
r_moviss-high = ' '.
append r_moviss.

r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '122'.
r_moviss-high = ' '.
append r_moviss.

r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '123'.
r_moviss-high = ' '.
append r_moviss.

r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '351'.
r_moviss-high = ' '.
append r_moviss.


r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '352'.
r_moviss-high = ' '.
append r_moviss.

r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '541'.
r_moviss-high = ' '.
append r_moviss.

r_moviss-sign = 'I'.
r_moviss-option = 'EQ'.
r_moviss-low = '542'.
r_moviss-high = ' '.
append r_moviss.
***********************************

r_movtra-sign = 'I'.
r_movtra-option = 'EQ'.
r_movtra-low = '301'.
r_movtra-high = ' '.
append r_movtra.

r_movtra-sign = 'I'.
r_movtra-option = 'EQ'.
r_movtra-low = '302'.
r_movtra-high = ' '.
append r_movtra.

r_movtra-sign = 'I'.
r_movtra-option = 'EQ'.
r_movtra-low = '303'.
r_movtra-high = ' '.
append r_movtra.

r_movtra-sign = 'I'.
r_movtra-option = 'EQ'.
r_movtra-low = '304'.
r_movtra-high = ' '.
append r_movtra.

r_movtra-sign = 'I'.
r_movtra-option = 'EQ'.
r_movtra-low = '305'.
r_movtra-high = ' '.
append r_movtra.


r_movtra-sign = 'I'.
r_movtra-option = 'EQ'.
r_movtra-low = '306'.
r_movtra-high = ' '.
append r_movtra.

r_movtra-sign = 'I'.
r_movtra-option = 'EQ'.
r_movtra-low = '309'.
r_movtra-high = ' '.
append r_movtra.

r_movtra-sign = 'I'.
r_movtra-option = 'EQ'.
r_movtra-low = '310'.
r_movtra-high = ' '.
append r_movtra.
*************************************

endform.

No comments:

link us...

For Visitors

if you want to publish or Add something on ERP, SAP , SAP FUNCTIONAL, SAP ABAP then mail us along with your email-id. contain must be yours

email-id :- avinashkr_raj@yahoo.com(any email)

email-id :- avinaskr_raj.abap@blogger.com ( use only gmail)