0% found this document useful (0 votes)
148 views7 pages

ZPP 007

This document defines the data types, internal tables, and variables used to generate a report displaying material planning information. It selects data from various tables related to materials, plants, and quantities. The data is then consolidated into a final table that is displayed to the user in an ALV grid, allowing them to view material planning data for selected plants, dates, and storage locations.

Uploaded by

Gurunath reddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
148 views7 pages

ZPP 007

This document defines the data types, internal tables, and variables used to generate a report displaying material planning information. It selects data from various tables related to materials, plants, and quantities. The data is then consolidated into a final table that is displayed to the user in an ALV grid, allowing them to view material planning data for selected plants, dates, and storage locations.

Uploaded by

Gurunath reddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 7

*&---------------------------------------------------------------------*

*& Report ZPP007


*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT zpp007.
TABLES: mseg.
*&---------------------------------------------------------------------*
*- Type-Pools Declaration
*&---------------------------------------------------------------------*
TYPE-POOLS: slis.
*&---------------------------------------------------------------------*
*- Structure Declaration
*&---------------------------------------------------------------------*
TYPES: BEGIN OF ty_val,
matnr TYPE blpk-matnr,
werks TYPE blpk-werks,
verid TYPE blpk-verid,
budat TYPE blpk-budat,
acharg TYPE blpk-acharg,
belnr TYPE mseg-belnr,
mtart TYPE mara-mtart,
END OF ty_val.

TYPES: BEGIN OF ty_marc,


matnr TYPE marc-matnr,
werks TYPE marc-werks,
dispo TYPE marc-dispo,
END OF ty_marc.

TYPES: BEGIN OF ty_makt,


matnr TYPE makt-matnr,
spras TYPE makt-spras,
maktx TYPE makt-maktx,
END OF ty_makt.

TYPES: BEGIN OF ty_t024d,


werks TYPE t024d-werks,
dispo TYPE t024d-dispo,
dsnam TYPE t024d-dsnam,
END OF ty_t024d.

TYPES: BEGIN OF ty_mseg,


mblnr TYPE mseg-mblnr,
bwart TYPE mseg-bwart,
lgort TYPE mseg-lgort,
menge TYPE mseg-menge,
meins TYPE mseg-meins,
END OF ty_mseg.

TYPES: BEGIN OF ty_temp,


mblnr TYPE mseg-mblnr,
menge TYPE mseg-menge,
menge1 TYPE mseg-menge,
* meins TYPE mseg-meins,
END OF ty_temp.

TYPES: BEGIN OF ty_final,


werks TYPE blpk-werks,
budat TYPE blpk-budat,
matnr TYPE blpk-matnr,
maktx TYPE makt-maktx,
lgort TYPE mseg-lgort,
verid TYPE blpk-verid,
dispo TYPE t024d-dispo,
dsnam TYPE t024d-dsnam,
menge TYPE mseg-menge,
meins TYPE mseg-meins,
acharg TYPE blpk-acharg,
mblnr TYPE mseg-mblnr, "Added by Bency, TR : E10K956556
END OF ty_final.

*&---------------------------------------------------------------------*
*- Internal table Declaration
*&---------------------------------------------------------------------*
DATA: lt_val TYPE TABLE OF ty_val,
lt_marc TYPE TABLE OF ty_marc,
lt_makt TYPE TABLE OF ty_makt,
lt_t024d TYPE TABLE OF ty_t024d,
lt_mseg TYPE TABLE OF ty_mseg,
lt_temp TYPE TABLE OF ty_temp,
lt_final TYPE TABLE OF ty_final.
DATA : i_t001w TYPE STANDARD TABLE OF t001w.
DATA : w_t001w TYPE t001w.
*&---------------------------------------------------------------------*
*- Work Area Declartion
*&---------------------------------------------------------------------*
DATA: ls_val TYPE ty_val,
ls_marc TYPE ty_marc,
ls_makt TYPE ty_makt,
ls_t024d TYPE ty_t024d,
ls_mseg TYPE ty_mseg,
ls_temp TYPE ty_temp,
ls_final TYPE ty_final.

*&---------------------------------------------------------------------*
*- Local Variable Declaration
*&---------------------------------------------------------------------*
DATA: lv_pos TYPE i.
*----------------------------------------------------------------------*
* DECLARATION FOR FIELDCATALOG
*----------------------------------------------------------------------*
*- Declaration for fieldcatalog.
DATA: lt_fieldcat TYPE slis_t_fieldcat_alv,
ls_fieldcat TYPE slis_fieldcat_alv,
ls_layout TYPE slis_layout_alv.

