Skip to Content

Operation cannot be determined, due to lack of identifying data error in CA01 BAPI Mess.CPCL 220

Hi,

I have face problem during creation of CA01 BAPI with PRT Assignment,

I use below code for creating CA01 BAPI,

REPORT ZBAPI_ROUTING_CREATE.

------ INTERNAL TABLE DECLARATION --------------------------------

TYPES : BEGIN OF s_itab,
group_counter(2),
task_list_usage TYPE pln_verwe, " Task list usage
plant TYPE werks_d , " Plant
task_list_status TYPE plnst , " Status
resp_planner_group TYPE vagrp , " Responsible planner group/department
description TYPE plantext , " Task list description
material TYPE matnr , " Material Number
activity TYPE vornr , " Operation/Activity Number
control_key TYPE steus , " Control key
work_cntr TYPE arbpl , " Work center
op_description TYPE ltxa1 , " Operation short text
base_quantity TYPE bmsch , " Base Quantity
std_unit_01 TYPE vgwrteh , " Unit of measure for the standard value
std_value_01 TYPE vgwrt , " Standard Value
std_unit_02 TYPE vgwrteh , " Unit of measure for the standard value
std_value_02 TYPE vgwrt , " Standard Value
std_unit_03 TYPE vgwrteh , " Unit of measure for the standard value
std_value_03 TYPE vgwrt , " Standard Value

PRT_NUMBER type FHMNR, " Production resource/tool number
PRT_PLANT type FHWRK, " Production resources/tools in plant
std_value_for_prt_qty type mgvgw, " standard value for the prt quantity
prt_measure_unit type mgeinh, " quantity unit of production resource/tool
std_usage_value_for_prt type ewvgw, " standard usage value for production resources/tools
prt_usage_value_unit type eweinh, " usage value unit of the production resource/tool

STATUS(10),
END OF s_itab.

* --------- DATA DECLARATION ------------------------------------------------
TYPES : trux_t_text_data(4096) TYPE C OCCURS 0.
* ---------------------------------------------
DATA : BEGIN OF t_error OCCURS 0.
DATA : material LIKE bapi1012_mtk_c-material.
INCLUDE STRUCTURE bapiret2.
DATA : END OF t_error.
* ---------------------------------------------
DATA : testrun TYPE bapiflag ,
unit_of_measure LIKE mara-meins,
commit_return LIKE bapiret2,
profile LIKE bapi1012_control_data-profile ,
bomusage TYPE bapi1012_control_data-bom_usage ,
application LIKE bapi1012_control_data-application ,
GROUP TYPE bapi1012_tsk_c-task_list_group,
groupcounter TYPE bapi1012_tsk_c-group_counter,
TASK LIKE TABLE OF bapi1012_tsk_c WITH HEADER LINE ,
materialtaskallocation LIKE TABLE OF bapi1012_mtk_c WITH HEADER LINE ,
sequence LIKE TABLE OF bapi1012_seq_c WITH HEADER LINE ,
operation LIKE TABLE OF bapi1012_opr_c WITH HEADER LINE ,
suboperation LIKE TABLE OF bapi1012_sub_opr_c WITH HEADER LINE ,
referenceoperation LIKE TABLE OF bapi1012_ref_opr_c WITH HEADER LINE,
workcenterreference LIKE TABLE OF bapi1012_wc_ref_opr_c WITH HEADER LINE,
componentallocation LIKE TABLE OF bapi1012_com_c WITH HEADER LINE,
productionresource LIKE TABLE OF bapi1012_prt_c WITH HEADER LINE,
inspcharacteristic LIKE TABLE OF bapi1012_cha_c WITH HEADER LINE,
textallocation LIKE TABLE OF bapi1012_txt_hdr_c WITH HEADER LINE,
TEXT LIKE TABLE OF bapi1012_txt_c WITH HEADER LINE,
RETURN LIKE TABLE OF bapiret2 WITH HEADER LINE,
itab TYPE STANDARD TABLE OF s_itab WITH HEADER LINE,
wa_itab TYPE s_itab,
ic_final TYPE STANDARD TABLE OF s_itab WITH HEADER LINE,
it_final TYPE STANDARD TABLE OF s_itab WITH HEADER LINE, wc_final LIKE LINE OF itab.
* ---------------------------------------------
DATA : it_raw TYPE trux_t_text_data.
DATA : con(110) TYPE C,
flag(1) TYPE n VALUE 0 .

DATA : it_log TYPE TABLE OF s_itab,
wa_log TYPE s_itab.

TYPES : BEGIN OF ty_fieldnames,
field_name(30) TYPE C, "Field names
END OF ty_fieldnames.

DATA: it_fieldnames TYPE TABLE OF ty_fieldnames.

DATA : wa_fieldnames TYPE ty_fieldnames.

DATA : filename TYPE string.
* --------------------------------------------------------------
selection-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
PARAMETERS: bdc_file TYPE rlgrap-filename obligatory.
selection-SCREEN: END OF BLOCK b1.
* --------------------------------------------------------------
AT selection-SCREEN ON VALUE-request FOR bdc_file.
******* fOR SEARCH HELP*******************
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = ' '
IMPORTING
file_name = bdc_file .
* --------------------------------------------------------------
start-OF-selection.
* --------------------------------------------------------------
************** CONVERSION OF EXCEL TO ITAB

