‎2010 Jul 22 7:59 PM
Please correct the following syntax:
delete lt_cdpos where (TABNAME NE 'ANLC')
AND (FNAME NOT IN('ANLN1','BUKRS','ANLKL','TXT50','TXA50','SERNR','AKTIV','KOSTL',
'GSBER','PRCTR','INVZU','ANLUE','STORT','ORD41','AIBN1',
'ZZIVNR','ZZLCL','DEAKT','ZZPRT','ZZODNR','XSTIL','AFABE','AFABG',
'NDJAR','NDPER','AFASL','INVNR','IVDAT','HERST','ZZCONTRACT','XLOEV','SCHRW','MENGE','POSNR2')).lt_cdpos is the internal table and i want all the records
where either tabname = ANLC or FNAME = all the values mentioned above.
I was wanting to delte the records where this condition is not satisfied, but it is giving me syntax error. Please rectify.
Please do not offer rewards.
Thanks
Edited by: Rob Burbank on Jul 22, 2010 3:45 PM
‎2010 Jul 23 5:58 AM
Fill the ranges table & use the range table to delete the data:
DATA: it_cdpos TYPE STANDARD TABLE OF cdpos,
r_delete TYPE RANGE OF fieldname,
wa_delete LIKE LINE OF r_delete.
PERFORM f_fill_range USING:
'ANLN1','BUKRS','ANLKL','TXT50','TXA50','SERNR',
'AKTIV','KOSTL','GSBER','PRCTR','INVZU','ANLUE','STORT','ORD41','AIBN1',
'ZZIVNR','ZZLCL','DEAKT','ZZPRT','ZZODNR','XSTIL','AFABE','AFABG',
'NDJAR','NDPER','AFASL','INVNR','IVDAT','HERST','ZZCONTRACT','XLOEV',
'SCHRW','MENGE','POSNR2'.
DELETE it_cdpos WHERE tabname NE 'ANLC' AND fname NOT IN r_delete.
*&---------------------------------------------------------------------*
*& Form F_FILL_RANGE
*&---------------------------------------------------------------------*
FORM f_fill_range USING ip_field TYPE fieldname.
wa_delete-sign = 'I'.
wa_delete-option = 'EQ'.
wa_delete-low = ip_field.
APPEND wa_delete TO r_delete.
CLEAR wa_delete.
ENDFORM. "F_FILL_RANGEBR,
Suhas
‎2010 Jul 22 8:37 PM
NOT IN doesn't work in DELETE statements...use AND FNAME NE 'NNNN' for each value! Looks like we selected WAY too much data from CDPOS...
‎2010 Jul 23 5:32 AM
Hi
Can you please provide the SYNTAX ERROR message you are geting.
Thanks
Lalit Gupta
‎2010 Jul 23 5:51 AM
Hi,
Try your logic like the below code
data : t_rseg TYPE STANDARD TABLE OF rseg.
data w_belnr TYPE belnr_d.
RAnges : r_belnr FOR w_belnr.
delete t_rseg where gjahr NE '2009'
AND belnr NOT IN r_belnr.
‎2010 Jul 23 5:58 AM
Fill the ranges table & use the range table to delete the data:
DATA: it_cdpos TYPE STANDARD TABLE OF cdpos,
r_delete TYPE RANGE OF fieldname,
wa_delete LIKE LINE OF r_delete.
PERFORM f_fill_range USING:
'ANLN1','BUKRS','ANLKL','TXT50','TXA50','SERNR',
'AKTIV','KOSTL','GSBER','PRCTR','INVZU','ANLUE','STORT','ORD41','AIBN1',
'ZZIVNR','ZZLCL','DEAKT','ZZPRT','ZZODNR','XSTIL','AFABE','AFABG',
'NDJAR','NDPER','AFASL','INVNR','IVDAT','HERST','ZZCONTRACT','XLOEV',
'SCHRW','MENGE','POSNR2'.
DELETE it_cdpos WHERE tabname NE 'ANLC' AND fname NOT IN r_delete.
*&---------------------------------------------------------------------*
*& Form F_FILL_RANGE
*&---------------------------------------------------------------------*
FORM f_fill_range USING ip_field TYPE fieldname.
wa_delete-sign = 'I'.
wa_delete-option = 'EQ'.
wa_delete-low = ip_field.
APPEND wa_delete TO r_delete.
CLEAR wa_delete.
ENDFORM. "F_FILL_RANGEBR,
Suhas