SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
SELECT-OPTIONS: mtart FOR mara-mtart, "Material Type
matnr FOR mseg-matnr , " Material
matkl FOR mara-matkl , " Material Group
bwkey FOR mseg-werks OBLIGATORY, "Plant
lgort FOR mseg-lgort, " Storage Location
bwtar FOR mseg-bwtar," Valuation type
budat FOR mkpf-budat OBLIGATORY. " Date
SELECTION-SCREEN END OF SCREEN 100.
SELECTION-SCREEN: BEGIN OF TABBED BLOCK b2 FOR 8 LINES,
TAB (50) title USER-COMMAND '' DEFAULT SCREEN 100,
END OF BLOCK b2.
INITIALIZATION.
title = 'Daily Stock Position.'.
START-OF-SELECTION.
DATA: date(2) TYPE n.
DATA: year(4) TYPE n.
DATA : tdate(2) TYPE n.
DATA: fdate TYPE sy-datum, pdate TYPE sy-datum.
DATA: period(10) TYPE c,
period2(10) TYPE c.
DATA: c_user_command TYPE slis_formname VALUE 'USER_COMMAND'.
DATA: language LIKE sy-langu,
dat_val LIKE sy-datum.
DATA: heading TYPE string,
head1 TYPE string,
head2 TYPE string,
head3 TYPE string.
DATA: test LIKE t247-ktx.
DATA : langu_back LIKE sy-langu,
longtext LIKE t247-ltx,
ld_lines TYPE i,
message_text TYPE string.
DATA: end_date LIKE sy-datum,
start_date LIKE sy-datum.
TYPE-POOLS: slis.
DATA: fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat LIKE LINE OF fieldcat,
i_sort TYPE slis_t_sortinfo_alv,
w_sort LIKE LINE OF i_sort,
fieldcatalog TYPE slis_fieldcat_alv,
layout TYPE slis_layout_alv,
sort TYPE slis_sortinfo_alv,
gd_repid LIKE sy-repid.
DATA: BEGIN OF itab OCCURS 0,
matkl LIKE mara-matkl, " Material group.
matnr LIKE mseg-matnr, " Material Number.
maktx LIKE makt-maktx, " Material Description.
bwtar LIKE mseg-bwtar, " Valuation type.
opstock LIKE mseg-erfmg, " Opening Stock.
rtodate LIKE mseg-erfmg, "Recieved to date.
trecv1 LIKE mseg-erfmg, " Total recieved OPSTOCK.
trecv2 LIKE mseg-erfmg, " Total recieved CLSTOCK.
itodate LIKE mseg-erfmg, "Issued to date.
tissued1 LIKE mseg-erfmg, " Total issued OPSTOCK.
tissued2 LIKE mseg-erfmg, " Total issued CLSTOCK.
clstock LIKE mseg-erfmg, " Closing Stock.
srrm LIKE mseg-erfmg, " Store return End date.
isd LIKE mseg-erfmg, " Issued to End Date.
rtd LIKE mseg-erfmg, " Reciept to end date.
mtart LIKE mara-mtart, "Material Type
wgbez LIKE t023t-wgbez, "Material Group Description.
mtbez LIKE t134t-mtbez, "Material type Description.
bwkey LIKE mseg-werks, "Valuation Area " Plant.
meins LIKE mara-meins, " Base Unit Measure.
d1 LIKE mkpf-budat, " From Date.
d2 LIKE mkpf-budat, "To Date.
mabst LIKE marc-mabst, "Maximum Stock Level.
minbe LIKE marc-mabst, "Reorder Point.
sr LIKE mseg-erfmg, "Store return.
srd LIKE mseg-erfmg, "Store to Date.
rj LIKE mseg-erfmg, "Rejection.
rjd LIKE mseg-erfmg, "Rejection to date.
END OF itab.
DATA: BEGIN OF itab2 OCCURS 0,
matkl LIKE mara-matkl, " Material group.
matnr LIKE mseg-matnr, " Material Number.
maktx LIKE makt-maktx, " Material Description.
bwtar LIKE mseg-bwtar, " Valuation type.
bwart LIKE mseg-bwart, "Movement type.
erfmg LIKE mseg-erfmg, " Opening Stock.
budat LIKE mkpf-budat, " Posting Date.
mblnr LIKE mkpf-mblnr, " Document Number.
shkzg LIKE mseg-shkzg,
lgort LIKE mseg-lgort,
mtart LIKE mara-mtart, "Material Type
wgbez LIKE t023t-wgbez, "Material Group Description.
mtbez LIKE t134t-mtbez, "Material type Description.
werks LIKE mseg-werks, "Valuation Area " Plant.
meins LIKE mara-meins, " Base Unit Measure.
d1 LIKE mkpf-budat, " From Date.
d2 LIKE mkpf-budat, "To Date.
mabst LIKE marc-mabst, "Maximum Stock Level.
minbe LIKE marc-mabst, "Reorder Point.
END OF itab2.
DATA: itab3 LIKE TABLE OF itab WITH HEADER LINE.
DATA: itab4 LIKE TABLE OF itab2 WITH HEADER LINE.
DESCRIBE TABLE itab LINES ld_lines.
message_text = ld_lines.
CONCATENATE message_text 'items displayed' INTO message_text SEPARATED BY space.
MESSAGE s000(zhak) WITH message_text .
*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM get_data.
SELECT * "mseg~matnr matkl maktx bwtar bwart erfmg budat mkpf~mblnr shkzg
INTO CORRESPONDING FIELDS OF TABLE itab2
FROM mseg
INNER JOIN mkpf ON mseg~mblnr = mkpf~mblnr
INNER JOIN makt ON mseg~matnr = makt~matnr
INNER JOIN mara ON mseg~matnr = mara~matnr
WHERE mseg~matnr IN matnr AND werks IN bwkey
AND budat IN budat AND matkl IN matkl AND mtart IN mtart
AND bwtar IN bwtar AND lgort IN lgort.
" GROUP BY mseg~matnr matkl maktx bwtar bwart erfmg budat mkpf~mblnr shkzg.
SORT itab2 BY mblnr.
SELECT * "mseg~matnr matkl maktx bwtar bwart erfmg budat mkpf~mblnr shkzg
INTO CORRESPONDING FIELDS OF TABLE itab4
FROM mseg
INNER JOIN mkpf ON mseg~mblnr = mkpf~mblnr
INNER JOIN makt ON mseg~matnr = makt~matnr
INNER JOIN mara ON mseg~matnr = mara~matnr
WHERE mseg~matnr IN matnr AND werks IN bwkey
AND budat LE end_date AND matkl IN matkl
AND mtart IN mtart AND bwtar IN bwtar AND lgort IN lgort.
" GROUP BY mseg~matnr matkl maktx bwtar bwart erfmg budat mkpf~mblnr shkzg.
SORT itab4 BY mblnr.
ENDFORM. "get_data
*&---------------------------------------------------------------------*
*& Form get_previous_month_last_date
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM get_previous_month_last_date.
end_date = budat-low.
end_date+6(2) = '01'.
end_date = end_date - 1.
ENDFORM. "get_previous_month_last_date
*&---------------------------------------------------------------------*
*& Form organize_detail
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM organize_detail.
LOOP AT itab4.
itab3-matkl = itab4-matkl.
itab3-matnr = itab4-matnr.
itab3-maktx = itab4-maktx.
itab3-bwtar = itab4-bwtar.
itab3-mtart = itab4-mtart.
itab3-bwkey = itab4-werks.
itab3-meins = itab4-meins.
SELECT wgbez FROM t023t INTO itab3-wgbez WHERE matkl = itab4-matkl. ENDSELECT.
SELECT mtbez FROM t134t INTO itab3-mtbez WHERE mtart = itab4-mtart. ENDSELECT.
SELECT mabst FROM marc INTO itab3-mabst WHERE werks = itab4-werks AND matnr = itab2-matnr. ENDSELECT.
SELECT minbe FROM marc INTO itab3-minbe WHERE werks = itab4-werks AND matnr = itab2-matnr. ENDSELECT.
SELECT wgbez FROM t023t INTO itab3-wgbez WHERE matkl = itab2-matkl. ENDSELECT.
SELECT mtbez FROM t134t INTO itab3-mtbez WHERE mtart = itab2-mtart. ENDSELECT.
SELECT mabst FROM marc INTO itab3-mabst WHERE werks = itab2-werks AND matnr = itab2-matnr. ENDSELECT.
SELECT minbe FROM marc INTO itab3-minbe WHERE werks = itab2-werks AND matnr = itab2-matnr. ENDSELECT.
IF itab2-shkzg = 'H' AND ( itab2-bwart = 201 OR itab2-bwart = 311 OR itab2-bwart = 351 ). .
itab3-tissued2 = itab2-erfmg.
ELSEIF itab2-shkzg = 'S' AND ( itab2-bwart = 101 OR itab2-bwart = 105 ).
itab3-trecv2 = itab2-erfmg.
ELSEIF itab2-shkzg = 'S' AND ( itab2-bwart = 202
OR itab2-bwart = 312 OR itab2-bwart = 352 AND budat = budat-high ).
itab3-isd = itab2-erfmg.
ELSEIF itab2-shkzg = 'S' AND ( itab2-bwart = 101 OR itab2-bwart = 351
OR itab2-bwart = 105 OR itab2-bwart = 103 AND budat = budat-high OR itab2-bwart = 561 ).
itab3-rtd = itab2-erfmg.
ENDIF.
itab3-trecv2 = itab3-trecv2 - itab3-rtd.
itab3-tissued2 = itab3-tissued2 - itab3-isd.
itab3-clstock = itab3-opstock + itab3-trecv2 - itab3-tissued2.
* Store Return.
IF itab2-shkzg = 'S' AND ( itab2-bwart = 202
OR itab2-bwart = 312 OR itab2-bwart = 561 ).
itab3-sr = itab2-erfmg.
ENDIF.
* Store Return to date.
IF itab2-shkzg = 'S' AND ( itab2-bwart = 202 OR itab2-bwart = 312 OR itab2-bwart = 561 AND budat = budat-high ).
itab3-srd = itab2-erfmg.
ENDIF.
*Rejection Overall.
IF itab2-shkzg = 'H' AND ( itab2-bwart = 122 OR itab2-bwart = 124 ).
itab3-rj = itab2-erfmg.
ENDIF.
*Rejection to Date.
IF itab2-shkzg = 'H' AND ( itab2-bwart = 122 OR itab2-bwart = 124 AND budat = budat-high ).
itab3-rjd = itab2-erfmg.
ENDIF.
COLLECT itab3 INTO itab.
MOVE-CORRESPONDING itab3 TO itab.
APPEND itab3.
CLEAR itab3.
ENDLOOP.
ENDFORM. "organize_detail
*&---------------------------------------------------------------------*
*& Form top-of-page
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM top-of-page.
*ALV Header declarations
DATA: t_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader,
t_line LIKE wa_header-info,
ld_lines TYPE i,
ld_linesc(10) TYPE c.
* Title
wa_header-typ = 'H'.
wa_header-info = 'Tri-Pack Films Limited'.
APPEND wa_header TO t_header.
CLEAR wa_header.
wa_header-typ = 'H'.
wa_header-info = 'Daily Stock Position Report.'.
APPEND wa_header TO t_header.
CLEAR wa_header.
* Date
wa_header-typ = 'S'.
wa_header-key = 'Report Date: '.
CONCATENATE sy-datum+6(2) sy-datum+4(2) sy-datum+0(4) INTO period SEPARATED BY '/'.
CONCATENATE period ' ' ' ' INTO wa_header-info SEPARATED BY ' ' .
APPEND wa_header TO t_header.
CLEAR: wa_header.
* Total No. of Records Selected
DESCRIBE TABLE itab LINES ld_lines.
ld_linesc = ld_lines.
CONCATENATE 'Total No. of Records Selected: ' ld_linesc
INTO t_line SEPARATED BY space.
wa_header-typ = 'A'.
wa_header-info = t_line.
APPEND wa_header TO t_header.
CLEAR: wa_header, t_line.
*&---------------------------------------------------------------------*
*& Form build_fieldcat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM build_fieldcat .
*&---------------------------------------------------------------------*
*& Form display_alv_report
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM display_alv_report .
gd_repid = sy-repid.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.