Skip to Content

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

BDC Issue

Hi All,

I have issue in BDC.

In a program i am doing BDC for MM01 using call transaction method.

In this multiple materials will be processed.

After that i need to pass these material no's generated & other flatfile data into BDC of CS01.

Now issue over here is after creating materials when i am passing first material to CS01 it is taking last material no as default.

How to avoid this situation, Though my BDCDATA table shows first material it is showing last material created in CS01.

Ex: I will get 3 records from flat file, Then i will loop at these data and pass the same to MM01 TCode. Then 3 materials 148, 149, 150 are created.

Then i will loop at these material and pass recording data with first material to CS01 TCode. but in CS01 it is showing lat created material 150 though BDCDATA has 148 as material. How to rectify this issue!

I am using CALL Transaction method for both the TCodes.

Thanks in advance.

Thanks,

Deep.

Former Member
replied

Deep,

After MM01 upload, use the FM 'CS_BI_BOM_CREATE_BATCH_INPUT1' to create BOM. See below code for reference... should help

*--- creating BOM using FUNCTION 'CS_BI_BOM_CREATE_BATCH_INPUT1'

loop at it_data2. (Containing materials created in the first upload - MM01)

perform create_bom.

endloop.

Reward if helpful,

Karthik

&----


*& Form create_bom

&----


FORM create_bom .

DATA:

x_msgid LIKE sy-msgid,

x_msgno LIKE t100-msgnr,

x_msgty LIKE sy-msgty,

x_msgv1 LIKE sy-msgv1,

x_msgv2 LIKE sy-msgv2,

x_msgv3 LIKE sy-msgv3,

x_msgv4 LIKE sy-msgv4.

DATA: x_bgr00 LIKE bgr00.

  • Local declarations

DATA: bom_header LIKE bicsk.

DATA: BEGIN OF bom_items OCCURS 0.

INCLUDE STRUCTURE bicsp.

DATA: END OF bom_items.

*--- new addition by Karthik

DATA: BEGIN OF BOM_SUBITEMS OCCURS 0.

INCLUDE STRUCTURE BICSU.

DATA: END OF BOM_SUBITEMS.

*--- end of addition

DATA: BEGIN OF j_3a_size_item OCCURS 0.

INCLUDE STRUCTURE j_3abombi.

DATA: END OF j_3a_size_item.

  • Fill batch input structure CLBGR00 for session data

MOVE:

'0' TO x_bgr00-stype,

'TESTBOM' TO x_bgr00-group,

sy-mandt TO x_bgr00-mandt,

sy-uname TO x_bgr00-usnam,

'X' TO x_bgr00-xkeep,

' ' TO x_bgr00-nodata.

  • set material bom key data

WRITE '1' TO bom_header-stype.

WRITE 'CS01' TO bom_header-tcode.

bom_header-matnr = it_data2-matnr.

bom_header-werks = '0001'.

bom_header-stlan = '5'.

WRITE sy-datum TO bom_header-datuv.

bom_header-bmeng = '1'.

bom_header-exstl = ' '.

bom_header-stlst = '1'.

  • no ext.ID given, use internal ID (STPO)

bom_items-stype = '2'.

bom_items-xline = '1'.

bom_items-postp = 'L'.

bom_items-idnrk = it_data2-matnr2.

bom_items-menge = '1'.

bom_items-meins = 'PAA'.

bom_items-rvrel = 'X'.

bom_items-auskz = 'X'.

APPEND bom_items.

DATA: item_count2 LIKE sy-tabix.

ADD 1 TO item_count2.

  • BOM-Item-Size_Data

*--- Looping at it_zpackcode to get BOM-item data

loop at it_zpackcode.

j_3a_size_item-stype = '3'.

j_3a_size_item-j_3apgnr = it_zpackcode-matgrid.

j_3a_size_item-j_3akordx = it_zpackcode-gridsize.

j_3a_size_item-j_3akordxl = it_zpackcode-packcode.

j_3a_size_item-menge = it_zpackcode-quantity.

j_3a_size_item-xline = '1'.

APPEND j_3a_size_item.

clear j_3a_size_item.

endloop.

  • Create BOM

CALL FUNCTION 'CS_BI_BOM_CREATE_BATCH_INPUT1'

EXPORTING

bom_header = bom_header

group_data = x_bgr00

  • commit_work = 'X'

tcode_mode = 'A'

IMPORTING

msgid = x_msgid

msgno = x_msgno

msgty = x_msgty

msgv1 = x_msgv1

msgv2 = x_msgv2

msgv3 = x_msgv3

msgv4 = x_msgv4

TABLES

bom_item = bom_items

*--- added by karthik

BOM_SUB_ITEM = BOM_SUBITEMS

*--- end of addition

j_3a_size_item = j_3a_size_item

EXCEPTIONS

OTHERS = 1.

IF x_msgty = 'E' OR sy-subrc <> 0.

MESSAGE ID x_msgid TYPE 'I' NUMBER x_msgno

DISPLAY LIKE 'E'

WITH x_msgv1 x_msgv2 x_msgv3 x_msgv4.

*--- to format error data if BOM creation is unsuccessful

PERFORM format_error_data2.

*--- Perform to process errors

PERFORM error_processing2.

elseif sy-subrc = 0.

v_success2 = v_success2 + 1.

*--- to prevent from creating alternative BOMs

PERFORM check_bom.

IF sy-subrc = 0.

CLEAR v_comment2.

v_comment2 = 'BOM for Musical successfully created' .

ELSE.

CLEAR v_comment2.

v_comment2 = 'BOM for Musical not created' .

ENDIF.

ENDIF.

ENDFORM. " create_bom

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question