*&---------------------------------------------------------------------*
*- Selection Screen
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
SELECT-OPTIONS : s_werks FOR ls_val-werks OBLIGATORY,
s_budat FOR ls_val-budat,
s_mtart FOR ls_val-mtart,
s_lgort FOR mseg-lgort.
SELECTION-SCREEN END OF BLOCK b1.

*&---------------------------------------------------------------------*
*& At Selection Screen *
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN.

SELECT * FROM t001w


INTO TABLE i_t001w
WHERE werks IN s_werks.

DELETE i_t001w WHERE werks EQ '0001'.

LOOP AT i_t001w INTO w_t001w.


AUTHORITY-CHECK OBJECT 'C_BACKFL'
ID 'WERKS' FIELD w_t001w-werks.
IF sy-subrc NE 0.
MESSAGE e001(38) WITH 'You are not authorizated to use Plant'
w_t001w-werks.
ENDIF.
AUTHORITY-CHECK OBJECT 'ZSDWERKS'
ID 'WERKS' FIELD w_t001w-werks.
IF sy-subrc NE 0.
MESSAGE e001(38) WITH 'You are not authorizated to use Plant'
w_t001w-werks.
ENDIF.
CLEAR : w_t001w.
ENDLOOP.

*&---------------------------------------------------------------------*
*- Start Of Selection
*&---------------------------------------------------------------------*
START-OF-SELECTION.
*- Clearing the memory of internal table
REFRESH:lt_val,lt_marc,lt_makt,lt_t024d,lt_mseg,lt_final.

*- Selecting the value from MDBP table and MARA table


SELECT a~matnr
werks
verid
budat
acharg
belnr
b~mtart
FROM mdbp AS a
INNER JOIN mara AS b
ON a~matnr = b~matnr
INTO TABLE lt_val
WHERE werks IN s_werks AND
budat IN s_budat AND
mtart IN s_mtart AND
( mtart = 'ZFGD' OR
mtart = 'ZFGE' OR
mtart = 'ZSFG' ).

IF lt_val IS NOT INITIAL.


*- Selecting the values from MARC for MRP Controller
SELECT matnr
werks
dispo
FROM marc
INTO TABLE lt_marc
FOR ALL ENTRIES IN lt_val
WHERE matnr = lt_val-matnr AND
werks = lt_val-werks.

IF lt_marc IS NOT INITIAL.


*- Selecting the discription for MRP CONTROLLER
SELECT werks
dispo
dsnam
FROM t024d
INTO TABLE lt_t024d
FOR ALL ENTRIES IN lt_marc
WHERE werks = lt_marc-werks AND
dispo = lt_marc-dispo.
ENDIF.
*- Selecting the material discription from MAKT table
SELECT matnr
spras
maktx
FROM makt
INTO TABLE lt_makt
FOR ALL ENTRIES IN lt_val
WHERE matnr = lt_val-matnr AND
spras = 'EN'.

*- Selecting the quantity from MSEG table


** SELECT mblnr
** bwart
** lgort
** menge
** meins
** FROM mseg
** INTO TABLE lt_mseg
** FOR ALL ENTRIES IN lt_val
** WHERE mblnr = lt_val-belnr
** AND ( bwart = '131' OR bwart = '132' )
** AND lgort IN s_lgort.
SELECT mblnr "Added as per Ticket - 82880 23/01/2014
bwart
lgort
menge
meins
FROM mseg
INTO TABLE lt_mseg
FOR ALL ENTRIES IN lt_val
WHERE mblnr = lt_val-belnr AND mjahr LIKE '%' AND bukrs LIKE '%'
AND werks = lt_val-werks AND ( bwart = '131' OR bwart = '132' )
AND shkzg LIKE '%'
AND budat_mkpf IN s_budat." AND lgort IN s_lgort.
DELETE lt_mseg WHERE lgort NOT IN s_lgort.
*- Finding the total quantity
LOOP AT lt_mseg INTO ls_mseg.
ls_temp-mblnr = ls_mseg-mblnr.
IF ls_mseg-bwart = '131'.
ls_temp-menge = ls_mseg-menge.
ELSE.
ls_temp-menge1 = ls_mseg-menge.
ENDIF.
* ls_temp-meins = ls_mseg-meins.
COLLECT ls_temp INTO lt_temp.
CLEAR ls_temp.
ENDLOOP.

ENDIF.

LOOP AT lt_val INTO ls_val.


