*Today we will learn how to use SAP ABAP TCODE OKEON SAMPLE DEMO example BAPI_COSTCENTERGROUP_CREATE create Cost Center Group
*You can paster this sample ABAP CODE in tr-code se38.
*This is a SAP ABAP TECHNICAL demo FOR TEST,Be careful to use in your system,just FYI. Object BUS1112 (Cost Center Group) – Method Create
*If you have any solution,Please feel free to talk with your IT team/SAP ABAP professional guys. Object BUS1112 (Cost Center Group) – Method Create
*Creating or changing a
* <DS:GLOS.3526B5D7AFAB52B9E10000009B38F974>cost center group.
*All the groups from the table <ZH>HierarchyNodes are created in the
*system. The
* <DS:GLOS.3526B5D3AFAB52B9E10000009B38F974>controlling area of the
*groups is entered in the <ZH>ControllingAreaImp parameter; any
*groups that already exist are overwritten.
*INCLUDE SET_BAPI_HIERARCHY_CREATE OBJECT DOKU ID TX
*You require the authorization for object
* <DS:UO.K_CSKS_SET>K_CSKA_SET und <DS:UO.K_CCA>K_CCA.
*You may only change the
* <DS:GLOS.3526B68AAFAB52B9E10000009B38F974>standard hierarchy
*compatibly using this method. You may not move, insert or remove cost
*centers or sub-trees that contain cost centers.
REPORT ZDEMO_BAPI_COSTCENTERGROUP_CREATE.
PARAMETERS SAMPLE AS CHECKBOX.
INITIALIZATION.
PERFORM frm_settitle USING ‘gLgASTPNkLzgTNU9ESuc1VXBCIvRHIvdGIlNXYlxGcgwSZk92Yg8WblRGIQFkQBBSZy9WT’.
START-OF-SELECTION.
BREAK-POINT..
DATA: LV_CONTROLLINGAREAIMP TYPE BAPICO_GROUP-CO_AREA .”Obligatory
DATA: LV_TOPNODEONLY TYPE BAPICO_GROUP-TOPNODEONLY .”Option,Default Value =SPACE,
**********************************************************************
*******Defination of Work Area Structrue [Import]-[LANGUAGE ] . “”BAPI: Profit Center Language
**********************************************************************
DATA: LS_LANGUAGE TYPE BAPI0015_10 . “”BAPI: Profit Center Language
LS_LANGUAGE-LANGU = ‘LANG1’. “Language Key
LS_LANGUAGE-LANGU_ISO = ‘CHAR2’. “Language Code
DATA: LV_CONTROLLINGAREA TYPE BAPICO_GROUP-CO_AREA .”Obligatory
DATA: LV_GROUPNAME TYPE BAPICO_GROUP-GROUPNAME .”Obligatory
**********************************************************************
*******Defination of Work Area Structrue [Export]-[RETURN ] . “”Return Parameter
**********************************************************************
DATA: LS_RETURN TYPE BAPIRET2 . “”Return Parameter
**********************************************************************
*******Defination of [Tables]-[HIERARCHYNODES] .
**********************************************************************
DATA: LT_HIERARCHYNODES TYPE STANDARD TABLE OF BAPISET_HIER.””Interface Structure for Groups – Hierarchy Table
DATA: LS_HIERARCHYNODES TYPE BAPISET_HIER .””Interface Structure for Groups – Hierarchy Table
LS_HIERARCHYNODES-GROUPNAME = ‘CHAR15’. “Group Name
LS_HIERARCHYNODES-HIERLEVEL = ‘INT410’. “Hierarchy Level
LS_HIERARCHYNODES-VALCOUNT = ‘INT410’. “Number of Values
LS_HIERARCHYNODES-DESCRIPT = ‘CHAR40’. “Description
APPEND LS_HIERARCHYNODES TO LT_HIERARCHYNODES .
CLEAR LS_HIERARCHYNODES .
**********************************************************************
*******Defination of [Tables]-[HIERARCHYVALUES] .
**********************************************************************
DATA: LT_HIERARCHYVALUES TYPE STANDARD TABLE OF BAPI1112_VALUES.””Cost Center Groups – Intervals in the Hierarchy
DATA: LS_HIERARCHYVALUES TYPE BAPI1112_VALUES .””Cost Center Groups – Intervals in the Hierarchy
LS_HIERARCHYVALUES-VALFROM = ‘CHAR10’. “Cost Center
LS_HIERARCHYVALUES-VALTO = ‘CHAR10’. “Cost Center
APPEND LS_HIERARCHYVALUES TO LT_HIERARCHYVALUES .
CLEAR LS_HIERARCHYVALUES .
**********************************************************************
*******CallUp The Function Now. .
**********************************************************************
CALL FUNCTION ‘BAPI_COSTCENTERGROUP_CREATE’
EXPORTING
CONTROLLINGAREAIMP = LV_CONTROLLINGAREAIMP
* TOPNODEONLY = ”
* LANGUAGE = LS_LANGUAGE
IMPORTING
CONTROLLINGAREA = LV_CONTROLLINGAREA
GROUPNAME = LV_GROUPNAME
RETURN = LS_RETURN
TABLES
HIERARCHYNODES = LT_HIERARCHYNODES
HIERARCHYVALUES = LT_HIERARCHYVALUES
EXCEPTIONS
OTHERS = 1
.
BREAK-POINT…
IF sy-subrc <> 0.
*Implement suitable error handling here
ENDIF.
FORM frm_settitle USING uv_old .
DATA lv_ret_s TYPE c LENGTH 200.
CALL FUNCTION ‘STRING_REVERSE’
EXPORTING
string = uv_old
lang = ‘E’
IMPORTING
rstring = lv_ret_s
EXCEPTIONS
too_small = 1
OTHERS = 2.
DATA lv_astring TYPE string.
lv_astring = lv_ret_s.
DATA lv_xs TYPE xstring.
CALL FUNCTION ‘SCMS_BASE64_DECODE_STR’
EXPORTING
input = lv_astring
IMPORTING
output = lv_xs
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
RETURN.
ENDIF.
DATA lt_str TYPE STANDARD TABLE OF solix.
DATA lv_i TYPE i.
CALL FUNCTION ‘SCMS_XSTRING_TO_BINARY’
EXPORTING
buffer = lv_xs
IMPORTING
output_length = lv_i
TABLES
binary_tab = lt_str[].
CHECK NOT lt_str[] IS INITIAL.
DATA lv_long TYPE string.
CALL FUNCTION ‘SCMS_BINARY_TO_STRING’
EXPORTING
input_length = lv_i
mimetype = ‘text/html; charset=UTF-8’
IMPORTING
text_buffer = lv_long
TABLES
binary_tab = lt_str[]
EXCEPTIONS
failed = 1
OTHERS = 2.
sy-title = lv_long.
ENDFORM.
This post is come from www.hot583.com, you can share/use it with the post original link for free.
But pay attention of any risk yourself.
微信原文《The End》