06-06-2011 9:18 AM
Hello experts!
I need some help in posting in infotype 0027 which should be fairly easy to most of you. As you guys know, there are a total of 25 cost centers available (KST01-KST25) for this infotype. What I want to do is check from KST01 if it exists with a valid entry at a specific date (BEGDA and ENDDA will be provided as well) all the way up to KST25 and choose the first cost center field that is INITIAL. This is used before 'BAPI_COSTCENTER_CREATEMULTIPLE' so that if KST01 up to KST05 all have values on the same BEGDA & ENDDA, how can I have KST06 chosen? Thanks in advance for your help!
06-06-2011 11:44 AM
Hi,
Write as below.
data : p_0027 like pa0027 occurs 0 with header line.
data : lv_KOSTL type KOSTL.
data : lv_index(2) type n.
data : lv_cost(12).
field-symbols : <lv_kostl> type any.
select single * from pa0027 into p_0027.
do 25 times
varying lv_KOSTL from p_0027-KST01 next p_0027-KST02.
lv_index = lv_index + 1.
IF lv_KOSTL is initial.
concatenate 'KST' lv_index into lv_cost.
exit.
endif.
enddo.
assign component lv_cost of structure p_0027 to <lv_kostl>.
IF sy-subrc = 0.
<lv_kostl> = '100'. " <-- Assign any value here
ENDIF.
Regards,
Srini.
06-06-2011 11:44 AM
Hi,
Write as below.
data : p_0027 like pa0027 occurs 0 with header line.
data : lv_KOSTL type KOSTL.
data : lv_index(2) type n.
data : lv_cost(12).
field-symbols : <lv_kostl> type any.
select single * from pa0027 into p_0027.
do 25 times
varying lv_KOSTL from p_0027-KST01 next p_0027-KST02.
lv_index = lv_index + 1.
IF lv_KOSTL is initial.
concatenate 'KST' lv_index into lv_cost.
exit.
endif.
enddo.
assign component lv_cost of structure p_0027 to <lv_kostl>.
IF sy-subrc = 0.
<lv_kostl> = '100'. " <-- Assign any value here
ENDIF.
Regards,
Srini.
06-07-2011 1:17 AM
Hi Srini.
Thanks for your reply. However, when I try to check for syntax errors, I get the error "The addition OCCURS is no longer supported in the OO context. use "TABLE OF ..... INITIAL SIZE instead"" I am currently coding this in a method in se24 but I don't have an idea how "TABLE OF.. INITIAL SIZE" will be used, can you please help me with this one? Thank you very much.
06-07-2011 5:45 AM
Hi,
Instead you can just declare a work area ..
data : p_0027 type pa0027.
data : lv_KOSTL type KOSTL.
data : lv_index(2) type n.
data : lv_cost(12).
field-symbols : <lv_kostl> type any.
select single * from pa0027 into p_0027.
do 25 times
varying lv_KOSTL from p_0027-KST01 next p_0027-KST02.
lv_index = lv_index + 1.
IF lv_KOSTL is initial.
concatenate 'KST' lv_index into lv_cost.
exit.
endif.
enddo.
assign component lv_cost of structure p_0027 to <lv_kostl>.
IF sy-subrc = 0.
<lv_kostl> = '100'. " <-- Assign any value here
ENDIF.
Regards,
Srini.
06-07-2011 6:42 AM