START-OF-SELECTION.

PERFORM select_file.
PERFORM fieldnames.
PERFORM process.
IF it_log IS NOT INITIAL.
PERFORM download_log.
ENDIF.
* --------------------------------------------------------------

FORM select_file.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
I_LINE_HEADER = 'X'
i_tab_raw_data = it_raw
i_filename = bdc_file
TABLES
i_tab_converted_data = itab[]
EXCEPTIONS
conversion_failed = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF .

* --------------------------------------------------------------
bomusage = '1'.
application = '1'.
* --------------------------------------------------------------
it_final[] = itab[].
* --------------------------------------------------------------
DELETE ADJACENT DUPLICATES FROM itab COMPARING material group_counter."delete duplicate materials records
* --------------------------------------------------------------
ENDFORM.
*DATA : material TYPE mara-matnr.

FORM fieldnames.
wa_fieldnames-field_name = 'GROUP COUNTER'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'TASK_LIST_USAGE'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'PLANT'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'TASK_LIST_STATUS'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'RESP_PLANNER_GROUP'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'DESCRIPTION'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'MATERIAL'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'OPERATION NO'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'CONTROL_KEY'.
APPEND wa_fieldnames TO it_fieldnames.

wa_fieldnames-field_name = 'WORK_CNTR'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'DESCRIPTION'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'BASE_QUANTITY'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'ACTTYPE_01'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'STD_UNIT_01'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'STD_VALUE_01'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'ACTTYPE_02'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'STD_UNIT_02'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'STD_VALUE_02'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'ACTTYPE_03'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'STD_UNIT_03'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'STD_VALUE_03'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'ACTTYPE_04'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'STD_UNIT_04'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'STD_VALUE_04'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'ACTTYPE_05'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'STD_UNIT_05'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'STD_VALUE_05'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'ACTIVITY'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'BOM_TYPE'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'BOM_NO'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'ALTERNATIVE_BOM'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'ITEM_ID'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'ITEM_NO'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'COMP_QTY'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'COMP_UNIT'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'BACKFLUSH'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'MATERIAL'.
APPEND wa_fieldnames TO it_fieldnames.
wa_fieldnames-field_name = 'STATUS'.
APPEND wa_fieldnames TO it_fieldnames.
ENDFORM.


FORM process.
IF itab[] IS NOT INITIAL.
LOOP AT itab.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = itab-material
IMPORTING
OUTPUT = itab-material
.* -------------------------------------------------------------------------------
SELECT SINGLE meins FROM mara INTO unit_of_measure WHERE matnr = itab-material.
* -------------------------------------------------------------------------------
TASK-group_counter = itab-group_counter.
TASK-task_list_usage = itab-task_list_usage.
TASK-plant = itab-plant.
TASK-task_list_status = itab-task_list_status.
TASK-valid_from = sy-datum.
TASK-valid_to_date = '99991231'.
TASK-task_measure_unit = unit_of_measure.
TASK-lot_size_from = '1'.
TASK-lot_size_to = '99999999'.
TASK-RESP_PLANNER_GROUP = ITAB-RESP_PLANNER_GROUP.
TASK-description = itab-description.
materialtaskallocation-material = itab-material.
materialtaskallocation-plant = itab-plant.
materialtaskallocation-valid_from = sy-datum.
materialtaskallocation-valid_to_date = '99991231'.
* -------------------------------------------------------------------------------
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = itab-material
IMPORTING
OUTPUT = itab-material
.
LOOP AT it_final INTO wa_itab WHERE material EQ itab-material and GROUP_COUNTER eq itab-GROUP_COUNTER.

operation-activity = wa_itab-activity .
* operation-operation_id = wa_itab-operation_id .
operation-valid_from = sy-datum .
operation-valid_to_date = '99991231' .
operation-control_key = wa_itab-control_key .
operation-work_cntr = wa_itab-work_cntr .
operation-plant = WA_itab-plant .
* OPERATION-STANDARD_TEXT_KEY = wa_itab-STANDARD_TEXT_KEY.
operation-description = wa_itab-op_description.
operation-operation_measure_unit = unit_of_measure .
operation-base_quantity = wa_itab-base_quantity.
operation-denominator = 1.
operation-nominator = 1.
operation-std_unit_01 = wa_itab-std_unit_01.
operation-std_value_01 = wa_itab-std_value_01.
operation-std_unit_02 = wa_itab-std_unit_02.
operation-std_value_02 = wa_itab-std_value_02.
* operation-acttype_03 = wa_itab-acttype_03.
operation-std_unit_03 = wa_itab-std_unit_03.
operation-std_value_03 = wa_itab-std_value_03.

