10-08-2007 7:11 AM
Hi All,
i have a report which dispalys a column profit center (CSKS-PRCTR).
My functional wants to replace this field (CSKS-PRCTR) with GLPCA-SPRCTR.
I tried with various option but not successful. Any help would be highly appreciated.
Thanks,
Senthil
Message was edited by:
senthil kumar
10-08-2007 7:39 AM
10-08-2007 7:43 AM
Hi,
The problem is that i am getting multiple records, the input given is controlling area, company code, date, plant, account number and functional area.
I am pasting my code here
----
start-of-selection.
perform get_data.
perform update_profit_center. "+D01K962014
perform produce_output.
&----
*& Form GET_DATA
&----
form get_data.
clear: t_month, t_days, t_year, t_date_from, t_date_to, t_line.
Month of Period to Analyze
t_month = p_perio2+1(2).
Year of Period to Analyze
t_year = p_gjahr2.
Get number of days of Period to Analyze
call function 'NUMBER_OF_DAYS_PER_MONTH_GET'
exporting
par_month = t_month
par_year = t_year
importing
par_days = t_days.
Put dates together for select from AFRU
concatenate p_gjahr1 p_perio1+1(2) '01' into t_date_from.
concatenate t_year t_month t_days into t_date_to.
Select Process Orders only for Dates specified
select aufnr into table itab_aufnr
from afru
where budat ge t_date_from
and budat le t_date_to
and werks in s_werks.
Sort and delete duplicates from Orders table
sort itab_aufnr.
delete adjacent duplicates from itab_aufnr.
describe table itab_aufnr lines t_line.
if t_line gt 0.
Now select all other data with regard to Orders in Orders table
select carbpl aauart awerks aaufnr bmatnr clmnga csptag "vornr
c~erdat "+D01K962077
fmaktx jktext
into table itab
from ( ( ( ( ( ( (
aufk as a inner join afpo as b on baufnr = aaufnr )
inner join s022 as c on caufnr = baufnr and
cmatnr = bmatnr and
cwerks = bpwerk )
inner join makt as f on fmatnr = bmatnr )
inner join tkkap as g on gkokrs = akokrs )
inner join tkv09 as h on hkokrs = akokrs )
inner join crhd as i on iarbpl = carbpl )
inner join crtx as j on iobjty = jobjty and
iobjid = jobjid )
for all entries in itab_aufnr
where a~aufnr eq itab_aufnr-aufnr
and a~auart in s_auart
and a~werks in s_werks
and c~arbpl in s_arbpl
and g~kokrs in s_kokrs
and g~versa in s_versa
and h~awvrs in s_awvrs.
sort itab by aufnr matnr.
delete adjacent duplicates from itab comparing aufnr matnr.
loop at itab.
concatenate 'OR' itab-aufnr into lr_objnr-low.
lr_objnr-sign = 'I'.
lr_objnr-option = 'EQ'.
append lr_objnr.
endloop.
sort lr_objnr.
delete adjacent duplicates from lr_objnr.
call function 'KKR_COOBJECT_VALUES_READ'
exporting
i_kokrs = s_kokrs-low
I_OBJNR =
i_gjahr_von = p_gjahr1
i_gjahr_bis = p_gjahr2
i_perio_von = p_perio1
i_perio_bis = p_perio2
i_nur_belast = ' '
I_KATYP =
I_NUR_P_I =
I_NUR_P_I_S =
i_kontrollkosten = ' '
i_read_owaer = ' '
i_pvers = '000'
i_ivers = '000'
i_svers = s_awvrs-low
i_avers = s_versa-low
i_bewsicht = '0'
I_CONV_UNITS = 'X'
IMPORTING
E_KENNZAHLEN =
tables
rng_objnr = lr_objnr
RNG_WRTTP =
RNG_BEKNZ =
t_kennzahlen = lt_keyfigures
T_KKBC =
T_KKROBJ =
T_KKBOB =
exceptions
no_kokrs_set = 1
no_input_data = 2
different_input_data = 3
OTHERS = 4
.
endif.
endform. " GET_DATA
&----
*& Form update_profit_center
&----
update profit center for each line item in itab
----
form update_profit_center.
data: lv_objid like crhd-objid,
lv_kokrs like crco-kokrs,
lv_kostl like crco-kostl,
lv_prctr like csks-prctr.
field-symbols: <fs_itab> like line of itab.
update profit center into itab - alv output table
loop at itab assigning <fs_itab>.
clear lv_objid.
read resource/work center id of resource/work center of a plant
-CRHD
select objid into lv_objid
from crhd
where objty = 'A' and " A - work center
use order creation date instead of period to analyse"+D01K962077
begda <= <fs_itab>-sptag and "+D01K962077
endda >= <fs_itab>-sptag and "-D01K962077
begda <= <fs_itab>-erdat and "+D01K962077
endda >= <fs_itab>-erdat and "+D01K962077
arbpl = <fs_itab>-arbpl and " resource/work center
werks = <fs_itab>-werks. " plant
exit.
endselect.
clear: lv_kokrs,lv_kostl.
if not lv_objid is initial.
read cost center using work center id and date to analyse field to
validate from and to valid periods- CRCO
select kokrs kostl
into (lv_kokrs,lv_kostl)
from crco
where objty = 'A' and
objid = lv_objid and
use order creation date instead of period to analyse"+D01K962077
endda >= <fs_itab>-sptag and "-D01K962077
begda <= <fs_itab>-sptag. "-D01K962077
endda >= <fs_itab>-erdat and "+D01K962077
begda <= <fs_itab>-erdat. "+D01K962077
exit.
endselect.
if sy-subrc eq 0.
clear lv_prctr.
read profit center of cost center that belongs to a date to
analyse period - from CSKS
<b>*** This quesry needs to be replaced with GLPCA table</b>
select <b>prctr into lv_prctr</b>
from csks
where kokrs = lv_kokrs and " Controlling Area
kostl = lv_kostl and " Cost Center
use order creation date instead of period to analyse"+D01K962077
datbi >= <fs_itab>-sptag and "-D01K962077
datab <= <fs_itab>-sptag. "-D01K962077
datbi >= <fs_itab>-erdat and "+D01K962077
datab <= <fs_itab>-erdat. "+D01K962077
exit.
endselect.
if sy-subrc eq 0.
update profit center to itab
<fs_itab>-prctr = lv_prctr. " Profit Center
endif.
endif.
endif.
endloop.
endform. " update_profit_center
Senthil.
Message was edited by:
senthil kumar
Message was edited by:
senthil kumar
10-08-2007 8:26 AM
10-08-2007 8:42 AM
Hi,
In GLPCT table how do i get ROBJNR, COBJNR, SOBJNR. Any idea??