Skip to Content
0
Former Member
Jan 26, 2011 at 03:44 PM

ABAP syntax for field check

446 Views

Hi,

Can anyone advise if there is a way to check if a list of fields has value in it? I can write the if/then statement to check but I want to see whether there are other options.

Data: field_1 type menge_d,

field_2 type menge_d,

field_3 type menge_d,

field_4 type menge_d,

field_5 type menge_d,

field_6 type menge_d,

In ABAP code, these fields will get assigned a quantity. How can I check if to see if at least 4 of these six fieldts has data assigned to it. It can be in any combination but at least 4 fields should have data.

Currently, I have this code but want to see if there are other intelligent ways of doing it than these redundant IFs statements.

If field_1 > 0.

count = count + 1.

endif.

If field_2 > 0.

count = count + 1.

endif.

If field_3 > 0.

count = count + 1.

endif.

If field_4 > 0.

count = count + 1.

endif.

If field_5 > 0.

count = count + 1.

endif.

If field_6 > 0.

count = count + 1.

endif.

after this, I check if count > = 4

Thanks.