sql_sub := 'insert into supermag.TTArticleDateProfit' ||
' (locid,article,forcmap,saledate,sum_notax,cp_notax)' ||
' select LOC_VAL,'||
'crd.article,' ||
'decode(crd.datatype,1,0,' || supermag.RepTools.LocString(20,'m') || ') forcmap' ||
s_dat || ' dat,' ||
'round(sum(decode(m.salelocationto,null,1,-1)*SUM_SPEC),' || SetSum.round_sum || ') sumspec_notax,' ||
'round(sum(decode(m.salelocationto,null,1,-1)*SUM_CP),' || SetSum.round_sum || ') cp_notax' ||
' from supermag.smcard crd,' || 'supermag.' || supermag.RepTools.GetMapRepTbl(:P_FirstDate,:P_LastDate) || ' m' ||
' where m.saleop in (' || SetSum.s_op_buyer_out || ',' || SetSum.s_op_buyer_in || ')' ||
' and m.saletype in (' || SetSum.s_type_buyer_out || ',' || SetSum.s_type_buyer_in || ')' ||
' and m.saledate between ' || supermag.Rep_Date(:P_FirstDate) ||
' and ' || supermag.Rep_Date(:P_LastDate) ||
' FORCMAP_WHERE' ||
' and crd.article=m.article' ||
supermag.RepTools.ClassString(4,'m') ||
supermag.RepTools.LocString(0,'nvl(m.salelocationfrom,m.salelocationto)') ||
' group by LOC_VAL,crd.article,decode(crd.datatype,1,0,' || supermag.RepTools.LocString(20,'m') || ')' || s_dat;