2007 Dec 11 7:15 AM
We have a SD add-on program to change the material number from outside company into inside company number.
The problem in this program as following:
In the material master, the materials flagged for deletion are used, therefore the disuse plant code is showed.
Here is the original program coding. How can I make the coding to not to select material master which has deletion flag?
Please help. Thank you.
-
FORM DATA_COLLECT.
*
CLEAR ITAB_LIST.
REFRESH ITAB_LIST.
*
CLEAR:WA_MATNR,WA_KUNNR,WA_KUNWE.
SELECT VKORG KUNAG KUNWE VTWEG YYKDMAT KNUMH YYSUBMI
FROM KOTD704
INTO (ITAB_LIST-VKORG,ITAB_LIST-KUNNR,ITAB_LIST-KUNWE,ITAB_LIST-VTWEG,
ITAB_LIST-CUSMAT,ITAB_LIST-COND,ITAB_LIST-YYSUBMI)
WHERE KSCHL = 'Y001'
AND VKORG IN S_VKORG
AND VTWEG IN S_VTWEG
AND KUNAG IN S_KUNNR
AND KUNWE IN S_KUNWE
AND YYKDMAT IN S_CUSMAT
AND DATBI >= SY-DATUM.
SELECT SMATN INTO WA_MATNR
FROM KONDD
WHERE KNUMH = ITAB_LIST-COND.
*
IF S_MATNR <> ''.
CHECK WA_MATNR IN S_MATNR.
ITAB_LIST-MATNR = WA_MATNR.
*
SELECT MAKTX INTO ITAB_LIST-MAKTX
FROM MAKT
WHERE MATNR = WA_MATNR
AND SPRAS = SY-LANGU.
ENDSELECT.
APPEND ITAB_LIST.
ELSE.
ITAB_LIST-MATNR = WA_MATNR.
*
SELECT MAKTX INTO ITAB_LIST-MAKTX
FROM MAKT
WHERE MATNR = WA_MATNR
AND SPRAS = SY-LANGU.
ENDSELECT.
APPEND ITAB_LIST.
ENDIF.
ENDSELECT.
*
CLEAR WA_MATNR.
*
ENDSELECT.
*ENDLOOP.
*
*2005/1/12 UPD S
*IF ITAB_LIST-KUNNR = SPACE.
IF ITAB_LIST-MATNR = SPACE.
*2005/1/12 UPD E
MESSAGE ID 'MG' TYPE 'I' NUMBER '899'
WITH '該当データなし'.
ELSE.
LOOP AT ITAB_LIST.
*
CLEAR:WA_CHOTATSU,WA_PLNNR,WA_PLNAL,WA_ARBID,
WA_ARBPL,WA_LIFNR_2,WA_LIFNR.
*
SELECT WERKS BESKZ INTO (ITAB_LIST-WERKS,WA_CHOTATSU)
FROM MARC
WHERE MATNR = ITAB_LIST-MATNR.
*
IF WA_CHOTATSU = 'E' OR
WA_CHOTATSU = 'X'.
SELECT PLNNR PLNAL FROM MAPL
INTO (WA_PLNNR, WA_PLNAL)
WHERE MATNR = ITAB_LIST-MATNR
AND PLNTY = 'N'.
SELECT COUNT(*) FROM PLKO
WHERE PLNNR = WA_PLNNR
AND PLNAL = WA_PLNAL
AND STATU = '4'.
CHECK SY-SUBRC = 0.
SELECT ARBID FROM PLPO
INTO WA_ARBID
WHERE PLNTY = 'N'
AND PLNNR = WA_PLNNR
AND STEUS = 'ZPP1'.
ENDSELECT.
IF WA_ARBID <> SPACE.
SELECT ARBPL FROM CRHD
INTO WA_ARBPL
WHERE OBJID = WA_ARBID.
ENDSELECT.
ENDIF.
ENDSELECT.
ITAB_LIST-ARBPL = WA_ARBPL.
ELSE.
SELECT LIFNR FROM EORD UP TO 1 ROWS
INTO WA_LIFNR
WHERE MATNR = ITAB_LIST-MATNR
AND WERKS = ITAB_LIST-WERKS
AND VDATU <= SY-DATUM
AND BDATU >= SY-DATUM.
ENDSELECT.
*
IF SY-SUBRC <> 0.
ITAB_LIST-ARBPL = SPACE.
ELSE.
WA_LIFNR_2 = WA_LIFNR.
ITAB_LIST-ARBPL = WA_LIFNR_2.
ENDIF.
*
ENDIF.
ENDSELECT.
ENDFORM. "DATA_COLLECT
2007 Dec 11 8:21 AM
Hi,
Use where condition while fetching data from MARC table as
SELECT WERKS BESKZ INTO (ITAB_LIST-WERKS,WA_CHOTATSU)
FROM MARC
WHERE MATNR = ITAB_LIST-MATNR
and LVORM = ' ' . "Flag Material for Deletion at Plant Level
Or you can use followinf restiction also.
SELECT PLNNR PLNAL FROM MAPL
INTO (WA_PLNNR, WA_PLNAL)
WHERE MATNR = ITAB_LIST-MATNR
AND PLNTY = 'N'
AND LOEKZ = ' ' .
Or you can use following restiction also.
SELECT COUNT(*) FROM PLKO
WHERE PLNNR = WA_PLNNR
AND PLNAL = WA_PLNAL
AND STATU = '4'
AND LOEKZ = ' ' .
Or you can use following restiction also.
SELECT ARBID FROM PLPO
INTO WA_ARBID
WHERE PLNTY = 'N'
AND PLNNR = WA_PLNNR
AND STEUS = 'ZPP1'
AND LOEKZ = ' '.
Better to restict at MARC level.
Reward if its useful.
Thanks
Sivaparvathi
null
2007 Dec 11 7:41 AM
field LVORM on table MARA is the flagged for deletion flag.
Select from MARA and if value 'X' ignore.
2007 Dec 11 8:21 AM
Hi,
Use where condition while fetching data from MARC table as
SELECT WERKS BESKZ INTO (ITAB_LIST-WERKS,WA_CHOTATSU)
FROM MARC
WHERE MATNR = ITAB_LIST-MATNR
and LVORM = ' ' . "Flag Material for Deletion at Plant Level
Or you can use followinf restiction also.
SELECT PLNNR PLNAL FROM MAPL
INTO (WA_PLNNR, WA_PLNAL)
WHERE MATNR = ITAB_LIST-MATNR
AND PLNTY = 'N'
AND LOEKZ = ' ' .
Or you can use following restiction also.
SELECT COUNT(*) FROM PLKO
WHERE PLNNR = WA_PLNNR
AND PLNAL = WA_PLNAL
AND STATU = '4'
AND LOEKZ = ' ' .
Or you can use following restiction also.
SELECT ARBID FROM PLPO
INTO WA_ARBID
WHERE PLNTY = 'N'
AND PLNNR = WA_PLNNR
AND STEUS = 'ZPP1'
AND LOEKZ = ' '.
Better to restict at MARC level.
Reward if its useful.
Thanks
Sivaparvathi
null