目录
一、程序源代码
*&---------------------------------------------------------------------*
*& Report ZBAPI003
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZBAPI003.
TYPE-POOLS: ICON.
TYPE-POOLS SLIS.
TABLES SSCRFIELDS.
SELECTION-SCREEN BEGIN OF BLOCK SCR1 WITH FRAME TITLE TEXT-001.
PARAMETERS: P_PATH TYPE STRING
DEFAULT 'D:\ZDATA.txt' OBLIGATORY.
SELECTION-SCREEN END OF BLOCK SCR1.
TYPES: BEGIN OF ST_TXT,
KOKRS TYPE CHAR4, "控制范围
LSTAR TYPE CHAR10, "作业类型
DATAB TYPE CHAR8, "开始时间
DATBI TYPE CHAR8, "结束时间
NAME TYPE CHAR20, "名称
DESCRIPT TYPE CHAR40, "描述
LEINH TYPE CHAR3, "作业单位
KSTTY TYPE CHAR8, "成本中心类型
LATYP TYPE CHAR1, "作业类型类别
VKSTA TYPE CHAR10, "分配成本要素
TARKZ TYPE CHAR3, "价格标志
LATYPI TYPE CHAR1, "实际活动类型类别
TARKZ_I TYPE CHAR1, "实际价格标志
ICON TYPE ICON-NAME,
ZSEL TYPE CHAR1,
TYPE TYPE CHAR1,
MESSAGE TYPE CHAR255,
END OF ST_TXT.
DATA: WA_TXT TYPE ST_TXT,
IT_TXT LIKE TABLE OF WA_TXT.
DATA: G_TYPE TYPE C.
DATA: G_MSTRING(480).
TYPE-POOLS: ICON.
TYPE-POOLS SLIS.
DATA: IS_LAYOUT TYPE SLIS_LAYOUT_ALV, "ALV输出样式
IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV, "ALV输出的头项目(内表)
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV, "ALV输出的头项目(工作区)
WA_REPID LIKE SY-REPID. "程序名
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_PATH.
PERFORM GET_PC_FILENAME.
START-OF-SELECTION.
PERFORM UPLOAD_FILE.
LOOP AT IT_TXT INTO WA_TXT.
WA_TXT-ZSEL = 'X'.
MODIFY IT_TXT FROM WA_TXT TRANSPORTING ZSEL.
ENDLOOP.
PERFORM FRM_DO_BAPI.
END-OF-SELECTION.
PERFORM FRM_SHOW_DATA.
*&---------------------------------------------------------------------*
*& Form GET_PC_FILENAME
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_PC_FILENAME .
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
MASK = '文本文件,*.txt.'
MODE = 'O'
IMPORTING
FILENAME = P_PATH
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
IF SY-SUBRC NE 0 AND SY-SUBRC NE 3.
MESSAGE '请输入有效的文件名!' TYPE 'E'.
ENDIF.
ENDFORM. " GET_PC_FILENAME
*&---------------------------------------------------------------------*
*& Form UPLOAD_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UPLOAD_FILE .
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = P_PATH
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* VIRUS_SCAN_PROFILE =
* IMPORTING
* FILELENGTH = UP_COUNT
* HEADER =
TABLES
DATA_TAB = IT_TXT
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
IF IT_TXT IS INITIAL.
MESSAGE '上载数据为空' TYPE 'E'.
ELSE.
DELETE IT_TXT INDEX 1.
IF IT_TXT IS INITIAL.
MESSAGE '上载数据为空' TYPE 'E'.
ELSE.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " UPLOAD_FILE
*&---------------------------------------------------------------------*
*& Form FRM_SHOW_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_SHOW_DATA .
WA_REPID = SY-REPID. "得到程序名
IS_LAYOUT-ZEBRA = 'X'. "颜色相间显示
IS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'. "优化列宽选项
IS_LAYOUT-BOX_FIELDNAME = 'ZSEL'.
DATA: DE_POS TYPE I.
DE_POS = DE_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = DE_POS.
* WA_FIELDCAT-KEY = 'X'.
WA_FIELDCAT-FIELDNAME = 'ICON'.
WA_FIELDCAT-ICON = 'X'.
WA_FIELDCAT-SELTEXT_L = ''.
WA_FIELDCAT-SELTEXT_M = ''.
WA_FIELDCAT-SELTEXT_S = ''.
WA_FIELDCAT-DDICTXT = 'L'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
DE_POS = DE_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = DE_POS.
* WA_FIELDCAT-KEY = 'X'.
WA_FIELDCAT-FIELDNAME = 'KOKRS'.
WA_FIELDCAT-REF_TABNAME = ''.
WA_FIELDCAT-REF_FIELDNAME = ''.
WA_FIELDCAT-SELTEXT_L = '控制范围'.
WA_FIELDCAT-SELTEXT_M = '控制范围'.
WA_FIELDCAT-SELTEXT_S = '控制范围'.
WA_FIELDCAT-DDICTXT = 'L'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
DE_POS = DE_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = DE_POS.
* WA_FIELDCAT-KEY = 'X'.
WA_FIELDCAT-FIELDNAME = 'LSTAR'.
WA_FIELDCAT-REF_TABNAME = ''.
WA_FIELDCAT-REF_FIELDNAME = ''.
WA_FIELDCAT-SELTEXT_L = '作业类型'.
WA_FIELDCAT-SELTEXT_M = '作业类型'.
WA_FIELDCAT-SELTEXT_S = '作业类型'.
WA_FIELDCAT-DDICTXT = 'L'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
DE_POS = DE_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = DE_POS.
* WA_FIELDCAT-KEY = 'X'.
WA_FIELDCAT-FIELDNAME = 'DATAB'.
WA_FIELDCAT-REF_TABNAME = ''.
WA_FIELDCAT-REF_FIELDNAME = ''.
WA_FIELDCAT-SELTEXT_L = '开始时间'.
WA_FIELDCAT-SELTEXT_M = '开始时间'.
WA_FIELDCAT-SELTEXT_S = '开始时间'.
WA_FIELDCAT-DDICTXT = 'L'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
DE_POS = DE_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = DE_POS.
* WA_FIELDCAT-KEY = 'X'.
WA_FIELDCAT-FIELDNAME = 'DATBI'.
WA_FIELDCAT-REF_TABNAME = ''.
WA_FIELDCAT-REF_FIELDNAME = ''.
WA_FIELDCAT-SELTEXT_L = '结束时间'.
WA_FIELDCAT-SELTEXT_M = '结束时间'.
WA_FIELDCAT-SELTEXT_S = '结束时间'.
WA_FIELDCAT-DDICTXT = 'L'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
DE_POS = DE_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = DE_POS.
* WA_FIELDCAT-KEY = 'X'.
WA_FIELDCAT-FIELDNAME = 'NAME'.
WA_FIELDCAT-REF_TABNAME = ''.
WA_FIELDCAT-REF_FIELDNAME = ''.
WA_FIELDCAT-SELTEXT_L = '名称'.
WA_FIELDCAT-SELTEXT_M = '名称'.
WA_FIELDCAT-SELTEXT_S = '名称'.
WA_FIELDCAT-DDICTXT = 'L'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
DE_POS = DE_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = DE_POS.
* WA_FIELDCAT-KEY = 'X'.
WA_FIELDCAT-FIELDNAME = 'DESCRIPT'.
WA_FIELDCAT-REF_TABNAME = ''.
WA_FIELDCAT-REF_FIELDNAME = ''.
WA_FIELDCAT-SELTEXT_L = '描述'.
WA_FIELDCAT-SELTEXT_M = '描述'.
WA_FIELDCAT-SELTEXT_S = '描述'.
WA_FIELDCAT-DDICTXT = 'L'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
DE_POS = DE_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = DE_POS.
* WA_FIELDCAT-KEY = 'X'.
WA_FIELDCAT-FIELDNAME = 'LEINH'.
WA_FIELDCAT-REF_TABNAME = ''.
WA_FIELDCAT-REF_FIELDNAME = ''.
WA_FIELDCAT-SELTEXT_L = '作业单位'.
WA_FIELDCAT-SELTEXT_M = '作业单位'.
WA_FIELDCAT-SELTEXT_S = '作业单位'.
WA_FIELDCAT-DDICTXT = 'L'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
DE_POS = DE_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = DE_POS.
* WA_FIELDCAT-KEY = 'X'.
WA_FIELDCAT-FIELDNAME = 'KSTTY'.
WA_FIELDCAT-REF_TABNAME = ''.
WA_FIELDCAT-REF_FIELDNAME = ''.
WA_FIELDCAT-SELTEXT_L = '成本中心类型'.
WA_FIELDCAT-SELTEXT_M = '成本中心类型'.
WA_FIELDCAT-SELTEXT_S = '成本中心类型'.
WA_FIELDCAT-DDICTXT = 'L'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
DE_POS = DE_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = DE_POS.
* WA_FIELDCAT-KEY = 'X'.
WA_FIELDCAT-FIELDNAME = 'LATYP'.
WA_FIELDCAT-REF_TABNAME = ''.
WA_FIELDCAT-REF_FIELDNAME = ''.
WA_FIELDCAT-SELTEXT_L = '作业类型类别'.
WA_FIELDCAT-SELTEXT_M = '作业类型类别'.
WA_FIELDCAT-SELTEXT_S = '作业类型类别'.
WA_FIELDCAT-DDICTXT = 'L'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
DE_POS = DE_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = DE_POS.
* WA_FIELDCAT-KEY = 'X'.
WA_FIELDCAT-FIELDNAME = 'VKSTA'.
WA_FIELDCAT-REF_TABNAME = ''.
WA_FIELDCAT-REF_FIELDNAME = ''.
WA_FIELDCAT-SELTEXT_L = '分配成本要素'.
WA_FIELDCAT-SELTEXT_M = '分配成本要素'.
WA_FIELDCAT-SELTEXT_S = '分配成本要素'.
WA_FIELDCAT-DDICTXT = 'L'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
DE_POS = DE_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = DE_POS.
* WA_FIELDCAT-KEY = 'X'.
WA_FIELDCAT-FIELDNAME = 'TARKZ'.
WA_FIELDCAT-REF_TABNAME = ''.
WA_FIELDCAT-REF_FIELDNAME = ''.
WA_FIELDCAT-SELTEXT_L = '价格标志'.
WA_FIELDCAT-SELTEXT_M = '价格标志'.
WA_FIELDCAT-SELTEXT_S = '价格标志'.
WA_FIELDCAT-DDICTXT = 'L'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
DE_POS = DE_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = DE_POS.
* WA_FIELDCAT-KEY = 'X'.
WA_FIELDCAT-FIELDNAME = 'LATYPI'.
WA_FIELDCAT-REF_TABNAME = ''.
WA_FIELDCAT-REF_FIELDNAME = ''.
WA_FIELDCAT-SELTEXT_L = '实际活动类型类别'.
WA_FIELDCAT-SELTEXT_M = '实际活动类型类别'.
WA_FIELDCAT-SELTEXT_S = '实际活动类型类别'.
WA_FIELDCAT-DDICTXT = 'L'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
DE_POS = DE_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = DE_POS.
* WA_FIELDCAT-KEY = 'X'.
WA_FIELDCAT-FIELDNAME = 'TARKZ_I'.
WA_FIELDCAT-REF_TABNAME = ''.
WA_FIELDCAT-REF_FIELDNAME = ''.
WA_FIELDCAT-SELTEXT_L = '实际价格标志'.
WA_FIELDCAT-SELTEXT_M = '实际价格标志'.
WA_FIELDCAT-SELTEXT_S = '实际价格标志'.
WA_FIELDCAT-DDICTXT = 'L'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
DE_POS = DE_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = DE_POS.
* WA_FIELDCAT-KEY = 'X'.
WA_FIELDCAT-FIELDNAME = 'ZFIELD'.
WA_FIELDCAT-REF_TABNAME = ''.
WA_FIELDCAT-REF_FIELDNAME = ''.
WA_FIELDCAT-SELTEXT_L = '自定义字段1'.
WA_FIELDCAT-SELTEXT_M = '自定义字段1'.
WA_FIELDCAT-SELTEXT_S = '自定义字段1'.
WA_FIELDCAT-DDICTXT = 'L'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
DE_POS = DE_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = DE_POS.
* WA_FIELDCAT-KEY = 'X'.
WA_FIELDCAT-FIELDNAME = 'TYPE'.
WA_FIELDCAT-REF_TABNAME = ''.
WA_FIELDCAT-REF_FIELDNAME = ''.
WA_FIELDCAT-SELTEXT_L = '消息类型: S 成功,E 错误'.
WA_FIELDCAT-SELTEXT_M = '消息类型: S 成功,E 错误'.
WA_FIELDCAT-SELTEXT_S = '消息类型: S 成功,E 错误'.
WA_FIELDCAT-DDICTXT = 'L'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
DE_POS = DE_POS + 1.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-COL_POS = DE_POS.
* WA_FIELDCAT-KEY = 'X'.
WA_FIELDCAT-FIELDNAME = 'MESSAGE'.
WA_FIELDCAT-REF_TABNAME = ''.
WA_FIELDCAT-REF_FIELDNAME = ''.
WA_FIELDCAT-SELTEXT_L = '消息文本'.
WA_FIELDCAT-SELTEXT_M = '消息文本'.
WA_FIELDCAT-SELTEXT_S = '消息文本'.
WA_FIELDCAT-DDICTXT = 'L'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = WA_REPID
* I_CALLBACK_PF_STATUS_SET = 'SET_STATUS'
* I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
IS_LAYOUT = IS_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_TXT
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " FRM_SHOW_DATA
*&---------------------------------------------------------------------*
*& Form FRM_DO_BDC
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_DO_BAPI .
DATA: COAREA TYPE BAPI1031_GEN-CO_AREA.
DATA: COSTELEMCLASS TYPE BAPI1030_GEN-COST_ELEM_CLS.
DATA: WA_ACTIVITYTYPELIST TYPE BAPI1031_ATINPUTLIST,
IT_ACTIVITYTYPELIST LIKE STANDARD TABLE OF WA_ACTIVITYTYPELIST,
WA_RETURN TYPE BAPIRET2,
IT_RETURN LIKE STANDARD TABLE OF WA_RETURN.
LOOP AT IT_TXT INTO WA_TXT WHERE ZSEL = 'X'.
***********************BAPI执行
CLEAR: G_TYPE,
G_MSTRING.
CLEAR: COAREA,
IT_ACTIVITYTYPELIST,
IT_RETURN.
COAREA = WA_TXT-KOKRS.
CLEAR: WA_ACTIVITYTYPELIST.
WA_ACTIVITYTYPELIST-ACTTYPE = WA_TXT-LSTAR."作业类型
WA_ACTIVITYTYPELIST-VALID_FROM = WA_TXT-DATAB."开始时间
WA_ACTIVITYTYPELIST-VALID_TO = WA_TXT-DATBI."结束时间
WA_ACTIVITYTYPELIST-NAME = WA_TXT-NAME."名称
WA_ACTIVITYTYPELIST-DESCRIPT = WA_TXT-DESCRIPT."描述
WA_ACTIVITYTYPELIST-ACT_UNIT = WA_TXT-LEINH."作业单位
CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'
EXPORTING
INPUT = WA_ACTIVITYTYPELIST-ACT_UNIT
LANGUAGE = SY-LANGU
IMPORTING
OUTPUT = WA_ACTIVITYTYPELIST-ACT_UNIT
EXCEPTIONS
UNIT_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
WA_ACTIVITYTYPELIST-COSTCENTER_CAT = WA_TXT-KSTTY."成本中心类型
WA_ACTIVITYTYPELIST-ACTIVITY_CAT = WA_TXT-LATYP."作业类型类别
WA_ACTIVITYTYPELIST-ALLOC_COST_ELEM = WA_TXT-VKSTA."分配成本要素
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = WA_ACTIVITYTYPELIST-ALLOC_COST_ELEM
IMPORTING
OUTPUT = WA_ACTIVITYTYPELIST-ALLOC_COST_ELEM.
WA_ACTIVITYTYPELIST-PRICE_INDICATOR = WA_TXT-TARKZ."价格标志
WA_ACTIVITYTYPELIST-ACT_CAT_ACTUAL = WA_TXT-LATYPI."实际活动类型类别
WA_ACTIVITYTYPELIST-ACT_PRICE_IND = WA_TXT-TARKZ_I."实际价格标志
APPEND WA_ACTIVITYTYPELIST TO IT_ACTIVITYTYPELIST.
CALL FUNCTION 'BAPI_ACTTYPE_CREATEMULTIPLE'
EXPORTING
COAREA = COAREA
* TESTRUN = ' '
TABLES
ACTIVITYTYPELIST = IT_ACTIVITYTYPELIST
RETURN = IT_RETURN.
READ TABLE IT_RETURN WITH KEY TYPE = 'E'
INTO WA_RETURN.
IF SY-SUBRC = 0.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
* IMPORTING
* RETURN =
.
G_TYPE = 'E'.
MESSAGE ID WA_RETURN-ID TYPE WA_RETURN-TYPE NUMBER WA_RETURN-NUMBER
WITH WA_RETURN-MESSAGE_V1 WA_RETURN-MESSAGE_V2
WA_RETURN-MESSAGE_V3 WA_RETURN-MESSAGE_V4
INTO G_MSTRING.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
* IMPORTING
* RETURN =
.
G_TYPE = 'S'.
READ TABLE IT_RETURN WITH KEY TYPE = 'S'
INTO WA_RETURN.
IF SY-SUBRC = 0.
MESSAGE ID WA_RETURN-ID TYPE WA_RETURN-TYPE NUMBER WA_RETURN-NUMBER
WITH WA_RETURN-MESSAGE_V1 WA_RETURN-MESSAGE_V2
WA_RETURN-MESSAGE_V3 WA_RETURN-MESSAGE_V4
INTO G_MSTRING.
ENDIF.
ENDIF.
WA_TXT-TYPE = G_TYPE.
WA_TXT-MESSAGE = G_MSTRING.
CASE G_TYPE.
WHEN 'S'.
WA_TXT-ICON = ICON_GREEN_LIGHT.
WHEN 'E'.
WA_TXT-ICON = ICON_RED_LIGHT.
WHEN OTHERS.
ENDCASE.
MODIFY IT_TXT FROM WA_TXT TRANSPORTING ICON TYPE MESSAGE.
ENDLOOP.
ENDFORM. " FRM_DO_BDC
二、数据模版
控制范围 | CHEN | CHEN |
作业类型 | ACT10 | ACT20 |
开始时间 | 20230101 | 20230101 |
结束时间 | 99991231 | 99991231 |
名称 | 人工 | 制费 |
描述 | 人工 | 制费 |
作业单位 | MIN | MIN |
成本中心类型 | 1 | 1 |
作业类型类别 | 1 | 1 |
成本要素分配 | 8200100100 | 8200100200 |
价格标志 | 1 | 1 |
实际活动类型类别 | 1 | 1 |
实际价格标志 | 5 | 5 |