Application Development 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: 

Grouping fields

Former Member
0 Kudos
57

Hi,

Why you group fields in modulepool program and how many modification is allowed per field?

Thanks in advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
40

Below is part of another answer I gave in another thread, plus some extra ideas.

Groups just give you a way of handling several fields at once, instead of having to specify one field at a time.

For example, rather than having to code:


loop at screen.
  if screen-name = 'KNA1-KUNNR'
  or screen-name = 'KNA1-NAME1'
  or screen-name = 'KNA1-NAME2'
  or screen-name = 'KNA1-NAME3'
  or screen-name = 'KNA1-NAME4'
  or screen-name = 'KNA1-ORT01'
  or  (etc etc etc) ....
*    do something to field atttibutes
  endif.
endloop.

You could set, say, group1 on all these fields to say "CUS" and code

loop at screen.
  if screen-group1 = 'CUS'.  "customer field
*    do something to field atttibutes
  endif.
endloop.

which is much more elegant.

As for the number of "modifications per field", there are four group fields but the ways you use then are only limited by your imagination e.g. you could use a separate bytes in each group to flag different things e.g.

loop at screen.
  l_flag = screen-group1+0(1).
  case l_flag. 
    when 'A'.   
*    do something to field atttibutes
* etc etc
  endcase.
endloop.

1 REPLY 1

Former Member
0 Kudos
41

Below is part of another answer I gave in another thread, plus some extra ideas.

Groups just give you a way of handling several fields at once, instead of having to specify one field at a time.

For example, rather than having to code:


loop at screen.
  if screen-name = 'KNA1-KUNNR'
  or screen-name = 'KNA1-NAME1'
  or screen-name = 'KNA1-NAME2'
  or screen-name = 'KNA1-NAME3'
  or screen-name = 'KNA1-NAME4'
  or screen-name = 'KNA1-ORT01'
  or  (etc etc etc) ....
*    do something to field atttibutes
  endif.
endloop.

You could set, say, group1 on all these fields to say "CUS" and code

loop at screen.
  if screen-group1 = 'CUS'.  "customer field
*    do something to field atttibutes
  endif.
endloop.

which is much more elegant.

As for the number of "modifications per field", there are four group fields but the ways you use then are only limited by your imagination e.g. you could use a separate bytes in each group to flag different things e.g.

loop at screen.
  l_flag = screen-group1+0(1).
  case l_flag. 
    when 'A'.   
*    do something to field atttibutes
* etc etc
  endcase.
endloop.