2007 Mar 22 8:27 PM
Hi,
I am new to BADI. can any one help me. i want to write code for this....
1.For each UDMCASEATTR00-COST_CENTER (1-10) make sure the respective COMPANY_CODE (1-10) and BUSINESS (1-10) areas are filled. You will have to search table CSKS for this information. Use CONTROLLING_AREA CONU (find the BUKRS and GSBER for the KOSTL).
for this change i written code as ,
Types: Begin of it_UDMCASEATTR00 ,
COST_CENTER1 TYPE UDMCASEATTR00-COST_CENTER1,
COST_CENTER2 TYPE UDMCASEATTR00-COST_CENTER2,
COST_CENTER3 TYPE UDMCASEATTR00-COST_CENTER3,
COST_CENTER4 TYPE UDMCASEATTR00-COST_CENTER4,
COST_CENTER5 TYPE UDMCASEATTR00-COST_CENTER5,
COST_CENTER6 TYPE UDMCASEATTR00-COST_CENTER6,
COST_CENTER7 TYPE UDMCASEATTR00-COST_CENTER7,
COST_CENTER8 TYPE UDMCASEATTR00-COST_CENTER8,
COST_CENTER9 TYPE UDMCASEATTR00-COST_CENTER9,
COST_CENTER10 TYPE UDMCASEATTR00-COST_CENTER10,
COMPANY_CODE1 TYPE UDMCASEATTR00-COMPANY_CODE1,
COMPANY_CODE2 TYPE UDMCASEATTR00-COMPANY_CODE2,
COMPANY_CODE3 TYPE UDMCASEATTR00-COMPANY_CODE3,
COMPANY_CODE4 TYPE UDMCASEATTR00-COMPANY_CODE4,
COMPANY_CODE5 TYPE UDMCASEATTR00-COMPANY_CODE5,
COMPANY_CODE6 TYPE UDMCASEATTR00-COMPANY_CODE6,
COMPANY_CODE7 TYPE UDMCASEATTR00-COMPANY_CODE7,
COMPANY_CODE8 TYPE UDMCASEATTR00-COMPANY_CODE8,
COMPANY_CODE9 TYPE UDMCASEATTR00-COMPANY_CODE9,
COMPANY_CODE10 TYPE UDMCASEATTR00-COMPANY_CODE10,
BUSINESS1 TYPE UDMCASEATTR00-BUSINESS1,
BUSINESS2 TYPE UDMCASEATTR00-BUSINESS2,
BUSINESS3 TYPE UDMCASEATTR00-BUSINESS3,
BUSINESS4 TYPE UDMCASEATTR00-BUSINESS4,
BUSINESS5 TYPE UDMCASEATTR00-BUSINESS5,
BUSINESS6 TYPE UDMCASEATTR00-BUSINESS6,
BUSINESS7 TYPE UDMCASEATTR00-BUSINESS7,
BUSINESS8 TYPE UDMCASEATTR00-BUSINESS8,
BUSINESS9 TYPE UDMCASEATTR00-BUSINESS9,
BUSINESS10 TYPE UDMCASEATTR00-BUSINESS10,
End of it_UDMCASEATTR00.
Data : it_UDMCASEATTR001 type table of it_UDMCASEATTR00 .
Data: wa_udmcaseattr00 like line of it_UDMCASEATTR001.
Data: it_UDMCASEATTR00_temp type table of it_UDMCASEATTR00.
Types: Begin of it_csks,
bukrs type csks-bukrs,
gsber type csks-gsber,
kostl type csks-kostl,
kokrs type csks-kokrs,
End of it_csks.
Data: it_csks1 type table of it_csks.
Data: wa_csks like line of it_csks1.
select cost_center1 cost_center2 cost_center3 cost_center4 cost_center5 cost_center6 cost_center7
cost_center8 cost_center9 cost_center10 company_code1 company_code2 company_code3 company_code4
company_code5 company_code6 company_code7 company_code8 company_code9 company_code10
business1 business2 business3 business4 business5 business6 business7 business8 business9
business10 from UDMCASEATTR00 into table it_UDMCASEATTR001 .
it_UDMCASEATTR00_temp[] = it_UDMCASEATTR001[].
Clear it_UDMCASEATTR001. refresh it_UDMCASEATTR001.
Loop at it_UDMCASEATTR00_temp.
If not it_UDMCASEATTR00_temp-cost_center is initial.
If not it_UDMCASEATTR00_temp-company_code is initial.
If not it_UDMCASEATTR00_temp-business is initial.
Append it_UDMCASEATTR00_temp to it_UDMCASEATTR001.
Endif.
Endif.
Endif.
Endloop.
*
Free it_UDMCASEATTR00_temp.
if not it_udmcaseattr001[] is initial.
select bukrs gsber kostl kokrs from csks
"for all entries in it_UDMCASEATTR001
into table it_csks1
where KOSTL = it_UDMCASEATTR001-cost_center1
and kokrs = 'CONU'
and bukrs = it_UDMCASEATTR001-company_code1
and gsber = it_UDMCASEATTR001-business1.
endif.
when i activate i am getting syntax error as At "loop at itab" onof the additions "into","assiging" or "transporting no fields" is required in the OO context.
please help me how to write code for this.
thanks,
ankitha
2007 Mar 22 10:34 PM
you need to loop into a work area.
Decalre a work area like this:
<b>data: wa_UDMCASEATTR00_temp type it_UDMCASEATTR00.</b>
then
<b>Loop at it_UDMCASEATTR00_temp into wa_UDMCASEATTR00_temp.</b>
write your statements
<b>endloop.</b>
2007 Mar 22 10:34 PM
you need to loop into a work area.
Decalre a work area like this:
<b>data: wa_UDMCASEATTR00_temp type it_UDMCASEATTR00.</b>
then
<b>Loop at it_UDMCASEATTR00_temp into wa_UDMCASEATTR00_temp.</b>
write your statements
<b>endloop.</b>
2007 Mar 22 10:39 PM
in loop
write this code
If not wa_UDMCASEATTR00_temp-cost_center is initial and
not wa_UDMCASEATTR00_temp-company_code is initial and
not wa_UDMCASEATTR00_temp-business is initial.
Append wa_UDMCASEATTR00_temp to it_UDMCASEATTR001.
endif.
2007 Mar 23 1:08 PM
Hi,
when i doing code in loop like this,
Loop at it_UDMCASEATTR00_temp into wa_UDMCASEATTR00_temp.
If not wa_UDMCASEATTR00_temp-cost_center is initial and
not wa_UDMCASEATTR00_temp-company_code is initial and
not wa_UDMCASEATTR00_temp-business is initial.
Append wa_UDMCASEATTR00_temp to it_UDMCASEATTR001.
ENDIF.
ENDLOOP.
I am geting error as The data object "wa_UDMCASEATTR00_temp" does not have
a component call "COST_CENTER".
CAN YOU HELP ME PLZ
2007 Mar 23 1:34 PM
hi,
how to write select statement for this...
1.For each UDMCASEATTR00-COST_CENTER (1-10) make sure the respective COMPANY_CODE (1-10) and BUSINESS (1-10) areas are filled. You will have to search table CSKS for this information. Use CONTROLLING_AREA CONU (find the BUKRS and GSBER for the KOSTL).
i am writing like this is it right r wrong...
if not it_udmcaseattr001[] is initial.
select bukrs gsber kostl kokrs from csks
"for all entries in it_UDMCASEATTR001
into table it_csks1
where KOSTL = it_UDMCASEATTR001-cost_center1
and kokrs = 'CONU'
and bukrs = it_UDMCASEATTR001-company_code1
and gsber = it_UDMCASEATTR001-business1.
endif.