2007 Sep 14 2:43 PM
hi my requirement is my code shud be able to check for sales order qty in alternate storage location.for storing this alternate storage location i created a ztable called ZSDSTLOCDET that has field called ZLGORT to maintain alternate location.but what i found out it when i debug the user exit there is no value in that field..can some one help me how to maintain value in that field..
here is the code
TYPES:BEGIN of TY_MARD,
MATNR TYPE MARD-MATNR,
WERKS TYPE MARD-WERKS,
LGORT TYPE MARD-LGORT,
LABST TYPE MARD-LABST,
END of TY_MARD.
DATA: T_MARD TYPE STANDARD table of TY_MARD,
WA_MARD LIKE LINE OF T_MARD.
TABLES: ZSDSTLOCDET.
CONSTANTS: C_SOBKZ LIKE MSKA-SOBKZ VALUE 'E'.
DATA: G_LGORT TYPE MARD-LGORT,
G_KALAB TYPE MSKA-KALAB,
G_LABST TYPE MARD-LABST.
*To get the default storage location
SELECT SINGLE LGORT
FROM TVKOL
INTO G_LGORT
WHERE VSTEL = IF_LAGOF-VSTEL
AND WERKS = IF_LAGOF-WERKS
AND RAUBE = IF_LAGOF-RAUBE.
IF SY-SUBRC EQ 0.
EF_LGORT = G_LGORT.
ENDIF.
*To check if the Plant and the Shipping point combination
*exist in the ZSDSTLOCDET table
SELECT SINGLE *
FROM ZSDSTLOCDET
WHERE WERKS = IF_LAGOF-WERKS
AND VSTEL = IF_LAGOF-VSTEL.
IF SY-SUBRC EQ 0.
*To check if the default Storage Location has
*Customer Order stock
SELECT SINGLE KALAB
FROM MSKA
INTO G_KALAB
WHERE MATNR = IF_LAGOF-MATNR
AND WERKS = IF_LAGOF-WERKS
AND LGORT = G_LGORT
AND CHARG = IF_LAGOF-CHARG
AND SOBKZ = C_SOBKZ
AND VBELN = IF_LAGOF-VGBEL
AND POSNR = IF_LAGOF-VGPOS.
<b>IF G_KALAB IS INITIAL.
*To check if the alternate Storage Location has
*Customer Order stock
SELECT SINGLE KALAB
FROM MSKA
INTO G_KALAB
WHERE MATNR = IF_LAGOF-MATNR
AND WERKS = IF_LAGOF-WERKS
AND LGORT = ZSDSTLOCDET-ZLGORT
AND CHARG = IF_LAGOF-CHARG
AND SOBKZ = C_SOBKZ
AND VBELN = IF_LAGOF-VGBEL
AND POSNR = IF_LAGOF-VGPOS.</b>
IF G_KALAB IS INITIAL.
*To check if the default Storage Location has
*Unrestricted Use stock
SELECT SINGLE LABST
FROM MARD
INTO G_LABST
WHERE MATNR = IF_LAGOF-MATNR
AND WERKS = IF_LAGOF-WERKS
AND LGORT = G_LGORT.
IF G_LABST IS INITIAL.
*To Get all the Storage Locations for the Material / Plant
*combination where Unrestricted use stock is not initial
SELECT MATNR
WERKS
LGORT
LABST
FROM MARD
INTO table T_MARD
WHERE MATNR = IF_LAGOF-MATNR
AND WERKS = IF_LAGOF-WERKS
AND LABST <> 0.
*To get the Storage Location with Max Unrestricted use stock
*as the first record
IF NOT T_MARD[] IS INITIAL.
SORT T_MARD BY LABST DESCENDING.
READ TABLE T_MARD INDEX 1 INTO WA_MARD.
*To pass the Storage Location which has the Max Unrestricted use stock
IF SY-SUBRC EQ 0.
EF_LGORT = WA_MARD-LGORT.
ENDIF. "SY-SUBRC
ENDIF. "NOT T_MARD[] IS INITIAL
ENDIF. "G_LABST IS INITIAL
ELSE.
EF_LGORT = ZSDSTLOCDET-ZLGORT.
ENDIF.
ENDIF. "G_KALAB IS INITIAL
ENDIF. "SY-SUBRC
ENDIF.
can some please help on this..here ZSDSTLOCDET-ZLGORT is not taking any alternate storage location values..
hi my requirement is my code shud be able to check for sales order qty in alternate storage location.for storing this alternate storage location i created a ztable called ZSDSTLOCDET that has field called ZLGORT to maintain alternate location.but what i found out it when i debug the user exit there is no value in that field..can some one help me how to maintain value in that field..
here is the code
TYPES:BEGIN of TY_MARD,
MATNR TYPE MARD-MATNR,
WERKS TYPE MARD-WERKS,
LGORT TYPE MARD-LGORT,
LABST TYPE MARD-LABST,
END of TY_MARD.
DATA: T_MARD TYPE STANDARD table of TY_MARD,
WA_MARD LIKE LINE OF T_MARD.
TABLES: ZSDSTLOCDET.
CONSTANTS: C_SOBKZ LIKE MSKA-SOBKZ VALUE 'E'.
DATA: G_LGORT TYPE MARD-LGORT,
G_KALAB TYPE MSKA-KALAB,
G_LABST TYPE MARD-LABST.
*To get the default storage location
SELECT SINGLE LGORT
FROM TVKOL
INTO G_LGORT
WHERE VSTEL = IF_LAGOF-VSTEL
AND WERKS = IF_LAGOF-WERKS
AND RAUBE = IF_LAGOF-RAUBE.
IF SY-SUBRC EQ 0.
EF_LGORT = G_LGORT.
ENDIF.
*To check if the Plant and the Shipping point combination
*exist in the ZSDSTLOCDET table
SELECT SINGLE *
FROM ZSDSTLOCDET
WHERE WERKS = IF_LAGOF-WERKS
AND VSTEL = IF_LAGOF-VSTEL.
IF SY-SUBRC EQ 0.
*To check if the default Storage Location has
*Customer Order stock
SELECT SINGLE KALAB
FROM MSKA
INTO G_KALAB
WHERE MATNR = IF_LAGOF-MATNR
AND WERKS = IF_LAGOF-WERKS
AND LGORT = G_LGORT
AND CHARG = IF_LAGOF-CHARG
AND SOBKZ = C_SOBKZ
AND VBELN = IF_LAGOF-VGBEL
AND POSNR = IF_LAGOF-VGPOS.
<b>IF G_KALAB IS INITIAL.
*To check if the alternate Storage Location has
*Customer Order stock
SELECT SINGLE KALAB
FROM MSKA
INTO G_KALAB
WHERE MATNR = IF_LAGOF-MATNR
AND WERKS = IF_LAGOF-WERKS
AND LGORT = ZSDSTLOCDET-ZLGORT
AND CHARG = IF_LAGOF-CHARG
AND SOBKZ = C_SOBKZ
AND VBELN = IF_LAGOF-VGBEL
AND POSNR = IF_LAGOF-VGPOS.</b>
IF G_KALAB IS INITIAL.
*To check if the default Storage Location has
*Unrestricted Use stock
SELECT SINGLE LABST
FROM MARD
INTO G_LABST
WHERE MATNR = IF_LAGOF-MATNR
AND WERKS = IF_LAGOF-WERKS
AND LGORT = G_LGORT.
IF G_LABST IS INITIAL.
*To Get all the Storage Locations for the Material / Plant
*combination where Unrestricted use stock is not initial
SELECT MATNR
WERKS
LGORT
LABST
FROM MARD
INTO table T_MARD
WHERE MATNR = IF_LAGOF-MATNR
AND WERKS = IF_LAGOF-WERKS
AND LABST <> 0.
*To get the Storage Location with Max Unrestricted use stock
*as the first record
IF NOT T_MARD[] IS INITIAL.
SORT T_MARD BY LABST DESCENDING.
READ TABLE T_MARD INDEX 1 INTO WA_MARD.
*To pass the Storage Location which has the Max Unrestricted use stock
IF SY-SUBRC EQ 0.
EF_LGORT = WA_MARD-LGORT.
ENDIF. "SY-SUBRC
ENDIF. "NOT T_MARD[] IS INITIAL
ENDIF. "G_LABST IS INITIAL
ELSE.
EF_LGORT = ZSDSTLOCDET-ZLGORT.
ENDIF.
ENDIF. "G_KALAB IS INITIAL
ENDIF. "SY-SUBRC
ENDIF.
can some please help on this..here ZSDSTLOCDET-ZLGORT is not taking any alternate storage location values..
2007 Sep 14 2:48 PM
Does the following SQL bring a record back.
SELECT SINGLE *
FROM ZSDSTLOCDET
WHERE WERKS = IF_LAGOF-WERKS
AND VSTEL = IF_LAGOF-VSTEL.
Is ZLGORT populated on the table.
2007 Sep 14 2:51 PM
hi martin..the problem the field ZLGORT is not being populated with data..i think i made a mistake in the code and not able to get an idea as to how i need to populate that field..actually values of alternate storage locations are
SHUN and SHIP..these are 2 fields that need to come in ZLGORT.
2007 Sep 14 2:54 PM
I would of assumed that ZLGORG would of come from the read of the table ZSDSTLOCDET. If not, then I do not understand where you are to get ZLGORT from.