Skip to Content
0
Former Member
Feb 27, 2009 at 06:19 AM

Create Cost center using Bapi_costcenter_createmultiple

755 Views

Hi All,

This is the first time that i am working on BAPI.

I have to upload an xcel sheet which has the data of required filds that are needed to create the cost center in tcode KS01.

So my flat file is ready to be used.

I am unable to use the bapi to upload this data and i am also getting a runtime error.

I am posting my code. Please help me out to finish the requirement.

DATA: T_COST TYPE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE,

T_CONT TYPE BAPI0012_GEN-CO_AREA,

T_LIST LIKE BAPI0012_CCINPUTLIST OCCURS 0 WITH HEADER LINE,

T_RETN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.

DATA: V_FILE like IBIPPARMS-PATH,

v_field like DYNPREAD-FIELDNAME,

v_file1 like RLGRAP-FILENAME.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

FIELD_NAME = v_field

IMPORTING

FILE_NAME = v_FILE

.

v_file1 = v_file.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = V_FILE1

i_begin_col = 1

i_begin_row = 2

i_end_col = 8

i_end_row = 3

tables

intern = T_COST

EXCEPTIONS

INCONSISTENT_PARAMETERS = 1

UPLOAD_OLE = 2

OTHERS = 3 .

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'BAPI_COSTCENTER_CREATEMULTIPLE'

EXPORTING

controllingarea = T_CONT

  • TESTRUN = ' '

  • MASTER_DATA_INACTIVE = ' '

LANGUAGE = sy-langu

tables

costcenterlist = T_LIST

return = T_RETN

  • EXTENSIONIN =

  • EXTENSIONOUT =

.

LOOP AT T_RETN.

WRITE:/ T_RETN-MESSAGE.

ENDLOOP.

Regards,

Darpana