Creation of IBASE (TA IB51) with ABAP
Posted: Sep 29, 2005 8:47 AM Reply E-mail this post
Hello all,
i want to create an IBASE with Instances (Materials) with Abap.
It is possible to create the IBASE but not to create the instances. I have always an empty IBASE without materials.
Can anybody help me
Thanks a lot
Markus
Here is my coding:
type-pools ibin .
type-pools IBCO2.
data: ibib_handle type i.
data: E_IBASE_REC TYPE IBCO2_IBASE_REC.
data: I_IBIB1 LIKE IBIB1.
data: I_IBIBT1 LIKE IBIBT1.
data: matobject type ref to cl_ibase_r3_material.
data: i_PROCESS_REC TYPE IBXX_PROCESS_REC.
data: C_INSTANCE_TAB TYPE IBCO1_INST_TAB1.
data: c_inst_struct type ibco1_inst_rec1.
CALL FUNCTION 'IB_COM_NEW'
IMPORTING
E_IBCO_HANDLE = ibib_handle.
CALL FUNCTION 'IB_COM2_CREATE_IBASE'
EXPORTING
I_IBCO_HANDLE = ibib_handle
I_IBTYP = 'Y1'
IMPORTING
E_IBASE_REC = E_IBASE_REC
EXCEPTIONS
IB_HANDLE_NOT_DEFINED = 1
OTHERS = 2.
clear: i_ibib1, i_ibibt1.
move-corresponding e_ibase_rec-com to i_ibib1.
move-corresponding e_ibase_rec-conf to i_ibib1.
i_ibib1-ibase = e_ibase_rec-ibase.
i_ibib1-extid = 'externer Name'.
*i_ibib1-authg = 'E001'.
i_ibibt1-ibase = e_ibase_rec-ibase.
i_ibibt1-langu = sy-langu.
i_ibibt1-descr = 'Beschreibung'.
CALL FUNCTION 'IB_COM1_CHANGE_IBASE_ONLY'
EXPORTING
I_IBCO_HANDLE = ibib_handle
I_IBIB1 = i_ibib1
I_IBIBT1 = i_ibibt1
EXCEPTIONS
IB_HANDLE_NOT_DEFINED = 1
OTHERS = 2.
.
create object matobject exporting i_matnr = '000000000000602028'.
clear i_process_rec.
i_process_rec-activity = '1'.
i_process_rec-ind_valfr = 'X'.
i_process_rec-ind_valto = 'X'.
i_process_rec-ind_sortf = 'X'.
i_process_rec-ind_amount = 'X'.
i_process_rec-ind_unit = 'X'.
i_process_rec-ind_objtyp = 'X'.
i_process_rec-ind_objid = 'X'.
i_process_rec-ind_serno = 'X'.
i_process_rec-ind_plant = 'X'.
i_process_rec-ind_batch = 'X'.
i_process_rec-ind_revlv = 'X'.
i_process_rec-ind_deviceid = 'X'.
i_process_rec-ind_posno = 'X'.
refresh c_instance_tab.
c_inst_struct-val-valfr = '20050929080000'.
c_inst_struct-val-valto = '99991231235959'.
c_inst_struct-com-amount = 1.
c_inst_struct-com-unit = 'ST'.
c_inst_struct-objtyp = '0002'.
c_inst_struct-object = matobject.
INSERT c_inst_struct INTO TABLE c_instance_tab.
CALL FUNCTION 'IB_COM1_PROCESS_INSTANCE'
EXPORTING
I_IBCO_HANDLE = ibib_handle
I_IBASE = e_ibase_rec-ibase
i_moment = '20050929080000'
I_PROCESS_REC = i_process_rec
CHANGING
C_INSTANCE_TAB = c_instance_tab
EXCEPTIONS
IB_HANDLE_NOT_DEFINED = 1
IB_NO_ACTIVITY = 2
IB_NOTHING_PROCESSED = 3
IB_INCONSISTEND_DATA = 4
IB_INSTALL_NOT_ALLOWED = 5
OTHERS = 6.
CALL FUNCTION 'IB_COM_SAVE_AND_FREE'
EXPORTING
I_IBCO_HANDLE = ibib_handle
EXCEPTIONS
IB_HANDLE_NOT_DEFINED = 1
IB_NOT_SUCCESSFUL = 2
OTHERS = 3
.
write: e_ibase_rec-ibase.
commit work.