COM***********************************
COM creating map of each field
COM***********************************
SET EXACT OFF
DELETE FOLDER temp OK
SET FOLDER
SET FOLDER /temp
OPEN %v_table%
v_field_len = len(%v_testfield%)
v_map = "map_1"+BLANKS(32000)
v_ctr = 1
GROUP IF RECNO() = 1
LOOP while v_ctr < v_field_len
v_map = ALL(v_map) +"+offset(map_1,"+ ALL(STRING(v_ctr,2))+ ")"
v_ctr = v_ctr + 1
END
END
DEL map_1 OK
DEL map_Result OK
DEL map_Resulttemp OK
COM*************************
COM Replacing values in the map_1 field
COM*************************
Define field map_1 computed
" " if match(ASCII(%v_testfield%), 32 ,9)
"9" if between((%v_testfield%),'0','9')
"X" if between(%v_testfield%,'A','Z')
"x" if between(%v_testfield%,'a','z')
" " if match(%v_testfield%, " ")
"?"
define field map_Resulttemp computed %v_map%
DEFINE FIELD map_result COMP
"Empty" if map_Resulttemp = ""
map_Resulttemp
DEL temp2.fil OK
DEL FORMAT temp2 OK
EXTRACT FIELDS ALL TO temp2 OPEN
SUM ON Vendor_ID Voucher_ID %v_testfield% map_1 map_result TO TEMP3 PRESORT IF map_Result <>""
COM*************************
COM Determine which vendors account for more than the determined minimum of transactions.
COM**************************
OPEN TEMP3
sum on Vendor_ID map_Result SUB count as "f_count" to TEMP4 presort
OPEN temp4
SUM ON Vendor_ID ACCUM F_count TO TEMP5 OPEN PRESORT
TOTAL F_count
EXTRACT FIELDS ALL IF F_count > total1 * 0.001 TO TEMP6
v_ctrl = write1
COM**************************************
COM Relating tables to extract information based upon the vendors who have the minimum
COM number of transactions
COM**************************************
OPEN temp6
INDEX on vendor_ID to "i_map"
Set INDEX TO "i_map"
OPEN TEMP4
DEFINE RELATION vendor_ID WITH temp6 INDEX i_map
EXTRACT FIELDS f_COUNT as "f_count1" map_Result VENDOR_ID temp6.F_count TO "TEMP7" OPEN IF temp6.F_count <>0
SORT ON Vendor_ID f_count1 D to TEMP8
CLOSE
CLOSE SEC
COM****************************
COM Determining which MAPS constitute at least 99% of the vendors transactions.
COM****************************
OPEN TEMP8
V_percent = 1.00*f_count1/f_count
v_list = blank(500)
v_vendor = BLANK(20)
v_count = 0
GROUP IF v_percent <.99 and ALL(v_vendor) = ALL(vendor_ID )
v_list = "'"+ ALL(map_result) + "'," + ALL(v_list)
v_percent = v_percent + 1.00*f_count1/f_count
v_vendor = vendor_ID
ELSE IF ALL(v_vendor) = ALL(vendor_ID )
V_percent = V_percent + 1.00*f_count1/f_count
v_vendor = vendor_ID
ELSE
EXTRACT v_vendor as "Vendor_ID" (ALL(v_list)) as "f_list" V_percent v_count as "f_count" IF RECNO() <> 1 TO TEMP9 EOF
V_percent = 1.00*f_count1/f_count
v_list = "'" + ALL(map_result) + "'"
v_vendor = vendor_ID
v_count = f_count
END
OPEN TEMP9
DEL Temp10.fil OK
DEL FORMAT TEMP10 OK
COUNT
v_cnt = 1
v_cntr = count1
DO I01b_Mapping_pt_3 WHILE v_cnt <= v_cntr
SET FOLDER
SET FOLDER /REPORT
OPEN TEMP10
EXTRACT FIELDS ALL TO REPORT_I01_Mapdif_%v_testfield% OPEN
EXPORT FIELDS map_result Map_Guide f_dupeset_master VOUCHER_ID VOUCHER_LINE_NUM TOTAL_DISTRIBS MAX_DISTRIB_LINE LINE_NBR DESCR MERCHANDISE_AMT MERCH_AMT_BSE ITM_S INV_ITEM_ID QTY_VCHR UNIT_PRICE RECEIVER_I RECV_LN_NBR VOUCHER_ID_related INSPECT_DT INVOICE_ID invoice_dt VNDR_LOC ADDRESS_SEQ_NUM entry_status accounting_dt VOUCHER_ due_dt dscnt_due_dt entered_dt last_update_dt PO_ID inv_recpt_dt receipt_dt VCHR_scr PAY_AMT PAY_AMT_BASE NAME1 VENDOR_ID SETID f_item F_inv_month map_1 map_Resulttemp map_result2 EXCEL TO "%v_path%REPORT_I01_Mapdif_PO_ID.XLS"
SET FOLDER
SET FOLDER /temp
SET EXACT OFF