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

Empty versus complete records

Former Member
0 Likes
752

Hello experts,

Let’s sat tableA with following records :

Field 1

Field 2

Field 3

Field 4

XXX

XXX

XXX

XXX

XXX

XXX

XXX

XXX

XXX

XXX

XXX

XXX

XXX

XXX

XXX

XXX

I am looking for the more performant logic to delete records where all the columns are complete.

In my example, only green lines have to be kept. The red lines must be delete.

I tought about:

Loop at table into structure

     Where field1 is not initial

     And Where field2 is not initial

     And Where field3 is not initial

     And Where field4 is not initial

Delete structure

Endloop.


Thanks for your suggestions.

Amine

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
726

Hi Amine

When a "performance" question is asked in this forum, it often receives many answers, from many different people, with many different opinions offered... but you should test them yourself to make sure you find the best for your specific situation.

Here's my opinion...

If I was you, I'd use the following:

DELETE tablea

  WHERE field1 IS NOT INITIAL

    AND field2 IS NOT INITIAL

    AND field3 IS NOT INITIAL

    AND field4 IS NOT INITIAL.

Regards

Glen

Hello experts,

Let’s sat tableA with following records :

Field 1

Field 2

Field 3

Field 4

XXX

XXX

XXX

XXX

XXX

XXX

XXX

XXX

XXX

XXX

XXX

XXX

XXX

XXX

XXX

XXX

I am looking for the more performant logic to delete records where all the columns are complete.

In my example, only green lines have to be kept. The red lines must be delete.

I tought about:

Loop at table into structure

     Where field1 is not initial

     And Where field2 is not initial

     And Where field3 is not initial

     And Where field4 is not initial

Delete structure

Endloop.


Thanks for your suggestions.

Amine

4 REPLIES 4
Read only

Former Member
0 Likes
727

Hi Amine

When a "performance" question is asked in this forum, it often receives many answers, from many different people, with many different opinions offered... but you should test them yourself to make sure you find the best for your specific situation.

Here's my opinion...

If I was you, I'd use the following:

DELETE tablea

  WHERE field1 IS NOT INITIAL

    AND field2 IS NOT INITIAL

    AND field3 IS NOT INITIAL

    AND field4 IS NOT INITIAL.

Regards

Glen

Read only

Former Member
0 Likes
726

Hi Amine,

DELETE itab WHERE field1 is not initial

              AND field2 is not initial

              AND field3 is not initial

              AND field4 is not initial.


Read only

Former Member
0 Likes
726

Hi Amine,

Another perspective,

Loop at table into structure.

if structure-field1 is not initial

and structure-field2 is not initial

and structure-field3 is not initial 

and structure-field4 is not initial  .

append structure to another table.


endif.

    

Endloop.

Here you need not delete anything. Just simple If condition and you get another internal table with your data.

BR,

Ankit.

Read only

Former Member
0 Likes
726

Thanks guys.

Amine