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

SAP Query (can´t delete specific fields)

Former Member
0 Likes
1,353

Hi all

I´m creating a query using COVP table agains a Z table we have.-

What I need is delete records from the COVP when the partner company code is equal to the company code and when the partner company code is blank

For thisI´ve been trying to do this in the "Records processing" section of the query.

//

Delete itab where itab-BUKRS eq itab-PBUKRS and itab-BUKRS eq blank.

//

But I get the error message:

Unable to interpret "WHERE". Possible causes of error: Incorrect spelling or comma error. "

In other topic mr. PPIO recomend me to use other option for the Delete function, but as I don´t know to much for coding I´m comming here

Is there something you can recomend me to make this work?

COVP is the table and inside you might find the below fields

COVP-BUKRS (partner ccd)

COVP-PBUKRS (company code)

What I need is to delete records BUKRS = PBUKRS and if BUKRS is in blank

Regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,266

Found the solution

In the record processing I add a sentence

CHECK COVP-PBUKRS <> COVP-BUKRS.

CHECK COVP-PBUKRS <> ' '.

And that was it.

Thanks all that tried to help

Regards

10 REPLIES 10
Read only

Former Member
0 Likes
1,266

Hi Yutoks,

Your WHERE condition is wrong i think.

According to your condition it will delete only when  itab-BUKRS eq itab-PBUKRS eq blank.

I guess that you have to use an OR condition instead of AND.

Try.

DELETE itab WHERE itab-BUKRS eq itab-PBUKRS OR itab-BUKRS eq ' '.

Regards,

Akhil

Read only

satvik_panchal
Participant
0 Likes
1,266

Hello,

write the code as:

DELETE itab WHERE BUKRS eq itab-PBUKRS OR BUKRS eq ' '.

Read only

Former Member
0 Likes
1,266

I must be doing something wrong because even though I tried both I still get the error.

Global syntax check

- Get/GET late code / code for record processing

- Error in code for record processing

- Unable to interpret "WHERE". Possible causes: Incorrect spelling or comma error

Any ideas?

Read only

former_member217916
Participant
0 Likes
1,266

Hi,

I just tried the above scenario. I put some data into the bukrs and pbukrs fields of the internal table itab.

The following removes all the records satisfying the above given condition.

LOOP at itab into itab_line.

       DELETE itab where
                       bukrs = itab_line-bukrs
                       AND pbukrs = itab_line-bukrs
                       OR pbukrs = ' '.
ENDLOOP.

Read only

0 Likes
1,266

Where should I paste that? in the Record Processing section?  because I get

"Field "ITAB" is unknown. It is neither in one of the specified tablesn or defined by a "DATA" statement."

Read only

Former Member
0 Likes
1,266

Hello,

Try these staements, they should help you -

DELETE ADJACENT DUPLICATES FROM  itab comparing BUKRS PBUKRS.

DELETE itab where BUKRS eq ' '.

best regards,

swanand

Read only

0 Likes
1,266

hello

For your case it should be

DELETE itab where BUKRS eq ' ' and PBUKRS = ' '. Since you want BUKRS and PBUKRS same and also BUKRS eq ' '.

best regards,

swanand

Read only

0 Likes
1,266

I try both, same issue.- It´s looks like the internal table don´t exist or something I mean I thought all querys have an itab

I´m wrong?

Regards

Read only

Former Member
0 Likes
1,266

Hi Yutoks,

Try the code below

DATA:it_covp TYPE STANDARD TABLE OF covp,
     wa_covp TYPE covp.

SELECT * FROM covp INTO TABLE it_covp.

LOOP AT it_covp INTO wa_covp.

  IF wa_covp-bukrs <> wa_covp-pbukrs.

    DELETE TABLE it_covp FROM wa_covp.
  ENDIF.
ENDLOOP.

LOOP AT it_covp INTO wa_covp.
  IF wa_covp-bukrs <> ' '.

    DELETE TABLE it_covp FROM wa_covp.

  ENDIF.

ENDLOOP.

DELETE covp FROM TABLE it_covp.

This will do your requirement, but i think there may be much better methods.

Regards,

Akhil

Read only

Former Member
0 Likes
1,267

Found the solution

In the record processing I add a sentence

CHECK COVP-PBUKRS <> COVP-BUKRS.

CHECK COVP-PBUKRS <> ' '.

And that was it.

Thanks all that tried to help

Regards