SEND FRO
Материал из Фабиус wiki
Версия от 10:58, 25 апреля 2017; Hisava (обсуждение | вклад)
SEND_FRO - это программа из справочника R266
local ip, my, end_data, fro, filt, sql, conn, path, msg // path := GetPrm( 'SHP_PATH', 'SHOPOPER' ) path := GetPrm( 'CASHBOX', 'CASH_SHOP' ) ip := InputPeriod( true ) if Empty( ip ) return endif my := StoD( ip[1] ) end_data := StoD( ip[2] ) + 1 while my <> end_data try conn := CreateConnection( path, 'adm1user', "ora=11" ) fro := OpenFData( 'DOCP' + Ret_f_ext( my ), 'DOCS', false, OpdataPath, 'DOCS' ) filt := [ KINDDOC = 'FRO' and DtoS( DATDOC ) = '] + DtoS( my ) + [' ] ( fro )->( SetFilter( filt ) ) ( fro )->( DbGoTop() ) WaitMsg( 'Очистка документов FRO', msg ) sql := [ Delete From DOCP] + Ret_f_ext( my ) + [ Where KINDDOC = 'FRO' and DATDOC = '] + SqlDate( my )+ [' and DREFL2 = 'R179' and DANAL2 = ] + ( fro )->DANAL2 SimpleSql( sql, conn ) while !( fro )->( eof() ) WaitMsg( a_s( ( fro )->AUTOID ), msg ) ( fro )->EXTPARENT := ( fro )->RGNUM sql := [ Insert into DOCP] + Ret_f_ext( my ) + [ ; ( "SUM", AMNT, DSHIFT, KSHIFT, M_TEXT, NUMDOC, NATTR1, NATTR2, NATTR3, NATTR4, ; NATTR5, NATTR6, NATTR7, NATTR8, NATTR9, NATTR10, KINDDOC, LVLNUM, PARENT, ; DATDOC, EXTPARENT, DREFL1, DANAL1, D1NAME, DREFL2, DANAL2, D2NAME, DREFL3, DANAL3, D3NAME, ; KREFL1, KANAL1, K1NAME, KREFL2, KANAL2, K2NAME, KREFL3, KANAL3, K3NAME ) ; VALUES ( ] + atr( str( ( fro )->SUM, 19, 4, '.' ) ) + [, ] + ; atr( str( ( fro )->AMNT, 19, 4, '.' ) ) + [, '] + ; ( fro )->DSHIFT + [', '] + ; ( fro )->KSHIFT + [', '] + ; ( fro )->M_TEXT + [', '] + ; ( fro )->NUMDOC + [', ] + ; atr( str( ( fro )->NATTR1, 19, 4, '.' ) ) + [, ] + ; atr( str( ( fro )->NATTR2, 19, 4, '.' ) ) + [, ] + ; atr( str( ( fro )->NATTR3, 19, 4, '.' ) ) + [, ] + ; atr( str( ( fro )->NATTR4, 19, 4, '.' ) ) + [, ] + ; atr( str( ( fro )->NATTR5, 19, 4, '.' ) ) + [, ] + ; atr( str( ( fro )->NATTR6, 19, 4, '.' ) ) + [, ] + ; atr( str( ( fro )->NATTR7, 19, 4, '.' ) ) + [, ] + ; atr( str( ( fro )->NATTR8, 19, 4, '.' ) ) + [, ] + ; atr( str( ( fro )->NATTR9, 19, 4, '.' ) ) + [, ] + ; atr( str( ( fro )->NATTR10, 19, 4, '.' ) ) + [, '] + ; ( fro )->KINDDOC + [', '] + ; ( fro )->LVLNUM + [', '] + ; ( fro )->PARENT + [', '] + ; SqlDate( ( fro )->DATDOC ) + [', '] + ; ( fro )->EXTPARENT + [', '] + ; ( fro )->DREFL1 + [', ] + ; ( fro )->DANAL1 + [, '] + ; ( fro )->D1NAME + [', '] + ; ( fro )->DREFL2 + [', ] + ; ( fro )->DANAL2 + [, '] + ; ( fro )->D2NAME + [', '] + ; ( fro )->DREFL3 + [', ] + ; ( fro )->DANAL3 + [, '] + ; ( fro )->D3NAME + [', '] + ; ( fro )->KREFL1 + [', ] + ; ( fro )->KANAL1 + [, '] + ; ( fro )->K1NAME + [', '] + ; ( fro )->KREFL2 + [', ] + ; ( fro )->KANAL2 + [, '] + ; ( fro )->K2NAME + [', '] + ; ( fro )->KREFL3 + [', ] + ; ( fro )->KANAL3 + [, '] + ; ( fro )->K3NAME + [' ) ] SimpleSql( sql, conn ) ( fro )->( DbSkip() ) end // заполняем RGNUM'ы sql := [ Update DOCP] + Ret_f_ext( my ) + [ Set RGNUM = Right( ' ' + Trim( Convert( AUTOID, sql_char ) ), 8 ) Where RGNUM = ] SimpleSql( sql, conn ) sql := [ Update d Set d.PARENT = dd.RGNUM From DOCP] + Ret_f_ext( my ) + [ d left outer join DOCP] + Ret_f_ext( my ) + [ dd ON d.PARENT = dd.EXTPARENT ; Where d.LVLNUM = '2' and dd.LVLNUM = '1' ] SimpleSql( sql, conn ) finally CloseTable( fro ) FreeAndNil( conn ) HideMsg( msg ) end my := my + 1 end Message( 'Документы FRO успешно перенесены' ) // Select Right( ' ' + Trim( Convert( AUTOID, sql_char ) ), 8 ) From DOCP0117 // local conn, path, sql, t // path := '\\192.168.234.15:5050\vol1\FabiusWIN\data\srg\reflis\dict.add' // try // conn := CreateConnection( path, 'adm1user', "ora=11" ) // sql := [ Select * From R09 ] // t := SelectSql( sql, conn ) // finally // FreeAndNil( conn ) // CloseTable( t ) // end