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: 

Program to update BOM by CSAP_MAT_BOM_CREATE as error KEY_INCOMPLETE coming

pavneet_rana
Active Participant
0 Kudos

Hi to all,

Can any one provide me sample program to update BOM via Function Module CSAP_MAT_BOM_CREATE.

As i already have created the program , but run time error is coming KEY_INCOMPLETE for CSAP_MAT_BOM_CREATE.

as i have already search the SDN , but cant get any specific answer for that.

Note: itab_bom_header and itab_bom_item_details are of same line type as

i_stko and t_stpo with data.

DATA: wa_bom_header TYPE zia_str_bom_header,

wa_itab_bom_item_details TYPE zia_str_bom_item_details.

IF itab_bom_header[] IS NOT INITIAL .

READ TABLE itab_bom_header INTO wa_bom_header INDEX 1 .

ENDIF.

*---- BOM header data structure

DATA: BEGIN OF tstko OCCURS 0.

INCLUDE STRUCTURE stko_api01.

DATA: END OF tstko.

DATA: wa_tstko LIKE LINE OF tstko.

*---- BOM items table

DATA: BEGIN OF tstpo OCCURS 0.

INCLUDE STRUCTURE stpo_api01.

DATA: END OF tstpo.

DATA: wa_tstpo LIKE LINE OF tstpo.

**---- Object dependencies table

*

    • Basis data

*data: begin of tdep_data occurs 0.

*include structure csdep_dat.

*data: end of tdep_data.

*

    • Description

*data: begin of tdep_descr occurs 0.

*include structure csdep_desc.

*data: end of tdep_descr.

*

    • Source

*data: begin of tdep_source occurs 0.

*include structure csdep_sorc.

*data: end of tdep_source.

*

    • Sequence

*data: begin of tdep_order occurs 0.

*include structure csdep_ord.

*data: end of tdep_order.

*

    • Documentation

*data: begin of tdep_doc occurs 0.

*include structure csdep_doc.

*data: end of tdep_doc.

CALL FUNCTION 'CALO_INIT_API'

  • EXPORTING

  • FLAG_DB_LOG_ON = 'X'

  • FLAG_MSG_ON = 'X'

  • FLAG_API_API_CALL_ON = ' '

  • FLAG_COLLECT_MSG_ON = ' '

  • EXTERNAL_LOG_NO = 'API'

  • DEL_LOG_AFTER_DAYS = '10'

  • DATA_RESET_SIGN = '!'

EXCEPTIONS

LOG_OBJECT_NOT_FOUND = 1

LOG_SUB_OBJECT_NOT_FOUND = 2

OTHERS = 3

.

LOOP AT itab_bom_header INTO wa_bom_header.

wa_tstko-BASE_QUAN = wa_bom_header-base_qty.

wa_tstko-BASE_UNIT = wa_bom_header-BASE_UOM.

wa_tstko-BOM_STATUS = wa_bom_header-BOM_STATUS.

ENDLOOP.

LOOP AT itab_bom_item_details INTO wa_itab_bom_item_details.

wa_tstpo-item_categ = wa_itab_bom_item_details-item_category.

wa_tstpo-item_no = wa_itab_bom_item_details-bom_itm_number.

wa_tstpo-component = wa_itab_bom_item_details-component.

wa_tstpo-comp_unit = wa_itab_bom_item_details-uom.

wa_tstpo-comp_qty = '10'.

wa_tstpo-valid_from = wa_itab_bom_item_details-valid_from.

wa_tstpo-itm_ident = wa_itab_bom_item_details-item_id .

APPEND wa_tstpo TO tstpo .

ENDLOOP.

  • FM to create BOM

CALL FUNCTION 'CSAP_MAT_BOM_CREATE'

EXPORTING

material = wa_bom_header-material

plant = wa_bom_header-plant

bom_usage = wa_bom_header-bom_usage

  • VALID_FROM = wa_bom_header-VALID_FROM

  • CHANGE_NO =

  • REVISION_LEVEL =

i_stko = tstko " bom header

  • FL_NO_CHANGE_DOC = ' '

  • FL_COMMIT_AND_WAIT = ' '

  • FL_CAD = ' '

  • fl_default_values = 'X'

IMPORTING

fl_warning = fl_warning

bom_no = bom_no

TABLES

t_stpo = tstpo " bom item

  • T_DEP_DATA = tdep_data

  • T_DEP_DESCR = tdep_descr

*

  • T_DEP_ORDER = tdep_source

  • T_DEP_SOURCE = tdep_order

  • T_DEP_DOC = tdep_doc

  • T_LTX_LINE =

  • T_STPU =

EXCEPTIONS

error = 1

  • OTHERS = 2

.

IF sy-subrc <> 1.

WRITE 'error'.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

IF fl_warning EQ 'X'.

WRITE 'done'.

ENDIF.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

  • IMPORTING

  • RETURN =

.

please can any one provide me the solution for that.

i shall be thankfull to you for this.

Regards

Pavneet Rana

Edited by: pavneet rana on Aug 18, 2011 3:01 PM

4 REPLIES 4

Former Member
0 Kudos

May I ask if you read the FM documentation, including the sample update program contained in the documentation? Have you debugged to see where and why ERROR exception is being raised? That would probably lead you to a solution. Not sure why you're doing a BAPI_COMMIT...this is an old-style update function module, not a BAPI?

0 Kudos

Thanks for reply,

i have debug my program and found that run time error is coming at GET_MAST function module.

but i have already checked that MATNR and STLNR is already filled before reaching to that FM.

GET_MAST

IF NOT SET IS INITIAL.

IF WA-MATNR IS INITIAL

AND WA-STLNR IS INITIAL.

RAISE KEY_INCOMPLETE.

ENDIF.

IF WA-MATNR <> SPACE

AND WA-STLNR <> SPACE.

RAISE KEY_INVALID.

ENDIF.

please can any one provide me the solution for that.

Regards

Pavneet Rana

0 Kudos

Look at the statement again...

IF NOT SET IS INITIAL.
IF WA-MATNR IS INITIAL
AND WA-STLNR IS INITIAL.

RAISE KEY_INCOMPLETE.
ENDIF.

Obviously SET is not initial, but both WA-MATNR and WA-STLNR are not populated for this error to occur!

In Debug, what are the contents of WA-MATNR and WA-STLNR and how did the program get to this point with these values not populated? Where were they supposed to be read from? Whatever code is filling the work area WA is NOT obtaining MATNR and STLNR values.

0 Kudos

Thanks for reply,

i have debug it again , found that error is coming for sy-subrc = 1

  • inside FM 'CSAP_MAT_BOM_CREATE' at point*

if flg_error eq kreuz.

fl_warning = flg_warning.

perform appl_log_exit using 'CSAP_MAT_BOM_CREATE'

changing hlp_subrc.

call function 'DEQUEUE_ALL'.

raise error.

else.

  • Stücklisten-Langtext (STZU)

g_ltx_tabix = g_ltx_tabix + 1.

please can any one help me ,why the error is coming, i am passing the value correctly to FM.

regards

pavneet rana