productionresource-valid_from = sy-datum.
productionresource-CTRL_KEY = '1'.
productionresource-valid_to_date = '99991231'.
productionresource-GROUP_COUNTER = WA_itab-GROUP_COUNTER.
productionresource-ACTIVITY = WA_itab-ACTIVITY.
productionresource-DESCRIPTION = WA_itab-DESCRIPTION.
productionresource-PRT_NUMBER = WA_itab-PRT_NUMBER.
productionresource-PRT_PLANT = WA_itab-PRT_PLANT.
productionresource-std_value_for_prt_qty = WA_itab-std_value_for_prt_qty.
productionresource-prt_measure_unit = WA_itab-prt_measure_unit.
productionresource-std_usage_value_for_prt = WA_itab-std_usage_value_for_prt.
productionresource-prt_usage_value_unit = WA_itab-prt_usage_value_unit.

*********************************************************************************
* ------------------------
APPEND : operation, productionresource .
CLEAR: wa_itab, operation.
* ------------------------
ENDLOOP.

APPEND : TASK,componentallocation,materialtaskallocation.
CLEAR : TASK,operation,componentallocation,materialtaskallocation.
* -------------------------------------------------------------------------------
CALL FUNCTION 'BAPI_ROUTING_CREATE'
EXPORTING
testrun = testrun
** PROFILE =
bomusage = '1'
application = 'N'
IMPORTING
GROUP = GROUP
groupcounter = groupcounter
TABLES
TASK = TASK
materialtaskallocation = materialtaskallocation
* SEQUENCE =
operation = operation
* SUBOPERATION =
* REFERENCEOPERATION =
* WORKCENTERREFERENCE =
* componentallocation = componentallocation
PRODUCTIONRESOURCE = productionresource
* INSPCHARACTERISTIC =
* TEXTALLOCATION =
* TEXT =
RETURN = RETURN.
* -------------------------------------------------------------------------------
LOOP AT RETURN.
IF RETURN-TYPE EQ 'E' OR RETURN-TYPE EQ 'A'.
t_error-material = materialtaskallocation-material.
t_error-MESSAGE = RETURN-MESSAGE.
APPEND t_error.
wa_log-status = 'Error'.
ELSE.

WAIT UP TO 2 SECONDS.
COMMIT WORK.
wa_log-status = 'Sucess'.
* WAIT UP TO 10 SECONDS.
* WRITE:/ 'BAPI Generated record succesfully'.
ENDIF.

ENDLOOP.
* -------------------------------------------------------------------------------
* LOOP AT t_error.
* WRITE:/ t_error-material,t_error-MESSAGE.
* ENDLOOP.
* ENDAT.
* ENDLOOP.
* -------------------------------------------------------------------------------
REFRESH: TASK,RETURN.
REFRESH materialtaskallocation.
REFRESH operation.
* -------------------------------------------------------------------------------

wa_log-group_counter = itab-group_counter.
wa_log-task_list_usage = itab-task_list_usage.
wa_log-plant = itab-plant.
wa_log-task_list_status = itab-task_list_status.
* wa_log-task_measure_unit = itab-task_measure_unit.
* wa_log-lot_size_from = '1'.
wa_log-resp_planner_group = itab-resp_planner_group.
wa_log-description = itab-description.
wa_log-material = itab-material.
wa_log-activity = itab-activity.
* wa_log-operation_id = itab-operation_id.
wa_log-control_key = itab-control_key.
wa_log-work_cntr = itab-work_cntr.
wa_log-op_description = itab-op_description.
wa_log-base_quantity = itab-base_quantity.
* wa_log-acttype_01 = itab-acttype_01.
wa_log-std_unit_01 = itab-std_unit_01.
wa_log-std_value_01 = itab-std_value_01.
* wa_log-acttype_02 = itab-acttype_02.
wa_log-std_unit_02 = itab-std_unit_02.
wa_log-std_value_02 = itab-std_value_02.
* wa_log-acttype_03 = itab-acttype_03.
wa_log-std_unit_03 = itab-std_unit_03.
wa_log-std_value_03 = itab-std_value_03.


wa_log-PRT_NUMBER = itab-PRT_NUMBER.
wa_log-PRT_PLANT = itab-PRT_PLANT.
wa_log-std_value_for_prt_qty = itab-std_value_for_prt_qty.
wa_log-prt_measure_unit = itab-prt_measure_unit .
wa_log-std_usage_value_for_prt = itab-std_usage_value_for_prt.
wa_log-prt_usage_value_unit = itab-prt_usage_value_unit.

APPEND wa_log TO it_log.

ENDLOOP.
ELSE.
MESSAGE 'Error while reading Excel File' TYPE 'E'.
ENDIF.
ENDFORM.

FORM download_log.
DATA : v_fullpath TYPE string.

CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
EXPORTING
window_title = 'STATUS RECORD FILE'
default_extension = '.xls'
IMPORTING
* filename = v_efile
fullpath = v_fullpath.


CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = v_fullpath
filetype = 'ASC'
write_field_separator = 'X'
TABLES
data_tab = it_log
fieldnames = it_fieldnames
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
MESSAGE 'Please check Status File' TYPE 'S'.
ENDIF.
ENDFORM.









Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers