*&---------------------------------------------------------------------* *& Report ZQM_INSPECTION_PLAN_UP *&---------------------------------------------------------------------* *& *&---------------------------------------------------------------------* report zqm_inspection_plan_up . * Type Pool Used for ALV Log Display type-pools : slis. * Data Declarations for import data: t_task t_materialtaskallocation , t_inspcharacteristic , t_operation , t_return * Local Variables data: v_group v_grpcounter v_file v_row v_plant v_lines v_per v_txt(50) type type type type like type type type internal table parameters to BAPI type table of bapi1191_tsk_c with header line, type table of bapi1191_mtk_c with header line type table of bapi1191_cha_c with header line type table of bapi1191_opr_c with header line type table of bapiret2 with header line. bapi1191_tsk_c-task_list_group, bapi1191_tsk_c-group_counter, localfile, n, t_task-plant, i, p, c. * Declare Internal table for Message Header for ALV Display data: begin of it_loghead occurs 0, material like bapi1191_mtk_c-material, plant like bapi1191_tsk_c-plant, msgtype like bapiret2-type, msg(100) type c, expand type c, end of it_loghead . * Declare Internal table for Message Details for ALV Display data: begin of it_logdetail occurs 0, material like bapi1191_mtk_c-material, plant like bapi1191_tsk_c-plant, msgtype like bapiret2-type, msg(100) type c, end of it_logdetail. * Structure to Load Data from the Text File types : begin of ty_insplan, plant like t_task-plant, material like t_materialtaskallocation-material, tsk_description like t_task-description, task_list_usage like t_task-task_list_usage, task_list_status like t_task-task_list_status, lot_size_from like t_task-lot_size_from, lot_size_to like t_task-lot_size_to, planning_work_center like t_task-planning_work_center, task_measure_unit like t_task-task_measure_unit, op_activity like t_operation-activity, control_key like t_operation-control_key, work_cntr like t_operation-work_cntr, op_description like t_operation-description, operation_measure_unit like t_operation-operation_measure_unit, ins_activity like t_inspcharacteristic-activity, inspchar like t_inspcharacteristic-inspchar, quantitative_ind like t_inspcharacteristicquantitative_ind, mstr_char like t_inspcharacteristic-mstr_char, cha_master_import_modus like t_inspcharacteristic-cha_master_import_modus, char_descr like t_inspcharacteristic-char_descr, method like t_inspcharacteristic-method, target_val like t_inspcharacteristic-target_val, up_tol_lmt like t_inspcharacteristic-up_tol_lmt, lw_tol_lmt like t_inspcharacteristic-lw_tol_lmt, smpl_procedure like t_inspcharacteristic-smpl_procedure, smpl_unit like t_inspcharacteristic-smpl_unit, smpl_quant like t_inspcharacteristic-smpl_quant, end of ty_insplan. types : begin of ty_log, * MESSAGE TYPE BAPI_MSG, * MESSAGE_V1 TYPE SYMSGV, * MESSAGE_V2 TYPE SYMSGV, message type char255, end of ty_log. data : t_log type table of ty_log with header line. * Internal Table to Load and Hold Data from the Text File data: it_insplan type table of ty_insplan with header line. data: g_file_name type rlgrap-filename ."STRING. data: g_raw_data type truxs_t_text_data . data split1 type char2. data split2 type char2. data split3 type char4. data : uom type mara-meins. data : kurztext type qpmt-kurztext. parameters : p_file type ibipparms-path obligatory . data: begin of t_datatab occurs 0, "COL0(50) TYPE C, "ALWAYS KEEP AN EMPTY CELL FOR THE CLIENT MANDT col1(50) type c, "GTIN material col2(50) type c, "material uom col3(50) col4(50) col5(50) col6(50) col7(50) col8(50) col9(50) col10(50) col11(50) col12(50) col13(50) col14(50) col15(50) col16(50) col17(50) col18(50) col19(50) col20(50) col21(50) col22(50) col23(50) col24(50) col25(50) type type type type type type type type type type type type type type type type type type type type type type type c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, "quantity "uom "ITEM CAT "plant "stor.loc "deliv.date "sto deliv date " end of t_datatab. at selection-screen on value-request for p_file. call function 'F4_FILENAME' exporting program_name = sy-repid * DYNPRO_NUMBER = SYST-DYNNR field_name = 'DATASET' importing file_name = p_file. start-of-selection. * * * * call function 'TEXT_CONVERT_XLS_TO_SAP' exporting I_FIELD_SEPERATOR = i_line_header = 'X' i_tab_raw_data = g_raw_data i_filename = p_file tables i_tab_converted_data = t_datatab[] "RECORD[] EXCEPTIONS CONVERSION_FAILED = 1 OTHERS = 2 . if sy-subrc <> 0. * IMPLEMENT SUITABLE ERROR HANDLING HERE endif. start-of-selection. loop at t_datatab. select single kurztext from qpmt into kurztext where mkmnr = t_datatab-col8. select single sollwni tolobni tolunni from qpmk into (t_inspcharacteristic-target_val_check_ind, t_inspcharacteristicup_tol_lmt_ind , t_inspcharacteristic-lw_tol_lmt_ind) where mkmnr = t_datatab-col8. * * * * split t_datatab-col3 at '.' into split1 split2 split3. concatenate split3 split2 split1 into t_datatab-col3 separated by '.'. condense t_datatab-col3 . replace all occurences of '.' in t_datatab-col3 with ''. Moving Corresponding fields to task internal table t_task-valid_from = t_datatab-col3. t_task-description = t_datatab-col7. t_task-task_list_usage = t_datatab-col4. t_task-task_list_status = t_datatab-col5. t_task-lot_size_from = it_insplan-lot_size_from. t_task-lot_size_to = it_insplan-lot_size_to. t_task-planning_work_center = it_insplan-planning_work_center. t_task-plant = t_datatab-col2. * Moving Corresponding fields to Material internal table t_materialtaskallocation-material = t_datatab-col1. call function 'CONVERSION_EXIT_ALPHA_INPUT' exporting input = t_materialtaskallocation-material importing output = t_materialtaskallocation-material. select single meins from mara into uom where matnr = t_materialtaskallocation-material. t_task-task_measure_unit = uom . "t_datatab-col17. t_materialtaskallocation-plant = t_datatab-col2. t_materialtaskallocation-valid_from = t_datatab-col3. * Moving Corresponding fields to Operation internal table t_operation-valid_from = t_datatab-col3. t_operation-activity = t_datatab-col15. t_operation-plant = t_datatab-col2. * * * * * * * * t_operation-control_key = t_datatab-col6. t_operation-change_no = '10'. t_operation-work_cntr = it_insplan-work_cntr. t_operation-description = t_datatab-col7. t_operation-operation_measure_unit = uom ." t_datatab-col18. t_operation-denominator = '1'." t_datatab-col19. t_operation-nominator = '1'." t_datatab-col20. t_operation-base_quantity = '1'." t_datatab-col21. t_inspcharacteristic-activity = t_datatab-col15. t_inspcharacteristic-inspchar = t_datatab-col16. t_inspcharacteristic-valid_from = t_datatab-col3. t_inspcharacteristic-mstr_char = t_datatab-col8. t_inspcharacteristic-pmstr_char = t_datatab-col2. t_inspcharacteristic-method = it_insplan-method. t_inspcharacteristic-pmethod = t_datatab-col2. clear t_inspcharacteristic-sampling_procedure_ind. clear t_inspcharacteristic-meas_value_confirm_ind . clear t_inspcharacteristic-scope_ind . clear t_inspcharacteristic-confirmation_category . if t_datatab-col18 = 'N'. t_inspcharacteristic-sampling_procedure_ind = 'X'. t_inspcharacteristic-meas_value_confirm_ind = 'X'. t_inspcharacteristic-scope_ind = '='. t_inspcharacteristic-confirmation_category = 'X'. endif. t_inspcharacteristic-smpl_procedure = t_datatab-col9. t_inspcharacteristic-smpl_unit = uom . " t_datatab-col22. t_inspcharacteristic-dec_places = '4'." t_datatab-col23. t_inspcharacteristic-smpl_quant = '1'." t_datatab-col24. t_inspcharacteristic-cha_master_import_modus = t_datatab-col18. t_inspcharacteristic-char_descr = it_insplan-char_descr. t_inspcharacteristic-quantitative_ind = t_datatab-col17. t_inspcharacteristic-target_val = t_datatab-col11. t_inspcharacteristic-up_tol_lmt = t_datatab-col10. t_inspcharacteristic-lw_tol_lmt = t_datatab-col12. t_inspcharacteristic-SEL_SET1 = t_datatab-col13. t_inspcharacteristic-PSEL_SET1 ='EC01'. t_inspcharacteristic-CAT_TYPE2 = t_datatab-col19 . t_inspcharacteristic-ATTRIBUTE_REQUIRED_IND = t_datatab-col20 . t_inspcharacteristic-PRESET_CTRL_INDS_KEY = t_datatab-col20 . t_inspcharacteristic-char_descr = kurztext. select single auswmenge1 auswmgwrk1 from qpmz into (t_inspcharacteristic-sel_set1,t_inspcharacteristic-psel_set1) where mkmnr = t_datatab-col8. *if sy-subrc = '0'. * break-POINT. * * * * * * t_inspcharacteristic-CAT_TYPE2 = '1'. endif. select single masseinhsw from qpmk into t_inspcharacteristic-meas_unit where mkmnr = t_datatab-col8. t_inspcharacteristic-CHAR_DESCR = t_datatab-col17. t_inspcharacteristic-UP_TOL_LMT_IND = 'X'. t_inspcharacteristic-LW_TOL_LMT_IND = 'X'. t_inspcharacteristic-TARGET_VAL_CHECK_IND = 'X'. append t_inspcharacteristic. at end of col1 . append t_task. append t_materialtaskallocation. append t_operation. call function 'BAPI_INSPECTIONPLAN_CREATE' importing group = v_group groupcounter = v_grpcounter tables task = t_task materialtaskallocation = t_materialtaskallocation operation = t_operation inspcharacteristic = t_inspcharacteristic return = t_return. *break-POINT. read table t_return index 1. loop at t_return. concatenate t_return-message t_return-message_v1 t_returnmessage_v2 into t_log-message separated by '/'. append t_log. endloop. call function 'BAPI_TRANSACTION_COMMIT' exporting wait = 'X'. Refresh : t_inspcharacteristic. endat. refresh : t_task, t_materialtaskallocation, t_operation, * t_inspcharacteristic, t_return. endloop. loop at t_log. write t_log-message. endloop.