Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Syntax error

Former Member
0 Likes
679

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

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
634

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_RANGE

BR,

Suhas

4 REPLIES 4
Read only

Former Member
0 Likes
634

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

Read only

Former Member
0 Likes
634

Hi

Can you please provide the SYNTAX ERROR message you are geting.

Thanks

Lalit Gupta

Read only

Former Member
0 Likes
634

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.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
635

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_RANGE

BR,

Suhas