10-26-2007 8:14 AM
In the selection screen i should have cost center and cost center group.
if i give cost center group i should get all the cost centers related to that group.
or if i give only cost center details i should get only that cost center details.
i am picking cost center from BSEG table but from which table i get cost center group details.
please help me this is urgent.
10-26-2007 8:19 AM
10-26-2007 8:22 AM
Check the BAPI <b>BAPI_COSTCENTERGROUP_GETDETAIL</b> to fetch the Cost Centers that fall under the Cost Center group
10-26-2007 8:24 AM
Hi,
Check the below code.
TABLES: csks.
For Identification Number
DATA: BEGIN OF it_kostl OCCURS 0,
kostl LIKE csks-kostl,
END OF it_kostl.
DATA: v_khinr LIKE csks-khinr.
For Run date
DATA: BEGIN OF it_khinr OCCURS 0,
khinr LIKE csks-khinr,
END OF it_khinr.
DATA it_ret LIKE ddshretval OCCURS 0 WITH HEADER LINE.
SELECTION-SCREEN: BEGIN OF BLOCK main WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP.
PARAMETERS: p_khinr LIKE csks-khinr.
SELECT-OPTIONS s_kostl FOR csks-kostl NO INTERVALS.
SELECTION-SCREEN END OF BLOCK main.
*----
Validation Section
*----
INITIALIZATION.
SELECT DISTINCT khinr FROM csks INTO TABLE it_khinr.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_khinr.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'KHINR'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'P_KHINR'
value_org = 'S'
TABLES
value_tab = it_khinr
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_kostl-low.
TABLES: t130r.
DATA: BEGIN OF dynpfields OCCURS 0. "Hilfsstruktur zum auslesen des
INCLUDE STRUCTURE dynpread. "Feldwertes vom Dynpro bei >F4<
DATA: END OF dynpfields.
DATA : sy_repid LIKE sy-repid,
sy_dynnr LIKE sy-dynnr.
CLEAR dynpfields.
REFRESH dynpfields.
dynpfields-fieldname = 'P_KHINR'.
APPEND dynpfields.
Lesen des akt. Wertes von Dynpro
sy_repid = sy-repid.
sy_dynnr = sy-dynnr.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = sy_repid
dynumb = sy_dynnr
TABLES
dynpfields = dynpfields
EXCEPTIONS
OTHERS = 01.
IF sy-subrc = 0.
READ TABLE dynpfields WITH KEY fieldname = 'P_KHINR'.
IF sy-subrc = 0.
v_khinr = dynpfields-fieldvalue.
ENDIF.
ENDIF.
SELECT kostl FROM csks
INTO TABLE it_kostl
WHERE khinr = v_khinr .
IF NOT it_kostl[] IS INITIAL.
SORT it_kostl BY kostl.
DELETE ADJACENT DUPLICATES FROM it_kostl COMPARING kostl.
ENDIF.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'KOSTL'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'S_KOSTL'
value_org = 'S'
TABLES
value_tab = it_kostl
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Message was edited by:
Velangini Showry Maria Kumar Bandanadham
10-26-2007 8:26 AM
Hi
hi you have to use the SETNODE and SETLEAF tables for getting all the Cost centers related to CC group
or use the fun module
concatenate Class, Subclass and CC group into p_setid and pass to this fun module
call function 'G_SET_TREE_IMPORT'
exporting
CLIENT = SY-MANDT
FIELDNAME = ' '
LANGU = SY-LANGU
NO_DESCRIPTIONS = ' '
NO_RW_INFO = ' '
setid = p_setid
TABNAME = ' '
NO_VARIABLE_REPLACEMENT = ' '
ROOT_HEADER_ONLY = ' '
NO_TABLE_BUFFERING = ' '
MAX_HIER_LEVEL = 99
DATE_FROM =
DATE_TO =
IMPORTING
SET_NOT_TRANSPARENT =
tables
set_hierarchy = ccenter_group_tab
set_values = cost_center_tab
EXCEPTIONS
SET_NOT_FOUND = 1
ILLEGAL_FIELD_REPLACEMENT = 2
ILLEGAL_TABLE_REPLACEMENT = 3
OTHERS = 4
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
Regards
Anji