Hi here is a script that is not working for me and not sure where the error is happening the file executes but the record is not being added to the database. If anyone can help that would be great.
Thanks
'Date Created: 19-Dec-2008 11:59:04 AM
'Last Updated: 19-Dec-2008 11:59:04 AM
'Created By : Chad
'Updated By : Chad
'Prompt for a filename and store result in a variable called 'Activation'.
dim prmpt_title as c
dim prmpt_filter as c
dim prmpt_default as c
dim prmpt_flag as c
prmpt_title = "Activation Number"
prmpt_filter = "(*.txt)"
prmpt_default = "S:\totals\*.txt"
DIM SHARED Activation AS C
Activation = ui_get_file( a5_eval_expression(prmpt_title,local_variables()),prmpt_filter,prmpt_default,"X")
temporary_import_table = file.temp_path_get()+ "actos_temp_table.dbf"
import_destination_table = "s:\totals\actos.dbf"
import_filename = ui_get_file( a5_eval_expression(prmpt_title,local_variables()),prmpt_filter,prmpt_default,"X")
if file.exists(import_filename) = .f. then
end if
ON ERROR GOTO ERROR19122008114024861
import.type = 0
import.names = "none"
import.file = import_filename
import.db = temporary_import_table
import.skip_lines = 1
import.skip_bytes = 0
import.field_sep = ","
import.record_sep = "<CR><LF>"
import.text_qualifier = "\""
import.record_len = 261
import.rem_blanks = .F.
import.escape_newlines = .F.
import.import_encoding = "default"
import.fields = 13
import.field1 = "activation_number,c,1,8,0"
import.field2 = "first_name,c,4,15,0"
import.field3 = "last_name,c,6,15,0"
import.field4 = "cell_number,c,8,10,0"
import.field5 = "esn,c,9,14,0"
import.field6 = "term,c,13,2,0"
import.field7 = "rate_plan,c,14,12,0"
import.field8 = "field_16,c,15,1,0"
import.field9 = "field_17,c,16,9,0"
import.field10 = "field_18,c,17,6,0"
import.field11 = "field_19,c,18,6,0"
import.field12 = "field_20,c,19,7,0"
import.field13 = "field_21,c,20,9,0"
import()
'Prompt for confirmation before appending the records that were imported into the temporary table.......
dim rec_count as n
rec_count = a5_get_records_in_query(temporary_import_table, ".t.")
message_text = "Up to " + rec_count + " record(s) will be imported into '"+import_destination_table+"'."+crlf(2)+ "OK to proceed?"
operation_result=ui_msg_box("Import Operation",message_text,UI_OK_CANCEL+ UI_FIRST_BUTTON_DEFAULT+ UI_INFORMATION_SYMBOL)
If operation_result <> ui_ok_selected then
end if
a_tbl = table.open(import_destination_table)
append.t_db = temporary_import_table
append.m_key = "OLD"
append.t_key = "OLD"
append.m_filter = ""
append.t_filter = ""
append.type = "all"
':::BEGIN_ERROR_INFO:::
'WARNING: field 'Activation_Number' doesn't exist in target table, field omitted
'WARNING: field 'First_Name' doesn't exist in target table, field omitted
'WARNING: field 'Last_Name' doesn't exist in target table, field omitted
'WARNING: field 'Cell_Number' doesn't exist in target table, field omitted
'WARNING: field 'ESN' doesn't exist in target table, field omitted
'WARNING: field 'Term' doesn't exist in target table, field omitted
'WARNING: field 'Rate_Plan' doesn't exist in target table, field omitted
'WARNING: field 'FIELD_16' doesn't exist in target table, field omitted
'WARNING: field 'FIELD_17' doesn't exist in target table, field omitted
'WARNING: field 'FIELD_18' doesn't exist in target table, field omitted
'WARNING: field 'FIELD_19' doesn't exist in target table, field omitted
'WARNING: field 'FIELD_20' doesn't exist in target table, field omitted
'WARNING: field 'FIELD_21' doesn't exist in target table, field omitted
'ERROR: no valid fieldnames specified for import into existing table
':::END_ERROR_INFO:::
GOTO CONTINUE19122008114024861
ERROR19122008114024861:
ON ERROR GOTO 0
ui_msg_box("Error","Error running Import Operation"+crlf()+error_text_get())
END
CONTINUE19122008114024861:
a_tbl.close()
a5_imp_append_op_result(a_records_processed,a_records_total,a_records_violated,import_destination_table)
'In case the destination table is not already in the Database, add it...
file_add_to_db(table.filename_get(import_destination_table))
'If the Operation is run from within a Form or Browse, then refresh the window
if is_object(topparent.this) then
end if
Thanks
'Date Created: 19-Dec-2008 11:59:04 AM
'Last Updated: 19-Dec-2008 11:59:04 AM
'Created By : Chad
'Updated By : Chad
'Prompt for a filename and store result in a variable called 'Activation'.
dim prmpt_title as c
dim prmpt_filter as c
dim prmpt_default as c
dim prmpt_flag as c
prmpt_title = "Activation Number"
prmpt_filter = "(*.txt)"
prmpt_default = "S:\totals\*.txt"
DIM SHARED Activation AS C
Activation = ui_get_file( a5_eval_expression(prmpt_title,local_variables()),prmpt_filter,prmpt_default,"X")
temporary_import_table = file.temp_path_get()+ "actos_temp_table.dbf"
import_destination_table = "s:\totals\actos.dbf"
import_filename = ui_get_file( a5_eval_expression(prmpt_title,local_variables()),prmpt_filter,prmpt_default,"X")
if file.exists(import_filename) = .f. then
end if
ON ERROR GOTO ERROR19122008114024861
import.type = 0
import.names = "none"
import.file = import_filename
import.db = temporary_import_table
import.skip_lines = 1
import.skip_bytes = 0
import.field_sep = ","
import.record_sep = "<CR><LF>"
import.text_qualifier = "\""
import.record_len = 261
import.rem_blanks = .F.
import.escape_newlines = .F.
import.import_encoding = "default"
import.fields = 13
import.field1 = "activation_number,c,1,8,0"
import.field2 = "first_name,c,4,15,0"
import.field3 = "last_name,c,6,15,0"
import.field4 = "cell_number,c,8,10,0"
import.field5 = "esn,c,9,14,0"
import.field6 = "term,c,13,2,0"
import.field7 = "rate_plan,c,14,12,0"
import.field8 = "field_16,c,15,1,0"
import.field9 = "field_17,c,16,9,0"
import.field10 = "field_18,c,17,6,0"
import.field11 = "field_19,c,18,6,0"
import.field12 = "field_20,c,19,7,0"
import.field13 = "field_21,c,20,9,0"
import()
'Prompt for confirmation before appending the records that were imported into the temporary table.......
dim rec_count as n
rec_count = a5_get_records_in_query(temporary_import_table, ".t.")
message_text = "Up to " + rec_count + " record(s) will be imported into '"+import_destination_table+"'."+crlf(2)+ "OK to proceed?"
operation_result=ui_msg_box("Import Operation",message_text,UI_OK_CANCEL+ UI_FIRST_BUTTON_DEFAULT+ UI_INFORMATION_SYMBOL)
If operation_result <> ui_ok_selected then
end if
a_tbl = table.open(import_destination_table)
append.t_db = temporary_import_table
append.m_key = "OLD"
append.t_key = "OLD"
append.m_filter = ""
append.t_filter = ""
append.type = "all"
':::BEGIN_ERROR_INFO:::
'WARNING: field 'Activation_Number' doesn't exist in target table, field omitted
'WARNING: field 'First_Name' doesn't exist in target table, field omitted
'WARNING: field 'Last_Name' doesn't exist in target table, field omitted
'WARNING: field 'Cell_Number' doesn't exist in target table, field omitted
'WARNING: field 'ESN' doesn't exist in target table, field omitted
'WARNING: field 'Term' doesn't exist in target table, field omitted
'WARNING: field 'Rate_Plan' doesn't exist in target table, field omitted
'WARNING: field 'FIELD_16' doesn't exist in target table, field omitted
'WARNING: field 'FIELD_17' doesn't exist in target table, field omitted
'WARNING: field 'FIELD_18' doesn't exist in target table, field omitted
'WARNING: field 'FIELD_19' doesn't exist in target table, field omitted
'WARNING: field 'FIELD_20' doesn't exist in target table, field omitted
'WARNING: field 'FIELD_21' doesn't exist in target table, field omitted
'ERROR: no valid fieldnames specified for import into existing table
':::END_ERROR_INFO:::
GOTO CONTINUE19122008114024861
ERROR19122008114024861:
ON ERROR GOTO 0
ui_msg_box("Error","Error running Import Operation"+crlf()+error_text_get())
END
CONTINUE19122008114024861:
a_tbl.close()
a5_imp_append_op_result(a_records_processed,a_records_total,a_records_violated,import_destination_table)
'In case the destination table is not already in the Database, add it...
file_add_to_db(table.filename_get(import_destination_table))
'If the Operation is run from within a Form or Browse, then refresh the window
if is_object(topparent.this) then
end if
Comment