Application Development 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: 

Issues with CSAP_MAT_BOM_MAINTAIN

Former Member
0 Kudos
2,865

Hi,

I am having trouble with updating the BOM Status on the header.

I get the FL_WARNING flag set to 'X', and in the export parameter table the status is still not changed.

I pass:

Material: XXX

Plant: XXX

Bom Usage: 1

Alternative: 1

Valid_from (todays date)

i_stko-bom_status

fl_commit_and_wait: X

fl_default_values: X

Where do I go wrong?

Do I need a change number?

Please help me out.

Rgds,

/Fredrik.

9 REPLIES 9

Former Member
0 Kudos
328

Hi Fred

Check out this

[;

Pushpraj

0 Kudos
328

Don't quite solve my issue.

Former Member
0 Kudos
328

LOOP AT i_bom_data INTO wa_bom_data.

MOVE wa_bom_data TO wa_bom_data_temp.

AT NEW matnr.

  • Read the BOM

PERFORM f_read_bom.

  • Translation logic for header

PERFORM f_translate_header_data.

ENDAT.

v_count = v_count + c_1.

  • Check if BOM exist or not

IF v_bom_exist = c_x.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = wa_bom_data_temp-posnr

IMPORTING

output = wa_bom_data_temp-posnr.

  • Check BOM component exist or not

CLEAR wa_stpo.

READ TABLE i_stpo INTO wa_stpo WITH KEY item_categ = c_l

item_no = wa_bom_data_temp-posnr

BINARY SEARCH.

IF sy-subrc IS INITIAL.

  • Translation logic

PERFORM f_translate_item_data USING c_x.

ELSE.

  • Translation logic

PERFORM f_translate_item_data USING space.

ENDIF.

  • If BOM does not exist and has to be created

ELSE.

  • Translation logic

PERFORM f_translate_item_data USING space.

ENDIF.

AT END OF matnr.

CLEAR v_bom_no.

IF v_bom_exist = c_x.

  • Change BOM component

PERFORM f_bom_maintain.

ELSE.

  • Create BOM

PERFORM f_create_bom.

ENDIF.

REFRESH: i_stpo, i_stko_api02, i_stpo_api03.

CLEAR: wa_bom_data_temp, wa_bom_data, wa_stko_api01, wa_stpo_api03, v_bom_no,

v_bom_exist, v_count.

ENDAT.

ENDLOOP.

&----


*& Form F_READ_BOM

&----


  • REad BOM data

----


FORM f_read_bom.

REFRESH: i_stpo, i_stko_api02.

CLEAR: v_bom_exist, v_datuv.

  • Read bom

CALL FUNCTION 'CSAP_MAT_BOM_READ'

EXPORTING

material = wa_bom_data_temp-matnr

plant = c_plant

bom_usage = wa_bom_data_temp-stlan

TABLES

t_stpo = i_stpo

t_stko = i_stko_api02

EXCEPTIONS

error = 1

OTHERS = 2.

IF sy-subrc EQ 0.

v_bom_exist = c_x.

SORT i_stpo BY item_categ item_no component.

CLEAR: wa_stko_api02, v_datuv.

READ TABLE i_stko_api02 INTO wa_stko_api02 INDEX c_1.

IF sy-subrc IS INITIAL.

v_datuv = wa_stko_api02-valid_from.

ENDIF.

ENDIF.

ENDFORM. " F_READ_BOM

&----


*& Form F_TRANSLATE_HEADER_DATA

&----


  • Translate header data

----


FORM f_translate_header_data.

CLEAR wa_stko_api01.

wa_stko_api01-base_quan = c_1.

wa_stko_api01-base_unit = c_ea.

CLEAR wa_mara.

READ TABLE i_mara INTO wa_mara WITH KEY matnr = wa_bom_data_temp-matnr BINARY SEARCH.

IF sy-subrc IS INITIAL.

wa_stko_api01-alt_text = wa_mara-normt.

ENDIF.

wa_stko_api01-bom_text = wa_bom_data_temp-ztext.

IF wa_bom_data_temp-stlst EQ c_y.

wa_stko_api01-bom_status = c_1.

ELSE.

wa_stko_api01-bom_status = c_2.

ENDIF.

ENDFORM. " F_TRANSLATE_HEADER_DATA

&----


*& Form F_VALIDATA_BOM_DATA

&----


  • Validate input data

----


FORM f_translate_item_data USING p_flag.

  • Item data

CLEAR: wa_stpo_api03.

IF p_flag EQ c_x.

wa_stpo_api03-item_no = wa_stpo-item_no.

wa_stpo_api03-id_item_no = wa_stpo-item_no.

ENDIF.

wa_stpo_api03-item_categ = c_l.

wa_stpo_api03-component = wa_bom_data_temp-idnrk.

wa_stpo_api03-comp_qty = wa_bom_data_temp-menge.

wa_stpo_api03-item_no = wa_bom_data_temp-posnr.

IF wa_bom_data-erskz EQ c_n.

wa_stpo_api03-spare_part = c_i.

ELSE.

wa_stpo_api03-spare_part = ' '.

ENDIF.

wa_stpo_api03-ai_group = wa_bom_data_temp-alpgr.

wa_stpo_api03-ai_prio = wa_bom_data_temp-alprf.

IF wa_bom_data-alprf EQ c_1.

wa_stpo_api03-sortstring = c_primary.

ELSEIF wa_bom_data-alprf GT c_1.

wa_stpo_api03-sortstring = c_sub.

ELSEIF wa_bom_data-alprf EQ ' '.

wa_stpo_api03-sortstring = c_stationary.

ENDIF.

wa_stpo_api03-zzmfg_num = wa_bom_data_temp-z_mfg_num.

wa_stpo_api03-zzcru_cat = wa_bom_data_temp-z_cru_cat.

PERFORM f_populate_zfields USING wa_bom_data_temp-z_key_part

CHANGING wa_stpo_api03-zzkey_part.

PERFORM f_populate_zfields USING wa_bom_data_temp-z_optional

CHANGING wa_stpo_api03-zzoptional.

PERFORM f_populate_zfields USING wa_bom_data_temp-z_check_in

CHANGING wa_stpo_api03-zzcheck_in.

PERFORM f_populate_zfields USING wa_bom_data_temp-z_pack_out

CHANGING wa_stpo_api03-zzpack_out.

PERFORM f_populate_zfields USING wa_bom_data_temp-z_charge

CHANGING wa_stpo_api03-zzcharge.

PERFORM f_populate_zfields USING wa_bom_data_temp-z_inst_man

CHANGING wa_stpo_api03-zzinst_man.

wa_stpo_api03-zzdeact_cru = wa_bom_data_temp-z_deact_cru.

APPEND wa_stpo_api03 TO i_stpo_api03.

CLEAR wa_stpo_api03.

ENDFORM. " F_VALIDATA_BOM_DATA

&----


*& Form F_BOM_MAINTAIN

&----


  • Add component or Change component in BOM

----


FORM f_bom_maintain.

  • Add or Change BOM

CALL FUNCTION 'CSAP_MAT_BOM_MAINTAIN'

EXPORTING

material = wa_temp-matnr

plant = c_plant

bom_usage = wa_temp-stlan

valid_from = v_datuv

i_stko = wa_stko_api01

fl_commit_and_wait = c_x

fl_new_item = c_x

TABLES

t_stpo = i_stpo_api03

EXCEPTIONS

error = 1

OTHERS = 2.

IF sy-subrc EQ 0.

CLEAR wa_stpo.

READ TABLE i_stpo INTO wa_stpo INDEX c_1.

IF sy-subrc IS INITIAL.

CLEAR v_bom_no.

v_bom_no = wa_stpo-bom_no.

PERFORM f_success_records.

ENDIF.

ELSE.

CLEAR: wa_temp-posnr, wa_temp-idnrk.

PERFORM f_error_records USING wa_temp text-020.

ENDIF.

ENDFORM. " F_BOM_MAINTAIN

&----


*& Form F_CREATE_BOM

&----


  • Create BOM

----


FORM f_create_bom.

DATA lwa_return LIKE bapiret2.

CLEAR lwa_return.

  • Create BOM

CALL FUNCTION 'CSAP_MAT_BOM_CREATE'

EXPORTING

material = wa_temp-matnr

plant = c_plant

bom_usage = wa_temp-stlan

i_stko = wa_stko_api01

IMPORTING

bom_no = v_bom_no

TABLES

t_stpo = i_stpo_api03

EXCEPTIONS

error = 1

OTHERS = 2.

IF sy-subrc EQ 0.

CLEAR lwa_return.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = c_x

IMPORTING

return = lwa_return.

IF lwa_return-type <> c_e.

PERFORM f_success_records.

  • Extend BOM to plants

PERFORM f_alloc_plat_to_bom.

ELSE.

CLEAR: wa_temp-posnr, wa_temp-idnrk.

PERFORM f_error_records USING wa_temp text-019.

ENDIF.

ELSE.

CLEAR: wa_temp-posnr, wa_temp-idnrk.

PERFORM f_error_records USING wa_temp text-019.

ENDIF.

ENDFORM. " F_CREATE_BOM

&----


*& Form F_ERROR_RECORDS

&----


  • Process error records

----


FORM f_error_records USING p_temp TYPE t_bom_data

p_text.

wa_error-stlan = p_temp-stlan.

wa_error-matnr = p_temp-matnr.

wa_error-posnr = p_temp-posnr.

wa_error-idnrk = p_temp-idnrk.

wa_error-message = p_text.

APPEND wa_error TO i_error.

CLEAR wa_error.

ENDFORM. " F_ERROR_RECORDS

&----


*& Form POPULATE_ZFIELDS

&----


  • text

----


  • -->P_WA_BOM_DATA_Z_KEY_PART text

  • <--P_WA_STPO_API03_ZZKEY_PART text

----


FORM f_populate_zfields USING p_input TYPE c

CHANGING p_output TYPE stpo-zzkey_part.

IF p_input EQ c_y.

p_output = c_x.

ELSE.

CLEAR p_output.

ENDIF.

ENDFORM. " POPULATE_ZFIELDS

Edited by: sugunav on Sep 8, 2009 4:52 PM

0 Kudos
328

Thanks for the code.

Still I don't see any differencies from my code to yours.

Do you get an 'X' in FL_WARNING?

I don't have any items to update, only the BOM Header Status.

0 Kudos
328

please use conversion exit for material.

0 Kudos
328

There is no difference in the material number if I run the conversion_exits (MATN1_INPUT/OUTPUT).

Besides I get the information from the MARA db-table.

0 Kudos
328

YES, I found the problem (or at least now it works).

You need to populate Base unit of measure for BOM and Base quantity (fields BMEIN and BMENG) also in order for the change to work. Tried the GUI also, but it didn't make any difference until I passed these values also.

Great.

Found something in some note that if you only change the status the FM doesn't consider this to be a valid change, maybe this is the reason.

Thank you all for your help.

Former Member
0 Kudos
328

CALL FUNCTION 'CSAP_MAT_BOM_MAINTAIN'


    EXPORTING


      material           = 'Material Number'


      plant              = 'Plant'


      bom_usage          = '1'


      alternative        = 'alt'


      change_no          = 'Change number'


      i_stko             = 'Header details STKO details'


      fl_commit_and_wait = 'X'


      fl_default_values  = 'X'


    TABLES


      t_stpo             = 'Item Details STPO'


    EXCEPTIONS


      error              = 1


      OTHERS             = 2.

Former Member
0 Kudos
328

HI,
I know it's a old subject but i just find the solution so to update long text feel the field
object_id in the table typed csltx_line for all the line you want to put in the header
with the below value:
* object_id = 0: Stücklistentext (STZU)  (-> CS_DI_BOM_UPDATE)
*           = 1: Alternativentext (STKO)
*           = 2: Positionstext (STPO)
Regards