Skip to Content
0
Former Member
Sep 14, 2007 at 01:43 PM

can someone help me on this code

53 Views

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..