BAPI_ACTTYPE_CREATEMULTIPLE Create Activity Types DEMO

*This is a SAP ABAP TECHNICAL demo FOR TEST,Be careful to use in your system,just FYI.Create One or More Activity Types
*If you have any solution,Please feel free to talk with your IT team/SAP ABAP professional guys.Create One or More Activity Types
*This module creates one or more master records for activity types.
*The interface of the module includes 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 function).
*An activity type can be defined in various time intervals. The
*following restrictions apply for this module:
*Only one time interval can be entered for a specified activity type.
*The activity type cannot already have time intervals entered for it in
*the database.
*Consult the documentation on Cost Center and Activity Type Accounting.

REPORT ZDEMO_BAPI_ACTTYPE_CREATEMULTIPLE.
PARAMETERS SAMPLE AS CHECKBOX.
INITIALIZATION.
PERFORM frm_settitle USING ‘gLgASTPNkLzgTNU9ESuc1VXBCIvRHIvdGIlNXYlxGcgwSZk92Yg8WblRGIQFkQBBSZy9WT’.
START-OF-SELECTION.
BREAK-POINT..
DATA: LV_COAREA TYPE BAPI1031_GEN-CO_AREA .”Obligatory
DATA: LV_TESTRUN TYPE BAPI1031_GEN-TESTRUN .”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]-[ACTIVITYTYPELIST] .
**********************************************************************
DATA: LT_ACTIVITYTYPELIST TYPE STANDARD TABLE OF BAPI1031_ATINPUTLIST.””Interface Structure: Create Activity Type Input List
DATA: LS_ACTIVITYTYPELIST TYPE BAPI1031_ATINPUTLIST .””Interface Structure: Create Activity Type Input List
LS_ACTIVITYTYPELIST-ACTTYPE = ‘CHAR6’. “Activity Type
LS_ACTIVITYTYPELIST-VALID_FROM = ‘20241208’. “Valid From
LS_ACTIVITYTYPELIST-VALID_TO = ‘20241208’. “Valid To
LS_ACTIVITYTYPELIST-ACT_UNIT = ‘UNIT3’. “Activity Unit
LS_ACTIVITYTYPELIST-ACT_UNIT_ISO = ‘CHAR3’. “Unit of measure ISO
LS_ACTIVITYTYPELIST-COSTCENTER_CAT = ‘CHAR8’. “CCtr Categories
LS_ACTIVITYTYPELIST-ACTIVITY_CAT = ‘CHAR1’. “ATyp category
LS_ACTIVITYTYPELIST-ALLOC_COST_ELEM = ‘CHAR10’. “Allocation cost elem
LS_ACTIVITYTYPELIST-PRICE_INDICATOR = ‘CHAR3’. “Price indicator
LS_ACTIVITYTYPELIST-AVERAGE_PRICE_IND = ‘CHAR1’. “Average price
LS_ACTIVITYTYPELIST-PREDIS_FXD_COST = ‘CHAR1’. “PreDistribFixedCosts
LS_ACTIVITYTYPELIST-MANUAL_ACT_QTY = ‘CHAR1’. “Actual qty set
LS_ACTIVITYTYPELIST-ACT_CAT_ACTUAL = ‘CHAR1’. “Actl Acty Type Cat.
LS_ACTIVITYTYPELIST-ACT_PRICE_IND = ‘CHAR3’. “Act. price indicator
LS_ACTIVITYTYPELIST-LOCK_INDICATOR = ‘CHAR1’. “Lock indicator
LS_ACTIVITYTYPELIST-OUTPUT_UNIT = ‘UNIT3’. “Display Unit/Measure
LS_ACTIVITYTYPELIST-OUTPUT_UNIT_ISO = ‘CHAR3’. “Unit of measure ISO
LS_ACTIVITYTYPELIST-OUTPUT_FACTOR = ‘DEC5’. “Output factor
LS_ACTIVITYTYPELIST-NAME = ‘CHAR20’. “Name
LS_ACTIVITYTYPELIST-DESCRIPT = ‘CHAR40’. “Description
LS_ACTIVITYTYPELIST-MANUAL_PLAN_QTY = ‘CHAR1’. “Plan qty set
APPEND LS_ACTIVITYTYPELIST TO LT_ACTIVITYTYPELIST .
CLEAR LS_ACTIVITYTYPELIST .

**********************************************************************
*******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 .

**********************************************************************
*******CallUp The Function Now. .
**********************************************************************
CALL FUNCTION ‘BAPI_ACTTYPE_CREATEMULTIPLE’
EXPORTING
COAREA = LV_COAREA
* TESTRUN = ”
* LANGUAGE = LS_LANGUAGE
TABLES
ACTIVITYTYPELIST = LT_ACTIVITYTYPELIST
RETURN = LT_RETURN
* EXTENSIONIN = LT_EXTENSIONIN
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.

About me:

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》