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

Need help regarding BAPI for CS01

Former Member
0 Likes
1,305

Hi Gurus,

My requirement is to create a new BOM by copying from an existing BOM using CS01.

So is there any standard BAPI for this?

Please help.

Thanks,

Srimanta Gupta

8 REPLIES 8
Read only

GauthamV
Active Contributor
0 Likes
990

Check these bapi.

BAPI_MATERIAL_BOM_GROUP_CREATE

CSAI_BOM_MAINTAIN

CSAP_MAT_BOM_CREATE.

Read only

Former Member
0 Likes
990

Hi Gupta,

See the sample code for bapi-bom.

REPORT ZNAV_CREATE_SIMPLEBOM.

  • This code will create a material BoM for the material

  • MAINMATERIAL with the components COMPON1 and COMPON2.

  • Data Declaration

DATA:

it_bomgroup LIKE bapi1080_bgr_c OCCURS 0 WITH HEADER LINE,

it_variants LIKE bapi1080_bom_c OCCURS 0 WITH HEADER LINE,

it_items LIKE bapi1080_itm_c OCCURS 0 WITH HEADER LINE,

it_matrel LIKE bapi1080_mbm_c OCCURS 0 WITH HEADER LINE,

it_itemas LIKE bapi1080_rel_itm_bom_c OCCURS 0 WITH HEADER LINE,

it_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

  • Fill the data

  • Material BoM Group Header Data

CLEAR it_bomgroup.

it_bomgroup-bom_group_identification = 'BAPI_SMP_COL1'.

it_bomgroup-object_type = 'BGR'.

it_bomgroup-object_id = 'SIMPLE1'.

it_bomgroup-bom_usage = '5'. " YOU COULD CHANGE THE BOM USAGE TO YOUR

NEEDS

it_bomgroup-ltxt_lang = sy-langu.

it_bomgroup-technical_type = ' '.

it_bomgroup-bom_text = 'Simple BoM - FM'.

APPEND it_bomgroup.

  • Header Details of the different variants

CLEAR it_variants.

it_variants-bom_group_identification = 'BAPI_SMP_COL1'.

it_variants-object_type = 'BOM'.

it_variants-object_id = 'SIMPLE1'.

it_variants-alternative_bom = '01'.

it_variants-bom_status = '01'.

it_variants-base_qty = '1.000'.

it_variants-valid_from_date = sy-datum.

it_variants-function = 'NEW'.

APPEND it_variants.

  • Details of the items of the variants

CLEAR it_items.

it_items-bom_group_identification = 'BAPI_SMP_COL1'.

it_items-object_type = 'ITM'.

it_items-object_id = 'SIMPLE1'.

it_items-item_no = '0010'.

it_items-item_cat = 'L'.

it_items-component = 'COMPON1'.

it_items-comp_qty = '2'.

it_items-valid_from_date = sy-datum.

APPEND it_items.

CLEAR it_items.

it_items-bom_group_identification = 'BAPI_SMP_COL1'.

it_items-object_type = 'ITM'.

it_items-object_id = 'SIMPLE1'.

it_items-item_no = '0020'.

it_items-item_cat = 'L'.

it_items-component = 'COMPON2'.

it_items-comp_qty = '3'.

it_items-valid_from_date = sy-datum.

APPEND it_items.

  • Details of the materials of the different variants

CLEAR it_matrel.

it_matrel-bom_group_identification = 'BAPI_SMP_COL1'.

it_matrel-material = 'MAINMATERIAL'.

it_matrel-bom_usage = '5'.

it_matrel-alternative_bom = '01'.

APPEND it_matrel.

  • Linking items to the corresponding variants

CLEAR it_itemas.

it_itemas-bom_group_identification = 'BAPI_SMP_COL1'.

it_itemas-sub_object_type = 'ITM'.

it_itemas-sub_object_id = 'SIMPLE1'.

it_itemas-super_object_type = 'BOM'.

it_itemas-super_object_id = 'SIMPLE1'.

it_itemas-valid_from_date = sy-datum.

it_itemas-function = 'NEW'.

APPEND it_itemas.

  • Create variants

CALL FUNCTION ''BAPI_MATERIAL_BOM_GROUP_CREATE'

EXPORTING

all_error = 'X'

TABLES

bomgroup = it_bomgroup

variants = it_variants

items = it_items

materialrelations = it_matrel

itemassignments = it_itemas

return = it_return.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

LOOP AT it_return.

WRITE:/ it_return-type, it_return-id, it_return-number,

it_return-message.

ENDLOOP.

Read only

Former Member
0 Likes
990

Hi Naveen,

I think the code you have given is for BOM group creation. My requirement is BOM creation. New BOM will be created by copying all the items from an eisting BOM.

Thanks,

Srimanta

Edited by: Srimanta Gupta on May 11, 2009 7:02 AM

Read only

0 Likes
990

Hi Rajesh,

Are you talking about BADI or BAPI,,,, I am bit confused.

Hi Srimantha,

You can write a simple BDC Program for this, record first and copy the code from recodring, Its a easy process,

Once I done the same for a 19 level BOM in 12 Hrs, you can achieve with Recording method.

Thanks & regards,

Dileep .C

Read only

Former Member
0 Likes
990

Hi

use the following steps to find a BAPI for any transaction

1.Open transaction SE24.

2.Now open the object CL_EXITHANDLER in display mode.

3.Go to the method tab and double click on the method GET_INSTANCE.

4.Put a break point on cl_exithandler=>get_class_name_by_interface.

5.Now execute the transaction you want to find BAPI for, it will take you to the above method.

6.Write EXIT_HANDLER in fieldnames and hit enter, it will tell you the BAPI used for your transaction.

7.Hit F8 and it will tell you all the BAPIu2019s for your transaction.

Regards

Rajesh Kumar

Read only

Former Member
0 Likes
990

Hi Dileep,

Thanks for your reply. At first i thought for going with BDC. Then i thought it will be great if i can get any BAPI for this. I will try to find out BAPI first or you people can help me. Otherwise BDC is the last option.

Once again thanks for your answer.

Srimanta.

Read only

0 Likes
990

Hi,

Why not try to search in SE37, or you can try this one.

CS_CL_S_MAT_BOM_CREATE_BY_COPY

Hope this helps,

Leonard Chomi

Read only

Former Member
0 Likes
990

ok