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

delete row if field is initial.

Former Member
0 Likes
3,421

Hello,

What I want to do is to delete the whole row if a specific field is empty. If it helps this is an ALV_GRID report

I have seen that there are a couple of topics about this but I haven't been able to solv it. My attempts are in bold.

wa_rec-sek_norm_sal = wa_rec-norm_sal - wa_rec-bet01.

<b>if wa_rec-sek_norm_sal is initial.

delete wa_rec.</b>

endif.

append wa_rec to lt_rec.

<b>loop at lt_rec.

if lt_rec-sek_norm_sal is initial.

delete lt_rec.

endif.

endloop.</b>

Error from <b>first</b> attempt:

"WA_REC" is not an internal table - the "OCCURS n" specification is missing"

Error from <b>second</b> attempt:

The internal table "LT_REC" has no Header line - explicit specification of an output area with "INTO wa" or "ASSIGNING <fs>" is required.

Thank you all.

Best Regards Claes

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,947

Hi claes,

1. how is your internal table defined ?

wa_rec

(is it work area or internal table ?

if internal table, then

it should be declared someting like this :

dat a: wa_rec like table of

T001 <b>WITH HEADER LINE.</b>

2. same is the case with 2.

lt_rec-sek_norm_sal

(it does not have header line)

regards,

amit m.

Hello,

What I want to do is to delete the whole row if a specific field is empty. If it helps this is an ALV_GRID report

I have seen that there are a couple of topics about this but I haven't been able to solv it. My attempts are in bold.

wa_rec-sek_norm_sal = wa_rec-norm_sal - wa_rec-bet01.

<b>if wa_rec-sek_norm_sal is initial.

delete wa_rec.</b>

endif.

append wa_rec to lt_rec.

<b>loop at lt_rec.

if lt_rec-sek_norm_sal is initial.

delete lt_rec.

endif.

endloop.</b>

Error from <b>first</b> attempt:

"WA_REC" is not an internal table - the "OCCURS n" specification is missing"

Error from <b>second</b> attempt:

The internal table "LT_REC" has no Header line - explicit specification of an output area with "INTO wa" or "ASSIGNING <fs>" is required.

Thank you all.

Best Regards Claes

5 REPLIES 5
Read only

Former Member
0 Likes
1,948

Hi claes,

1. how is your internal table defined ?

wa_rec

(is it work area or internal table ?

if internal table, then

it should be declared someting like this :

dat a: wa_rec like table of

T001 <b>WITH HEADER LINE.</b>

2. same is the case with 2.

lt_rec-sek_norm_sal

(it does not have header line)

regards,

amit m.

Read only

0 Likes
1,947

Problem solved, Thank you for all the help!

Best Regards

Claes

Read only

Former Member
0 Likes
1,947

create it_rec with header line.

let me know if u need any assistance.

Raja.

Read only

Former Member
1,947

1. The first part of the code must be running in a loop.. right??

If I am not wrong, your code looks like this:

loop at it_rec into wa_rec.

.....

wa_rec-sek_norm_sal = wa_rec-norm_sal - wa_rec-bet01.

if wa_rec-sek_norm_sal is initial.

*delete wa_rec.

DELETE <IT_REC> index sy-tabix.

endif.

endloop.

2.

Create a workarea for lt_rec.

For ex:

data: wa_rec like lt_rec.

data: v_tabix like sy-tabix.

loop at lt_rec into wa_rec.

v_tabix = sy-tabix.

if wa_rec-sek_norm_sal is initial.

delete lt_rec index v_tabix.

endif.

endloop.

Hope this helps

Read only

Former Member
0 Likes
1,947

hi,

data: x_rec like line of lt_rec.

loop at lt_rec into x_rec. 
if x_rec-sek_norm_sal is initial.
delete lt_rec index sy-tabix.
endif.
endloop.

this will solve .

Regards

Vijay