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 element

Former Member
0 Kudos
220

I am developing a cost center. where i am extracting cost center and object number from

CSKS table.

Using the Object I am extracting Cost element...

loop at itab.
  l_tabix = sy-tabix.
  select single kstar ebeln from covp
         into  (covp-kstar , covp-ebeln)
         where kokrs = p_kokrs
         and   objnr = gt_cc-objnr
         and   gjahr = p_fyear
         and   perio in s_period.
  if sy-subrc = 0.
    itab-kstar = covp-kstar.
    itab-ebeln = covp-ebeln.
    modify itab index sy-tabix.
  endif.
endloop.

The problem is a object number can have any number of cost elements associated with it....

this part however is retreiving only 1 cost element...

Please let me know how to fix this problem...

5 REPLIES 5

Former Member
0 Kudos
133

you have a select single... that will return only one entry..

i am sorry if i have understood incorrectly... but thats how i have interpreted ur issue.

0 Kudos
133

my internal table already has the cost center and object number

I cannot use select for all entries due to performance issue

so i used a select single..

Let me know how to fix this one

0 Kudos
133

No other way,you need to use for all entries option,since select single will get one record at time.

Thanks

Seshu

Former Member
0 Kudos
133

Hi Alexander,

chk the BAPI , BAPI_COSTELEMENTGROUP_GETDETAIL,

Former Member
0 Kudos
133

Hi,

as you have multiple entries .. here is the code..

take one two more tables one jtab like itab and another table say ktab with two fields kstar and ebeln..

loop at itab.

l_tabix = sy-tabix.

select kstar ebeln from covp

into table ktab

where kokrs = p_kokrs

and objnr = gt_cc-objnr

and gjahr = p_fyear

and perio in s_period.

if sy-subrc = 0.

loop at ktab.

jtab = itab.

jtab-kstar = ktab-kstar.

jtab-ebeln = ktab-ebeln.

append jtab.

endloop.

endif.

endloop.

Thanks,

Mahesh