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: 

cost center group select option

Former Member
0 Kudos

here is my code:

declaration of select option.

SELECT-OPTIONS s_khinr FOR csks_itab_group-khinr no intervals.

at selection-screen on value-request for s_khinr-low.

at selection-screen on value-request for s_khinr-high.

************************************************************************

  • Initialization

************************************************************************

initialization.

perform build_group_option.

delete adjacent duplicates from csks_itab_group comparing all fields.

at initialization fir build my internal table called csks_itab_group, which gets the names for the coster center groups then I delect any duplicates.

still does work, any ideas.

thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Please specify the code for BUILD_GROUP_OPTION.

5 REPLIES 5

Former Member
0 Kudos

Please specify the code for BUILD_GROUP_OPTION.

0 Kudos

form build_group_option.

select khinr from csks into csks_itab_group where kokrs eq 'NSCO'.

endselect.

endform.

0 Kudos

This works.......



REPORT ZRICH_0001 .

tables: csks.

data: begin of itab occurs 0,
      khinr type csks-khinr,
      end of itab.

SELECT-OPTIONS s_khinr FOR csks-khinr no intervals.

initialization.

perform build_group_option.
sort itab ascending by khinr.
delete adjacent duplicates from itab comparing all fields.

at selection-screen on value-request for s_khinr-low.

  call function 'F4IF_INT_TABLE_VALUE_REQUEST'
       exporting
            retfield    = 'KHINR'
            dynprofield = 'S_KHINR'
            dynpprog    = sy-cprog
            dynpnr      = sy-dynnr
            value_org   = 'S'
       tables
            value_tab   = itab.

at selection-screen on value-request for s_khinr-high.

start-of-selection.


form build_group_option.

*** MAKE SURE YOU MODIFY THIS STATEMENT
select khinr from csks into table itab
         where kokrs eq 'NSCO'.
         
         
endform.

Regards,

Rich Heilman

0 Kudos

Jamie,

If you are trying to provide F4 help for Cost Center Group, try this:

at selection-screen on value-request for s_khinr-low.

data: l_ksgru like like rksb1-ksgru.

call function 'K_GROUP_SELECT'

exporting

class = '0101'

field_name = 'KOSTL'

importing

set_name = l_ksgru

exceptions

no_set_picked = 02.

s_khinr-low = l_ksgru.

If you are building your group list from CSKS, you will only get the groups that have cost centers (leafs) but not the groups that have other groups as nodes.

If you then have to find the Cost Centers in the selected groups, you will have to find all the groups first and then use BAPI_COSTCENTER_GETLIST1 for each group and then eliminate duplicate cost centers.

0 Kudos

I do not have sufficient info to test your program. How have you defined csks_itab_group internal table?

Based on what all fields it has, the program will delete the duplicate entries.

One of the reason that it is not deleting duplicate entries is that you MUST issue a SORT command to sort the internal table. The program is executing the logic to delete "adjacent" records that are similar; hence write a:

SORT csks_itab_group

statement just before the DELETE statement that you have in your program - and you will get the correct results. Let me know if it still fails.