Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BOM Creation - CS01

Former Member
0 Likes
685

Hi all.

i need to write a BDC for creating BOM. are there any BAPI

available.untill now i came across two :

BAPI_BOM_UPLOAD_SAVE

BAPI_MATERIAL_BOM_GROUP_CREATE

Which one is the apt one or is it better to do bdc?

Thanks,

kavitha

Hi all.

i need to write a BDC for creating BOM. are there any BAPI

available.untill now i came across two :

BAPI_BOM_UPLOAD_SAVE

BAPI_MATERIAL_BOM_GROUP_CREATE

Which one is the apt one or is it better to do bdc?

Thanks,

kavitha

2 REPLIES 2
Read only

Former Member
0 Likes
620

Hi,

CSAP_MAT_BOM_CREATE This Function module.

Sample Code...

* BOM header

DATA: BEGIN OF tstko.

INCLUDE STRUCTURE stko_api01.

DATA: END OF tstko.

* BOM item

DATA: BEGIN OF tstpo OCCURS 0.

INCLUDE STRUCTURE stpo_api01.

DATA: END OF tstpo.

* BOMs: Basic Data of a Dependency

DATA: BEGIN OF tdep_data OCCURS 0.

INCLUDE STRUCTURE csdep_dat.

DATA: END OF tdep_data.

* BOMs: Object Dependency Descriptions

DATA: BEGIN OF tdep_descr OCCURS 0.

INCLUDE STRUCTURE csdep_desc.

DATA: END OF tdep_descr.

* BOMs: Source Code of Object Dependencies

DATA: BEGIN OF tdep_source OCCURS 0.

INCLUDE STRUCTURE csdep_sorc.

DATA: END OF tdep_source.

* BOMs: Sort Sequence of Object Dependencies

DATA: BEGIN OF tdep_order OCCURS 0.

INCLUDE STRUCTURE csdep_ord.

DATA: END OF tdep_order.

* BOMs: Object Dependency Documentation

DATA: BEGIN OF tdep_doc OCCURS 0.

INCLUDE STRUCTURE csdep_doc.

DATA: END OF tdep_doc.

DATA: flg_warning LIKE capiflag-flwarning.

DATA: counter TYPE i,

itemno(4) TYPE n,

matnr LIKE csap_mbom-matnr,

werks LIKE csap_mbom-werks,

usage LIKE csap_mbom-stlan,

date LIKE csap_mbom-datuv.

* CA APIs for Logging

CALL FUNCTION 'CALO_INIT_API'

EXCEPTIONS

log_object_not_found = 1

log_sub_object_not_found = 2

other_error = 3

OTHERS = 4.

* delete extra unnecessary lines

DELETE t_bom_tab WHERE matnr = space.

DELETE t_bom_tab WHERE qty = 0 AND stock = c_l.

SORT t_bom_tab BY matnr.

* header data

tstko-base_quan = '1.000'.

LOOP AT t_bom_tab INTO s_bom_rec.

at new matnr.

CLEAR: tstpo.

REFRESH: tstpo.

MOVE s_bom_rec-matnr TO matnr.

MOVE s_bom_rec-werks TO werks.

move s_bom_rec-usage to usage.

move sy-datum to date.

CLEAR: counter.

endat.

* item data

CLEAR tstpo.

ADD 1 TO counter.

itemno = counter * 10.

tstpo-item_no = itemno.

tstpo-item_categ = s_bom_rec-stock.

tstpo-component = s_bom_rec-compo.

IF s_bom_rec-qty = 0.

* DIEN materials

tstpo-comp_qty = c_qty.

ELSE.

tstpo-comp_qty = s_bom_rec-qty.

ENDIF.

tstpo-comp_unit = s_bom_rec-meins.

APPEND tstpo.

AT END OF matnr.

CLEAR: s_log_rec.

CALL FUNCTION 'CSAP_MAT_BOM_CREATE'

EXPORTING

material = matnr

plant = werks

bom_usage = usage

valid_from = date

i_stko = tstko

IMPORTING

fl_warning = flg_warning

TABLES

t_stpo = tstpo

* t_dep_data = tdep_data

* t_dep_descr = tdep_descr

* t_dep_source = tdep_source

* t_dep_order = tdep_order

* t_dep_doc = tdep_doc

EXCEPTIONS

error = 1.

Commit Work.

Reward if usefull............

Thanks,

Durai.V

Read only

Former Member
0 Likes
620

chk this