*- Reading the table for quantity
READ TABLE lt_temp INTO ls_temp
WITH KEY mblnr = ls_val-belnr.
*- Reading the table for MRP controller
READ TABLE lt_marc INTO ls_marc
WITH KEY matnr = ls_val-matnr
werks = ls_val-werks.
*- Reading the table for MRP Name
READ TABLE lt_t024d INTO ls_t024d
WITH KEY werks = ls_marc-werks
dispo = ls_marc-dispo.
*- Reading the table for Material Description
READ TABLE lt_makt INTO ls_makt
WITH KEY matnr = ls_val-matnr.
*- Reading the table for storage location
READ TABLE lt_mseg INTO ls_mseg
WITH KEY mblnr = ls_val-belnr.
IF sy-subrc = 0.
ls_final-werks = ls_val-werks.
ls_final-budat = ls_val-budat.
ls_final-matnr = ls_val-matnr.
ls_final-maktx = ls_makt-maktx.
ls_final-verid = ls_val-verid.
ls_final-dispo = ls_marc-dispo.
ls_final-dsnam = ls_t024d-dsnam.
ls_final-menge = ls_temp-menge - ls_temp-menge1.
ls_final-acharg = ls_val-acharg.

ls_final-lgort = ls_mseg-lgort.
ls_final-meins = ls_mseg-meins.
ls_final-mblnr = ls_mseg-mblnr. "Added by Bency, TR :
E10K956556
APPEND ls_final TO lt_final.
ENDIF.
CLEAR: ls_final,ls_val,ls_makt,ls_t024d,ls_temp,ls_mseg.

ENDLOOP.

END-OF-SELECTION.
*- Displaying ALV
IF lt_final IS NOT INITIAL.
PERFORM display USING :
lv_pos 'WERKS' 'LT_FINAL' 'Plant' '10',
lv_pos 'BUDAT' 'LT_FINAL' 'Date' '10',
lv_pos 'MATNR' 'LT_FINAL' 'Material' '20',
lv_pos 'MAKTX' 'LT_FINAL' 'Material Description' '40',
lv_pos 'VERID' 'LT_FINAL' 'Production version' '10',
lv_pos 'DISPO' 'LT_FINAL' 'MRP controller' '10',
lv_pos 'DSNAM' 'LT_FINAL' 'Description' '20',
lv_pos 'MENGE' 'LT_FINAL' 'Quantity' '15',
lv_pos 'MEINS' 'LT_FINAL' 'Unit' '10',
lv_pos 'LGORT' 'LT_FINAL' 'Location' '10',
lv_pos 'ACHARG' 'LT_FINAL' 'Batch no' '10',
lv_pos 'MBLNR' 'LT_FINAL' 'Mat.Doc.no' '10'. "Added by Bency, TR :
E10K956556
PERFORM alv_display.
ELSE.
MESSAGE 'Records not Found' TYPE 'I' DISPLAY LIKE 'E'.
ENDIF.

*&---------------------------------------------------------------------*
*& Form DISPLAY
*&---------------------------------------------------------------------*
* This Subroutine is used for passing the values to the field
* catalog.
*----------------------------------------------------------------------*
* -->col_pos --> Column Position
* -->fieldname --> Field Name
* -->tabname --> Table Name
* -->seltext_l --> Selection Text
*----------------------------------------------------------------------*
FORM display USING col_pos TYPE sy-cucol
fieldname TYPE slis_fieldname
tabname TYPE slis_tabname
seltext_l TYPE dd03p-scrtext_l
outputlen TYPE dd03p-outputlen. "Added by Bency, TR :
E10K951355

lv_pos = lv_pos + 1.
ls_fieldcat-col_pos = lv_pos.
ls_fieldcat-fieldname = fieldname.
ls_fieldcat-tabname = tabname.
ls_fieldcat-seltext_l = seltext_l.
ls_fieldcat-outputlen = outputlen. "Added by Bency, TR : E10K951355
APPEND ls_fieldcat TO lt_fieldcat.
CLEAR ls_fieldcat.

ENDFORM. " DISPLAY


*&---------------------------------------------------------------------*
*& Form ALV_DISPLAY
*&---------------------------------------------------------------------*
* This Subroutine is used for Displaying the Fieldcatalog
*----------------------------------------------------------------------*
FORM alv_display .
ls_layout-colwidth_optimize = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = ls_layout
it_fieldcat = lt_fieldcat
TABLES
t_outtab = lt_final.
ENDFORM. " ALV_DISPLAY

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy