...
P_LIST_SEPAR_PICKING_MAPA
Passando a Empresa, Carga e o Tipo de Separação: { 0-GERAL / 1-POR CIDADE / 2-POR BAIRRO / 3-CLIENTE / 4-PEDIDO / 5-PALETE(PESO) / 6-PALETE(CUBAGEM) / 7-RUA / 8-CLIENTE/PALETE ROTEIRIZADO }
UPDATE PLAN_SEP_MAPA_MERC_1196 SET QTD_FATURADA_CX_1196 = 0, QTD_FATURADA_UN_1196 = NVL((SELECT SUM (QTD_SEP_UN_541) QTD FROM PED_CONF_MERC_541 JOIN PED_CONF_538 ON EMPRESA_PF_538 = EMPRESA_PF_541 AND NUM_PED_CONF_PK_538 = NUM_PED_CONF_PF_541 AND CARREG_538 = :CARGA WHERE EMPRESA_PF_541 = EMPRESA_PF_1196 AND MERC_PF_541 = MERC_PF_1196 AND NOT EXISTS (SELECT 1 FROM PLAN_SEP_800 JOIN PLAN_SEP_EQUIPAM_MERC_802 ON EMPRESA_PF_802 = EMPRESA_PF_800 AND SEQ_PLANILHA_PF_802 = SEQ_PLANILHA_PK_800 WHERE EMPRESA_PEDCONF_FK_800 = EMPRESA_PF_538 AND NUM_PEDCONF_FK_800 = NUM_PED_CONF_PK_538)), 0) + NVL((SELECT SUM(CASE WHEN SITUACAO_802 = '3' THEN QTD_CONFERIDA_802 ELSE QTD_FATURADA_802 END) FROM PED_CONF_538, PLAN_SEP_800, PLAN_SEP_EQUIPAM_MERC_802 WHERE EMPRESA_PF_538 = EMPRESA_PF_1196 AND CARREG_538 = :CARGA AND EMPRESA_PEDCONF_FK_800 = EMPRESA_PF_538 AND NUM_PEDCONF_FK_800 = NUM_PED_CONF_PK_538 AND EMPRESA_PF_802 = EMPRESA_PF_800 AND SEQ_PLANILHA_PF_802 = SEQ_PLANILHA_PK_800 AND MERC_PF_802 = MERC_PF_1196 ), 0) , QTD_UNIDADE_1196 = NVL((SELECT SUM (QTD_SEP_UN_541) QTD FROM PED_CONF_MERC_541 JOIN PED_CONF_538 ON EMPRESA_PF_538 = EMPRESA_PF_541 AND NUM_PED_CONF_PK_538 = NUM_PED_CONF_PF_541 AND CARREG_538 = :CARGA WHERE EMPRESA_PF_541 = EMPRESA_PF_1196 AND MERC_PF_541 = MERC_PF_1196 AND NOT EXISTS (SELECT 1 FROM PLAN_SEP_800 JOIN PLAN_SEP_EQUIPAM_MERC_802 ON EMPRESA_PF_802 = EMPRESA_PF_800 AND SEQ_PLANILHA_PF_802 = SEQ_PLANILHA_PK_800 WHERE EMPRESA_PEDCONF_FK_800 = EMPRESA_PF_538 AND NUM_PEDCONF_FK_800 = NUM_PED_CONF_PK_538)), 0) + NVL((SELECT SUM(CASE WHEN SITUACAO_802 = '3' THEN QTD_CONFERIDA_802 ELSE QTD_FATURADA_802 END) FROM PED_CONF_538, PLAN_SEP_800, PLAN_SEP_EQUIPAM_MERC_802 WHERE EMPRESA_PF_538 = EMPRESA_PF_1196 AND CARREG_538 = :CARGA AND EMPRESA_PEDCONF_FK_800 = EMPRESA_PF_538 AND NUM_PEDCONF_FK_800 = NUM_PED_CONF_PK_538 AND EMPRESA_PF_802 = EMPRESA_PF_800 AND SEQ_PLANILHA_PF_802 = SEQ_PLANILHA_PK_800 AND MERC_PF_802 = MERC_PF_1196 ), 0) WHERE (EMPRESA_PF_1196, SEQ_PLANILHA_PF_1196) IN (SELECT EMPRESA_PF_1195, SEQ_PLANILHA_PK_1195 FROM PLAN_SEP_MAPA_1195 WHERE EMPRESA_PF_1195 = :EMPRESA AND CARGA_1195 = :CARGA) AND MERC_PF_1196 IN (SELECT MERC_PF_468 FROM MERC_EMPRESA_468 WHERE EMPRESA_PF_468 = :EMPRESA AND SN_PESO_VARIAVEL_468 = 'S');
...