‎2007 Aug 08 9:45 PM
Hi All,
i have used this statement
delete zwplcrppd from table t_zwplcrpd
here primary key is Matnr.
t_zwplcrpd has contain 2 records only but this deleted all records from the data base table . Is there any thing wrong with this staement ? Please let me know.
Message was edited by:
null
‎2007 Aug 08 9:57 PM
Hi,
Your code looks fine ...
How do you declare internal t_zwplcrpd and populate it with two records?
Can you paste the whole codes?
Regards,
Ferry Lianto
‎2007 Aug 08 9:58 PM
Here is my whole code.
DATA: t_zwplcrppd TYPE STANDARD TABLE OF zwplcrppd WITH HEADER LINE.
DATA: l_zwplcrppd TYPE zwplcrppd.
DATA: t_zwplcrpd TYPE zwplcrppd OCCURS 0 WITH HEADER LINE.
DATA: t_return TYPE STANDARD TABLE OF bapiret2 WITH HEADER LINE.
DATA: l_return TYPE bapiret2.
TYPES: BEGIN OF rptline,
zwevtb TYPE zwplcsctbud-zwevtb,
matnr TYPE mara-matnr,
zwgehrrg TYPE zwplcsmev-zwgehrrg,
zwgehrct TYPE zwplcsmev-zwgehrct,
zwgbev TYPE zwplcgbev-zwgbev,
zwsbev TYPE zwplcsbev-zwsbev,
zwpldt TYPE zwplcgbev-zwpldt,
zwenfl TYPE zwplcgbev-zwenfl,
message TYPE bapiret2-message,
END OF rptline.
DATA: t_rptline TYPE STANDARD TABLE OF rptline WITH HEADER LINE,
t_glob like zwplcgbev occurs 0 with header line,
t_smev like zwplcsmev occurs 0 with header line.
TYPES: BEGIN OF fieldnames,
text(60) TYPE c,
tabname(10) TYPE c,
fieldname(10) TYPE c,
typ(1) TYPE c,
END OF fieldnames.
DATA: t_fieldnames TYPE STANDARD TABLE OF fieldnames WITH HEADER LINE.
DATA: myreport LIKE sy-repid,
w_matnr type matnr,
w_zwishp type zwishp,
head_line1(80) TYPE c,
head_line2(80) TYPE c,
head_line3(80) TYPE c,
head_line4(80) TYPE c,
w_date TYPE sy-datum,
work_v3 TYPE bapiret2-message_v3,
scrn(2) TYPE c,
return_code LIKE sy-subrc.
************************************************************************
S E L E C T I O N S C R E E N L A Y O U T S
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP 1.
PARAMETERS: p_matnr TYPE matnr OBLIGATORY.
PARAMETERS: p_rppdno TYPE zwrppdno .
PARAMETERS: p_reg TYPE zwgehrrg OBLIGATORY.
PARAMETERS: p_ctry TYPE zwgehrct OBLIGATORY.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(28) text-003.
SELECTION-SCREEN POSITION 33.
PARAMETERS: p_pfrpfl AS CHECKBOX.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(28) text-004.
SELECTION-SCREEN POSITION 33.
PARAMETERS: p_norpfl AS CHECKBOX.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(28) text-002.
SELECTION-SCREEN POSITION 33.
PARAMETERS: p_enfl AS CHECKBOX.
SELECTION-SCREEN END OF LINE.
PARAMETERS: p_stdt TYPE zwstdt.
PARAMETERS: p_eddt TYPE zweddt.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(28) text-005.
SELECTION-SCREEN POSITION 33.
PARAMETERS: p_xloek AS CHECKBOX.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK a1.
************************************************************************
I N I T I A L I Z A T I O N E V E N T
************************************************************************
INITIALIZATION.
************************************************************************
A T S E L E C T I O N E V E N T
************************************************************************
AT SELECTION-SCREEN. "V001
IF p_norpfl = 'X' AND p_rppdno NE SPACE. "V001
MESSAGE e208(00) WITH 'No Repl.Flag Active, Remove Repl.Product No'. "V001
ELSEIF p_norpfl = ' ' AND p_rppdno EQ SPACE. "V001
MESSAGE e208(00) WITH 'Maintain Replacement Product Number'. "V001
ENDIF. "V001
IF p_norpfl = 'X' AND p_pfrpfl = 'X'. "V001
MESSAGE e208(00) WITH 'Either Prefered Repl.or No Repl.flag can be active '. "V001
ENDIF. "V001
************************************************************************
S T A R T - O F - S E L E C T I O N E V E N T
************************************************************************
START-OF-SELECTION.
Validate input.
Validate material no.
select single matnr into w_matnr
from mara
where matnr = p_matnr.
if sy-subrc ne 0.
MESSAGE i073(zplc) WITH p_matnr.
stop.
endif.
Validate replacement product no.
IF p_rppdno ne space.
select single matnr into w_matnr
from mara
where matnr = p_rppdno.
if sy-subrc ne 0.
MESSAGE i074(zplc) WITH p_rppdno.
stop.
endif.
ENDIF.
Validate region and country.
if p_reg = 'WW'.
p_reg = 'ALL'.
endif.
if p_reg ne 'ALL' or
p_ctry ne 'ALL'.
if p_reg ne 'ALL'.
if p_reg+2(1) ne 'R' and
p_reg+2(1) ne 'S'.
MESSAGE i077(zplc).
stop.
endif.
select single zwishp into w_zwishp
from zwwwgehrdf
where zwishp = p_reg(2)
and zwiscdctcg = p_reg+2(2).
if sy-subrc ne 0.
MESSAGE i077(zplc).
stop.
endif.
endif.
if p_ctry ne 'ALL'.
if p_ctry+2(2) ne space.
MESSAGE i078(zplc).
stop.
endif.
select single zwishp into w_zwishp
from zwwwgehrdf
where zwishp = p_ctry(2)
and zwiscdctcg = 'IC'.
if sy-subrc ne 0.
MESSAGE i078(zplc).
stop.
endif.
endif.
endif.
Validate start and end date.
if p_stdt is not initial or
p_eddt is not initial.
if p_stdt is initial and
p_eddt is not initial.
MESSAGE i075(zplc).
stop.
endif.
if p_eddt is not initial.
if p_eddt < p_stdt.
MESSAGE i076(zplc).
stop.
endif.
endif.
endif.
if p_stdt >= '21000101' or
p_eddt >= '21000101'.
MESSAGE i079(zplc).
stop.
endif.
CLEAR l_zwplcrppd.
if p_reg = 'ALL' AND p_ctry = 'ALL'.
select single * from zwplcgbev into t_glob where matnr = p_matnr.
if sy-subrc <> 0 .
MESSAGE I080(zplc) .
stop.
ENDIF.
ELSEIF p_reg <> 'ALL' OR p_ctry <> 'ALL'.
select single * from zwplcsmev into t_smev where matnr = p_matnr and
zwgehrrg = p_reg and
zwgehrct = p_ctry .
if sy-subrc <> 0 .
MESSAGE I081(zplc) .
stop.
ENDIF.
endif.
SELECT SINGLE *
INTO CORRESPONDING FIELDS OF l_zwplcrppd
FROM zwplcrppd
WHERE matnr = p_matnr
AND zwrppdno = p_rppdno
AND zwgehrrg = p_reg
AND zwgehrct = p_ctry.
IF sy-subrc = 0.
l_zwplcrppd-zwpfrpfl = p_pfrpfl.
l_zwplcrppd-zwnorpfl = p_norpfl.
l_zwplcrppd-zwenfl = p_enfl.
l_zwplcrppd-zwstdt = p_stdt.
l_zwplcrppd-zweddt = p_eddt.
l_zwplcrppd-xloek = p_xloek.
ELSE.
l_zwplcrppd-matnr = p_matnr.
l_zwplcrppd-zwrppdno = p_rppdno.
l_zwplcrppd-zwgehrrg = p_reg.
l_zwplcrppd-zwgehrct = p_ctry .
l_zwplcrppd-zwpfrpfl = p_pfrpfl.
l_zwplcrppd-zwnorpfl = p_norpfl.
l_zwplcrppd-zwenfl = p_enfl.
l_zwplcrppd-zwstdt = p_stdt.
l_zwplcrppd-zweddt = p_eddt.
l_zwplcrppd-xloek = p_xloek.
l_zwplcrppd-zwcrdt = sy-datum.
l_zwplcrppd-zwcrtm = sy-uzeit.
l_zwplcrppd-zwcrus = sy-uname.
ENDIF.
CLEAR t_zwplcrppd[].
if p_norpfl = 'X'.
select * from zwplcrppd into table t_zwplcrpd where matnr = p_matnr "V001
AND zwgehrrg = p_reg "V001
AND zwgehrct = p_ctry. "V001
ENDIF.
append l_zwplcrppd to t_zwplcrppd.
CALL FUNCTION 'Z_WPLC_DATA_UPDATE'
EXPORTING
userid = sy-uname
TABLES
t_zwplcrppd = t_zwplcrppd
return = t_return
EXCEPTIONS
ABORT_CONDITION = 1
OTHERS = 2.
if sy-subrc ne 0.
write: /01 'Abort condition encountered ***** '.
rollback work.
write: /01 'Messages returned from event table updates.'.
skip.
loop at t_return.
write: /01 'Msg Type =', t_return-type,
'Msg ID =', t_return-id,
'Msg No =', t_return-number.
write: /01 'Msg text =', t_return-message.
write: /01 'Msg V1 =', t_return-message_v1.
write: /01 'Msg V2 =', t_return-message_v2.
write: /01 'Msg V3 =', t_return-message_v3.
write: /01 'Msg V4 =', t_return-message_v4.
skip.
endloop.
message I048(zplc) with sy-cprog.
stop.
"V001
endif.
READ TABLE t_return with key type = 'E'.
IF sy-subrc <> 0.
delete zwplcrppd from table t_zwplcrpd .
endif.
LOOP AT t_return.
CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
EXPORTING
TITEL = 'Update Messages'
TEXTLINE1 = t_return-message+000(100)
TEXTLINE2 = t_return-message+100(100)
START_COLUMN = 25
START_ROW = 6.
ENDLOOP.
STOP.
‎2007 Aug 08 10:02 PM
Hi,
Can you check whether t_zwplcrppd is empty or initial?
In the mean let me check your program.
Regards,
Ferry Lianto
‎2007 Aug 08 10:03 PM
I've never used this option because it seems dangerous. But from my reading of the documentation, it's only looking at the primary key. So if the databse table only contains material numbers that are in the two internal table records than everything should be deleted.
But like I said, I've not used this before. It would be better if you posted your code and give us an idea of what the tables look like.
Rob