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

Finding the NOT null value fields in Work Area

Former Member
0 Likes
1,220

Hi,

I am selecting the data from COSP table. When processing the data I have to go thourgh the fields from WTG001 to WKF016 (which are 64 fields) and add up all the values into a variable. I was wondering if there is a way to find out the fields which are NOT NULL and directly sum up the values into variable.

Currently the code is:

data: gt_cosp TYPE STANDARD TABLE OF cosp,
         wa_cosp LIKE LINE OF gt_cosp.

   select * 
         into table gt_cosp 
         from cosp
     where objnr = lv_objnr.

   loop at gt_cosp into wa_cosp.
     lv_value = wa_cosp-WTG001 + wa_cosp-WTG002 + .....wa_cosp-WKF016
      ..........
      ..........
   endloop.

What I am trying to do is, if there are only 3 fields with values, let's say WTG004, WTG006, WTG009. Then I want to sum up only these 3 fields into lv_value. Is there anything that can be used to find this out dynamically. I was thinking of using Field Symbols. Nut sure how I can do that though.

Please let me know. Appreciate your help. Thanks.

Edited by: sey ni on Aug 31, 2011 3:16 PM

1 ACCEPTED SOLUTION
4 REPLIES 4
Read only

Former Member
0 Likes
1,153

Don't know why this is a problem.... those fields are all curr, so will all have zero or non-zero value....a simple addition will get your the results.... you could do the hard way....

if wa_cosp-WTG001 ne 0.

lv_value = lv_value + wa_cost_WTG001.

endif.

if wa_costp-wtg002 ne 0.

lv_value = lv_value + wa-cosp-wtg002.

endif.

etc.

Read only

0 Likes
1,153

I know it is a little bit of programming and writing a line of code with all these 64 fields in it. But was just wondering if there is a better way of doing this which I am not aware of. Thanks for the responses though.

Read only

Former Member
0 Likes
1,153

no better way found.