Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Problem in BAPI_TRANSACTION_COMMIT

Given below is the code for creating multiple cost centre and updating in database using BAPI.everything goes fine but the database table is not being updated. Can someone plz tell me what is the problem in the code and the solution for it.

REPORT ZF_BAPI_COST_CENTER.

Data: begin of it_tab occurs 0,

text(255),

end of it_tab.

Data: it_cost type table of bapi0012_ccinputlist.

Data: wa_cost type bapi0012_ccinputlist.

Data: it_return type table of bapiret2 with header line.

Data: it_return1 type table of bapiret2.

PARAMETERS:p_file TYPE rlgrap-filename OBLIGATORY.

Parameters:co_area type A027-kokrs.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

field_name = 'P_FILE'

IMPORTING

file_name = p_file.

Start-of-selection.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\Documentsand Settings\rk49895\Desktop\data.txt'

  • FILETYPE = 'ASC'

  • HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = it_tab

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

ENDIF.

Loop at it_tab.

split it_tab-text at ',' into wa_cost-costcenter

wa_cost-valid_from

wa_cost-valid_to

wa_cost-name

wa_cost-person_in_charge

wa_cost-department

wa_cost-costcenter_type

wa_cost-costctr_hier_grp

wa_cost-comp_code

wa_cost-bus_area

wa_cost-currency.

append wa_cost to it_cost.

CALL FUNCTION 'BAPI_COSTCENTER_CREATEMULTIPLE'

EXPORTING

CONTROLLINGAREA = co_area

  • TESTRUN = ' '

  • MASTER_DATA_INACTIVE = ' '

  • LANGUAGE =

TABLES

COSTCENTERLIST = it_cost

RETURN = it_return

  • EXTENSIONIN =

  • EXTENSIONOUT =

.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

  • EXPORTING

  • WAIT = ' '.

  • IMPORTING

  • RETURN = ' '.

Endloop.

Former Member
Not what you were looking for? View more on this topic or Ask a question