*This is a SAP ABAP TECHNICAL demo FOR KS01 ,Be careful to use in your system,just FYI. Create One or More Cost Centers
*If you have any solution,Please feel free to talk with your IT team/SAP ABAP professional guys. Create One or More Cost Centers
*This module creates one or more master records for cost centers.
*The module interface contains fields that can also be filled during
*online processing. The appropriate field checks are performed.
*If you set the flag TESTRUN, only the checks take place. The subsequent
*posting does not occur (check functions).
*A cost center can be defined in various time intervals. The following
*restrictions apply for this module:
*Only one time interval can be entered for a specified cost center.
*The cost center cannot already have time intervals entered for it in
*the database.
*Consult the documentation on Cost Center Accounting.
REPORT ZDEMO_BAPI_COSTCENTER_CREATEMULTIPLE.
PARAMETERS SAMPLE AS CHECKBOX.
INITIALIZATION.
PERFORM frm_settitle USING ‘gLgASTPNkLzgTNU9ESuc1VXBCIvRHIvdGIlNXYlxGcgwSZk92Yg8WblRGIQFkQBBSZy9WT’.
START-OF-SELECTION.
BREAK-POINT..
DATA: LV_CONTROLLINGAREA TYPE BAPI0012_GEN-CO_AREA .”Obligatory
DATA: LV_TESTRUN TYPE BAPI0012_GEN-TESTRUN .”Option,Default Value =SPACE,
DATA: LV_MASTER_DATA_INACTIVE TYPE BAPI0012_GEN-MASTER_DATA_INACTIVE .”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
**********************************************************************
*******Defination of [Tables]-[COSTCENTERLIST] .
**********************************************************************
DATA: LT_COSTCENTERLIST TYPE STANDARD TABLE OF BAPI0012_CCINPUTLIST.””Interface Structure: Create Cost Center Input List
DATA: LS_COSTCENTERLIST TYPE BAPI0012_CCINPUTLIST .””Interface Structure: Create Cost Center Input List
LS_COSTCENTERLIST-COSTCENTER = ‘CHAR10’. “Cost Center
LS_COSTCENTERLIST-VALID_FROM = ‘20241208’. “Valid From
LS_COSTCENTERLIST-VALID_TO = ‘20241208’. “Valid To
LS_COSTCENTERLIST-PERSON_IN_CHARGE = ‘CHAR20’. “Person Responsible
LS_COSTCENTERLIST-DEPARTMENT = ‘CHAR12’. “Department
LS_COSTCENTERLIST-COSTCENTER_TYPE = ‘CHAR1’. “Cost Center Category
LS_COSTCENTERLIST-COSTCTR_HIER_GRP = ‘CHAR12’. “Hierarchy Area
LS_COSTCENTERLIST-COMP_CODE = ‘CHAR4’. “Company Code
LS_COSTCENTERLIST-BUS_AREA = ‘CHAR4’. “Business Area
LS_COSTCENTERLIST-CURRENCY = ‘CUKY5’. “Currency
LS_COSTCENTERLIST-CURRENCY_ISO = ‘CHAR3’. “ISO Currency Code
LS_COSTCENTERLIST-PROFIT_CTR = ‘CHAR10’. “Profit Center
LS_COSTCENTERLIST-RECORD_QUANTITY = ‘CHAR1’. “Record Quantity
LS_COSTCENTERLIST-LOCK_IND_ACTUAL_PRIMARY_COSTS = ‘CHAR1’. “Actual primary costs
LS_COSTCENTERLIST-LOCK_IND_PLAN_PRIMARY_COSTS = ‘CHAR1’. “Plan primary costs
LS_COSTCENTERLIST-LOCK_IND_ACT_SECONDARY_COSTS = ‘CHAR1’. “Actual Secondary Costs
LS_COSTCENTERLIST-LOCK_IND_PLAN_SECONDARY_COSTS = ‘CHAR1’. “Plan Secondary Costs
LS_COSTCENTERLIST-LOCK_IND_ACTUAL_REVENUES = ‘CHAR1’. “Actual Revenues
LS_COSTCENTERLIST-LOCK_IND_PLAN_REVENUES = ‘CHAR1’. “Plan Revenues
LS_COSTCENTERLIST-LOCK_IND_COMMITMENT_UPDATE = ‘CHAR1’. “Commitment Update
LS_COSTCENTERLIST-CONDITION_TABLE_USAGE = ‘CHAR1’. “Usage
LS_COSTCENTERLIST-APPLICATION = ‘CHAR2’. “Application
LS_COSTCENTERLIST-CSTG_SHEET = ‘CHAR6’. “Costing Sheet
LS_COSTCENTERLIST-ACTY_INDEP_TEMPLATE = ‘CHAR10’. “Acty-Indep. FormPlng Temp
LS_COSTCENTERLIST-ACTY_DEP_TEMPLATE = ‘CHAR10’. “Acty-Dep. Form.Plng Temp.
LS_COSTCENTERLIST-ADDR_TITLE = ‘CHAR15’. “Title
LS_COSTCENTERLIST-ADDR_NAME1 = ‘CHAR35’. “Name
LS_COSTCENTERLIST-ADDR_NAME2 = ‘CHAR35’. “Name 2
LS_COSTCENTERLIST-ADDR_NAME3 = ‘CHAR35’. “Name 3
LS_COSTCENTERLIST-ADDR_NAME4 = ‘CHAR35’. “Name 4
LS_COSTCENTERLIST-ADDR_STREET = ‘CHAR35’. “Street
LS_COSTCENTERLIST-ADDR_CITY = ‘CHAR35’. “City
LS_COSTCENTERLIST-ADDR_DISTRICT = ‘CHAR35’. “District
LS_COSTCENTERLIST-ADDR_COUNTRY = ‘CHAR3’. “Country/Region Key
LS_COSTCENTERLIST-ADDR_COUNTRY_ISO = ‘CHAR2’. “Country/Region ISO
LS_COSTCENTERLIST-ADDR_TAXJURCODE = ‘CHAR15’. “Tax Jurisdiction
LS_COSTCENTERLIST-ADDR_PO_BOX = ‘CHAR10’. “PO Box
LS_COSTCENTERLIST-ADDR_POSTL_CODE = ‘CHAR10’. “Postal Code
LS_COSTCENTERLIST-ADDR_POBX_PCD = ‘CHAR10’. “P.O. Box Postal Code
LS_COSTCENTERLIST-ADDR_REGION = ‘CHAR3’. “Region
LS_COSTCENTERLIST-TELCO_LANGU = ‘LANG1’. “Language Key
LS_COSTCENTERLIST-TELCO_LANGU_ISO = ‘CHAR2’. “Language Code
LS_COSTCENTERLIST-TELCO_TELEPHONE = ‘CHAR16’. “Telephone 1
LS_COSTCENTERLIST-TELCO_TELEPHONE2 = ‘CHAR16’. “Telephone 2
LS_COSTCENTERLIST-TELCO_TELEBOX = ‘CHAR15’. “Telebox Number
LS_COSTCENTERLIST-TELCO_TELEX = ‘CHAR30’. “Telex Number
LS_COSTCENTERLIST-TELCO_FAX_NUMBER = ‘CHAR31’. “Fax Number
LS_COSTCENTERLIST-TELCO_TELETEX = ‘CHAR30’. “Teletex Number
LS_COSTCENTERLIST-TELCO_PRINTER = ‘CHAR4’. “Printer Destination
LS_COSTCENTERLIST-TELCO_DATA_LINE = ‘CHAR14’. “Data line
LS_COSTCENTERLIST-JV_VENTURE = ‘CHAR6’. “Joint venture
LS_COSTCENTERLIST-JV_REC_IND = ‘CHAR2’. “Recovery Indicator
LS_COSTCENTERLIST-JV_EQUITY_TYP = ‘CHAR3’. “Equity type
LS_COSTCENTERLIST-JV_OTYPE = ‘CHAR4’. “Joint Venture Object Type
LS_COSTCENTERLIST-JV_JIBCL = ‘CHAR3’. “JIB/JIBE Class
LS_COSTCENTERLIST-JV_JIBSA = ‘CHAR5’. “JIB/JIBE Subclass A
LS_COSTCENTERLIST-NAME = ‘CHAR20’. “Name
LS_COSTCENTERLIST-DESCRIPT = ‘CHAR40’. “Description
LS_COSTCENTERLIST-FUNC_AREA = ‘CHAR4’. “Functional Area
LS_COSTCENTERLIST-ACTY_DEP_TEMPLATE_ALLOC_CC = ‘CHAR10’. “Acty-Dep. Alloc. Template
LS_COSTCENTERLIST-ACTY_INDEP_TEMPLATE_ALLOC_CC = ‘CHAR10’. “Acty-Indep. Alloc. Temp.
LS_COSTCENTERLIST-FUNC_AREA_LONG = ‘CHAR16’. “Functional Area
LS_COSTCENTERLIST-PERSON_IN_CHARGE_USER = ‘CHAR12’. “User Responsible
LS_COSTCENTERLIST-LOGSYSTEM = ‘CHAR10’. “Logical System
LS_COSTCENTERLIST-ACTY_DEP_TEMPLATE_SK = ‘CHAR10’. “Templ.: Act. Stat. Key Figure
LS_COSTCENTERLIST-ACTY_INDEP_TEMPLATE_SK = ‘CHAR10’. “Templ.: Act. Stat. Key Figure
LS_COSTCENTERLIST-BUDGET_CARRYING_COST_CTR = ‘CHAR10’. “Budget-Carrying Cost Center
LS_COSTCENTERLIST-AVC_PROFILE = ‘CHAR6’. “Budget Availability Ctrl Prfl
LS_COSTCENTERLIST-AVC_ACTIVE = ‘CHAR1’. “Budget Availability Control is Active
LS_COSTCENTERLIST-FUND = ‘CHAR10’. “Fund
LS_COSTCENTERLIST-GRANT_ID = ‘CHAR20’. “Grant
LS_COSTCENTERLIST-FUND_FIX_ASSIGNED = ‘CHAR1’. “Fund Fixed Assignment
LS_COSTCENTERLIST-GRANT_FIX_ASSIGNED = ‘CHAR1’. “Grant Fixed Assignment
LS_COSTCENTERLIST-FUNC_AREA_FIX_ASSIGNED = ‘CHAR1’. “Functional Area Fixed Assignment
APPEND LS_COSTCENTERLIST TO LT_COSTCENTERLIST .
CLEAR LS_COSTCENTERLIST .
**********************************************************************
*******Defination of [Tables]-[RETURN] .
**********************************************************************
DATA: LT_RETURN TYPE STANDARD TABLE OF BAPIRET2.””Return Parameter
DATA: LS_RETURN TYPE BAPIRET2 .””Return Parameter
LS_RETURN-TYPE = ‘CHAR1’. “Message type
LS_RETURN-ID = ‘CHAR20’. “Message Class
LS_RETURN-NUMBER = ‘NUMC3’. “Message Number
LS_RETURN-MESSAGE = ‘CHAR220’. “Message Text
LS_RETURN-LOG_NO = ‘CHAR20’. “Log Number
LS_RETURN-LOG_MSG_NO = ‘NUMC6’. “Message Serial No.
LS_RETURN-MESSAGE_V1 = ‘CHAR50’. “Message Variable
LS_RETURN-MESSAGE_V2 = ‘CHAR50’. “Message Variable
LS_RETURN-MESSAGE_V3 = ‘CHAR50’. “Message Variable
LS_RETURN-MESSAGE_V4 = ‘CHAR50’. “Message Variable
LS_RETURN-PARAMETER = ‘CHAR32’. “Parameter Name
LS_RETURN-ROW = ‘INT410’. “Lines in parameter
LS_RETURN-FIELD = ‘CHAR30’. “Field name
LS_RETURN-SYSTEM = ‘CHAR10’. “Logical system (source of message)
APPEND LS_RETURN TO LT_RETURN .
CLEAR LS_RETURN .
**********************************************************************
*******Defination of [Tables]-[EXTENSIONIN] .
**********************************************************************
DATA: LT_EXTENSIONIN TYPE STANDARD TABLE OF BAPIPAREX.””Ref. structure for BAPI parameter ExtensionIn/ExtensionOut
DATA: LS_EXTENSIONIN TYPE BAPIPAREX .””Ref. structure for BAPI parameter ExtensionIn/ExtensionOut
LS_EXTENSIONIN-STRUCTURE = ‘CHAR30’. “BAPI table extension struct.
LS_EXTENSIONIN-VALUEPART1 = ‘CHAR240’. “Data
LS_EXTENSIONIN-VALUEPART2 = ‘CHAR240’. “Data
LS_EXTENSIONIN-VALUEPART3 = ‘CHAR240’. “Data
LS_EXTENSIONIN-VALUEPART4 = ‘CHAR240’. “Data
APPEND LS_EXTENSIONIN TO LT_EXTENSIONIN .
CLEAR LS_EXTENSIONIN .
**********************************************************************
*******Defination of [Tables]-[EXTENSIONOUT] .
**********************************************************************
DATA: LT_EXTENSIONOUT TYPE STANDARD TABLE OF BAPIPAREX.””Ref. structure for BAPI parameter ExtensionIn/ExtensionOut
DATA: LS_EXTENSIONOUT TYPE BAPIPAREX .””Ref. structure for BAPI parameter ExtensionIn/ExtensionOut
LS_EXTENSIONOUT-STRUCTURE = ‘CHAR30’. “BAPI table extension struct.
LS_EXTENSIONOUT-VALUEPART1 = ‘CHAR240’. “Data
LS_EXTENSIONOUT-VALUEPART2 = ‘CHAR240’. “Data
LS_EXTENSIONOUT-VALUEPART3 = ‘CHAR240’. “Data
LS_EXTENSIONOUT-VALUEPART4 = ‘CHAR240’. “Data
APPEND LS_EXTENSIONOUT TO LT_EXTENSIONOUT .
CLEAR LS_EXTENSIONOUT .
**********************************************************************
*******CallUp The Function Now. .
**********************************************************************
CALL FUNCTION ‘BAPI_COSTCENTER_CREATEMULTIPLE’
EXPORTING
CONTROLLINGAREA = LV_CONTROLLINGAREA
* TESTRUN = ”
* MASTER_DATA_INACTIVE = ”
* LANGUAGE = LS_LANGUAGE
TABLES
COSTCENTERLIST = LT_COSTCENTERLIST
RETURN = LT_RETURN
* EXTENSIONIN = LT_EXTENSIONIN
* EXTENSIONOUT = LT_EXTENSIONOUT
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.
If you have problem, please fell free to contact.Thanks.
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》