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 Delete....

Former Member
0 Likes
1,724

Hi Friends,

I am using a function module CSAI_BOM_DELETE to delete a Material BOM for a specific plant. But if the BOM number is same for a material for different plants, then all the combinations are being deleted. We need to delete only the BOM for a material and Plant combination. The BOM should not get deleted for other Plants. Please help me out in this.

Thanx in advance,

Ram

7 REPLIES 7
Read only

Former Member
0 Likes
1,244

You can delete BOM specific to a plant by populating field ECSIN-WERKS with the palnt no you want in the same FM 'CSAI_BOM_DELETE'.

Check this out.

Thanks

Read only

0 Likes
1,244

Hi Rahul,

Though I am passing that field, still it deletes the BOM for other plants also if the BOM number is same.

Read only

Former Member
0 Likes
1,244

Hi Ram,

By using CS02 transaction you can delete BOM for a specific Material Number, BOM Usage, Valid-From date, Plant and Alternative BOM....

You need to write BDC for this...i hav atteched here is the code for that.....

TYPES :

BEGIN OF ty_bom,

matnr TYPE matnr, "Material Number

stlan TYPE stlan, "BOM Usage

datuv(10) TYPE c, “Valid-From date

werks TYPE werks, "Plant

stlal TYPE stlal, "Alternative BOM

END OF ty_bom.

DATA:

  • Internal Table to hold all records from source file

i_mast

TYPE STANDARD TABLE OF ty_bom INITIAL SIZE 0.

DATA:

  • Declaring work area for material master

wa_mast TYPE ty_bom.

*local

DATA: l_ws_path TYPE string.

--


Selection Screen--

PARAMETERS : p_path1 LIKE rlgrap-filename .

  • BDC Include

INCLUDE bdcrecx1.

--


At Selection-Screen--

*F4 Functionality for Source file

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path1.

PERFORM sub_get_file CHANGING p_path1.

************************************************************************

--


Start of Selection--

START-OF-SELECTION .

  • To upload source file

PERFORM upload_file.

  • To open bdc session.

PERFORM open_group.

  • To perform bdc steps

PERFORM process_record.

&----


*& Form upload_file

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM upload_file .

  • Source file name is mandatory

IF p_path1 IS INITIAL.

MESSAGE I001 WITH TEXT-002.

LEAVE LIST-PROCESSING .

ENDIF.

  • Upload source file from presentation server

l_ws_path = p_path1.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = l_ws_path

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = '#'

tables

data_tab = i_mast

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17.

IF sy-subrc <> 0.

MESSAGE e001(rlb) WITH text-001.

LEAVE LIST-PROCESSING .

ENDIF.

ENDFORM. " upload_file

&----


*& Form process_record

&----


  • Subroutine to Perform BDC actions

----


  • None

----


FORM process_record .

LOOP AT i_mast into wa_mast.

PERFORM bdc_dynpro USING 'SAPLCSDI' '0100'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'RC29N-MATNR'

wa_mast-matnr.

PERFORM bdc_field USING 'RC29N-STLAN'

wa_mast-stlan.

PERFORM bdc_field USING 'RC29N-DATUV'

wa_mast-datuv.

PERFORM bdc_field USING 'RC29N-WERKS'

wa_mast-werks.

PERFORM bdc_field USING 'RC29N-STLAL'

wa_mast-stlal.

PERFORM bdc_dynpro USING 'SAPLCSDI' '0150'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=FCLO'.

PERFORM bdc_transaction USING 'CS02'.

CLEAR wa_mast.

ENDLOOP.

PERFORM close_group.

ENDFORM. " process_record

&----


*& Form sub_get_file

&----


  • Subroutine to add the F4 Functionality

----


FORM sub_get_file CHANGING p_file.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = syst-cprog

dynpro_number = syst-dynnr

field_name = ' '

IMPORTING

file_name = p_file.

ENDFORM. " sub_get_file

Hope this will solve your issue.....

Thanks,

Shilpa K

Read only

0 Likes
1,244

Hi Shilpa,

I dont have authorization to use CS02 transaction... I should go for some function module only.

Read only

0 Likes
1,244

Hi,

If you have authorization to SE38 then you can write the code given by me..

create flat file with tab delimited data and run your code..it will create BDC session you can process that session in sm35 using forground mode.....

just try this in your devlpment server...........

Read only

0 Likes
1,244

Hi Shilpa,

actually when i am running cs02 transaction, it throws an error saying ECR/ECO is not maintained and stops the process. So when i write the BDC, I guess i will encounter the same problem.

Read only

Former Member
0 Likes
1,244

Hi,

For CS02 transaction the FM used to delete BOM is 'CS_BT_BOM_DELETE' and plant variable is 'I_STZUB-WRKAN'. Try using this FM.

Thanks.