MDBT authorisation by plant
Hi all
I am trying to give authorisation for MDBT by plant. I used the object M_MTDI_ORG but it doesn't seem to work.
User given authorisation only for a particular plant can run all plants.
any suggestions??
Thanks in advance
JOE
Check in SU24 (enter there transaction MDBT) whether the check indicator for M_MTDI_ORG is set to check or not check.
If it is set to check, then open a message at SAP, if it does not do what it is supposed to do
Similar Messages
-
Restricting access to certain plants - any suggestions welcome
Hi,
I have been asked to create a small number of new plants for our business which are only to be viewed by a small number of people. Now the plants will have the same initial letter as a number of existing plants (this can't be changed).
For example, the new plants might be AB01, AB02. The existing plants are A001, A002, A003.
Many of our authorisations at plant level reference this first letter:
i.e. The user can see all the plants beginning with the letter A*.
Can anyone think of a way whereby I can restrict the access to the new plants without having to change all the existing authorisations?
Thanks,
Steph.Without authorization you can go for customized developement,
search for standard user exit & take help of abaper to complete it. -
Report needs to be corrected it is urgent
Ageing Analysis of Inventory Material. This is a report for Inventory Ageing. The report is not giving correct result for the field Value of total valuated stock(MBEWH-SALK3). After displaying the report when we add up the field SALK3 it not the correct result which I got in transaction code MB5L. Can anyone kindly help me in correcting out this report. I am keeping the source code also.
*& Application : Materials Management (MM)
*& Description : Ageing Analysis of Inventory Material
*& Transaction Code :
*& Area Menu Code : ZMM
Report ZMM0001.
MAPPING OF MONTH AND PERIOD AS FINACIAL YEAR STARTS FROM APR - MAR. *
just for reference.
MONTH PERIOD
01.2003 - 10.2003
02.2003 - 11.2003
03.2003 - 12.2003
04.2003 - 01.2003
05.2003 - 02.2003
06.2003 - 03.2003
07.2003 - 04.2003
08.2003 - 05.2003
09.2003 - 06.2003
10.2003 - 07.2003
11.2003 - 08.2003
12.2003 - 09.2003
01.2004 - 10.2004
02.2004 - 11.2004
03.2004 - 12.2004
04.2004 - 01.2004
REPORT ZMMR0001 MESSAGE-ID GW NO STANDARD PAGE HEADING
LINE-COUNT 1000
LINE-SIZE 170.
*FLOWLOGIC
*This Program displays the Ageing Analysis details of Material inventory
*pick up the opening balance consider the previous month of the period
*entered in selection screen.
*Get the qty and value for all material types from mbew table but
*excludeentries where no valuation type is defined
*calculate the receipt qty pick all entries from z_mkpf_mseg where
*date( is less that or equal to the last day of the month and movement
*type equals '101', '561', '501', '951', '953', '955', '957', '301' *
*into i_mseg table.
*To calculate the reversal for receipt qty.
*To get the issue qty upto the date of receipt, delete the issue qty
*fromstock to get the exact stock value on the date the receipt of
*materials happen.
*Calculate the difference in days and mark values based on the below
*condition.
*Display the output as per the user given format.
*FLOWLOGIC
Tables
TABLES : S031, " Statistics: Movements for current stocks
S032, " Statistics: Current Stock and Grouping Terms
MBEW, " Material Valuation
MBEWH, " Material Valuation: History
MARC, " Plant Data for Material
MARA, "material master
T001W, " Plant Details
MKPF,
V_T179.
TYPE-POOLS
TYPE-POOLS: SLIS.
DATA: IT_HEADING TYPE SLIS_T_LISTHEADER WITH HEADER LINE.
DATA: IT_FCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
DATA: LAY TYPE SLIS_LAYOUT_ALV.
DATA: IT_SORT_SUBTOTAL TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE.
DATA: IT_EVENT TYPE SLIS_T_EVENT WITH HEADER LINE.
DATA: V_REPID LIKE SY-REPID.
DATA: PRDHA1(5),
PRDHA2(10),
LVL1(40),
LVL2(40),
LVL3(40).
RANGES: S_BWTAR FOR BWTAR.
INTERNAL Tables
*******For Mat. Desc.************
DATA : BEGIN OF I_MAKT OCCURS 0,
MATNR TYPE MAKT-MATNR, " Material Code
MAKTX TYPE MAKT-MAKTX, " Material Description
END OF I_MAKT.
DATA : BEGIN OF TEMP OCCURS 0,
VTEXT(40),
END OF TEMP.
*******For Mat. No. & Type & Grp*
DATA : BEGIN OF I_MARA OCCURS 0,
MATNR TYPE MARA-MATNR, " Material Code
MATKL TYPE MARA-MATKL,
MTART TYPE MARA-MTART,
MFRNR TYPE MARA-MFRNR,
END OF I_MARA.
******For Stock******************
DATA : BEGIN OF I_MBEWH OCCURS 0,
MATNR TYPE MBEWH-MATNR,
BWTAR TYPE MBEWH-BWTAR,
LBKUM TYPE MBEWH-LBKUM,
SALK3 TYPE MBEWH-SALK3,
BWKEY TYPE MBEWH-BWKEY,
VBELN TYPE EBEW-VBELN,
POSNR TYPE EBEW-POSNR,
SOBKZ TYPE QBEW-SOBKZ,
PSPNR TYPE QBEW-PSPNR,
LFGJA TYPE MBEW-LFGJA,
LFMON TYPE MBEW-LFMON,
END OF I_MBEWH.
DATA: I_MBEWH1 LIKE I_MBEWH OCCURS 0 WITH HEADER LINE.
*******For Moving Price***********
DATA : BEGIN OF I_MBEW OCCURS 0,
MATNR TYPE MBEWH-MATNR,
BWTAR TYPE MBEWH-BWTAR,
LBKUM TYPE MBEWH-LBKUM,
VERPR TYPE MBEWH-VERPR,
VPRSV TYPE MBEWH-VPRSV,
STPRS TYPE MBEWH-STPRS,
END OF I_MBEW.
DATA : BEGIN OF I_RECIPT1 OCCURS 0,
MATNR TYPE Z_MKPF_MSEG-MATNR,
NAME1 TYPE LFA1-NAME1,
MAKTX TYPE MAKT-MAKTX,
BWTAR TYPE Z_MKPF_MSEG-BWTAR,
VERPR TYPE MBEWH-VERPR,
PRDHA LIKE MARA-PRDHA,
VTEXT(40) ,
LBKUM TYPE MBEWH-LBKUM,
SALK3 TYPE MBEWH-SALK3,
QTY1 TYPE MBEWH-LBKUM,
VAL1 TYPE P DECIMALS 2,
QTY2 TYPE MBEWH-LBKUM,
VAL2 TYPE P DECIMALS 2,
QTY3 TYPE MBEWH-LBKUM,
VAL3 TYPE P DECIMALS 2,
QTY4 TYPE MBEWH-LBKUM,
VAL4 TYPE P DECIMALS 2,
QTY5 TYPE MBEWH-LBKUM,
VAL5 TYPE P DECIMALS 2,
QTY6 TYPE MBEWH-LBKUM,
VAL6 TYPE P DECIMALS 2,
QTY7 TYPE MBEWH-LBKUM,
VAL7 TYPE P DECIMALS 2,
END OF I_RECIPT1.
DATA : BEGIN OF I_MKPF_MSEG OCCURS 0,
MATNR LIKE MARA-MATNR,
MBLNR LIKE MSEG-MBLNR,
ZEILE LIKE MSEG-ZEILE,
MENGE LIKE MSEG-MENGE,
BWART LIKE MSEG-BWART,
BUDAT LIKE MKPF-BUDAT,
NET_VAL LIKE MSEG-MENGE,
EBELN LIKE MSEG-EBELN,
EBELP LIKE MSEG-EBELP,
LFBNR LIKE MSEG-LFBNR,
LFPOS LIKE MSEG-LFPOS,
SHKZG LIKE MSEG-SHKZG,
MEINS LIKE MARA-MEINS,
SMBLN LIKE MSEG-SMBLN,
SMBLP LIKE MSEG-SMBLP,
END OF I_MKPF_MSEG,
WA_MSEG LIKE I_MKPF_MSEG.
********For Material Movement***
DATA: BEGIN OF I_MSEG OCCURS 0,
MBLNR TYPE Z_MKPF_MSEG-MBLNR,
MATNR TYPE Z_MKPF_MSEG-MATNR,
WERKS TYPE Z_MKPF_MSEG-WERKS,
BWART TYPE Z_MKPF_MSEG-BWART,
BUDAT TYPE Z_MKPF_MSEG-BUDAT,
MENGE TYPE Z_MKPF_MSEG-MENGE,
MEINS TYPE Z_MKPF_MSEG-MEINS,
BWTAR TYPE Z_MKPF_MSEG-BWTAR,
NET_VAL LIKE MSEG-MENGE,
ZEILE TYPE MSEG-ZEILE,
END OF I_MSEG.
********For Material Monvment(Reverse)***
DATA: BEGIN OF I_MSEG1 OCCURS 0,
MBLNR TYPE Z_MKPF_MSEG-MBLNR,
MATNR TYPE Z_MKPF_MSEG-MATNR,
WERKS TYPE Z_MKPF_MSEG-WERKS,
BWART TYPE Z_MKPF_MSEG-BWART,
BUDAT TYPE Z_MKPF_MSEG-BUDAT,
MENGE TYPE Z_MKPF_MSEG-MENGE,
MEINS TYPE Z_MKPF_MSEG-MEINS,
BWTAR TYPE Z_MKPF_MSEG-BWTAR,
SMBLN TYPE Z_MKPF_MSEG-SMBLN,
SMBLP TYPE Z_MKPF_MSEG-SMBLP,
END OF I_MSEG1.
DATA: I_MSEG2 LIKE I_MSEG1 OCCURS 0 WITH HEADER LINE.
********For Recipt Details*******
DATA: BEGIN OF I_RECIPT OCCURS 0,
MATNR TYPE Z_MKPF_MSEG-MATNR,
BWTAR TYPE Z_MKPF_MSEG-BWTAR,
BUDAT TYPE Z_MKPF_MSEG-BUDAT,
DAYS TYPE P,
QTY TYPE Z_MKPF_MSEG-MENGE,
MONTH(3),
YEAR(4),
VERPR TYPE MBEWH-VERPR,
COST TYPE P DECIMALS 2,
MARK(1),
END OF I_RECIPT.
DATA: BEGIN OF I_PLANT OCCURS 0,
WERKS LIKE T024W-WERKS,
EKORG LIKE T024W-EKORG,
BUKRS LIKE T024E-BUKRS,
CHK(1) TYPE C,
END OF I_PLANT.
DATA: BEGIN OF I_USERGRP OCCURS 0.
INCLUDE STRUCTURE USGRP_USER.
DATA: VKORG LIKE VBAK-VKORG,
END OF I_USERGRP.
DATA: MUGRP LIKE USGRP_USER-USERGROUP.
DATA: MUNAME LIKE SY-UNAME,
MMSGTX1(50) TYPE C.
*********For Temp.Values*****
*data: begin of i_temp occurs 0,
matnr type z_mkpf_mseg-matnr,
bwtar type z_mkpf_mseg-bwtar,
budat type z_mkpf_mseg-budat,
menge type z_mkpf_mseg-menge,
end of i_temp.
DATA: DAYS(2).
DATA: NET_VAL LIKE MSEG-MENGE.
DATA: DATE1 TYPE D.
DATA: DATE2 TYPE D.
DATA: MBLNR TYPE MSEG-MBLNR.
DATA: MATNR TYPE MSEG-MATNR.
DATA: BWTAR TYPE MSEG-BWTAR.
DATA : V_DATE TYPE SY-DATUM.
DATA : X(2) TYPE C VALUE '01'.
DATA : P TYPE T009B-POPER. " MONTH
DATA : Q TYPE T009B-BDATJ. " YEAR
DATA : A TYPE T009B-POPER. " FOR MONTH WHERE MONTH STARTS AT APRIL
DATA : B(4) TYPE C. " FOR YEAR
DATA : DATE TYPE SY-DATUM.
DATA: NUMBER_OF_DAYS TYPE P.
DATA: DAT TYPE D.
DATA : X1(2) .
DATA: VPRSV TYPE MBEWH-VPRSV,
STPRS TYPE MBEWH-STPRS.
DATA: C TYPE C VALUE 0,
S(10).
Parameter / Selection - screens
SELECTION-SCREEN BEGIN OF BLOCK IND1 WITH FRAME TITLE TEXT_001.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(28) TEXT_002 FOR FIELD P_WERKS.
PARAMETERS : P_WERKS LIKE S031-WERKS OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(28) TEXT_003 FOR FIELD P_SPMON.
PARAMETERS : P_SPMON LIKE S031-SPMON MODIF ID ABC .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(25) TEXT_004 FOR FIELD S_MATNR.
SELECT-OPTIONS : S_MATNR FOR S031-MATNR.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK IND1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT_005.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(25) TEXT_006 FOR FIELD SO_MATTP.
SELECT-OPTIONS : SO_MATTP FOR MARA-MTART.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(25) TEXT_007 FOR FIELD SO_MATGP.
SELECT-OPTIONS : SO_MATGP FOR MARA-MATKL.
SELECTION-SCREEN END OF LINE.
begin of changes by cvns01
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(25) TEXT_008 FOR FIELD SO_MFRNR.
SELECT-OPTIONS : SO_MFRNR FOR MARA-MFRNR.
SELECTION-SCREEN END OF LINE.
end of changes by cvns01
*changes
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(25) TEXT_009 FOR FIELD SO_MFRNR.
SELECT-OPTIONS : SO_PRDHA FOR MARA-PRDHA NO INTERVALS."NO-EXTENSION.
SELECTION-SCREEN END OF LINE.
*end
SELECTION-SCREEN END OF BLOCK B2.
Initialization
INITIALIZATION.
TEXT_001 = 'Required Data'.
TEXT_002 = 'Plant'.
TEXT_003 = 'Period to analyze - month'.
TEXT_004 = 'Material Number'.
TEXT_005 = 'Optional Data'.
TEXT_006 = 'Material Type'.
TEXT_007 = 'Material Group'.
start of changes by cvns01
TEXT_008 = 'Manufacturer No.'.
TEXT_009 = 'Product Hierarchy'.
end of changes by cvns01
CLEAR:P,Q.
CLEAR A.
P = SY-DATUM+4(2).
SHIFT P LEFT DELETING LEADING C.
Q = SY-DATUM(4).
IF P <= 9.
CONCATENATE Q '0' P INTO S. "p_spmon.
ELSE.
CONCATENATE Q P INTO S. "p_spmon.
ENDIF.
*concatenate q p into s. "p_spmon.
CONDENSE S.
P_SPMON = S.
AT SELECTION-SCREEN ON WERKS
AT SELECTION-SCREEN ON P_WERKS.
CHECK SY-UCOMM = 'ONLI'.
SELECT SINGLE * FROM T001W WHERE WERKS EQ P_WERKS.
IF SY-SUBRC NE 0.
MESSAGE E999 WITH 'Invalid Plant'.
ENDIF.
SELECT T024W~WERKS T024E~EKORG T024E~BUKRS
INTO CORRESPONDING FIELDS OF TABLE I_PLANT
FROM T024W
JOIN T024E ON T024E~EKORG = T024W~EKORG
WHERE T024W~WERKS EQ P_WERKS.
SORT I_PLANT BY WERKS.
DELETE ADJACENT DUPLICATES FROM I_PLANT COMPARING WERKS.
SELECT * INTO CORRESPONDING FIELDS OF TABLE I_USERGRP
FROM USGRP_USER
WHERE BNAME = SY-UNAME.
IF I_USERGRP[] IS INITIAL.
MESSAGE E208(00) WITH 'You are not authorised to view this report'.
ENDIF.
LOOP AT I_USERGRP.
CONCATENATE I_USERGRP-USERGROUP(2) '00' INTO I_USERGRP-VKORG.
MODIFY I_USERGRP.
ENDLOOP.
LOOP AT I_USERGRP.
LOOP AT I_PLANT WHERE BUKRS = I_USERGRP-VKORG.
I_PLANT-CHK = 'X'.
MODIFY I_PLANT.
ENDLOOP.
ENDLOOP.
*delete i_plant where chk = ''.
IF NOT I_PLANT[] IS INITIAL.
LOOP AT I_PLANT.
IF I_PLANT-CHK = ''.
CLEAR P_WERKS.
CONCATENATE 'You are not authorised for plant ' I_PLANT-WERKS INTO MMSGTX1 SEPARATED BY SPACE.
MESSAGE E208(00) WITH MMSGTX1.
ENDIF.
ENDLOOP.
ENDIF.
IF P_WERKS = ''.
MESSAGE E208(00) WITH 'Select/Enter Plant'.
ENDIF.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF SCREEN-GROUP1 = 'ABC'.
SCREEN-INPUT = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
AT SELECTION-SCREEN
*AT SELECTION-SCREEN .
SELECT SINGLE * FROM s031 WHERE werks EQ p_werks
AND spmon EQ p_spmon
AND matnr IN s_matnr.
IF sy-subrc NE 0.
MESSAGE e999 WITH 'NO VALUES EXIST FOR SELECTION CRITERIA'.
ENDIF.
START-OF-SELECTION
START-OF-SELECTION.
PERFORM PRDHA_INITIALIZATION.
PERFORM FETCH_DATA.
PERFORM DISPLAY_DATA.
END-OF-SELECTION.
*& Form FETCH_DATA
text
--> p1 text
<-- p2 text
FORM FETCH_DATA .
CLEAR:P,Q.
CLEAR A.
P = P_SPMON+4(2).
Q = P_SPMON+0(4).
******Materials**********************************
changes made by akshatha
SELECT MARA~MATNR
FROM MARA
JOIN MARC
ON MARCMATNR = MARAMATNR
INTO CORRESPONDING FIELDS OF TABLE I_MARA
WHERE MARA~MATNR IN S_MATNR
AND MARC~WERKS = P_WERKS
AND MARA~MTART IN SO_MATTP
AND MARA~MATKL IN SO_MATGP
AND MARA~MFRNR IN SO_MFRNR
AND MARA~PRDHA IN SO_PRDHA.
end of changes
To get material description for the material
IF NOT I_MARA[] IS INITIAL.
SELECT MATNR
MAKTX
FROM MAKT
INTO CORRESPONDING FIELDS OF TABLE I_MAKT
FOR ALL ENTRIES IN I_MARA
WHERE MATNR = I_MARA-MATNR
AND SPRAS = SY-LANGU.
TO GET OPEN BALANCE QTY WE NEED TO CONSIDER PREVIOUS MONTH OF THE
CORRESPONDING PERIOD
WE WILL GET PROBLEM ONLY PROBLEM WHEN PERIOD IS '01'. THEN WE MUST
CONSIDER FOR 12 TH MONTH OF PREVIOUS YEAR.
****Closing Stock as on Selection-Screen Month....
*By Default last date of month is taken
changed by akshatha
CONCATENATE P_SPMON X INTO V_DATE.
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
I_DATE = V_DATE
I_MONMIT = 00
I_PERIV = 'V3'
IMPORTING
E_BUPER = A
E_GJAHR = Q
EXCEPTIONS
INPUT_FALSE = 1
T009_NOTFOUND = 2
T009B_NOTFOUND = 3
OTHERS = 4 .
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
to get stock quantity
SELECT MATNR LBKUM SALK3 BWKEY LFGJA LFMON
FROM MBEWH
INTO CORRESPONDING FIELDS OF TABLE I_MBEWH
FOR ALL ENTRIES IN I_MARA
WHERE MATNR = I_MARA-MATNR
AND BWKEY = P_WERKS AND BWTAR IN S_BWTAR
AND LFGJA = Q
AND LFMON = A
AND LBKUM > '0.0'.
SELECT MATNR LBKUM SALK3 BWKEY VBELN POSNR LFGJA LFMON
FROM EBEWH
APPENDING CORRESPONDING FIELDS OF TABLE I_MBEWH
WHERE MATNR = I_MARA-MATNR
AND BWKEY = P_WERKS
AND BWTAR IN S_BWTAR
AND LFGJA = Q
AND LFMON = A
AND LBKUM > '0.0'.
and VPRSV = 'S'.
SELECT MATNR LBKUM SALK3 BWKEY SOBKZ PSPNR LFGJA LFMON
FROM QBEWH
APPENDING CORRESPONDING FIELDS OF TABLE I_MBEWH
WHERE MATNR = I_MARA-MATNR
AND BWKEY = P_WERKS
AND BWTAR IN S_BWTAR
AND LFGJA = Q
AND LFMON = A
AND LBKUM > '0.0'.
SELECT MATNR LBKUM SALK3 BWKEY BWTAR
FROM MBEW
INTO CORRESPONDING FIELDS OF TABLE I_MBEWH1
FOR ALL ENTRIES IN I_MARA
WHERE MATNR = I_MARA-MATNR
AND BWKEY = P_WERKS
AND LBKUM > '0.0'.
SELECT MATNR LBKUM SALK3 BWKEY VBELN POSNR SOBKZ BWTAR
FROM EBEW
APPENDING CORRESPONDING FIELDS OF TABLE I_MBEWH1
FOR ALL ENTRIES IN I_MARA
WHERE MATNR = I_MARA-MATNR
AND BWKEY = P_WERKS
AND LBKUM > '0.0'.
SELECT MATNR LBKUM SALK3 BWKEY BWTAR SOBKZ PSPNR
FROM QBEW
APPENDING CORRESPONDING FIELDS OF TABLE I_MBEWH1
FOR ALL ENTRIES IN I_MARA
WHERE MATNR = I_MARA-MATNR
AND BWKEY = P_WERKS
AND LBKUM > '0.0'.
SORT I_MBEWH BY MATNR BWKEY.
SORT I_MBEWH1 BY MATNR BWKEY.
LOOP AT I_MBEWH.
LOOP AT I_MBEWH1 WHERE MATNR = I_MBEWH-MATNR
AND BWKEY = I_MBEWH-BWKEY.
DELETE I_MBEWH1.
ENDLOOP.
ENDLOOP.
APPEND LINES OF I_MBEWH1 TO I_MBEWH.
CLEAR : I_MBEWH1.
REFRESH I_MBEWH1.
SORT I_MBEWH BY MATNR.
LOOP AT I_MBEWH .
I_MBEWH1 = I_MBEWH.
AT END OF MATNR.
SUM.
I_MBEWH1-LBKUM = I_MBEWH-LBKUM.
I_MBEWH1-SALK3 = I_MBEWH-SALK3.
APPEND I_MBEWH1.
ENDAT.
ENDLOOP.
DELETE I_MBEWH1 WHERE LBKUM <= 0.
I_MBEWH[] = I_MBEWH1[].
end of changes
loop at i_mara.
concatenate p_spmon x into v_date.
call function 'DATE_TO_PERIOD_CONVERT'
exporting
i_date = v_date
I_MONMIT = 00
i_periv = 'V3'
importing
e_buper = a
e_gjahr = q
exceptions
input_false = 1
t009_notfound = 2
t009b_notfound = 3
others = 4 .
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
To get STOCK QUANTITY and STOCK VALUE for All Valuation Type
select matnr
bwtar
lbkum
salk3
from mbewh
into corresponding fields of i_mbewh
where matnr = i_mara-matnr
and bwkey = p_werks
and lfmon = a " 'A' IS PERIOD FOR FISCAL YR
and lfgja = q.
collect i_mbewh.
clear i_mbewh.
endselect.
if sy-subrc ne 0.
select matnr
bwtar
lbkum
salk3
from mbew
into corresponding fields of i_mbewh
where matnr = i_mara-matnr
and bwkey = p_werks.
collect i_mbewh.
clear i_mbewh.
endselect.
endif.
endloop.
end of changes
Logic: If the Val. Type is defined then for that material dont take
the line item where Val. Type is blank......
sort i_mbewh by matnr bwtar.
i_mbewh1[] = i_mbewh[].
delete i_mbewh where bwtar = ' '.
loop at i_mbewh1.
read table i_mbewh with key matnr = i_mbewh1-matnr.
if sy-subrc <> 0.
move-corresponding i_mbewh1 to i_mbewh.
append i_mbewh.
endif.
endloop.
sort i_mbewh by matnr bwtar.
i_mbewh1[] = i_mbewh[].
end of changes
*****************Last Date of the month is Calculated to find Qty
DAT = V_DATE.
CALL FUNCTION 'HR_E_NUM_OF_DAYS_OF_MONTH'
EXPORTING
P_FECHA = DAT
IMPORTING
NUMBER_OF_DAYS = NUMBER_OF_DAYS.
X1 = NUMBER_OF_DAYS.
CONCATENATE P_SPMON X1 INTO DATE.
********RECIPT QTY FETCHING*************************
select mblnr
matnr
bwart
budat
menge
meins
bwtar
zeile
from z_mkpf_mseg
into (i_mseg-mblnr,
i_mseg-matnr,
i_mseg-bwart,
i_mseg-budat,
i_mseg-menge,
i_mseg-meins,
i_mseg-bwtar,
i_mseg-zeile)
for all entries in i_mbewh
where matnr = i_mbewh-matnr and werks = p_werks
and ( budat le date or budat eq date )
and bwart in ('101','561','501','951','953','955',
**'957','301','105')
and bwtar = i_mbewh-bwtar.
append i_mseg.
clear i_mseg.
endselect.
select mblnr
matnr
bwart
budat
menge
meins
bwtar
zeile
from mseg "z_mkpf_mseg
into corresponding fields of table i_mseg
(i_mseg-mblnr,
i_mseg-matnr,
i_mseg-bwart,
i_mseg-budat,
i_mseg-menge,
i_mseg-meins,
i_mseg-bwtar,
i_mseg-zeile)
for all entries in i_mbewh
where matnr = i_mbewh-matnr and werks = p_werks
and ( budat le date or budat eq date )
and bwart in ('101','561','501','951','953','955',
***'957','301','105')
and bwart in ('101','561','501','951','953','955',
*'957','301','309','105')
and bwtar = i_mbewh-bwtar.
loop at i_mseg.
select single * from mkpf
where mblnr = i_mseg-mblnr.
if ( mkpf-budat ge date ).
delete i_mseg where mblnr = i_mseg-mblnr.
else.
i_mseg-budat = mkpf-budat.
modify i_mseg.
endif.
endloop.
sort i_mseg descending by matnr bwtar budat.
**********For Reversal FOR RECIPT(CHECK FOR REFERENCE)
**********(102,562,502,952,954,956,958)
select mblnr
matnr
bwart
menge
meins
bwtar
smbln
smblp
from mseg
into corresponding fields of table i_mseg1
for all entries in i_mbewh
where matnr = i_mbewh-matnr and werks = p_werks
and bwart in ('102','562','502','952','954','956','958','302')
and bwtar = i_mbewh-bwtar.
loop at i_mseg1.
select single * from mkpf
where mblnr = i_mseg1-mblnr.
if ( mkpf-budat ge date ).
delete i_mseg1 where mblnr = i_mseg1-mblnr.
else.
i_mseg1-budat = mkpf-budat.
modify i_mseg1.
endif.
endloop.
loop at i_mseg1.
read table i_mseg with key mblnr = i_mseg1-smbln
zeile = i_mseg1-smblp.
if sy-subrc = 0.
i_mseg-menge = i_mseg-menge - i_mseg1-menge.
delete i_mseg where mblnr = i_mseg1-smbln and
zeile = i_mseg1-smblp.
move-corresponding i_mseg to i_mseg2.
append i_mseg2.
endif.
endloop.
loop at i_mseg2.
move-corresponding i_mseg2 to i_mseg.
append i_mseg.
endloop.
end of changes.
SELECT MSEGMATNR MSEGMBLNR MSEGZEILE MSEGMENGE MSEGBWART MSEGEBELN
MSEGEBELP MSEGSMBLN MSEG~SMBLP
MKPFBUDAT MSEGSHKZG
FROM MKPF
JOIN MSEG ON MSEGMBLNR = MKPFMBLNR
AND MSEGMJAHR = MKPFMJAHR
INTO CORRESPONDING FIELDS OF TABLE I_MKPF_MSEG
FOR ALL ENTRIES IN I_MARA
WHERE MSEG~MATNR = I_MARA-MATNR
AND MSEG~WERKS = P_WERKS
AND MKPF~BUDAT LE DATE
AND MSEG~BWART IN ('101','105','561','501','301','309','951','953','955','957','712','657','658',
'521','522','303','304','102','562','502','952','954','956','958','302').
DELETE I_MKPF_MSEG WHERE ( BWART = '309' AND SHKZG = 'H' )
OR ( BWART = '303' AND SHKZG = 'H' )
OR ( BWART = '304' AND SHKZG = 'S' )
OR ( BWART = '657' AND SHKZG = 'H' )
OR ( BWART = '658' AND SHKZG = 'S' ).
SORT I_MKPF_MSEG BY MATNR MBLNR.
LOOP AT I_MKPF_MSEG.
if i_mkpf_mseg-bwart = '101' or i_mkpf_mseg-bwart = '102'.
select single * from ekpo where ebeln = i_mkpf_mseg-ebeln
and ebelp = i_mkpf_mseg-ebelp.
if ekpo-pstyp = 7.
delete i_mkpf_mseg where ebeln = i_mkpf_mseg-ebeln
and ebelp = i_mkpf_mseg-ebelp.
CLEAR I_MKPF_MSEG-MENGE.
endif.
endif.
IF ( I_MKPF_MSEG-BWART = '101' OR I_MKPF_MSEG-BWART = '105' OR I_MKPF_MSEG-BWART = '561' OR
I_MKPF_MSEG-BWART = '501' OR I_MKPF_MSEG-BWART = '301' OR I_MKPF_MSEG-BWART = '309' OR
I_MKPF_MSEG-BWART = '951' OR I_MKPF_MSEG-BWART = '953' OR I_MKPF_MSEG-BWART = '955' OR
I_MKPF_MSEG-BWART = '957' OR I_MKPF_MSEG-BWART = '303' OR I_MKPF_MSEG-BWART = '521' OR
I_MKPF_MSEG-BWART = '712' OR I_MKPF_MSEG-BWART = '657' ).
NET_VAL = NET_VAL + I_MKPF_MSEG-MENGE.
ENDIF.
LOOP AT I_MKPF_MSEG WHERE MATNR = I_MKPF_MSEG-MATNR.
IF ( I_MKPF_MSEG-BWART = '102' OR I_MKPF_MSEG-BWART = '562' OR
I_MKPF_MSEG-BWART = '502' OR I_MKPF_MSEG-BWART = '952' OR
I_MKPF_MSEG-BWART = '954' OR I_MKPF_MSEG-BWART = '956' OR
I_MKPF_MSEG-BWART = '958' OR I_MKPF_MSEG-BWART = '302' OR
I_MKPF_MSEG-BWART = '304' OR I_MKPF_MSEG-BWART = '522' OR
I_MKPF_MSEG-BWART = '658' ) AND
( I_MKPF_MSEG-MBLNR = I_MKPF_MSEG-SMBLN AND
I_MKPF_MSEG-ZEILE = I_MKPF_MSEG-SMBLP ).
NET_VAL = NET_VAL - I_MKPF_MSEG-MENGE.
DELETE I_MSEG WHERE MBLNR = I_MSEG1-SMBLN AND
ZEILE = I_MSEG1-SMBLP.
ENDIF.
ENDLOOP.
WA_MSEG = I_MKPF_MSEG.
AT END OF MATNR.
I_MSEG-MATNR = WA_MSEG-MATNR.
I_MSEG-MENGE = NET_VAL.
I_MSEG-BUDAT = WA_MSEG-BUDAT.
APPEND I_MSEG.
CLEAR NET_VAL.
ENDAT.
ENDLOOP.
end of changes
DELETE I_MSEG WHERE MENGE = '0.000'.
SORT I_MSEG DESCENDING BY MATNR BWTAR BUDAT.
***#******RECIPT COMPLETE FINAL TABLE( I_MSEG)**********
********IF THE VAL. TYPE IS NOT THERE THEN PUT 'X'
loop at i_mbewh.
if i_mbewh-bwtar = ' '.
i_mbewh-bwtar = 'X'.
modify i_mbewh.
endif.
endloop.
delete i_mbewh where lbkum = '0.00'.
end of changes
loop at i_mseg.
if i_mseg-bwtar = ' '.
i_mseg-bwtar = 'X'.
modify i_mseg.
endif.
endloop.
end of changes
DATA: MENGE TYPE MSEG-MENGE.
start of changes by akshatha
SORT I_MSEG BY MATNR BWTAR.
SORT I_MBEWH BY MATNR BWTAR.
LOOP AT I_MSEG.
if condition, read and it_mseg-loop commented by akshatha.
if i_mbewh-lbkum > '0.00'.
read table i_mbewh with key matnr = i_mseg-matnr
bwtar = i_mseg-bwtar.
loop at i_mseg .
if ( i_mseg-mblnr <> mblnr ) and ( i_mseg-matnr ne i_temp-matnr
or i_mseg-bwtar ne i_temp-bwtar ) .
i_temp-matnr = i_mseg-matnr.
i_temp-bwtar = i_mseg-bwtar.
i_temp-budat = i_mseg-budat.
i_temp-menge = i_mseg-menge.
mblnr = i_mseg-mblnr.
matnr = i_mseg-matnr.
bwtar = i_mseg-bwtar.
append i_temp.
end of changes
delete i_mseg .
loop at i_mbewh where matnr = matnr
and bwtar = bwtar.
end of changes
LOOP AT I_MBEWH WHERE MATNR = I_MSEG-MATNR
AND BWTAR = I_MSEG-BWTAR.
FOR GETTING THE VALUES OF ISSUES ON & UPTO THE DATE OF RECIPT.
DELETE THE ISSUE QTY FROM STOCK SO THAT WE CAN GET THE EXACT STOCK
VALUE ON THE DATE WHEN RECIPT OF MATERIAL HAS HAPPEN
ISSUES R NOTHING BUT TYPE OF CONSUPTION.
commented and changed by akshatha
if ( i_mbewh-lbkum >= i_temp-menge ).
IF ( I_MBEWH-LBKUM >= I_MSEG-MENGE ).
I_RECIPT-MATNR = I_MBEWH-MATNR.
I_RECIPT-BWTAR = I_MBEWH-BWTAR.
i_recipt-budat = i_temp-budat.
I_RECIPT-BUDAT = I_MSEG-BUDAT.
end of changes
*Type Conversion From Sy-datum to type d.
DATE1 = DATE.
DATE2 = I_RECIPT-BUDAT.
*Type Conversion From Sy-datum to type d.
CALL FUNCTION 'SD_DATETIME_DIFFERENCE'
EXPORTING
DATE1 = DATE1
TIME1 = SY-UZEIT
DATE2 = DATE2
TIME2 = SY-UZEIT
IMPORTING
DATEDIFF = I_RECIPT-DAYS.
IF SY-SUBRC <> 0.
ENDIF.
i_recipt-qty = i_temp-menge.
I_RECIPT-QTY = I_MSEG-MENGE.
i_mbewh-lbkum = i_mbewh-lbkum - i_temp-menge.
I_MBEWH-LBKUM = I_MBEWH-LBKUM - I_MSEG-MENGE.
elseif ( i_mbewh-lbkum < i_temp-menge ).
ELSEIF ( I_MBEWH-LBKUM < I_MSEG-MENGE ).
I_RECIPT-MATNR = I_MBEWH-MATNR.
I_RECIPT-BWTAR = I_MBEWH-BWTAR.
i_recipt-budat = i_temp-budat.
I_RECIPT-BUDAT = I_MSEG-BUDAT.
*Type Conversion From Sy-datum to type d.
DATE1 = DATE.
DATE2 = I_RECIPT-BUDAT.
*Calculation of Difference of dates
CALL FUNCTION 'SD_DATETIME_DIFFERENCE'
EXPORTING
DATE1 = DATE1
TIME1 = SY-UZEIT
DATE2 = DATE2
TIME2 = SY-UZEIT
IMPORTING
DATEDIFF = I_RECIPT-DAYS.
IF SY-SUBRC <> 0.
ENDIF.
I_RECIPT-QTY = I_MBEWH-LBKUM.
I_MBEWH-LBKUM = '0.00'.
ENDIF.
MODIFY I_MBEWH.
APPEND I_RECIPT.
exit.
end of changes
ENDLOOP.
endif.
IF I_MBEWH-LBKUM <> '0.00'.
clear i_temp.
CLEAR I_MSEG.
ENDIF.
endloop.
endif.
end of changes
ENDLOOP.
**********FINAL RECIPT TABLE WITH AGE
SORT I_RECIPT BY MATNR BWTAR DAYS.
LOOP AT I_RECIPT.
*Calculation of Fiscal yr for moving price.
PERFORM PERIOD_CALCULATION USING I_RECIPT-BUDAT+4(2)
I_RECIPT-BUDAT+0(4) I_RECIPT-MONTH
I_RECIPT-YEAR.
IF I_RECIPT-BWTAR = 'X'.
I_RECIPT-BWTAR = ' '.
ENDIF.
**************Moving Price for All material for all months......
SELECT SINGLE VERPR
VPRSV
STPRS
FROM MBEWH
INTO (I_RECIPT-VERPR,
VPRSV,
STPRS )
WHERE MATNR = I_RECIPT-MATNR
AND BWTAR = I_RECIPT-BWTAR
AND BWKEY = P_WERKS
AND LFMON = I_RECIPT-MONTH
AND LFGJA = I_RECIPT-YEAR
and lbkum = i_recipt-qty.
IF SY-SUBRC <> 0.
SELECT SINGLE VERPR
VPRSV
STPRS
FROM MBEW
INTO (I_RECIPT-VERPR,
VPRSV,
STPRS )
WHERE MATNR = I_RECIPT-MATNR
AND BWKEY = P_WERKS
and lbkum = i_recipt-qty.
ENDIF.
IF I_RECIPT-VERPR IS INITIAL.
SELECT SINGLE VERPR
VPRSV
STPRS
FROM EBEWH
INTO (I_RECIPT-VERPR,
VPRSV,
STPRS )
WHERE MATNR = I_RECIPT-MATNR
AND BWTAR = I_RECIPT-BWTAR
AND BWKEY = P_WERKS
AND LFMON = I_RECIPT-MONTH
AND LFGJA = I_RECIPTNever mind. I updated my aperture in app store and it fixed the problem. Thank you.
-
Authority Check in Queries (SQ01 / SQ02)
Hi Friends.
When I run a query (sq01 / sq02) , E.G. that contain the table MARC, the user can select all the plants, but he only must have access to plant "1000". In their roles / profiles, the basis only set authorisation to plant "1000".
I can resctrict the selection via abab code in the RECORD PROCESSING step of the INFOSET, but I want to know if exist a standar way to restrict this kind of authorisations in queries.
pls, any help will be nice!
thanks!
Edited by: ARTURO SENOSAIN on Jan 20, 2009 4:10 PMUse the logical database as the data source for the query:
" < ... > you should always use logical databases as the data source within InfoSets that are used for query-based reporting. Using a logical database as your data source guarantees that the SAP solution is smart enough to know which areas of the data a user is allowed to see so that only the appropriate data will show in an SAP query report. Regardless of what type of security access the person who created the report has, the system is smart enough to display only the appropriate data for the user executing the report. (Note that this is the case only when logical databases are used as the data source if a SAP query is created using an InfoSet that is based on anything other than a logical database (for example, a table, a table join, a program). It is fair to say that no security whatsoever is in place when the query is run because all records within the tables are displayed in the report output.)"
Edited by: Jelena Perfiljeva on Jan 20, 2009 5:15 PM
Edited by: Jelena Perfiljeva on Jan 20, 2009 5:15 PM -
hello dear,
how can i calculate total from a fields to get value,i am using table bset and i have to calculate total of fields fwste in according to hkont and belnr to get exice amount please refer some related programs.If you want to calculate th e third filed based on other two, you would need to do it programatically using control break statements like AT NEW / AT END OF ect ..
Below is sample program which does summary based on mrp controllers and other parameeters.
Modification Log
Program Name:ZCD0R_PDC_PERCENT_FILL
Author:Santosh Sarda
Date Written:7/19/2007
Request #:CDXK961051
Requested by:Blanca Ramirez.
Description: Get the percent fill of PDC Service Parts Requirements
Program Specifications:Service Store Percent Fill
Mod date Programmer Reference Description
REPORT zcd0r_pdc_percent_fill.
Includes
types
tables
types
internal tables
Work Areas
internal data fields
Internal table for field catalogue
Internal table for sort and sum
Structure for layout control settings
Structure for sort and Sum
Parameters and Selection Options
Initialization
at selection screen
event Start of Selection
Get ReQuired Data
Calculate % FILL MRP Controllerwise.
Calculate % Fill material wise.
forms
---- This Subroutine does not take any parameters.
*07/19/2007 Santosh S. CDXK961051 Initial Creation
*08/01/2007 Santosh S. CDXK961295 Layout change
*eject
TYPE-POOLS : slis.
Select data as per selection screen conditions .
TABLES:vbep, " Sales Document: Schedule Line Data
vbap, " Sales Document: Item Data
vbak, " Sales Document: Header Data
marc. " Plant Data for Material
This Subroutine does not take any parameters.
TYPES:
BEGIN OF t_vbak,
vbeln TYPE vbak-vbeln, "Sales document
kunnr TYPE vbak-kunnr, "Sold-to party
END OF t_vbak,
BEGIN OF t_vbap,
vbeln TYPE vbap-vbeln, "Sales document
posnr TYPE vbap-posnr, "Item
werks TYPE vbap-werks, "Plant
matnr TYPE vbap-matnr, "Material
END OF t_vbap,
BEGIN OF t_marc,
werks TYPE marc-werks, "Plant
matnr TYPE marc-matnr, "Material
dispo TYPE marc-dispo, "MRP Controller
END OF t_marc,
BEGIN OF t_makt,
matnr TYPE makt-matnr, "Material
maktx TYPE makt-maktx, "Material Description
END OF t_makt,
BEGIN OF t_vbpa,
vbeln TYPE vbpa-vbeln, "Sales document
parvw TYPE vbpa-parvw, "Partner Function
kunnr TYPE vbpa-kunnr, "Ship To Party
END OF t_vbpa,
BEGIN OF t_t024d,
werks TYPE t024d-werks, "Plant
dispo TYPE t024d-dispo, "MRP Controller
dsnam TYPE t024d-dsnam, "Controller Name
END OF t_t024d,
BEGIN OF t_vbep,
vbeln TYPE vbep-vbeln, "Sales document
posnr TYPE vbep-posnr, "Item
etenr TYPE vbep-etenr, "Schedule line
edatu TYPE vbep-edatu, "Delivery Date
wmeng TYPE vbep-wmeng, "Order quantity
END OF t_vbep,
BEGIN OF t_vbep_all,
vbeln TYPE vbep-vbeln, "Sales document
posnr TYPE vbep-posnr, "Item
etenr TYPE vbep-etenr, "Schedule line
matnr TYPE marc-matnr, "Material
maktx TYPE makt-maktx, "Material Description
dispo TYPE t024d-dispo, "MRP Controller
dsnam TYPE t024d-dsnam, "Controller Name
edatu TYPE vbep-edatu, "Delivery Date
wmeng TYPE vbep-wmeng, "Order Quantity
olfmng TYPE olfmng, "Open Quantity
soldto TYPE vbak-kunnr, "Sold To Party
shipto TYPE vbpa-kunnr, "Ship To Party
END OF t_vbep_all,
BEGIN OF t_marc_all,
werks TYPE marc-werks, "Plant
matnr TYPE marc-matnr, "Material
dispo TYPE marc-dispo, "MRP Controller
maktx TYPE makt-maktx, "Material Description
dsnam TYPE t024d-dsnam, "Controller Name
END OF t_marc_all,
BEGIN OF t_output,
dispo TYPE marc-dispo, "MRP Controller
dsnam TYPE t024d-dsnam, "Controller Name
matnr TYPE vbap-matnr, "Material
maktx TYPE makt-maktx, "Material Description
vbeln TYPE vbak-vbeln, "Sales document
posnr TYPE vbap-posnr, "Item
edatu TYPE vbep-edatu, "Delivery Date
wmeng TYPE i, "Order Quantity
shipqty TYPE i, "Shipped Quantity
olfmng TYPE i, "Open Quantity
fill TYPE olfmng, "%Fill
materialfill TYPE olfmng,
controllerfill TYPE olfmng,
soldto TYPE vbak-kunnr, "Sold To Party
shipto TYPE vbpa-kunnr, "Ship To Party
END OF t_output,
BEGIN OF t_date,
edatu TYPE sy-datum, "Delivery date
END OF t_date.
******************* Do Nothing
Do Nothing
Do Nothing
Do Nothing
Begin Of CDXK961295********************************
TYPES:BEGIN OF t_sum_mrpcontro,
dispo TYPE marc-dispo, "MRP Controller
dsnam TYPE t024d-dsnam, "Controller Name
wmeng TYPE i, "Order Quantity
shipqty TYPE i, "Shipped Quantity
olfmng TYPE i, "Open Quantity
controllerfill TYPE olfmng,
END OF t_sum_mrpcontro,
BEGIN OF t_sum_material,
dispo TYPE marc-dispo, "MRP Controller
dsnam TYPE t024d-dsnam, "Controller Name
matnr TYPE vbap-matnr, "Material
maktx TYPE makt-maktx, "Material Description
wmeng TYPE i, "Order Quantity
shipqty TYPE i, "Shipped Quantity
olfmng TYPE i, "Open Quantity
materialfill TYPE olfmng,
END OF t_sum_material.
*******************Get Data from VBEP: schedule line data within Date range of EDATU.
End Of CDXK961295 This Subroutine does not take any parameters.
Do Nothing .
DATA:
i_vbak TYPE STANDARD TABLE OF t_vbak,
i_vbap TYPE STANDARD TABLE OF t_vbap,
i_marc TYPE STANDARD TABLE OF t_marc,
i_makt TYPE STANDARD TABLE OF t_makt,
i_vbpa TYPE STANDARD TABLE OF t_vbpa,
i_t024d TYPE STANDARD TABLE OF t_t024d,
i_vbep TYPE STANDARD TABLE OF t_vbep,
i_vbep_all TYPE STANDARD TABLE OF t_vbep_all,
i_marc_all TYPE STANDARD TABLE OF t_marc_all,
o_output TYPE STANDARD TABLE OF t_output,
i_date TYPE STANDARD TABLE OF t_date,
i_sum_mrpcontro TYPE STANDARD TABLE OF t_sum_mrpcontro,"CDXK961295
i_sum_material TYPE STANDARD TABLE OF t_sum_material. "CDXK961295
DATA:
wa_vbak LIKE LINE OF i_vbak,
wa_vbap LIKE LINE OF i_vbap,
wa_marc LIKE LINE OF i_marc,
wa_makt LIKE LINE OF i_makt,
wa_vbpa LIKE LINE OF i_vbpa,
wa_t024d LIKE LINE OF i_t024d,
wa_vbep LIKE LINE OF i_vbep,
wa_vbep_all LIKE LINE OF i_vbep_all,
wa_marc_all LIKE LINE OF i_marc_all,
wa_output LIKE LINE OF o_output,
wa_date LIKE LINE OF i_date,
wa_sum_mrpcontro LIKE LINE OF i_sum_mrpcontro, "CDXK961295
wa_sum_material LIKE LINE OF i_sum_material. "CDXK961295
Process material and mrp controller data.
CONSTANTS:
c_spras(2) TYPE c VALUE 'EN', "To get material Description In EN
c_parvw(2) TYPE c VALUE 'WE', "To get Ship to party ( SH=WE )
c_act_auth_03 LIKE tactz-actvt VALUE '03', "03 --> Plant check
c_x TYPE c VALUE 'X', "Field catelogue
c_c TYPE c value 'C'. "field catelogue
DATA: g_date TYPE sy-datum, "To keep track of delivery date
g_totalopen TYPE olfmng, "To Split OLFMNG in given date range
g_tabix TYPE sy-tabix. "To keep loop track
*Declartion of t_code for authority check.
DATA: g_tcode LIKE sy-tcode. "variable for TCODE.
************************** This Subroutine does not take any parameters.
ALVObject**********************************
DATA:
i_fieldcat TYPE slis_t_fieldcat_alv,
Process VBEP data with material data.
i_sort TYPE slis_t_sortinfo_alv,
This Subroutine does not take any parameters.
fs_layout TYPE slis_layout_alv,
fs_sort LIKE LINE OF i_sort ,
*internal table to set pf status
i_extab TYPE standard table of slis_extab.
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:
s_werks FOR marc-werks OBLIGATORY, " Producing Plant
s_matnr FOR marc-matnr, " Material
s_dispo FOR marc-dispo. " MRP Controller
SELECTION-SCREEN END OF BLOCK blk1.
SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002.
SELECT-OPTIONS:
s_vkorg FOR vbak-vkorg , " Sales Organisation
s_vbeln FOR vbak-vbeln , " Sales Order
s_auart FOR vbak-auart DEFAULT 'ZLCW' TO 'ZLIF', " Sales Doc Type
s_lgort FOR vbap-lgort, " Storage Location
s_kunnr FOR vbak-kunnr DEFAULT '99999PDY00', " Sold to party
s_edatu FOR vbep-edatu OBLIGATORY. " Delivery Date
SELECTION-SCREEN END OF BLOCK blk2.
**********************This subroutine is copied from transaction ZCSRS to get open quantity.
Naming Conventions have been changed as per standards.
BEGIN OF CDXK961295 This Subroutine does not take any parameters.
*To add select radiobutton group for choosing layout as per users
*requirement to see detail or summary.
SELECTION-SCREEN BEGIN OF BLOCK blk3 WITH FRAME TITLE text-026.
PARAMETER r_lay1 RADIOBUTTON GROUP r1.
PARAMETER r_lay2 RADIOBUTTON GROUP r1 DEFAULT 'X'.
PARAMETER r_lay3 RADIOBUTTON GROUP r1.
SELECTION-SCREEN END OF BLOCK blk3.
**********************Consider only Sch Agmts here to proceed further
CHECK NOT t_sch_agmts[] IS INITIAL.
Doc Flow entries from VBFA
Sales Document: Item Status from VBUP
Sch Line items from VBEP
Sch Agmt Items from VBAP
Now, use the FM for each line item and get the open qty. Make a copy
of iT_SCH_AGMTS for use later on.
Call the FM now
END OF CDXK961295*****************************
To populate final output table
INITIALIZATION.
PERFORM t_code_check.
This Subroutine does not take any parameters.
*Check Authorisation For Plant.
AT SELECTION-SCREEN ON s_werks.
PERFORM plant_auth_check.
*Validate MRP Controller.
AT SELECTION-SCREEN ON s_dispo.
PERFORM validate_mrp_controller.
*Validate Document type.
AT SELECTION-SCREEN ON s_auart.
PERFORM validate_doc_type.
if s_edatu-high value is enterd by user
if only s_edatu-low value is enterd by user
sort for getting orders with shedule lines in reverse order TO adjust
open quantity as per earliest delivery date.
START-OF-SELECTION.
*Check Delivery Dates Entered By user and MODIFY the same.
PERFORM chk_del_date.
PERFORM get_data.
*Loop To Process Number Of Single Values Entered Of EDATU.
LOOP AT s_edatu .
g_tabix = sy-tabix.
READ TABLE i_date INTO wa_date INDEX g_tabix.
IF sy-subrc = 0.
g_date = wa_date-edatu.
PERFORM get_vbep_data. "Get Data from VBEP
PERFORM process_material_data. "Material Detail
PERFORM process_data. "Process Data
PERFORM get_rem_quantity. "Get Open Qty From FM
PERFORM get_final_output. "Add data to output table
CLEAR: i_vbep[],i_vbep_all[].
ENDIF. " IF SY-SUBRC = 0.
ENDLOOP. " LOOP AT s_edatu .
**********************To Calculate TOTAL % fill MRP ControllerWise
BEGIN OF CDXK961295 This subroutine does not take any parameters.
*Display alv as per layout selection.
IF r_lay1 = 'X'.
PERFORM calc_mrpcontroller_%fill.
PERFORM calc_material_%fill.
PERFORM fill_catalogue. " Fill catelogue
PERFORM display_output. " Display OUTPUT ON AlV GRID using FM.
ELSEIF r_lay2 = 'X'.
PERFORM process_sum_mrpcontro.
PERFORM fill_catelogue_mrpcontro. " Fill catelogue
PERFORM display_sum_mrpcontro. " Display OUTPUT ON AlV GRID using FM
ELSEIF r_lay3 = 'X'.
PERFORM process_sum_material.
PERFORM fill_catelogue_material. " Fill catelogue
PERFORM display_sum_material. " Display OUTPUT ON AlV GRID using FM.
ENDIF. " IF r_lay1 = 'X'.
**********************END OF CDXK961295 This subroutine does not take any parameter.
&---- To fill FieldCatelogue to be passed to FM
*& Form chk_del_date
This Subroutine does not take any parameters.
&----To sort output on MRP Controller AND Material and do subtotal.
Sort on controller name ,material description to get
displayed controller name and material description along with mrp
controller and material at subtotals level.
*check if delivery date is less than today,then modify date till today
*else search in given range.
---- Call alv display function module
This Subroutine does not take any parameters.
SORT AS per MRP Controller,Material and delete duplicates.
Set the Layout attributes
Call FUNCTION MODULE FOR DISPLAY
DO NOTHING
----FORM chk_del_date.
LOOP AT s_edatu.
wa_date = s_edatu-high.
IF s_edatu-low LT sy-datum AND s_edatu-high LT sy-datum.
s_edatu-high = sy-datum.
s_edatu-option = 'BT'.
MODIFY s_edatu.
ENDIF. "IF s_edatu-low LT sy-datum AND s_edatu-high LT sy-datum.
APPEND wa_date TO i_date.
CLEAR:wa_date.
ENDLOOP. " LOOP AT s_edatu.
ENDFORM. " chk_del_date
Check authorization against transaction code
&---- This subroutine does not take any parameters.
*& Form get_data
Validate Document type.
This subroutine does not take any parameters.
Authorisation and validation of Plant
---- This subroutine does not take any parameters.
FORM get_data.
*Get data from VBAK SD agreement and Sold To Party
SELECT vbeln
kunnr
FROM vbak
INTO TABLE i_vbak
WHERE vbeln IN s_vbeln
AND kunnr IN s_kunnr
AND auart IN s_auart
AND vkorg IN s_vkorg.
IF sy-subrc = 0.
SORT i_vbak BY vbeln.
ELSE.
MESSAGE e208(00) WITH 'No Scheduling Agreements Found '(003).
ENDIF. " IF SY-SUBRC = 0.
*Get data from VBAP item data and related material for SD Agrrement from
*VBAK
IF NOT i_vbak[] IS INITIAL.
SELECT vbeln
posnr
werks
matnr
FROM vbap
INTO TABLE i_vbap
FOR ALL ENTRIES IN i_vbak
WHERE vbeln EQ i_vbak-vbeln
AND werks IN s_werks
AND matnr IN s_matnr
AND lgort IN s_lgort
AND abgru EQ space.
IF sy-subrc = 0.
SORT i_vbap BY vbeln posnr.
ELSE.
MESSAGE e368(00) WITH
'No SD Agreements Found for Plant'(004) s_werks.
ENDIF. " IF SY-SUBRC = 0
ENDIF. "IF NOT i_vbak[] IS INITIAL
IF NOT i_vbap[] IS INITIAL.
*Get data from MARC material and MRP Controller for given PLANT.
SELECT werks
matnr
dispo
FROM marc
INTO TABLE i_marc
FOR ALL ENTRIES IN i_vbap
WHERE werks EQ i_vbap-werks
AND matnr EQ i_vbap-matnr
AND dispo IN s_dispo.
IF sy-subrc = 0.
SORT i_marc BY werks matnr.
ELSE.
Validation for PlantSELECT SINGLE WERKS
ENDIF. " IF SY-SUBRC = 0.
*To DELETE Entries from VBAP AS per dispo from select option .
LOOP AT i_vbap INTO wa_vbap.
READ TABLE i_marc INTO wa_marc WITH KEY werks = wa_vbap-werks
matnr = wa_vbap-matnr BINARY SEARCH.
IF sy-subrc <> 0.
DELETE i_vbap.
CONTINUE.
ENDIF. " IF SY-SUBRC <> 0.
ENDLOOP. " LOOP AT i_vbap INTO wa_vbap.
*Get Ship To Party FROM VBPA.
SELECT vbeln
parvw
kunnr
FROM vbpa
INTO TABLE i_vbpa
FOR ALL ENTRIES IN i_vbap
WHERE vbeln EQ i_vbap-vbeln
AND parvw EQ c_parvw.
IF sy-subrc = 0.
SORT i_vbpa BY vbeln.
DELETE ADJACENT DUPLICATES FROM i_vbpa COMPARING vbeln.
ELSE.
ENDIF. " IF SY-SUBRC = 0.
ENDIF. " IF i_vbap[] IS INITIAL
IF NOT i_marc[] IS INITIAL.
*Get Material Description in English from MAKT.
SELECT matnr
maktx
FROM makt
INTO TABLE i_makt
FOR ALL ENTRIES IN i_marc
WHERE matnr EQ i_marc-matnr
AND spras = c_spras.
IF sy-subrc = 0 .
SORT i_makt BY matnr.
DELETE ADJACENT DUPLICATES FROM i_makt COMPARING matnr.
ELSE.
Validate MRP Controller
ENDIF. " IF SY-SUBRC = 0 .
*Get MRP Controller Name from T024D.
SELECT werks
dispo
dsnam
FROM t024d
INTO TABLE i_t024d
FOR ALL ENTRIES IN i_marc
WHERE werks EQ i_marc-werks
AND dispo EQ i_marc-dispo.
IF sy-subrc = 0 .
SORT i_t024d BY werks dispo.
ELSE.
This subroutine does not take any parameters.
ENDIF. " IF SY-SUBRC = 0 .
ENDIF. " IF NOT i_marc[] IS INITIAL
ENDFORM. " get_data
*& Form get_vbep_data
&----Display summary by MRP Controller
This subroutine does not take any parameter.
Field Catelogue for summary by MRP Controller
This Subroutine doen not take any parameter
----FORM get_vbep_data.
IF NOT i_vbap[] IS INITIAL.
IF s_edatu-low GE sy-datum AND s_edatu-high IS INITIAL.
SELECT vbeln
posnr
etenr
edatu
wmeng
FROM vbep
INTO TABLE i_vbep
FOR ALL ENTRIES IN i_vbap
WHERE vbeln EQ i_vbap-vbeln
AND posnr EQ i_vbap-posnr
AND edatu EQ s_edatu-low.
ELSE.
SELECT vbeln
posnr
etenr
edatu
wmeng
FROM vbep
INTO TABLE i_vbep
FOR ALL ENTRIES IN i_vbap
WHERE vbeln = i_vbap-vbeln
AND posnr = i_vbap-posnr
AND edatu BETWEEN s_edatu-low and s_edatu-high.
ENDIF. "IF s_edatu-low GE sy-datum AND s_edatu-high IS INITIAL.
IF sy-subrc = 0 .
ELSE.
MESSAGE e208(00) WITH
'No Scheduling Agreements Found Within Given Delivery Date'(018).
ENDIF. " IF SY-SUBRC = 0 .
ENDIF. " i_vbap[] IS INITIAL.
ENDFORM. " get_vbep_data
Call alv display function module
&---- This Subroutine does not take any parameters.
*& Form process_material_data
SORT AS per MRP Controller and delete duplicates.
Do nothing
Set the Layout attributes
Call FUNCTION MODULE FOR DISPLAY
DO NOTHING
&---- This subRoutine calculates summary line by material and store in
internal table to display as in alv
this subroutine does not take any parameter.
Fills Field Catelogue for alv display for summary by material
---- This subRoutine does not take any parameter.
FORM process_material_data.
*To get Mterial Description and MRP Controller.
LOOP AT i_marc INTO wa_marc .
wa_marc_all-werks = wa_marc-werks.
wa_marc_all-matnr = wa_marc-matnr.
wa_marc_all-dispo = wa_marc-dispo.
READ TABLE i_t024d INTO wa_t024d WITH KEY werks = wa_marc-werks
dispo = wa_marc-dispo BINARY SEARCH.
IF sy-subrc = 0.
wa_marc_all-dsnam = wa_t024d-dsnam.
ENDIF. " IF SY-SUBRC = 0
READ TABLE i_makt INTO wa_makt WITH KEY matnr = wa_marc-matnr
BINARY SEARCH.
IF sy-subrc = 0.
wa_marc_all-maktx = wa_makt-maktx.
ENDIF. " IF SY-SUBRC = 0.
APPEND wa_marc_all TO i_marc_all.
CLEAR :wa_marc_all,wa_marc,wa_t024d,wa_makt.
ENDLOOP. " i_marc INTO wa_marc
*Sort by palnt,material.
SORT i_marc_all BY werks matnr.
ENDFORM. " process_material_data
*& Form process_data
Call Function module For Display of summary my material.
&---- This SubRoutine Does not take any parameter.
SORT AS per MRP Controller,Material and delete duplicates.
do nothing.
Set the Layout attributes
Call FUNCTION MODULE FOR DISPLAY
DO NOTHING
---- Fills fieldcatelogue to be passed to ALV
p_output--> internal table for field catelogue type i_fieldcat.
FORM process_data.
*To get i-vbep_all
IF NOT i_vbep IS INITIAL.
LOOP AT i_vbep INTO wa_vbep.
wa_vbep_all-vbeln = wa_vbep-vbeln.
wa_vbep_all-posnr = wa_vbep-posnr.
wa_vbep_all-etenr = wa_vbep-etenr.
wa_vbep_all-edatu = wa_vbep-edatu.
wa_vbep_all-wmeng = wa_vbep-wmeng.
READ TABLE i_vbap INTO wa_vbap WITH KEY vbeln = wa_vbep-vbeln
posnr = wa_vbep-posnr BINARY SEARCH.
IF sy-subrc = 0.
wa_vbep_all-matnr = wa_vbap-matnr.
READ TABLE i_marc_all INTO wa_marc_all WITH KEY
werks = wa_vbap-werks matnr = wa_vbap-matnr BINARY SEARCH.
IF sy-subrc = 0.
wa_vbep_all-dispo = wa_marc_all-dispo.
wa_vbep_all-dsnam = wa_marc_all-dsnam.
wa_vbep_all-maktx = wa_marc_all-maktx.
ENDIF. " IF SY-SUBRC = 0.
ENDIF. " IF SY-SUBRC = 0.
READ TABLE i_vbak INTO wa_vbak WITH KEY vbeln = wa_vbep-vbeln
BINARY SEARCH.
IF sy-subrc = 0.
wa_vbep_all-soldto = wa_vbak-kunnr.
ENDIF. " IF SY-SUBRC = 0.
READ TABLE i_vbpa INTO wa_vbpa WITH KEY vbeln = wa_vbep-vbeln
BINARY SEARCH.
IF sy-subrc = 0.
wa_vbep_all-shipto = wa_vbpa-kunnr.
ENDIF. " IF SY-SUBRC = 0.
APPEND wa_vbep_all TO i_vbep_all.
CLEAR: wa_vbep,wa_vbap,wa_marc_all,wa_vbep_all,wa_vbak,wa_vbpa.
ENDLOOP. " LOOP AT i_vbep
ENDIF. "i_vbep is INITIAL
ENDFORM. " process_data
*& Form get_rem_quantity
FORM get_rem_quantity.
*Types Declaration
TYPES: BEGIN OF lt_sch_agmts ,
vbeln LIKE vbak-vbeln, "Sales Document
posnr LIKE vbap-posnr, "Item No
END OF lt_sch_agmts,
BEGIN OF lt_doc_types,
vbeln LIKE vbak-vbeln, "Sales Document
vbtyp LIKE vbak-vbtyp, "Document type
END OF lt_doc_types.
*Internal Tables Declaration.
DATA: it_vbfa_data TYPE STANDARD TABLE OF vbfa,
it_vbup_data TYPE STANDARD TABLE OF vbup,
it_vbep_data TYPE STANDARD TABLE OF vbepvb,
it_vbap_data TYPE STANDARD TABLE OF vbapvb,
it_sub_vbfa_data TYPE STANDARD TABLE OF vbfa,
it_sub_vbup_data TYPE STANDARD TABLE OF vbup,
it_sub_vbep_data TYPE STANDARD TABLE OF vbepvb,
it_sub_vbap_data TYPE STANDARD TABLE OF vbapvb,
it_sch_agmts TYPE STANDARD TABLE OF lt_sch_agmts,
it_doc_types TYPE STANDARD TABLE OF lt_doc_types.
*Work area declaration.
DATA: l_vbfa_data LIKE LINE OF it_vbfa_data,
l_vbup_data LIKE LINE OF it_vbup_data,
l_vbep_data LIKE LINE OF it_vbep_data,
l_vbap_data LIKE LINE OF it_vbap_data,
l_sub_vbfa_data LIKE LINE OF it_sub_vbfa_data,
l_sub_vbup_data LIKE LINE OF it_sub_vbup_data,
l_sub_vbep_data LIKE LINE OF it_sub_vbep_data,
l_sub_vbap_data LIKE LINE OF it_sub_vbap_data,
l_sch_agmts LIKE LINE OF it_sch_agmts,
l_doc_types LIKE LINE OF it_doc_types.
*ranges
RANGES: r_vbtyp FOR vbak-vbtyp.
*local variables
DATA: l_tabix LIKE sy-tabix.
CLEAR r_vbtyp[].
r_vbtyp-sign = 'I'. r_vbtyp-option = 'EQ'. r_vbtyp-low = 'E'.
APPEND r_vbtyp. CLEAR r_vbtyp.
r_vbtyp-sign = 'I'. r_vbtyp-option = 'EQ'. r_vbtyp-low = 'F'.
APPEND r_vbtyp. CLEAR r_vbtyp.
CLEAR it_doc_types[].
IF NOT i_vbep_all[] IS INITIAL.
SELECT vbeln
vbtyp
INTO TABLE it_doc_types
FROM vbak
FOR ALL ENTRIES IN i_vbep_all
WHERE vbeln = i_vbep_all-vbeln.
ENDIF.
SORT it_doc_types BY vbtyp.
DELETE it_doc_types WHERE NOT vbtyp IN r_vbtyp.
SORT it_doc_types BY vbeln.
LOOP AT i_vbep_all INTO wa_vbep_all.
READ TABLE it_doc_types INTO l_doc_types
WITH KEY vbeln = wa_vbep_all-vbeln BINARY SEARCH.
IF sy-subrc = 0 .
l_sch_agmts-vbeln = wa_vbep_all-vbeln.
l_sch_agmts-posnr = wa_vbep_all-posnr.
APPEND l_sch_agmts TO it_sch_agmts.
CLEAR l_sch_agmts.
ENDIF.
CLEAR : wa_vbep_all,l_doc_types.
ENDLOOP.
SORT it_sch_agmts.
DELETE ADJACENT DUPLICATES FROM it_sch_agmts COMPARING
vbeln posnr.
IF NOT it_sch_agmts[] IS INITIAL.
SELECT *
FROM vbfa
INTO TABLE it_vbfa_data
FOR ALL ENTRIES IN it_sch_agmts
WHERE vbelv = it_sch_agmts-vbeln
AND posnv = it_sch_agmts-posnr.
SELECT *
FROM vbup
INTO TABLE it_vbup_data
FOR ALL ENTRIES IN it_sch_agmts
WHERE vbeln = it_sch_agmts-vbeln
AND posnr = it_sch_agmts-posnr.
SELECT *
FROM vbep
INTO TABLE it_vbep_data
FOR ALL ENTRIES IN it_sch_agmts
WHERE vbeln = it_sch_agmts-vbeln
AND posnr = it_sch_agmts-posnr.
SELECT *
FROM vbap
INTO TABLE it_vbap_data
FOR ALL ENTRIES IN it_sch_agmts
WHERE vbeln = it_sch_agmts-vbeln
AND posnr = it_sch_agmts-posnr.
LOOP AT it_sch_agmts INTO l_sch_agmts .
CLEAR: it_sub_vbfa_data[], it_sub_vbup_data[],it_sub_vbep_data[],
it_sub_vbap_data[].
LOOP AT it_vbfa_data INTO l_vbfa_data
WHERE vbelv = l_sch_agmts-vbeln AND posnv = l_sch_agmts-posnr.
l_sub_vbfa_data = l_vbfa_data.
APPEND l_sub_vbfa_data TO it_sub_vbfa_data.
CLEAR : l_sub_vbfa_data,l_vbfa_data.
ENDLOOP. "LOOP AT it_vbfa_data into l_vbfa_data
LOOP AT it_vbup_data INTO l_vbup_data
WHERE vbeln = l_sch_agmts-vbeln AND posnr = l_sch_agmts-posnr.
l_sub_vbup_data = l_vbup_data.
APPEND l_sub_vbup_data TO it_sub_vbup_data.
CLEAR : l_sub_vbup_data,l_vbup_data.
ENDLOOP. " LOOP AT it_vbup_data Into l_vbup_data
LOOP AT it_vbep_data INTO l_vbep_data
WHERE vbeln = l_sch_agmts-vbeln AND posnr = l_sch_agmts-posnr.
l_sub_vbep_data = l_vbep_data.
APPEND l_sub_vbep_data TO it_sub_vbep_data.
CLEAR : l_sub_vbep_data,l_vbep_data.
ENDLOOP. " LOOP AT it_vbep_data INTO l_vbep_data
LOOP AT it_vbap_data INTO l_vbap_data
WHERE vbeln = l_sch_agmts-vbeln AND posnr = l_sch_agmts-posnr.
l_sub_vbap_data = l_vbap_data.
APPEND l_sub_vbap_data TO it_sub_vbap_data.
CLEAR : l_sub_vbap_data, l_vbap_data.
ENDLOOP. " LOOP AT it_vbap_data INTO l_vbap_data
CALL FUNCTION 'RV_SCHEDULE_CHECK_DELIVERIES'
EXPORTING
fbeleg = l_sch_agmts-vbeln
fposnr = l_sch_agmts-posnr
TABLES
fvbfa = it_sub_vbfa_data
fvbup = it_sub_vbup_data
fxvbep = it_sub_vbep_data
fvbap = it_sub_vbap_data
EXCEPTIONS
fehler_bei_lesen_fvbup = 1
fehler_bei_lesen_fxvbep = 2
OTHERS = 3.
IF sy-subrc EQ 0.
LOOP AT i_vbep_all INTO wa_vbep_all
WHERE vbeln = l_sch_agmts-vbeln.
l_tabix = sy-tabix.
READ TABLE it_sub_vbep_data INTO l_sub_vbep_data
WITH KEY vbeln = wa_vbep_all-vbeln
posnr = wa_vbep_all-posnr
etenr = wa_vbep_all-etenr.
IF sy-subrc EQ 0.
wa_vbep_all-olfmng = l_sub_vbep_data-olfmng.
MODIFY i_vbep_all FROM wa_vbep_all
INDEX l_tabix TRANSPORTING olfmng.
ENDIF. " IF SY-SUBRC EQ 0.
ENDLOOP. " LOOP AT i_vbep_all INTO wa_vbep_all
ENDIF. " IF SY-SUBRC EQ 0.
CLEAR l_sch_agmts.
ENDLOOP. "LOOP AT it_sch_agmts INTO l_sch_agmts .
ENDIF. "IF NOT it_sch_agmts[] IS INITIAL.
ENDFORM. " get_rem_quantity
*& Form get_final_output
FORM get_final_output.
DATA:l_vbeln LIKE vbep-vbeln, "Sales Document
l_posnr LIKE vbep-posnr, "Item
l_edatu LIKE vbep-edatu, "Delivery Date
l_tabix TYPE sy-tabix. "Index
IF NOT i_vbep_all IS INITIAL.
*Delete records which are beyond given deleivery date only.
LOOP AT i_vbep_all INTO wa_vbep_all.
l_vbeln = wa_vbep_all-vbeln.
l_posnr = wa_vbep_all-posnr.
l_edatu = wa_vbep_all-edatu.
AT NEW posnr.
IF NOT g_date IS INITIAL.
IF l_edatu > g_date.
DELETE i_vbep_all WHERE vbeln = l_vbeln
AND posnr = l_posnr.
IF sy-subrc = 0.
CONTINUE.
ENDIF. " IF SY-SUBRC = 0.
ENDIF. " IF l_edatu > g_date.
ELSE.
IF l_edatu > s_edatu-low.
DELETE i_vbep_all WHERE vbeln = l_vbeln
AND posnr = l_posnr.
IF sy-subrc = 0.
CONTINUE.
ENDIF. "IF SY-SUBRC = 0.
ENDIF. "IF l_edatu > s_edatu-low.
ENDIF. " g_date IS INITIAL
ENDAT. " AT NEW posnr.
*Delete Records where order quantity is 0 and open quantity is also 0.
IF wa_vbep_all-wmeng EQ 0 AND wa_vbep_all-olfmng EQ 0.
DELETE i_vbep_all. "Deletes current row.
ENDIF. " IF wa_vbep_all-wmeng EQ 0 AND wa_vbep_all-olfmng EQ 0.
CLEAR:wa_vbep_all,l_vbeln,l_posnr.
ENDLOOP. " LOOP AT i_vbep_all INTO wa_vbep_all.
SORT i_vbep_all DESCENDING.
LOOP AT i_vbep_all INTO wa_vbep_all.
l_tabix = sy-tabix.
AT NEW posnr .
SUM.
g_totalopen = wa_vbep_all-olfmng.
ENDAT. " AT NEW posnr .
IF g_totalopen > 0 AND wa_vbep_all-wmeng > 0.
IF wa_vbep_all-wmeng < g_totalopen.
wa_vbep_all-olfmng = wa_vbep_all-wmeng.
g_totalopen = g_totalopen - wa_vbep_all-wmeng.
ELSEIF wa_vbep_all-wmeng GE g_totalopen.
wa_vbep_all-olfmng = g_totalopen.
g_totalopen = 0.
ENDIF. " IF wa_vbep_all-wmeng < g_totalopen.
MODIFY i_vbep_all FROM wa_vbep_all
INDEX l_tabix TRANSPORTING olfmng.
ENDIF. " IF g_totalopen > 0 AND wa_vbep_all-wmeng > 0.
ENDLOOP. " LOOP AT i_vbep_all INTO wa_vbep_all.
*Sort Back In Ascending Order
SORT i_vbep_all.
*DELETE Records where open quantity is 0 .
IF NOT i_vbep_all IS INITIAL.
DELETE i_vbep_all WHERE wmeng = 0 .
ENDIF. " IF NOT i_vbep_all IS INITIAL.
*DELETE Records to get records within delivery date range.
IF NOT g_date IS INITIAL.
DELETE i_vbep_all WHERE edatu > g_date.
ELSEIF g_date IS INITIAL.
DELETE i_vbep_all WHERE edatu > s_edatu-low.
ENDIF. " IF NOT g_date IS INITIAL.
*Populate Final Output Internal Table
LOOP AT i_vbep_all INTO wa_vbep_all.
wa_output-dispo = wa_vbep_all-dispo.
wa_output-dsnam = wa_vbep_all-dsnam.
wa_output-matnr = wa_vbep_all-matnr.
wa_output-maktx = wa_vbep_all-maktx.
wa_output-vbeln = wa_vbep_all-vbeln.
wa_output-posnr = wa_vbep_all-posnr.
wa_output-edatu = wa_vbep_all-edatu.
wa_output-dispo = wa_vbep_all-dispo.
wa_output-wmeng = wa_vbep_all-wmeng.
wa_output-olfmng = wa_vbep_all-olfmng.
wa_output-soldto = wa_vbep_all-soldto.
wa_output-shipto = wa_vbep_all-shipto.
wa_output-shipqty = wa_vbep_all-wmeng - wa_vbep_all-olfmng.
wa_output-fill =
( wa_output-shipqty / wa_vbep_all-wmeng ) * 100.
APPEND wa_output TO o_output.
CLEAR: wa_output,wa_vbep_all.
ENDLOOP. " LOOP AT i_vbep_all INTO wa_vbep_all.
ENDIF. " IF NOT i_vbep_all IS INITIAL.
ENDFORM. " get_final_output
*& Form process_output
FORM calc_mrpcontroller_%fill.
DATA:l_shipqty TYPE olfmng, "Shipped Quantity
l_wmeng LIKE vbep-wmeng, "Order Quantity
l_fill TYPE olfmng, "%fill
l_dispo LIKE t024d-dispo. "Mrp Controller
IF NOT o_output IS INITIAL.
SORT o_output BY dispo.
LOOP AT o_output INTO wa_output.
l_dispo = wa_output-dispo.
AT NEW dispo.
SUM.
l_shipqty = wa_output-shipqty.
l_wmeng = wa_output-wmeng.
ENDAT. " AT NEW dispo
l_fill = ( l_shipqty / l_wmeng ) * 100 .
wa_output-controllerfill = l_fill.
MODIFY o_output FROM wa_output TRANSPORTING controllerfill
WHERE dispo = l_dispo.
CLEAR:wa_output.
ENDLOOP. "LOOP AT o_output INTO wa_output.
ENDIF. "IF NOT o_output IS INITIAL.
ENDFORM. " calc_mrpcontroller_%fill
*& Form calc_material_%fill
*To Calculate Total % Fill By Material.
FORM calc_material_%fill.
DATA: l_shipqty TYPE olfmng, "Shipped Quantity
l_wmeng TYPE vbep-wmeng, "Order Quantity
l_fill TYPE olfmng, "%fill
l_matnr TYPE mara-matnr. "Material
IF NOT o_output IS INITIAL.
SORT o_output BY dispo matnr.
LOOP AT o_output INTO wa_output.
l_matnr = wa_output-matnr.
AT NEW matnr.
SUM.
l_shipqty = wa_output-shipqty.
l_wmeng = wa_output-wmeng.
ENDAT. " AT NEW matnr.
l_fill = ( l_shipqty / l_wmeng ) * 100 .
wa_output-materialfill = l_fill.
MODIFY o_output FROM wa_output TRANSPORTING materialfill
WHERE matnr = l_matnr.
CLEAR:wa_output.
ENDLOOP. "LOOP AT o_output INTO wa_output.
ENDIF. "IF NOT o_output IS INITIAL.
ENDFORM. " calc_material_%fill
*& Form fill_catalogue
FORM fill_catalogue.
CLEAR: i_fieldcat[].
PERFORM build_fieldcat using 1 'DISPO' 'O_OUTPUT' 15 ' '
'MRP Controller'(005) ' ' i_fieldcat.
PERFORM build_fieldcat using 2 'DSNAM' 'O_OUTPUT' 15 ' '
'Controller Name'(006) ' ' i_fieldcat.
PERFORM build_fieldcat using 3 'MATNR' 'O_OUTPUT' 10 ' '
'Material'(007) c_c i_fieldcat.
PERFORM build_fieldcat using 4 'MAKTX' 'O_OUTPUT' 20 ' '
'Material Description'(008) ' ' i_fieldcat.
PERFORM build_fieldcat using 5 'VBELN' 'O_OUTPUT' 12 ' '
'SD Agreement'(009) c_c i_fieldcat.
PERFORM build_fieldcat using 6 'POSNR' 'O_OUTPUT' 4 ' '
'Item'(010) ' ' i_fieldcat.
PERFORM build_fieldcat using 7 'EDATU' 'O_OUTPUT' 13 ' '
'Delivery Date'(011) ' ' i_fieldcat.
PERFORM build_fieldcat using 8 'WMENG' 'O_OUTPUT' 20 c_x
'Scheduled Quantity'(012) c_c i_fieldcat.
PERFORM build_fieldcat using 9 'SHIPQTY' 'O_OUTPUT' 16 c_x
'Shipped Quantity'(013) c_c i_fieldcat.
PERFORM build_fieldcat using 10 'OLFMNG' 'O_OUTPUT' 12 c_x
'REM Quantity'(014) c_c i_fieldcat.
PERFORM build_fieldcat using 11 'FILL' 'O_OUTPUT' 6 ' '
'% Fill Per SchedLine'(025) c_c i_fieldcat.
PERFORM build_fieldcat using 12 'MATERIALFILL' 'O_OUTPUT' 21 ' '
'Tot %Fill By Material'(023) c_c i_fieldcat.
PERFORM build_fieldcat using 13 'CONTROLLERFILL' 'O_OUTPUT' 24 ' '
'Tot %Fill By MRP Contro.'(024) c_c i_fieldcat.
PERFORM build_fieldcat using 14 'SOLDTO' 'O_OUTPUT' 8 ' '
'SoldTo'(016) ' ' i_fieldcat.
PERFORM build_fieldcat using 15 'SHIPTO' 'O_OUTPUT' 8 ' '
'ShipTo'(017) ' ' i_fieldcat.
*Sort by mrp Controller.
fs_sort-spos = 1.
fs_sort-fieldname = 'DISPO'.
fs_sort-up = c_x.
APPEND fs_sort TO i_sort.
CLEAR fs_sort.
*Sort and subtotal by controller description and subtotal.
fs_sort-spos = 2.
fs_sort-fieldname = 'DSNAM'.
fs_sort-up = c_x.
fs_sort-subtot = c_x.
APPEND fs_sort TO i_sort.
CLEAR fs_sort.
*Sort by material.
fs_sort-spos = 3.
fs_sort-fieldname = 'MATNR'.
fs_sort-up = c_x.
APPEND fs_sort TO i_sort.
CLEAR fs_sort.
*Sort and subtotal by material description.
fs_sort-spos = 4.
fs_sort-fieldname = 'MAKTX'.
fs_sort-up = c_x.
fs_sort-subtot = c_x.
APPEND fs_sort TO i_sort.
CLEAR fs_sort.
ENDFORM. " fill_catalogue
*& Form display_output
FORM display_output.
IF o_output IS INITIAL.
MESSAGE e208(00) WITH text-022.
ELSE.
SORT o_output BY dispo matnr vbeln posnr edatu.
ENDIF. " IF o_output IS INITIAL.
MOVE c_x TO fs_layout-colwidth_optimize.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = fs_layout
it_fieldcat = i_fieldcat
it_sort = i_sort
i_save = 'A'
TABLES
t_outtab = o_output.
IF sy-subrc <> 0.
ENDIF.
ENDFORM. " display_output
*& Form t_code_check
FORM t_code_check.
**validate authorization against transaction code
SELECT tcode FROM tstc
UP TO 1 ROWS
INTO g_tcode
WHERE pgmna = sy-repid.
ENDSELECT.
IF sy-subrc = 0.
AUTHORITY-CHECK OBJECT 'S_TCODE'
ID 'TCD' FIELD g_tcode.
IF sy-subrc NE 0.
MESSAGE e261(sf) WITH g_tcode.
ENDIF. "IF SY-SUBRC NE 0.
ENDIF. "IF SY-SUBRC = 0.
ENDFORM. " t_code_check
*& Form validate_doc_type
FORM validate_doc_type.
DATA:l_auart LIKE tvak-auart. "validate document type
SELECT auart
FROM tvak
UP TO 1 ROWS
INTO l_auart
WHERE auart IN s_auart.
ENDSELECT.
IF sy-subrc NE 0 AND NOT l_auart IS INITIAL .
MESSAGE e000(oo)
WITH 'Please enter a valid document type'(019).
ENDIF.
ENDFORM. " validate_doc_type
*& Form plant_auth_check
FORM plant_auth_check.
*Types declaration for werks
TYPES:BEGIN OF lt_werks,
werks TYPE marc-werks,
END OF lt_werks.
*internal table and wrk area to hold multiple plants
DATA :li_werks TYPE STANDARD TABLE OF lt_werks,
l_werks LIKE LINE OF li_werks.
SELECT werks
FROM t001w
INTO TABLE li_werks
WHERE werks IN s_werks.
IF sy-subrc EQ 0.
LOOP AT li_werks INTO l_werks.
AUTHORITY-CHECK OBJECT 'Z_MM_PLANT'
ID 'ACTVT' FIELD c_act_auth_03
ID 'WERKS' FIELD l_werks
ID 'TCD' FIELD g_tcode.
IF sy-subrc NE 0.
MESSAGE e004(co) WITH l_werks.
ENDIF. " IF SY-SUBRC NE 0..
ENDLOOP. " LOOP AT li_werks INTO l_werks..
ELSE.
MESSAGE e174(q3) WITH s_werks.
ENDIF. " IF SY-SUBRC EQ 0.....
ENDFORM. " plant_auth_check
*& Form validate_mrp_controller
FORM validate_mrp_controller.
DATA: l_dispo LIKE t024d-dispo. "mrp Controller
SELECT dispo
FROM t024d
UP TO 1 ROWS
INTO l_dispo
WHERE dispo IN s_dispo.
ENDSELECT.
IF sy-subrc NE 0 AND NOT l_dispo IS INITIAL.
MESSAGE e000(oo)
WITH 'Please enter a valid MRP Controller'(020).
ENDIF. "SY-SUBRC NE 0 AND NOT l_dispo IS INITIAL.
ENDFORM. " validate_mrp_controller
**********************BEGIN OF CDXK961295****************************
*& Form display_summary
FORM process_sum_mrpcontro.
DATA:l_shipqty TYPE olfmng, "Shipped Quantity
l_wmeng LIKE vbep-wmeng, "Order Quantity
l_fill TYPE olfmng, "%fill
l_olfmng TYPE olfmng. "Open Quantity
IF NOT o_output IS INITIAL.
SORT o_output BY dispo.
LOOP AT o_output INTO wa_output.
wa_sum_mrpcontro-dispo = wa_output-dispo.
wa_sum_mrpcontro-dsnam = wa_output-dsnam.
AT END OF dispo.
SUM.
wa_sum_mrpcontro-shipqty = wa_output-shipqty.
wa_sum_mrpcontro-wmeng = wa_output-wmeng.
wa_sum_mrpcontro-olfmng = wa_output-olfmng.
l_fill = ( wa_output-shipqty / wa_output-wmeng ) * 100 .
wa_sum_mrpcontro-controllerfill = l_fill.
APPEND wa_sum_mrpcontro TO i_sum_mrpcontro.
ENDAT. " AT END OF dispo
CLEAR:wa_sum_mrpcontro,wa_output, l_fill.
ENDLOOP. "LOOP AT o_output INTO wa_output.
SORT i_sum_mrpcontro BY dispo.
*Calculate 'total' and add as lastline to internal table .
LOOP AT i_sum_mrpcontro INTO wa_sum_mrpcontro.
l_shipqty = l_shipqty + wa_sum_mrpcontro-shipqty.
l_wmeng = l_wmeng + wa_sum_mrpcontro-wmeng.
l_olfmng = l_olfmng + wa_sum_mrpcontro-olfmng.
CLEAR:wa_sum_mrpcontro.
ENDLOOP. "LOOP AT i_sum_mrpcontro
l_fill = ( l_shipqty / l_wmeng ) * 100 .
wa_sum_mrpcontro-dsnam = 'Total'(015).
wa_sum_mrpcontro-wmeng = l_wmeng.
wa_sum_mrpcontro-shipqty = l_shipqty.
wa_sum_mrpcontro-olfmng = l_olfmng.
wa_sum_mrpcontro-controllerfill = l_fill.
APPEND wa_sum_mrpcontro TO i_sum_mrpcontro.
ENDIF. "IF NOT o_output IS INITIAL.
ENDFORM. " process_sum_mrpcontro.
*& Form fill_catelogue_summary
FORM fill_catelogue_mrpcontro.
CLEAR: i_fieldcat[].
PERFORM build_fieldcat using 1 'DISPO' 'I_SUM_MRPCONTRO' 15 ' '
'MRP Controller'(005) ' ' i_fieldcat.
PERFORM build_fieldcat using 2 'DSNAM' 'I_SUM_MRPCONTRO' 15 ' '
'Controller Name'(006) ' ' i_fieldcat.
PERFORM build_fieldcat using 3 'WMENG' 'I_SUM_MRPCONTRO' 20 ' '
'Scheduled Quantity'(012) c_c i_fieldcat.
PERFORM build_fieldcat using 4 'SHIPQTY' 'I_SUM_MRPCONTRO' 16 ' '
'Shipped Quantity'(013) c_c i_fieldcat.
PERFORM build_fieldcat using 5 'OLFMNG' 'I_SUM_MRPCONTRO' 12 ' '
'REM Quantity'(014) c_c i_fieldcat.
PERFORM build_fieldcat using 6 'CONTROLLERFILL' 'I_SUM_MRPCONTRO' 24
' ' 'Tot %Fill By MRP Contro.'(024) c_c i_fieldcat.
ENDFORM. " fill_catelogue_mrpcontro.
*& Form display_output
FORM display_sum_mrpcontro.
IF i_sum_mrpcontro IS INITIAL.
MESSAGE e208(00) WITH text-022.
ELSE.
ENDIF. " IF o_output IS INITIAL.
fs_layout-colwidth_optimize = c_x.
*To disable option of sort,and sum.
DATA:lr_extab TYPE slis_extab.
lr_extab-fcode = '&OUP'.
APPEND lr_extab TO i_extab.
lr_extab-fcode = '&ODN'.
APPEND lr_extab TO i_extab.
lr_extab-fcode = '&UMC'.
APPEND lr_extab TO i_extab.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = fs_layout
it_fieldcat = i_fieldcat
i_save = 'A'
IT_EXCLUDING = i_extab
TABLES
t_outtab = i_sum_mrpcontro.
IF sy-subrc <> 0.
ENDIF.
ENDFORM. " display_sum_mrpcontro
*& Form process_sum_material
FORM process_sum_material.
DATA:l_shipqty TYPE olfmng, "Shipped Quantity
l_wmeng LIKE vbep-wmeng, "Order Quantity
l_fill TYPE olfmng, "%fill
l_olfmng TYPE olfmng. "Open Quantity
IF NOT o_output IS INITIAL.
SORT o_output BY dispo matnr.
LOOP AT o_output INTO wa_output.
wa_sum_material-dispo = wa_output-dispo.
wa_sum_material-dsnam = wa_output-dsnam.
wa_sum_material-matnr = wa_output-matnr.
wa_sum_material-maktx = wa_output-maktx.
AT END OF matnr.
SUM.
l_fill = ( wa_output-shipqty / wa_output-wmeng ) * 100 .
wa_sum_material-wmeng = wa_output-wmeng.
wa_sum_material-shipqty = wa_output-shipqty.
wa_sum_material-olfmng = wa_output-olfmng.
wa_sum_material-materialfill = l_fill.
APPEND wa_sum_material TO i_sum_material.
ENDAT. " AT END OF matnr
CLEAR:wa_sum_material,wa_output, l_fill.
ENDLOOP. "LOOP AT o_output INTO wa_output.
SORT i_sum_material BY dispo matnr.
*Calculate 'total' and add as lastline to internal table .
LOOP AT i_sum_material INTO wa_sum_material.
l_shipqty = l_shipqty + wa_sum_material-shipqty.
l_wmeng = l_wmeng + wa_sum_material-wmeng.
l_olfmng = l_olfmng + wa_sum_material-olfmng.
CLEAR:wa_sum_material.
ENDLOOP. "LOOP AT i_sum_material
l_fill = ( l_shipqty / l_wmeng ) * 100 .
wa_sum_material-dsnam = 'Total'(015).
wa_sum_material-wmeng = l_wmeng.
wa_sum_material-shipqty = l_shipqty.
wa_sum_material-olfmng = l_olfmng.
wa_sum_material-materialfill = l_fill.
APPEND wa_sum_material TO i_sum_material.
ENDIF. "IF NOT o_output IS INITIAL.
ENDFORM. " process_sum_material
*& Form fill_catelogue_material
FORM fill_catelogue_material.
CLEAR: i_fieldcat[].
PERFORM build_fieldcat using 1 'DISPO' 'I_SUM_MATERIAL' 15 ' '
'MRP Controller'(005) ' ' i_fieldcat.
PERFORM build_fieldcat using 2 'DSNAM' 'I_SUM_MATERIAL' 15 ' '
'Controller Name'(006) ' ' i_fieldcat.
PERFORM build_fieldcat using 3 'MATNR' 'I_SUM_MATERIAL' 10 ' '
'Material'(007) c_c i_fieldcat.
PERFORM build_fieldcat using 4 'MAKTX' 'I_SUM_MATERIAL' 20 ' '
'Material Description'(008) ' ' i_fieldcat.
PERFORM build_fieldcat using 5 'WMENG' 'I_SUM_MATERIAL' 20 ' '
'Scheduled Quantity'(012) c_c i_fieldcat.
PERFORM build_fieldcat using 6 'SHIPQTY' 'I_SUM_MATERIAL' 16 ' '
'Shipped Quantity'(013) c_c i_fieldcat.
PERFORM build_fieldcat using 7 'OLFMNG' 'I_SUM_MATERIAL' 12 ' '
'REM Quantity'(014) c_c i_fieldcat.
PERFORM build_fieldcat using 8 'MATERIALFILL' 'I_SUM_MATERIAL' 24
' ' 'Tot %Fill By Material'(023) c_c i_fieldcat.
ENDFORM. " fill_catelogue_material
*& Form display_sum_material
FORM display_sum_material.
IF i_sum_material IS INITIAL.
MESSAGE e208(00) WITH text-022.
ELSE.
ENDIF. " IF o_output IS INITIAL.
fs_layout-colwidth_optimize = c_x.
*To disable option of sort,and sum.
DATA:lr_extab TYPE slis_extab.
lr_extab-fcode = '&OUP'.
APPEND lr_extab TO i_extab.
lr_extab-fcode = '&ODN'.
APPEND lr_extab TO i_extab.
lr_extab-fcode = '&UMC'.
APPEND lr_extab TO i_extab.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = fs_layout
it_fieldcat = i_fieldcat
IT_EXCLUDING = i_extab
i_save = 'A'
TABLES
t_outtab = i_sum_material.
IF sy-subrc <> 0.
ENDIF.
ENDFORM. " display_sum_material
*& Form Build field catelogue
*This subroutine takes paremeters.
*p_colpos-->column no. in alv
*p_fieldname-->name of column in internal table type char
*p_tabname-->name of internal table type char
*p-outputlen--> output length of column.
*p_do_sum--> flag to set subtotal
*p_coltext--> column heading type char
*p_just--> flag to set center justify type char
FORM build_fieldcat USING p_colpos p_fieldname p_tabname p_outputlen
p_do_sum p_coltext p_just p_output like i_fieldcat[].
DATA : l_fieldcat LIKE LINE OF i_fieldcat. "wrk area for field catelog
l_fieldcat-col_pos = p_colpos.
l_fieldcat-fieldname = p_fieldname.
l_fieldcat-tabname = p_tabname.
l_fieldcat-outputlen = p_outputlen.
l_fieldcat-do_sum = p_do_sum.
l_fieldcat-seltext_l = p_coltext.
l_fieldcat-just = p_just.
APPEND l_fieldcat TO p_output.
CLEAR l_fieldcat.
ENDFORM. " BUILD_FIELDCAT
**********************END OF CDXK961295**************************** -
Authorisation of Objects to Plant Specific Users
Hi,
I developed Zreports for HR and PP modules. In these reports ,Selection Screen contains Personal Area and Personal Subarea(in case of HR module) and Plant(PP module). Now any User can give any Personnel area or Plant and can view the report Output.But the User should be able to view the report Output only when he gives the Personnel Area or Plant to which he belongs otherwise not. For example if the User belongs to Personnel Area or Plant -
>1500,he should have the authorisation to run the report for 1500 only. If he gives any other Plant ,i should raise an error message. How can i approach to this issue?Please help.
Regards
K SrinivasHi,
Lets say based on the plant you want to assign the authorization objects.
Then based on the plant authorization, first check any standard reports or standard transactions are now taking place. Usually the users belong to the same can answer this better.
Now by looking at the authorization given to those standard transactions, we can trace the roles given, and we can see the authorization objects used there.
I mean there will be some authorization objects existing for plants.
So in the at selection screen of your custom development, first check the authorization with respect to the plant given in the selection screen, then proceed.
For more information look into the transaction SUIM.
Regards,
Santhosh. -
Need Authorisation Object: CO88 on plant code
Hi
Need to restrict C088 transaction code on user's plant code, can any one let me know the authorisation object for the same
Thanks a lot
Edited by: Julius Bussche on Aug 27, 2009 9:24 AM
Please use meaningfull subject titlesThere are four Objects for CO class(as of 4.6C, my bad I'm still in old version),as CO88 belongs to CO.
K_CKBOB
K_ML_MGV
K_PKSA
K_WIP
You can choose either of these. As a test if you wanna try creating a test role only for CO88, then add any object in SU24 & maintain(Check/maintain) its Check ID, it should work only for the Plant you choose in the test role.
Regards
Puneeth -
Authorisation to be restrict to plant level for VA01
hi experts,
is it possible to restrict the user to plant level for the transaction VA01.
if possible authorization object for the same or some other processI think you can maintain the same through MV45AFZZ by linking with the User name & Plant itself.
Otherwise you can maintain your own Authorization Object and assign it to User Name Profile ( through BASIS Constnt) by mentioning Plant & Activity in an Authorization Object.
Best Regards,
Ankur -
Authorisation-object for Plant-WERKS in SD
Hi Experts,
Am working on a report for SD / OTC module.
We have PLANT-WERKS field in the selection screen, so, I have to cross-check user authentication for PLANT-WERKS level, so, when I checked the SU20 and SU21, I saw the below 2 objects,
1) 'M_RECH_WRK' (Invoices: Plant - Materials Management - Invoice Verification class)"
2) 'M_EINF_WRK' (Plant in Purchasing Info Record - Materials Management: Purchasing)
But, seems they are for MM module, pls. let me know Wht is the PLANT-WERKS authentication object for SD / OTC module?
Thank youI don't think there are any SD based authorization objects exclusively for Plant. Table TOBJ defines auth objects and contains *_WRK entries only for MM, PP and WG modules. Listing all the SD objects in TOBJ, only the V_ECCN auth object includes the Plant in the fields checked, but it also checks another field and I'm not sure where it is checked, so it may or may not be useful to you. You might need to create a custom authorization object.
.. Craig -
My requirement is:
The user of a particular plant should be able to get the dispatch details for that Plant only.
Use the Authorization object .
The filed WERKS is not used anywhere else in the list expect for select options.Hi
*& Form sub_check_auth_iwerk *
This form checks authorization for plant. *
FORM sub_check_auth_iwerk .
--Constant for t code, no tcode hence value = '' (all)
CONSTANTS: lc_tcd LIKE tstc-tcode VALUE '*'.
*--Table for all the plants in selection screen. This
table will be used for authority check.
DATA: BEGIN OF li_plant OCCURS 0,
iwerk LIKE t001w-werks,
END OF li_plant.
*--Select query to pick plant from table t001w
SELECT werks "Plant
INTO TABLE li_plant
FROM t001w
WHERE werks IN s_iwerk.
LOOP AT li_plant.
AUTHORITY-CHECK OBJECT 'I_SWERK'
ID 'TCD' FIELD lc_tcd
ID 'SWERK' FIELD li_plant-iwerk.
*--Check SUBRC
IF sy-subrc NE 0.
*--No Authorization for Plant
MESSAGE e016 WITH li_plant-iwerk.
ENDIF.
ENDLOOP. "loop at li_plant
ENDFORM. "sub_check_auth_iwerk
Try this link also:
http://help.sap.com/saphelp_47x200/helpdata/en/52/67167f439b11d1896f0000e8322d00/frameset.htm
http://help.sap.com/saphelp_erp2005/helpdata/en/ef/4aba3b3bf00152e10000000a114084/frameset.htm
go through this link hope this would help you to give the idea about authorization object,
http://help.sap.com/saphelp_nw04s/helpdata/en/9f/dbaccb35c111d1829f0000e829fbfe/content.htm
http://help.sap.com/saphelp_nw04s/helpdata/en/9f/dbacbe35c111d1829f0000e829fbfe/content.htm
http://www.guidancetech.com/people/holland/sap/abap/
Regards
Neha -
Authorisation for transfer of material from group of plants to another.
Hi experts
We need to control mvt of goods from group of plants to another group of plants by the same user. The group of plants may be combination of multiple plants or single plant also. Transaction to be checked is MB1B with 541/412 mvt. Basically this requirement is to check transfer of exempted material to Non-exempted material from the point of VAT implication. Can any body share your thought.
rgds
Raghu ShettyHi,
i still have some concerns about the creating new materials solution because we have to create the following relevant things:
SD: condition record
MM: infor record
PP: new BoM
we have 25 materials which will change profit center, there're a lot extra works we need to do.
Is there any other way we can try?
Regards -
Authorization of alv report based on plants
I have created a new alv report for sale order statement.The problem is which can be seen in all plants
irespective of the user.Suppose our company has 5 palnt
Plant 1100 to 1500
The problem is suppose a user he has only rights in a prticular plant but he can see all the palnt sale order details
How can we authorize this particular alv report based on the plantsHello,
My assumption: You have Company Code(T001-BUKRS) in the selection-screen.
Plz check the code snippet below:
DATA:
IT_PLANT TYPE STANDARD TABLE OF WERKS,
WA_PLANT LIKE LINE OF IT_PLANT.
DATA:
IT_R_WERKS TYPE RANGE_T_WERKS_D,
R_WERKS TYPE RANGE_S_WERKS_D.
SELECT BWKEY INTO TABLE IT_PLANT
FROM T001K
WHERE BUKRS = '1000'. "--> Here you have to use your sel. scr. parameter
IF SY-SUBRC = 0.
SORT IT_PLANT BY WERKS.
ENDIF.
LOOP AT IT_PLANT INTO WA_PLANT.
* Check the authority for the plant
AUTHORITY-CHECK OBJECT 'M_MSEG_WMB'
ID 'ACTVT' FIELD '03'
ID 'WERKS' FIELD WA_PLANT-WERKS.
IF SY-SUBRC = 0.
R_WERKS-SIGN = 'I'.
R_WERKS-OPTION = 'EQ'.
R_WERKS-LOW = WA_PLANT-WERKS.
APPEND R_WERKS TO IT_R_WERKS.
CLEAR R_WERKS.
ENDIF.
ENDLOOP.
IF IT_R_WERKS IS NOT INITIAL.
"Select data using the Plants for which user is authorised
ELSE.
"User has no authority to display any Plant data
ENDIF.
Hope this is of some help to you.
BR,
Suhas
Edited by: Suhas Saha on Mar 18, 2009 10:18 AM -
Any difference setting background MRP run in MDBT and SM37
Hello,
Just wander if there is any differences setting up MRP run in MDBT or in SM37 to run RMMRP000? This is to run MRP at plant level in background.
Thanks,
Lin-LinHi,.
Both MDBT & SM37 are having same program (SAPLBTCH) . MDBT is <b>Foreground</b> job as well as <b>Background job.</b>
SM37 is only for <b>Background job</b> only.
Pls let me know any further clarification.
regards,
Mohan
Message was edited by:
Mohan Ramalingam -
Materials with multiple plants and wm views
Hello,
we are migrating materials to an environment where we have multiple plants, sales org., warehouse numbers. When we create the WM view we set a plant and warehouse number. As WM view is not really connected to a plant (table MLGN) we have the problem that when the users wish to mantain a material WM view, they see different combinations of plants and warehouse numbers, what is not really correct, as they are in different countries.
Country 1: plant 0001, warehouse number 001
Country 2: plant 0002, warehouse number 002
Country 3: plant 0003, warehouse number 003
In country 1, with MM02, the user can open the material in plant 0001 and in any warehouse, ie. 001, 002, 003. This user should only be able to open plant 0001, warehouse nr. 001.
Is there a way in customizing, authorizations, etc. to avoid this?
Thanks for your comments.Hi
THis can be contolled via authorisation to the users. Please check with Basis consultant.
[http://help.sap.com/saphelp_45b/helpdata/en/91/1a39516e36d1118b3f0060b03ca329/content.htm]
Karthik
Edited by: Karthik on Jun 29, 2011 5:59 PM -
CJ20N project builder restriction on plant or company code
HI there
I hope this is in the right formum..
I just cannot seem to get the transaction CJ20n to check on orglevel Plant (WERKS) or Company code (BUKRS).
When displaying or changing a project people should not be able to access projects from differents companies (or plants). When I look at the basic data, organisation fields of the project, there are CO area and Business area, as well as Company code and plant. On one of the last (company code or plant) I want to have an authorisation check wether the user is allowed to display or maintain the project
when I trace the actions, I only find checks on
C_PROJ_KOK (controlling areaa)
C_PROJ_PRC (profit center)
C_PROJ_VNR (project manager)
but they are not company specific here
I activated object C_PPBD Authorization for maintaining planned independent requirements SAP note 635612), but this is not being checked on transacton start or when changing project meta data e.g. description.
Has somebody any ideas/tips on howto get CJ20n to check on WERKS (plant) or BUKRS (company code)? I would be very thankfull
JosJos,
It looks like your question got hijacked, so a shot at your original question regarding CJ20N:
If you want the check upfront and not inside the transaction, then you could add it in transaction SE93. but this will only prevent the user from starting the transaction, not using it.
If the check on F_BKPF_BUK or whatever is not coded anywhere in CJ20N, then adding or removing SU24 indicators will not help. You could try to look for a user exit ("Enhancement transactions CMOD / SMOD)). I would ask this question in the CJ20N forum.
You could open a development request with SAP, but there would most likely need to be a few more customers with the same request or a realy good reason to add it before this materializes.
If all of those fail, you can get yourself an object key for where ever it is that you want an additional check to be coded and change it yourself. After this, CJ20N or the check function will belong to you (not SAP) and anybody with a developer key could also change it using normal developer authorizations.
Good luck,
Julius
Maybe you are looking for
-
I can't get my hp office jet pro 8500 A910 printer to print in color when I want to .
When I want to print a page from the internet in black & white it prints in color. When I want to print an excel file in color, it prints in black & white. This is a new problem. My printer use to work just fine. My operating system is Windows XP.
-
Will a Radeon HD 7950 fit in a p7-1234?
My friend has recently upgraded his GFX and offered to sell me his Radeon HD 7950, it looks like it *might* be too big. It has the necessary PCI-E slot but Im worried that I'll buy it and it won't fit. Thanks for any help!
-
Faxing with a cable phone?
Is it possible to fax from my macbook if i have a cable phone?
-
Modification adjustments during Preprocessing phase in ECC6.0 EHP4 upgrade
Hello All, We are upgrading our SAP systems from R3 4.7 to ECC 6.0 EHP4 and we are currently in the PreProcessing phase. The upgrade screen has prompted the below message *You must now include your repository modifications in the new SAP import. 35 m
-
hi experts, i have a simple problem. i want to display one report. in this report, i want display date. Means, in one column, i want to display difference b/w dates. i took a one local variable. Problem: if dates are same, it doesn't display any thin