MMC Ter8 cc801306 0047 Terceiros
MMC Ter8 cc801306 0047 Terceiros
MMC Ter8 cc801306 0047 Terceiros
FieldFormula]
/***
BRLOC - BI - HAT - 8.01 -13/09/2001
Descricao: Chamada dos Paineis de estoque automaticamente(EXPRESS_ISSUE,PUTAWAY
_EXPRESS) para ser utilizado na solucao das novas operaoes fiscais
********************************************************************************
*****************************************
Leandro Rodrigues da Silva Souza - mmcbsds4813 Tuning - Melhorar o tempo do proc
esso de confirmao de nota fiscal
********************************************************************************
****************************************/
Function Select_NF_HDR_BBL_FS();
SQLExec("SELECT FLOW_ID_BBL, NF_IN_FLG_BBL, BUSINESS_UNIT_IN, SHIP_TO_CUST_ID
, ADDRESS_SEQ_SHIP, FLOW_BUS_UNIT_IN, STORAGE_AREA, STOR_LEVEL_1, STOR_LEVEL_2,
STOR_LEVEL_3, STOR_LEVEL_4 ,BUSINESS_UNIT_IN,RMNEIO_ID_BBL, LOCATION, DESTIN_BU
FROM PS_NF_HDR_BBL_FS WHERE NF_BRL_ID=:1 AND BUSINESS_UNIT=:2", &NF_BRL_ID, &BUS
_UNIT, &FLOW_ID_BBL, &NF_IN_FLG_BBL, &BUSINESS_UNIT_IN, &SHIP_TO_CUST_ID, &ADDRE
SS_SEQ_SHIP, &FLOW_BUS_UNIT_IN, &STORAGE_AREA, &STOR_LEVEL_1, &STOR_LEVEL_2, &ST
OR_LEVEL_3, &STOR_LEVEL_4, &BUSINESS_UNIT_IN, &RMNEIO_ID_BBL, &LOC_DEST_TO, &DES
T_TO);
End-Function;
Function Select_NF_FLOW_BBL();
SQLExec("SELECT RMA_FLG_BBL, AR_FLG_BBL, PND_ITEM_TYPE_BBL, DOC_CLASS_BBL,GL_
FLG_BBL,NF_ACT_TMPL_BBL, DT_FLG_BBL, DT_TERM_BBL, CALC_FLG_BBL, LINK_FLG_BBL, SH
IP_FLG_BBL, SHIP_TRAN_FLG_BBL, RECV_FLG_BBL, RECV_TRAN_FLG_BBL, LOCATION_TO, NF_
ACT_TMPL_BBL,DESCR50 FROM PS_NF_FLOW_BBL WHERE SETID = :1 AND FLOW_ID_BBL = :2",
&SETID, &FLOW_ID_BBL, &RMA_FLG_BBL, &AR_FLG_BBL, &PND_ITEM_TYPE_BBL, &DOC_CLASS
_BBL, &GL_FLG_BBL, &NF_ACT_TMPL_BBL, &DT_FLG_BBL, &DT_TERM_BBL, &CALC_FLG_BBL, &
LINK_FLG_BBL, &SHIP_FLG_BBL, &SHIP_TRAN_FLG_BBL, &RECV_FLG_BBL, &RECV_TRAN_FLG_B
BL, &LOCATION_TO, &NF_ACT_TMPL_BBL, &DESCR50);
End-Function;
Function Select_NF_FLOW_DRV_BBL();
SQLExec("SELECT FLOW_ID_DRV_BBL, SHIPTO_FLG_BBL, TOF_PBL FROM PS_NF_FLOW_DRV_
BBL WHERE SETID = :1 AND FLOW_ID_BBL = :2 ", &SETID, &FLOW_ID_BBL, &FLOW_ID_DRV_
BBL, &SHIPTO_FLG_BBL, &TOF_PBL);
End-Function;
Function Select_NF_LN_BBL_FS();
SQLExec("SELECT DEMAND_SOURCE FROM PS_NF_LN_BBL_FS WHERE BUSINESS_UNIT = :1 A
ND NF_BRL_ID = :2 AND NF_BRL_LINE_NUM = 1 ", &BUS_UNIT, &NF_BRL_ID, &DEMAND_SOUR
CE);
End-Function;
Function call_pages_inv(&NF, &BU) Returns boolean ;
&NF_BRL_ID = &NF;
&BUS_UNIT = &BU;
&SETID = GetSetId("BUSINESS_UNIT", &BU, Record.NF_HDR_BBL_FS, "");
/******* mmcbsds4813.on *********
Select_NF_HDR_BBL_FS();
Select_NF_FLOW_BBL();
Select_NF_FLOW_DRV_BBL();
******* mmcbsds4813.oe ********/
If All(&FLOW_ID_BBL) And
(None(&DEMAND_SOURCE) Or
&DEMAND_SOURCE = "OM") And
&NF_IN_FLG_BBL <> "Y" Then
/******
Definicao de Variaveis a serem usadas nos Insert abaixos
******/
&TASK_ID = 0;
&USER = %OperatorId;
&DATE = %Date;
/***
Chamar a EXPRESS_ISSUE para fazer requisio externa
***/
If &SHIP_FLG_BBL = "Y" Then
/****
Zera Flags de acompanhamento de processamento
****/
MSR_EXP_BBL_WRK.FLAG_RETURN_OK = "N";
MSR_EXP_BBL_WRK.FLAG = "N";
&ACTION = "A";
MSR_EXP_BBL_WRK.BUSINESS_UNIT = &BUSINESS_UNIT_IN;
MSR_EXP_BBL_WRK.CUST_ID = &SHIP_TO_CUST_ID;
MSR_EXP_BBL_WRK.ADDRESS_SEQ_SHIP = &ADDRESS_SEQ_SHIP;
MSR_EXP_BBL_WRK.BUSINESS_UNIT_BI = &BUS_UNIT;
MSR_EXP_BBL_WRK.NF_BRL_ID = &NF_BRL_ID;
MSR_EXP_BBL_WRK.ORDER_NO = "NEXT";
MSR_EXP_BBL_WRK.REQUEST_TYPE = "E";
MSR_EXP_BBL_WRK.BUSINESS_UNIT_IN = &BUSINESS_UNIT_IN;
MSR_EXP_BBL_WRK.LOCATION = &LOC_DEST_TO;
MSR_EXP_BBL_WRK.DESTIN_BU = &DEST_TO;
/* BRLOC-BI-FARID-NEW-BEGIN-14/01/2004 ICE RESOL 150351
*/
/* Descrio: inclusao dos campos MSR_EXP_BBL_WRK.LOCATION e MSR_EXP_BBL_WR
K.DESTIN_BU para */
/* as tranferencias entre unidades
*/
MSR_EXP_BBL_WRK.LOCATION = &LOC_DEST_TO;
MSR_EXP_BBL_WRK.DESTIN_BU = &DEST_TO;
/* BRLOC-BI-FARID-END-BEGIN-14/01/2004 ICE RESOL 150351
*/
DoModalPanelGroup(MenuName.FULFILL_STOCK_ORDERS, BarName.USE2, ItemName
.EXPRESS_ISSUE, Panel.EXPRESS_ISSUE, &ACTION, Record.MSR_EXP_BBL_WRK);
If MSR_EXP_BBL_WRK.FLAG_RETURN_OK = "Y" Then
&INVENTORY_FLAG = "Y";
&TASK_DESC = "Express Issue processado com sucesso ";
Else
&INVENTORY_FLAG = "N";
&TASK_DESC = "Express Issue no processado.Precisa ser feito manualmen
te";
End-If;
/****
Grava log de processamento inventario
****/
&TASK_ID = &TASK_ID + 1;
If &TASK_ID <> 1 Then
InsertRow(Scroll.NF_INV_LOG_BBL, &TASK_ID - 1, True);
End-If;
/* InsertRow(Record.NF_INV_LOG_BBL, 1); */
UpdateValue(NF_INV_LOG_BBL.BUSINESS_UNIT, 1, MSR_EXP_BBL_WRK.BUSINESS_U
NIT_BI);
UpdateValue(NF_INV_LOG_BBL.NF_BRL_ID, 1, MSR_EXP_BBL_WRK.NF_BRL_ID);
UpdateValue(NF_INV_LOG_BBL.TASK_ID, 1, &TASK_ID);
UpdateValue(NF_INV_LOG_BBL.TASK_DESC, 1, &TASK_DESC);
UpdateValue(NF_INV_LOG_BBL.CREATED_BY_USER, 1, &USER);
UpdateValue(NF_INV_LOG_BBL.CREATE_DATE, 1, &DATE);
UpdateValue(NF_INV_LOG_BBL.INVENTORY_FLAG, 1, &INVENTORY_FLAG);
End-If;
/***
Chamar a EXPRESS_ISSUE para fazer requisio de transferencia entre unidades
***/
If &SHIP_TRAN_FLG_BBL = "Y" Then
/****
Zera Flags de acompanhamento de processamento
****/
MSR_EXP_BBL_WRK.FLAG_RETURN_OK = "N";
MSR_EXP_BBL_WRK.FLAG = "N";
&ACTION = "A";
MSR_EXP_BBL_WRK.BUSINESS_UNIT = &BUSINESS_UNIT_IN;
MSR_EXP_BBL_WRK.CUST_ID = &SHIP_TO_CUST_ID;
MSR_EXP_BBL_WRK.ADDRESS_SEQ_SHIP = &ADDRESS_SEQ_SHIP;
MSR_EXP_BBL_WRK.BUSINESS_UNIT_BI = &BUS_UNIT;
MSR_EXP_BBL_WRK.NF_BRL_ID = &NF_BRL_ID;
MSR_EXP_BBL_WRK.ORDER_NO = &NF_BRL_ID;
MSR_EXP_BBL_WRK.REQUEST_TYPE = "U";
MSR_EXP_BBL_WRK.FLOW_BUS_UNIT_IN = &FLOW_BUS_UNIT_IN;
MSR_EXP_BBL_WRK.BUSINESS_UNIT_IN = &BUSINESS_UNIT_IN;
MSR_EXP_BBL_WRK.RMNEIO_ID_BBL = &RMNEIO_ID_BBL;
/* BRLOC-BI-FARID-NEW-BEGIN-14/01/2004
*/
MSR_EXP_BBL_WRK.LOCATION = &LOC_DEST_TO;
MSR_EXP_BBL_WRK.DESTIN_BU = &DEST_TO;
/* BRLOC-BI-FARID-END-BEGIN-14/01/2004 ICE RESOL 150351
*/
DoModalPanelGroup(MenuName.FULFILL_STOCK_ORDERS, BarName.USE2, ItemName
.EXPRESS_ISSUE, Panel.EXPRESS_ISSUE, &ACTION, Record.MSR_EXP_BBL_WRK);
If MSR_EXP_BBL_WRK.FLAG_RETURN_OK = "Y" Then
&INVENTORY_FLAG = "Y";
&TASK_DESC = "Express Issue (Transferencia) Saida processada com suc
esso";
Else
&INVENTORY_FLAG = "N";
&TASK_DESC = "Express Issue (Transferencia) Saida no processada.Preci
sa ser feito manualmente";
End-If;
/****
Grava log de processamento inventario
****/
&TASK_ID = &TASK_ID + 1;
If &TASK_ID <> 1 Then
InsertRow(Scroll.NF_INV_LOG_BBL, &TASK_ID - 1, True);
End-If;
UpdateValue(NF_INV_LOG_BBL.BUSINESS_UNIT, &TASK_ID, MSR_EXP_BBL_WRK.BUS
INESS_UNIT_BI);
UpdateValue(NF_INV_LOG_BBL.NF_BRL_ID, &TASK_ID, MSR_EXP_BBL_WRK.NF_BRL_
ID);
UpdateValue(NF_INV_LOG_BBL.TASK_ID, &TASK_ID, &TASK_ID);
UpdateValue(NF_INV_LOG_BBL.TASK_DESC, &TASK_ID, &TASK_DESC);
UpdateValue(NF_INV_LOG_BBL.CREATED_BY_USER, &TASK_ID, &USER);
UpdateValue(NF_INV_LOG_BBL.CREATE_DATE, &TASK_ID, &DATE);
UpdateValue(NF_INV_LOG_BBL.INVENTORY_FLAG, &TASK_ID, &INVENTORY_FLAG);
/****
Fazer o DEPLETION para que possa ser feita o recebimento da transferencia
****/
&TASK_ID = &TASK_ID + 1;
If &TASK_ID <> 1 Then
InsertRow(Scroll.NF_INV_LOG_BBL, &TASK_ID - 1, True);
End-If;
&INVENTORY_FLAG = "N";
&TASK_DESC = "Fazer o Depletion do EXPRESS ISSUE de transferencia ";
UpdateValue(NF_INV_LOG_BBL.BUSINESS_UNIT, &TASK_ID, MSR_EXP_BBL_WRK.BUS
INESS_UNIT_BI);
UpdateValue(NF_INV_LOG_BBL.NF_BRL_ID, &TASK_ID, MSR_EXP_BBL_WRK.NF_BRL_
ID);
UpdateValue(NF_INV_LOG_BBL.TASK_ID, &TASK_ID, &TASK_ID);
UpdateValue(NF_INV_LOG_BBL.TASK_DESC, &TASK_ID, &TASK_DESC);
UpdateValue(NF_INV_LOG_BBL.CREATED_BY_USER, &TASK_ID, &USER);
UpdateValue(NF_INV_LOG_BBL.CREATE_DATE, &TASK_ID, &DATE);
UpdateValue(NF_INV_LOG_BBL.INVENTORY_FLAG, &TASK_ID, &INVENTORY_FLAG);
/****
Grava registro no log de processamento inventario da tarefa a ser realizada
****/
&TASK_ID = &TASK_ID + 1;
If &TASK_ID <> 1 Then
InsertRow(Scroll.NF_INV_LOG_BBL, &TASK_ID - 1, True);
End-If;
&INVENTORY_FLAG = "N";
&TASK_DESC = "Fazer o Recebimento de transferencia entre unidades";
UpdateValue(NF_INV_LOG_BBL.BUSINESS_UNIT, &TASK_ID, MSR_EXP_BBL_WRK.BUS
INESS_UNIT_BI);
UpdateValue(NF_INV_LOG_BBL.NF_BRL_ID, &TASK_ID, MSR_EXP_BBL_WRK.NF_BRL_
ID);
UpdateValue(NF_INV_LOG_BBL.TASK_ID, &TASK_ID, &TASK_ID);
UpdateValue(NF_INV_LOG_BBL.TASK_DESC, &TASK_ID, &TASK_DESC);
UpdateValue(NF_INV_LOG_BBL.CREATED_BY_USER, &TASK_ID, &USER);
UpdateValue(NF_INV_LOG_BBL.CREATE_DATE, &TASK_ID, &DATE);
UpdateValue(NF_INV_LOG_BBL.INVENTORY_FLAG, &TASK_ID, &INVENTORY_FLAG);
UpdateValue(NF_INV_LOG_BBL.FLOW_BUS_UNIT_IN, &TASK_ID, &FLOW_BUS_UNIT_I
N);
UpdateValue(NF_INV_LOG_BBL.STORAGE_AREA, &TASK_ID, &STORAGE_AREA);
UpdateValue(NF_INV_LOG_BBL.STOR_LEVEL_1, &TASK_ID, &STOR_LEVEL_1);
UpdateValue(NF_INV_LOG_BBL.STOR_LEVEL_2, &TASK_ID, &STOR_LEVEL_2);
UpdateValue(NF_INV_LOG_BBL.STOR_LEVEL_3, &TASK_ID, &STOR_LEVEL_3);
UpdateValue(NF_INV_LOG_BBL.STOR_LEVEL_4, &TASK_ID, &STOR_LEVEL_4);
End-If;
/***
Chamar a PUTAWAY_EXPRESS para fazer entrada expressa
***/
If &RECV_FLG_BBL = "Y" Then
/****
Zera Flags de acompanhamento de processamento
****/
MSR_EXP_BBL_WRK.BUSINESS_UNIT = &BUSINESS_UNIT_IN;
MSR_EXP_BBL_WRK.FLAG_RETURN_OK = "N";
MSR_EXP_BBL_WRK.FLAG = "N";
&ACTION = "U";
MSR_EXP_BBL_WRK.ORDER_NO = "NEXT";
MSR_EXP_BBL_WRK.REQUEST_TYPE = "U";
MSR_EXP_BBL_WRK.BUSINESS_UNIT_BI = &BUS_UNIT;
MSR_EXP_BBL_WRK.NF_BRL_ID = &NF_BRL_ID;
MSR_EXP_BBL_WRK.BUSINESS_UNIT_IN = &BUSINESS_UNIT_IN;
DoModalPanelGroup(MenuName.PUTAWAY_STOCK, BarName.USE, ItemName.EXPRESS
_PUTAWAY, Panel.EXPRESS_PUTAWAY, &ACTION, Record.MSR_EXP_BBL_WRK);
If MSR_EXP_BBL_WRK.FLAG_RETURN_OK = "Y" Then
&INVENTORY_FLAG = "Y";
&TASK_DESC = "Putaway Express (Entrada) processada com sucesso ";
Else
&INVENTORY_FLAG = "N";
&TASK_DESC = "Putaway Express (Entrada) no processada.Precisa ser fei
to manualmente ";
End-If;
/****
Grava log de processamento inventario
****/
&TASK_ID = &TASK_ID + 1;
If &TASK_ID <> 1 Then
InsertRow(Scroll.NF_INV_LOG_BBL, &TASK_ID - 1, True);
End-If;
UpdateValue(NF_INV_LOG_BBL.BUSINESS_UNIT, &TASK_ID, MSR_EXP_BBL_WRK.BUS
INESS_UNIT_BI);
UpdateValue(NF_INV_LOG_BBL.NF_BRL_ID, &TASK_ID, MSR_EXP_BBL_WRK.NF_BRL_
ID);
UpdateValue(NF_INV_LOG_BBL.TASK_ID, &TASK_ID, &TASK_ID);
UpdateValue(NF_INV_LOG_BBL.TASK_DESC, &TASK_ID, &TASK_DESC);
UpdateValue(NF_INV_LOG_BBL.CREATED_BY_USER, &TASK_ID, &USER);
UpdateValue(NF_INV_LOG_BBL.CREATE_DATE, &TASK_ID, &DATE);
UpdateValue(NF_INV_LOG_BBL.INVENTORY_FLAG, &TASK_ID, &INVENTORY_FLAG);
End-If;
/***
Chamar a EXPRESS_ISSUE para fazer Transferencia como sendo entrada
***/
If &RECV_TRAN_FLG_BBL = "Y" Then
/****
Zera Flags de acompanhamento de processamento
****/
MSR_EXP_BBL_WRK.FLAG_RETURN_OK = "N";
MSR_EXP_BBL_WRK.FLAG = "Y";
&ACTION = "A";
MSR_EXP_BBL_WRK.BUSINESS_UNIT = &FLOW_BUS_UNIT_IN;
MSR_EXP_BBL_WRK.CUST_ID = &SHIP_TO_CUST_ID;
MSR_EXP_BBL_WRK.ADDRESS_SEQ_SHIP = &ADDRESS_SEQ_SHIP;
MSR_EXP_BBL_WRK.BUSINESS_UNIT_BI = &BUS_UNIT;
MSR_EXP_BBL_WRK.ORDER_NO = &NF_BRL_ID;
MSR_EXP_BBL_WRK.REQUEST_TYPE = "U";
MSR_EXP_BBL_WRK.FLOW_BUS_UNIT_IN = &BUSINESS_UNIT_IN;
DoModalPanelGroup(MenuName.FULFILL_STOCK_ORDERS, BarName.USE2, ItemName
.EXPRESS_ISSUE, Panel.EXPRESS_ISSUE, &ACTION, Record.MSR_EXP_BBL_WRK);
If MSR_EXP_BBL_WRK.FLAG_RETURN_OK = "Y" Then
&INVENTORY_FLAG = "Y";
&TASK_DESC = "Express Issue (Transferencia) Saida processada com suc
esso";
Else
&INVENTORY_FLAG = "N";
&TASK_DESC = "Express Issue (Transferencia) Saida no processada.Preci
sa ser feito manualmente";
End-If;
/****
Grava log de processamento inventario
****/
&TASK_ID = &TASK_ID + 1;
If &TASK_ID <> 1 Then
InsertRow(Scroll.NF_INV_LOG_BBL, &TASK_ID - 1, True);
End-If;
UpdateValue(NF_INV_LOG_BBL.BUSINESS_UNIT, &TASK_ID, MSR_EXP_BBL_WRK.BUS
INESS_UNIT_BI);
UpdateValue(NF_INV_LOG_BBL.NF_BRL_ID, &TASK_ID, MSR_EXP_BBL_WRK.NF_BRL_
ID);
UpdateValue(NF_INV_LOG_BBL.TASK_ID, &TASK_ID, &TASK_ID);
UpdateValue(NF_INV_LOG_BBL.TASK_DESC, &TASK_ID, &TASK_DESC);
UpdateValue(NF_INV_LOG_BBL.CREATED_BY_USER, &TASK_ID, &USER);
UpdateValue(NF_INV_LOG_BBL.CREATE_DATE, &TASK_ID, &DATE);
UpdateValue(NF_INV_LOG_BBL.INVENTORY_FLAG, &TASK_ID, &INVENTORY_FLAG);
/****
Fazer o DEPLETION para que possa ser feita o recebimento da transferencia
****/
&TASK_ID = &TASK_ID + 1;
If &TASK_ID <> 1 Then
InsertRow(Scroll.NF_INV_LOG_BBL, &TASK_ID - 1, True);
End-If;
&INVENTORY_FLAG = "N";
&TASK_DESC = "Fazer o Depletion do EXPRESS ISSUE de transferencia ";
UpdateValue(NF_INV_LOG_BBL.BUSINESS_UNIT, &TASK_ID, MSR_EXP_BBL_WRK.BUS
INESS_UNIT_BI);
UpdateValue(NF_INV_LOG_BBL.NF_BRL_ID, &TASK_ID, MSR_EXP_BBL_WRK.NF_BRL_
ID);
UpdateValue(NF_INV_LOG_BBL.TASK_ID, &TASK_ID, &TASK_ID);
UpdateValue(NF_INV_LOG_BBL.TASK_DESC, &TASK_ID, &TASK_DESC);
UpdateValue(NF_INV_LOG_BBL.CREATED_BY_USER, &TASK_ID, &USER);
UpdateValue(NF_INV_LOG_BBL.CREATE_DATE, &TASK_ID, &DATE);
UpdateValue(NF_INV_LOG_BBL.INVENTORY_FLAG, &TASK_ID, &INVENTORY_FLAG);
/****
Grava registro no log de processamento inventario da tarefa a ser realizada
****/
&TASK_ID = &TASK_ID + 1;
[FUNCLIB_OF.FLOW_ID_BBL.FieldFormula]
/*** DECLARAES ***/
Declare Function replace_meta_data PeopleCode FUNCLIB_OM.RULE_ID_PBL FieldFormul
a;
/*** NF Derived ***/
Local array of string &d_value;
Local array of string &d_doc;
Local array of string &d_flowid;
Local array of string &d_tof;
Local array of string &d_lttof;
Local array of string &d_shipto;
Local array of string &d_ar;
Local array of string &d_arp;
/*** NF Text Related ***/
Local array of string &t_doc;
Local array of string &t_text;
/**** Value Formulate ***/
Local array of string &v_doc;
/*** NF Line - Value Formulate ***/
Local array of number &l_value;
Local array of number &l_seq;
Local array of number &l_qty;
Local array of string &l_item;
Local array of number &l_uvalue;
Local array of number &l_nvalue;
Local array of number &l_ouvalue;
Local array of number &l_onvalue;
/**** Variables beyond function escope ***/
/*PREP*/
Local string &NF_BRL_ID;
Local string &BUSINESS_UNIT;
Local string &SETID;
Local string &FLOW_ID_BBL;
Local string &FLOW_ID_BBL2;
Local string &TOF2;
Local string &BUS_UNIT_REF_BBL;
/*flow struct*/
Local string &DOC_CLASS_BBL;
Local string &DT_FLG_BBL;
Local number &DT_TERM_BBL;
Local string &PND_ITEM_TYPE_BBL;
Local string &RMA_FLG_BBL;
Local string &AR_FLG_BBL;
Local string &SHIP_TRAN;
Local string &RECV_TRAN;
/*HDR*/
/*Local string &BUSINESS_UNIT;*/
/*Local string &NF_BRL_ID;*/
Local string &NF_BRL_SERIES;
Local string &SHIP_TO_CUST_ID;
Local number &ADDRESS_SEQ_SHIP;
Local string &LOCATION;
Local string &DESTIN_BU;
Local string &BILL_TO_CUST_ID;
Local number &ADDRESS_SEQ_NUM;
Local string &NF_BRL_TYPE;
Local string &SHIP_FROM_STATE;
Local string &SHIP_BRL_TO_STATE;
Local string &BUSINESS_UNIT_GL;
Local string &CURRENCY_CD;
Local string &RT_TYPE;
Local number &RATE_MULT;
Local number &RATE_DIV;
Local string &CURRENCY_CD_BASE;
Local string &PYMENT_TERMS_CD;
Local string &COUNTRY;
Local string &STATE;
Local string &PRORATE_METH_BBL;
Local string <_GRP_ID_BBL;
Local string &TXN_NAT_BBL;
Local string &IN_OUT_CD_BBL;
/*Local string &PND_ITEM_TYPE_BBL;*/
/*Local string &RMA_FLG_BBL;*/
Local string &TIE_NF_FLG_BBL;
Local string &BUSINESS_UNIT_IN;
Local string &DST_ID_AR;
Local string &EF_LOC_BRL;
/*Local string &FLOW_ID_BBL2;*/
Local string &FLOW_BUS_UNIT_IN;
Local string &STORAGE_AREA;
Local string &STOR_LEVEL_1;
Local string &STOR_LEVEL_2;
Local string &STOR_LEVEL_3;
Local string &STOR_LEVEL_4;
/*LT->HDR*/
/*Local string &NF_BRL_TYPE;*/
/*Local string &TXN_NAT_BBL;*/
/*Local string &IN_OUT_CD_BBL;*/
Local string
Local string
Local string
Local string
Local string
Local string
/*LINE*/
Local string
Local string
Local string
Local string
Local number
Local number
Local number
Local string
Local number
Local number
Local string
Local string
Local string
Local string
Local string
Local string
Local string
Local string
Local string
Local string
Local number
Local string
Local string
Local number
Local number
Local number
Local number
Local number
Local number
Local number
Local number
Local number
Local string
Local string
Local string
Local string
Local number
Local string
/**/
Local string
Local string
/**/
Local string
&CFOP_STATE_BBL;
&CFOP_EXT_STATE_BBL;
&CFOP_INTST_BBL;
&CFOP_EXT_INTST_BBL;
&CFOP_INTNT_BBL;
&CFOP_EXT_INTNT_BBL;
&NF_BRL_LINE_NUM;
&INVITEM_SETID;
&INV_ITEM_ID;
&DESCR;
&MERCHANDISE_AMT;
&MERCH_AMT_BSE;
&QTY_NF_BRL;
&UNIT_OF_MEASURE;
&UNIT_PRICE;
&NET_UNIT_PRICE;
&CURRENCY_CD2;
&CURRENCY_CD_BASE2;
&CFO_BRL_CD;
&PURCH_PROP_BRL;
&TAX_CLASS_BRL;
&TOF_PBL;
&NF_LINE_TYPE_BBL;
&DEMAND_SOURCE;
&SOURCE_BUS_UNIT;
&PRODUCT_ID;
&KIT_LINE_NBR;
&ITEM_ORIGIN_BBL;
&CFOP_EXT_CD_BBL;
&UNIT_AMT_BSE_BBL;
&NET_AMT_BSE_BBL;
&UNIT_COST;
<_IPI_BSE_BBL;
<_ICMS_BSE_BBL;
<_ICMS_ST_BSE_BBL;
<_PIS_BSE_BBL;
<_COFINS_BSE_BBL;
<_ISS_BSE_BBL;
&NF_ACT_TMPL_BBL;
&DST_ID_DIS;
&DST_ID_REV;
&DST_ID_SUR;
<_PISS_BSE_BBL;
&IF_BRL;
&COUNTRY_FROM;
&COUNTRY_TO;
&LIXO;
Function Declare_Scroll_DRV();
&d_value = CreateArrayRept("", 0);
&d_doc = CreateArrayRept("", 0);
&d_flowid = CreateArrayRept("", 0);
&d_tof = CreateArrayRept("", 0);
&d_lttof = CreateArrayRept("", 0);
&d_shipto = CreateArrayRept("", 0);
&d_ar = CreateArrayRept("", 0);
&d_arp = CreateArrayRept("", 0);
End-Function;
Function Declare_Scroll_REL();
&t_doc = CreateArrayRept("", 0);
&t_text = CreateArrayRept("", 0);
End-Function;
Function Declare_Scroll_FRM();
&v_doc = CreateArrayRept("", 0);
End-Function;
/*** GERAIS ***/
Function GetSetId_Flow(&BUSINESS_UNIT) Returns string ;
&RET_SETID = GetSetId("BUSINESS_UNIT", &BUSINESS_UNIT, Record.NF_FLOW_BBL, ""
);
Return (&RET_SETID);
End-Function;
Function GetSetId_Cust(&BUSINESS_UNIT) Returns string ;
&RET_SETID = GetSetId("BUSINESS_UNIT", &BUSINESS_UNIT, Record.CUSTOMER, "");
Return (&RET_SETID);
End-Function;
Function GetSetId_LT(&BUSINESS_UNIT) Returns string ;
&RET_SETID = GetSetId("BUSINESS_UNIT", &BUSINESS_UNIT, Record.LT_GRP_BBL, "")
;
Return (&RET_SETID);
End-Function;
Function GetSetId_Loc(&BUSINESS_UNIT) Returns string ;
&RET_SETID = GetSetId("BUSINESS_UNIT", &BUSINESS_UNIT, Record.LOCATION_TBL, "
");
Return (&RET_SETID);
End-Function;
Function GetNbrStart() Returns number ;
&QRY = "SELECT NF_BRL_NUM_LASTUSE FROM PS_INSTALLATION ";
SQLExec(&QRY, &RET);
Return &RET;
End-Function;
/*** BRLOC_BI - SBRITO - JUL/2001 - Pega dados da NF ***/
Function GetNF_FlowID(&NF_BRL_ID, &BUSINESS_UNIT) Returns string ;
&QRY = "SELECT FLOW_ID_BBL FROM PS_NF_HDR_BBL_FS WHERE ";
&QRY = &QRY | " NF_BRL_ID=:1 AND BUSINESS_UNIT=:2 ";
SQLExec(&QRY, &NF_BRL_ID, &BUSINESS_UNIT, &RET);
Return &RET;
End-Function;
/*** BRLOC_BI - SBRITO - JUL/2001 - Pega Flow da NF ***/
Function GetFlow_Struct(&FLOW_ID_BBL, &SETID) Returns boolean ;
&QRY = "SELECT DOC_CLASS_BBL,DT_FLG_BBL,DT_TERM_BBL,PND_ITEM_TYPE_BBL,RMA_FLG
_BBL,";
&QRY = &QRY | "AR_FLG_BBL,SHIP_TRAN_FLG_BBL,RECV_TRAN_FLG_BBL ";
&QRY = &QRY | "FROM PS_NF_FLOW_BBL WHERE FLOW_ID_BBL=:1 AND SETID=:2 ";
SQLExec(&QRY, &FLOW_ID_BBL, &SETID, &DOC_CLASS_BBL, &DT_FLG_BBL, &DT_TERM_BBL
, &PND_ITEM_TYPE_BBL, &RMA_FLG_BBL, &AR_FLG_BBL, &SHIP_TRAN, &RECV_TRAN);
If All(&DOC_CLASS_BBL) Then
Return True;
Else
Return False;
End-If;
End-Function;
/*** BRLOC_BI - SBRITO - JUL/2001 - Pega NF Derived ***/
Function GetNF_Derived(&FLOW_ID_BBL, &SETID, &EXT, <_EXT, &TOF_EXT, &VAL_EXT)
Returns boolean ;
Declare_Scroll_DRV();
If &EXT = False Then
&QRY = "SELECT DOC_CLASS_BBL,FLOW_ID_DRV_BBL,SHIPTO_FLG_BBL,TOF_PBL,LT_GRP
_ID_BBL,";
&QRY = &QRY | "NF_VAL_CREATE_BBL,AR_FLG_BBL,PND_ITEM_TYPE_BBL FROM PS_NF_F
LOW_BBL A,PS_NF_FLOW_DRV_BBL B ";
&QRY = &QRY | "WHERE B.FLOW_ID_BBL=:1 AND B.SETID=:2 AND ";
&QRY = &QRY | "A.FLOW_ID_BBL=B.FLOW_ID_BBL AND A.SETID=B.SETID ";
&SQL2 = CreateSQL(&QRY, &FLOW_ID_BBL, &SETID);
&RET = False;
While &SQL2.Fetch(&DOC_CLASS_BBL3, &FLOW_ID_DRV_BBL, &SHIPTO_FLG_BBL, &TOF
_PBL, <_GRP_ID_BBL, &NF_VAL_CREATE_BBL, &AR_FLG_BBL2, &PYMENT_TERMS_CD2)
&d_flowid.Push(&FLOW_ID_DRV_BBL);
&d_value.Push(&NF_VAL_CREATE_BBL);
&d_doc.Push(&DOC_CLASS_BBL3);
&d_tof.Push(&TOF_PBL);
&d_lttof.Push(<_GRP_ID_BBL);
&d_shipto.Push(&SHIPTO_FLG_BBL);
&d_ar.Push(&AR_FLG_BBL2);
&d_arp.Push(&PYMENT_TERMS_CD2);
&RET = True;
End-While;
&SQL2.Close();
Else
&RET = True;
&d_flowid.Push(&FLOW_ID_BBL);
&d_value.Push(&VAL_EXT);
&d_doc.Push(&DOC_CLASS_BBL);
&d_tof.Push(&TOF_EXT);
&d_lttof.Push(<_EXT);
&d_shipto.Push("N");
&d_ar.Push(&AR_FLG_BBL);
&d_arp.Push(&PND_ITEM_TYPE_BBL);
End-If;
Return &RET;
End-Function;
/*** BRLOC_BI - SBRITO - JUL/2001 - Pega 1a NF do processo ***/
Function GetNF_Father(&NF_BRL_ID, &BUSINESS_UNIT) Returns string ;
&RET = "";
&QRY = "SELECT NF_PAI_ID_BBL,BUS_UNIT_REF_BBL FROM PS_NF_LINK_BBL WHERE ";
&QRY = &QRY | " NF_BRL_ID=:1 AND BUSINESS_UNIT=:2 ";
SQLExec(&QRY, &NF_BRL_ID, &BUSINESS_UNIT, &RET, &BUS_UNIT_REF_BBL);
If None(&RET) Or
&RET = "" Then
&RET = &NF_BRL_ID;
&BUS_UNIT_REF_BBL = &BUSINESS_UNIT;
End-If;
Return &RET;
End-Function;
/*** RESOLUO DE TEXTOS RELACIONADOS ***/
&text = &t_text2[&i];
&NF_PAI = GetNF_Father(&NF_BRL_ID, &BUSINESS_UNIT);
&NEW_TEXT = GetTextRelated(&BUS_UNIT_REF_BBL, &NF_PAI, &BUSINESS_UNI
T, &NF_BRL_ID, &doc);
SQLExec("select DESCR254, TXT_NF_PRINT_BBL from PS_TXTTBL_PBL where
TEXT_PBL = :1", &text, &DESCR, &NF_PRINT);
&DESCR = Substitute(&DESCR, "%%NF-RELAC%%", &NEW_TEXT);
Insert_text(&text, &DESCR, &NF_PRINT);
End-For;
Else
End-If;
Else
End-If;
End-Function;
/*** RESOLUO DE HEADER ***/
/*** BRLOC_BI - SBRITO - AGO/2001 - Pega dst_id_ar ***/
Function GetDST_ID_AR(&SETID, &CUST_ID) Returns string ;
&QRY = "SELECT DST_ID_AR,PYMNT_TERMS_CD FROM PS_CUST_OPTION A WHERE ";
&QRY = &QRY | " A.SETID = :1 AND A.CUST_ID = :2 AND A.EFFDT = ( ";
&QRY = &QRY | " SELECT MAX(B.EFFDT) FROM PS_CUST_OPTION B ";
&QRY = &QRY | " WHERE B.SETID = A.SETID AND B.CUST_ID = A.CUST_ID ";
&QRY = &QRY | " AND A.EFFDT <= %currentdatein) AND A.EFF_STATUS = 'A' ";
SQLExec(&QRY, &SETID, &CUST_ID, &RET, &PYMENT_TERMS_CD);
Return &RET;
End-Function;
/*** BRLOC_BI - SBRITO - AGO/2001 - Pega dados de CFOP da OF ***/
Function GetOF_Data(&TOF);
&QRY = "SELECT F.CFOP_STATE_BBL,F.CFOP_EXT_STATE_BBL,F.CFOP_INTST_BBL,F.CFOP_
EXT_INTST_BBL,";
&QRY = &QRY | "F.CFOP_INTNT_BBL,F.CFOP_EXT_INTNT_BBL FROM PS_TOF_TYPE_PBL F W
HERE ";
&QRY = &QRY | " F.TOF_PBL = :1 AND F.EFFDT = ( ";
&QRY = &QRY | " SELECT MAX(B.EFFDT) FROM PS_TOF_TYPE_PBL B WHERE ";
&QRY = &QRY | " B.TOF_PBL = F.TOF_PBL AND B.EFFDT <= %currentdatein) AND F.EF
F_STATUS = 'A' ";
SQLExec(&QRY, &TOF, &CFOP_STATE_BBL, &CFOP_EXT_STATE_BBL, &CFOP_INTST_BBL, &C
FOP_EXT_INTST_BBL, &CFOP_INTNT_BBL, &CFOP_EXT_INTNT_BBL);
End-Function;
/*** BRLOC_BI - SBRITO - AGO/2001 - Determina CFOP da NF ***/
Function setCFOP();
If All(&SHIP_FROM_STATE) And
All(&SHIP_BRL_TO_STATE) Then
If &SHIP_FROM_STATE = &SHIP_BRL_TO_STATE Then
&CFO_BRL_CD = &CFOP_STATE_BBL;
&CFO_EXT_CD_BBL = &CFOP_EXT_STATE_BBL;
Else
&CFO_BRL_CD = &CFOP_INTST_BBL;
&CFO_EXT_CD_BBL = &CFOP_EXT_INTST_BBL;
If All(&COUNTRY_FROM) And
All(&COUNTRY_TO) Then
If &COUNTRY_FROM = &COUNTRY_TO Then
Else
&CFO_BRL_CD = &CFOP_INTNT_BBL;
&CFO_EXT_CD_BBL = &CFOP_EXT_INTNT_BBL;
End-If;
Else
End-If;
End-If
Else
End-If;
End-Function;
/*** BRLOC_BI - SBRITO - AGO/2001 - Pega dados do grupo de OF ***/
Function GetLT_Data(&SETID, <GRP);
/*A.PND_ITEM_TYPE_BBL*/
&QRY = "SELECT A.NF_BRL_TYPE,A.TXN_NAT_BBL,A.IN_OUT_CD_BBL FROM PS_LT_GRP_BBL
A WHERE ";
&QRY = &QRY | " A.SETID = :1 AND A.LT_GRP_ID_BBL = :2 AND A.EFFDT = ( ";
&QRY = &QRY | " SELECT MAX(B.EFFDT) FROM PS_LT_GRP_BBL B WHERE ";
&QRY = &QRY | " B.SETID = A.SETID AND B.LT_GRP_ID_BBL = A.LT_GRP_ID_BBL ";
&QRY = &QRY | " AND B.EFFDT <= %currentdatein) AND A.EFF_STATUS = 'A' ";
SQLExec(&QRY, &SETID, <GRP, &NF_BRL_TYPE, &TXN_NAT_BBL, &IN_OUT_CD_BBL);
End-Function;
/*** BRLOC_BI - SBRITO - AGO/2001 - Pega dados da NF Pai***/
Function GetNF_HDR_Data(&NF_BRL_ID, &BUSINESS_UNIT);
&QRY = "SELECT SHIP_TO_CUST_ID,ADDRESS_SEQ_SHIP,EF_LOC_BRL,";
&QRY = &QRY | "TXN_NAT_BBL,FLOW_BUS_UNIT_IN,STORAGE_AREA,";
&QRY = &QRY | "STOR_LEVEL_1,STOR_LEVEL_2,STOR_LEVEL_3,STOR_LEVEL_4,";
&QRY = &QRY | "FLOW_SHIP_ID_BBL,FLOW_LOCATION_BBL,";
&QRY = &QRY | "NF_BRL_SERIES,LOCATION,DESTIN_BU,BILL_TO_CUST_ID,";
&QRY = &QRY | "ADDRESS_SEQ_NUM,NF_BRL_TYPE,SHIP_FROM_STATE,SHIP_BRL_TO_STATE,
";
&QRY = &QRY | "PYMNT_TERMS_CD,DST_ID_AR,BUSINESS_UNIT_GL,";
&QRY = &QRY | "TXN_CURRENCY_CD, RT_TYPE,RATE_MULT, RATE_DIV,BASE_CURRENCY,";
&QRY = &QRY | "PRORATE_METH_BBL,BUSINESS_UNIT_IN,COUNTRY,STATE ";
&QRY = &QRY | " FROM PS_NF_HDR_BBL_FS WHERE ";
&QRY = &QRY | " NF_BRL_ID=:1 AND BUSINESS_UNIT=:2 ";
SQLExec(&QRY, &NF_BRL_ID, &BUSINESS_UNIT, &SHIP_TO_CUST_ID, &ADDRESS_SEQ_SHIP
, &EF_LOC_BRL, &TXN_NAT_BBL, &FLOW_BUS_UNIT_IN, &STORAGE_AREA, &STOR_LEVEL_1, &S
TOR_LEVEL_2, &STOR_LEVEL_3, &STOR_LEVEL_4, &FLOW_SHIP_ID_BBL, &FLOW_LOCATION_BBL
, &NF_BRL_SERIES, &LOCATION, &DESTIN_BU, &BILL_TO_CUST_ID, &ADDRESS_SEQ_NUM, &NF
_BRL_TYPE, &SHIP_FROM_STATE, &SHIP_BRL_TO_STATE, &PYMENT_TERMS_CD, &DST_ID_AR, &
BUSINESS_UNIT_GL, &CURRENCY_CD, &RT_TYPE, &RATE_MULT, &RATE_DIV, &CURRENCY_CD_BA
SE, &PRORATE_METH_BBL, &BUSINESS_UNIT_IN, &COUNTRY, &STATE);
/*If &RT_TYPE = "" Then
&RT_TYPE = " ";
End-If;*/
End-Function;
/*** BRLOC_BI - SBRITO - AGO/2001 - Get inventory flow fields into parents ***/
Function GetFlow_INV(&BU, &NF, &NF_AVO);
If All(&NF_AVO) Then
&QRY = "SELECT FLOW_BUS_UNIT_IN,STORAGE_AREA,STOR_LEVEL_1,STOR_LEVEL_2,";
&QRY = &QRY | "STOR_LEVEL_3,STOR_LEVEL_4 FROM PS_NF_LINK_BBL A,PS_NF_HDR_B
BL_FS B ";
&QRY = &QRY | "WHERE A.NF_PAI_ID_BBL=:1 AND A.BUS_UNIT_REF_BBL=:2 ";
&QRY = &QRY | "AND A.NF_BRL_ID=B.NF_BRL_ID AND A.BUSINESS_UNIT=B.BUSINESS_
UNIT ";
/* &QRY = &QRY | "UNION ";
&QRY = "SELECT NF_BRL,NF_BRL_SERIES FROM PS_NF_HDR_BBL_FS ";
End-Function;
/*** BRLOC_BI - SBRITO - AGO/2001 - Insert NF Header ***/
Function Insert_HDR(&NF_BRL_ID, &BU);
/*** BRLOC-PO-AO-29/04/2002 - ICE Resolution 100957
- Adicionado campo MERCH_ORIG_AMT_PBL com valor 0 no insert da tabela NF_HDR_BB
L_FS.
***************************************************************************/
/* BRLOC - PO - GTM - 12/12/03 - ICE Resoltuion ID: 147996
Descrio: Fix MP 135, adio de campos de reteno de COFINS, CSLL e PIS */
/* BRLOC - PO - FCF - 14/04/04 - ICE Resoltuion ID:157904
Descrio: Fix MP 164, adio de campos de reteno de PISTAX_BRL_AMT E COFINSTAX_BRL_
AMT */
/***
BRLOC-BI - FCF - 04/05/04 - Resolution ID : 159199 - IMPOSTOS DE RETENCAO IS
S
substituio do campo merc_orig_amt_pbl por iss_brl_retention na tabela ps_nf_ln_bbl
_fs
***/
&QRY1 = " INSERT INTO PS_NF_HDR_BBL_FS (";
&QRY1 = &QRY1 | "BUSINESS_UNIT,NF_BRL_ID, NF_BRL,NF_BRL_SERIES,SHIP_TO_CUST_I
D,";
&QRY1 = &QRY1 | "ADDRESS_SEQ_SHIP,LOCATION,DESTIN_BU,BILL_TO_CUST_ID,ADDRESS_
SEQ_NUM,";
&QRY1 = &QRY1 | "VENDOR_ID,NF_BRL_TYPE,NF_BRL_DATE,NF_BRL_STATUS,NF_STATUS_BB
L,";
&QRY1 = &QRY1 | "NF_BRL_TTL_LINES,NF_BRL_FATURA,MAX_LINE,CFO_BRL_CD,PURCH_PRO
P_BRL,";
&QRY1 = &QRY1 | "SHIP_FROM_STATE,SHIP_BRL_TO_STATE,DELIVERED_DT,ORIGIN_METHOD
,";
&QRY1 = &QRY1 | "VENDOR_SETID,VNDR_LOC,ACCOUNTING_DT,PROCESS_INSTANCE,";
&QRY2 = "BUSINESS_UNIT_GL,DST_CNTRL_ID,GROSS_AMT,GROSS_AMT_BSE,";
&QRY2 = &QRY2 | "TXN_CURRENCY_CD,RT_TYPE,RATE_DIV,RATE_MULT,CUR_RT_SOURCE,";
&QRY2 = &QRY2 | "BASE_CURRENCY,DSCNT_AMT,DSCNT_AMT_BSE,FREIGHT_AMT,";
&QRY2 = &QRY2 | "FREIGHT_AMT_BSE,INSURANCE_BRL_AMT,INSURANCE_BRL_BSE,";
&QRY2 = &QRY2 | "OTHEREXP_BRL_AMT,OTHEREXP_BRL_BSE,PYMNT_TERMS_CD,ENTERED_DT,
";
&QRY2 = &QRY2 | "LAST_UPDATE_DT,MERCHANDISE_AMT,MERCH_AMT_BSE,ISSTAX_BRL_AMT,
";
&QRY2 = &QRY2 | "ISSTAX_BRL_BSE,ISSTAX_BRL_CD,ISSTAX_BRL_BSS,ISS_BRL_RETENTIO
N,";
&QRY3 = "INSS_BRL_RET_BSE,IRTAX_BRL_AMT,IRTAX_BRL_BSE,IRTAX_BRL_BSS,";
&QRY3 = &QRY3 | "IRTAX_BRL_CD,IPITAX_BRL_AMT,IPITAX_BRL_BSE,IPITAX_BRL_RCVRY,
";
&QRY3 = &QRY3 | "ICMSTAX_BRL_AMT,ICMSTAX_BRL_BSE,ICMSTAX_BRL_BSS,";
&QRY3 = &QRY3 | "ICMSTAX_BRL_RCVRY,ICMSTAX_BRL_RETENT,ICMSTAX_BRL_DUE,";
&QRY3 = &QRY3 | "ICMSSUB_BRL_AMT,ICMSSUB_BRL_BSE,ICMSSUB_BRL_BSS,";
&QRY3 = &QRY3 | "TAX_BRL_CALC_FLG,TRANSPORT_CD,TRANSPORT_MODE,NAME1,";
&QRY3 = &QRY3 | "ADDRESS1,ADDRESS2,CITY_CD_BBL,CITY,STATE,ZIP,COUNTRY,NET_WEI
GHT_BRL,";
&QRY4 = "GROSS_WEIGHT_BRL,UOM_WEIGHT,QTY_VOL_BRL,NUM_VOL_BRL,";
&QRY4 = &QRY4 | "TRADE_VOL_BRL,TYPE_VOL_BRL,CGC_BRL, IE_BRL,VOUCHER_ID,";
&QRY4 = &QRY4 | "RECEIVER_ID,BUSINESS_UNIT_RECV,OPRID_LAST_UPDT,MTCH_STATUS_P
BL,";
&QRY4 = &QRY4 | "INOUT_FLG_PBL,PRORATE_METH_BBL,FRGHT_PRORATE_PBL,OTHER_PRORA
TE_PBL,";
&QRY4 = &QRY4 | "ICMS_COMPL_AMT_PBL,DESCR100,IN_PROCESS_FLG,";
&QRY4 = &QRY4 | "GROSS_AMT_PBL_DIV,ICMSTAX_PBL_DIV,IPITAX_PBL_DIV,";
=
=
=
=
" INSERT
&QRY | "
&QRY | "
&QRY | "
Return &RET;
End-Function;
/*** BRLOC_BI - SBRITO - AGO/2001 ***/
Function GetBRL_FROM_STATE(&BU, &SETID);
&QRY = "SELECT A.COUNTRY,A.STATE FROM PS_LOCATION_TBL A,PS_BUS_UNIT_TBL_BI
";
&QRY = &QRY | " WHERE B.BUSINESS_UNIT = :1 AND A.SETID = :2 AND A.LOCATION
B.LOCATION ";
&QRY = &QRY | " AND A.EFFDT = (SELECT MAX(X.EFFDT) FROM PS_LOCATION_TBL X
ERE ";
&QRY = &QRY | " X.SETID = A.SETID AND X.LOCATION = A.LOCATION AND X.EFFDT
%CURRENTDATEIN) ";
&QRY = &QRY | " AND A.EFF_STATUS = 'A' ";
SQLExec(&QRY, &BU, &SETID, &COUNTRY_FROM, &STATE);
End-Function;
B
=
WH
<=
|
|
|
|
|
|
"
"
"
"
"
"
ADDR_NVL();
SQLExec(&QRY, &BU, &NF_BRL_ID, &TYPE, &CNJ, &CPF, &IE, &IM, &SETID_CUST, &CUS
T_ID, &SEQ);
End-Function;
/*** BRLOC_BI - SBRITO - AGO/2001 - Insert ADDR para mesmo cliente ***/
&QRY
&QRY
&QRY
&QRY
&QRY
&QRY
&QRY
&QRY
=
=
=
=
=
=
=
=
&QRY
&QRY
&QRY
&QRY
&QRY
&QRY
&QRY
&QRY
|
|
|
|
|
|
|
|
"
"
"
"
"
"
"
"
If &NF_ADDR_TYPE_BBL = "" Or
None(&NF_ADDR_TYPE_BBL) Then
Else
SQLExec(&QRY, &BU, &NF_BRL_ID, &TYPE, &CGC_BRL, &CPF_BRL, &IE_BRL, &IM_BRL
, &ESTABID, &NAME1, &COUNTRY2, &ADDRESS1, &ADDRESS2, &ADDRESS3, &ADDRESS4, &CITY
2, &STATE2, &POSTAL, &CITY_CD_BBL);
End-If;
End-Function;
/*** CONTROLE DE DATAS ***/
/*** BRLOC_BI - SBRITO - AGO/2001 - Mark Date Field ***/
Function Mark_Date(&NF_BRL_ID, &BU, &TERM);
&TERM2 = %Date + &TERM;
&QRY = "UPDATE PS_NF_HDR_BBL_FS ";
&QRY = &QRY | " SET DT_FLOW_BBL=:1 ";
&QRY = &QRY | " WHERE NF_BRL_ID = :2 AND BUSINESS_UNIT = :3 ";
SQLExec(&QRY, &TERM2, &NF_BRL_ID, &BU);
End-Function;
/*** RESOLUO DE LINHAS ***/
/*** BRLOC_BI - SBRITO - JUL/2001 - Pega NF Derived - value formulate ***/
Function GetValue_formulate(&DRV_VAL) Returns boolean ;
Declare_Scroll_FRM();
&QRY = "SELECT DOC_CLASS_BBL FROM PS_NF_VALDET_BBL ";
&QRY = &QRY | "WHERE NF_VAL_CREATE_BBL=:1 ";
&SQL2 = CreateSQL(&QRY, &DRV_VAL);
&RET = False;
While &SQL2.Fetch(&DOC_CLASS_BBL3)
&v_doc.Push(&DOC_CLASS_BBL3);
&RET = True;
End-While;
&SQL2.Close();
Return &RET;
End-Function;
Function Solve_ValueFormulate(&NF_BRL_ID, &BUSINESS_UNIT, &NF_PAI, &BUS_UNIT_REF
, &SHIP_TO);
&l_seq = CreateArrayRept(0, 0);
&l_value = CreateArrayRept(0, 0);
&l_qty = CreateArrayRept(0, 0);
&l_item = CreateArrayRept("", 0);
&l_uvalue = CreateArrayRept(0, 0);
&l_nvalue = CreateArrayRept(0, 0);
&l_ouvalue = CreateArrayRept(0, 0);
&l_onvalue = CreateArrayRept(0, 0);
&IN = "";
For &k = 1 To &v_doc.Len
&doc = &v_doc[&k];
If &k = 1 Then
End-While;
&QRY = "SELECT B.NF_BRL_LINE_NUM,SUM(B.GROSS_AMT_BSE),B.INV_ITEM_ID,AVG(B.
QTY_NF_BRL),";
&QRY = &QRY | "SUM(B.UNIT_AMT_BSE_BBL),SUM(B.NET_AMT_BSE_BBL),SUM(B.UNIT_P
RICE),SUM(B.NET_UNIT_PRICE) ";
&QRY = &QRY | " FROM PS_NF_LINK_BBL A,PS_NF_LN_BBL_FS B,PS_NF_HDR_BBL_FS C
";
&QRY = &QRY | "WHERE A.NF_PAI_ID_BBL=:1 AND A.BUS_UNIT_REF_BBL=:2 ";
&QRY = &QRY | "AND A.NF_BRL_ID=C.NF_BRL_ID AND A.BUSINESS_UNIT=C.BUSINESS_
UNIT ";
&QRY = &QRY | "AND A.NF_BRL_ID=B.NF_BRL_ID AND A.BUSINESS_UNIT=B.BUSINESS_
UNIT ";
If &IN > "" Then
&QRY = &QRY | "AND C.DOC_CLASS_BBL " | &IN
End-If;
&QRY = &QRY | " AND C.SHIP_TO_CUST_ID = :3 AND B.NF_BRL_ID <> :4 ";
&QRY = &QRY | " GROUP BY B.NF_BRL_LINE_NUM,B.INV_ITEM_ID ";
&SQL2 = CreateSQL(&QRY, &NF_PAI, &BUS_UNIT_REF, &SHIP_TO, &NF_PAI);
While &SQL2.Fetch(&NUM, &VALOR, &INV_ITEM_ID, &QTY_NF_BRL, &UVALOR, &NVALO
R, &OUVALOR, &ONVALOR)
&PTR = &l_seq.Find(&NUM);
If &PTR > 0 Then
If &l_item[&PTR] = &INV_ITEM_ID Then
&l_value[&PTR] = &l_value[&PTR] + &VALOR;
&l_uvalue[&PTR] = &l_uvalue[&PTR] + &UVALOR;
&l_nvalue[&PTR] = &l_nvalue[&PTR] + &NVALOR;
&l_ouvalue[&PTR] = &l_ouvalue[&PTR] + &OUVALOR;
&l_onvalue[&PTR] = &l_onvalue[&PTR] + &ONVALOR;
Else
&PTR = &l_item.Find(&INV_ITEM_ID);
If &PTR > 0 Then
&l_value[&PTR] = &l_value[&PTR] + &VALOR;
&l_uvalue[&PTR] = &l_uvalue[&PTR] + &UVALOR;
&l_nvalue[&PTR] = &l_nvalue[&PTR] + &NVALOR;
&l_ouvalue[&PTR] = &l_ouvalue[&PTR] + &OUVALOR;
&l_onvalue[&PTR] = &l_onvalue[&PTR] + &ONVALOR;
Else
End-If;
End-If;
End-If;
End-While;
&SQL2.Close();
End-If;
End-Function;
/*** BRLOC_BI - SBRITO - AGO/2001 - Pega Valor da Linha***/
Function GetVal(&NUM) Returns number ;
&RET = 0;
For &k = 1 To &l_seq.Len
If &l_seq[&k] = &NUM Then
&RET = &k;
Break;
End-If;
End-For;
Return &RET;
End-Function;
/*** BRLOC_BI - SBRITO - AGO/2001 - Pega dados da Linha para NF Pai***/
<_IPI_BSE_BBL = 0;
<_ICMS_BSE_BBL = 0;
<_ICMS_ST_BSE_BBL = 0;
<_PIS_BSE_BBL = 0;
<_COFINS_BSE_BBL = 0;
<_ISS_BSE_BBL = 0;
<_PISS_BSE_BBL = 0;
<_PISS_BSE_BBL = 0;
<_PISS_BSE_BBL = 0;
<_PISS_BSE_BBL = 0;
Else
If &EXT = False Then
Error "Erro(InsertLine): Index(" | &index | ")";
Else
&OK = False;
End-If;
End-If;
Else
End-If;
/*** BRLOC-PO-AO-29/04/2002 - ICE Resolution 100957
- Adicionado os campos COEF_BASE_FLG_PBL, COEF_BASE_ICMS_PBL, COEF_BASE_IPI_PBL
e MERCH_ORIG_AMT_PBL com valores de inicializao no insert da tabela NF_LN_BBL_FS.
***************************************************************************/
/*** BRLOC-PO-SAM-24/06/2003 - ICE Resolution 131084
- Adicionado campo IPITAX_BRL_RED com valor de inicializao no insert da tabela NF
_LN_BBL_FS.
***************************************************************************/
/* BRLOC-BI - FCF - 12/03/04 - Resolution ID : 155163 - IMPOSTOS DE RETENCAO
(PIS/COFINS/CSLL) no lugar dos campos do PO ( na nf_ln_brl ) continuam os campos
antigos do PO */
/* BRLOC - PO - FCF - 14/04/04 - ICE Resoltuion ID:157904
Descrio: Fix MP 164, adio de campos de reteno de PISTAX_BRL_AMT,COFINSTAX_BRL_AMT,COEF
_BASE_PIS_PBL,COEF_BASE_COFI_PBL,CF_IPI_ID_PBL,CF_ICMS_ID_PBL,CF_PIS_ID_PBL,CF_C
OFINS_ID_PBL,PIS_TAX_STATUS_PBL,COFI_TX_STATUS_PBL,PIS_CRLIM_PCT_PBL,COFI_CRLIM_
PCT_PBL*/
&QRY1 = " INSERT INTO PS_NF_LN_BBL_FS (";
&QRY1 = &QRY1 | "BUSINESS_UNIT,NF_BRL_ID,NF_BRL_LINE_NUM,TOTAL_DISTRIBS,MAX_D
ISTRIB_LINE,";
&QRY1 = &QRY1 | "BUSINESS_UNIT_PO,PO_ID,ITM_SETID,INV_ITEM_ID,DESCR,MERCHANDI
SE_AMT,";
&QRY1 = &QRY1 | "MERCH_AMT_BSE,QTY_NF_BRL,STATISTIC_AMOUNT,UNIT_OF_MEASURE,";
&QRY1 = &QRY1 | "UNIT_PRICE,NET_UNIT_PRICE,FREIGHT_AMT_BSE,FREIGHT_AMT,INSURA
NCE_BRL_AMT,";
&QRY1 = &QRY1 | "INSURANCE_BRL_BSE,OTHEREXP_BRL_AMT,OTHEREXP_BRL_BSE,DSCNT_AM
T,";
&QRY1 = &QRY1 | "DSCNT_AMT_BSE,DSCNT_PCT,ERROR_FLAG,BUSINESS_UNIT_RECV,";
&QRY2 = "RECEIVER_ID,RECV_LN_NBR,RECV_SHIP_SEQ_NBR,SHIPTO_ID,TXN_CURRENCY_CD,
";
&QRY2 = &QRY2 | "BASE_CURRENCY,CURRENCY_CD,CFO_BRL_CD,PURCH_PROP_BRL,TAX_CLAS
S_BRL,";
&QRY2 = &QRY2 | "IPITAX_BRL_BSE,IPITAX_BRL_AMT,IPITAX_BRL_PCT,IPITAX_BRL_RCVR
Y,";
&QRY2 = &QRY2 | "IPITAX_BRL_BSS,TAX_TYPE_BRL,ICMSTAX_BRL_BSE,ICMSTAX_BRL_AMT,
";
&QRY2 = &QRY2 | "ICMSTAX_BRL_PCT,ICMSTAX_BRL_RED,ICMSTAX_BRL_RCVRY,ICMSTAX_BR
L_BSS,";
&QRY2 = &QRY2 | "ICMSSUB_BRL_AMT,ICMSSUB_BRL_BSE,ICMSTAX_BRL_DUE,CSLL_BRL_RET
ENT,";
&QRY2 = &QRY2 | "CFOP_INCOM_PBL,IPI_CRLIM_PCT_PBL,IPI_EXTCR_PCT_PBL,ICMS_CRLI
M_PCT_PBL,";
&QRY2 = &QRY2 | "ICMS_EXTCR_PCT_PBL,ICMS_COMPL_PCT_PBL,PIS_BRL_RETENT,";
&QRY3 = "COFINS_BRL_RETENT,IPITAX_PBL_DIV,TOF_PBL,NF_LINE_TYPE_BBL,";
&QRY3 = &QRY3 | "RMNEIO_LINE_NO_BBL,DEMAND_SOURCE,SOURCE_BUS_UNIT,PRODUCT_ID,
";
&QRY3 = &QRY3 | "KIT_LINE_NBR,ITEM_ORIGIN_BBL,SIT_TRIB_ICMS_BBL,CFOP_EXT_CD_B
BL,";
&QRY3 = &QRY3 | "INT_TAX_CLASS_BRL,UNIT_AMT_BSE_BBL,NET_AMT_BSE_BBL,UNIT_COST
,";
&QRY3 = &QRY3 | "COFINS_BSS_AMT_BBL,COFINS_PCT_BBL,COFINS_AMT_BBL,COFINS_AMT_
BSE_BBL,";
&QRY3 = &QRY3 | "PIS_BSS_AMT_BBL,PIS_PCT_BBL,PIS_AMT_BBL,PIS_AMT_BSE_BBL,";
&QRY3 = &QRY3 | "ISSTAX_BRL_BSS,ISSTAX_BRL_PCT,ISSTAX_BRL_AMT,ISSTAX_BRL_BSE,
";
&QRY3 = &QRY3 | "MVA_PCT_BBL,LT_IPI_BSE_BBL,LT_ICMS_BSE_BBL,LT_ICMS_ST_BSE_BB
L,";
&QRY4 = "LT_PIS_BSE_BBL,LT_COFINS_BSE_BBL,LT_ISS_BSE_BBL,FIN_CHG_PCT_BBL,";
&QRY4 = &QRY4 | "FINCHG_AMT_BBL,FINCHG_AMT_BSE_BBL,NF_ACT_TMPL_BBL,ICMSTAX_ST
S_BBL,";
&QRY4 = &QRY4 | "ICMSSUB_STS_BBL,IPITAX_STS_BBL,ISSTAX_STS_BBL,IRTAX_STS_BBL,
INSSTAX_STS_BBL,";
&QRY4 = &QRY4 | "IPI_IN_ICMSBAS_BBL,ICMS_RED_BSE_BBL,ICMSST_RED_BSE_BBL,IPI_R
ED_BSE_BBL,";
&QRY4 = &QRY4 | "ISS_RED_BSE_BBL,IR_RED_BSE_BBL,INSS_RED_BSE_BBL,ICMSSUB_BRL_
BSS,";
&QRY4 = &QRY4 | "ICMSST_PCT_BBL,GROSS_AMT_BSE,DST_ID_DIS,DST_ID_REV,DST_ID_SU
R,";
&QRY4 = &QRY4 | "INVENTORY_ITEM,COST_ADJ_STS_PBL,FRT_INCR_BSE_BBL,INSR_INCR_B
SE_BBL,";
&QRY4 = &QRY4 | "OTEX_INCR_BSE_BBL,WTHD_CD,PROCESS_INSTANCE,DESCR254_MIXED,";
&QRY4 = &QRY4 | "PYMNT_TERMS_CD,PAY_TRM_BSE_DT_OPT,ICMS_COMPL_FLG_PBL,";
&QRY5 = "COFINST_BSSAMT_BBL,COFINSST_PCT_BBL,COFINSST_AMT_BBL,COFINST_BSEAMT_
BBL,";
&QRY5 = &QRY5 | "LT_COFINSSTBSE_BBL,PISST_BSS_AMT_BBL,PISST_PCT_BBL,PISST_AMT
_BBL,";
&QRY5 = &QRY5 | "PISST_BSE_AMT_BBL,LT_PISS_BSE_BBL,IR_BSS_AMT_BBL,IR_PCT_BBL,
IR_BSE_AMT_BBL,";
&QRY5 = &QRY5 | "IR_AMT_BBL,LT_IRBSE_BBL,INSS_BSS_AMT_BBL,INSS_PCT_BBL,INSS_B
SE_AMT_BBL,";
&QRY5 = &QRY5 | "INSS_AMT_BBL,LT_INSSBSE_BBL,IF_BRL,PAYTRMS_DT_BSE_PBL,FLOW_S
TATUS_PBL,";
&QRY5 = &QRY5 | "RTV_ID,RTV_LN_NBR,FLOW_ID_BBL,FLOW_BUS_UNIT_IN,STORAGE_AREA,
STOR_LEVEL_1,";
&QRY5 = &QRY5 | "STOR_LEVEL_2,STOR_LEVEL_3,STOR_LEVEL_4,FLOW_SHIP_ID_BBL,FLOW
_LOCATION_BBL,";
&QRY5 = &QRY5 | "ICMS_DISCOUNT_BBL,DT_FLOW_BBL,COEF_BASE_FLG_PBL,COEF_BASE_IC
MS_PBL,COEF_BASE_IPI_PBL,ISS_BRL_RETENTION,DISTRIB_MTHD_FLG,IPITAX_BRL_RED";
&QRY6 = ",PISTAX_BRL_AMT,COFINSTAX_BRL_AMT,COEF_BASE_PIS_PBL,COEF_BASE_COFI_P
BL,CF_IPI_ID_PBL,CF_ICMS_ID_PBL,CF_PIS_ID_PBL,CF_COFINS_ID_PBL,PIS_TAX_STATUS_PB
L,COFI_TX_STATUS_PBL,PIS_CRLIM_PCT_PBL,COFI_CRLIM_PCT_PBL) VALUES (";
&QRY6 = &QRY6 | ":1,:2,:3,0,0,' ',' ',:4,:5,:6,:7,:8,:9,0,";
&QRY6 = &QRY6 | ":10,:11,:12,0,0,0,0,0,0,0,:51,:52,' ',' ',' ', 0,0,' ',";
&QRY6 = &QRY6 | ":13,:14,:15,:16,:17,:18,0,0,0, 0,0,' ',0,";
&QRY6 = &QRY6 | " 0,0,0,0,0,0,0,0,0,' ', 0,0,0,0,0,0,0,0,:19,";
&QRY6 = &QRY6 | ":20,0,' ',:21,:22,:23,:24,' ',:25,' ',:26,:27,";
&QRY6 = &QRY6 | ":28,0,0,0,0,0,0,0,0,0,0,0,0,0,:29,:30,:31,:32,";
&QRY7 = ":33,:34,0,0,0,:35,' ',' ',' ',' ',' ',' ',' ',0,0,0,0,";
&QRY7 = &QRY7 | "0,0,0,0,0,:36,:37,:38,' ',' ',0,0,0,' ',0,' ',' ',' ',' ',0,
0,0,0,:39,0,";
&QRY7 = &QRY7 | "0,0,0,:40,0,0,0,0,:41,0,0,0,0,:42,:43,%DateIn('1900-01-01'),
";
&QRY7 = &QRY7 | "' ',' ',0,:44,:45,:46,:47,:48,:49,:50,' ',' ',0,%DateIn('190
0-01-01'),' ',0,0,0,' ',0,0,0,0,0,' ',' ',' ',' ',' ',' ',0,0) ";
If &OK = True Then
SQLExec(&QRY1 | &QRY2 | &QRY3 | &QRY4 | &QRY5 | &QRY6 | &QRY7, &BU, &NF_BR
L_ID, &NF_BRL_LINE_NUM, &INVITEM_SETID, &INV_ITEM_ID, &DESCR, &MERCHANDISE_AMT,
&MERCH_AMT_BSE, &QTY_NF_BRL, &UNIT_OF_MEASURE, &UNIT_PRICE, &NET_UNIT_PRICE, &CU
RRENCY_CD2, &CURRENCY_CD_BASE2, &CURRENCY_CD2, &CFO_BRL_CD, &PURCH_PROP_BRL, &TA
X_CLASS_BRL, &TOF_PBL, &NF_LINE_TYPE_BBL, &SOURCE_BUS_UNIT, &PRODUCT_ID, &KIT_LI
NE_NBR, &ITEM_ORIGIN_BBL, &CFOP_EXT_CD_BBL, &UNIT_AMT_BSE_BBL, &NET_AMT_BSE_BBL,
&UNIT_COST, <_IPI_BSE_BBL, <_ICMS_BSE_BBL, <_ICMS_ST_BSE_BBL, <_PIS_BSE
_BBL, <_COFINS_BSE_BBL, <_ISS_BSE_BBL, &NF_ACT_TMPL_BBL, &DST_ID_DIS, &DST_I
D_REV, &DST_ID_SUR, <_PISS_BSE_BBL, <_PISS_BSE_BBL, <_PISS_BSE_BBL, <_PI
SS_BSE_BBL, &IF_BRL, &FLOW_ID_BBL2, &FLOW_BUS_UNIT_IN, &STORAGE_AREA, &STOR_LEVE
L_1, &STOR_LEVEL_2, &STOR_LEVEL_3, &STOR_LEVEL_4, &DSCNT_AMT_BSE, &DSCNT_PCT);
End-If;
End-Function;
/*** BRLOC_BI - SBRITO - AGO/2001 - Percorre Linhas da NF Pai***/
Function NF_Line_Scroll(&NF, &BU, &VAL_PAI, &NF_BRL_NEW, &NF_AVO, &EXT, &VAL_EXT
);
If &EXT = False Then
If &VAL_PAI = True Then
For &x = 1 To &l_seq.Len
&LINE_NUM = &l_seq[&x];
GetNF_Line_Data(&NF_AVO, &BU, &LINE_NUM);
Insert_Line(&NF_BRL_NEW, &BU, &LINE_NUM, &VAL_PAI, &EXT);
End-For;
Else
&QRY = "SELECT NF_BRL_LINE_NUM ";
&QRY = &QRY | " FROM PS_NF_LN_BBL_FS WHERE ";
&QRY = &QRY | " NF_BRL_ID=:1 AND BUSINESS_UNIT=:2 ";
&SQL2 = CreateSQL(&QRY, &NF, &BU);
While &SQL2.Fetch(&LINE_NUM)
GetNF_Line_Data(&NF, &BU, &LINE_NUM);
Insert_Line(&NF_BRL_NEW, &BU, &LINE_NUM, &VAL_PAI, &EXT);
End-While;
&SQL2.Close();
End-If;
Else
If All(&VAL_EXT) Then
For &x = 1 To &l_seq.Len
&LINE_NUM = &l_seq[&x];
GetNF_Line_Data(&NF_AVO, &BU, &LINE_NUM);
Insert_Line(&NF_BRL_NEW, &BU, &LINE_NUM, &VAL_PAI, &EXT);
End-For;
Else
&l_seq = CreateArrayRept(0, 0);
&l_value = CreateArrayRept(0, 0);
&l_qty = CreateArrayRept(0, 0);
&l_item = CreateArrayRept("", 0);
&l_uvalue = CreateArrayRept(0, 0);
&l_nvalue = CreateArrayRept(0, 0);
&l_ouvalue = CreateArrayRept(0, 0);
&l_onvalue = CreateArrayRept(0, 0);
/*BRLOC-BI-FCF-27/05/02 - ALTER THE FUNCTION TO TAKE THE VALUE OF THE D
ESCOUNT */
&l_ondescpct = CreateArrayRept(0, 0);
[FUNCLIB_OF.FLOW_ID_DRV_BBL.FieldFormula]
Declare Function nf_derived_generate PeopleCode FLOW_ID_BBL FieldFormula;
Function GenerateNF() Returns boolean ;
&RET = True;
&NF = NF_HDR_BBL_FS.NF_BRL_ID;
&BU = NF_HDR_BBL_FS.BUSINESS_UNIT;
&NF_NEW = FetchValue(NF_FLOW_BBL_WRK.NF_BRL_ID, 1);
&FLOW_ID_DRV_BBL = FetchValue(NF_FLOW_BBL_WRK.FLOW_ID_DRV_BBL, 1);
&NF_VAL_CREATE_BBL = FetchValue(NF_FLOW_BBL_WRK.NF_VAL_CREATE_BBL, 1);
&TOF_PBL = FetchValue(NF_FLOW_BBL_WRK.TOF_PBL, 1);
<_GRP_ID_BBL = FetchValue(NF_FLOW_BBL_WRK.LT_GRP_ID_BBL, 1);
&SHIPTO_FLG_BBL = FetchValue(NF_FLOW_BBL_WRK.SHIPTO_FLG_BBL, 1);
If &NF_NEW = "" Then
[MMC_IN_LIB.FUNCLIB.FieldFormula]
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange;
Function busca_origem_item(&setid As string, &inv_item_id As string) Returns str
ing
&SQL = CreateSQL("SELECT ITEM_ORIGIN_BBL FROM SYSADM.PS_INV_ITEMS WHERE SETID
= :1 AND INV_ITEM_ID = :2", &setid, &inv_item_id);
If &SQL.FETCH(&ITEM_ORIGIN_BBL) Then
Return &ITEM_ORIGIN_BBL;
End-If;
Return "";
End-Function;
Function match(&business_unit As string, &inv_item_id As string, &item_origin_bb
l As string, &distrib_type As string, &deptid As string, &project_id As string)
Returns boolean
&SQL = CreateSQL("SELECT STORAGE_AREA, STOR_LEVEL_1, STOR_LEVEL_2, STOR_LEVEL
_3, STOR_LEVEL_4 FROM SYSADM.PS_MMC_ARM_RULES WHERE BUSINESS_UNIT = :1 AND INV_I
TEM_ID = :2 AND ITEM_ORIGIN_BBL = :3 AND DISTRIB_TYPE = :4 AND DEPTID = :5 AND P
ROJECT_ID = :6", &business_unit, &inv_item_id, &item_origin_bbl, &distrib_type,
&deptid, &project_id);
If &SQL.FETCH(&STORAGE_AREA, &STOR_LEVEL_1, &STOR_LEVEL_2, &STOR_LEVEL_3, &ST
OR_LEVEL_4) Then
If All(&STORAGE_AREA) Then
PHYS_INV_VW1.STORAGE_AREA = &STORAGE_AREA;
End-If;
If All(&STOR_LEVEL_1) Then
PHYS_INV_VW1.STOR_LEVEL_1 = &STOR_LEVEL_1;
End-If;
If All(&STOR_LEVEL_2) Then
PHYS_INV_VW1.STOR_LEVEL_2 = &STOR_LEVEL_2;
End-If;
If All(&STOR_LEVEL_3) Then
PHYS_INV_VW1.STOR_LEVEL_3 = &STOR_LEVEL_3;
End-If;
If All(&STOR_LEVEL_4) Then
PHYS_INV_VW1.STOR_LEVEL_4 = &STOR_LEVEL_4;
End-If;
Return True;
End-If;
Return False;
End-Function;
Function match_rule(&business_unit As string, &inv_item_id As string, &distrib_t
ype As string, &deptid As string, &project_id As string) Returns boolean
&setid = BUSCA_SETID();
If None(&setid) Then
Error "No foi possvel obter o SETID da empresa.";
End-If;
&ITEM_ORIGIN_BBL = busca_origem_item(&setid, &inv_item_id);
If None(&ITEM_ORIGIN_BBL) Then
Error "No foi possvel encontrar a origem do item : " | &inv_item_id;
End-If;
&result = match(&business_unit, &inv_item_id, &ITEM_ORIGIN_BBL, &distrib_type
, &deptid, &project_id);
If &result = False Then
&result = match(&business_unit, " ", &ITEM_ORIGIN_BBL, &distrib_type, &dep
tid, &project_id);
End-If;
Return &result;
End-Function;
[MMC_IN_LIB.FUNCLIB.SavePostChange]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 24/10/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Biblioteca de Funes de Entrada e Reduo de Estoque.
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Fabiano Cunha - MMC - 06/03/2008 - mmcb.at0603 - armazenagem on-line dos iten
s fabricados. *
*******************************************************************************
*****************/
/*******************************************************************************
*****************
***************/
/* Leandro Rodrigues da Silva Souza - MMCB - SDS5026 - 17/11/2015
*
* O nem sempre todos os processos que movimentam item para areas WIP
*
* considera que o item deve possuir a quantidade reservada
*
********************************************************************************
****************/
/*******************************************************************************
****************
* Vincius Alves Mello - MMC - 26/01/2015 - mmcb.hd226465
*
* Bloquear a gravao de item na UN de estoque, caso o mesmo no possua cadastro.
*
*******************************************************************************
****************/
/*******************************************************************************
****************
* Vincius Alves Mello - MMC - mmcb.sds5105 - 26/01/2015
*
* Ajustes controle de terceiros em nosso poder.
*
*******************************************************************************
****************/
/*hd193198.sn*/
Function ATUALIZAR_RASTREABILIDADE(&PAR_BUSINESS_UNIT, &PAR_PRODUCTION_ID)
SQLExec("SELECT MMC_CP_GRUPO, MMC_ID_APONTAM, INV_ITEM_TEMPLATE, INV_LOT_ID F
ROM (SELECT MMC_CP_GRUPO,MMC_ID_APONTAM, INV_ITEM_TEMPLATE, INV_LOT_ID FROM SYSA
DM.PS_MMC_PRS_APONTAM WHERE BUSINESS_UNIT =:1 AND PRODUCTION_ID =:2 ORDER BY MMC
_SEQ_PROCES DESC) WHERE ROWNUM = 1", &PAR_BUSINESS_UNIT, &PAR_PRODUCTION_ID, &V_
MMC_CP_GRUPO, &V_MMC_ID_APONTAM, &V_INV_ITEM_TEMPLATE, &V_INV_LOT_ID);
&SQL = "SELECT BUSINESS_UNIT, MMC_CP_GRUPO, :1 MMC_ID_APONTAM, ' ' MMC_CABINE
, MMC_SEQ_PROCES,MMC_LOC_APONTAM, :2 INV_ITEM_TEMPLATE, :3 INV_LOT_ID, :4 PRODUC
TION_ID, :5 MMC_SUFIXO_CHASSI FROM SYSADM.PS_MMC_LOC_APONTAM A WHERE A.BUSINESS_
UNIT=:6 AND A.MMC_CP_GRUPO = :7 AND A.MMC_SEQ_PROCES < '70' and A.MMC_SEQ_PROCES
NOT IN ('62','65') AND NOT EXISTS(SELECT 'Y' FROM SYSADM.PS_MMC_PRS_APONTAM B W
HERE B.BUSINESS_UNIT = A.BUSINESS_UNIT AND B.MMC_CP_GRUPO = A.MMC_CP_GRUPO AND B
.MMC_SEQ_PROCES = A.MMC_SEQ_PROCES AND B.PRODUCTION_ID =:8 AND B.MMC_LOC_APONTAM
= A.MMC_LOC_APONTAM)";
&cmdSQL = CreateSQL(&SQL, &V_MMC_ID_APONTAM, &V_INV_ITEM_TEMPLATE, &V_INV_LOT
_ID, &PAR_PRODUCTION_ID, &V_MMC_ID_APONTAM, &PAR_BUSINESS_UNIT, &V_MMC_CP_GRUPO,
&PAR_PRODUCTION_ID);
While &cmdSQL.fetch(&V_BUSINESS_UNIT, &V_MMC_CP_GRUPO, &V_MMC_ID_APONTAM, &V_
MMC_CABINE, &V_MMC_SEQ_PROCES, &V_MMC_LOC_APONTAM, &V_INV_ITEM_TEMPLATE, &V_INV_
LOT_ID, &V_PRODUCTION_ID, &V_MMC_SUFIXO_CHASSI);
MC_SUFIXO_CHASSI | "',SYSDATE)";
SQLExec(&INSERT);
*/
&INSERT = "Insert into SYSADM.PS_MMC_PRS_APONTAM(BUSINESS_UNIT, MMC_CP_GRU
PO, MMC_ID_APONTAM, MMC_CABINE, MMC_SEQ_PROCES, MMC_LOC_APONTAM, INV_ITEM_TEMPLA
TE, INV_LOT_ID, PRODUCTION_ID, MMC_SUFIXO_CHASSI, DT_TIMESTAMP) Values (:1, :2,
:3, :4,:5, :6, :7, :8,:9,:10,SYSDATE)";
SQLExec(&INSERT, &PAR_BUSINESS_UNIT, &V_MMC_CP_GRUPO, &V_MMC_ID_APONTAM, "
", &V_MMC_SEQ_PROCES, &V_MMC_LOC_APONTAM, &V_INV_ITEM_TEMPLATE, &V_INV_LOT_ID,
&PAR_PRODUCTION_ID, &V_MMC_SUFIXO_CHASSI);
End-While;
End-Function;
/*******************************************************************************
****************/
/*hd193198.en*/
/* mmcb.SDS5026.sn */
Function quantidadeReservadaBU(&bu, &item) Returns number
&qty_allocated_dmnd_inv = 0;
SQLExec("select SUM(MDI.QTY_ALLOCATED) FROM SYSADM.PS_MMC_DMND_INV MDI WHERE
MDI.BUSINESS_UNIT =:1 AND MDI.INV_ITEM_ID =:2", &bu, &item, &qty_allocated_dmnd_
inv);
&qty_allocated = 0;
SQLExec("select sum(qty_allocated) from SYSADM.PS_demand_inv where business_u
nit=:1 and inv_item_id =:2 and cancel_flag <> 'Y'", &bu, &item, &qty_allocated);
&qty_allocated_ship = 0;
&qty_shipped = 0;
SQLExec("select sum(qty_allocated), sum(qty_shipped) from SYSADM.PS_ship_inf_
inv a where a.business_unit =:1 and a.inv_item_id =:2 and a.confirmed_flag = 'Y'
and a.pssh_complete
= 'N' and a.pssh_run_status <> 3 and a.cancel_flag <
> 'Y' ", &bu, &item, &qty_allocated_ship, &qty_shipped);
&qty_allocated_ship2 = 0;
&qty_shipped_2 = 0;
SQLExec("select sum(qty_allocated),sum(qty_shipped) from SYSADM.PS_ship_inf_i
nv a where a.business_unit=:1 and a.inv_item_id=:2 and a.confirmed_flag
= '
Y' and a.pssh_complete
= 'Y' and a.pssh_run_status = 1 and a.cancel_flag <
> 'Y' ", &bu, &item, &qty_allocated_ship2, &qty_shipped_2);
If &qty_shipped <= 0 Then
&qty_res_bu = &qty_allocated_ship + &qty_allocated;
Else
&qty_res_bu = &qty_shipped + &qty_allocated;
End-If;
If &qty_shipped_2 <= 0 Then
&REC_MMC_TE_CONTR_MT.UNIT_PRICE.VALUE = &MAT_UNIT_PRICE;
&REC_MMC_TE_CONTR_MT.MERCHANDISE_AMT.VALUE = &MAT_MERCHANDISE_AMT;
&REC_MMC_TE_CONTR_MT.SHIPTO_ID.VALUE = &MAT_SHIPTO_ID;
&REC_MMC_TE_CONTR_MT.Insert();
/****************************mmcb.hd89739.so*********************************
***/
/*SQLExec("UPDATE SYSADM.PS_MMC_TE_CONTR_MT SET DESCR = UPPER(translate
DESCR,',','ACEIOUAEIOUAEIOUAOEUaceiouaeiouaeiouaoeu'
T, &MAT_NF_BRL_ID);*/
/****************************mmcb.hd89739.eo*********************************
***/
/****************************mmcb.hd89739.so*********************************
***/
SQLExec("UPDATE SYSADM.PS_MMC_TE_CONTR_MT SET DESCR = UPPER(translate(
DESCR,',','ACEIOUAEIOUAEIOUAOEUaceiouaeiouaeiouaoeu')
, &MAT_NF_BRL_ID);
/****************************mmcb.hd89739.eo*********************************
***/
End-Function;
Function ATUALIZA_CONTROLE_MAT_TERC(&MAT_BUSINESS_UNIT, &MAT_NF_BRL_ID, &MAT_NF_
BRL_LINE_NUM, &MAT_NF_BRL, &MAT_NF_BRL_SERIES, &MAT_INV_ITEM_ID, &MAT_DESCR, &MA
T_VENDOR_ID, &MAT_NF_BRL_DATE, &MAT_TRANSACTION_GROUP, &MAT_TRANSACTION_DATE, &M
AT_TAX_CLASS_BRL, &MAT_TOF_PBL, &MAT_SOURCE_BUS_UNIT, &MAT_ORDER_NO, &MAT_ORDER_
INT_LINE_NO, &MAT_BUSINESS_UNIT_BI, &MAT_MMC_NF_BRL_ID_OUT, &MAT_MMC_LINE_NUM_OU
T, &MAT_CUST_ID, &MAT_ACCOUNT, &MAT_MMC_TIPO_AJUST, &MAT_OPRID, &MAT_UNIT_OF_MEA
SURE, &MAT_MMC_OBS_AJUST, &MAT_MMC_ISSUE_QTY, &MAT_QTY_NF_BRL, &MAT_UNIT_PRICE,
&MAT_MERCHANDISE_AMT, &MAT_SHIPTO_ID)
SQLExec("delete SYSADM.PS_MMC_TE_CONTR_MT where BUSINESS_UNIT = :1 and NF_BRL
_ID = :2 and TRANSACTION_GROUP = '020'", &MAT_BUSINESS_UNIT, &MAT_NF_BRL_ID);
GRAVA_CONTROLE_MAT_TERC(&MAT_BUSINESS_UNIT, &MAT_NF_BRL_ID, &MAT_NF_BRL_LINE_
NUM, &MAT_NF_BRL, &MAT_NF_BRL_SERIES, &MAT_INV_ITEM_ID, &MAT_DESCR, &MAT_VENDOR_
ID, &MAT_NF_BRL_DATE, &MAT_TRANSACTION_GROUP, &MAT_TRANSACTION_DATE, &MAT_TAX_CL
ASS_BRL, &MAT_TOF_PBL, &MAT_SOURCE_BUS_UNIT, &MAT_ORDER_NO, &MAT_ORDER_INT_LINE_
NO, &MAT_BUSINESS_UNIT_BI, &MAT_MMC_NF_BRL_ID_OUT, &MAT_MMC_LINE_NUM_OUT, &MAT_C
UST_ID, &MAT_ACCOUNT, &MAT_MMC_TIPO_AJUST, &MAT_OPRID, &MAT_UNIT_OF_MEASURE, &MA
T_MMC_OBS_AJUST, &MAT_MMC_ISSUE_QTY, &MAT_QTY_NF_BRL, &MAT_UNIT_PRICE, &MAT_MERC
HANDISE_AMT, &MAT_SHIPTO_ID);
End-Function;
/************************* mmcb.sds2946.en ************************************
********/
&REC_STAGED_ITEM_INV.STAGING_ID.VALUE = &S_STAGING_ID;
&REC_STAGED_ITEM_INV.INV_LOT_ID.VALUE = &S_INV_LOT_ID;
&REC_STAGED_ITEM_INV.CONTAINER_ID.VALUE = &S_CONTAINER_ID;
&REC_STAGED_ITEM_INV.INV_ITEM_ID.VALUE = &S_INV_ITEM_ID;
&REC_STAGED_ITEM_INV.SERIAL_ID.VALUE = &S_SERIAL_ID;
&REC_STAGED_ITEM_INV.RECEIVER_ID.VALUE = &S_RECEIVER_ID;
&REC_STAGED_ITEM_INV.RECV_LN_NBR.VALUE = &S_RECV_LN_NBR;
&REC_STAGED_ITEM_INV.STAGED_NUM.VALUE = &S_STAGED_NUM;
&REC_STAGED_ITEM_INV.SOURCE_BUS_UNIT.VALUE = &S_SOURCE_BUS_UNIT;
&REC_STAGED_ITEM_INV.RECV_SHIP_SEQ_NBR.VALUE = &S_RECV_SHIP_SEQ_NBR;
&REC_STAGED_ITEM_INV.DISTRIB_LINE_NUM.VALUE = &S_DISTRIB_LINE_NUM;
&REC_STAGED_ITEM_INV.DISTRIB_SEQ_NUM.VALUE = &S_DISTRIB_SEQ_NUM;
&REC_STAGED_ITEM_INV.RMA_ID.VALUE = &S_RMA_ID;
&REC_STAGED_ITEM_INV.RMA_LINE_NBR.VALUE = &S_RMA_LINE_NBR;
&REC_STAGED_ITEM_INV.PTWY_PLAN_ID.VALUE = &S_PTWY_PLAN_ID;
&REC_STAGED_ITEM_INV.PTWYPLAN_LN_NBR.VALUE = &S_PTWYPLAN_LN_NBR;
&REC_STAGED_ITEM_INV.STAGED_DATE.VALUE = &S_STAGED_DATE;
&REC_STAGED_ITEM_INV.LOT_BIRTHDATE.VALUE = &S_LOT_BIRTHDATE;
&REC_STAGED_ITEM_INV.EXPIRATION_DATE.VALUE = &S_EXPIRATION_DATE;
&REC_STAGED_ITEM_INV.MA_PRDN_ID_FLG.VALUE = &S_MA_PRDN_ID_FLG;
&REC_STAGED_ITEM_INV.PRODUCTION_ID.VALUE = &S_PRODUCTION_ID;
&REC_STAGED_ITEM_INV.PRDN_AREA_CODE.VALUE = &S_PRDN_AREA_CODE;
&REC_STAGED_ITEM_INV.PRODUCTION_TYPE.VALUE = &S_PRODUCTION_TYPE;
&REC_STAGED_ITEM_INV.TO_PRODUCTION_ID.VALUE = &S_TO_PRODUCTION_ID;
&REC_STAGED_ITEM_INV.OP_SEQUENCE.VALUE = &S_OP_SEQUENCE;
&REC_STAGED_ITEM_INV.QTY_CODE.VALUE = &S_QTY_CODE;
&REC_STAGED_ITEM_INV.INV_STOCK_TYPE.VALUE = &S_INV_STOCK_TYPE;
&REC_STAGED_ITEM_INV.QTY.VALUE = &S_QTY;
&REC_STAGED_ITEM_INV.UNIT_OF_MEASURE.VALUE = &S_UNIT_OF_MEASURE;
&REC_STAGED_ITEM_INV.QTY_BASE.VALUE = &S_QTY_BASE;
&REC_STAGED_ITEM_INV.QTY_CONV_FLAG.VALUE = &S_QTY_CONV_FLAG;
&REC_STAGED_ITEM_INV.PUTAWAY_STATUS.VALUE = &S_PUTAWAY_STATUS;
&REC_STAGED_ITEM_INV.CONVERSION_RATE.VALUE = &S_CONVERSION_RATE;
&REC_STAGED_ITEM_INV.TRANSFER_COST.VALUE = &S_TRANSFER_COST;
&REC_STAGED_ITEM_INV.PROCESS_FLAG.VALUE = &S_PROCESS_FLAG;
&REC_STAGED_ITEM_INV.PROCESS_INSTANCE.VALUE = &S_PROCESS_INSTANCE;
&REC_STAGED_ITEM_INV.JOB_INSTANCE.VALUE = &S_JOB_INSTANCE;
&REC_STAGED_ITEM_INV.PUTAWAY_COMMENT.VALUE = &S_PUTAWAY_COMMENT;
&REC_STAGED_ITEM_INV.FROM_STOR_AREA.VALUE = &S_FROM_STOR_AREA;
&REC_STAGED_ITEM_INV.FROM_STOR_LEV1.VALUE = &S_FROM_STOR_LEV1;
&REC_STAGED_ITEM_INV.FROM_STOR_LEV2.VALUE = &S_FROM_STOR_LEV2;
&REC_STAGED_ITEM_INV.FROM_STOR_LEV3.VALUE = &S_FROM_STOR_LEV3;
&REC_STAGED_ITEM_INV.FROM_STOR_LEV4.VALUE = &S_FROM_STOR_LEV4;
&REC_STAGED_ITEM_INV.FROM_UOM.VALUE = &S_FROM_UOM;
&REC_STAGED_ITEM_INV.STORAGE_AREA.VALUE = &S_STORAGE_AREA;
&REC_STAGED_ITEM_INV.STOR_LEVEL_1.VALUE = &S_STOR_LEVEL_1;
&REC_STAGED_ITEM_INV.STOR_LEVEL_2.VALUE = &S_STOR_LEVEL_2;
&REC_STAGED_ITEM_INV.STOR_LEVEL_3.VALUE = &S_STOR_LEVEL_3;
&REC_STAGED_ITEM_INV.STOR_LEVEL_4.VALUE = &S_STOR_LEVEL_4;
&REC_STAGED_ITEM_INV.PUTAWAY_FLAG.VALUE = &S_PUTAWAY_FLAG;
&REC_STAGED_ITEM_INV.RECEIPT_TYPE.VALUE = &S_RECEIPT_TYPE;
&REC_STAGED_ITEM_INV.PO_ID.VALUE = &S_PO_ID;
&REC_STAGED_ITEM_INV.INTERUNIT_ID.VALUE = &S_INTERUNIT_ID;
&REC_STAGED_ITEM_INV.INTERUNIT_LINE.VALUE = &S_INTERUNIT_LINE;
&REC_STAGED_ITEM_INV.SF_KANBAN_ID.VALUE = &S_SF_KANBAN_ID;
&REC_STAGED_ITEM_INV.INSPECT_STATUS.VALUE = &S_INSPECT_STATUS;
&REC_STAGED_ITEM_INV.INSPECTION_ID.VALUE = &S_INSPECTION_ID;
&REC_STAGED_ITEM_INV.LAST_PURCH_DATE.VALUE = &S_LAST_PURCH_DATE;
&REC_STAGED_ITEM_INV.NON_OWN_FLAG.VALUE = &S_NON_OWN_FLAG;
&REC_STAGED_ITEM_INV.PURCH_LOT_ID.VALUE = &S_PURCH_LOT_ID;
&REC_STAGED_ITEM_INV.VENDOR_ID.VALUE = &S_VENDOR_ID;
&REC_STAGED_ITEM_INV.STORAGE_CODE.VALUE = &S_STORAGE_CODE;
&REC_STAGED_ITEM_INV.OPRID.VALUE = &S_OPRID;
&REC_STAGED_ITEM_INV.STAGED_TYPE.VALUE = &S_STAGED_TYPE;
&REC_STAGED_ITEM_INV.DISTRIB_TYPE.VALUE = &S_DISTRIB_TYPE;
&REC_STAGED_ITEM_INV.PO_DT.VALUE = &S_PO_DT;
&REC_STAGED_ITEM_INV.BUSINESS_UNIT_PO.VALUE = &S_BUSINESS_UNIT_PO;
&REC_STAGED_ITEM_INV.TRANS_SOURCE.VALUE = &S_TRANS_SOURCE;
&REC_STAGED_ITEM_INV.CONFIG_CODE.VALUE = &S_CONFIG_CODE;
&REC_STAGED_ITEM_INV.CANCEL_NETTABLE.VALUE = &S_CANCEL_NETTABLE;
&REC_STAGED_ITEM_INV.DT_TIMESTAMP.VALUE = &S_DT_TIMESTAMP;
&REC_STAGED_ITEM_INV.CONTAINER_TYPE.VALUE = &S_CONTAINER_TYPE;
&REC_STAGED_ITEM_INV.SPEEDTYPE_KEY.VALUE = &S_SPEEDTYPE_KEY;
&REC_STAGED_ITEM_INV.ACCOUNT.VALUE = &S_ACCOUNT;
&REC_STAGED_ITEM_INV.ALTACCT.VALUE = &S_ALTACCT;
&REC_STAGED_ITEM_INV.OPERATING_UNIT.VALUE = &S_OPERATING_UNIT;
&REC_STAGED_ITEM_INV.DEPTID.VALUE = &S_DEPTID;
&REC_STAGED_ITEM_INV.PRODUCT.VALUE = &S_PRODUCT;
&REC_STAGED_ITEM_INV.PROJECT_ID.VALUE = &S_PROJECT_ID;
&REC_STAGED_ITEM_INV.ACTIVITY_ID.VALUE = &S_ACTIVITY_ID;
&REC_STAGED_ITEM_INV.RESOURCE_TYPE.VALUE = &S_RESOURCE_TYPE;
&REC_STAGED_ITEM_INV.RESOURCE_CATEGORY.VALUE = &S_RESOURCE_CATEGORY;
&REC_STAGED_ITEM_INV.RESOURCE_SUB_CAT.VALUE = &S_RESOURCE_SUB_CAT;
&REC_STAGED_ITEM_INV.ANALYSIS_TYPE.VALUE = &S_ANALYSIS_TYPE;
&REC_STAGED_ITEM_INV.BUSINESS_UNIT_PC.VALUE = &S_BUSINESS_UNIT_PC;
&REC_STAGED_ITEM_INV.COMBO_VALID_FLG.VALUE = &S_COMBO_VALID_FLG;
&REC_STAGED_ITEM_INV.CONSIGNED_FLAG.VALUE = &S_CONSIGNED_FLAG;
&REC_STAGED_ITEM_INV.Insert();
End-Function;
/*******************************************************************************
******
* Faz Insert Tabela: SYSADM.PS_STAGED_INF_INV
*
********************************************************************************
*****/
Function GRAVA_STAGED_INF_INV(&IN_BUSINESS_UNIT, &IN_INV_LOT_ID, &IN_CONTAINER_I
D, &IN_INV_ITEM_ID, &IN_SERIAL_ID, &IN_RECEIVER_ID, &IN_RECV_LN_NBR, &IN_SEQ_NUM
, &IN_SOURCE_BUS_UNIT, &IN_RECV_SHIP_SEQ_NBR, &IN_DISTRIB_LINE_NUM, &IN_DISTRIB_
SEQ_NUM, &IN_COST_ELEMENT, &IN_RMA_ID, &IN_RMA_LINE_NBR, &IN_LOT_BIRTHDATE, &IN_
EXPIRATION_DATE, &IN_PO_ID, &IN_INTERUNIT_ID, &IN_INTERUNIT_LINE, &IN_INSPECT_ST
ATUS, &IN_INSPECTION_ID, &IN_LAST_PURCH_DATE, &IN_ACTUAL_COST, &IN_CONVERSION_RA
TE, &IN_TRANSFER_COST, &IN_QTY, &IN_UNIT_OF_MEASURE, &IN_RECEIPT_TYPE, &IN_NON_O
WN_FLAG, &IN_INV_STOCK_TYPE, &IN_PURCH_LOT_ID, &IN_VENDOR_ID, &IN_MA_PRDN_ID_FLG
, &IN_PRODUCTION_ID, &IN_PRDN_AREA_CODE, &IN_PRODUCTION_TYPE, &IN_TO_PRODUCTION_
ID, &IN_OP_SEQUENCE, &IN_QTY_CODE, &IN_STORAGE_CODE, &IN_STORAGE_AREA, &IN_STOR_
LEVEL_1, &IN_STOR_LEVEL_2, &IN_STOR_LEVEL_3, &IN_STOR_LEVEL_4, &IN_DISTRIB_TYPE,
&IN_PO_DT, &IN_BUSINESS_UNIT_PO, &IN_TRANS_SOURCE, &IN_STAGED_STATUS, &IN_CONFI
G_CODE, &IN_OPRID, &IN_PROCESS_FLAG, &IN_PROCESS_INSTANCE, &IN_JOB_INSTANCE, &IN
_CONTAINER_TYPE, &IN_SPEEDTYPE_KEY, &IN_ACCOUNT, &IN_ALTACCT, &IN_OPERATING_UNIT
, &IN_DEPTID, &IN_PRODUCT, &IN_PROJECT_ID, &IN_ACTIVITY_ID, &IN_RESOURCE_TYPE, &
IN_RESOURCE_CATEGORY, &IN_RESOURCE_SUB_CAT, &IN_ANALYSIS_TYPE, &IN_BUSINESS_UNIT
_PC, &IN_COMBO_VALID_FLG, &IN_CONSIGNED_FLAG, &IN_SF_KANBAN_ID)
&REC_STAGED_INF_INV = CreateRecord(Record.STAGED_INF_INV);
&REC_STAGED_INF_INV.BUSINESS_UNIT.VALUE = &IN_BUSINESS_UNIT;
&REC_STAGED_INF_INV.INV_LOT_ID.VALUE = &IN_INV_LOT_ID;
&REC_STAGED_INF_INV.CONTAINER_ID.VALUE = &IN_CONTAINER_ID;
&REC_STAGED_INF_INV.INV_ITEM_ID.VALUE = &IN_INV_ITEM_ID;
&REC_STAGED_INF_INV.SERIAL_ID.VALUE = &IN_SERIAL_ID;
&REC_STAGED_INF_INV.RECEIVER_ID.VALUE = &IN_RECEIVER_ID;
&REC_STAGED_INF_INV.RECV_LN_NBR.VALUE = &IN_RECV_LN_NBR;
&REC_STAGED_INF_INV.SEQ_NUM.VALUE = &IN_SEQ_NUM;
&REC_STAGED_INF_INV.SOURCE_BUS_UNIT.VALUE = &IN_SOURCE_BUS_UNIT;
&REC_STAGED_INF_INV.RECV_SHIP_SEQ_NBR.VALUE = &IN_RECV_SHIP_SEQ_NBR;
&REC_STAGED_INF_INV.DISTRIB_LINE_NUM.VALUE = &IN_DISTRIB_LINE_NUM;
&REC_STAGED_INF_INV.DISTRIB_SEQ_NUM.VALUE = &IN_DISTRIB_SEQ_NUM;
&REC_STAGED_INF_INV.COST_ELEMENT.VALUE = &IN_COST_ELEMENT;
&REC_STAGED_INF_INV.RMA_ID.VALUE = &IN_RMA_ID;
&REC_STAGED_INF_INV.RMA_LINE_NBR.VALUE = &IN_RMA_LINE_NBR;
&REC_STAGED_INF_INV.LOT_BIRTHDATE.VALUE = &IN_LOT_BIRTHDATE;
&REC_STAGED_INF_INV.EXPIRATION_DATE.VALUE = &IN_EXPIRATION_DATE;
&REC_STAGED_INF_INV.PO_ID.VALUE = &IN_PO_ID;
&REC_STAGED_INF_INV.INTERUNIT_ID.VALUE = &IN_INTERUNIT_ID;
&REC_STAGED_INF_INV.INTERUNIT_LINE.VALUE = &IN_INTERUNIT_LINE;
&REC_STAGED_INF_INV.INSPECT_STATUS.VALUE = &IN_INSPECT_STATUS;
&REC_STAGED_INF_INV.INSPECTION_ID.VALUE = &IN_INSPECTION_ID;
&REC_STAGED_INF_INV.LAST_PURCH_DATE.VALUE = &IN_LAST_PURCH_DATE;
&REC_STAGED_INF_INV.ACTUAL_COST.VALUE = &IN_ACTUAL_COST;
&REC_STAGED_INF_INV.CONVERSION_RATE.VALUE = &IN_CONVERSION_RATE;
&REC_STAGED_INF_INV.TRANSFER_COST.VALUE = &IN_TRANSFER_COST;
&REC_STAGED_INF_INV.QTY.VALUE = &IN_QTY;
&REC_STAGED_INF_INV.UNIT_OF_MEASURE.VALUE = &IN_UNIT_OF_MEASURE;
&REC_STAGED_INF_INV.RECEIPT_TYPE.VALUE = &IN_RECEIPT_TYPE;
&REC_STAGED_INF_INV.NON_OWN_FLAG.VALUE = &IN_NON_OWN_FLAG;
&REC_STAGED_INF_INV.INV_STOCK_TYPE.VALUE = &IN_INV_STOCK_TYPE;
&REC_STAGED_INF_INV.PURCH_LOT_ID.VALUE = &IN_PURCH_LOT_ID;
&REC_STAGED_INF_INV.VENDOR_ID.VALUE = &IN_VENDOR_ID;
&REC_STAGED_INF_INV.MA_PRDN_ID_FLG.VALUE = &IN_MA_PRDN_ID_FLG;
&REC_STAGED_INF_INV.PRODUCTION_ID.VALUE = &IN_PRODUCTION_ID;
&REC_STAGED_INF_INV.PRDN_AREA_CODE.VALUE = &IN_PRDN_AREA_CODE;
&REC_STAGED_INF_INV.PRODUCTION_TYPE.VALUE = &IN_PRODUCTION_TYPE;
&REC_STAGED_INF_INV.TO_PRODUCTION_ID.VALUE = &IN_TO_PRODUCTION_ID;
&REC_STAGED_INF_INV.OP_SEQUENCE.VALUE = &IN_OP_SEQUENCE;
&REC_STAGED_INF_INV.QTY_CODE.VALUE = &IN_QTY_CODE;
&REC_STAGED_INF_INV.STORAGE_CODE.VALUE = &IN_STORAGE_CODE;
&REC_STAGED_INF_INV.STORAGE_AREA.VALUE = &IN_STORAGE_AREA;
&REC_STAGED_INF_INV.STOR_LEVEL_1.VALUE = &IN_STOR_LEVEL_1;
&REC_STAGED_INF_INV.STOR_LEVEL_2.VALUE = &IN_STOR_LEVEL_2;
&REC_STAGED_INF_INV.STOR_LEVEL_3.VALUE = &IN_STOR_LEVEL_3;
&REC_STAGED_INF_INV.STOR_LEVEL_4.VALUE = &IN_STOR_LEVEL_4;
&REC_STAGED_INF_INV.DISTRIB_TYPE.VALUE = &IN_DISTRIB_TYPE;
&REC_STAGED_INF_INV.PO_DT.VALUE = &IN_PO_DT;
&REC_STAGED_INF_INV.BUSINESS_UNIT_PO.VALUE = &IN_BUSINESS_UNIT_PO;
&REC_STAGED_INF_INV.TRANS_SOURCE.VALUE = &IN_TRANS_SOURCE;
&REC_STAGED_INF_INV.STAGED_STATUS.VALUE = &IN_STAGED_STATUS;
&REC_STAGED_INF_INV.CONFIG_CODE.VALUE = &IN_CONFIG_CODE;
&REC_STAGED_INF_INV.OPRID.VALUE = &IN_OPRID;
&REC_STAGED_INF_INV.PROCESS_FLAG.VALUE = &IN_PROCESS_FLAG;
&REC_STAGED_INF_INV.PROCESS_INSTANCE.VALUE = &IN_PROCESS_INSTANCE;
&REC_STAGED_INF_INV.JOB_INSTANCE.VALUE = &IN_JOB_INSTANCE;
&REC_STAGED_INF_INV.CONTAINER_TYPE.VALUE = &IN_CONTAINER_TYPE;
&REC_STAGED_INF_INV.SPEEDTYPE_KEY.VALUE = &IN_SPEEDTYPE_KEY;
&REC_STAGED_INF_INV.ACCOUNT.VALUE = &IN_ACCOUNT;
&REC_STAGED_INF_INV.ALTACCT.VALUE = &IN_ALTACCT;
&REC_STAGED_INF_INV.OPERATING_UNIT.VALUE = &IN_OPERATING_UNIT;
&REC_STAGED_INF_INV.DEPTID.VALUE = &IN_DEPTID;
&REC_STAGED_INF_INV.PRODUCT.VALUE = &IN_PRODUCT;
&REC_STAGED_INF_INV.PROJECT_ID.VALUE = &IN_PROJECT_ID;
&REC_STAGED_INF_INV.ACTIVITY_ID.VALUE = &IN_ACTIVITY_ID;
&REC_STAGED_INF_INV.RESOURCE_TYPE.VALUE = &IN_RESOURCE_TYPE;
&REC_STAGED_INF_INV.RESOURCE_CATEGORY.VALUE = &IN_RESOURCE_CATEGORY;
&REC_STAGED_INF_INV.RESOURCE_SUB_CAT.VALUE = &IN_RESOURCE_SUB_CAT;
&REC_STAGED_INF_INV.ANALYSIS_TYPE.VALUE = &IN_ANALYSIS_TYPE;
&REC_STAGED_INF_INV.BUSINESS_UNIT_PC.VALUE = &IN_BUSINESS_UNIT_PC;
&REC_STAGED_INF_INV.COMBO_VALID_FLG.VALUE = &IN_COMBO_VALID_FLG;
&REC_STAGED_INF_INV.CONSIGNED_FLAG.VALUE = &IN_CONSIGNED_FLAG;
&REC_STAGED_INF_INV.SF_KANBAN_ID.VALUE = &IN_SF_KANBAN_ID;
&REC_STAGED_INF_INV.Insert();
End-Function;
/*******************************************************************************
**********************************
* Retorna maior CM_SEQ_COST tabela CM_ACTUAL_COST
********************************************************************************
*********************************/
Function max_cmseqcost_cmactualcost(&PAR_BUSINESS_UNIT, &PAR_INV_ITEM_ID, &PAR_D
T_TIMESTAMP, &PAR_SEQ_NBR, &PAR_COST_ELEMENT) Returns number
SQLExec("select case when max(cm_seq_cost) > 0 then max(cm_seq_cost)+1 else 1
end from sysadm.ps_cm_actual_cost where business_unit=:1 and inv_item_id=:2 an
d dt_timestamp= %datetimein(:3) and seq_nbr=:4 and cost_element=:5 ", &PAR_BUSIN
ESS_UNIT, &PAR_INV_ITEM_ID, &PAR_DT_TIMESTAMP, &PAR_SEQ_NBR, &PAR_COST_ELEMENT,
&CM_SEQ_COST);
Return &CM_SEQ_COST;
End-Function;
/*******************************************************************************
**********************************
* INSERE DADOS TAVELA CM_ACTUAL_COST
********************************************************************************
*********************************/
Function GRAVA_CM_ACTUAL_COST(&P_C_BUSINESS_UNIT, &P_C_INV_ITEM_ID, &P_C_DT_TIME
STAMP, &P_C_SEQ_NBR, &P_C_COST_ELEMENT, &P_C_CM_SEQ_COST, &P_C_BUSINESS_UNIT_REC
V, &P_C_RECEIVER_ID, &P_C_RECV_LN_NBR, &P_C_RECV_SHIP_SEQ_NBR, &P_C_DISTRIB_LINE
_NUM, &P_C_EFF_STATUS, &P_C_CM_DTTM_IN_EFFECT, &P_C_CM_DTTM_STAMP, &P_C_CM_ADJ_T
YPE, &P_C_CM_COST_SOURCE, &P_C_CM_UNIT_COST, &P_C_CURRENCY_CD, &P_C_PROCESS_INST
ANCE)
If None(&P_C_COST_ELEMENT) Or
&P_C_COST_ELEMENT = " " Or
Len(&P_C_COST_ELEMENT) = 0 Then
SQLExec("SELECT COST_ELEMENT FROM SYSADM.PS_BU_ITEMS_INV WHERE BUSINESS_UN
IT =:1 AND INV_ITEM_ID =:2 ", &P_C_BUSINESS_UNIT, &P_C_INV_ITEM_ID, &P_C_COST_EL
EMENT);
End-If;
&REC_CM_ACTUAL_COST = CreateRecord(Record.CM_ACTUAL_COST);
&REC_CM_ACTUAL_COST.BUSINESS_UNIT.VALUE = &P_C_BUSINESS_UNIT;
&REC_CM_ACTUAL_COST.INV_ITEM_ID.VALUE = &P_C_INV_ITEM_ID;
&REC_CM_ACTUAL_COST.DT_TIMESTAMP.VALUE = &P_C_DT_TIMESTAMP;
&REC_CM_ACTUAL_COST.SEQ_NBR.VALUE = &P_C_SEQ_NBR;
&REC_CM_ACTUAL_COST.COST_ELEMENT.VALUE = &P_C_COST_ELEMENT;
&REC_CM_ACTUAL_COST.CM_SEQ_COST.VALUE = &P_C_CM_SEQ_COST;
&REC_CM_ACTUAL_COST.BUSINESS_UNIT_RECV.VALUE = &P_C_BUSINESS_UNIT_RECV;
&REC_CM_ACTUAL_COST.RECEIVER_ID.VALUE = &P_C_RECEIVER_ID;
&REC_CM_ACTUAL_COST.RECV_LN_NBR.VALUE = &P_C_RECV_LN_NBR;
&REC_CM_ACTUAL_COST.RECV_SHIP_SEQ_NBR.VALUE = &P_C_RECV_SHIP_SEQ_NBR;
&REC_CM_ACTUAL_COST.DISTRIB_LINE_NUM.VALUE = &P_C_DISTRIB_LINE_NUM;
&REC_CM_ACTUAL_COST.EFF_STATUS.VALUE = &P_C_EFF_STATUS;
&REC_CM_ACTUAL_COST.CM_DTTM_IN_EFFECT.VALUE = &P_C_CM_DTTM_IN_EFFECT;
&REC_CM_ACTUAL_COST.CM_DTTM_STAMP.VALUE = &P_C_CM_DTTM_STAMP;
&REC_CM_ACTUAL_COST.CM_ADJ_TYPE.VALUE = &P_C_CM_ADJ_TYPE;
&REC_CM_ACTUAL_COST.CM_COST_SOURCE.VALUE = &P_C_CM_COST_SOURCE;
&REC_CM_ACTUAL_COST.CM_UNIT_COST.VALUE = &P_C_CM_UNIT_COST;
&REC_CM_ACTUAL_COST.CURRENCY_CD.VALUE = &P_C_CURRENCY_CD;
&REC_CM_ACTUAL_COST.PROCESS_INSTANCE.VALUE = &P_C_PROCESS_INSTANCE;
&REC_CM_ACTUAL_COST.Insert();
End-Function;
/*******************************************************************************
**********************************
* INSERE DADOS TAVELA CM_PERPAVG_COST
********************************************************************************
*********************************/
Function GRAVA_CM_PERPAVG_COST(&P1_BUSINESS_UNIT, &P1_INV_ITEM_ID, &P1_DT_TIMEST
AMP, &P1_SEQ_NBR, &P1_TRANSACTION_DT, &P1_CM_COST_SOURCE, &P1_CM_UNIT_COST, &P1_
CURRENCY_CD)
&REC_CM_PERPAVG_COST = CreateRecord(Record.CM_PERPAVG_COST);
&REC_CM_PERPAVG_COST.BUSINESS_UNIT.VALUE = &P1_BUSINESS_UNIT;
&REC_CM_PERPAVG_COST.INV_ITEM_ID.VALUE = &P1_INV_ITEM_ID;
&REC_CM_PERPAVG_COST.DT_TIMESTAMP.VALUE = &P1_DT_TIMESTAMP;
&REC_CM_PERPAVG_COST.SEQ_NBR.VALUE = &P1_SEQ_NBR;
&REC_CM_PERPAVG_COST.TRANSACTION_DT.VALUE = &P1_TRANSACTION_DT;
&REC_CM_PERPAVG_COST.CM_COST_SOURCE.VALUE = &P1_CM_COST_SOURCE;
&REC_CM_PERPAVG_COST.CM_UNIT_COST.VALUE = &P1_CM_UNIT_COST;
&REC_CM_PERPAVG_COST.CURRENCY_CD.VALUE = &P1_CURRENCY_CD;
&REC_CM_PERPAVG_COST.Insert();
End-Function;
/*******************************************************************************
**********************************
* CUSTO ITEM
********************************************************************************
*********************************/
Function BUSCA_CUSTO_ITEM(&C_BUSINESS_UNIT, &C_INV_ITEM_ID, &C_DT_TIMESTAMP, &C_
CONFIG_CODE) Returns number
/*
SOURCE_CODE = '1' = Fabricado
SOURCE_CODE = '2' = Comprado
*/
/************************************* mmcb.hd170820.sn *********************
****************/
/*Recupera o SETID*/
&SETID = BUSCA_SETID();
/*Recupera se o item e controlado por lote*/
SQLExec("SELECT LOT_CONTROL FROM SYSADM.PS_MASTER_ITEM_TBL WHERE SETID = :1 A
ND INV_ITEM_ID = :2", &SETID, &C_INV_ITEM_ID, &LOT_CONTROL);
/*Atualiza a varivel C_CONFIG_CODE, caso o item no seja controlado por lote*/
If &LOT_CONTROL = "N" Then
&C_CONFIG_CODE = " ";
End-If;
/************************************* mmcb.hd170820.en *********************
****************/
SQLExec("select source_code from sysadm.ps_bu_items_inv where business_unit =
:1 and inv_item_id=:2", &C_BUSINESS_UNIT, &C_INV_ITEM_ID, &SOURCE_CODE);
If None(&SOURCE_CODE) Then
Error ("Item :" | &C_INV_ITEM_ID | "no est parametrizado.");
End-If;
&QTDE_DIAS = %Date - Date3(1998, 1, 1);
&DIA_INICIAL = 0;
&DIA_FINAL = 30;
&CUSTO_COMPRADO = 0;
&CUSTO_FABRICADO = 0;
While (&DIA_INICIAL <= &QTDE_DIAS)
If &SOURCE_CODE = "2" Then
SQLExec("select cc.cm_unit_cost from sysadm.ps_cm_perpavg_cost cc where
cc.business_unit =:1 and cc.inv_item_id =:2 and cc.dt_timestamp = ( select max(
bc.dt_timestamp ) from sysadm.ps_cm_perpavg_cost bc where bc.business_unit = cc
.business_unit and bc.inv_item_id = cc.inv_item_id and bc.dt_timestamp >= %datet
imein(:3) - :4 and bc.dt_timestamp <= %datetimein(:5) - :6 ) and cc.seq_nbr = (
select max( bc1.seq_nbr ) from sysadm.ps_cm_perpavg_cost bc1 where bc1.business_
unit = cc.business_unit and bc1.inv_item_id = cc.inv_item_id and bc1.dt_timestam
p
= cc.dt_timestamp )", &C_BUSINESS_UNIT, &C_INV_ITEM_ID, &C_DT_TIMESTAMP, &D
IA_FINAL, &C_DT_TIMESTAMP, &DIA_INICIAL, &CUSTO_COMPRADO);
If &CUSTO_COMPRADO > 0 Then
Return &CUSTO_COMPRADO;
End-If;
End-If;
If &SOURCE_CODE = "1" Then
SQLExec("select sum(tl_cost + ll_cost) from sysadm.ps_cm_prodcost cc wh
ere cc.business_unit =:1 and cc.inv_item_id =:2 and cc.config_code =:3 and cc.ef
fdt = ( select max(bc.effdt) from sysadm.ps_cm_prodcost bc where bc.business_un
it = cc.business_unit and bc.inv_item_id = cc.inv_item_id and bc.config_code = c
c.config_code and bc.effdt >= %datetimein(:4) - :5 and bc.effdt <= %datetimein(:
6) - :7 )", &C_BUSINESS_UNIT, &C_INV_ITEM_ID, &C_CONFIG_CODE, &C_DT_TIMESTAMP, &
DIA_FINAL, &C_DT_TIMESTAMP, &DIA_INICIAL, &CUSTO_FABRICADO);
If &CUSTO_FABRICADO > 0 Then
Return &CUSTO_FABRICADO;
End-If;
End-If;
&P_C_CURRENCY_CD = "BRL";
&P_C_PROCESS_INSTANCE = 0;
GRAVA_CM_ACTUAL_COST(&P_C_BUSINESS_UNIT, &P_C_INV_ITEM_ID, &P_C_DT_TIMESTAMP,
&P_C_SEQ_NBR, &P_C_COST_ELEMENT, &P_C_CM_SEQ_COST, &P_C_BUSINESS_UNIT_RECV, &P_
C_RECEIVER_ID, &P_C_RECV_LN_NBR, &P_C_RECV_SHIP_SEQ_NBR, &P_C_DISTRIB_LINE_NUM,
&P_C_EFF_STATUS, &P_C_CM_DTTM_IN_EFFECT, &P_C_CM_DTTM_STAMP, &P_C_CM_ADJ_TYPE, &
P_C_CM_COST_SOURCE, &P_C_CM_UNIT_COST, &P_C_CURRENCY_CD, &P_C_PROCESS_INSTANCE);
&P1_BUSINESS_UNIT = &P_BUSINESS_UNIT;
&P1_INV_ITEM_ID = &P_INV_ITEM_ID;
&P1_DT_TIMESTAMP = &P_DT_TIMESTAMP;
&P1_SEQ_NBR = &P_SEQ_NBR;
&P1_TRANSACTION_DT = &P_TRANSACTION_DT;
&P1_CM_COST_SOURCE = "2";
&P1_CM_UNIT_COST = &NOVO_CUSTO;
&P1_CURRENCY_CD = "BRL";
GRAVA_CM_PERPAVG_COST(&P1_BUSINESS_UNIT, &P1_INV_ITEM_ID, &P1_DT_TIMESTAMP, &
P1_SEQ_NBR, &P1_TRANSACTION_DT, &P1_CM_COST_SOURCE, &P1_CM_UNIT_COST, &P1_CURREN
CY_CD)
End-Function;
/*******************************************************************************
**********************************
* Retorna maior SEQ_NBR PS_TRANSACTION_INV
********************************************************************************
*********************************/
Function max_seqnbr_transaction(&PAR_BUSINESS_UNIT, &PAR_INV_ITEM_ID, &PAR_DT_TI
MESTAMP) Returns number
SQLExec("select case when max(seq_nbr)>0 then max(seq_nbr)+1 else 1 end from
sysadm.ps_transaction_inv where business_unit=:1 and inv_item_id=:2 and dt_times
tamp =%datetimein(:3)", &PAR_BUSINESS_UNIT, &PAR_INV_ITEM_ID, &PAR_DT_TIMESTAMP,
&V_SEQ_NBR);
Return &V_SEQ_NBR;
End-Function;
/*******************************************************************************
**********************************
* Insere uma nova linha na tabela PHYSICAL_INV
********************************************************************************
*********************************/
Function GRAVA_PHYSICAL_INV(&PAR_BUSINESS_UNIT, &PAR_STAGED_DATE, &PAR_INV_LOT_I
D, &PAR_INV_ITEM_ID, &PAR_SERIAL_ID, &PAR_STORAGE_AREA, &PAR_STOR_LEVEL_1, &PAR_
STOR_LEVEL_2, &PAR_STOR_LEVEL_3, &PAR_STOR_LEVEL_4, &PAR_CONTAINER_ID, &PAR_UNIT
_OF_MEASURE, &PAR_LAST_TRANSACT_TYPE, &PAR_LAST_ISSUE_DATE, &PAR_QTY, &PAR_QTY_R
ESERVED, &PAR_QTY_BASE, &PAR_QTY_RESERVED_BASE, &PAR_AVAIL_STATUS, &PAR_DT_TIMES
TAMP)
&REC_PHYSICAL_INV = CreateRecord(Record.PHYSICAL_INV);
&REC_PHYSICAL_INV.BUSINESS_UNIT.VALUE = &PAR_BUSINESS_UNIT;
&REC_PHYSICAL_INV.STAGED_DATE.VALUE = &PAR_STAGED_DATE;
&REC_PHYSICAL_INV.INV_LOT_ID.VALUE = &PAR_INV_LOT_ID;
&REC_PHYSICAL_INV.INV_ITEM_ID.VALUE = &PAR_INV_ITEM_ID;
&REC_PHYSICAL_INV.SERIAL_ID.VALUE = &PAR_SERIAL_ID;
&REC_PHYSICAL_INV.STORAGE_AREA.VALUE = &PAR_STORAGE_AREA;
&REC_PHYSICAL_INV.STOR_LEVEL_1.VALUE = &PAR_STOR_LEVEL_1;
&REC_PHYSICAL_INV.STOR_LEVEL_2.VALUE = &PAR_STOR_LEVEL_2;
&REC_PHYSICAL_INV.STOR_LEVEL_3.VALUE = &PAR_STOR_LEVEL_3;
&REC_PHYSICAL_INV.STOR_LEVEL_4.VALUE = &PAR_STOR_LEVEL_4;
&REC_PHYSICAL_INV.CONTAINER_ID.VALUE = &PAR_CONTAINER_ID;
&REC_PHYSICAL_INV.UNIT_OF_MEASURE.VALUE = &PAR_UNIT_OF_MEASURE;
&REC_PHYSICAL_INV.LAST_TRANSACT_TYPE.VALUE = &PAR_LAST_TRANSACT_TYPE;
&REC_PHYSICAL_INV.LAST_ISSUE_DATE.VALUE = &PAR_LAST_ISSUE_DATE;
&REC_PHYSICAL_INV.QTY.VALUE = &PAR_QTY;
&REC_PHYSICAL_INV.QTY_RESERVED.VALUE = &PAR_QTY_RESERVED;
&REC_PHYSICAL_INV.QTY_BASE.VALUE = &PAR_QTY_BASE;
&REC_PHYSICAL_INV.QTY_RESERVED_BASE.VALUE = &PAR_QTY_RESERVED_BASE;
&REC_PHYSICAL_INV.AVAIL_STATUS.VALUE = &PAR_AVAIL_STATUS;
&REC_PHYSICAL_INV.AVAIL_STATUS_TYPE.VALUE = " ";
&REC_PHYSICAL_INV.REASON_CD.VALUE = " ";
&REC_PHYSICAL_INV.DT_TIMESTAMP.VALUE = &PAR_DT_TIMESTAMP;
&REC_PHYSICAL_INV.DESCR254.VALUE = " ";
&REC_PHYSICAL_INV.Insert();
End-Function;
/*******************************************************************************
**********************************
* Faz atualizao de QTDs na tabela PHYSICAL_INV ou Cria uma nova linha caso no exist
a.
********************************************************************************
*********************************/
Function ATUALIZA_PHYSICAL_INV_020(&PAR_BUSINESS_UNIT, &PAR_STAGED_DATE, &PAR_IN
V_LOT_ID, &PAR_INV_ITEM_ID, &PAR_SERIAL_ID, &PAR_STORAGE_AREA, &PAR_STOR_LEVEL_1
, &PAR_STOR_LEVEL_2, &PAR_STOR_LEVEL_3, &PAR_STOR_LEVEL_4, &PAR_CONTAINER_ID, &P
AR_UNIT_OF_MEASURE, &PAR_QTY, &PAR_QTY_BASE)
SQLExec("select 'Y' from sysadm.ps_physical_inv where business_unit=:1 and s
taged_date= %datein(:2) and inv_lot_id=:3 and inv_item_id=:4 and serial_id=:5 an
d storage_area=:6 and stor_level_1=:7 and stor_level_2=:8 and stor_level_3=:9 an
d stor_level_4=:10 and container_id=:11 and unit_of_measure=:12", &PAR_BUSINESS_
UNIT, &PAR_STAGED_DATE, &PAR_INV_LOT_ID, &PAR_INV_ITEM_ID, &PAR_SERIAL_ID, &PAR_
STORAGE_AREA, &PAR_STOR_LEVEL_1, &PAR_STOR_LEVEL_2, &PAR_STOR_LEVEL_3, &PAR_STOR
_LEVEL_4, &PAR_CONTAINER_ID, &PAR_UNIT_OF_MEASURE, &EXISTE);
If &EXISTE = "Y" Then
&REC_PHYSICAL_INV = CreateRecord(Record.PHYSICAL_INV);
&REC_PHYSICAL_INV.BUSINESS_UNIT.VALUE = &PAR_BUSINESS_UNIT;
&REC_PHYSICAL_INV.STAGED_DATE.VALUE = &PAR_STAGED_DATE;
&REC_PHYSICAL_INV.INV_LOT_ID.VALUE = &PAR_INV_LOT_ID;
&REC_PHYSICAL_INV.INV_ITEM_ID.VALUE = &PAR_INV_ITEM_ID;
&REC_PHYSICAL_INV.SERIAL_ID.VALUE = &PAR_SERIAL_ID;
&REC_PHYSICAL_INV.STORAGE_AREA.VALUE = &PAR_STORAGE_AREA;
&REC_PHYSICAL_INV.STOR_LEVEL_1.VALUE = &PAR_STOR_LEVEL_1;
&REC_PHYSICAL_INV.STOR_LEVEL_2.VALUE = &PAR_STOR_LEVEL_2;
&REC_PHYSICAL_INV.STOR_LEVEL_3.VALUE = &PAR_STOR_LEVEL_3;
&REC_PHYSICAL_INV.STOR_LEVEL_4.VALUE = &PAR_STOR_LEVEL_4;
&REC_PHYSICAL_INV.CONTAINER_ID.VALUE = &PAR_CONTAINER_ID;
&REC_PHYSICAL_INV.UNIT_OF_MEASURE.VALUE = &PAR_UNIT_OF_MEASURE;
&REC_PHYSICAL_INV.SelectByKey();
&REC_PHYSICAL_INV.QTY.VALUE = &REC_PHYSICAL_INV.QTY.VALUE + &PAR_QTY;
&REC_PHYSICAL_INV.QTY_BASE.VALUE = &REC_PHYSICAL_INV.QTY_BASE.VALUE + &PAR
_QTY_BASE;
&REC_PHYSICAL_INV.DT_TIMESTAMP.VALUE = %Datetime;
&REC_PHYSICAL_INV.UPDATE();
Else
&PAR_LAST_TRANSACT_TYPE = "020";
&PAR_LAST_ISSUE_DATE = %Date;
&PAR_QTY_RESERVED = 0;
&PAR_QTY_RESERVED_BASE = 0;
&PAR_AVAIL_STATUS = "1";
&PAR_DT_TIMESTAMP = %Datetime;
GRAVA_PHYSICAL_INV(&PAR_BUSINESS_UNIT, &PAR_STAGED_DATE, &PAR_INV_LOT_ID,
&PAR_INV_ITEM_ID, &PAR_SERIAL_ID, &PAR_STORAGE_AREA, &PAR_STOR_LEVEL_1, &PAR_STO
R_LEVEL_2, &PAR_STOR_LEVEL_3, &PAR_STOR_LEVEL_4, &PAR_CONTAINER_ID, &PAR_UNIT_OF
_MEASURE, &PAR_LAST_TRANSACT_TYPE, &PAR_LAST_ISSUE_DATE, &PAR_QTY, &PAR_QTY_RESE
RVED, &PAR_QTY_BASE, &PAR_QTY_RESERVED_BASE, &PAR_AVAIL_STATUS, &PAR_DT_TIMESTAM
P)
End-If;
End-Function;
&PAR_QTY_RESERVED = 0;
&PAR_QTY_RESERVED_BASE = 0;
&PAR_AVAIL_STATUS = "1";
&PAR_DT_TIMESTAMP = %Datetime;
GRAVA_PHYSICAL_INV(&PAR_BUSINESS_UNIT, &PAR_STAGED_DATE, &PAR_INV_LOT_ID,
&PAR_INV_ITEM_ID, &PAR_SERIAL_ID, &PAR_STORAGE_AREA, &PAR_STOR_LEVEL_1, &PAR_STO
R_LEVEL_2, &PAR_STOR_LEVEL_3, &PAR_STOR_LEVEL_4, &PAR_CONTAINER_ID, &PAR_UNIT_OF
_MEASURE, &PAR_LAST_TRANSACT_TYPE, &PAR_LAST_ISSUE_DATE, &PAR_QTY, &PAR_QTY_RESE
RVED, &PAR_QTY_BASE, &PAR_QTY_RESERVED_BASE, &PAR_AVAIL_STATUS, &PAR_DT_TIMESTAM
P)
End-If;
End-Function;
/********************************************** mmcb.sds4289.en ****************
**********************************/
/*******************************************************************************
***
Faz atualizaes QTDs na tabela BU_ITEMS_INV nas Transaes '020' e '030'
********************************************************************************
***/
Function ATUALIZA_BU_ITEMS_INV(&PAR_BUSINESS_UNIT, &PAR_INV_ITEM_ID, &PAR_QTY, &
PAR_TRANSACTION_GROUP, &PAR_LAST_ORDER, &FLAG_AREA_ACEITA_RESERVA)
&REC_BU_ITEMS_INV = CreateRecord(Record.BU_ITEMS_INV);
&REC_BU_ITEMS_INV.BUSINESS_UNIT.VALUE = &PAR_BUSINESS_UNIT;
&REC_BU_ITEMS_INV.INV_ITEM_ID.VALUE = &PAR_INV_ITEM_ID;
&REC_BU_ITEMS_INV.SelectByKey();
/************************************ mmcb.at2603 - s.n */
Evaluate &PAR_TRANSACTION_GROUP
When = "020"
If &FLAG_AREA_ACEITA_RESERVA = "Y" Then
&REC_BU_ITEMS_INV.QTY_AVAILABLE.VALUE = &REC_BU_ITEMS_INV.QTY_AVAILABLE
.VALUE + &PAR_QTY;
End-If;
/* mmcb.SDS5026.so/
/*If (&FLAG_AREA_WIP = "Y") Then
&REC_BU_ITEMS_INV.QTY_RESERVED.VALUE = &REC_BU_ITEMS_INV.QTY_RESERVED.V
ALUE + &PAR_QTY;
End-If;*/
&reservado = quantidadeReservadaBU(&PAR_BUSINESS_UNIT, &PAR_INV_ITEM_ID);
/* mmcb.SDS5026.ln */
&REC_BU_ITEMS_INV.QTY_RESERVED.VALUE = &reservado; /* mmcb.SDS5026.ln */
&REC_BU_ITEMS_INV.QTY_OWNED.VALUE = &REC_BU_ITEMS_INV.QTY_OWNED.VALUE + &P
AR_QTY;
&REC_BU_ITEMS_INV.QTY_ONHAND.VALUE = &REC_BU_ITEMS_INV.QTY_ONHAND.VALUE +
&PAR_QTY;
Break;
When = "021"
&REC_BU_ITEMS_INV.QTY_AVAILABLE.VALUE = &REC_BU_ITEMS_INV.QTY_AVAILABLE.VA
LUE + &PAR_QTY;
&REC_BU_ITEMS_INV.QTY_OWNED.VALUE = &REC_BU_ITEMS_INV.QTY_OWNED.VALUE + &P
AR_QTY;
&REC_BU_ITEMS_INV.QTY_ONHAND.VALUE = &REC_BU_ITEMS_INV.QTY_ONHAND.VALUE +
&PAR_QTY;
&reservado = quantidadeReservadaBU(&PAR_BUSINESS_UNIT, &PAR_INV_ITEM_ID);
/* mmcb.SDS5026.ln */
&REC_BU_ITEMS_INV.QTY_RESERVED.VALUE = &reservado; /* mmcb.SDS5026.ln */
Break;
When = "030"
/* mmcb.SDS5026.sn */
If ((&REC_BU_ITEMS_INV.QTY_RESERVED.VALUE - &PAR_QTY) < 0) Then
&PAR_QTY_RESERVA = &REC_BU_ITEMS_INV.QTY_RESERVED.VALUE;
Else
&PAR_QTY_RESERVA = &PAR_QTY;
End-If;
/* mmcb.SDS5026.en */
&REC_BU_ITEMS_INV.QTY_OWNED.VALUE = &REC_BU_ITEMS_INV.QTY_OWNED.VALUE - &P
AR_QTY;
&REC_BU_ITEMS_INV.QTY_ONHAND.VALUE = &REC_BU_ITEMS_INV.QTY_ONHAND.VALUE &PAR_QTY;
/*&REC_BU_ITEMS_INV.QTY_RESERVED.VALUE = &REC_BU_ITEMS_INV.QTY_RESERVED.VA
LUE - &PAR_QTY;
mmcb.SDS5026.lo */
&REC_BU_ITEMS_INV.QTY_RESERVED.VALUE = &REC_BU_ITEMS_INV.QTY_RESERVED.VALU
E - &PAR_QTY_RESERVA; /* mmcb.SDS5026.ln */
&REC_BU_ITEMS_INV.DT_TIMESTAMP.VALUE = %Datetime;
&REC_BU_ITEMS_INV.LAST_ORDER.VALUE = &PAR_LAST_ORDER;
&REC_BU_ITEMS_INV.LAST_ORDER_DATE.VALUE = %Date;
Break;
/********************** mmcb.sds4289.sn ***********************/
When = "720"
If &FLAG_AREA_ACEITA_RESERVA = "Y" Then
&REC_BU_ITEMS_INV.QTY_AVAILABLE.VALUE = &REC_BU_ITEMS_INV.QTY_AVAILABLE
.VALUE + &PAR_QTY;
End-If;
&REC_BU_ITEMS_INV.QTY_OWNED.VALUE = &REC_BU_ITEMS_INV.QTY_OWNED.VALUE + &P
AR_QTY;
&REC_BU_ITEMS_INV.QTY_ONHAND.VALUE = &REC_BU_ITEMS_INV.QTY_ONHAND.VALUE +
&PAR_QTY;
&reservado = quantidadeReservadaBU(&PAR_BUSINESS_UNIT, &PAR_INV_ITEM_ID);
/* mmcb.SDS5026.ln */
&REC_BU_ITEMS_INV.QTY_RESERVED.VALUE = &reservado; /* mmcb.SDS5026.ln */
Break;
/********************** mmcb.sds4289.en ***********************/
End-Evaluate;
&R_BU_ITEMS_INV.ROPC_STATUS.VALUE = "1";
&R_BU_ITEMS_INV.SSTC_INSTANCE.VALUE = 0;
&R_BU_ITEMS_INV.SSTC_STATUS.VALUE = "1";
&R_BU_ITEMS_INV.EOQC_INSTANCE.VALUE = 0;
&R_BU_ITEMS_INV.EOQC_STATUS.VALUE = "1";
&R_BU_ITEMS_INV.HLDC_INSTANCE.VALUE = 0;
&R_BU_ITEMS_INV.HLDC_STATUS.VALUE = "1";
&R_BU_ITEMS_INV.ANNDM_INSTANCE.VALUE = 0;
&R_BU_ITEMS_INV.ANNDM_STATUS.VALUE = "1";
&R_BU_ITEMS_INV.CYCLE_INSTANCE.VALUE = 0;
&R_BU_ITEMS_INV.NO_REPLENISH_FLG.VALUE = "Y";
&R_BU_ITEMS_INV.INCL_WIP_QTY_FLG.VALUE = " ";
&R_BU_ITEMS_INV.SOURCE_CODE.VALUE = "2";
&R_BU_ITEMS_INV.PHANTOM_ITEM_FLAG.VALUE = "N";
&R_BU_ITEMS_INV.BOM_USAGE.VALUE = "1";
&R_BU_ITEMS_INV.DT_TIMESTAMP.VALUE = %Date;
&R_BU_ITEMS_INV.LAST_PRICE_PAID.VALUE = 0;
&R_BU_ITEMS_INV.AVERAGE_COST.VALUE = 2;
&R_BU_ITEMS_INV.CURRENT_COST.VALUE = 0;
&R_BU_ITEMS_INV.DFLT_ACTUAL_COST.VALUE = 0;
&R_BU_ITEMS_INV.EXCESS_INVENTORY.VALUE = "N";
&R_BU_ITEMS_INV.REVISION_CONTROL.VALUE = "N";
&R_BU_ITEMS_INV.ISSUE_METHOD.VALUE = "ISS";
&R_BU_ITEMS_INV.STAGED_DATE_FLAG.VALUE = "N";
&R_BU_ITEMS_INV.ISSUE_MULTIPLE.VALUE = 1;
&R_BU_ITEMS_INV.REPLENISH_POINT.VALUE = 0;
&R_BU_ITEMS_INV.WIP_MIN_QTY.VALUE = 0;
&R_BU_ITEMS_INV.PLANNER_CD.VALUE = " ";
&R_BU_ITEMS_INV.YIELD_CALC_FLG.VALUE = "N";
&R_BU_ITEMS_INV.PRDN_AREA_CODE.VALUE = " ";
&R_BU_ITEMS_INV.TRANSIT_COST_TYP.VALUE = "F";
&R_BU_ITEMS_INV.UOM_CONV_FLAG.VALUE = "0";
&R_BU_ITEMS_INV.MASTER_RTG_OPT.VALUE = "ITM";
&R_BU_ITEMS_INV.REF_ROUTING_ITEM.VALUE = &P_INV_ITEM_ID;
&R_BU_ITEMS_INV.STD_PACK_UOM.VALUE = "PC";
&R_BU_ITEMS_INV.FORECAST_ITEM_FLAG.VALUE = "N";
&R_BU_ITEMS_INV.COUNTRY_IST_ORIGINV.VALUE = " ";
&R_BU_ITEMS_INV.IST_REGION_ORIGIN.VALUE = " ";
SQLExec("select itm_status_effdt from sysadm.ps_master_item_tbl where setid='
MMCSA' and inv_item_id =:1 ", &P_INV_ITEM_ID, &V_ITM_STATUS_EFFDT);
If None(&V_ITM_STATUS_EFFDT) Then
Error ("O Item: " | &P_INV_ITEM_ID | " no est parametrizado. ");
End-If;
&R_BU_ITEMS_INV.ITM_STATUS_EFFDT.VALUE = &V_ITM_STATUS_EFFDT;
&R_BU_ITEMS_INV.ITM_STATUS_CURRENT.VALUE = "1";
&R_BU_ITEMS_INV.ITM_STATUS_FUTURE.VALUE = " ";
&R_BU_ITEMS_INV.DECLARED_VALUE.VALUE = 0;
&R_BU_ITEMS_INV.SF_WIP_MAX_QTY.VALUE = 0;
&R_BU_ITEMS_INV.SF_RPL_MODE.VALUE = "1";
&R_BU_ITEMS_INV.SF_RPL_SOURCE.VALUE = "1";
&R_BU_ITEMS_INV.SF_RPL_METHOD.VALUE = "3";
&R_BU_ITEMS_INV.SF_RPL_TYPE.VALUE = "1";
&R_BU_ITEMS_INV.SF_DISPATCH_MODE.VALUE = "1";
&R_BU_ITEMS_INV.SF_RPL_STOR_AREA.VALUE = " ";
&R_BU_ITEMS_INV.SF_RPL_STOR_LEV1.VALUE = " ";
&R_BU_ITEMS_INV.SF_RPL_STOR_LEV2.VALUE = " ";
&R_BU_ITEMS_INV.SF_RPL_STOR_LEV3.VALUE = " ";
&R_BU_ITEMS_INV.SF_RPL_STOR_LEV4.VALUE = " ";
&R_BU_ITEMS_INV.SF_RPL_VENDOR_ID.VALUE = " ";
&R_BU_ITEMS_INV.SF_RPL_VNDR_LOC.VALUE = " ";
&R_BU_ITEMS_INV.EXPORT_LIC_NBR.Insert();
End-Function;
/*******************************************************************************
********************
Insere uma nova linha Tabela TRANSACTION_INV para transaes '020' e '030'
********************************************************************************
*******************/
Function GRAVA_TRANSACTION(&PAR_BUSINESS_UNIT, &PAR_INV_ITEM_ID, &PAR_DT_TIMESTA
MP, &PAR_SEQ_NBR, &PAR_SOURCE_BUS_UNIT, &PAR_ORDER_NO, &PAR_ORDER_INT_LINE_NO, &
PAR_SCHED_LINE_NO, &PAR_DEMAND_LINE_NO, &PAR_STAGED_DATE, &PAR_INV_LOT_ID, &PAR_
SERIAL_ID, &PAR_STORAGE_AREA, &PAR_STOR_LEVEL_1, &PAR_STOR_LEVEL_2, &PAR_STOR_LE
VEL_3, &PAR_STOR_LEVEL_4, &PAR_RECEIVER_ID, &PAR_RECV_LN_NBR, &PAR_TRANSACTION_G
ROUP, &PAR_TRANSACTION_DATE, &PAR_QTY_BASE, &PAR_QTY, &PAR_UNIT_MEASURE_STD, &PA
R_UNIT_OF_MEASURE, &PAR_OPRID, &PAR_ACCOUNT, &PAR_DEPTID, &PAR_PO_ID, &PAR_DISTR
IB_LINE_NUM, &PAR_DISTRIB_SEQ_NUM, &PAR_RECV_SHIP_SEQ_NBR, &PAR_PRICE_PO, &PAR_A
NALYSIS_TYPE, &PAR_VENDOR_ID, &PAR_STAGED_TYPE, &PAR_DISTRIB_TYPE, &PAR_BUSINESS
_UNIT_PO, &PAR_TRANSACTION_SOURCE, &PAR_CONVERSION_RATE, &PAR_PROCESS_INSTANCE,
&PAR_PROCESS_FLAG, &PAR_SHIP_ID)
&REC_TRANSACTION = CreateRecord(Record.TRANSACTION_INV);
&REC_TRANSACTION.BUSINESS_UNIT.Value = &PAR_BUSINESS_UNIT;
&REC_TRANSACTION.INV_ITEM_ID.Value = &PAR_INV_ITEM_ID;
&REC_TRANSACTION.DT_TIMESTAMP.Value = &PAR_DT_TIMESTAMP;
&REC_TRANSACTION.SEQ_NBR.Value = &PAR_SEQ_NBR;
&REC_TRANSACTION.SOURCE_BUS_UNIT.Value = &PAR_SOURCE_BUS_UNIT;
&REC_TRANSACTION.ORDER_NO.Value = &PAR_ORDER_NO;
&REC_TRANSACTION.ORDER_INT_LINE_NO.Value = &PAR_ORDER_INT_LINE_NO;
&REC_TRANSACTION.SCHED_LINE_NO.Value = &PAR_SCHED_LINE_NO;
&REC_TRANSACTION.DEMAND_LINE_NO.Value = &PAR_DEMAND_LINE_NO;
&REC_TRANSACTION.STAGED_DATE.Value = &PAR_STAGED_DATE;
&REC_TRANSACTION.INV_LOT_ID.Value = &PAR_INV_LOT_ID;
&REC_TRANSACTION.SERIAL_ID.Value = &PAR_SERIAL_ID;
&REC_TRANSACTION.STORAGE_AREA.Value = &PAR_STORAGE_AREA;
&REC_TRANSACTION.STOR_LEVEL_1.Value = &PAR_STOR_LEVEL_1;
&REC_TRANSACTION.STOR_LEVEL_2.Value = &PAR_STOR_LEVEL_2;
&REC_TRANSACTION.STOR_LEVEL_3.Value = &PAR_STOR_LEVEL_3;
&REC_TRANSACTION.STOR_LEVEL_4.Value = &PAR_STOR_LEVEL_4;
&REC_TRANSACTION.CONTAINER_ID.Value = " ";
&REC_TRANSACTION.RECEIVER_ID.Value = &PAR_RECEIVER_ID;
&REC_TRANSACTION.RECV_LN_NBR.Value = &PAR_RECV_LN_NBR;
&REC_TRANSACTION.COUNTING_EVENT_ID.Value = 0;
&REC_TRANSACTION.TRANSACTION_GROUP.Value = &PAR_TRANSACTION_GROUP;
&REC_TRANSACTION.TRANSACTION_DATE.Value = &PAR_TRANSACTION_DATE;
&REC_TRANSACTION.QTY_BASE.Value = &PAR_QTY_BASE;
&REC_TRANSACTION.QTY.Value = &PAR_QTY;
&REC_TRANSACTION.UNIT_MEASURE_STD.Value = &PAR_UNIT_MEASURE_STD;
&REC_TRANSACTION.UNIT_OF_MEASURE.Value = &PAR_UNIT_OF_MEASURE;
&REC_TRANSACTION.TO_CONTAINER_ID.Value = " ";
&REC_TRANSACTION.TO_STORAGE_AREA.Value = " ";
&REC_TRANSACTION.TO_STOR_LEVEL_1.Value = " ";
&REC_TRANSACTION.TO_STOR_LEVEL_2.Value = " ";
&REC_TRANSACTION.TO_STOR_LEVEL_3.Value = " ";
&REC_TRANSACTION.TO_STOR_LEVEL_4.Value = " ";
&REC_TRANSACTION.TO_UOM.Value = " ";
&REC_TRANSACTION.ADJUST_TYPE.Value = " ";
&REC_TRANSACTION.REASON_CD.Value = " ";
&REC_TRANSACTION.DOCUMENT_ID.Value = " ";
&REC_TRANSACTION.SHIP_ID.Value = &PAR_SHIP_ID;
&REC_TRANSACTION.CONSIGNED_FLAG.Value = "N";
&REC_TRANSACTION.TO_CONSIGNED_FLG.Value = " ";
&REC_TRANSACTION.TO_NON_OWN_FLG.Value = " ";
&REC_TRANSACTION.EXPORT.Value = "N";
&REC_TRANSACTION.REPLACEMENT_FLG.Value = "NA";
&REC_TRANSACTION.IST_RETURN_FLG_IUT.Value = "N";
&REC_TRANSACTION.IST_TXN_FLG.Value = "N";
&REC_TRANSACTION.TRANSFER_COST_DEST.Value = 0;
&REC_TRANSACTION.SF_KANBAN_ID.Value = " ";
&REC_TRANSACTION.Insert();
End-Function;
/*******************************************************************************
********************
Fabiano Cunha - MMC - mmcb.at2603 Insere uma nova linha Tabela TRANSACTION_INV para transao '021'
********************************************************************************
*******************/
Function GRAVA_TRANSACTION_021(&PAR_BUSINESS_UNIT, &PAR_INV_ITEM_ID, &PAR_DT_TIM
ESTAMP, &PAR_SEQ_NBR, &PAR_INV_LOT_ID, &PAR_SERIAL_ID, &PAR_STORAGE_AREA, &PAR_S
TOR_LEVEL_1, &PAR_STOR_LEVEL_2, &PAR_STOR_LEVEL_3, &PAR_STOR_LEVEL_4, &PAR_TRANS
ACTION_DATE, &PAR_QTY_BASE, &PAR_QTY, &PAR_UNIT_MEASURE_STD, &PAR_UNIT_OF_MEASUR
E, &PAR_OPRID, &PAR_PRODUCTION_ID, &PAR_PRDN_AREA_CODE, &PAR_PROCESS_INSTANCE)
&REC_TRANSACTION = CreateRecord(Record.TRANSACTION_INV);
&REC_TRANSACTION.BUSINESS_UNIT.Value = &PAR_BUSINESS_UNIT;
&REC_TRANSACTION.INV_ITEM_ID.Value = &PAR_INV_ITEM_ID;
&REC_TRANSACTION.DT_TIMESTAMP.Value = &PAR_DT_TIMESTAMP;
&REC_TRANSACTION.SEQ_NBR.Value = &PAR_SEQ_NBR;
&REC_TRANSACTION.SOURCE_BUS_UNIT.Value = " ";
&REC_TRANSACTION.ORDER_NO.Value = " ";
&REC_TRANSACTION.ORDER_INT_LINE_NO.Value = 0;
&REC_TRANSACTION.SCHED_LINE_NO.Value = 0;
&REC_TRANSACTION.DEMAND_LINE_NO.Value = 0;
&REC_TRANSACTION.STAGED_DATE.Value = Date3(1900, 1, 1);
&REC_TRANSACTION.INV_LOT_ID.Value = &PAR_INV_LOT_ID;
&REC_TRANSACTION.SERIAL_ID.Value = &PAR_SERIAL_ID;
&REC_TRANSACTION.STORAGE_AREA.Value = &PAR_STORAGE_AREA;
&REC_TRANSACTION.STOR_LEVEL_1.Value = &PAR_STOR_LEVEL_1;
&REC_TRANSACTION.STOR_LEVEL_2.Value = &PAR_STOR_LEVEL_2;
&REC_TRANSACTION.STOR_LEVEL_3.Value = &PAR_STOR_LEVEL_3;
&REC_TRANSACTION.STOR_LEVEL_4.Value = &PAR_STOR_LEVEL_4;
&REC_TRANSACTION.CONTAINER_ID.Value = " ";
&REC_TRANSACTION.RECEIVER_ID.Value = "ALL";
&REC_TRANSACTION.RECV_LN_NBR.Value = "99999";
&REC_TRANSACTION.COUNTING_EVENT_ID.Value = 0;
&REC_TRANSACTION.TRANSACTION_GROUP.Value = "021";
&REC_TRANSACTION.TRANSACTION_DATE.Value = &PAR_TRANSACTION_DATE;
&REC_TRANSACTION.QTY_BASE.Value = &PAR_QTY_BASE;
&REC_TRANSACTION.QTY.Value = &PAR_QTY;
&REC_TRANSACTION.UNIT_MEASURE_STD.Value = &PAR_UNIT_MEASURE_STD;
&REC_TRANSACTION.UNIT_OF_MEASURE.Value = &PAR_UNIT_OF_MEASURE;
&REC_TRANSACTION.TO_CONTAINER_ID.Value = " ";
&REC_TRANSACTION.TO_STORAGE_AREA.Value = " ";
&REC_TRANSACTION.TO_STOR_LEVEL_1.Value = " ";
&REC_TRANSACTION.TO_STOR_LEVEL_2.Value = " ";
&REC_TRANSACTION.TO_STOR_LEVEL_3.Value = " ";
&PAR_LAST_ISSUE_DATE = %Date;
&PAR_QTY_RESERVED = 0;
&PAR_QTY_RESERVED_BASE = 0;
&PAR_AVAIL_STATUS = "1";
&PAR_DT_TIMESTAMP = %Datetime;
GRAVA_PHYSICAL_INV(&PAR_BUSINESS_UNIT, &PAR_STAGED_DATE, &PAR_INV_LOT_ID,
&PAR_INV_ITEM_ID, &PAR_SERIAL_ID, &PAR_STORAGE_AREA, &PAR_STOR_LEVEL_1, &PAR_STO
R_LEVEL_2, &PAR_STOR_LEVEL_3, &PAR_STOR_LEVEL_4, &PAR_CONTAINER_ID, &PAR_UNIT_OF
_MEASURE, &PAR_LAST_TRANSACT_TYPE, &PAR_LAST_ISSUE_DATE, &PAR_QTY, &PAR_QTY_RESE
RVED, &PAR_QTY_BASE, &PAR_QTY_RESERVED_BASE, &PAR_AVAIL_STATUS, &PAR_DT_TIMESTAM
P)
End-If;
End-Function;
/*******************************************************************************
*******************
Cria uma Entrada de Estoque (Transao 020)
********************************************************************************
*******************/
Function ENTRADA_ESTOQUE(&P_BUSINESS_UNIT, &P_STAGED_DATE, &P_INV_LOT_ID, &P_INV
_ITEM_ID, &P_SERIAL_ID, &P_STORAGE_AREA, &P_STOR_LEVEL_1, &P_STOR_LEVEL_2, &P_ST
OR_LEVEL_3, &P_STOR_LEVEL_4, &P_CONTAINER_ID, &P_UNIT_OF_MEASURE, &P_QTY, &P_DEP
TO, &P_DISTRIB_TYPE, &P_DT_TIMESTAMP, &P_BUSINESS_UNIT_RECV, &P_RECEIVER_ID, &P_
RECV_LN_NBR, &P_RECV_SHIP_SEQ_NBR, &P_SOURCE_BUS_UNIT, &P_ORDER_NO, &P_ORDER_INT
_LINE_NO, &P_CUSTO, &P_CONFIG_CODE, &P_PARAMETRO_OPCIONAL)
/************************************ mmcb.hd226465.sn **********************
**************/
/*Verifica se o item esta cadastrado na UN de estoque*/
SQLExec("SELECT 'Y' AS EXISTE_BU FROM SYSADM.PS_BU_ITEMS_INV WHERE BUSINESS_U
NIT = :1 AND INV_ITEM_ID = :2 AND ITM_STATUS_CURRENT = '1' AND ITM_STATUS_EFFDT
<= TRUNC(SYSDATE)", &P_BUSINESS_UNIT, &P_INV_ITEM_ID, &EXISTE_BU);
If None(&EXISTE_BU) Then
Error ("O item " | &P_INV_ITEM_ID | " no esta cadastrado na UN de estoque "
| &P_BUSINESS_UNIT | "! Favor verificar a tela Home > Manter Itens > Definir It
ens > Usar > Definio do Item da UN.");
End-If;
/************************************ mmcb.hd226465.en **********************
**************/
If None(&P_BUSINESS_UNIT_RECV) Or
&P_BUSINESS_UNIT_RECV = "" Or
&P_BUSINESS_UNIT_RECV = " " Then
Error ("Erro Funo: ENTRADA_ESTOQUE Parametro &P_BUSINESS_UNIT_RECV UN: " | &
P_BUSINESS_UNIT | " Item: " | &P_INV_ITEM_ID);
End-If;
If None(&P_RECEIVER_ID) Or
&P_RECEIVER_ID = "" Or
&P_RECEIVER_ID = " " Then
Error ("Erro Funo: ENTRADA_ESTOQUE Parametro &P_RECEIVER_ID UN: " | &P_BUSIN
ESS_UNIT | " Item: " | &P_INV_ITEM_ID);
End-If;
/* If None(&P_RECV_LN_NBR) Or
&P_RECV_LN_NBR <= 0 Then
Error ("Erro Funo: ENTRADA_ESTOQUE Parametro &P_RECV_LN_NBR UN: " | &P_BUSIN
ESS_UNIT | " Item: " | &P_INV_ITEM_ID);
End-If;
If None(&P_RECV_SHIP_SEQ_NBR) Or
&P_RECV_SHIP_SEQ_NBR <= 0 Then
Error ("Erro Funo: ENTRADA_ESTOQUE Parametro &P_RECV_SHIP_SEQ_NBR UN: " | &P
_BUSINESS_UNIT | " Item: " | &P_INV_ITEM_ID);
End-If;*/
If None(&P_DISTRIB_TYPE) Or
&P_DISTRIB_TYPE = "" Or
&P_DISTRIB_TYPE = " " Then
Error ("Erro Funo: ENTRADA_ESTOQUE Parametro &P_DISTRIB_TYPE UN: " | &P_BUSI
NESS_UNIT | " Item: " | &P_INV_ITEM_ID);
End-If;
If None(&P_PARAMETRO_OPCIONAL) Or
&P_PARAMETRO_OPCIONAL = "" Or
&P_PARAMETRO_OPCIONAL = " " Then
Error ("Erro Funo: ENTRADA_ESTOQUE Parametro &P_PARAMETRO_OPCIONAL: " | &P_P
ARAMETRO_OPCIONAL | " retornada em branco.");
End-If;
&PAR_BUSINESS_UNIT = &P_BUSINESS_UNIT;
&PAR_STAGED_DATE = &P_STAGED_DATE;
&PAR_INV_LOT_ID = &P_INV_LOT_ID;
&PAR_INV_ITEM_ID = &P_INV_ITEM_ID;
&PAR_SERIAL_ID = &P_SERIAL_ID;
&PAR_STORAGE_AREA = &P_STORAGE_AREA;
&PAR_STOR_LEVEL_1 = &P_STOR_LEVEL_1;
&PAR_STOR_LEVEL_2 = &P_STOR_LEVEL_2;
&PAR_STOR_LEVEL_3 = &P_STOR_LEVEL_3;
&PAR_STOR_LEVEL_4 = &P_STOR_LEVEL_4;
&PAR_CONTAINER_ID = &P_CONTAINER_ID;
&PAR_UNIT_OF_MEASURE = &P_UNIT_OF_MEASURE;
&PAR_QTY = &P_QTY;
&PAR_QTY_BASE = &P_QTY;
&PAR_DT_TIMESTAMP = &P_DT_TIMESTAMP;
&PAR_SEQ_NBR = max_seqnbr_transaction(&P_BUSINESS_UNIT, &PAR_INV_ITEM_ID, &PA
R_DT_TIMESTAMP);;
&PAR_SOURCE_BUS_UNIT = &P_SOURCE_BUS_UNIT;
&PAR_ORDER_NO = &P_ORDER_NO;
&PAR_ORDER_INT_LINE_NO = &P_ORDER_INT_LINE_NO;
&PAR_SCHED_LINE_NO = 0;
&PAR_DEMAND_LINE_NO = 0;
&PAR_RECEIVER_ID = &P_RECEIVER_ID;
&PAR_RECV_LN_NBR = &P_RECV_LN_NBR;
&PAR_TRANSACTION_GROUP = "020";
&PAR_TRANSACTION_DATE = %Date;
&PAR_QTY_BASE = &P_QTY;
&PAR_QTY = &P_QTY;
&PAR_UNIT_MEASURE_STD = &PAR_UNIT_OF_MEASURE;
&PAR_UNIT_OF_MEASURE = &PAR_UNIT_OF_MEASURE;
&PAR_OPRID = %UserId;
&PAR_DEPTID = &P_DEPTO;
&PAR_PO_ID = " ";
&PAR_DISTRIB_LINE_NUM = 0;
&PAR_DISTRIB_SEQ_NUM = 0;
&PAR_RECV_SHIP_SEQ_NBR = &P_RECV_SHIP_SEQ_NBR;
&PAR_PRICE_PO = 0;
&PAR_ANALYSIS_TYPE = "ACT";
&PAR_VENDOR_ID = " ";
&PAR_STAGED_TYPE = "1";
&PAR_DISTRIB_TYPE = &P_DISTRIB_TYPE;
&PAR_BUSINESS_UNIT_PO = " ";
&PAR_TRANSACTION_SOURCE = "IN";
&PAR_CONVERSION_RATE = 0;
&PAR_PROCESS_INSTANCE = 0;
&PAR_PROCESS_FLAG = "N";
&PAR_SHIP_ID = " ";
GRAVA_TRANSACTION(&PAR_BUSINESS_UNIT, &PAR_INV_ITEM_ID, &PAR_DT_TIMESTAMP, &P
AR_SEQ_NBR, &PAR_SOURCE_BUS_UNIT, &PAR_ORDER_NO, &PAR_ORDER_INT_LINE_NO, &PAR_SC
HED_LINE_NO, &PAR_DEMAND_LINE_NO, &PAR_STAGED_DATE, &PAR_INV_LOT_ID, &PAR_SERIAL
_ID, &PAR_STORAGE_AREA, &PAR_STOR_LEVEL_1, &PAR_STOR_LEVEL_2, &PAR_STOR_LEVEL_3,
&PAR_STOR_LEVEL_4, &PAR_RECEIVER_ID, &PAR_RECV_LN_NBR, &PAR_TRANSACTION_GROUP,
&PAR_TRANSACTION_DATE, &PAR_QTY_BASE, &PAR_QTY, &PAR_UNIT_MEASURE_STD, &PAR_UNIT
_OF_MEASURE, &PAR_OPRID, &PAR_ACCOUNT, &PAR_DEPTID, &PAR_PO_ID, &PAR_DISTRIB_LIN
E_NUM, &PAR_DISTRIB_SEQ_NUM, &PAR_RECV_SHIP_SEQ_NBR, &PAR_PRICE_PO, &PAR_ANALYSI
S_TYPE, &PAR_VENDOR_ID, &PAR_STAGED_TYPE, &PAR_DISTRIB_TYPE, &PAR_BUSINESS_UNIT_
PO, &PAR_TRANSACTION_SOURCE, &PAR_CONVERSION_RATE, &PAR_PROCESS_INSTANCE, &PAR_P
ROCESS_FLAG, &PAR_SHIP_ID);
SQLExec("select qty_available, cost_element, source_code from sysadm.ps_bu_it
ems_inv where business_unit=:1 and inv_item_id=:2", &P_BUSINESS_UNIT, &P_INV_ITE
M_ID, &BU_QTY_AVAILABLE, &BU_COST_ELEMENT, &BU_SOURCE_CODE);
If &BU_SOURCE_CODE = "2" Then
GERA_CUSTO_MEDIO_ITEM(&PAR_BUSINESS_UNIT, &PAR_INV_ITEM_ID, &PAR_QTY, &PAR
_DT_TIMESTAMP, &PAR_SEQ_NBR, &P_BUSINESS_UNIT_RECV, &PAR_RECEIVER_ID, &PAR_RECV_
LN_NBR, &PAR_RECV_SHIP_SEQ_NBR, &P_CUSTO, &P_CONFIG_CODE, &PAR_TRANSACTION_DATE,
&P_PARAMETRO_OPCIONAL);
End-If;
ATUALIZA_PHYSICAL_INV_020(&PAR_BUSINESS_UNIT, &PAR_STAGED_DATE, &PAR_INV_LOT_
ID, &PAR_INV_ITEM_ID, &PAR_SERIAL_ID, &PAR_STORAGE_AREA, &PAR_STOR_LEVEL_1, &PAR
_STOR_LEVEL_2, &PAR_STOR_LEVEL_3, &PAR_STOR_LEVEL_4, &PAR_CONTAINER_ID, &PAR_UNI
T_OF_MEASURE, &PAR_QTY, &PAR_QTY);
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
=
=
=
=
=
=
=
=
=
"";
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
|
|
|
|
|
|
|
|
*****************/
/*Verifica se o item esta cadastrado na UN de estoque*/
SQLExec("SELECT 'Y' AS EXISTE_BU FROM SYSADM.PS_BU_ITEMS_INV WHERE BUSINES
S_UNIT = :1 AND INV_ITEM_ID = :2 AND ITM_STATUS_CURRENT = '1' AND ITM_STATUS_EFF
DT <= TRUNC(SYSDATE)", &P_BUSINESS_UNIT, &V_INV_ITEM_ID, &EXISTE_BU);
If None(&EXISTE_BU) Then
Error ("O item " | &V_INV_ITEM_ID | " no esta cadastrado na UN de estoqu
e " | &P_BUSINESS_UNIT | "! Favor verificar a tela Home > Manter Itens > Definir
Itens > Usar > Definio do Item da UN.");
End-If;
/************************************ mmcb.hd226465.en *******************
*****************/
&PAR_BUSINESS_UNIT = &P_BUSINESS_UNIT;
&PAR_INV_ITEM_ID = &V_INV_ITEM_ID;
&PAR_DT_TIMESTAMP = %Datetime;
&PAR_SEQ_NBR = max_seqnbr_transaction(&P_BUSINESS_UNIT, &PAR_INV_ITEM_ID,
&PAR_DT_TIMESTAMP);
&PAR_SOURCE_BUS_UNIT = &V_SOURCE_BUS_UNIT;
&PAR_ORDER_NO = &v_order_no;
&PAR_ORDER_INT_LINE_NO = &v_order_int_line_no;
&PAR_SCHED_LINE_NO = &v_sched_line_no;
&PAR_DEMAND_LINE_NO = &v_demand_line_no;
&PAR_STAGED_DATE = Date3(1900, 1, 1);
&PAR_INV_LOT_ID = &V_INV_LOT_ID;
&PAR_SERIAL_ID = &V_SERIAL_ID;
&PAR_STORAGE_AREA = &V_STORAGE_AREA;
&PAR_STOR_LEVEL_1 = &V_STOR_LEVEL_1;
&PAR_STOR_LEVEL_2 = &V_STOR_LEVEL_2;
&PAR_STOR_LEVEL_3 = &V_STOR_LEVEL_3;
&PAR_STOR_LEVEL_4 = &V_STOR_LEVEL_4;
&PAR_RECEIVER_ID = " ";
&PAR_RECV_LN_NBR = 0;
&PAR_TRANSACTION_GROUP = "030";
&PAR_TRANSACTION_DATE = %Date;
&PAR_QTY_BASE = &v_qty_ship_base;
&PAR_QTY = &v_qty_ship_base;
&PAR_UNIT_MEASURE_STD = &v_unit_measure_ship;
&PAR_UNIT_OF_MEASURE = &v_unit_measure_ship;
&PAR_OPRID = %UserId;
&PAR_ACCOUNT = " ";
&PAR_DEPTID = &V_DEPTID;
&PAR_PO_ID = " ";
&PAR_DISTRIB_LINE_NUM = 0;
&PAR_DISTRIB_SEQ_NUM = 0;
&PAR_RECV_SHIP_SEQ_NBR = 0;
&PAR_PRICE_PO = 0;
&PAR_ANALYSIS_TYPE = "ACT";
&PAR_VENDOR_ID = " ";
&PAR_STAGED_TYPE = " ";
&PAR_DISTRIB_TYPE = &V_DISTRIB_TYPE;
&PAR_BUSINESS_UNIT_PO = " ";
&PAR_TRANSACTION_SOURCE = "IN";
&PAR_CONVERSION_RATE = 0;
&PAR_PROCESS_INSTANCE = 0;
&PAR_PROCESS_FLAG = "N";
&PAR_SHIP_ID = &P_SHIP_ID;
GRAVA_TRANSACTION(&PAR_BUSINESS_UNIT, &PAR_INV_ITEM_ID, &PAR_DT_TIMESTAMP,
&PAR_SEQ_NBR, &PAR_SOURCE_BUS_UNIT, &PAR_ORDER_NO, &PAR_ORDER_INT_LINE_NO, &PAR
&S_QTY_CONV_FLAG = "1";
&S_PUTAWAY_STATUS = "1";
&S_CONVERSION_RATE = &V_CONVERSION_RATE;
&S_TRANSFER_COST = &V_TRANSFER_COST;
&S_PROCESS_FLAG = "N";
&S_PROCESS_INSTANCE = 0;
&S_JOB_INSTANCE = 0;
&S_PUTAWAY_COMMENT = " ";
&S_FROM_STOR_AREA = " ";
&S_FROM_STOR_LEV1 = " ";
&S_FROM_STOR_LEV2 = " ";
&S_FROM_STOR_LEV3 = " ";
&S_FROM_STOR_LEV4 = " ";
&S_FROM_UOM = " ";
&S_STORAGE_AREA = &V_STORAGE_AREA;
&S_STOR_LEVEL_1 = &V_STOR_LEVEL_1;
&S_STOR_LEVEL_2 = &V_STOR_LEVEL_2;
&S_STOR_LEVEL_3 = &V_STOR_LEVEL_3;
&S_STOR_LEVEL_4 = &V_STOR_LEVEL_4;
&S_PUTAWAY_FLAG = "Y";
&S_RECEIPT_TYPE = &V_RECEIPT_TYPE;
&S_PO_ID = &V_PO_ID;
&S_INTERUNIT_ID = &V_INTERUNIT_ID;
&S_INTERUNIT_LINE = &V_INTERUNIT_LINE;
&S_SF_KANBAN_ID = &V_SF_KANBAN_ID;
&S_INSPECT_STATUS = &V_INSPECT_STATUS;
&S_INSPECTION_ID = &V_INSPECTION_ID;
&S_LAST_PURCH_DATE = &V_LAST_PURCH_DATE;
&S_NON_OWN_FLAG = &V_NON_OWN_FLAG;
&S_PURCH_LOT_ID = &V_PURCH_LOT_ID;
&S_VENDOR_ID = &V_VENDOR_ID;
&S_STORAGE_CODE = &V_STORAGE_CODE;
&S_OPRID = %UserId;
&S_STAGED_TYPE = "1";
&S_DISTRIB_TYPE = &V_DISTRIB_TYPE;
&S_PO_DT = &V_PO_DT;
&S_BUSINESS_UNIT_PO = &V_BUSINESS_UNIT_PO;
&S_TRANS_SOURCE = &V_TRANS_SOURCE;
&S_CONFIG_CODE = &V_CONFIG_CODE;
&S_CANCEL_NETTABLE = "N";
&S_DT_TIMESTAMP = %Datetime;
&S_CONTAINER_TYPE = &V_CONTAINER_TYPE;
&S_SPEEDTYPE_KEY = &V_SPEEDTYPE_KEY;
&S_ACCOUNT = &V_ACCOUNT;
&S_ALTACCT = &V_ALTACCT;
&S_OPERATING_UNIT = &V_OPERATING_UNIT;
&S_DEPTID = &V_DEPTID;
&S_PRODUCT = &V_PRODUCT;
&S_PROJECT_ID = &V_PROJECT_ID;
&S_ACTIVITY_ID = &V_ACTIVITY_ID;
&S_RESOURCE_TYPE = &V_RESOURCE_TYPE;
&S_RESOURCE_CATEGORY = &V_RESOURCE_CATEGORY;
&S_RESOURCE_SUB_CAT = &V_RESOURCE_SUB_CAT;
&S_ANALYSIS_TYPE = &V_ANALYSIS_TYPE;
&S_BUSINESS_UNIT_PC = &V_BUSINESS_UNIT_PC;
&S_COMBO_VALID_FLG = &V_COMBO_VALID_FLG;
&S_CONSIGNED_FLAG = &V_CONSIGNED_FLAG;
GRAVA_STAGED_ITEM_INV(&S_BUSINESS_UNIT, &S_STAGING_ID, &S_INV_LOT_ID, &S_C
ONTAINER_ID, &S_INV_ITEM_ID, &S_SERIAL_ID, &S_RECEIVER_ID, &S_RECV_LN_NBR, &S_ST
* Armazenagem
*
********************************************************************************
*****/
Function ARMAZENAGEM(&PAR_BUSINESS_UNIT, &PAR_STAGING_ID)
SQLExec("select distinct staging_id from sysadm.ps_staged_item_inv where busi
ness_unit=:1 and staging_id=:2 and putaway_status = '1' and
putaway_flag = 'Y
' and process_flag = 'N'", &PAR_BUSINESS_UNIT, &PAR_STAGING_ID, &EXISTE_STAGINGI
D);
If None(&EXISTE_STAGINGID) Then
Error ("O ID de Armazenagem Temporaria: " | &PAR_STAGING_ID | " no est na li
sta de Processos.");
End-If;
&SQL1 = "select a.business_unit, a.staged_date, a.inv_lot_id, a.inv_item_id,
a.serial_id, a.storage_area, a.stor_level_1, a.stor_level_2, a.stor_level_3, a.s
tor_level_4, a.container_id, a.unit_of_measure, a.qty, a.deptid, a.distrib_type,
a.dt_timestamp, a.receiver_id, a.recv_ln_nbr, a.recv_ship_seq_nbr, a.source_bus
_unit, a.config_code, b.actual_cost from sysadm.ps_staged_item_inv a, sysadm.ps_
staged_cost_inv b where a.business_unit=:1 and a.staging_id=:2 and a.putaway_sta
tus = '1' and a.putaway_flag = 'Y' and a.process_flag = 'N' and a.business_unit
= b.business_unit and a.staging_id = b.staging_id and a.inv_lot_id = b.inv_lot_
id and ";
&SQL2 = " a.container_id = b.container_id and a.inv_item_id = b.inv_item_id a
nd a.serial_id = b.serial_id and a.receiver_id = b.receiver_id and a.recv_ln_nbr
= b.recv_ln_nbr and a.staged_num = b.staged_num and a.source_bus_unit = b.sourc
e_bus_unit and a.recv_ship_seq_nbr = b.recv_ship_seq_nbr and a.distrib_line_num
= b.distrib_line_num and a.distrib_seq_num = b.distrib_seq_num order by a.recei
ver_id, a.recv_ln_nbr";
&SQLCMD = &SQL1 | &SQL2;
&SQL = CreateSQL(&SQLCMD, &PAR_BUSINESS_UNIT, &PAR_STAGING_ID);
While &SQL.Fetch(&V_BUSINESS_UNIT, &V_STAGED_DATE, &V_INV_LOT_ID, &V_INV_ITEM
_ID, &V_SERIAL_ID, &V_STORAGE_AREA, &V_STOR_LEVEL_1, &V_STOR_LEVEL_2, &V_STOR_LE
VEL_3, &V_STOR_LEVEL_4, &V_CONTAINER_ID, &V_UNIT_OF_MEASURE, &V_QTY, &V_DEPTID,
&V_DISTRIB_TYPE, &V_DT_TIMESTAMP, &V_RECEIVER_ID, &V_RECV_LN_NBR, &V_RECV_SHIP_S
EQ_NBR, &V_SOURCE_BUS_UNIT, &V_CONFIG_CODE, &ACTUAL_COST)
&P_BUSINESS_UNIT = &V_BUSINESS_UNIT;
&P_STAGED_DATE = Date3(1900, 1, 1);
&P_INV_LOT_ID = &V_INV_LOT_ID;
&P_INV_ITEM_ID = &V_INV_ITEM_ID;
&P_SERIAL_ID = &V_SERIAL_ID;
&P_STORAGE_AREA = &V_STORAGE_AREA;
&P_STOR_LEVEL_1 = &V_STOR_LEVEL_1;
&P_STOR_LEVEL_2 = &V_STOR_LEVEL_2;
&P_STOR_LEVEL_3 = &V_STOR_LEVEL_3;
&P_STOR_LEVEL_4 = &V_STOR_LEVEL_4;
&P_CONTAINER_ID = &V_CONTAINER_ID;
&P_UNIT_OF_MEASURE = &V_UNIT_OF_MEASURE;
&P_QTY = &V_QTY;
&P_DEPTO = &V_DEPTID;
&P_DISTRIB_TYPE = &V_DISTRIB_TYPE;
&P_DT_TIMESTAMP = %Datetime;
&P_BUSINESS_UNIT_RECV = &V_SOURCE_BUS_UNIT;
&P_RECEIVER_ID = &V_RECEIVER_ID;
&P_RECV_LN_NBR = &V_RECV_LN_NBR;
&P_RECV_SHIP_SEQ_NBR = &V_RECV_SHIP_SEQ_NBR;
SQLExec("select business_unit, nf_brl_id, nf_brl_line_num from sysadm.ps_n
f_ln_brl where business_unit_recv =:1 and receiver_id =:2 and recv_ln_nbr=:3 and
recv_ship_seq_nbr=:4", &P_BUSINESS_UNIT_RECV, &P_RECEIVER_ID, &P_RECV_LN_NBR, &
P_RECV_SHIP_SEQ_NBR, &P_SOURCE_BUS_UNIT, &P_ORDER_NO, &P_ORDER_INT_LINE_NO);
&P_CONFIG_CODE = &V_CONFIG_CODE;
&P_CUSTO = &ACTUAL_COST;
ENTRADA_ESTOQUE(&P_BUSINESS_UNIT, &P_STAGED_DATE, &P_INV_LOT_ID, &P_INV_IT
EM_ID, &P_SERIAL_ID, &P_STORAGE_AREA, &P_STOR_LEVEL_1, &P_STOR_LEVEL_2, &P_STOR_
LEVEL_3, &P_STOR_LEVEL_4, &P_CONTAINER_ID, &P_UNIT_OF_MEASURE, &P_QTY, &P_DEPTO,
&P_DISTRIB_TYPE, &P_DT_TIMESTAMP, &P_BUSINESS_UNIT_RECV, &P_RECEIVER_ID, &P_REC
V_LN_NBR, &P_RECV_SHIP_SEQ_NBR, &P_SOURCE_BUS_UNIT, &P_ORDER_NO, &P_ORDER_INT_LI
NE_NO, &P_CUSTO, &P_CONFIG_CODE, &P_PARAMETRO_OPCIONAL);
End-While;
SQLExec("update sysadm.ps_staged_item_inv set process_flag = 'Y' where busine
ss_unit = :1 and staging_id = :2 and putaway_status = '1' and putaway_flag = 'Y'
and process_flag = 'N'", &PAR_BUSINESS_UNIT, &PAR_STAGING_ID);
End-Function;
Function BAIXA_ESTOQUE(&B_BUSINESS_UNIT, &B_INV_ITEM_ID, &B_INV_LOT_ID, &B_QTD,
&B_UNIT_OF_MEASURE, &B_SERIAL_ID, &B_DT_TIMESTAMP, &B_ORDER_NO, &B_ORDER_INT_LIN
E_NO, &B_TRANSACTION_DATE, &B_STORAGE_AREA, &B_STOR_LEVEL_1, &B_STOR_LEVEL_2, &B
_STOR_LEVEL_3, &B_STOR_LEVEL_4, &B_DEPTID, &B_DISTRIB_TYPE, &B_SHIP_ID, &B_SOURC
E_BUS_UNIT)
If None(&B_ORDER_NO) Or
&B_ORDER_NO = "" Or
&B_ORDER_NO = " " Then
Error ("Erro Funo: BAIXA_ESTOQUE parametro: &B_ORDER_NO est em branco UN: " |
&B_BUSINESS_UNIT | " Item: " | &B_INV_ITEM_ID);
End-If;
If None(&B_ORDER_INT_LINE_NO) Or
&B_ORDER_INT_LINE_NO <= 0 Then
Error ("Erro Funo: BAIXA_ESTOQUE parametro: &B_ORDER_INT_LINE_NO est em branc
o UN: " | &B_BUSINESS_UNIT | " Item: " | &B_INV_ITEM_ID);
End-If;
/************************************ mmcb.hd226465.sn **********************
**************/
/*Verifica se o item esta cadastrado na UN de estoque*/
SQLExec("SELECT 'Y' AS EXISTE_BU FROM SYSADM.PS_BU_ITEMS_INV WHERE BUSINESS_U
NIT = :1 AND INV_ITEM_ID = :2 AND ITM_STATUS_CURRENT = '1' AND ITM_STATUS_EFFDT
<= TRUNC(SYSDATE)", &B_BUSINESS_UNIT, &B_INV_ITEM_ID, &EXISTE_BU);
If None(&EXISTE_BU) Then
Error ("O item " | &B_INV_ITEM_ID | " no esta cadastrado na UN de estoque "
| &B_BUSINESS_UNIT | "! Favor verificar a tela Home > Manter Itens > Definir It
ens > Usar > Definio do Item da UN.");
End-If;
/************************************ mmcb.hd226465.en **********************
**************/
SQLExec("select qty - QTY_RESERVED FROM sysadm.ps_physical_inv where business
_unit = :1 and inv_item_id = :2 and inv_lot_id = :3 and serial_id = :4 and stora
ge_area = :5 and stor_level_1 = :6 and stor_level_2 = :7 and stor_level_3= :8 an
d stor_level_4 = :9", &B_BUSINESS_UNIT, &B_INV_ITEM_ID, &B_INV_LOT_ID, &B_SERIA
L_ID, &B_STORAGE_AREA, &B_STOR_LEVEL_1, &B_STOR_LEVEL_2, &B_STOR_LEVEL_3, &B_STO
R_LEVEL_4, &V_QTD_DISPONIVEL);
If &V_QTD_DISPONIVEL < &B_QTD Then
Error ("No existe Saldo em Estoque suficiente para Item: " | &B_INV_ITEM_ID
| " Endereo: " | &B_STORAGE_AREA | " - " | &B_STOR_LEVEL_1 | " - " | &B_STOR_LEV
EL_2 | " - " | &B_STOR_LEVEL_3);
End-If;
SQLExec("update sysadm.ps_physical_inv set last_transact_type = '030', last_i
ssue_date = to_date(sysdate), qty = qty - :1, qty_base = qty_base - :2, dt_times
tamp = to_date(sysdate) where business_unit = :3 and inv_item_id = :4 and inv_lo
t_id = :5 and serial_id = :6 and storage_area = :7 and stor_level_1 = :8 and sto
r_level_2 = :9 and stor_level_3 = :10 and stor_level_4 = :11", &B_QTD, &B_QTD, &
B_BUSINESS_UNIT, &B_INV_ITEM_ID, &B_INV_LOT_ID, &B_SERIAL_ID, &B_STORAGE_AREA, &
B_STOR_LEVEL_1, &B_STOR_LEVEL_2, &B_STOR_LEVEL_3, &B_STOR_LEVEL_4);
&PAR_BUSINESS_UNIT = &B_BUSINESS_UNIT;
&PAR_INV_ITEM_ID = &B_INV_ITEM_ID;
&PAR_DT_TIMESTAMP = &B_DT_TIMESTAMP;
&PAR_SEQ_NBR = max_seqnbr_transaction(&B_BUSINESS_UNIT, &B_INV_ITEM_ID, &B_DT
_TIMESTAMP);
&PAR_SOURCE_BUS_UNIT = &B_SOURCE_BUS_UNIT;
&PAR_ORDER_NO = &B_ORDER_NO;
&PAR_ORDER_INT_LINE_NO = &B_ORDER_INT_LINE_NO;
&PAR_SCHED_LINE_NO = &B_ORDER_INT_LINE_NO;
&PAR_DEMAND_LINE_NO = &B_ORDER_INT_LINE_NO;
&PAR_STAGED_DATE = Date3(1900, 1, 1);
&PAR_INV_LOT_ID = &B_INV_LOT_ID;
&PAR_SERIAL_ID = &B_SERIAL_ID;
&PAR_STORAGE_AREA = &B_STORAGE_AREA;
&PAR_STOR_LEVEL_1 = &B_STOR_LEVEL_1;
&PAR_STOR_LEVEL_2 = &B_STOR_LEVEL_2;
&PAR_STOR_LEVEL_3 = &B_STOR_LEVEL_3;
&PAR_STOR_LEVEL_4 = &B_STOR_LEVEL_4;
&PAR_RECEIVER_ID = " ";
&PAR_RECV_LN_NBR = 0;
&PAR_TRANSACTION_GROUP = "030";
&PAR_TRANSACTION_DATE = &B_TRANSACTION_DATE;
&PAR_QTY_BASE = &B_QTD;
&PAR_QTY = &B_QTD;
&PAR_UNIT_MEASURE_STD = &B_UNIT_OF_MEASURE;
&PAR_UNIT_OF_MEASURE = &B_UNIT_OF_MEASURE;
&PAR_OPRID = %UserId;
&PAR_ACCOUNT = " ";
&PAR_DEPTID = &B_DEPTID;
[MMC_IN_LIB.TO_STORAGE_AREA.SavePostChange]
/*******************************************************************************
*****
* Wagner Sorio - MMC - 21/07/2010 - mmcb.sds3346 - Cancela Reserva Automatica
*
* Funo para Fazer Transferencia entre Area Estoque
*
********************************************************************************
*****/
/******************************** mmcb.sds3346.SN ******************************
****/
Function TRANSFE_ENTRE_AREAS_ESTOQUE(&P_SETID, &P_BUSINESS_UNIT, &P_INV_ITEM_ID,
&P_QTY_SOLICITADA, &P_FROM_STORAGE_AREA, &P_FROM_STOR_LEVEL_1, &P_FROM_STOR_LEV
EL_2, &P_FROM_STOR_LEVEL_3, &P_FROM_STOR_LEVEL_4, &P_TO_STORAGE_AREA, &P_TO_STOR
_LEVEL_1, &P_TO_STOR_LEVEL_2, &P_TO_STOR_LEVEL_3, &P_TO_STOR_LEVEL_4, &OUT_STATU
S_TRANSFERENCIA, &OUT_MMC_TRAN_BU, &OUT_MMC_TRAN_ITEM, &OUT_MMC_TRAN_TIMESTAMP,
&OUT_MMC_TRAN_SEQ_NBR)
&OUT_STATUS_TRANSFERENCIA = "ERRO";
If None(&P_BUSINESS_UNIT) Then
Error ("Erro na funo: TRANSFE_ENTRE_AREAS_ESTOQUE o parametro: &P_BUSINESS_U
NIT est em branco.");
End-If;
If None(&P_INV_ITEM_ID) Then
Error ("Erro na funo: TRANSFE_ENTRE_AREAS_ESTOQUE o parametro: &P_INV_ITEM_I
D est em branco.");
End-If;
If None(&P_QTY_SOLICITADA) Then
Error ("Erro na funo: TRANSFE_ENTRE_AREAS_ESTOQUE o parametro: &P_QTY_SOLICI
TADA est em branco.");
End-If;
If None(&P_FROM_STORAGE_AREA) Then
Error ("Erro na funo: TRANSFE_ENTRE_AREAS_ESTOQUE o parametro: &P_FROM_STORA
GE_AREA est em branco.");
End-If;
If None(&P_FROM_STOR_LEVEL_1) Then
Error ("Erro na funo: TRANSFE_ENTRE_AREAS_ESTOQUE o parametro: &P_FROM_STOR_
LEVEL_1 est em branco.");
End-If;
If None(&P_FROM_STOR_LEVEL_2) Then
Error ("Erro na funo: TRANSFE_ENTRE_AREAS_ESTOQUE o parametro: &P_FROM_STOR_
LEVEL_2 est em branco.");
End-If;
If None(&P_FROM_STOR_LEVEL_3) Then
Error ("Erro na funo: TRANSFE_ENTRE_AREAS_ESTOQUE o parametro: &P_FROM_STOR_
LEVEL_3 est em branco.");
End-If;
If None(&P_FROM_STOR_LEVEL_4) Then
Error ("Erro na funo: TRANSFE_ENTRE_AREAS_ESTOQUE o parametro: &P_FROM_STOR_
LEVEL_4 est em branco.");
End-If;
If None(&P_TO_STORAGE_AREA) Then
Error ("Erro na funo: TRANSFE_ENTRE_AREAS_ESTOQUE o parametro: &P_TO_STORAGE
_AREA est em branco.");
End-If;
If None(&P_TO_STOR_LEVEL_1) Then
Error ("Erro na funo: TRANSFE_ENTRE_AREAS_ESTOQUE o parametro: &P_TO_STOR_LE
VEL_1 est em branco.");
End-If;
If None(&P_TO_STOR_LEVEL_2) Then
Error ("Erro na funo: TRANSFE_ENTRE_AREAS_ESTOQUE o parametro: &P_TO_STOR_LE
VEL_2 est em branco.");
End-If;
If None(&P_TO_STOR_LEVEL_3) Then
Error ("Erro na funo: TRANSFE_ENTRE_AREAS_ESTOQUE o parametro: &P_TO_STOR_LE
VEL_3 est em branco.");
End-If;
If None(&P_TO_STOR_LEVEL_4) Then
Error ("Erro na funo: TRANSFE_ENTRE_AREAS_ESTOQUE o parametro: &P_TO_STOR_LE
VEL_4 est em branco.");
End-If;
If &P_QTY_SOLICITADA <= 0 Then
Error ("Erro QTD do endereo de Origem: " | &P_BUSINESS_UNIT | " - " | &P_IN
V_ITEM_ID | " - " | &P_FROM_STORAGE_AREA | " - " | &P_FROM_STOR_LEVEL_1 | " - "
| &P_FROM_STOR_LEVEL_2 | " - " | &P_FROM_STOR_LEVEL_3 | " - " | &P_FROM_STOR_LEV
EL_4 | " no pode ser nenor ou igual a zero.");
End-If;
If &P_FROM_STORAGE_AREA = &P_TO_STORAGE_AREA And
&P_FROM_STOR_LEVEL_1 = &P_TO_STOR_LEVEL_1 And
&P_FROM_STOR_LEVEL_2 = &P_TO_STOR_LEVEL_2 And
&P_FROM_STOR_LEVEL_3 = &P_TO_STOR_LEVEL_3 And
&P_FROM_STOR_LEVEL_4 = &P_TO_STOR_LEVEL_4 Then
Error ("Erro durante Transferencia do Item: " | &P_BUSINESS_UNIT | " - " |
&P_INV_ITEM_ID | " endereo de origem e destino so iguais.");
End-If;
&ITEM_EXISTE_FLAG = "N";
&SQL
&SQL
&SQL
&SQL
&SQL
=
=
=
=
=
"";
&SQL
&SQL
&SQL
&SQL
|
|
|
|
";
";
";
";
=
=
=
=
=
=
=
:1
:2
:3
:4
:5
:6
:7
";
";
";
";
";
";
";
";
";
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
"";
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
" SELECT
";
"
PI.INV_LOT_ID
"
, PI.SERIAL_ID
"
, PI.UNIT_OF_MEASURE
"
, PI.QTY
"
, PI.QTY_RESERVED
"
, SLI.NETTABLE_FLG
"
, SLI.WIP_LOC_FLG
" FROM SYSADM.PS_PHYSICAL_INV PI,
"
SYSADM.PS_STOR_LOC_INV SLI
" WHERE PI.BUSINESS_UNIT
=
"
AND PI.INV_ITEM_ID
=
"
AND PI.STORAGE_AREA
=
"
AND PI.STOR_LEVEL_1
=
"
AND PI.STOR_LEVEL_2
=
"
AND PI.STOR_LEVEL_3
=
"
AND PI.STOR_LEVEL_4
=
"
AND PI.BUSINESS_UNIT
=
"
AND PI.STORAGE_AREA
=
"
AND PI.STOR_LEVEL_1
=
"
AND PI.STOR_LEVEL_2
=
"
AND PI.STOR_LEVEL_3
=
"
AND PI.STOR_LEVEL_4
=
"
AND PI.QTY - PI.QTY_RESERVED
>
";
";
";
";
";
";
";
:1
:2
:3
:4
:5
:6
:7
SLI.BUSINESS_UNIT
SLI.STORAGE_AREA
SLI.STOR_LEVEL_1
SLI.STOR_LEVEL_2
SLI.STOR_LEVEL_3
SLI.STOR_LEVEL_4
0
";
";
";
";
";
";
";
";
";
";
";
";
";
";
";
";
=
=
=
=
=
=
=
=
"";
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
|
|
|
|
|
|
|
";
";
";
";
";
";
";
REM ! o saldo REAL do estoque, mesmo esta pea estando em reas que no aceitam res
erva.
;
REM *************************************************************************
********************;
&QTY_DISPONIVEL = 0;
If &BU_QTY_OWNED > &BU_QTY_RESERVED Then
&QTY_DISPONIVEL = &BU_QTY_OWNED - &BU_QTY_RESERVED;
End-If;
REM *************************************************************************
********************;
REM ! Aqui temos um caso onde temos item em rea que no aceita reserva, pois a q
uantidade
;
REM ! disponivel na BU_ITEMS_INV est menor que a quantidade disponvel REAL.
;
REM *************************************************************************
********************;
If &BU_QTY_AVAILABLE < &QTY_DISPONIVEL Then
&BU_QTY_AVAILABLE = &QTY_DISPONIVEL;
End-If;
REM *************************************************************************
********************;
REM ! Se a quantidade da BU for menor ou igual a zero, devemos abandonar
;
REM ! o loop mesmo se existirem quantidades na PHYSICAL, pois estas quantidad
es
;
REM ! j esto alocadas.
;
REM *************************************************************************
********************;
If &BU_QTY_AVAILABLE <= 0 Then
Error ("Erro: No existe saldo na Unidade Negocio: " | &P_BUSINESS_UNIT | "
disponivel para transferir o Item: " | &P_INV_ITEM_ID | ".");
End-If;
If &P_QTY_SOLICITADA > &BU_QTY_AVAILABLE Then
Error ("Erro: No existe saldo na Unidade Negocio: " | &P_BUSINESS_UNIT | "
disponivel para transferir o Item: " | &P_INV_ITEM_ID | ".");
End-If;
&EXISTE_AREAPHYSICAL_DESTINO = "N";
&SQL = "";
&SQL = &SQL | " SELECT DISTINCT 'Y'
&SQL = &SQL | "
FROM SYSADM.PS_PHYSICAL_INV PI_E
&SQL = &SQL | " WHERE PI_E.BUSINESS_UNIT
= :1
&SQL = &SQL | "
AND PI_E.INV_ITEM_ID
= :2
";
";
";
";
&SQL
&SQL
&SQL
&SQL
&SQL
=
=
=
=
=
&SQL
&SQL
&SQL
&SQL
&SQL
|
|
|
|
|
"
"
"
"
"
AND
AND
AND
AND
AND
PI_E.STORAGE_AREA
PI_E.STOR_LEVEL_1
PI_E.STOR_LEVEL_2
PI_E.STOR_LEVEL_3
PI_E.STOR_LEVEL_4
=
=
=
=
=
:3
:4
:5
:6
:7
";
";
";
";
";
= "N";
'Y'
, SLI_E.SUSPEND_FLG
, SLI_E.PHYS_CYC_INV_FLG
, SLI_E.NETTABLE_FLG
, SLI_E.WIP_LOC_FLG
, SLI_E.INSPECT_FLG
, SLI_E.DELETE_STORLOC_FLG
SYSADM.PS_STOR_LOC_INV SLI_E
SLI_E.BUSINESS_UNIT
SLI_E.STORAGE_AREA
SLI_E.STOR_LEVEL_1
SLI_E.STOR_LEVEL_2
SLI_E.STOR_LEVEL_3
SLI_E.STOR_LEVEL_4
=
=
=
=
=
=
:1
:2
:3
:4
:5
:6
";
";
";
";
";
";
";
";
";
";
";
";
";
";
=
=
=
=
=
=
=
=
=
=
=
"";
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
|
|
|
|
|
|
|
|
|
|
=
=
=
=
=
=
=
=
=
QTY
QTY_BASE -
:1
:2
:3
:4
:5
:6
:7
:8
:9
";
";
";
";
";
";
";
";
";
";
SET QTY
QTY
+ :1
QTY_BASE
+ :2
";
&SQL = &SQL | "
, QTY_BASE
";
&SQL = &SQL | "
WHERE BUSINESS_UNIT
:3
AND INV_ITEM_ID
:4
AND STORAGE_AREA
:5
AND STOR_LEVEL_1
:6
AND STOR_LEVEL_2
:7
AND STOR_LEVEL_3
:8
AND STOR_LEVEL_4
:9
";
";
";
";
";
";
";
&sqlStmt = CreateSQL(&SQL, &P_QTY_SOLICITADA, &P_QTY_SOLICITADA, &P_BUSINE
SS_UNIT, &P_INV_ITEM_ID, &P_TO_STORAGE_AREA, &P_TO_STOR_LEVEL_1, &P_TO_STOR_LEVE
L_2, &P_TO_STOR_LEVEL_3, &P_TO_STOR_LEVEL_4);
&sqlStmt.Close();
Else
&REC_PHYSICAL_INV = CreateRecord(Record.PHYSICAL_INV);
&REC_PHYSICAL_INV.BUSINESS_UNIT.VALUE = &P_BUSINESS_UNIT;
&REC_PHYSICAL_INV.STAGED_DATE.VALUE = Date3(1900, 1, 1);
&REC_PHYSICAL_INV.INV_LOT_ID.VALUE = "NONE";
&REC_PHYSICAL_INV.INV_ITEM_ID.VALUE = &P_INV_ITEM_ID;
&REC_PHYSICAL_INV.SERIAL_ID.VALUE = "NONE";
&REC_PHYSICAL_INV.STORAGE_AREA.VALUE = &P_TO_STORAGE_AREA;
&REC_PHYSICAL_INV.STOR_LEVEL_1.VALUE = &P_TO_STOR_LEVEL_1;
&REC_PHYSICAL_INV.STOR_LEVEL_2.VALUE = &P_TO_STOR_LEVEL_2;
&REC_PHYSICAL_INV.STOR_LEVEL_3.VALUE = &P_TO_STOR_LEVEL_3;
&REC_PHYSICAL_INV.STOR_LEVEL_4.VALUE = &P_TO_STOR_LEVEL_4;
&REC_PHYSICAL_INV.CONTAINER_ID.VALUE = " ";
&REC_PHYSICAL_INV.UNIT_OF_MEASURE.VALUE = &E_ORIG_UNIT_OF_MEASURE;
&REC_PHYSICAL_INV.LAST_TRANSACT_TYPE.VALUE = "060";
&REC_PHYSICAL_INV.QTY.VALUE = &P_QTY_SOLICITADA;
&REC_PHYSICAL_INV.QTY_RESERVED.VALUE = 0;
&REC_PHYSICAL_INV.QTY_BASE.VALUE = &P_QTY_SOLICITADA;
&REC_PHYSICAL_INV.QTY_RESERVED_BASE.VALUE = 0;
&REC_PHYSICAL_INV.AVAIL_STATUS.VALUE = "1";
&REC_PHYSICAL_INV.AVAIL_STATUS_TYPE.VALUE = " ";
&REC_PHYSICAL_INV.REASON_CD.VALUE = " ";
&REC_PHYSICAL_INV.DT_TIMESTAMP.VALUE = %Datetime;
&REC_PHYSICAL_INV.DESCR254.VALUE = " ";
&sqlStmt = CreateSQL("%INSERT(:1)");
&sqlStmt.Execute(&REC_PHYSICAL_INV);
&sqlStmt.Close();
End-If;
&QTY_AVAILABLE = 0;
&QTY_RESERVED = 0;
/****************************************************************************
************************************/
/****************************************************************************
************************************/
/****************************************************************************
************************************/
REM
REM
REM
REM
******************************************;
! rea que aceita reserva.
;
! Regra 01
;
******************************************;
******************************************;
! rea que no aceita reserva.
;
! Regra 02
;
******************************************;
******************************************;
! rea WIP que aceita reserva.
;
! Regra 03
;
******************************************;
&QTY_RESERVED = &P_QTY_SOLICITADA;
End-If;
REM ******************************************;
REM ! No aceita reserva.
;
REM ******************************************;
If &E_DEST_WIP_LOC_FLG = "N" And
&E_DEST_NETTABLE_FLG = "N" Then
REM ! Subtrai quantidade reservada.
&QTY_AVAILABLE = 0;
&QTY_RESERVED = &P_QTY_SOLICITADA;
End-If;
End-If;
/****************************************************************************
************************************/
/****************************************************************************
************************************/
/****************************************************************************
************************************/
REM ******************************************;
REM ! rea WIP que no aceita reserva.
;
REM ! Regra 04
;
REM ******************************************;
If &E_ORIG_WIP_LOC_FLG = "Y" And
&E_ORIG_NETTABLE_FLG = "N" Then
REM ******************************************;
REM ! WIP / Aceita reserva.
;
REM ******************************************;
If &E_DEST_WIP_LOC_FLG = "Y" And
&E_DEST_NETTABLE_FLG = "Y" Then
REM ! Soma quantidade reservada. ;
&QTY_AVAILABLE = 0;
&QTY_RESERVED = &P_QTY_SOLICITADA * - 1;
End-If;
REM ******************************************;
REM ! No aceita reserva.
;
REM ******************************************;
If &E_DEST_WIP_LOC_FLG = "N" And
&E_DEST_NETTABLE_FLG = "N" Then
REM ! No faz nada. ;
End-If;
REM ******************************************;
REM ! Aceita reserva.
;
REM ******************************************;
If &E_DEST_WIP_LOC_FLG = "N" And
&E_DEST_NETTABLE_FLG = "Y" Then
REM ! Soma quantidade disponivel. ;
&QTY_AVAILABLE = &P_QTY_SOLICITADA * - 1;
&QTY_RESERVED = 0;
End-If;
End-If;
/****************************************************************************
************************************/
/****************************************************************************
************************************/
/****************************************************************************
************************************/
If &QTY_AVAILABLE <> 0 Or
&QTY_RESERVED <> 0 Then
,
,
&SQL
&SQL
";
&SQL
";
&SQL
";
&SQL
";
&SQL
";
&SQL
";
= "";
= &SQL | " UPDATE SYSADM.PS_BU_ITEMS_INV
= &SQL | "
SET QTY_AVAILABLE
= QTY_AVAILABLE -
:1
:2
= &SQL | "
QTY_RESERVED
= QTY_RESERVED
= &SQL | "
DT_TIMESTAMP
= SYSDATE
= &SQL | "
WHERE BUSINESS_UNIT
:3
= &SQL | "
AND INV_ITEM_ID
:4
= :1
= :2
";
";
";
";
&TRANS_DT_TIMESTAMP = %Datetime;
&SQL = "";
&SQL = &SQL | " SELECT CASE WHEN MAX(TI.SEQ_NBR) IS NULL THEN 1 ELSE MAX(TI.
= :1
= :2
= %DateTimeIn(:3)
&sqlStmt = CreateSQL("%INSERT(:1)");
&sqlStmt.Execute(&REC_TRAN);
&sqlStmt.Close();
&OUT_STATUS_TRANSFERENCIA = "OK";
&OUT_MMC_TRAN_BU = &P_BUSINESS_UNIT;
&OUT_MMC_TRAN_ITEM = &P_INV_ITEM_ID;
&OUT_MMC_TRAN_TIMESTAMP = &TRANS_DT_TIMESTAMP;
&OUT_MMC_TRAN_SEQ_NBR = &TRANS_SEQ_NBR;
End-Function;
********************************************************************************
*****/
Function MMC_NUMERACAO_ID(&NUMERACAO_ID) Returns string
/* SQLExec("update sysadm.ps_mmc_numeracao set mmc_ultimo_numero = mmc_ultim
o_numero+1 where mmc_numeracao_id=:1", &NUMERACAO_ID);
SQLExec("select auto_number_prefix, mmc_ultimo_numero, TRIM(auto_number_prefi
x)||LPAD(mmc_ultimo_numero,10-length(auto_number_prefix),'0' ) NUMERO_PREFIXO fr
om sysadm.ps_mmc_numeracao where mmc_numeracao_id=:1", &NUMERACAO_ID, &AUTO_NUMB
ER_PREFIX, &MMC_ULTIMO_NUMERO, &NUMERO_PREFIXO);
If All(&AUTO_NUMBER_PREFIX) And
&AUTO_NUMBER_PREFIX <> " " Then
Return &NUMERO_PREFIXO;
Else
Return &MMC_ULTIMO_NUMERO;
End-If;
*/
rem SQLExec("SELECT SYSADM.MMC_PK_PU.FC_GERA_E_RETORNA_PROXIMO_ID(:1) FROM D
UAL", &NUMERACAO_ID, &MMC_ULTIMO_NUMERO);
SQLExec("select TRIM(auto_number_prefix)||LPAD(SYSADM.MMC_PK_PU.FC_GERA_E_RET
ORNA_PROXIMO_ID(:1),10-length(auto_number_prefix),'0' ) NUMERO_PREFIXO from sysa
dm.ps_mmc_numeracao where mmc_numeracao_id=:2", &NUMERACAO_ID, &NUMERACAO_ID, &M
MC_ULTIMO_NUMERO);
Return &MMC_ULTIMO_NUMERO;
End-Function;
[MMC_PO_LIB.FUNCLIB.SavePostChange]
/*******************************************************************************
*****
Wagner Sorio / Claudio Costa - MMC - 06/11/2007 - mmcb.at2323 - Sistema Controle
Terceiros
Biblioteca de Funes Compras.
********************************************************************************
*****/
/*******************************************************************************
******
* Daniel Holer R Santos - MMC - 17/09/2014 - mmcb.sds4689
*
* Funes acrescentadas: VALIDA_BU_LOCAL, GET_BU_CONTABIL e VALIDA_DEPTO
*
*****************************************************************
********************/
/******************** mmcb.sds4689.sn ********************/
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange;
Declare Function VERIFICA_STATUS_CUSTOMIZACAO PeopleCode MMC_CUSTOMIZA.MMC_CUSTO
MIZA_ID FieldFormula;
/*------------------------------------------------------------------------------------ Funo que valida se um Local vlido para uma Unidade de Negcio
- Parmetros: &P_BU - Unidade de Negcio a ser validada
End-If;
End-If;
End-Function;
/******************** mmcb.sds4689.sn ********************/
/*-----------------------------------------------------------------------------------FAZ INSERT TABELA SYSADM.PS_RECV_LN_ASSET
------------------------------------------------------------------------------------*/
Function GRAVA_RECV_LN_ASSET(&P1_BUSINESS_UNIT, &P1_RECEIVER_ID, &P1_RECV_LN_NBR
, &P1_RECV_SHIP_SEQ_NBR, &P1_DISTRIB_LINE_NUM, &P1_DISTRIB_SEQ_NUM, &P1_ACTUAL_C
OST, &P1_ASSET_ID, &P1_AUTO_BIN2BIN, &P1_BUSINESS_UNIT_AM, &P1_BUSINESS_UNIT_IN,
&P1_CONTAINER_ID, &P1_COST, &P1_CURRENCY_CD, &P1_CUSTODIAN, &P1_DESCR, &P1_DTTM
_STAMP, &P1_FINANCIAL_ASSET_SW, &P1_FROM_STOR_AREA, &P1_FROM_STOR_LEV1, &P1_FROM
_STOR_LEV2, &P1_FROM_STOR_LEV3, &P1_FROM_STOR_LEV4, &P1_INV_ITEM_ID, &P1_ITM_SET
ID, &P1_LOCATION, &P1_LOT_ID, &P1_MANUFACTURER, &P1_MODEL, &P1_PRE_INTFC_ID, &P1
_PRE_INTFC_LINE_NUM, &P1_PRICE_PO_BSE, &P1_PROCESS_INSTANCE, &P1_PROFILE_ID, &P1
_QTY_MOVED_ASSET, &P1_QTY_MOVED_INV, &P1_QUANTITY, &P1_RECV_AM_STATUS, &P1_SERIA
L_ID, &P1_SF_KANBAN_ID, &P1_STORAGE_AREA, &P1_STORAGE_CODE, &P1_STOR_LEVEL_1, &P
1_STOR_LEVEL_2, &P1_STOR_LEVEL_3, &P1_STOR_LEVEL_4, &P1_TAG_NUMBER, &P1_VENDOR_I
D, &P1_VENDOR_LOT_ID, &P1_PRICE_FOR_INV_PBL, &P1_COST_AM_PBL, &P1_PROC_NF_CANCEL
_PBL)
&REC_RECV_LN_ASSET = CreateRecord(Record.RECV_LN_ASSET);
&REC_RECV_LN_ASSET.BUSINESS_UNIT.VALUE = &P1_BUSINESS_UNIT;
&REC_RECV_LN_ASSET.RECEIVER_ID.VALUE = &P1_RECEIVER_ID;
&REC_RECV_LN_ASSET.RECV_LN_NBR.VALUE = &P1_RECV_LN_NBR;
&REC_RECV_LN_ASSET.RECV_SHIP_SEQ_NBR.VALUE = &P1_RECV_SHIP_SEQ_NBR;
&REC_RECV_LN_ASSET.DISTRIB_LINE_NUM.VALUE = &P1_DISTRIB_LINE_NUM;
&REC_RECV_LN_ASSET.DISTRIB_SEQ_NUM.VALUE = &P1_DISTRIB_SEQ_NUM;
&REC_RECV_LN_ASSET.ACTUAL_COST.VALUE = &P1_ACTUAL_COST;
&REC_RECV_LN_ASSET.ASSET_ID.VALUE = &P1_ASSET_ID;
&REC_RECV_LN_ASSET.AUTO_BIN2BIN.VALUE = &P1_AUTO_BIN2BIN;
&REC_RECV_LN_ASSET.BUSINESS_UNIT_AM.VALUE = &P1_BUSINESS_UNIT_AM;
&REC_RECV_LN_ASSET.BUSINESS_UNIT_IN.VALUE = &P1_BUSINESS_UNIT_IN;
&REC_RECV_LN_ASSET.CONTAINER_ID.VALUE = &P1_CONTAINER_ID;
&REC_RECV_LN_ASSET.COST.VALUE = &P1_COST;
&REC_RECV_LN_ASSET.CURRENCY_CD.VALUE = &P1_CURRENCY_CD;
&REC_RECV_LN_ASSET.CUSTODIAN.VALUE = &P1_CUSTODIAN;
&REC_RECV_LN_ASSET.DESCR.VALUE = &P1_DESCR;
&REC_RECV_LN_ASSET.DTTM_STAMP.VALUE = &P1_DTTM_STAMP;
&REC_RECV_LN_ASSET.FINANCIAL_ASSET_SW.VALUE = &P1_FINANCIAL_ASSET_SW;
&REC_RECV_LN_ASSET.FROM_STOR_AREA.VALUE = &P1_FROM_STOR_AREA;
&REC_RECV_LN_ASSET.FROM_STOR_LEV1.VALUE = &P1_FROM_STOR_LEV1;
&REC_RECV_LN_ASSET.FROM_STOR_LEV2.VALUE = &P1_FROM_STOR_LEV2;
&REC_RECV_LN_ASSET.FROM_STOR_LEV3.VALUE = &P1_FROM_STOR_LEV3;
&REC_RECV_LN_ASSET.FROM_STOR_LEV4.VALUE = &P1_FROM_STOR_LEV4;
&REC_RECV_LN_ASSET.INV_ITEM_ID.VALUE = &P1_INV_ITEM_ID;
&REC_RECV_LN_ASSET.ITM_SETID.VALUE = &P1_ITM_SETID;
&REC_RECV_LN_ASSET.LOCATION.VALUE = &P1_LOCATION;
&REC_RECV_LN_ASSET.LOT_ID.VALUE = &P1_LOT_ID;
&REC_RECV_LN_ASSET.MANUFACTURER.VALUE = &P1_MANUFACTURER;
&REC_RECV_LN_ASSET.MODEL.VALUE = &P1_MODEL;
&REC_RECV_LN_ASSET.PRE_INTFC_ID.VALUE = &P1_PRE_INTFC_ID;
&REC_RECV_LN_ASSET.PRE_INTFC_LINE_NUM.VALUE = &P1_PRE_INTFC_LINE_NUM;
&REC_RECV_LN_ASSET.PRICE_PO_BSE.VALUE = &P1_PRICE_PO_BSE;
&REC_RECV_LN_ASSET.PROCESS_INSTANCE.VALUE = &P1_PROCESS_INSTANCE;
&REC_RECV_LN_ASSET.PROFILE_ID.VALUE = &P1_PROFILE_ID;
&REC_RECV_LN_ASSET.QTY_MOVED_ASSET.VALUE = &P1_QTY_MOVED_ASSET;
&REC_RECV_LN_ASSET.QTY_MOVED_INV.VALUE = &P1_QTY_MOVED_INV;
&REC_RECV_LN_ASSET.QUANTITY.VALUE = &P1_QUANTITY;
&REC_RECV_LN_ASSET.RECV_AM_STATUS.VALUE = &P1_RECV_AM_STATUS;
&REC_RECV_LN_ASSET.SERIAL_ID.VALUE = &P1_SERIAL_ID;
&REC_RECV_LN_ASSET.SF_KANBAN_ID.VALUE = &P1_SF_KANBAN_ID;
&REC_RECV_LN_ASSET.STORAGE_AREA.VALUE = &P1_STORAGE_AREA;
&REC_RECV_LN_ASSET.STORAGE_CODE.VALUE = &P1_STORAGE_CODE;
&REC_RECV_LN_ASSET.STOR_LEVEL_1.VALUE = &P1_STOR_LEVEL_1;
&REC_RECV_LN_ASSET.STOR_LEVEL_2.VALUE = &P1_STOR_LEVEL_2;
&REC_RECV_LN_ASSET.STOR_LEVEL_3.VALUE = &P1_STOR_LEVEL_3;
&REC_RECV_LN_ASSET.STOR_LEVEL_4.VALUE = &P1_STOR_LEVEL_4;
&REC_RECV_LN_ASSET.TAG_NUMBER.VALUE = &P1_TAG_NUMBER;
&REC_RECV_LN_ASSET.VENDOR_ID.VALUE = &P1_VENDOR_ID;
&REC_RECV_LN_ASSET.VENDOR_LOT_ID.VALUE = &P1_VENDOR_LOT_ID;
&REC_RECV_LN_ASSET.PRICE_FOR_INV_PBL.VALUE = &P1_PRICE_FOR_INV_PBL;
&REC_RECV_LN_ASSET.COST_AM_PBL.VALUE = &P1_COST_AM_PBL;
&REC_RECV_LN_ASSET.PROC_NF_CANCEL_PBL.VALUE = &P1_PROC_NF_CANCEL_PBL;
&REC_RECV_LN_ASSET.Insert();
End-Function;
/*-----------------------------------------------------------------------------------FAZ INSERT TABELA SYSADM.PS_RECV_LN_DISTRIB
------------------------------------------------------------------------------------*/
Function GRAVA_RECV_LN_DISTRIB(&P2_BUSINESS_UNIT, &P2_RECEIVER_ID, &P2_RECV_LN_N
BR, &P2_RECV_SHIP_SEQ_NBR, &P2_DISTRIB_LINE_NUM, &P2_ACCOUNT, &P2_ALTACCT, &P2_A
CTIVITY_ID, &P2_ANALYSIS_TYPE, &P2_BUSINESS_UNIT_AM, &P2_BUSINESS_UNIT_GL, &P2_B
USINESS_UNIT_IN, &P2_BUSINESS_UNIT_PC, &P2_BUSINESS_UNIT_PO, &P2_CAP_NUM, &P2_CA
P_SEQUENCE, &P2_CHARTFIELD_STATUS, &P2_CONSIGNED_FLAG, &P2_COST_TYPE, &P2_COSTED
_FLAG, &P2_CURRENCY_CD, &P2_CURRENCY_CD_BASE, &P2_DELIVERED_FLG, &P2_DELIVERED_T
O, &P2_DISTRIB_TYPE, &P2_DST_ACCT_TYPE, &P2_EMPLID, &P2_FINANCIAL_ASSET_SW, &P2_
FREIGHT_PERCENT, &P2_LINE_NBR, &P2_LOCATION, &P2_LOC_RECV_LBL_FLG, &P2_MERCH_AMT
_BSE, &P2_MERCH_AMT_PO_BSE, &P2_MERCHANDISE_AMT, &P2_MERCHANDISE_AMT_PO, &P2_MOV
_DS_ACCPT_SUOM, &P2_PO_DIST_LINE_NUM, &P2_PO_ID, &P2_PROCESS_INSTANCE, &P2_PROFI
LE_ID, &P2_QTY_DS_ACCPT_SUOM, &P2_QTY_DS_ACCPT_VUOM, &P2_QTY_PO, &P2_RATE_DIV, &
P2_RATE_MULT, &P2_RECV_DS_STATUS, &P2_REQ_ID, &P2_RESOURCE_CATEGORY, &P2_RESOURC
E_SUB_CAT, &P2_RESOURCE_TYPE, &P2_RT_TYPE, &P2_SCHED_NBR, &P2_STATISTICS_CODE, &
P2_STATISTIC_AMOUNT, &P2_TAX_CD_SUT_PCT, &P2_TAX_CD_VAT_PCT, &P2_OPERATING_UNIT,
&P2_DEPTID, &P2_PRODUCT, &P2_PROJECT_ID, &P2_AFFILIATE)
&REC_RECV_LN_DISTRIB = CreateRecord(Record.RECV_LN_DISTRIB);
&REC_RECV_LN_DISTRIB.BUSINESS_UNIT.VALUE = &P2_BUSINESS_UNIT;
&REC_RECV_LN_DISTRIB.RECEIVER_ID.VALUE = &P2_RECEIVER_ID;
&REC_RECV_LN_DISTRIB.RECV_LN_NBR.VALUE = &P2_RECV_LN_NBR;
&REC_RECV_LN_DISTRIB.RECV_SHIP_SEQ_NBR.VALUE = &P2_RECV_SHIP_SEQ_NBR;
&REC_RECV_LN_DISTRIB.DISTRIB_LINE_NUM.VALUE = &P2_DISTRIB_LINE_NUM;
&REC_RECV_LN_DISTRIB.ACCOUNT.VALUE = &P2_ACCOUNT;
&REC_RECV_LN_DISTRIB.ALTACCT.VALUE = &P2_ALTACCT;
&REC_RECV_LN_DISTRIB.ACTIVITY_ID.VALUE = &P2_ACTIVITY_ID;
&REC_RECV_LN_DISTRIB.ANALYSIS_TYPE.VALUE = &P2_ANALYSIS_TYPE;
&REC_RECV_LN_DISTRIB.BUSINESS_UNIT_AM.VALUE = &P2_BUSINESS_UNIT_AM;
&REC_RECV_LN_DISTRIB.BUSINESS_UNIT_GL.VALUE = &P2_BUSINESS_UNIT_GL;
&REC_RECV_LN_DISTRIB.BUSINESS_UNIT_IN.VALUE = &P2_BUSINESS_UNIT_IN;
&REC_RECV_LN_DISTRIB.BUSINESS_UNIT_PC.VALUE = &P2_BUSINESS_UNIT_PC;
&REC_RECV_LN_DISTRIB.BUSINESS_UNIT_PO.VALUE = &P2_BUSINESS_UNIT_PO;
&REC_RECV_LN_DISTRIB.CAP_NUM.VALUE = &P2_CAP_NUM;
&REC_RECV_LN_DISTRIB.CAP_SEQUENCE.VALUE = &P2_CAP_SEQUENCE;
&REC_RECV_LN_DISTRIB.CHARTFIELD_STATUS.VALUE = &P2_CHARTFIELD_STATUS;
&REC_RECV_LN_DISTRIB.CONSIGNED_FLAG.VALUE = &P2_CONSIGNED_FLAG;
&REC_RECV_LN_DISTRIB.COST_TYPE.VALUE = &P2_COST_TYPE;
&REC_RECV_LN_DISTRIB.COSTED_FLAG.VALUE = &P2_COSTED_FLAG;
&REC_RECV_LN_DISTRIB.CURRENCY_CD.VALUE = &P2_CURRENCY_CD;
&REC_RECV_LN_DISTRIB.CURRENCY_CD_BASE.VALUE = &P2_CURRENCY_CD_BASE;
&REC_RECV_LN_DISTRIB.DELIVERED_FLG.VALUE = &P2_DELIVERED_FLG;
&REC_RECV_LN_DISTRIB.DELIVERED_TO.VALUE = &P2_DELIVERED_TO;
&REC_RECV_LN_DISTRIB.DISTRIB_TYPE.VALUE = &P2_DISTRIB_TYPE;
&REC_RECV_LN_DISTRIB.DST_ACCT_TYPE.VALUE = &P2_DST_ACCT_TYPE;
&REC_RECV_LN_DISTRIB.EMPLID.VALUE = &P2_EMPLID;
&REC_RECV_LN_DISTRIB.FINANCIAL_ASSET_SW.VALUE = &P2_FINANCIAL_ASSET_SW;
&REC_RECV_LN_DISTRIB.FREIGHT_PERCENT.VALUE = &P2_FREIGHT_PERCENT;
&REC_RECV_LN_DISTRIB.LINE_NBR.VALUE = &P2_LINE_NBR;
&REC_RECV_LN_DISTRIB.LOCATION.VALUE = &P2_LOCATION;
&REC_RECV_LN_DISTRIB.LOC_RECV_LBL_FLG.VALUE = &P2_LOC_RECV_LBL_FLG;
&REC_RECV_LN_DISTRIB.MERCH_AMT_BSE.VALUE = &P2_MERCH_AMT_BSE;
&REC_RECV_LN_DISTRIB.MERCH_AMT_PO_BSE.VALUE = &P2_MERCH_AMT_PO_BSE;
&REC_RECV_LN_DISTRIB.MERCHANDISE_AMT.VALUE = &P2_MERCHANDISE_AMT;
&REC_RECV_LN_DISTRIB.MERCHANDISE_AMT_PO.VALUE = &P2_MERCHANDISE_AMT_PO;
&REC_RECV_LN_DISTRIB.MOV_DS_ACCPT_SUOM.VALUE = &P2_MOV_DS_ACCPT_SUOM;
&REC_RECV_LN_DISTRIB.PO_DIST_LINE_NUM.VALUE = &P2_PO_DIST_LINE_NUM;
&REC_RECV_LN_DISTRIB.PO_ID.VALUE = &P2_PO_ID;
&REC_RECV_LN_DISTRIB.PROCESS_INSTANCE.VALUE = &P2_PROCESS_INSTANCE;
&REC_RECV_LN_DISTRIB.PROFILE_ID.VALUE = &P2_PROFILE_ID;
&REC_RECV_LN_DISTRIB.QTY_DS_ACCPT_SUOM.VALUE = &P2_QTY_DS_ACCPT_SUOM;
&REC_RECV_LN_DISTRIB.QTY_DS_ACCPT_VUOM.VALUE = &P2_QTY_DS_ACCPT_VUOM;
&REC_RECV_LN_DISTRIB.QTY_PO.VALUE = &P2_QTY_PO;
&REC_RECV_LN_DISTRIB.RATE_DIV.VALUE = &P2_RATE_DIV;
&REC_RECV_LN_DISTRIB.RATE_MULT.VALUE = &P2_RATE_MULT;
&REC_RECV_LN_DISTRIB.RECV_DS_STATUS.VALUE = &P2_RECV_DS_STATUS;
&REC_RECV_LN_DISTRIB.REQ_ID.VALUE = &P2_REQ_ID;
&REC_RECV_LN_DISTRIB.RESOURCE_CATEGORY.VALUE = &P2_RESOURCE_CATEGORY;
&REC_RECV_LN_DISTRIB.RESOURCE_SUB_CAT.VALUE = &P2_RESOURCE_SUB_CAT;
&REC_RECV_LN_DISTRIB.RESOURCE_TYPE.VALUE = &P2_RESOURCE_TYPE;
&REC_RECV_LN_DISTRIB.RT_TYPE.VALUE = &P2_RT_TYPE;
&REC_RECV_LN_DISTRIB.SCHED_NBR.VALUE = &P2_SCHED_NBR;
&REC_RECV_LN_DISTRIB.STATISTICS_CODE.VALUE = &P2_STATISTICS_CODE;
&REC_RECV_LN_DISTRIB.STATISTIC_AMOUNT.VALUE = &P2_STATISTIC_AMOUNT;
&REC_RECV_LN_DISTRIB.TAX_CD_SUT_PCT.VALUE = &P2_TAX_CD_SUT_PCT;
&REC_RECV_LN_DISTRIB.TAX_CD_VAT_PCT.VALUE = &P2_TAX_CD_VAT_PCT;
&REC_RECV_LN_DISTRIB.OPERATING_UNIT.VALUE = &P2_OPERATING_UNIT;
&REC_RECV_LN_DISTRIB.DEPTID.VALUE = &P2_DEPTID;
&REC_RECV_LN_DISTRIB.PRODUCT.VALUE = &P2_PRODUCT;
&REC_RECV_LN_DISTRIB.PROJECT_ID.VALUE = &P2_PROJECT_ID;
&REC_RECV_LN_DISTRIB.AFFILIATE.VALUE = &P2_AFFILIATE;
&REC_RECV_LN_DISTRIB.Insert();
End-Function;
/*-----------------------------------------------------------------------------------FAZ INSERT TABELA SYSADM.PS_RECV_LN_INSP
--------------------------------------------------------------------------------
-----*/
Function GRAVA_RECV_LN_INSP(&P3_BUSINESS_UNIT, &P3_RECEIVER_ID, &P3_RECV_LN_NBR,
&P3_OP_SEQ, &P3_ROUTING_SETID, &P3_ROUTING_ID, &P3_OP_TIME_STD, &P3_OP_TIME_CD,
&P3_OP_TIME_STD_TTL, &P3_OP_TIME_ACT_TTL, &P3_PROCESS_INSTANCE)
&REC_RECV_LN_INSP = CreateRecord(Record.RECV_LN_INSP);
&REC_RECV_LN_INSP.BUSINESS_UNIT.VALUE = &P3_BUSINESS_UNIT;
&REC_RECV_LN_INSP.RECEIVER_ID.VALUE = &P3_RECEIVER_ID;
&REC_RECV_LN_INSP.RECV_LN_NBR.VALUE = &P3_RECV_LN_NBR;
&REC_RECV_LN_INSP.OP_SEQ.VALUE = &P3_OP_SEQ;
&REC_RECV_LN_INSP.ROUTING_SETID.VALUE = &P3_ROUTING_SETID;
&REC_RECV_LN_INSP.ROUTING_ID.VALUE = &P3_ROUTING_ID;
&REC_RECV_LN_INSP.OP_TIME_STD.VALUE = &P3_OP_TIME_STD;
&REC_RECV_LN_INSP.OP_TIME_CD.VALUE = &P3_OP_TIME_CD;
&REC_RECV_LN_INSP.OP_TIME_STD_TTL.VALUE = &P3_OP_TIME_STD_TTL;
&REC_RECV_LN_INSP.OP_TIME_ACT_TTL.VALUE = &P3_OP_TIME_ACT_TTL;
&REC_RECV_LN_INSP.PROCESS_INSTANCE.VALUE = &P3_PROCESS_INSTANCE;
&REC_RECV_LN_INSP.Insert()
End-Function;
/*-----------------------------------------------------------------------------------FAZ INSERT TABELA SYSADM.PS_RECV_LN_SHIP
------------------------------------------------------------------------------------*/
Function GRAVA_RECV_LN_SHIP(&P4_BUSINESS_UNIT, &P4_RECEIVER_ID, &P4_RECV_LN_NBR,
&P4_RECV_SHIP_SEQ_NBR, &P4_AMT_ONLY_FLG, &P4_ASN_SEQ_NBR, &P4_BILL_OF_LADING, &
P4_BUSINESS_UNIT_IN, &P4_BUSINESS_UNIT_PO, &P4_CATEGORY_ID, &P4_CONFIG_CODE, &P4
_CONVERSION_RATE, &P4_CONVERT_TO_STK, &P4_CONVERT_TO_PO, &P4_CONVERT_STK_TO_STD,
&P4_COUNTRY_IST_ORIGIN, &P4_CURRENCY_CD, &P4_CURRENCY_CD_BASE, &P4_DESCR254_MIX
ED, &P4_DEVICE_TRACKING, &P4_DISTRIB_MTHD_FLG, &P4_DUE_DT, &P4_DUE_TIME, &P4_EIP
_CTL_ID, &P4_ERS_INV_SEQ, &P4_ERS_STATUS, &P4_INSPECT_CD, &P4_INSPECT_DTTM, &P4_
INSPECT_STATUS, &P4_INV_ITEM_ID, &P4_IST_DISTRIB_STATUS, &P4_ITM_ID_VNDR, &P4_IT
M_SETID, &P4_LINE_NBR, &P4_LOT_CONTROL, &P4_LOT_STATUS, &P4_MATCH_LINE_FLG, &P4_
MATCH_STATUS_LC, &P4_MERCH_AMT_BSE, &P4_MERCH_AMT_PO_BSE, &P4_MERCHANDISE_AMT, &
P4_MERCHANDISE_AMT_PO, &P4_MFG_ID, &P4_MFG_ITM_ID, &P4_MOVE_STAT_AM, &P4_MOVE_ST
AT_INV, &P4_MOVE_STAT_MFG, &P4_OP_SEQUENCE, &P4_OPRID, &P4_PACKSLIP_NO, &P4_PO_I
D, &P4_PO_TYPE, &P4_PRICE_PO, &P4_PRICE_PO_BSE, &P4_PRO_NUMBER, &P4_PROCESS_COMP
LETE, &P4_PROCESS_INSTANCE, &P4_PRODUCTION_ID, &P4_QTY_LN_ASSET_SUOM, &P4_QTY_LN
_INV_SUOM, &P4_QTY_SH_ACCPT, &P4_QTY_SH_ACCPT_SUOM, &P4_QTY_SH_ACCPT_VUOM, &P4_Q
TY_SH_INSPD, &P4_QTY_SH_INSPD_SUOM, &P4_QTY_SH_INSPD_VUOM, &P4_QTY_SH_NETRCV_VUO
M, &P4_QTY_SH_RECVD, &P4_QTY_SH_RECVD_SUOM, &P4_QTY_SH_RECVD_VUOM, &P4_QTY_SH_RE
JCT, &P4_QTY_SH_REJCT_SUOM, &P4_QTY_SH_REJCT_VUOM, &P4_QTY_SH_RTN, &P4_QTY_SH_RT
N_SUOM, &P4_QTY_SH_RTN_VUOM, &P4_REJECT_ACTION, &P4_REJECT_REASON, &P4_REVISION,
&P4_RMA_ID, &P4_RMA_LINE_NBR, &P4_RECEIPT_ALLOC_TYPE, &P4_RECEIPT_DTTM, &P4_REC
EIPT_UM, &P4_RECEIVE_UOM, &P4_RECV_LN_MATCH_OPT, &P4_RECV_SHIP_STATUS, &P4_RECV_
STOCK_UOM, &P4_REPLACEMENT_FLG, &P4_SCHED_NBR, &P4_SERIAL_CONTROL, &P4_SERIAL_ST
ATUS, &P4_SHIP_DATE_STATUS, &P4_SHIP_QTY_STATUS, &P4_SHIPTO_ID, &P4_UNIT_MEASURE
_STD)
&REC_RECV_LN_SHIP = CreateRecord(Record.RECV_LN_SHIP);
&REC_RECV_LN_SHIP.BUSINESS_UNIT.VALUE = &P4_BUSINESS_UNIT;
&REC_RECV_LN_SHIP.RECEIVER_ID.VALUE = &P4_RECEIVER_ID;
&REC_RECV_LN_SHIP.RECV_LN_NBR.VALUE = &P4_RECV_LN_NBR;
&REC_RECV_LN_SHIP.RECV_SHIP_SEQ_NBR.VALUE = &P4_RECV_SHIP_SEQ_NBR;
&REC_RECV_LN_SHIP.AMT_ONLY_FLG.VALUE = &P4_AMT_ONLY_FLG;
&REC_RECV_LN_SHIP.ASN_SEQ_NBR.VALUE = &P4_ASN_SEQ_NBR;
&REC_RECV_LN_SHIP.BILL_OF_LADING.VALUE = &P4_BILL_OF_LADING;
&REC_RECV_LN_SHIP.BUSINESS_UNIT_IN.VALUE = &P4_BUSINESS_UNIT_IN;
&REC_RECV_LN_SHIP.BUSINESS_UNIT_PO.VALUE = &P4_BUSINESS_UNIT_PO;
&REC_RECV_LN_SHIP.CATEGORY_ID.VALUE = &P4_CATEGORY_ID;
&REC_RECV_LN_SHIP.CONFIG_CODE.VALUE = &P4_CONFIG_CODE;
&REC_RECV_LN_SHIP.CONVERSION_RATE.VALUE = &P4_CONVERSION_RATE;
&REC_RECV_LN_SHIP.CONVERT_TO_STK.VALUE = &P4_CONVERT_TO_STK;
&REC_RECV_LN_SHIP.CONVERT_TO_PO.VALUE = &P4_CONVERT_TO_PO;
&REC_RECV_LN_SHIP.CONVERT_STK_TO_STD.VALUE = &P4_CONVERT_STK_TO_STD;
&REC_RECV_LN_SHIP.COUNTRY_IST_ORIGIN.VALUE = &P4_COUNTRY_IST_ORIGIN;
&REC_RECV_LN_SHIP.CURRENCY_CD.VALUE = &P4_CURRENCY_CD;
&REC_RECV_LN_SHIP.CURRENCY_CD_BASE.VALUE = &P4_CURRENCY_CD_BASE;
&REC_RECV_LN_SHIP.DESCR254_MIXED.VALUE = &P4_DESCR254_MIXED;
&REC_RECV_LN_SHIP.DEVICE_TRACKING.VALUE = &P4_DEVICE_TRACKING;
&REC_RECV_LN_SHIP.DISTRIB_MTHD_FLG.VALUE = &P4_DISTRIB_MTHD_FLG;
&REC_RECV_LN_SHIP.DUE_DT.VALUE = &P4_DUE_DT;
&REC_RECV_LN_SHIP.DUE_TIME.VALUE = &P4_DUE_TIME;
&REC_RECV_LN_SHIP.EIP_CTL_ID.VALUE = &P4_EIP_CTL_ID;
&REC_RECV_LN_SHIP.ERS_INV_SEQ.VALUE = &P4_ERS_INV_SEQ;
&REC_RECV_LN_SHIP.ERS_STATUS.VALUE = &P4_ERS_STATUS;
&REC_RECV_LN_SHIP.INSPECT_CD.VALUE = &P4_INSPECT_CD;
&REC_RECV_LN_SHIP.INSPECT_DTTM.VALUE = &P4_INSPECT_DTTM;
&REC_RECV_LN_SHIP.INSPECT_STATUS.VALUE = &P4_INSPECT_STATUS;
&REC_RECV_LN_SHIP.INV_ITEM_ID.VALUE = &P4_INV_ITEM_ID;
&REC_RECV_LN_SHIP.IST_DISTRIB_STATUS.VALUE = &P4_IST_DISTRIB_STATUS;
&REC_RECV_LN_SHIP.ITM_ID_VNDR.VALUE = &P4_ITM_ID_VNDR;
&REC_RECV_LN_SHIP.ITM_SETID.VALUE = &P4_ITM_SETID;
&REC_RECV_LN_SHIP.LINE_NBR.VALUE = &P4_LINE_NBR;
&REC_RECV_LN_SHIP.LOT_CONTROL.VALUE = &P4_LOT_CONTROL;
&REC_RECV_LN_SHIP.LOT_STATUS.VALUE = &P4_LOT_STATUS;
&REC_RECV_LN_SHIP.MATCH_LINE_FLG.VALUE = &P4_MATCH_LINE_FLG;
&REC_RECV_LN_SHIP.MATCH_STATUS_LC.VALUE = &P4_MATCH_STATUS_LC;
&REC_RECV_LN_SHIP.MERCH_AMT_BSE.VALUE = &P4_MERCH_AMT_BSE;
&REC_RECV_LN_SHIP.MERCH_AMT_PO_BSE.VALUE = &P4_MERCH_AMT_PO_BSE;
&REC_RECV_LN_SHIP.MERCHANDISE_AMT.VALUE = &P4_MERCHANDISE_AMT;
&REC_RECV_LN_SHIP.MERCHANDISE_AMT_PO.VALUE = &P4_MERCHANDISE_AMT_PO;
&REC_RECV_LN_SHIP.MFG_ID.VALUE = &P4_MFG_ID;
&REC_RECV_LN_SHIP.MFG_ITM_ID.VALUE = &P4_MFG_ITM_ID;
&REC_RECV_LN_SHIP.MOVE_STAT_AM.VALUE = &P4_MOVE_STAT_AM;
&REC_RECV_LN_SHIP.MOVE_STAT_INV.VALUE = &P4_MOVE_STAT_INV;
&REC_RECV_LN_SHIP.MOVE_STAT_MFG.VALUE = &P4_MOVE_STAT_MFG;
&REC_RECV_LN_SHIP.OP_SEQUENCE.VALUE = &P4_OP_SEQUENCE;
&REC_RECV_LN_SHIP.OPRID.VALUE = &P4_OPRID;
&REC_RECV_LN_SHIP.PACKSLIP_NO.VALUE = &P4_PACKSLIP_NO;
&REC_RECV_LN_SHIP.PO_ID.VALUE = &P4_PO_ID;
&REC_RECV_LN_SHIP.PO_TYPE.VALUE = &P4_PO_TYPE;
&REC_RECV_LN_SHIP.PRICE_PO.VALUE = &P4_PRICE_PO;
&REC_RECV_LN_SHIP.PRICE_PO_BSE.VALUE = &P4_PRICE_PO_BSE;
&REC_RECV_LN_SHIP.PRO_NUMBER.VALUE = &P4_PRO_NUMBER;
&REC_RECV_LN_SHIP.PROCESS_COMPLETE.VALUE = &P4_PROCESS_COMPLETE;
&REC_RECV_LN_SHIP.PROCESS_INSTANCE.VALUE = &P4_PROCESS_INSTANCE;
&REC_RECV_LN_SHIP.PRODUCTION_ID.VALUE = &P4_PRODUCTION_ID;
&REC_RECV_LN_SHIP.QTY_LN_ASSET_SUOM.VALUE = &P4_QTY_LN_ASSET_SUOM;
&REC_RECV_LN_SHIP.QTY_LN_INV_SUOM.VALUE = &P4_QTY_LN_INV_SUOM;
&REC_RECV_LN_SHIP.QTY_SH_ACCPT.VALUE = &P4_QTY_SH_ACCPT;
&REC_RECV_LN_SHIP.QTY_SH_ACCPT_SUOM.VALUE = &P4_QTY_SH_ACCPT_SUOM;
&REC_RECV_LN_SHIP.QTY_SH_ACCPT_VUOM.VALUE = &P4_QTY_SH_ACCPT_VUOM;
&REC_RECV_LN_SHIP.QTY_SH_INSPD.VALUE = &P4_QTY_SH_INSPD;
&REC_RECV_LN_SHIP.QTY_SH_INSPD_SUOM.VALUE = &P4_QTY_SH_INSPD_SUOM;
&REC_RECV_LN_SHIP.QTY_SH_INSPD_VUOM.VALUE = &P4_QTY_SH_INSPD_VUOM;
&REC_RECV_LN_SHIP.QTY_SH_NETRCV_VUOM.VALUE = &P4_QTY_SH_NETRCV_VUOM;
&REC_RECV_LN_SHIP.QTY_SH_RECVD.VALUE = &P4_QTY_SH_RECVD;
&REC_RECV_LN_SHIP.QTY_SH_RECVD_SUOM.VALUE = &P4_QTY_SH_RECVD_SUOM;
&REC_RECV_LN_SHIP.QTY_SH_RECVD_VUOM.VALUE = &P4_QTY_SH_RECVD_VUOM;
&REC_RECV_LN_SHIP.QTY_SH_REJCT.VALUE = &P4_QTY_SH_REJCT;
&REC_RECV_LN_SHIP.QTY_SH_REJCT_SUOM.VALUE = &P4_QTY_SH_REJCT_SUOM;
&REC_RECV_LN_SHIP.QTY_SH_REJCT_VUOM.VALUE = &P4_QTY_SH_REJCT_VUOM;
&REC_RECV_LN_SHIP.QTY_SH_RTN.VALUE = &P4_QTY_SH_RTN;
&REC_RECV_LN_SHIP.QTY_SH_RTN_SUOM.VALUE = &P4_QTY_SH_RTN_SUOM;
&REC_RECV_LN_SHIP.QTY_SH_RTN_VUOM.VALUE = &P4_QTY_SH_RTN_VUOM;
&REC_RECV_LN_SHIP.REJECT_ACTION.VALUE = &P4_REJECT_ACTION;
&REC_RECV_LN_SHIP.REJECT_REASON.VALUE = &P4_REJECT_REASON;
&REC_RECV_LN_SHIP.REVISION.VALUE = &P4_REVISION;
&REC_RECV_LN_SHIP.RMA_ID.VALUE = &P4_RMA_ID;
&REC_RECV_LN_SHIP.RMA_LINE_NBR.VALUE = &P4_RMA_LINE_NBR;
&REC_RECV_LN_SHIP.RECEIPT_ALLOC_TYPE.VALUE = &P4_RECEIPT_ALLOC_TYPE;
&REC_RECV_LN_SHIP.RECEIPT_DTTM.VALUE = &P4_RECEIPT_DTTM;
&REC_RECV_LN_SHIP.RECEIPT_UM.VALUE = &P4_RECEIPT_UM;
&REC_RECV_LN_SHIP.RECEIVE_UOM.VALUE = &P4_RECEIVE_UOM;
&REC_RECV_LN_SHIP.RECV_LN_MATCH_OPT.VALUE = &P4_RECV_LN_MATCH_OPT;
&REC_RECV_LN_SHIP.RECV_SHIP_STATUS.VALUE = &P4_RECV_SHIP_STATUS;
&REC_RECV_LN_SHIP.RECV_STOCK_UOM.VALUE = &P4_RECV_STOCK_UOM;
&REC_RECV_LN_SHIP.REPLACEMENT_FLG.VALUE = &P4_REPLACEMENT_FLG;
&REC_RECV_LN_SHIP.SCHED_NBR.VALUE = &P4_SCHED_NBR;
&REC_RECV_LN_SHIP.SERIAL_CONTROL.VALUE = &P4_SERIAL_CONTROL;
&REC_RECV_LN_SHIP.SERIAL_STATUS.VALUE = &P4_SERIAL_STATUS;
&REC_RECV_LN_SHIP.SHIP_DATE_STATUS.VALUE = &P4_SHIP_DATE_STATUS;
&REC_RECV_LN_SHIP.SHIP_QTY_STATUS.VALUE = &P4_SHIP_QTY_STATUS;
&REC_RECV_LN_SHIP.SHIPTO_ID.VALUE = &P4_SHIPTO_ID;
&REC_RECV_LN_SHIP.UNIT_MEASURE_STD.VALUE = &P4_UNIT_MEASURE_STD;
&REC_RECV_LN_SHIP.Insert();
End-Function;
/*-----------------------------------------------------------------------------------FAZ INSERT TABELA SYSADM.PS_RECV_LN_SHP_MTH
------------------------------------------------------------------------------------*/
Function GRAVA_RECV_LN_SHP_MTH(&P5_BUSINESS_UNIT, &P5_RECEIVER_ID, &P5_RECV_LN_N
BR, &P5_RECV_SHIP_SEQ_NBR, &P5_TXN_CURRENCY_CD, &P5_QTY_MATCHED, &P5_AMT_MATCHED
)
&REC_RECV_LN_SHP_MTH = CreateRecord(Record.RECV_LN_SHP_MTH);
&REC_RECV_LN_SHP_MTH.BUSINESS_UNIT.VALUE = &P5_BUSINESS_UNIT;
&REC_RECV_LN_SHP_MTH.RECEIVER_ID.VALUE = &P5_RECEIVER_ID;
&REC_RECV_LN_SHP_MTH.RECV_LN_NBR.VALUE = &P5_RECV_LN_NBR;
&REC_RECV_LN_SHP_MTH.RECV_SHIP_SEQ_NBR.VALUE = &P5_RECV_SHIP_SEQ_NBR;
&REC_RECV_LN_SHP_MTH.TXN_CURRENCY_CD.VALUE = &P5_TXN_CURRENCY_CD;
&REC_RECV_LN_SHP_MTH.QTY_MATCHED.VALUE = &P5_QTY_MATCHED;
&REC_RECV_LN_SHP_MTH.AMT_MATCHED.VALUE = &P5_AMT_MATCHED;
&REC_RECV_LN_SHP_MTH.Insert();
End-Function;
/*-----------------------------------------------------------------------------------FAZ INSERT TABELA SYSADM.PS_RECV_RECV_HDR
------------------------------------------------------------------------------------*/
&REC_RECV_HDR.LAST_DTTM_UPDATE.VALUE = &P6_LAST_DTTM_UPDATE;
&REC_RECV_HDR.NF_BRL.VALUE = &P6_NF_BRL;
&REC_RECV_HDR.NF_BRL_SERIES.VALUE = &P6_NF_BRL_SERIES;
&REC_RECV_HDR.NF_BRL_DATE.VALUE = &P6_NF_BRL_DATE;
&REC_RECV_HDR.ADDRESS_SEQ_NUM.VALUE = &P6_ADDRESS_SEQ_NUM;
&REC_RECV_HDR.FLG_NF_FISCAL_PBL.VALUE = &P6_FLG_NF_FISCAL_PBL;
&REC_RECV_HDR.Insert();
End-Function;
[MMC_PO_LIB.NF_BRL_ID.SavePostChange]
/*******************************************************************************
*****
* Vincius Alves Mello - MMC - mmcb.sds4122 - 16/10/2012
*
* Gerar NF de entrada, a partir do XML enviado pelo Fornecedor.
*
*******************************************************************************
*****/
/*******************************************************************************
*****
* Mauri R. Back - MMC - mmcb.sds4359 - 14/08/2013
*
* Gerar Recebimento Fisico e Fiscal a partir do XML enviado pelo Fornecedor.
*
*******************************************************************************
*****/
/*******************************************************************************
*****
* Mauri R. Back - MMC - mmcb.hd207045 - 09/07/2014
*
* Gravar FCI
*
*******************************************************************************
*****/
/*******************************************************************************
*****
* Wagner Sorio - MMC - mmcb.hd219468 - 07/11/2014
*
* Correo do campo BUSINESS_UNIT_GL
*
*******************************************************************************
*****/
/*Gera o Cabealho do Documento Fiscal via XML - Similar painel entrada direta*/
/*Function GERAR_CAB_DOC_FISCAL_VIA_XML(&P_BUSINESS_UNIT, &P_NF_BRL_ID, &P_NF_BR
L, &P_NF_BRL_SERIES, &P_NF_BRL_DATE, &P_MMC_CHAVE_ACS_NFE, &P_SETID, &P_VENDOR_I
D, &P_NAME1, &P_ADDRESS_SEQ_NUM, &P_VNDR_LOC, &P_SHIPTO_ID, &P_EF_LOC_BRL, &P_SH
IP_FROM_STATE, &P_SHIP_BRL_TO_STATE, &P_MERCH_ORIG_AMT_PBL, &P_GROSS_AMT, &P_ICM
STAX_BRL_BSE, &P_ICMSTAX_BRL_AMT, &P_IPITAX_BRL_AMT, &P_PISTAX_BRL_AMT, &P_COFIN
STAX_BRL_AMT, &P_ICMSSUB_BRL_BSS, &P_ICMSSUB_BRL_AMT, &P_FREIGHT_AMT, &P_INSURAN
CE_BRL_AMT, &P_OTHEREXP_BRL_AMT)*/ /*mmcb.sds4359.lo*/
Function GERAR_CAB_DOC_FISCAL_VIA_XML(&P_BUSINESS_UNIT, &P_NF_BRL_ID, &P_NF_BRL,
&P_NF_BRL_SERIES, &P_NF_BRL_DATE, &P_MMC_CHAVE_ACS_NFE, &P_SETID, &P_VENDOR_ID,
&P_NAME1, &P_ADDRESS_SEQ_NUM, &P_VNDR_LOC, &P_SHIPTO_ID, &P_EF_LOC_BRL, &P_SHIP
_FROM_STATE, &P_SHIP_BRL_TO_STATE, &P_MERCH_ORIG_AMT_PBL, &P_GROSS_AMT, &P_ICMST
AX_BRL_BSE, &P_ICMSTAX_BRL_AMT, &P_IPITAX_BRL_AMT, &P_PISTAX_BRL_AMT, &P_COFINST
&NF_HDR_BRL.DSCNT_AMT_BSE.VALUE = 0;
&NF_HDR_BRL.FREIGHT_AMT.VALUE = &P_FREIGHT_AMT;
&NF_HDR_BRL.FREIGHT_AMT_BSE.VALUE = &P_FREIGHT_AMT;
&NF_HDR_BRL.INSURANCE_BRL_AMT.VALUE = &P_INSURANCE_BRL_AMT;
&NF_HDR_BRL.INSURANCE_BRL_BSE.VALUE = &P_INSURANCE_BRL_AMT;
&NF_HDR_BRL.OTHEREXP_BRL_AMT.VALUE = &P_OTHEREXP_BRL_AMT;
&NF_HDR_BRL.OTHEREXP_BRL_BSE.VALUE = &P_OTHEREXP_BRL_AMT;
&NF_HDR_BRL.PYMNT_TERMS_CD.VALUE = "30D";
&NF_HDR_BRL.ENTERED_DT.VALUE = %Date;
&NF_HDR_BRL.LAST_UPDATE_DT.VALUE = %Date;
&NF_HDR_BRL.MERCHANDISE_AMT.VALUE = &P_MERCH_ORIG_AMT_PBL;
&NF_HDR_BRL.MERCH_AMT_BSE.VALUE = &P_MERCH_ORIG_AMT_PBL;
&NF_HDR_BRL.ISSTAX_BRL_AMT.VALUE = 0;
&NF_HDR_BRL.ISSTAX_BRL_BSE.VALUE = 0;
&NF_HDR_BRL.ISSTAX_BRL_CD.VALUE = " ";
&NF_HDR_BRL.ISSTAX_BRL_BSS.VALUE = 0;
&NF_HDR_BRL.INSS_BRL_RETENTION.VALUE = 0;
&NF_HDR_BRL.INSS_BRL_RET_BSE.VALUE = 0;
&NF_HDR_BRL.IRTAX_BRL_AMT.VALUE = 0;
&NF_HDR_BRL.IRTAX_BRL_BSE.VALUE = 0;
&NF_HDR_BRL.IRTAX_BRL_BSS.VALUE = 0;
&NF_HDR_BRL.IRTAX_BRL_CD.VALUE = " ";
&NF_HDR_BRL.IPITAX_BRL_AMT.VALUE = &P_IPITAX_BRL_AMT;
&NF_HDR_BRL.IPITAX_BRL_BSE.VALUE = &P_IPITAX_BRL_AMT;
&NF_HDR_BRL.IPITAX_BRL_RCVRY.VALUE = 0;
&NF_HDR_BRL.ICMSTAX_BRL_AMT.VALUE = &P_ICMSTAX_BRL_AMT;
&NF_HDR_BRL.ICMSTAX_BRL_BSE.VALUE = &P_ICMSTAX_BRL_BSE;
&NF_HDR_BRL.ICMSTAX_BRL_BSS.VALUE = &P_ICMSTAX_BRL_BSE;
&NF_HDR_BRL.ICMSTAX_BRL_RCVRY.VALUE = &P_ICMSTAX_BRL_AMT;
&NF_HDR_BRL.ICMSTAX_BRL_RETENT.VALUE = 0;
&NF_HDR_BRL.ICMSTAX_BRL_DUE.VALUE = 0;
&NF_HDR_BRL.ICMSSUB_BRL_AMT.VALUE = &P_ICMSSUB_BRL_AMT;
&NF_HDR_BRL.ICMSSUB_BRL_BSE.VALUE = &P_ICMSSUB_BRL_AMT;
&NF_HDR_BRL.ICMSSUB_BRL_BSS.VALUE = &P_ICMSSUB_BRL_BSS;
&NF_HDR_BRL.TAX_BRL_CALC_FLG.VALUE = "Y";
&NF_HDR_BRL.TRANSPORT_CD.VALUE = " ";
&NF_HDR_BRL.TRANSPORT_MODE.VALUE = " ";
&NF_HDR_BRL.NAME1.VALUE = " ";
&NF_HDR_BRL.ADDRESS1.VALUE = " ";
&NF_HDR_BRL.ADDRESS2.VALUE = " ";
&NF_HDR_BRL.CITY_CD_BBL.VALUE = " ";
&NF_HDR_BRL.CITY.VALUE = " ";
&NF_HDR_BRL.STATE.VALUE = " ";
&NF_HDR_BRL.ZIP.VALUE = " ";
&NF_HDR_BRL.COUNTRY.VALUE = "BRA";
&NF_HDR_BRL.NET_WEIGHT_BRL.VALUE = 0;
&NF_HDR_BRL.GROSS_WEIGHT_BRL.VALUE = 0;
&NF_HDR_BRL.UOM_WEIGHT.VALUE = " ";
&NF_HDR_BRL.QTY_VOL_BRL.VALUE = 0;
&NF_HDR_BRL.NUM_VOL_BRL.VALUE = 0;
&NF_HDR_BRL.TRADE_VOL_BRL.VALUE = " ";
&NF_HDR_BRL.TYPE_VOL_BRL.VALUE = " ";
&NF_HDR_BRL.CGC_BRL.VALUE = " ";
&NF_HDR_BRL.IE_BRL.VALUE = " ";
&NF_HDR_BRL.FREIGHT_PAY_BY_BRL.VALUE = " ";
&NF_HDR_BRL.LICENCE_PLATE_BRL.VALUE = " ";
&NF_HDR_BRL.VOUCHER_ID.VALUE = " ";
/*&NF_HDR_BRL.RECEIVER_ID.VALUE = " ";*/ /*mmcb.sds4359.lo*/
&NF_HDR_BRL.RECEIVER_ID.VALUE = &P_RECEIVER_ID; /*mmcb.sds4359.ln*/
/*&NF_HDR_BRL.BUSINESS_UNIT_RECV.VALUE = " ";*/ /*mmcb.sds4359.lo*/
&NF_HDR_BRL.INSR_INCR_BSE_BBL.VALUE = 0;
&NF_HDR_BRL.OTEX_INCR_BSE_BBL.VALUE = 0;
&NF_HDR_BRL.COLLECT_COD_BRL.VALUE = " ";
&NF_HDR_BRL.DFI_ENTRY_STS_PBL.VALUE = " ";
&NF_HDR_BRL.GRP_ID_PBL.VALUE = " ";
&NF_HDR_BRL.COFINST_BSEAMT_BBL.VALUE = 0;
&NF_HDR_BRL.COFINST_BSSAMT_BBL.VALUE = 0;
&NF_HDR_BRL.PISST_BSE_AMT_BBL.VALUE = 0;
&NF_HDR_BRL.IR_BSS_AMT_BBL.VALUE = 0;
&NF_HDR_BRL.IR_BSE_AMT_BBL.VALUE = 0;
&NF_HDR_BRL.INSS_BSS_AMT_BBL.VALUE = 0;
&NF_HDR_BRL.INSS_BSE_AMT_BBL.VALUE = 0;
&NF_HDR_BRL.SHIPTO_ID.VALUE = &P_SHIPTO_ID;
&NF_HDR_BRL.NF_ID_REL_PBL.VALUE = " ";
/*PAYTRMS_DT_BSE_PBL = Null*/
&NF_HDR_BRL.VOUCHER_FLOW_PBL.VALUE = "N";
&NF_HDR_BRL.ACCOUNT_FLOW_PBL.VALUE = "A";
&NF_HDR_BRL.FLOW_ID_BBL.VALUE = " ";
&NF_HDR_BRL.FLOW_BUS_UNIT_IN.VALUE = " ";
&NF_HDR_BRL.STORAGE_AREA.VALUE = " ";
&NF_HDR_BRL.STOR_LEVEL_1.VALUE = " ";
&NF_HDR_BRL.STOR_LEVEL_2.VALUE = " ";
&NF_HDR_BRL.STOR_LEVEL_3.VALUE = " ";
&NF_HDR_BRL.STOR_LEVEL_4.VALUE = " ";
&NF_HDR_BRL.FLOW_SHIP_ID_BBL.VALUE = " ";
&NF_HDR_BRL.FLOW_LOCATION_BBL.VALUE = " ";
&NF_HDR_BRL.ICMS_DISCOUNT_BBL.VALUE = 0;
/*DT_FLOW_BBL = Null;*/
&NF_HDR_BRL.NF_AM_FLG_BRL.VALUE = " ";
&NF_HDR_BRL.NF_IN_FLG_BBL.VALUE = " ";
&NF_HDR_BRL.DOC_CLASS_BBL.VALUE = " ";
&NF_HDR_BRL.PISST_BSS_AMT_BBL.VALUE = 0;
&NF_HDR_BRL.ECTRANSID.VALUE = " ";
&NF_HDR_BRL.ECQUEUEINSTANCE.VALUE = 0;
&NF_HDR_BRL.ECTRANSINOUTSW.VALUE = " ";
&NF_HDR_BRL.PAY_TRM_BSE_DT_OPT.VALUE = " ";
&NF_HDR_BRL.SERIE_SPIN_BBL.VALUE = 0;
&NF_HDR_BRL.IRRF_BBL_BRL.VALUE = 0;
&NF_HDR_BRL.INSSR_BBL_BRL.VALUE = 0;
&NF_HDR_BRL.MERCH_ORIG_AMT_PBL.VALUE = &P_MERCH_ORIG_AMT_PBL;
&NF_HDR_BRL.COFINS_BRL_RETENT.VALUE = 0;
&NF_HDR_BRL.PIS_BRL_RETENT.VALUE = 0;
&NF_HDR_BRL.CSLL_BRL_RETENT.VALUE = 0;
&NF_HDR_BRL.PISTAX_BRL_AMT.VALUE = &P_PISTAX_BRL_AMT;
&NF_HDR_BRL.COFINSTAX_BRL_AMT.VALUE = &P_COFINSTAX_BRL_AMT;
&NF_HDR_BRL.Insert();
/*Gravar os dados na tabela MMC_CH_ACES_NFE (Chave da NFe)*/
&MMC_CH_ACES_NFE = CreateRecord(Record.MMC_CH_ACES_NFE);
&MMC_CH_ACES_NFE.BUSINESS_UNIT.VALUE = &P_BUSINESS_UNIT;
&MMC_CH_ACES_NFE.NF_BRL_ID.VALUE = &P_NF_BRL_ID;
&MMC_CH_ACES_NFE.MMC_CHAVE_ACS_NFE.VALUE = &P_MMC_CHAVE_ACS_NFE;
&MMC_CH_ACES_NFE.Insert();
End-Function;
/*Gera as linhas do Documento Fiscal via XML - Similar painel entrada direta*/
/*Function GERAR_LN_DOC_FISCAL_VIA_XML(&P_BUSINESS_UNIT, &P_NF_BRL_ID, &P_SETID,
&P_SHIPTO_ID, &P_NF_BRL_LINE_NUM, &P_INV_ITEM_ID, &P_DESCR, &P_UNIT_OF_MEASURE,
&NF_LN_BRL.COFINS_AMT_BSE_BBL.VALUE = 0;
&NF_LN_BRL.PIS_BSS_AMT_BBL.VALUE = &P_PIS_BSS_AMT_BBL;
&NF_LN_BRL.PIS_PCT_BBL.VALUE = &P_PIS_PCT_BBL;
&NF_LN_BRL.PIS_AMT_BBL.VALUE = 0;
&NF_LN_BRL.PIS_AMT_BSE_BBL.VALUE = 0;
&NF_LN_BRL.ISSTAX_BRL_BSS.VALUE = 0;
&NF_LN_BRL.ISSTAX_BRL_PCT.VALUE = 0;
&NF_LN_BRL.ISSTAX_BRL_AMT.VALUE = 0;
&NF_LN_BRL.ISSTAX_BRL_BSE.VALUE = 0;
&NF_LN_BRL.MVA_PCT_BBL.VALUE = 0;
&NF_LN_BRL.LT_IPI_BSE_BBL.VALUE = 0;
&NF_LN_BRL.LT_ICMS_BSE_BBL.VALUE = 0;
&NF_LN_BRL.LT_ICMS_ST_BSE_BBL.VALUE = 0;
&NF_LN_BRL.LT_PIS_BSE_BBL.VALUE = 0;
&NF_LN_BRL.LT_COFINS_BSE_BBL.VALUE = 0;
&NF_LN_BRL.LT_ISS_BSE_BBL.VALUE = 0;
&NF_LN_BRL.FIN_CHG_PCT_BBL.VALUE = 0;
&NF_LN_BRL.FINCHG_AMT_BBL.VALUE = 0;
&NF_LN_BRL.FINCHG_AMT_BSE_BBL.VALUE = 0;
&NF_LN_BRL.NET_UNIT_PRICE.VALUE = 0;
&NF_LN_BRL.NF_ACT_TMPL_BBL.VALUE = " ";
&NF_LN_BRL.ICMSTAX_STS_BBL.VALUE = " ";
&NF_LN_BRL.ICMSSUB_STS_BBL.VALUE = " ";
&NF_LN_BRL.IPITAX_STS_BBL.VALUE = " ";
&NF_LN_BRL.ISSTAX_STS_BBL.VALUE = " ";
&NF_LN_BRL.IRTAX_STS_BBL.VALUE = " ";
&NF_LN_BRL.INSSTAX_STS_BBL.VALUE = " ";
&NF_LN_BRL.IPI_IN_ICMSBAS_BBL.VALUE = " ";
&NF_LN_BRL.ICMS_RED_BSE_BBL.VALUE = 0;
&NF_LN_BRL.ICMSST_RED_BSE_BBL.VALUE = 0;
&NF_LN_BRL.IPI_RED_BSE_BBL.VALUE = 0;
&NF_LN_BRL.ISS_RED_BSE_BBL.VALUE = 0;
&NF_LN_BRL.ICMSSUB_BRL_BSS.VALUE = 0;
&NF_LN_BRL.IR_RED_BSE_BBL.VALUE = 0;
&NF_LN_BRL.INSS_RED_BSE_BBL.VALUE = 0;
&NF_LN_BRL.ICMSST_PCT_BBL.VALUE = 0;
&NF_LN_BRL.GROSS_AMT_BSE.VALUE = 0;
&NF_LN_BRL.DST_ID_DIS.VALUE = " ";
&NF_LN_BRL.DST_ID_REV.VALUE = " ";
&NF_LN_BRL.DST_ID_SUR.VALUE = " ";
&NF_LN_BRL.INVENTORY_ITEM.VALUE = "Y";
&NF_LN_BRL.COST_ADJ_STS_PBL.VALUE = "X";
&NF_LN_BRL.FRT_INCR_BSE_BBL.VALUE = 0;
&NF_LN_BRL.INSR_INCR_BSE_BBL.VALUE = 0;
&NF_LN_BRL.OTEX_INCR_BSE_BBL.VALUE = 0;
/*&NF_LN_BRL.WTHD_CD.VALUE = " ";*/ /*MMCB.SDS4359.LO*/
&NF_LN_BRL.WTHD_CD.VALUE = &WTHD_CD; /*MMCB.SDS4359.LN*/
&NF_LN_BRL.PROCESS_INSTANCE.VALUE = 0;
&NF_LN_BRL.DESCR254_MIXED.VALUE = &P_DESCR;
&NF_LN_BRL.PYMNT_TERMS_CD.VALUE = "30D";
&NF_LN_BRL.PAY_TRM_BSE_DT_OPT.VALUE = " ";
&NF_LN_BRL.ICMS_COMPL_FLG_PBL.VALUE = "N";
&NF_LN_BRL.COFINST_BSSAMT_BBL.VALUE = 0;
&NF_LN_BRL.COFINSST_PCT_BBL.VALUE = 0;
&NF_LN_BRL.COFINSST_AMT_BBL.VALUE = 0;
&NF_LN_BRL.COFINST_BSEAMT_BBL.VALUE = 0;
&NF_LN_BRL.LT_COFINSSTBSE_BBL.VALUE = 0;
&NF_LN_BRL.PISST_BSS_AMT_BBL.VALUE = 0;
&NF_LN_BRL.PISST_PCT_BBL.VALUE = 0;
&NF_LN_BRL.PISST_AMT_BBL.VALUE = 0;
&NF_LN_BRL.PISST_BSE_AMT_BBL.VALUE = 0;
&NF_LN_BRL.LT_PISS_BSE_BBL.VALUE = 0;
&NF_LN_BRL.IR_BSS_AMT_BBL.VALUE = 0;
&NF_LN_BRL.IR_PCT_BBL.VALUE = 0;
&NF_LN_BRL.IR_BSE_AMT_BBL.VALUE = 0;
&NF_LN_BRL.IR_AMT_BBL.VALUE = 0;
&NF_LN_BRL.LT_IRBSE_BBL.VALUE = 0;
&NF_LN_BRL.INSS_BSS_AMT_BBL.VALUE = 0;
&NF_LN_BRL.INSS_PCT_BBL.VALUE = 0;
&NF_LN_BRL.INSS_BSE_AMT_BBL.VALUE = 0;
&NF_LN_BRL.INSS_AMT_BBL.VALUE = 0;
&NF_LN_BRL.LT_INSSBSE_BBL.VALUE = 0;
&NF_LN_BRL.IF_BRL.VALUE = " ";
&NF_LN_BRL.DISTRIB_MTHD_FLG.VALUE = "A";
/*PAYTRMS_DT_BSE_PBL = Null;*/
&NF_LN_BRL.FLOW_STATUS_PBL.VALUE = "A";
&NF_LN_BRL.RTV_ID.VALUE = " ";
&NF_LN_BRL.RTV_LN_NBR.VALUE = 0;
&NF_LN_BRL.FLOW_ID_BBL.VALUE = " ";
&NF_LN_BRL.FLOW_BUS_UNIT_IN.VALUE = " ";
&NF_LN_BRL.STORAGE_AREA.VALUE = " ";
&NF_LN_BRL.STOR_LEVEL_1.VALUE = " ";
&NF_LN_BRL.STOR_LEVEL_2.VALUE = " ";
&NF_LN_BRL.STOR_LEVEL_3.VALUE = " ";
&NF_LN_BRL.STOR_LEVEL_4.VALUE = " ";
&NF_LN_BRL.FLOW_SHIP_ID_BBL.VALUE = " ";
&NF_LN_BRL.FLOW_LOCATION_BBL.VALUE = " ";
&NF_LN_BRL.ICMS_DISCOUNT_BBL.VALUE = 0;
/*DT_FLOW_BBL = Null;*/
&NF_LN_BRL.COEF_BASE_FLG_PBL.VALUE = " ";
&NF_LN_BRL.COEF_BASE_ICMS_PBL.VALUE = 0;
&NF_LN_BRL.COEF_BASE_IPI_PBL.VALUE = 0;
&NF_LN_BRL.MERCH_ORIG_AMT_PBL.VALUE = &P_MERCH_ORIG_AMT_PBL;
&NF_LN_BRL.IPITAX_BRL_RED.VALUE = 0;
&NF_LN_BRL.COEF_BASE_COFI_PBL.VALUE = 1;
&NF_LN_BRL.CF_IPI_ID_PBL.VALUE = " ";
&NF_LN_BRL.CF_ICMS_ID_PBL.VALUE = " ";
&NF_LN_BRL.CF_PIS_ID_PBL.VALUE = " ";
&NF_LN_BRL.CF_COFINS_ID_PBL.VALUE = " ";
&NF_LN_BRL.COEF_BASE_PIS_PBL.VALUE = 0;
&NF_LN_BRL.COFI_CRLIM_PCT_PBL.VALUE = 0;
&NF_LN_BRL.PIS_CRLIM_PCT_PBL.VALUE = 0;
&NF_LN_BRL.COFINSTAX_BRL_AMT.VALUE = &P_COFINSTAX_BRL_AMT;
&NF_LN_BRL.PISTAX_BRL_AMT.VALUE = &P_PISTAX_BRL_AMT;
&NF_LN_BRL.PIS_TAX_STATUS_PBL.VALUE = " ";
&NF_LN_BRL.COFI_TX_STATUS_PBL.VALUE = " ";
&NF_LN_BRL.Insert();
/*Gravar os dados na tabela BRL_DISTRIB_LN (Distribuio do documento fiscal)*/
&BRL_DISTRIB_LN = CreateRecord(Record.BRL_DISTRIB_LN);
&BRL_DISTRIB_LN.BUSINESS_UNIT.VALUE = &P_BUSINESS_UNIT;
&BRL_DISTRIB_LN.NF_BRL_ID.VALUE = &P_NF_BRL_ID;
&BRL_DISTRIB_LN.NF_BRL_LINE_NUM.VALUE = &P_NF_BRL_LINE_NUM;
&BRL_DISTRIB_LN.DISTRIB_LINE_NUM.VALUE = 1;
&BRL_DISTRIB_LN.SUSPENSE_REF_NUM.VALUE = 0;
/********************* mmcb.hd219468.so *********************/
/* &BRL_DISTRIB_LN.BUSINESS_UNIT_GL.VALUE = &P_SETID;
*/
/********************* mmcb.hd219468.eo *********************/
&BRL_DISTRIB_LN.DIST_LINE_REL_PBL.VALUE = 0;
&BRL_DISTRIB_LN.MERCH_ORIG_AMT_PBL.VALUE = &P_MERCH_ORIG_AMT_PBL;
&BRL_DISTRIB_LN.Insert();
/*Gravar os dados na tabela NF_MTCH_PBL*/
&NF_MTCH_PBL = CreateRecord(Record.NF_MTCH_PBL);
&NF_MTCH_PBL.BUSINESS_UNIT.VALUE = &P_BUSINESS_UNIT;
&NF_MTCH_PBL.NF_BRL_ID.VALUE = &P_NF_BRL_ID;
&NF_MTCH_PBL.NF_BRL_LINE_NUM.VALUE = &P_NF_BRL_LINE_NUM;
&NF_MTCH_PBL.BUSINESS_UNIT_PO.VALUE = " ";
&NF_MTCH_PBL.PO_ID.VALUE = " ";
&NF_MTCH_PBL.LINE_NBR.VALUE = 0;
&NF_MTCH_PBL.SCHED_NBR.VALUE = 0;
/*&NF_MTCH_PBL.RECEIVER_ID.VALUE = " "; */ /*mmcb.sds4359.lo*/
&NF_MTCH_PBL.RECEIVER_ID.VALUE = &P_RECEIVER_ID; /*mmcb.sds4359.ln*/
&NF_MTCH_PBL.RECV_LN_NBR.VALUE = 0;
&NF_MTCH_PBL.RECV_SHIP_SEQ_NBR.VALUE = 0;
&NF_MTCH_PBL.MERCH_AMT_NF_PBL.VALUE = 0;
&NF_MTCH_PBL.MERCH_AMT_PO.VALUE = 0;
&NF_MTCH_PBL.MERCH_AMT_RECV.VALUE = 0;
&NF_MTCH_PBL.UNIT_PRICE.VALUE = 0;
&NF_MTCH_PBL.PRICE_PO.VALUE = 0;
&NF_MTCH_PBL.PRICE_PO_RECV.VALUE = 0;
&NF_MTCH_PBL.UNIT_PRICE_CNVT.VALUE = 0;
&NF_MTCH_PBL.UNIT_PRICE_CNVTR.VALUE = 0;
&NF_MTCH_PBL.UNIT_PRC_TOL.VALUE = 0;
&NF_MTCH_PBL.PCT_UNIT_PRC_TOL.VALUE = 0;
&NF_MTCH_PBL.EXT_PRC_TOL.VALUE = 0;
&NF_MTCH_PBL.PCT_EXT_PRC_TOL.VALUE = 0;
&NF_MTCH_PBL.UNIT_PRC_TOL_L.VALUE = 0;
&NF_MTCH_PBL.PCT_UNIT_PRC_TOL_L.VALUE = 0;
&NF_MTCH_PBL.EXT_PRC_TOL_L.VALUE = 0;
&NF_MTCH_PBL.PCT_EXT_PRC_TOL_L.VALUE = 0;
&NF_MTCH_PBL.FREIGHT_AMT.VALUE = 0;
&NF_MTCH_PBL.FREIGHT_PO_PBL.VALUE = 0;
&NF_MTCH_PBL.INSURANCE_BRL_AMT.VALUE = 0;
&NF_MTCH_PBL.INSUR_AMT_PO_PBL.VALUE = 0;
&NF_MTCH_PBL.OTHEREXP_BRL_AMT.VALUE = 0;
&NF_MTCH_PBL.OTEXP_AMT_PO_PBL.VALUE = 0;
&NF_MTCH_PBL.DSCNT_AMT.VALUE = 0;
&NF_MTCH_PBL.DSCNT_AMT_PO_PBL.VALUE = 0;
&NF_MTCH_PBL.ICMSSUB_BRL_AMT.VALUE = 0;
&NF_MTCH_PBL.ICMSSUB_PO_PBL.VALUE = 0;
&NF_MTCH_PBL.ICMSTAX_BRL_PCT.VALUE = 0;
&NF_MTCH_PBL.ICMS_PCT_EXC_PBL.VALUE = 0;
&NF_MTCH_PBL.ICMSTAX_BRL_BSS.VALUE = 0;
&NF_MTCH_PBL.ICMS_BSS_EXC_PBL.VALUE = 0;
&NF_MTCH_PBL.ICMSTAX_BRL_RED.VALUE = 0;
&NF_MTCH_PBL.ICMS_RED_EXC_PBL.VALUE = 0;
&NF_MTCH_PBL.IPITAX_BRL_PCT.VALUE = 0;
&NF_MTCH_PBL.IPI_PCT_EXC_PBL.VALUE = 0;
&NF_MTCH_PBL.IPITAX_BRL_BSS.VALUE = 0;
&NF_MTCH_PBL.IPI_BSS_EXC_PBL.VALUE = 0;
&NF_MTCH_PBL.PURCH_PROP_BRL.VALUE = " ";
&NF_MTCH_PBL.PURCH_PROP_PO_PBL.VALUE = " ";
&NF_MTCH_PBL.TOF_PBL.VALUE = " ";
&NF_MTCH_PBL.TOF_PO_PBL.VALUE = " ";
&NF_MTCH_PBL.ICMS_COMPL_FLG_PBL.VALUE = "N";
&NF_MTCH_PBL.ICMSCOMPL_PO_PBL.VALUE = "N";
End-If;
/*########################################################################
#
# FIM INSERINDO TABELA RECV_HDR
#
########################################################################*/
/*########################################################################
#
# INSERINDO TABELA RECV_LN_ASSET
#
########################################################################*/
&P1_BUSINESS_UNIT = &PAR_BUSINESS_UNIT;
&P1_RECEIVER_ID = &PAR_RECEIVER_ID;
&P1_RECV_LN_NBR = &PAR_RECV_LN_NBR;
&P1_RECV_SHIP_SEQ_NBR = &PAR_RECV_SHIP_SEQ_NBR;
&P1_DISTRIB_LINE_NUM = 1;
&P1_DISTRIB_SEQ_NUM = 1;
&P1_ACTUAL_COST = &CUSTO_UNITARIO;
&P1_ASSET_ID = " ";
&P1_AUTO_BIN2BIN = "N";
&P1_BUSINESS_UNIT_AM = " ";
&P1_BUSINESS_UNIT_IN = &PAR_BUSINESS_UNIT_IN;
&P1_CONTAINER_ID = " ";
&P1_COST = &PAR_QTD * &CUSTO_UNITARIO;
&P1_CURRENCY_CD = &V_CURRENCY_CD;
&P1_CUSTODIAN = " ";
&P1_DESCR = &V_DESCR;
&P1_DTTM_STAMP = %Datetime;
&P1_FINANCIAL_ASSET_SW = "N";
&P1_FROM_STOR_AREA = " ";
&P1_FROM_STOR_LEV1 = " ";
&P1_FROM_STOR_LEV2 = " ";
&P1_FROM_STOR_LEV3 = " ";
&P1_FROM_STOR_LEV4 = " ";
&P1_INV_ITEM_ID = &PAR_INV_ITEM_ID;
&P1_ITM_SETID = &PAR_SETID;
&P1_LOCATION = &V_CRTL_LOCATION_BBL;
&P1_LOT_ID = &V_DFLT_INV_LOT_ID;
&P1_MANUFACTURER = " ";
&P1_MODEL = &V_MODEL;
&P1_PRE_INTFC_ID = 0;
&P1_PRE_INTFC_LINE_NUM = 0;
&P1_PRICE_PO_BSE = 0;
&P1_PROCESS_INSTANCE = 0;
&P1_PROFILE_ID = " ";
&P1_QTY_MOVED_ASSET = 0;
&P1_QTY_MOVED_INV = 0;
&P1_QUANTITY = &PAR_QTD;
&P1_RECV_AM_STATUS = "O";
&P1_SERIAL_ID = &V_DFLT_SERIAL_ID;
&P1_SF_KANBAN_ID = " ";
&P1_STORAGE_AREA = " ";
&P1_STORAGE_CODE = " ";
&P1_STOR_LEVEL_1 = " ";
&P1_STOR_LEVEL_2 = " ";
&P1_STOR_LEVEL_3 = " ";
&P1_STOR_LEVEL_4 = " ";
&P1_TAG_NUMBER = " ";
&P1_VENDOR_ID = &PAR_VENDOR_ID;
&P1_VENDOR_LOT_ID = " ";
&P1_PRICE_FOR_INV_PBL = 0;
&P1_COST_AM_PBL = 0;
&P1_PROC_NF_CANCEL_PBL = " ";
&P2_MERCH_AMT_PO_BSE = &CUSTO_UNITARIO;
&P2_MERCHANDISE_AMT = &CUSTO_UNITARIO * &PAR_QTD;
&P2_MERCHANDISE_AMT_PO = &CUSTO_UNITARIO;
&P2_MOV_DS_ACCPT_SUOM = 0;
&P2_PO_DIST_LINE_NUM = 0;
&P2_PO_ID = &PAR_PO_ID;
&P2_PROCESS_INSTANCE = 0;
&P2_PROFILE_ID = " ";
&P2_QTY_DS_ACCPT_SUOM = &PAR_QTD * &V_CONVERSION_RATE;
&P2_QTY_DS_ACCPT_VUOM = &PAR_QTD;
&P2_QTY_PO = &PAR_QTD;
&P2_RATE_DIV = 1;
&P2_RATE_MULT = 1;
&P2_RECV_DS_STATUS = "R";
&P2_REQ_ID = " ";
&P2_RESOURCE_CATEGORY = " ";
&P2_RESOURCE_SUB_CAT = " ";
&P2_RESOURCE_TYPE = " ";
&P2_RT_TYPE = "CRRNT";
&P2_SCHED_NBR = &PAR_PO_SCHED_NBR;
&P2_STATISTICS_CODE = 0;
&P2_STATISTIC_AMOUNT = 0;
&P2_TAX_CD_SUT_PCT = 0;
&P2_TAX_CD_VAT_PCT = 0;
&P2_OPERATING_UNIT = " ";
&P2_DEPTID = &PAR_DEPTID;
&P2_PRODUCT = " ";
&P2_PROJECT_ID = " ";
&P2_AFFILIATE = " ";
GRAVA_RECV_LN_DISTRIB(&P2_BUSINESS_UNIT, &P2_RECEIVER_ID, &P2_RECV_LN_NBR, &P
2_RECV_SHIP_SEQ_NBR, &P2_DISTRIB_LINE_NUM, &P2_ACCOUNT, &P2_ALTACCT, &P2_ACTIVIT
Y_ID, &P2_ANALYSIS_TYPE, &P2_BUSINESS_UNIT_AM, &P2_BUSINESS_UNIT_GL, &P2_BUSINES
S_UNIT_IN, &P2_BUSINESS_UNIT_PC, &P2_BUSINESS_UNIT_PO, &P2_CAP_NUM, &P2_CAP_SEQU
ENCE, &P2_CHARTFIELD_STATUS, &P2_CONSIGNED_FLAG, &P2_COST_TYPE, &P2_COSTED_FLAG,
&P2_CURRENCY_CD, &P2_CURRENCY_CD_BASE, &P2_DELIVERED_FLG, &P2_DELIVERED_TO, &P2
_DISTRIB_TYPE, &P2_DST_ACCT_TYPE, &P2_EMPLID, &P2_FINANCIAL_ASSET_SW, &P2_FREIGH
T_PERCENT, &P2_LINE_NBR, &P2_LOCATION, &P2_LOC_RECV_LBL_FLG, &P2_MERCH_AMT_BSE,
&P2_MERCH_AMT_PO_BSE, &P2_MERCHANDISE_AMT, &P2_MERCHANDISE_AMT_PO, &P2_MOV_DS_AC
CPT_SUOM, &P2_PO_DIST_LINE_NUM, &P2_PO_ID, &P2_PROCESS_INSTANCE, &P2_PROFILE_ID,
&P2_QTY_DS_ACCPT_SUOM, &P2_QTY_DS_ACCPT_VUOM, &P2_QTY_PO, &P2_RATE_DIV, &P2_RAT
E_MULT, &P2_RECV_DS_STATUS, &P2_REQ_ID, &P2_RESOURCE_CATEGORY, &P2_RESOURCE_SUB_
CAT, &P2_RESOURCE_TYPE, &P2_RT_TYPE, &P2_SCHED_NBR, &P2_STATISTICS_CODE, &P2_STA
TISTIC_AMOUNT, &P2_TAX_CD_SUT_PCT, &P2_TAX_CD_VAT_PCT, &P2_OPERATING_UNIT, &P2_D
EPTID, &P2_PRODUCT, &P2_PROJECT_ID, &P2_AFFILIATE);
/*########################################################################
#
# FIM INSERINDO TABELA RECV_LN_DISTRIB
#
########################################################################*/
/*########################################################################
#
# INSERINDO TABELA RECV_LN_INSP
#
########################################################################*/
&P3_BUSINESS_UNIT = &PAR_BUSINESS_UNIT;
&P3_RECEIVER_ID = &PAR_RECEIVER_ID;
&P3_RECV_LN_NBR = &PAR_RECV_LN_NBR;
&P3_OP_SEQ = 0;
&P3_ROUTING_SETID = " ";
&P3_ROUTING_ID = &V_ROUTING_ID;
&P3_OP_TIME_STD = 0;
&P3_OP_TIME_CD = "P";
&P3_OP_TIME_STD_TTL = 0;
&P3_OP_TIME_ACT_TTL = 0;
&P3_PROCESS_INSTANCE = 0;
GRAVA_RECV_LN_INSP(&P3_BUSINESS_UNIT, &P3_RECEIVER_ID, &P3_RECV_LN_NBR, &P3_O
P_SEQ, &P3_ROUTING_SETID, &P3_ROUTING_ID, &P3_OP_TIME_STD, &P3_OP_TIME_CD, &P3_O
P_TIME_STD_TTL, &P3_OP_TIME_ACT_TTL, &P3_PROCESS_INSTANCE);
/*########################################################################
#
# FIM INSERINDO TABELA RECV_LN_INSP
#
########################################################################*/
/*########################################################################
#
# INSERINDO TABELA RECV_LN_SHIP
#
########################################################################*/
&P4_BUSINESS_UNIT = &PAR_BUSINESS_UNIT;
&P4_RECEIVER_ID = &PAR_RECEIVER_ID;
&P4_RECV_LN_NBR = &PAR_RECV_LN_NBR;
&P4_RECV_SHIP_SEQ_NBR = &PAR_RECV_SHIP_SEQ_NBR;
&P4_AMT_ONLY_FLG = "N";
&P4_ASN_SEQ_NBR = 0;
&P4_BILL_OF_LADING = " ";
&P4_BUSINESS_UNIT_IN = &PAR_BUSINESS_UNIT_IN;
&P4_BUSINESS_UNIT_PO = &PAR_BUSINESS_UNIT_PO;
&P4_CATEGORY_ID = &V_CATEGORY_ID;
&P4_CONFIG_CODE = &PAR_SERIAL_ID;
&P4_CONVERSION_RATE = &V_CONVERSION_RATE;
&P4_CONVERT_TO_STK = &V_CONVERSION_RATE;
&P4_CONVERT_TO_PO = &V_CONVERSION_RATE;
&P4_CONVERT_STK_TO_STD = &V_CONVERSION_RATE;
&P4_COUNTRY_IST_ORIGIN = " ";
&P4_CURRENCY_CD = "BRL";
&P4_CURRENCY_CD_BASE = "BRL";
&P4_DESCR254_MIXED = &PAR_DESCR_ITEM;
&P4_DEVICE_TRACKING = &V_DEVICE_TRACKING;
&P4_DISTRIB_MTHD_FLG = "Q";
&P4_DUE_DT = %Date;
&P4_DUE_TIME = %Time;
&P4_EIP_CTL_ID = " ";
&P4_ERS_INV_SEQ = 0;
&P4_ERS_STATUS = "N";
&P4_INSPECT_CD = &V_INSPECT_CD;
&P4_INSPECT_DTTM = %Datetime;
&P4_INSPECT_STATUS = "C";
&P4_INV_ITEM_ID = &PAR_INV_ITEM_ID;
&P4_IST_DISTRIB_STATUS = "I";
&P4_ITM_ID_VNDR = " ";
&P4_ITM_SETID = &V_ITM_SETID;
&P4_LINE_NBR = &PAR_PO_LINE_NBR;
&P4_LOT_CONTROL = &V_LOT_CONTROL;
&P4_LOT_STATUS = "C";
&P4_MATCH_LINE_FLG = "Y";
&P4_MATCH_STATUS_LC = 0;
&P4_MERCH_AMT_BSE = &PAR_QTD * &CUSTO_UNITARIO;
&P4_MERCH_AMT_PO_BSE = &CUSTO_UNITARIO;
&P4_MERCHANDISE_AMT = &PAR_QTD * &CUSTO_UNITARIO;
&P4_MERCHANDISE_AMT_PO = &CUSTO_UNITARIO;
&P4_MFG_ID = " ";
&P4_MFG_ITM_ID = " ";
&P4_MOVE_STAT_AM = "N";
&P4_MOVE_STAT_INV = "P";
&P4_MOVE_STAT_MFG = "N";
&P4_OP_SEQUENCE = 0;
&P4_OPRID = %UserId;
&P4_PACKSLIP_NO = " ";
&P4_PO_ID = &PAR_PO_ID;
&P4_PO_TYPE = " ";
&P4_PRICE_PO = &CUSTO_UNITARIO;
&P4_PRICE_PO_BSE = &CUSTO_UNITARIO;
&P4_PRO_NUMBER = " ";
&P4_PROCESS_COMPLETE = "N";
&P4_PROCESS_INSTANCE = 0;
&P4_PRODUCTION_ID = " ";
&P4_QTY_LN_ASSET_SUOM = 0;
&P4_QTY_LN_INV_SUOM = &PAR_QTD * &V_CONVERSION_RATE;
&P4_QTY_SH_ACCPT = &PAR_QTD;
&P4_QTY_SH_ACCPT_SUOM = &PAR_QTD;
&P4_QTY_SH_ACCPT_VUOM = &PAR_QTD;
&P4_QTY_SH_INSPD = 0;
&P4_QTY_SH_INSPD_SUOM = 0;
&P4_QTY_SH_INSPD_VUOM = 0;
&P4_QTY_SH_NETRCV_VUOM = &PAR_QTD;
&P4_QTY_SH_RECVD = &PAR_QTD;
&P4_QTY_SH_RECVD_SUOM = &PAR_QTD * &V_CONVERSION_RATE;
&P4_QTY_SH_RECVD_VUOM = &PAR_QTD;
&P4_QTY_SH_REJCT = 0;
&P4_QTY_SH_REJCT_SUOM = 0;
&P4_QTY_SH_REJCT_VUOM = 0;
&P4_QTY_SH_RTN = 0;
&P4_QTY_SH_RTN_SUOM = 0;
&P4_QTY_SH_RTN_VUOM = 0;
&P4_REJECT_ACTION = " ";
&P4_REJECT_REASON = " ";
&P4_REVISION = " ";
&P4_RMA_ID = " ";
&P4_RMA_LINE_NBR = 0;
&P4_RECEIPT_ALLOC_TYPE = "1";
&P4_RECEIPT_DTTM = %Datetime;
&P4_RECEIPT_UM = &PAR_UNIT_OF_MEASURE;
&P4_RECEIVE_UOM = &PAR_UNIT_OF_MEASURE;
&P4_RECV_LN_MATCH_OPT = "N";
&P4_RECV_SHIP_STATUS = "R";
&P4_RECV_STOCK_UOM = &V_UNIT_MEASURE_STD;
&P4_REPLACEMENT_FLG = "NA";
&P4_SCHED_NBR = &PAR_PO_SCHED_NBR;
&P4_SERIAL_CONTROL = &V_SERIAL_CONTROL;
&P4_SERIAL_STATUS = "C";
&P4_SHIP_DATE_STATUS = "3";
&P4_SHIP_QTY_STATUS = "1";
&P4_SHIPTO_ID = &PAR_SHIPTO_ID;
&P4_UNIT_MEASURE_STD = &V_UNIT_MEASURE_STD;
GRAVA_RECV_LN_SHIP(&P4_BUSINESS_UNIT, &P4_RECEIVER_ID, &P4_RECV_LN_NBR, &P4_R
ECV_SHIP_SEQ_NBR, &P4_AMT_ONLY_FLG, &P4_ASN_SEQ_NBR, &P4_BILL_OF_LADING, &P4_BUS
INESS_UNIT_IN, &P4_BUSINESS_UNIT_PO, &P4_CATEGORY_ID, &P4_CONFIG_CODE, &P4_CONVE
RSION_RATE, &P4_CONVERT_TO_STK, &P4_CONVERT_TO_PO, &P4_CONVERT_STK_TO_STD, &P4_C
OUNTRY_IST_ORIGIN, &P4_CURRENCY_CD, &P4_CURRENCY_CD_BASE, &P4_DESCR254_MIXED, &P
4_DEVICE_TRACKING, &P4_DISTRIB_MTHD_FLG, &P4_DUE_DT, &P4_DUE_TIME, &P4_EIP_CTL_I
D, &P4_ERS_INV_SEQ, &P4_ERS_STATUS, &P4_INSPECT_CD, &P4_INSPECT_DTTM, &P4_INSPEC
T_STATUS, &P4_INV_ITEM_ID, &P4_IST_DISTRIB_STATUS, &P4_ITM_ID_VNDR, &P4_ITM_SETI
D, &P4_LINE_NBR, &P4_LOT_CONTROL, &P4_LOT_STATUS, &P4_MATCH_LINE_FLG, &P4_MATCH_
STATUS_LC, &P4_MERCH_AMT_BSE, &P4_MERCH_AMT_PO_BSE, &P4_MERCHANDISE_AMT, &P4_MER
CHANDISE_AMT_PO, &P4_MFG_ID, &P4_MFG_ITM_ID, &P4_MOVE_STAT_AM, &P4_MOVE_STAT_INV
, &P4_MOVE_STAT_MFG, &P4_OP_SEQUENCE, &P4_OPRID, &P4_PACKSLIP_NO, &P4_PO_ID, &P4
_PO_TYPE, &P4_PRICE_PO, &P4_PRICE_PO_BSE, &P4_PRO_NUMBER, &P4_PROCESS_COMPLETE,
&P4_PROCESS_INSTANCE, &P4_PRODUCTION_ID, &P4_QTY_LN_ASSET_SUOM, &P4_QTY_LN_INV_S
UOM, &P4_QTY_SH_ACCPT, &P4_QTY_SH_ACCPT_SUOM, &P4_QTY_SH_ACCPT_VUOM, &P4_QTY_SH_
INSPD, &P4_QTY_SH_INSPD_SUOM, &P4_QTY_SH_INSPD_VUOM, &P4_QTY_SH_NETRCV_VUOM, &P4
_QTY_SH_RECVD, &P4_QTY_SH_RECVD_SUOM, &P4_QTY_SH_RECVD_VUOM, &P4_QTY_SH_REJCT, &
P4_QTY_SH_REJCT_SUOM, &P4_QTY_SH_REJCT_VUOM, &P4_QTY_SH_RTN, &P4_QTY_SH_RTN_SUOM
, &P4_QTY_SH_RTN_VUOM, &P4_REJECT_ACTION, &P4_REJECT_REASON, &P4_REVISION, &P4_R
MA_ID, &P4_RMA_LINE_NBR, &P4_RECEIPT_ALLOC_TYPE, &P4_RECEIPT_DTTM, &P4_RECEIPT_U
M, &P4_RECEIVE_UOM, &P4_RECV_LN_MATCH_OPT, &P4_RECV_SHIP_STATUS, &P4_RECV_STOCK_
UOM, &P4_REPLACEMENT_FLG, &P4_SCHED_NBR, &P4_SERIAL_CONTROL, &P4_SERIAL_STATUS,
&P4_SHIP_DATE_STATUS, &P4_SHIP_QTY_STATUS, &P4_SHIPTO_ID, &P4_UNIT_MEASURE_STD);
/*########################################################################
#
# FIM INSERINDO TABELA RECV_LN_SHIP
#
########################################################################*/
/*########################################################################
#
# INSERINDO TABELA RECV_LN_SHP_MTH
#
########################################################################*/
&P5_BUSINESS_UNIT = &PAR_BUSINESS_UNIT;
&P5_RECEIVER_ID = &PAR_RECEIVER_ID;
&P5_RECV_LN_NBR = &PAR_RECV_LN_NBR;
&P5_RECV_SHIP_SEQ_NBR = &PAR_RECV_SHIP_SEQ_NBR;
&P5_TXN_CURRENCY_CD = " ";
&P5_QTY_MATCHED = 0;
&P5_AMT_MATCHED = 0;
GRAVA_RECV_LN_SHP_MTH(&P5_BUSINESS_UNIT, &P5_RECEIVER_ID, &P5_RECV_LN_NBR, &P
5_RECV_SHIP_SEQ_NBR, &P5_TXN_CURRENCY_CD, &P5_QTY_MATCHED, &P5_AMT_MATCHED);
/*########################################################################
#
# FIM INSERINDO TABELA RECV_LN_SHP_MTH
#
########################################################################*/
||
||
|| GRAVANDO O RECEBIMENTO
||
||
||
|||||||||||||||||||||||||||||||||||||
*/
/*########################################################################
#
# INSERINDO TABELA RECV_HDR
#
########################################################################*/
SQLExec("select 'X' from sysadm.ps_recv_hdr where business_unit=:1 and rec
eiver_id=:2 ", &V_BUSINESS_UNIT_PO, &PAR_RECEIVER_ID, &EXISTE_RECEBTO);
If &EXISTE_RECEBTO <> "X" Then
&P6_BUSINESS_UNIT = &V_BUSINESS_UNIT_PO;
&P6_RECEIVER_ID = &PAR_RECEIVER_ID;
&P6_SHIPTO_ID = &V_SHIPTO_ID;
&P6_VENDOR_ID = &V_VENDOR_ID;
&P6_VEHICLE_ID = " ";
&P6_BILL_OF_LADING = " ";
&P6_CARRIER_ID = " ";
&P6_CONTAINER_ID = " ";
&P6_COUNTRY_SHIP_FROM = "BRA";
&P6_DFLT_PACKSLIP_NO = " ";
&P6_DRIVER_ID = " ";
&P6_EIP_CTL_ID = " ";
&P6_ERS_FLAG = "N";
&P6_ERS_INV_DT_OPT = " ";
&P6_ERS_INV_STATUS = "N";
&P6_FREIGHT_TERMS = " ";
&P6_HOLD_ASSET = "N";
&P6_HOLD_INVENTORY = "N";
&P6_IN_PROCESS_FLG = "N";
&P6_INTFC_ASSET = "Y";
&P6_INTFC_INVENTORY = "Y";
&P6_INTFC_MG = "Y";
&P6_MATCH_CNTRL_ID = &V_MATCH_CNTRL_ID;
&P6_MATCH_PROCESS_FLG = "N";
&P6_MATCH_STATUS_RECV = "N";
&P6_NUM_OF_CARTONS = 0;
&P6_OPRID = %OperatorId;
&P6_ORIGIN = " ";
&P6_PALLETS_RECV = 0;
&P6_PALLETS_RTN = 0;
&P6_PO_RECEIPT_FLG = "Y";
&P6_PORT_OF_UNLOADING = " ";
&P6_PRO_NUMBER = " ";
&P6_PROCESS_INSTANCE = 99999;
&P6_RECEIPT_DT = %Date;
&P6_RECEIPT_TM = %Time;
&P6_RECV_SOURCE = "1";
&P6_RECV_STATUS = "M";
&P6_SETID = &V_ITM_SETID;
&P6_SHIP_DATE = %Date;
/*########################################################################
#
# FIM INSERINDO TABELA RECV_HDR
#
########################################################################*/
If &PAR_CUSTO_TERCEIRO_FLG = "Y" Then
&CUSTO_UNITARIO = &PAR_CUSTO_TERCEIRO;
Else
&CUSTO_UNITARIO = &PAR_PRECO_UNITARIO;
End-If;
&TOTAL_LN_RECV = &PAR_QTD_ACEITA * &CUSTO_UNITARIO;
/*########################################################################
#
# INSERINDO TABELA RECV_LN_ASSET
#
########################################################################*/
&P1_BUSINESS_UNIT = &V_BUSINESS_UNIT_PO;
&P1_RECEIVER_ID = &PAR_RECEIVER_ID;
&P1_RECV_LN_NBR = &PAR_RECV_LN_NBR;
&P1_RECV_SHIP_SEQ_NBR = &PAR_RECV_SHIP_SEQ_NBR;
&P1_DISTRIB_LINE_NUM = &V_DISTRIB_LINE_NUM;
&P1_DISTRIB_SEQ_NUM = 1;
&P1_ACTUAL_COST = &CUSTO_UNITARIO;
&P1_ASSET_ID = " ";
&P1_AUTO_BIN2BIN = "N";
&P1_BUSINESS_UNIT_AM = &RECVPO_BUSINESS_UNIT_AM;
&P1_BUSINESS_UNIT_IN = &V_BUSINESS_UNIT_IN;
&P1_CONTAINER_ID = " ";
&P1_COST = &TOTAL_LN_RECV;
&P1_CURRENCY_CD = &V_CURRENCY_CD;
&P1_CUSTODIAN = " ";
&P1_DESCR = &VM_DESCR;
&P1_DTTM_STAMP = %Datetime;
&P1_FINANCIAL_ASSET_SW = &RECVPO_FINANCIAL_ASSET_SW;
&P1_FROM_STOR_AREA = " ";
&P1_FROM_STOR_LEV1 = " ";
&P1_FROM_STOR_LEV2 = " ";
&P1_FROM_STOR_LEV3 = " ";
&P1_FROM_STOR_LEV4 = " ";
&P1_INV_ITEM_ID = &V_INV_ITEM_ID;
&P1_ITM_SETID = &V_ITM_SETID;
&P1_LOCATION = &V_CRTL_LOCATION_BBL;
&P1_LOT_ID = &INT_DFLT_INV_LOT_ID;
&P1_MANUFACTURER = &V_MANUFACTURER;
&P1_MODEL = &G_MODEL;
&P1_PRE_INTFC_ID = 0;
&P1_PRE_INTFC_LINE_NUM = 0;
&P1_PRICE_PO_BSE = &V_PRICE_PO_BSE;
&P1_PROCESS_INSTANCE = 0;
&P1_PROFILE_ID = &RECVPO_PROFILE_ID;
&P1_QTY_MOVED_ASSET = 0;
&P1_QTY_MOVED_INV = 0;
&P1_QUANTITY = &PAR_QTD_ACEITA;
&P1_RECV_AM_STATUS = "O";
&P1_SERIAL_ID = &INT_DFLT_SERIAL_ID;
&P1_SF_KANBAN_ID = " ";
&P1_STORAGE_AREA = " ";
&P1_STORAGE_CODE = " ";
&P1_STOR_LEVEL_1 = " ";
&P1_STOR_LEVEL_2 = " ";
&P1_STOR_LEVEL_3 = " ";
&P1_STOR_LEVEL_4 = " ";
&P1_TAG_NUMBER = &V_TAG_NUMBER;
&P1_VENDOR_ID = &V_VENDOR_ID;
&P1_VENDOR_LOT_ID = " ";
&P1_PRICE_FOR_INV_PBL = 0;
&P1_COST_AM_PBL = 0;
&P1_PROC_NF_CANCEL_PBL = " ";
GRAVA_RECV_LN_ASSET(&P1_BUSINESS_UNIT, &P1_RECEIVER_ID, &P1_RECV_LN_NBR, &
P1_RECV_SHIP_SEQ_NBR, &P1_DISTRIB_LINE_NUM, &P1_DISTRIB_SEQ_NUM, &P1_ACTUAL_COST
, &P1_ASSET_ID, &P1_AUTO_BIN2BIN, &P1_BUSINESS_UNIT_AM, &P1_BUSINESS_UNIT_IN, &P
1_CONTAINER_ID, &P1_COST, &P1_CURRENCY_CD, &P1_CUSTODIAN, &P1_DESCR, &P1_DTTM_ST
AMP, &P1_FINANCIAL_ASSET_SW, &P1_FROM_STOR_AREA, &P1_FROM_STOR_LEV1, &P1_FROM_ST
OR_LEV2, &P1_FROM_STOR_LEV3, &P1_FROM_STOR_LEV4, &P1_INV_ITEM_ID, &P1_ITM_SETID,
&P1_LOCATION, &P1_LOT_ID, &P1_MANUFACTURER, &P1_MODEL, &P1_PRE_INTFC_ID, &P1_PR
&P2_PROFILE_ID = &RECVPO_PROFILE_ID;
&P2_QTY_DS_ACCPT_SUOM = &PAR_QTD_ACEITA * &RECV_CONVERSION_RATE;
&P2_QTY_DS_ACCPT_VUOM = &PAR_QTD_ACEITA;
&P2_QTY_PO = &V_QTY_PO;
&P2_RATE_DIV = &V_RATE_DIV;
&P2_RATE_MULT = &V_RATE_MULT;
&P2_RECV_DS_STATUS = "R";
&P2_REQ_ID = &RECVPO_REQ_ID;
&P2_RESOURCE_CATEGORY = &RECVPO_RESOURCE_SUB_CAT;
&P2_RESOURCE_SUB_CAT = &RECVPO_RESOURCE_SUB_CAT;
&P2_RESOURCE_TYPE = &RECVPO_RESOURCE_TYPE;
&P2_RT_TYPE = &RECVPO_RT_TYPE;
&P2_SCHED_NBR = &V_SCHED_NBR;
&P2_STATISTICS_CODE = &RECVPO_STATISTICS_CODE;
&P2_STATISTIC_AMOUNT = &RECVPO_STATISTIC_AMOUNT;
&P2_TAX_CD_SUT_PCT = &RECVPO_TAX_CD_SUT_PCT;
&P2_TAX_CD_VAT_PCT = &RECVPO_TAX_CD_VAT_PCT;
&P2_OPERATING_UNIT = &RECVPO_OPERATING_UNIT;
&P2_DEPTID = &V_DEPTID;
&P2_PRODUCT = &V_PRODUCTION_ID;
&P2_PROJECT_ID = &V_PROJECT_ID;
&P2_AFFILIATE = &RECVPO_AFFILIATE;
GRAVA_RECV_LN_DISTRIB(&P2_BUSINESS_UNIT, &P2_RECEIVER_ID, &P2_RECV_LN_NBR,
&P2_RECV_SHIP_SEQ_NBR, &P2_DISTRIB_LINE_NUM, &P2_ACCOUNT, &P2_ALTACCT, &P2_ACTI
VITY_ID, &P2_ANALYSIS_TYPE, &P2_BUSINESS_UNIT_AM, &P2_BUSINESS_UNIT_GL, &P2_BUSI
NESS_UNIT_IN, &P2_BUSINESS_UNIT_PC, &P2_BUSINESS_UNIT_PO, &P2_CAP_NUM, &P2_CAP_S
EQUENCE, &P2_CHARTFIELD_STATUS, &P2_CONSIGNED_FLAG, &P2_COST_TYPE, &P2_COSTED_FL
AG, &P2_CURRENCY_CD, &P2_CURRENCY_CD_BASE, &P2_DELIVERED_FLG, &P2_DELIVERED_TO,
&P2_DISTRIB_TYPE, &P2_DST_ACCT_TYPE, &P2_EMPLID, &P2_FINANCIAL_ASSET_SW, &P2_FRE
IGHT_PERCENT, &P2_LINE_NBR, &P2_LOCATION, &P2_LOC_RECV_LBL_FLG, &P2_MERCH_AMT_BS
E, &P2_MERCH_AMT_PO_BSE, &P2_MERCHANDISE_AMT, &P2_MERCHANDISE_AMT_PO, &P2_MOV_DS
_ACCPT_SUOM, &P2_PO_DIST_LINE_NUM, &P2_PO_ID, &P2_PROCESS_INSTANCE, &P2_PROFILE_
ID, &P2_QTY_DS_ACCPT_SUOM, &P2_QTY_DS_ACCPT_VUOM, &P2_QTY_PO, &P2_RATE_DIV, &P2_
RATE_MULT, &P2_RECV_DS_STATUS, &P2_REQ_ID, &P2_RESOURCE_CATEGORY, &P2_RESOURCE_S
UB_CAT, &P2_RESOURCE_TYPE, &P2_RT_TYPE, &P2_SCHED_NBR, &P2_STATISTICS_CODE, &P2_
STATISTIC_AMOUNT, &P2_TAX_CD_SUT_PCT, &P2_TAX_CD_VAT_PCT, &P2_OPERATING_UNIT, &P
2_DEPTID, &P2_PRODUCT, &P2_PROJECT_ID, &P2_AFFILIATE);
/*########################################################################
#
# FIM INSERINDO TABELA RECV_LN_DISTRIB
#
########################################################################*/
/*########################################################################
#
# INSERINDO TABELA RECV_LN_INSP
#
########################################################################*/
&P3_BUSINESS_UNIT = &V_BUSINESS_UNIT_PO;
&P3_RECEIVER_ID = &PAR_RECEIVER_ID;
&P3_RECV_LN_NBR = &PAR_RECV_LN_NBR;
&P3_OP_SEQ = &V_OP_SEQUENCE;
&P3_ROUTING_SETID = " ";
&P3_ROUTING_ID = &V_ROUTING_ID;
&P3_OP_TIME_STD = 0;
&P3_OP_TIME_CD = "P";
&P3_OP_TIME_STD_TTL = 0;
&P3_OP_TIME_ACT_TTL = 0;
&P3_PROCESS_INSTANCE = 0;
GRAVA_RECV_LN_INSP(&P3_BUSINESS_UNIT, &P3_RECEIVER_ID, &P3_RECV_LN_NBR, &P
3_OP_SEQ, &P3_ROUTING_SETID, &P3_ROUTING_ID, &P3_OP_TIME_STD, &P3_OP_TIME_CD, &P
3_OP_TIME_STD_TTL, &P3_OP_TIME_ACT_TTL, &P3_PROCESS_INSTANCE);
/*########################################################################
#
# FIM INSERINDO TABELA RECV_LN_INSP
#
########################################################################*/
/*########################################################################
#
# INSERINDO TABELA RECV_LN_SHIP
#
########################################################################*/
&P4_BUSINESS_UNIT = &V_BUSINESS_UNIT_PO;
&P4_RECEIVER_ID = &PAR_RECEIVER_ID;
&P4_RECV_LN_NBR = &PAR_RECV_LN_NBR;
&P4_RECV_SHIP_SEQ_NBR = &PAR_RECV_SHIP_SEQ_NBR;
&P4_AMT_ONLY_FLG = &V_AMT_ONLY_FLG;
&P4_ASN_SEQ_NBR = 0;
&P4_BILL_OF_LADING = " ";
&P4_BUSINESS_UNIT_IN = &V_BUSINESS_UNIT_IN;
&P4_BUSINESS_UNIT_PO = &V_BUSINESS_UNIT_PO;
&P4_CATEGORY_ID = &V_CATEGORY_ID;
&P4_CONFIG_CODE = &V_CONFIG_CODE;
&P4_CONVERSION_RATE = &RECV_CONVERSION_RATE;
&P4_CONVERT_TO_STK = &RECV_CONVERSION_RATE;
&P4_CONVERT_TO_PO = &IN_CONVERSION_RATE;
&P4_CONVERT_STK_TO_STD = &IN_CONVERSION_RATE;
&P4_COUNTRY_IST_ORIGIN = &V_COUNTRY_IST_ORIGIN;
&P4_CURRENCY_CD = &V_CURRENCY_CD;
&P4_CURRENCY_CD_BASE = &V_CURRENCY_CD_BASE;
&P4_DESCR254_MIXED = &V_DESCR254_MIXED;
&P4_DEVICE_TRACKING = &V_DEVICE_TRACKING;
&P4_DISTRIB_MTHD_FLG = &V_DISTRIB_MTHD_FLG;
&P4_DUE_DT = &V_DUE_DT;
&P4_DUE_TIME = %Time;
&P4_EIP_CTL_ID = " ";
&P4_ERS_INV_SEQ = 0;
&P4_ERS_STATUS = "N";
&P4_INSPECT_CD = &V_INSPECT_CD;
&P4_INSPECT_DTTM = %Datetime;
&P4_INSPECT_STATUS = "C";
&P4_INV_ITEM_ID = &V_INV_ITEM_ID;
&P4_IST_DISTRIB_STATUS = "I";
&P4_ITM_ID_VNDR = " ";
&P4_ITM_SETID = &PAR_SETID;
&P4_LINE_NBR = &PAR_LINE_NBR;
&P4_LOT_CONTROL = &VM_LOT_CONTROL;
&P4_LOT_STATUS = "C";
&P4_MATCH_LINE_FLG = "Y";
&P4_MATCH_STATUS_LC = 0;
&P4_MERCH_AMT_BSE = &TOTAL_LN_RECV;
&P4_MERCH_AMT_PO_BSE = &V_MERCH_AMT_PO_BSE;
&P4_MERCHANDISE_AMT = &TOTAL_LN_RECV;
&P4_MERCHANDISE_AMT_PO = &V_MERCHANDISE_AMT_PO;
&P4_MFG_ID = &V_MFG_ID;
&P4_MFG_ITM_ID = &V_MFG_ITM_ID;
&P4_MOVE_STAT_AM = "N";
&P4_MOVE_STAT_INV = "P";
&P4_MOVE_STAT_MFG = "N";
&P4_OP_SEQUENCE = 0;
&P4_OPRID = %UserId;
&P4_PACKSLIP_NO = " ";
&P4_PO_ID = &V_PO_ID;
&P4_PO_TYPE = &V_PO_TYPE;
&P4_PRICE_PO = &V_PRICE_PO_BSE;
&P4_PRICE_PO_BSE = &V_PRICE_PO_BSE;
&P4_PRO_NUMBER = " ";
&P4_PROCESS_COMPLETE = "N";
&P4_PROCESS_INSTANCE = 0;
&P4_PRODUCTION_ID = &V_PRODUCTION_ID;
&P4_QTY_LN_ASSET_SUOM = 0;
&P4_QTY_LN_INV_SUOM = &PAR_QTD_ACEITA * &RECV_CONVERSION_RATE;
&P4_QTY_SH_ACCPT = &PAR_QTD_ACEITA;
&P4_QTY_SH_ACCPT_SUOM = &PAR_QTD_ACEITA;
&P4_QTY_SH_ACCPT_VUOM = &PAR_QTD_ACEITA;
&P4_QTY_SH_INSPD = 0;
&P4_QTY_SH_INSPD_SUOM = 0;
&P4_QTY_SH_INSPD_VUOM = 0;
&P4_QTY_SH_NETRCV_VUOM = &PAR_QTD_ACEITA;
&P4_QTY_SH_RECVD = &PAR_QTD_ACEITA;
&P4_QTY_SH_RECVD_SUOM = &PAR_QTD_ACEITA * &RECV_CONVERSION_RATE;
&P4_QTY_SH_RECVD_VUOM = &PAR_QTD_ACEITA;
&P4_QTY_SH_REJCT = 0;
&P4_QTY_SH_REJCT_SUOM = 0;
&P4_QTY_SH_REJCT_VUOM = 0;
&P4_QTY_SH_RTN = 0;
&P4_QTY_SH_RTN_SUOM = 0;
&P4_QTY_SH_RTN_VUOM = 0;
&P4_REJECT_ACTION = " ";
&P4_REJECT_REASON = " ";
&P4_REVISION = &V_REVISION;
&P4_RMA_ID = " ";
&P4_RMA_LINE_NBR = 0;
&P4_RECEIPT_ALLOC_TYPE = "1";
&P4_RECEIPT_DTTM = %Datetime;
&P4_RECEIPT_UM = &V_UNIT_OF_MEASURE;
&P4_RECEIVE_UOM = &V_UNIT_OF_MEASURE;
&P4_RECV_LN_MATCH_OPT = "N";
&P4_RECV_SHIP_STATUS = "R";
&P4_RECV_STOCK_UOM = &VM_UNIT_MEASURE_STD;
&P4_REPLACEMENT_FLG = "NA";
&P4_SCHED_NBR = &V_SCHED_NBR;
&P4_SERIAL_CONTROL = &VM_SERIAL_CONTROL;
&P4_SERIAL_STATUS = "C";
&P4_SHIP_DATE_STATUS = "3";
&P4_SHIP_QTY_STATUS = "1";
&P4_SHIPTO_ID = &V_SHIPTO_ID;
&P4_UNIT_MEASURE_STD = &VM_UNIT_MEASURE_STD;
GRAVA_RECV_LN_SHIP(&P4_BUSINESS_UNIT, &P4_RECEIVER_ID, &P4_RECV_LN_NBR, &P
4_RECV_SHIP_SEQ_NBR, &P4_AMT_ONLY_FLG, &P4_ASN_SEQ_NBR, &P4_BILL_OF_LADING, &P4_
BUSINESS_UNIT_IN, &P4_BUSINESS_UNIT_PO, &P4_CATEGORY_ID, &P4_CONFIG_CODE, &P4_CO
NVERSION_RATE, &P4_CONVERT_TO_STK, &P4_CONVERT_TO_PO, &P4_CONVERT_STK_TO_STD, &P
4_COUNTRY_IST_ORIGIN, &P4_CURRENCY_CD, &P4_CURRENCY_CD_BASE, &P4_DESCR254_MIXED,
&P4_DEVICE_TRACKING, &P4_DISTRIB_MTHD_FLG, &P4_DUE_DT, &P4_DUE_TIME, &P4_EIP_CT
L_ID, &P4_ERS_INV_SEQ, &P4_ERS_STATUS, &P4_INSPECT_CD, &P4_INSPECT_DTTM, &P4_INS
PECT_STATUS, &P4_INV_ITEM_ID, &P4_IST_DISTRIB_STATUS, &P4_ITM_ID_VNDR, &P4_ITM_S
ETID, &P4_LINE_NBR, &P4_LOT_CONTROL, &P4_LOT_STATUS, &P4_MATCH_LINE_FLG, &P4_MAT
CH_STATUS_LC, &P4_MERCH_AMT_BSE, &P4_MERCH_AMT_PO_BSE, &P4_MERCHANDISE_AMT, &P4_
MERCHANDISE_AMT_PO, &P4_MFG_ID, &P4_MFG_ITM_ID, &P4_MOVE_STAT_AM, &P4_MOVE_STAT_
INV, &P4_MOVE_STAT_MFG, &P4_OP_SEQUENCE, &P4_OPRID, &P4_PACKSLIP_NO, &P4_PO_ID,
&P4_PO_TYPE, &P4_PRICE_PO, &P4_PRICE_PO_BSE, &P4_PRO_NUMBER, &P4_PROCESS_COMPLET
E, &P4_PROCESS_INSTANCE, &P4_PRODUCTION_ID, &P4_QTY_LN_ASSET_SUOM, &P4_QTY_LN_IN
V_SUOM, &P4_QTY_SH_ACCPT, &P4_QTY_SH_ACCPT_SUOM, &P4_QTY_SH_ACCPT_VUOM, &P4_QTY_
SH_INSPD, &P4_QTY_SH_INSPD_SUOM, &P4_QTY_SH_INSPD_VUOM, &P4_QTY_SH_NETRCV_VUOM,
&P4_QTY_SH_RECVD, &P4_QTY_SH_RECVD_SUOM, &P4_QTY_SH_RECVD_VUOM, &P4_QTY_SH_REJCT
, &P4_QTY_SH_REJCT_SUOM, &P4_QTY_SH_REJCT_VUOM, &P4_QTY_SH_RTN, &P4_QTY_SH_RTN_S
UOM, &P4_QTY_SH_RTN_VUOM, &P4_REJECT_ACTION, &P4_REJECT_REASON, &P4_REVISION, &P
4_RMA_ID, &P4_RMA_LINE_NBR, &P4_RECEIPT_ALLOC_TYPE, &P4_RECEIPT_DTTM, &P4_RECEIP
T_UM, &P4_RECEIVE_UOM, &P4_RECV_LN_MATCH_OPT, &P4_RECV_SHIP_STATUS, &P4_RECV_STO
CK_UOM, &P4_REPLACEMENT_FLG, &P4_SCHED_NBR, &P4_SERIAL_CONTROL, &P4_SERIAL_STATU
S, &P4_SHIP_DATE_STATUS, &P4_SHIP_QTY_STATUS, &P4_SHIPTO_ID, &P4_UNIT_MEASURE_ST
D);
/*########################################################################
#
# FIM INSERINDO TABELA RECV_LN_SHIP
#
########################################################################*/
/*########################################################################
#
# INSERINDO TABELA RECV_LN_SHP_MTH
#
########################################################################*/
&P5_BUSINESS_UNIT = &V_BUSINESS_UNIT_PO;
&P5_RECEIVER_ID = &PAR_RECEIVER_ID;
&P5_RECV_LN_NBR = &PAR_RECV_LN_NBR;
&P5_RECV_SHIP_SEQ_NBR = &PAR_RECV_SHIP_SEQ_NBR;
&P5_TXN_CURRENCY_CD = " ";
&P5_QTY_MATCHED = 0;
&P5_AMT_MATCHED = 0;
GRAVA_RECV_LN_SHP_MTH(&P5_BUSINESS_UNIT, &P5_RECEIVER_ID, &P5_RECV_LN_NBR,
&P5_RECV_SHIP_SEQ_NBR, &P5_TXN_CURRENCY_CD, &P5_QTY_MATCHED, &P5_AMT_MATCHED);
/*########################################################################
#
# FIM INSERINDO TABELA RECV_LN_SHP_MTH
#
########################################################################*/
/*
|||||||||||||||||||||||||||||||||||||
||
||
|| FIM GRAVANDO O RECEBIMENTO
||
||
||
|||||||||||||||||||||||||||||||||||||
*/
If &ULTIMA_LINHA = "Y" Then
&RECEBIDO_TUDO = "Y";
SQLExec("SELECT 'N' FROM SYSADM.PS_MMC_TE_OC_VW WHERE BUSINESS_UNIT = :
1 AND PO_ID = :2 AND QTY_PO > 0", &V_BUSINESS_UNIT_PO, &V_PO_ID, &RECEBIDO_TUDO)
;
If None(&RECEBIDO_TUDO) Or
&RECEBIDO_TUDO = "N" Then
SQLExec("update sysadm.ps_po_hdr set recv_status = 'P', backorder_st
atus='3' where business_unit =:1 and po_id =:2 ", &V_BUSINESS_UNIT_PO, &V_PO_ID)
;
Else
SQLExec("update sysadm.ps_po_hdr set recv_status = 'R', backorder_st
atus='3' where business_unit =:1 and po_id =:2 ", &V_BUSINESS_UNIT_PO, &V_PO_ID)
;
End-If;
End-If;
End-While;
End-Function;
[MMC_TE_CAL_PREC.ADD_AMOUNT.FieldChange]
/*******************************************************************************
***
* Claudio Henrique da Costa - MMC - 20/12/2007 - mmcb.2323
*
* Criao da tela de parametrizao de valor/percentual adicional/fixo para item
*
* em faturamento via Solicitao Eletrnica.
*
********************************************************************************
***/
If %Page = "MMC_TE_CAL_PREC" Then
If (ADD_AMOUNT <> 0 And
AMOUNT <> 0) Or
(AMOUNT <> 0 And
MMC_PERCENTUAL <> 0) Or
(MMC_PERCENTUAL <> 0 And
End-If;
[MMC_TE_CAL_PREC.INV_ITEM_ID.FieldChange]
/*******************************************************************************
***
* Claudio Henrique da Costa - MMC - 20/12/2007 - mmcb.2323
*
* Criao da tela de parametrizao de valor/percentual adicional/fixo para item
*
* em faturamento via Solicitao Eletrnica.
*
********************************************************************************
***/
If %Page = "MMC_TE_CAL_PREC" Then
If All(INV_ITEM_ID) And
(All(LT_GRP_ID_BBL) Or
All(TOF_PBL)) Then
Error ("Apenas Dados Fiscais ou Item deve ser parametrizados.");
End-If;
End-If;
[MMC_TE_CAL_PREC.MMC_PERCENTUAL.FieldChange]
/*******************************************************************************
***
* Claudio Henrique da Costa - MMC - 20/12/2007 - mmcb.2323
*
* Criao da tela de parametrizao de valor/percentual adicional/fixo para item
*
* em faturamento via Solicitao Eletrnica.
*
********************************************************************************
***/
If %Page = "MMC_TE_CAL_PREC" Then
If (ADD_AMOUNT <> 0 And
AMOUNT <> 0) Or
(AMOUNT <> 0 And
MMC_PERCENTUAL <> 0) Or
(MMC_PERCENTUAL <> 0 And
ADD_AMOUNT <> 0) Then
Error ("Apenas um tipo de acrscimo ou valor fixo permitido por Grupo/OF ou
Item.");
End-If;
End-If;
[MMC_TE_CAL_PREC.SETID.RowInit]
/*******************************************************************************
***
* Claudio Henrique da Costa - MMC - 20/12/2007 - mmcb.2323
*
* Criao da tela de parametrizao de valor/percentual adicional/fixo para item
*
* em faturamento via Solicitao Eletrnica.
*
********************************************************************************
***/
/*******************************************************************************
**
* Ricardo L. Rezende - MMCB - 06/11/2009
- mmcb.sds3239
*
* Projeto Implantao People - Multi Empresa MMCB-SVB.
*
********************************************************************************
*/
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange; /* mmc
b.sds3239.ln */
/********************** mmcb.sds3239.so *********************
SETID = "MMCSA";
/********************** mmcb.sds3239.eo **********************/
/********************** mmcb.sds3239.sn **********************/
SETID = BUSCA_SETID();
/********************** mmcb.sds3239.en **********************/
[MMC_TE_CRIAOP.MMC_ESPECIFICO.FieldChange]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 08/01/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Oculta Campo de NF para todas NFs.
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Vincius Alves Mello - MMC - 14/10/2010 - mmcb.sds3425 - Sistema Controle Terce
iros
*
* Retirada a tabela MMC_TE_OP_ASNFS da tela.
*
*******************************************************************************
*****************/
If %Component = "MMC_TE_CRIAOP" Then
NF_BRL_ID = " ";
If MMC_ESPECIFICO = "T" Then
Hide(NF_BRL_ID);
/*HideScroll(Record.MMC_TE_OP_ASNFS);*/ /*mmcb.sds3425.lo*/
Else
UnHide(NF_BRL_ID);
End-If;
End-If;
[MMC_TE_CRIAOP.NF_BRL_ID.FieldChange]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 08/01/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Oculta Campo de NF para todas NFs.
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Vincius Alves Mello - MMC - 14/10/2010 - mmcb.sds3425 - Sistema Controle Terce
iros
*
* Foi retirada a tabela MMC_TE_OP_ASNFS da tela.
*
*******************************************************************************
*****************/
If %Component = "MMC_TE_CRIAOP" Then
/*ScrollFlush(Record.MMC_TE_OP_ASNFS);*/ /*mmcb.sds3425.lo*/
If NF_BRL_ID = " " Or
NF_BRL_ID = "" Or
None(NF_BRL_ID) Then
/*********************** mmcb.sds3425.so ***********************/
/*HideScroll(Record.MMC_TE_OP_ASNFS);
GetRowset(Scroll.MMC_TE_OP_ASNFS).Select(Record.MMC_TE_OP_ASNFS, "where bu
siness_unit = '" | BUSINESS_UNIT | "' AND NF_BRL_ID = '" | NF_BRL_ID | "'");*/
/*********************** mmcb.sds3425.eo ***********************/
Else
/*UnhideScroll(Record.MMC_TE_OP_ASNFS);*/ /*mmcb.sds3425.lo*/
SQLExec("SELECT COUNT(DISTINCT NF_BRL_LINE_NUM) FROM SYSADM.PS_MMC_TE_OP W
HERE BUSINESS_UNIT = :1 AND NF_BRL_ID = :2", BUSINESS_UNIT, NF_BRL_ID, &RESULTAD
O);
/*********************** mmcb.sds3425.so ***********************/
/*
GetRowset(Scroll.MMC_TE_OP_ASNFS).Select(Record.MMC_TE_OP_ASNFS, "where bu
siness_unit = '" | BUSINESS_UNIT | "' AND NF_BRL_ID = '" | NF_BRL_ID | "'");
If &RESULTADO = GetLevel0()(1).GetRowset(Scroll.MMC_TE_OP_ASNFS).ActiveRow
Count Then
For &I = 1 To GetLevel0()(1).GetRowset(Scroll.MMC_TE_OP_ASNFS).ActiveRo
wCount
GetLevel0()(1).GetRowset(Scroll.MMC_TE_OP_ASNFS)(&I).GetRecord(Recor
d.MMC_TE_OP_ASNFS).SEQ_NBR.Value = &I;
GetLevel0()(1).GetRowset(Scroll.MMC_TE_OP_ASNFS)(&I).GetRecord(Recor
d.MMC_TE_OP_ASNFS).BUSINESS_UNIT.Value = BUSINESS_UNIT;
GetLevel0()(1).GetRowset(Scroll.MMC_TE_OP_ASNFS)(&I).GetRecord(Recor
d.MMC_TE_OP_ASNFS).NF_BRL_ID.Value = NF_BRL_ID;
End-For;
End-If;
*/
/*********************** mmcb.sds3425.eo ***********************/
If &RESULTADO = 1 Then
SQLExec("SELECT BUSINESS_UNIT_IN, NF_BRL_ID_2_BBL, NF_BRL_LINE_NUM FROM
SYSADM.PS_MMC_TE_OP WHERE BUSINESS_UNIT = :1 AND NF_BRL_ID = :2", BUSINESS_UNIT
[MMC_TE_OP.MMC_TE_QTD_PAI.SaveEdit]
/*******************************************************************************
*****************
* Wagner Sorio MMC - 09/04/2008 - mmcb.at2323 - Sistema Controle Terceiros
*
* No deixar salvar codigo item pai negativo ou zerado.
*
********** ********************************************************************
******************/
/********************** mmcb.at2323.sn **********************/
If MMC_TE_QTD_PAI <= 0 Then
Error ("Quantidade Item Pai deve ser maior que Zero ");
End-If;
/********************** mmcb.at2323.en **********************/
[MMC_TE_OP_OC_WK.ADDRESS_SEQ_NUM.FieldChange]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 15/11/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Preenche automaticamente CNPJ do fornecedor.
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Augusto Vilarinho Neto - MMCB - 05/11/2009 - mmcb.sds3239
*
* Projeto Implantao People - Multi Empresa MMCB-SVB.
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Vincius Alves Mello - MMC - 05/10/2010 - mmcb.sds3426
*
* Preencher dados fornecedor.
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Vincius Alves Mello - MMCB - 07/10/2010 - mmcb.sds3425 - Sistema Controle Terc
eiros
*
* Buscar condio de pagamento automaticamente, para notas de triangulao.
*
*******************************************************************************
*****************/
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange; /* mmc
b.sds3239.ln */
/********************** mmcb.at2323.sn **********************/
If All(VENDOR_ID) And
All(ADDRESS_SEQ_NUM) Then
If None(BUSINESS_UNIT_IN) Then
WinMessage("Unidade Negocio Insumos est em branco");
Exit;
End-If;
If None(NF_BRL_ID_2_BBL) Then
WinMessage("NF Insumos est em branco");
Exit;
End-If;
If None(MMC_TE_QTD_PAI) Or
MMC_TE_QTD_PAI <= 0 Then
WinMessage("Qtd Item Pai invalida.");
End-If;
&LEVEL1 = GetRowset(Scroll.MMC_TE_OP_OC_VW);
&condicao = " where business_unit= '" | NF_HDR_BRL.BUSINESS_UNIT | "' ";
If All(VENDOR_ID) Then
&condicao = &condicao | " and vendor_id='" | VENDOR_ID | "' ";
Else
WinMessage("O Campo fornecedor Obrigatorio.");
Exit;
End-If;
If All(PO_ID) Then
&condicao = &condicao | " and po_id='" | PO_ID | "' ";
End-If;
If All(INV_ITEM_ID) Then
&condicao = &condicao | " and inv_item_id='" | INV_ITEM_ID | "' ";
End-If;
&condicao = &condicao | " and qty_po > 0 ";
For &Q = &LEVEL1.ACTIVEROWCOUNT To 1 Step - 1;
If &LEVEL1.GetRow(&Q).MMC_TE_WRK.MMC_TE_CONFI_FLG.VALUE <> "Y" Then
&LEVEL1.DeleteRow(&Q);
End-If
End-For;
&LEVEL1.Select(Record.MMC_TE_OP_OC_VW, &condicao);
REM Codigo para validar se existe OC Duplicado ;
REM LIMPA AS NFS QUE NO FORAM SELECIONADAS ;
For &N1 = &LEVEL1.ActiveRowCount To 1 Step - 1;
&PO_ID_ANTERIOR = &LEVEL1.GetRow(&N1).MMC_TE_OP_OC_VW.PO_ID.VALUE;
&PO_LINE_ANTERIOR = &LEVEL1.GetRow(&N1).MMC_TE_OP_OC_VW.LINE_NBR.VALUE;
&PO_SCHED_ANTERIOR = &LEVEL1.GetRow(&N1).MMC_TE_OP_OC_VW.SCHED_NBR.VALUE;
For &N2 = &LEVEL1.ActiveRowCount To 1 Step - 1;
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||
|| INICIO: ROTINA DE VERIFICAO QTD ITEMS ENTRE NF SERVIO E NF INSUMOS
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||*/
/********************** mmcb.sds3426.so **********************/
/*
&ITEM_SERVICO = "";
For &W = &L1_OP.ActiveRowCount To 1 Step - 1;
If &L1_OP.ActiveRowCount = 1 Then
&ITEM_SERVICO = &ITEM_SERVICO | "'" | &L1_OP.GetRow(&W).MMC_TE_OP_OC
_VW.INV_ITEM_ID.VALUE | "'";
Else
&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.BUSINESS_UNIT_PO.Value = &L1_OP.Ge
tRow(&i).MMC_TE_OP_OC_VW.BUSINESS_UNIT.VALUE;
&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.PO_ID.Value = &L1_OP.GetRow(&i).MM
C_TE_OP_OC_VW.PO_ID.VALUE;
&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.QTY_NF_BRL.VALUE = &L1_OP.GetRow(&
i).MMC_TE_WRK.QTY_OPEN.VALUE;
&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.UNIT_PRICE.VALUE = &L1_OP.GetRow(&
i).MMC_TE_OP_OC_VW.PRICE_PO.VALUE;
&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.MERCH_ORIG_AMT_PBL.VALUE = &L1_OP.
GetRow(&i).MMC_TE_WRK.QTY_OPEN.VALUE * &L1_OP.GetRow(&i).MMC_TE_OP_OC_VW.PRICE_P
O.VALUE;
If None(&L1_OP.GetRow(&i).MMC_TE_OP_OC_VW.DESCR254_MIXED.VALUE) Then
&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.DESCR.VALUE = &L1_OP.GetRow(&i)
.MASTER_ITEM_TBL.DESCR.VALUE;
Else
&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.DESCR.VALUE = &L1_OP.GetRow(&i)
.MMC_TE_OP_OC_VW.DESCR254_MIXED.VALUE;
End-If;
SQLExec("select A.INVENTORY_ITEM, A.UNIT_MEASURE_STD from PS_MASTER_ITE
M_TBL A where A.SETID = :1 and A.INV_ITEM_ID = :2", &VAR_SETID, &rowsetNiv1.GetR
ow(&COUNT).NF_LN_BRL.INV_ITEM_ID.VALUE, &INVENTORY_ITEM, &UNIT_OF_MEASURE);
If None(&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.UNIT_OF_MEASURE.VALUE) The
n
&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.UNIT_OF_MEASURE.VALUE = &UNIT_O
F_MEASURE;
End-If;
If None(&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.INVENTORY_ITEM.VALUE) Then
&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.INVENTORY_ITEM.Value = &INVENTO
RY_ITEM;
End-If;
SQLExec("select account from sysadm.ps_itm_purch_vw where setid=:1 and
inv_item_id =:2 ", &VAR_SETID, &rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.INV_ITEM_ID.
VALUE, &ACCOUNT);
UpdateValue(Record.NF_LN_BRL, &COUNT, BRL_DISTRIB_LN.ACCOUNT, 1, &ACCOU
NT);
&rowsetNiv1.GetRow(&COUNT).MMC_TE_OP_WRK.BUSINESS_UNIT_PO.VALUE = &L1_O
P.GetRow(&i).MMC_TE_OP_OC_VW.BUSINESS_UNIT.VALUE;
&rowsetNiv1.GetRow(&COUNT).MMC_TE_OP_WRK.PO_ID.VALUE = &L1_OP.GetRow(&i
).MMC_TE_OP_OC_VW.PO_ID.VALUE;
&rowsetNiv1.GetRow(&COUNT).MMC_TE_OP_WRK.LINE_NBR.VALUE = &L1_OP.GetRow
(&i).MMC_TE_OP_OC_VW.LINE_NBR.VALUE;
&rowsetNiv1.GetRow(&COUNT).MMC_TE_OP_WRK.SCHED_NBR.VALUE = &L1_OP.GetRo
w(&i).MMC_TE_OP_OC_VW.SCHED_NBR.VALUE;
&rowsetNiv1.GetRow(&COUNT).MMC_TE_OP_WRK.BUSINESS_UNIT_IN.VALUE = BUSIN
ESS_UNIT_IN;
&rowsetNiv1.GetRow(&COUNT).MMC_TE_OP_WRK.NF_BRL_ID_2_BBL.VALUE = NF_BRL
_ID_2_BBL;
&rowsetNiv1.GetRow(&COUNT).MMC_TE_OP_WRK.INV_ITEM_ID.VALUE = MMC_ITEM_P
AI;
/*&rowsetNiv1.GetRow(&COUNT).MMC_TE_OP_WRK.MMC_TE_QTD_PAI.VALUE = &L1_O
P.GetRow(&I).MMC_TE_WRK.QTY_OPEN.VALUE;*/ /*mmcb.sds3426.lo*/
/********************** mmcb.sds3426.sn **********************/
&rowsetNiv1.GetRow(&COUNT).MMC_TE_OP_WRK.MMC_TE_QTD_PAI.VALUE = MMC_TE_
QTD_PAI;
&rowsetNiv1.GetRow(&COUNT).MMC_TE_OP_WRK.INV_ITEM_ID_PO.VALUE = &rowset
Niv1.GetRow(&COUNT).NF_LN_BRL.INV_ITEM_ID.VALUE;
&rowsetNiv1.GetRow(&COUNT).MMC_TE_OP_WRK.QTY_NF_BRL.VALUE = &rowsetNiv1
.GetRow(&COUNT).NF_LN_BRL.QTY_NF_BRL.VALUE;
/********************** mmcb.sds3426.en **********************/
&COUNT = &COUNT + 1;
End-For;
MMC_TE_OP_OC_WK.VENDOR_ID.Enabled = False;
MMC_TE_OP_OC_WK.ADDRESS_SEQ_NUM.Enabled = False;
MMC_TE_OP_OC_WK.CGC_BRL.Enabled = False;
MMC_TE_OP_OC_WK.VNDR_LOC.Enabled = False;
/********************** mmcb.sds3426.so **********************/
/*MMC_TE_OP_OC_WK.PO_ID.Enabled = False;
MMC_TE_OP_OC_WK.INV_ITEM_ID.Enabled = False;
MMC_TE_OP_OC_WK.BTN_SELECT.Enabled = False;
MMC_TE_OP_OC_WK.BUTTON1.Enabled = False;
MMC_TE_OP_OC_WK.BUTTON.Enabled = False;*/
/********************** mmcb.sds3426.eo **********************/
MMC_TE_OP_OC_WK.MMC_ITEM_PAI.Enabled = False;
MMC_TE_OP_OC_WK.MMC_TE_QTD_PAI.Enabled = False;
MMC_TE_OP_OC_WK.BUSINESS_UNIT_IN.Enabled = False;
MMC_TE_OP_OC_WK.NF_BRL_ID_2_BBL.Enabled = False;
End-If;
End-If;
/********************** mmcb.at2323.en **********************/
[MMC_TE_OP_OC_WK.BUTTON1.FieldChange]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 26/12/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Customizao Sistema de Terceiros - Limpa Grade OC da Industrializao.
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Vincius Alves Mello - MMC - 06/10/2010 - mmcb.sds3426 - Sistema Controle Terce
iros
*
* Permitir inserir mais de um insumo para a NF de industrializao.
*
*******************************************************************************
*****************/
/********************** mmcb.at2323.sn **********************/
If %Page = Page.MMC_TE_NF_OP Then
/*GetRowset(Scroll.MMC_TE_OP_OC_VW).Flush();*/ /*mmcb.sds3426.lo*/
/********************** mmcb.sds3426.sn **********************/
&rowsetN1 = GetRowset(Scroll.MMC_TE_OP_OC_VW);
&rowsetN2 = GetRowset(Scroll.NF_LN_BRL);
&rowsetN3 = GetRowset(Scroll.MMC_TE_TRIA_BOM);
For &i = &rowsetN1.ActiveRowCount To 1 Step - 1;
&rowsetN1.DeleteRow(&i);
End-For;
For &i = &rowsetN2.ActiveRowCount To 1 Step - 1;
&rowsetN2.DeleteRow(&i);
End-For;
For &i = &rowsetN3.ActiveRowCount To 1 Step - 1;
&rowsetN3.DeleteRow(&i);
End-For;
&rowsetN1.Flush();
&rowsetN2.Flush();
&rowsetN3.Flush();
MMC_TE_OP_OC_WK.VENDOR_ID.Enabled = True;
MMC_TE_OP_OC_WK.ADDRESS_SEQ_NUM.Enabled = True;
MMC_TE_OP_OC_WK.CGC_BRL.Enabled = True;
MMC_TE_OP_OC_WK.VNDR_LOC.Enabled = True;
MMC_TE_OP_OC_WK.MMC_ITEM_PAI.Enabled = True;
MMC_TE_OP_OC_WK.MMC_TE_QTD_PAI.Enabled = True;
MMC_TE_OP_OC_WK.BUSINESS_UNIT_IN.Enabled = True;
MMC_TE_OP_OC_WK.NF_BRL_ID_2_BBL.Enabled = True;
/********************** mmcb.sds3426.en **********************/
End-If;
/********************** mmcb.at2323.en **********************/
[MMC_TE_OP_OC_WK.BUTTON2.FieldChange]
/*******************************************************************************
*****************
* Vincius Alves Mello - MMC - 05/10/2010 - mmcb.sds3426 - Sistema Controle Terce
iros
*
* Realizar a verificao entre os itens da NF de retorno e o BOM.
*
*******************************************************************************
*****************/
/*************************** mmcb.sds3426.sn ***************************/
Declare Function VERIFICA_NF_VS_BOM PeopleCode BUTTON2 FieldFormula;
If %Component = "NF_INFO_PBL" Then
If MMC_TE_NFLN_WRK.MMC_TERCEIRO_FLG = "Y" Then
If None(MMC_ITEM_PAI) Or
None(MMC_TE_QTD_PAI) Then
WinMessage("Favor informe o Item Pai e a sua Quantidade.");
Exit;
End-If;
VERIFICA_NF_VS_BOM();
End-If;
End-If;
/*************************** mmcb.sds3426.en ***************************/
[MMC_TE_OP_OC_WK.BUTTON2.FieldFormula]
/*******************************************************************************
*****************
* Vincius Alves Mello - MMC - 05/10/2010 - mmcb.sds3426 - Sistema Controle Terce
iros
*
* Realizar a verificao entre os itens da NF de retorno e o BOM.
*
*******************************************************************************
*****************/
/********************** mmcb.sds3426.sn **********************/
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange;
Function VERIFICA_NF_VS_BOM;
If All(MMC_ITEM_PAI) And
All(MMC_TE_QTD_PAI) Then
&SETID = BUSCA_SETID();
&V_DATA_HORA = %Datetime;
&V_OPRID = %OperatorId;
&LINHA = 1;
&rowsetN1 = GetRowset(Scroll.MMC_TE_TRIA_BOM);
&rowsetN2 = GetRowset(Scroll.NF_LN_BRL);
For &I = &rowsetN1.ActiveRowCount To 1 Step - 1;
&rowsetN1.DeleteRow(&I);
End-For;
SQLExec("SELECT BUSINESS_UNIT_IN, SHIPTO_ID FROM SYSADM.PS_SHIPTO_TBL WHER
E SETID=:1 AND BUSINESS_UNIT_RECV=:2", &SETID, NF_HDR_BRL.BUSINESS_UNIT, &BU_IND
UST, &LOC_INDUST);
&SQL = CreateSQL("SELECT X.COMPONENT_ID, SUM(X.QTY_PER) AS QTY_PER FROM (
SELECT CONNECT_BY_ROOT C.INV_ITEM_ID CARRO, C.COMPONENT_ID, C.QTY_PER FROM SYSAD
M.PS_EN_BOM_COMPS C WHERE C.BUSINESS_UNIT = :1 AND C.BOM_STATE = 'PR' AND C.BOM_
TYPE = 'PR' AND SYSDATE BETWEEN C.DATE_IN_EFFECT AND C.DATE_OBSOLETE CONNECT BY
NOCYCLE PRIOR C.COMPONENT_ID = C.INV_ITEM_ID START WITH C.INV_ITEM_ID = :3 AND S
YSDATE BETWEEN C.DATE_IN_EFFECT AND C.DATE_OBSOLETE ORDER BY C.COMPONENT_ID ) X
GROUP BY X.COMPONENT_ID", &BU_INDUST, &LOC_INDUST, MMC_ITEM_PAI);
While &SQL.Fetch(&V_COMPONENT_ID, &V_QTY_PER)
&rowsetN1.InsertRow(&LINHA);
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.BUSINESS_UNIT.VALUE = NF_HDR_B
RL.BUSINESS_UNIT;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.NF_BRL.VALUE = NF_HDR_BRL.NF_B
RL;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.NF_BRL_SERIES.VALUE = NF_HDR_B
RL.NF_BRL_SERIES;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.VENDOR_ID.VALUE = VENDOR_ID;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.ADDRESS_SEQ_NUM.VALUE = ADDRES
S_SEQ_NUM;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.DT_TIMESTAMP.VALUE = &V_DATA_H
ORA;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.SEQ_NBR.VALUE = &LINHA;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.MMC_OPRID.VALUE = &V_OPRID;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.INV_ITEM_ID.VALUE = &V_COMPONE
NT_ID;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.DESCR254.VALUE = "-";
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.QTY_PER.VALUE = &V_QTY_PER * M
MC_TE_QTD_PAI;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE = 0;
&LINHA = &LINHA + 1;
End-While;
&SQL2 = CreateSQL("SELECT INV_ITEM_ID, SUM(QTY_NF_BRL) AS QTY_NF_BRL FROM
SYSADM.PS_NF_LN_BRL WHERE BUSINESS_UNIT=:1 AND NF_BRL_ID=:2 GROUP BY INV_ITEM_ID
", BUSINESS_UNIT_IN, NF_BRL_ID_2_BBL);
While &SQL2.Fetch(&V_INV_ITEM_ID, &V_QTY_NF_BRL)
&statusLinha = "NOT OK";
For &j = &rowsetN1.ActiveRowCount To 1 Step - 1;
If &V_INV_ITEM_ID = &rowsetN1.GetRow(&j).MMC_TE_TRIA_BOM.INV_ITEM_ID
.VALUE And
&rowsetN1.GetRow(&j).MMC_TE_TRIA_BOM.DESCR254.VALUE = "-" Then
&statusLinha = "OK";
&rowsetN1.GetRow(&j).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE = &rowset
N1.GetRow(&j).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE + &V_QTY_NF_BRL;
Else
If &V_INV_ITEM_ID = &rowsetN1.GetRow(&j).MMC_TE_TRIA_BOM.INV_ITEM
_ID.VALUE And
&rowsetN1.GetRow(&j).MMC_TE_TRIA_BOM.DESCR254.VALUE <> "-"
Then
&statusLinha = "OK";
&rowsetN1.GetRow(&j).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE = &row
setN1.GetRow(&j).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE + &V_QTY_NF_BRL;
&rowsetN1.GetRow(&j).MMC_TE_TRIA_BOM.DESCR254.VALUE = "-";
End-If;
End-If;
End-For;
If &statusLinha = "NOT OK" Then
&rowsetN1.InsertRow(&LINHA);
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.BUSINESS_UNIT.VALUE = NF_HD
R_BRL.BUSINESS_UNIT;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.NF_BRL.VALUE = NF_HDR_BRL.N
F_BRL;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.NF_BRL_SERIES.VALUE = NF_HD
R_BRL.NF_BRL_SERIES;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.VENDOR_ID.VALUE = VENDOR_ID
;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.ADDRESS_SEQ_NUM.VALUE = ADD
RESS_SEQ_NUM;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.DT_TIMESTAMP.VALUE = &V_DAT
A_HORA;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.SEQ_NBR.VALUE = &LINHA;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.MMC_OPRID.VALUE = &V_OPRID;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.INV_ITEM_ID.VALUE = &V_INV_
ITEM_ID;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.DESCR254.VALUE = "Item no en
contrado no BOM.";
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.QTY_PER.VALUE = 0;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE = &V_QTY
_NF_BRL;
&LINHA = &LINHA + 1;
End-If;
End-While;
For &I = &rowsetN2.ActiveRowCount To 1 Step - 1;
&statusLinha = "NOT OK";
For &j = &rowsetN1.ActiveRowCount To 1 Step - 1;
If &rowsetN2.GetRow(&I).NF_LN_BRL.INV_ITEM_ID.VALUE = &rowsetN1.GetR
ow(&j).MMC_TE_TRIA_BOM.INV_ITEM_ID.VALUE And
&rowsetN1.GetRow(&j).MMC_TE_TRIA_BOM.DESCR254.VALUE = "-" Then
&statusLinha = "OK";
&rowsetN1.GetRow(&j).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE = &rowset
N1.GetRow(&j).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE + &rowsetN2.GetRow(&I).NF_LN_BR
L.QTY_NF_BRL.VALUE;
Else
If &rowsetN2.GetRow(&I).NF_LN_BRL.INV_ITEM_ID.VALUE = &rowsetN1.G
etRow(&j).MMC_TE_TRIA_BOM.INV_ITEM_ID.VALUE And
&rowsetN1.GetRow(&j).MMC_TE_TRIA_BOM.DESCR254.VALUE <> "-"
Then
&statusLinha = "OK";
&rowsetN1.GetRow(&j).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE = &row
setN1.GetRow(&j).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE + &rowsetN2.GetRow(&I).NF_LN
_BRL.QTY_NF_BRL.VALUE;
&rowsetN1.GetRow(&j).MMC_TE_TRIA_BOM.DESCR254.VALUE = "-";
End-If;
End-If;
End-For;
If &statusLinha = "NOT OK" Then
&rowsetN1.InsertRow(&LINHA);
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.BUSINESS_UNIT.VALUE = NF_HD
R_BRL.BUSINESS_UNIT;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.NF_BRL.VALUE = NF_HDR_BRL.N
F_BRL;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.NF_BRL_SERIES.VALUE = NF_HD
R_BRL.NF_BRL_SERIES;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.VENDOR_ID.VALUE = VENDOR_ID
;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.ADDRESS_SEQ_NUM.VALUE = ADD
RESS_SEQ_NUM;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.DT_TIMESTAMP.VALUE = &V_DAT
A_HORA;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.SEQ_NBR.VALUE = &LINHA;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.MMC_OPRID.VALUE = &V_OPRID;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.INV_ITEM_ID.VALUE = &rowset
N2.GetRow(&I).NF_LN_BRL.INV_ITEM_ID.VALUE;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.DESCR254.VALUE = "Item no en
contrado no BOM.";
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.QTY_PER.VALUE = 0;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE = &rowse
tN2.GetRow(&I).NF_LN_BRL.QTY_NF_BRL.VALUE;
&LINHA = &LINHA + 1;
End-If;
End-For;
&rowsetN1.DeleteRow(&LINHA);
For &I = &rowsetN1.ActiveRowCount To 1 Step - 1;
If &rowsetN1.GetRow(&I).MMC_TE_TRIA_BOM.QTY_PER.VALUE <> &rowsetN1.GetR
ow(&I).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE And
&rowsetN1.GetRow(&I).MMC_TE_TRIA_BOM.DESCR254.VALUE = "-" Then
If &rowsetN1.GetRow(&I).MMC_TE_TRIA_BOM.QTY_PER.VALUE > 0 And
&rowsetN1.GetRow(&I).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE > 0 Th
en
&rowsetN1.GetRow(&I).MMC_TE_TRIA_BOM.DESCR254.VALUE = "Quantidade
do BOM (" | &rowsetN1.GetRow(&I).MMC_TE_TRIA_BOM.QTY_PER.VALUE | ") esta difere
nte da quantidade da NF (" | &rowsetN1.GetRow(&I).MMC_TE_TRIA_BOM.QTY_PER_BASE.V
ALUE | ").";
Else
If &rowsetN1.GetRow(&I).MMC_TE_TRIA_BOM.QTY_PER.VALUE > 0 And
&rowsetN1.GetRow(&I).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE = 0
Then
&rowsetN1.GetRow(&I).MMC_TE_TRIA_BOM.DESCR254.VALUE = "Item no
encontrado na NF.";
Else
If &rowsetN1.GetRow(&I).MMC_TE_TRIA_BOM.DESCR254.VALUE = "-" T
hen
&rowsetN1.DeleteRow(&I);
End-If;
End-If;
End-If;
Else
If &rowsetN1.GetRow(&I).MMC_TE_TRIA_BOM.DESCR254.VALUE = "-" Then
&rowsetN1.DeleteRow(&I);
End-If;
End-If;
End-For;
End-If;
End-Function;
/********************** mmcb.sds3426.en **********************/
[MMC_TE_OP_OC_WK.CGC_BRL.FieldChange]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 11/12/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Preenche automaticamente fornecedor.
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Vincius Alves Mello - MMC - 05/10/2010 - mmcb.sds3426
*
* Preenche automaticamente os dados do fornecedor.
*
********************************************************************************
*****************/
/*******************************************************************************
*****************
* Vincius Alves Mello - MMCB - 07/10/2010 - mmcb.sds3425 - Sistema Controle Terc
eiros
*
* Buscar condio de pagamento automaticamente, para notas de triangulao.
*
*******************************************************************************
*****************/
/********************** mmcb.sds3426.sn **********************/
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange;
If All(CGC_BRL) Then
&SETID_GERAL = BUSCA_SETID();
VENDOR_ID = "";
ADDRESS_SEQ_NUM = 0;
VNDR_LOC = "";
SQLExec("SELECT A.VENDOR_ID, A.ADDRESS_SEQ_NUM, C.VNDR_LOC FROM SYSADM.PS_VND
R_ADDR_SCROL A, SYSADM.PS_VENDOR B, SYSADM.PS_VENDOR_LOC C WHERE A.SETID = B.SET
ID AND A.VENDOR_ID = B.VENDOR_ID AND A.SETID = C.SETID AND A.VENDOR_ID = C.VENDO
End-If;
/********************** mmcb.sds3426.en **********************/
SQLExec("SELECT PYMNT_TERMS_CD FROM SYSADM.PS_VNDR_ADDR_SCROL A, SYSADM.PS
_VENDOR_LOC B WHERE B.SETID = A.SETID AND B.VENDOR_ID = A.VENDOR_ID AND B.REMIT_
ADDR_SEQ_NUM = A.ADDRESS_SEQ_NUM AND A.CGC_BRL=:1", CGC_BRL, NF_HDR_BRL.PYMNT_TE
RMS_CD); /*mmcb.sds3425.ln*/
End-If;
End-If;
/********************** mmcb.at2323.en **********************/
[MMC_TE_OP_OC_WK.NF_BRL_ID_2_BBL.FieldChange]
/*******************************************************************************
*****************
* Vincius Alves Mello - MMCB - 07/10/2010 - mmcb.sds3425 - Sistema Controle Terc
eiros
*
* Buscar condio de pagamento automaticamente, para notas de triangulao.
*
*******************************************************************************
*****************/
/********************** mmcb.sds3425.sn **********************/
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange;
If %Page = Page.MMC_TE_NF_OP Then
If All(BUSINESS_UNIT_IN) And
All(NF_BRL_ID_2_BBL) Then
&SETID_GERAL = BUSCA_SETID();
SQLExec("SELECT B.VENDOR_ID, B.ADDRESS_SEQ_NUM, C.CGC_BRL, E.VNDR_LOC FROM
SYSADM.PS_NF_HDR_BRL B, SYSADM.PS_VNDR_ADDR_SCROL C, SYSADM.PS_VENDOR D, SYSADM
.PS_VENDOR_LOC E WHERE B.BUSINESS_UNIT=:1 AND B.NF_BRL_ID=:2 AND B.NF_BRL_STATUS
= 'F' AND C.SETID = :3 AND C.VENDOR_ID = B.VENDOR_ID AND C.ADDRESS_SEQ_NUM = B.
ADDRESS_SEQ_NUM AND C.SETID = D.SETID AND C.VENDOR_ID = D.VENDOR_ID AND C.SETID
= E.SETID AND C.VENDOR_ID = E.VENDOR_ID AND C.ADDRESS_SEQ_NUM = E.ADDR_SEQ_NUM_O
RDR AND E.EFF_STATUS = 'A' AND E.EFFDT IN ( SELECT MAX (E_X.EFFDT) FROM SYSADM.P
S_VENDOR_LOC E_X WHERE E_X.SETID = E.SETID AND E_X.VENDOR_ID = E.VENDOR_ID AND E
_X.ADDR_SEQ_NUM_ORDR = E.ADDR_SEQ_NUM_ORDR AND E_X.EFF_STATUS = 'A')", BUSINESS_
UNIT_IN, NF_BRL_ID_2_BBL, &SETID_GERAL, VENDOR_ID, ADDRESS_SEQ_NUM, CGC_BRL, VND
R_LOC);
SQLExec("SELECT PYMNT_TERMS_CD FROM SYSADM.PS_VNDR_ADDR_SCROL A, SYSADM.PS
_VENDOR_LOC B WHERE B.SETID = A.SETID AND B.VENDOR_ID = A.VENDOR_ID AND B.REMIT_
ADDR_SEQ_NUM = A.ADDRESS_SEQ_NUM AND A.CGC_BRL=:1", CGC_BRL, NF_HDR_BRL.PYMNT_TE
RMS_CD);
End-If;
End-If;
/********************** mmcb.sds3425.en **********************/
[MMC_TE_OP_OC_WK.VENDOR_ID.FieldChange]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 01/11/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
End-If;
/********************** mmcb.at2323.en **********************/
/********************** mmcb.sds3426.sn **********************/
Gray(VNDR_LOC);
/********************** mmcb.sds3426.en **********************/
[MMC_TE_OP_WRK.BUSINESS_UNIT_IN.SaveEdit]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 12/12/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Customizao Sistema de Terceiros - No deixa os campos serem salvos em branco.
*
*******************************************************************************
*****************/
/********************** mmcb.at2323.sn **********************/
If %Component = Component.NF_INFO_PBL Then
If MMC_TE_RECV_WRK.MMC_TE_NFSERVI_FLG = "Y" Then
If None(BUSINESS_UNIT_IN) Or
None(NF_BRL_ID_2_BBL) Then
Error ("UN Servio ou NF Servio esto em branco.");
End-If;
End-If;
End-If;
/********************** mmcb.at2323.en **********************/
[MMC_TE_OP_WRK.BUSINESS_UNIT_PO.SaveEdit]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 13/12/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Customizao Sistema de Terceiros - No deixa os campos serem salvos em branco.
*
*******************************************************************************
*****************/
/********************** mmcb.at2323.sn **********************/
If %Component = Component.NF_INFO_PBL Then
If MMC_TE_RECV_WRK.MMC_TE_NFSERVI_FLG = "Y" Then
If None(BUSINESS_UNIT_PO) Or
None(PO_ID) Or
None(LINE_NBR) Or
None(SCHED_NBR) Then
Error ("Error Industrializao: Um dos campos Ordem Compra est em branco.");
End-If;
End-If;
End-If;
/********************** mmcb.at2323.en **********************/
[MMC_TE_OP_WRK.INV_ITEM_ID.FieldChange]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 17/12/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Customizao Sistema de Terceiros - Preencher automaticamente o campo de Industri
alizao
*
*******************************************************************************
*****************/
/********************** mmcb.at2323.sn **********************/
/*
Local Rowset &L;
If %Component = Component.NF_INFO_PBL Then
&L = GetLevel0();
&L_IND = &L(1).GetRowset(Scroll.NF_LN_BRL);
If All(&L_IND.GetRow(1).MMC_TE_OP_WRK.INV_ITEM_ID.VALUE) Then
For &NIND = 2 To &L_IND.ActiveRowCount;
&L_IND.GetRow(&NIND).MMC_TE_OP_WRK.INV_ITEM_ID.VALUE = &L_IND.GetRow(1)
.MMC_TE_OP_WRK.INV_ITEM_ID.VALUE;
End-For;
End-If;
End-If;
*/
/********************** mmcb.at2323.en **********************/
[MMC_TE_OP_WRK.INV_ITEM_ID.SaveEdit]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 14/12/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Customizao Sistema de Terceiros - No deixa os campos serem salvos em branco.
*
*******************************************************************************
*****************/
/********************** mmcb.at2323.sn **********************/
If %Component = Component.NF_INFO_PBL Then
If MMC_TE_RECV_WRK.MMC_TE_NFSERVI_FLG = "Y" Then
If None(INV_ITEM_ID) Or
None(MMC_TE_QTD_PAI) Then
Error ("Error: Campos Industrializao em branco.");
End-If;
End-If;
End-If;
/********************** mmcb.at2323.en **********************/
[MMC_TE_RECV_VND.ADDRESS_SEQ_NUM.FieldChange]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 15/11/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Preenche automaticamente CNPJ do fornecedor.
*****************************************************************************
*******************/
/*******************************************************************************
**
* Augusto Vilarinho Neto - MMCB - 05/11/2009 - mmcb.sds3239
*
* Projeto Implantao People - Multi Empresa MMCB-SVB.
*
********************************************************************************
*/
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange; /* mmc
b.sds3239.ln */
/********************** mmcb.at2323.sn **********************/
If All(VENDOR_ID) And
All(ADDRESS_SEQ_NUM) Then
/********************** mmcb.sds3239.so **********************/
/* SQLExec("Select A.CGC_BRL,B.DEFAULT_LOC FROM PS_VNDR_ADDR_SCROL A, PS_VE
NDOR B where A.SETID = B.SETID AND A.VENDOR_ID = B.VENDOR_ID AND A.SETID = 'MMCS
A' AND A.VENDOR_ID=:1 AND A.ADDRESS_SEQ_NUM =:2 ", VENDOR_ID, ADDRESS_SEQ_NUM, C
GC_BRL, VNDR_LOC);*/
/********************** mmcb.sds3239.eo **********************/
/********************** mmcb.sds3239.sn **********************/
SQLExec("Select A.CGC_BRL,B.DEFAULT_LOC FROM PS_VNDR_ADDR_SCROL A, PS_VENDOR
B where A.SETID = B.SETID AND A.VENDOR_ID = B.VENDOR_ID AND A.SETID = :1 AND A.V
ENDOR_ID=:2 AND A.ADDRESS_SEQ_NUM =:3 ", BUSCA_SETID(), VENDOR_ID, ADDRESS_SEQ_N
UM, CGC_BRL, VNDR_LOC);
/********************** mmcb.sds3239.en **********************/
End-If;
/********************** mmcb.at2323.en **********************/
[MMC_TE_RECV_VND.NF_BRL_SERIES.FieldChange]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 18/01/2008 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* No permitir documento fiscal igual entre NF de Remessa e NF Referencia.
*
*******************************************************************************
*****************/
/********************** mmcb.at2323.sn **********************/
If %Component = Component.NF_INFO_PBL Then
If NF_HDR_BRL.NF_BRL = NF_BRL And
NF_HDR_BRL.NF_BRL_SERIES = NF_BRL_SERIES Then
WinMessage("Erro: Documento Fiscal do Cabealho igual ao da Referencia");
NF_BRL = "";
NF_BRL_SERIES = "";
End-If;
End-If;
/********************** mmcb.at2323.en **********************/
[MMC_TE_RECV_VND.VENDOR_ID.FieldChange]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 01/11/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Preenche automaticamente CNPJ do fornecedor.
*****************************************************************************
*******************/
/********************** mmcb.at2323.sn **********************/
If All(VENDOR_ID) Then
SQLExec("Select A.CGC_BRL, B.ADDR_SEQ_NUM_ORDR, B.DEFAULT_LOC FROM PS_VNDR_AD
DR_SCROL A, PS_VENDOR B where A.SETID = B.SETID AND A.VENDOR_ID = B.VENDOR_ID AN
D A.SETID = :1 and A.VENDOR_ID = :2", MMC_TE_RECV_WRK.SETID, VENDOR_ID, CGC_BRL,
ADDRESS_SEQ_NUM, VNDR_LOC);
If VENDOR_ID = MMC_TE_RECV_WRK.VENDOR_ID Then
WinMessage("Fornecedor de Industrializao deve ser diferente do fornecedor de
Insumos.");
VENDOR_ID = "";
End-If;
End-If;
/********************** mmcb.at2323.en **********************/
[MMC_TE_RECV_WRK.ADDRESS_SEQ_NUM.FieldChange]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 15/11/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Preenche automaticamente CNPJ do fornecedor.
*****************************************************************************
****************/
/*******************************************************************************
**
* Augusto Vilarinho Neto - MMCB - 05/11/2009 - mmcb.sds3239
*
* Projeto Implantao People - Multi Empresa MMCB-SVB.
*
*******************************************************************************
*/
/*******************************************************************************
*****************
* Douglas/Itamar Junior (Enc. Dhyogo Almeida) - SVB - 21/07/2014 - mmcb.hd20860
2 - Buscando *
* a cidade do fornecedor de forma incorreta.
*
*******************************************************************************
****************/
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange; /* mmc
b.sds3239.ln */
&SETID_GERAL = BUSCA_SETID(); /* mmcb.sds3239.ln */
/********************** mmcb.at2323.sn **********************/
If All(VENDOR_ID) And
All(ADDRESS_SEQ_NUM) Then
/********************** mmcb.sds3239.so **********************/
/* SQLExec("Select A.CGC_BRL,B.DEFAULT_LOC FROM PS_VNDR_ADDR_SCROL A, PS_VE
NDOR B where A.SETID = B.SETID AND A.VENDOR_ID = B.VENDOR_ID AND A.SETID = 'MMCS
A' AND A.VENDOR_ID=:1 AND A.ADDRESS_SEQ_NUM =:2 ", VENDOR_ID, ADDRESS_SEQ_NUM, C
GC_BRL, VNDR_LOC);*/
/********************** mmcb.sds3239.eo **********************/
/********************** mmcb.hd208602.so **********************
/********************** mmcb.sds3239.sn ***********************
SQLExec("Select A.CGC_BRL,B.DEFAULT_LOC FROM PS_VNDR_ADDR_SCROL A, PS_VENDOR
B where A.SETID = B.SETID AND A.VENDOR_ID = B.VENDOR_ID AND A.SETID = :1 AND A.V
ENDOR_ID=:2 AND A.ADDRESS_SEQ_NUM =:3 ", &SETID_GERAL, VENDOR_ID, ADDRESS_SEQ_NU
M, CGC_BRL, VNDR_LOC);
/********************** mmcb.sds3239.en ***********************
*********************** mmcb.hd208602.eo *********************/
/********************** mmcb.hd208602.sn **********************/
SQLExec("Select A.CGC_BRL, A.DESCR FROM PS_VNDR_ADDR_SCROL A, PS_VENDOR B whe
re A.SETID = B.SETID AND A.VENDOR_ID = B.VENDOR_ID AND A.SETID = :1 AND A.VENDOR
_ID=:2 AND A.ADDRESS_SEQ_NUM =:3 ", &SETID_GERAL, VENDOR_ID, ADDRESS_SEQ_NUM, CG
C_BRL, VNDR_LOC);
/********************** mmcb.hd208602.en **********************/
End-If;
/********************** mmcb.at2323.en **********************/
[MMC_TE_RECV_WRK.BUTTON.FieldChange]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 01/11/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Customizao Sistema de Terceiros - Cria linha do recebimento, automticamente, pel
a OC. *
********** ********************************************************************
******************/
/********************** mmcb.at2323.sn **********************/
If %Page = Page.MMC_TE_RECV Then
&LEVEL1 = GetRowset(Scroll.MMC_TE_OC_VW);
[MMC_TE_RECV_WRK.CGC_BRL.FieldChange]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 11/12/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Preenche automaticamente fornecedor.
*
*******************************************************************************
****************/
/*******************************************************************************
*****************
* Itamar Junior - SVB - 18/07/2014 - mmcb.hd207896 - Pgina puxando o endereo de f
ornecedor
*
* errado.
*
*******************************************************************************
****************/
/*******************************************************************************
*****************
* Douglas/Itamar Junior (Enc. Dhyogo Almeida) - MMCB - 21/07/2014 - mmcb.hd2081
17 - Buscando *
* a cidade do fornecedor de forma incorreta.
*
*******************************************************************************
****************/
/********************** mmcb.at2323.sn **********************/
If All(CGC_BRL) Then
/********************** mmcb.hd207896.so **********************
SQLExec("Select A.VENDOR_ID, B.ADDR_SEQ_NUM_ORDR, B.DEFAULT_LOC FROM PS_VNDR_
ADDR_SCROL A, PS_VENDOR B where A.SETID = B.SETID AND A.VENDOR_ID = B.VENDOR_ID
AND A.SETID = :1 and A.CGC_BRL = :2", SETID, CGC_BRL, VENDOR_ID, ADDRESS_SEQ_NUM
, VNDR_LOC);
********************** mmcb.hd207896.eo **********************/
/********************** mmcb.hd208117.so **********************
/********************** mmcb.hd207896.sn **********************
SQLExec("Select A.VENDOR_ID, A.ADDRESS_SEQ_NUM, B.DEFAULT_LOC FROM PS_VNDR_AD
DR_SCROL A, PS_VENDOR B where A.SETID = B.SETID AND A.VENDOR_ID = B.VENDOR_ID AN
D A.SETID = :1 and A.CGC_BRL = :2", SETID, CGC_BRL, VENDOR_ID, ADDRESS_SEQ_NUM,
VNDR_LOC);
/********************** mmcb.hd207896.en **********************
*********************** mmcb.hd208117.eo **********************/
/********************** mmcb.hd208117.sn **********************/
SQLExec("Select A.VENDOR_ID, A.ADDRESS_SEQ_NUM, A.DESCR FROM PS_VNDR_ADDR_SCR
OL A, PS_VENDOR B where A.SETID = B.SETID AND A.VENDOR_ID = B.VENDOR_ID AND A.SE
TID = :1 and A.CGC_BRL = :2", SETID, CGC_BRL, VENDOR_ID, ADDRESS_SEQ_NUM, VNDR_L
OC);
/********************** mmcb.hd208117.en **********************/
End-If;
/********************** mmcb.at2323.en **********************/
[MMC_TE_RECV_WRK.MMC_TE_NFSERVI_FLG.FieldChange]
/*******************************************************************************
*****
Wagner Sorio - MMC - 12/12/2007 - mmcb.at2323 - Sistema Controle Terceiros
[MMC_TE_TOF_TYPE.MMC_OF_IDENT.SaveEdit]
If None(MMC_OF_IDENT) Then
Error ("Preenchimento do campo: Identificao Operao Fiscal obrigatrio.");
End-If;
[MMC_TE_TRIA_WRK.ADDRESS_SEQ_NUM.FieldChange]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 15/11/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Preenche automaticamente CNPJ do fornecedor.
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Augusto Vilarinho Neto - MMCB - 05/11/2009 - mmcb.sds3239
*
* Projeto Implantao People - Multi Empresa MMCB-SVB.
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Vincius Alves Mello - MMC - 05/10/2010 - mmcb.sds3426
*
* Preencher dados fornecedor.
*
*******************************************************************************
*****************/
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange; /* mmc
b.sds3239.ln */
&SETID_GERAL = BUSCA_SETID(); /* mmcb.sds3239.ln */
/********************** mmcb.at2323.sn ***********************/
If All(VENDOR_ID) And
All(ADDRESS_SEQ_NUM) Then
/********************** mmcb.sds3239.so **********************/
/* SQLExec("Select A.CGC_BRL,B.DEFAULT_LOC FROM PS_VNDR_ADDR_SCROL A, PS_VE
NDOR B where A.SETID = B.SETID AND A.VENDOR_ID = B.VENDOR_ID AND A.SETID = 'MMCS
A' AND A.VENDOR_ID=:1 AND A.ADDRESS_SEQ_NUM =:2 ", VENDOR_ID, ADDRESS_SEQ_NUM, C
GC_BRL, VNDR_LOC);*/
/********************** mmcb.sds3239.eo **********************/
/********************** mmcb.sds3426.so **********************/
/********************** mmcb.sds3239.sn **********************/
/*SQLExec("Select A.CGC_BRL,B.DEFAULT_LOC FROM PS_VNDR_ADDR_SCROL A, PS_VENDO
R B where A.SETID = B.SETID AND A.VENDOR_ID = B.VENDOR_ID AND A.SETID = :1 AND A
.VENDOR_ID=:2 AND A.ADDRESS_SEQ_NUM =:3 ", &SETID_GERAL, VENDOR_ID, ADDRESS_SEQ_
NUM, CGC_BRL, VNDR_LOC);*/
/********************** mmcb.sds3239.en **********************/
/********************** mmcb.sds3426.eo **********************/
/********************** mmcb.sds3426.sn **********************/
CGC_BRL = "";
VNDR_LOC = "";
End-If;
End-For;
/************************** mmcb.sds3425.en **************************/
End-If;
End-For;
REM Codigo para validar se existe numero de NF Duplicado ;
REM LIMPA AS NFS QUE NO FORAM SELECIONADAS ;
For &N1 = &L1.ActiveRowCount To 1 Step - 1;
&NF_ID_ANTERIOR = &L1.GetRow(&N1).MMC_TE_S_NF_VW.NF_BRL_ID.VALUE;
&NF_LN_ANTERIOR = &L1.GetRow(&N1).MMC_TE_S_NF_VW.NF_BRL_LINE_NUM.VALUE;
For &N2 = &L1.ActiveRowCount To 1 Step - 1;
If &N1 <> &N2 Then
&NF_ID_NOVA = &L1.GetRow(&N2).MMC_TE_S_NF_VW.NF_BRL_ID.VALUE;
&NF_LN_NOVA = &L1.GetRow(&N2).MMC_TE_S_NF_VW.NF_BRL_LINE_NUM.VALUE;
If (&NF_ID_ANTERIOR = &NF_ID_NOVA) And
(&NF_LN_ANTERIOR = &NF_LN_NOVA) Then
&L1.DeleteRow(&N2);
End-If;
End-If;
End-For;
End-For;
REM FIM Codigo para validar se existe numero de NF Duplicado ;
/************************** mmcb.sds3425.sn **************************/
For &N1 = 1 To &L1.ActiveRowCount;
If &L1.GetRow(&N1).MMC_TE_WRK.MMC_TE_CONFI_FLG.VALUE = "N" And
&L1.GetRow(&N1).MMC_TE_WRK.MMC_SALDO.VALUE > 0 And
&L1.GetRow(&N1).MMC_TE_WRK.MMC_SALDO.VALUE > &L1.GetRow(&N1).MMC_TE_
S_NF_VW.QTY_AVAILABLE.VALUE Then
&V_QTY_SALDO = &L1.GetRow(&N1).MMC_TE_WRK.MMC_SALDO.VALUE - &L1.GetRow(
&N1).MMC_TE_S_NF_VW.QTY_AVAILABLE.VALUE;
&L1.GetRow(&N1).MMC_TE_WRK.QTY_OPEN.VALUE = &L1.GetRow(&N1).MMC_TE_S_NF
_VW.QTY_AVAILABLE.VALUE;
&L1.GetRow(&N1).MMC_TE_WRK.MMC_TE_CONFI_FLG.VALUE = "Y";
&L1.GetRow(&N1).MMC_TE_WRK.MMC_TE_CONFI_FLG.Enabled = False;
&L1.GetRow(&N1).MMC_TE_WRK.QTY_OPEN.Enabled = False;
For &N2 = 1 To &L1.ActiveRowCount;
If &L1.GetRow(&N1).MMC_TE_S_NF_VW.INV_ITEM_ID.VALUE = &L1.GetRow(&N2
).MMC_TE_S_NF_VW.INV_ITEM_ID.VALUE Then
&L1.GetRow(&N2).MMC_TE_WRK.MMC_SALDO.VALUE = &V_QTY_SALDO;
End-If;
End-For;
Else
If &L1.GetRow(&N1).MMC_TE_WRK.MMC_TE_CONFI_FLG.VALUE = "N" And
&L1.GetRow(&N1).MMC_TE_WRK.MMC_SALDO.VALUE > 0 And
&L1.GetRow(&N1).MMC_TE_WRK.MMC_SALDO.VALUE <= &L1.GetRow(&N1).MMC
_TE_S_NF_VW.QTY_AVAILABLE.VALUE Then
&V_QTY_SALDO = 0;
&L1.GetRow(&N1).MMC_TE_WRK.QTY_OPEN.VALUE = &L1.GetRow(&N1).MMC_TE_W
RK.MMC_SALDO.VALUE;
&L1.GetRow(&N1).MMC_TE_WRK.MMC_TE_CONFI_FLG.VALUE = "Y";
&L1.GetRow(&N1).MMC_TE_WRK.MMC_TE_CONFI_FLG.Enabled = False;
&L1.GetRow(&N1).MMC_TE_WRK.QTY_OPEN.Enabled = False;
For &N2 = 1 To &L1.ActiveRowCount;
If &L1.GetRow(&N1).MMC_TE_S_NF_VW.INV_ITEM_ID.VALUE = &L1.GetRow(
&N2).MMC_TE_S_NF_VW.INV_ITEM_ID.VALUE Then
&L1.GetRow(&N2).MMC_TE_WRK.MMC_SALDO.VALUE = &V_QTY_SALDO;
End-If;
End-For;
End-If;
End-If;
End-For;
For &N1 = &L1.ActiveRowCount To 1 Step - 1;
If &L1.GetRow(&N1).MMC_TE_WRK.MMC_TE_CONFI_FLG.VALUE = "N" And
&L1.GetRow(&N1).MMC_TE_WRK.MMC_SALDO.VALUE = 0 Then
&L1.DeleteRow(&N1);
End-If;
End-For;
/************************** mmcb.sds3425.en **************************/
MMC_TE_TRIA_WRK.BUTTON.Enabled = False;
MMC_TE_TRIA_WRK.BUTTON1.Enabled = False;
MMC_TE_TRIA_WRK.BTN_COPY.Enabled = False;
MMC_TE_TRIA_WRK.VENDOR_ID.Enabled = False;
MMC_TE_TRIA_WRK.MMC_STOCK_UN.Enabled = False;
MMC_TE_TRIA_WRK.MMC_TE_TIPO_RECEBI.Enabled = False;
MMC_TE_TRIA_WRK.ADDRESS_SEQ_NUM.Enabled = False;
MMC_TE_TRIA_WRK.CGC_BRL.Enabled = False;
MMC_TE_TRIA_WRK.VNDR_LOC.Enabled = False;
MMC_TE_TRIA_WRK.NF_BRL.Enabled = False;
MMC_TE_TRIA_WRK.NF_BRL_SERIES.Enabled = False;
MMC_TE_TRIA_WRK.INV_ITEM_ID.Enabled = False;
End-If;
/********************** mmcb.at2323.en **********************/
[MMC_TE_TRIA_WRK.BUTTON.FieldChange]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 01/11/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Customizao Sistema de Terceiros - Cria linha do recebimento, automticamente, pel
a OC. *
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Claudio Henrique da Costa - MMC - 03/06/2008 - mmcb.sds2701
*
* Correo do programa - Apagando Linha com retorno indicado em nova pesquisa.
*
*******************************************************************************
*****************/
/********************** mmcb.at2323.sn **********************/
If %Page = Page.MMC_TE_RECV_TRIAN Then
&L1 = GetRowset(Scroll.MMC_TE_S_NF_VW);
If &L1.GetRow(1).MMC_TE_S_NF_VW.NF_BRL_ID.VALUE = "NEXT" Then
&L1.Flush();
End-If;
/*
If None(MMC_STOCK_UN) Then
WinMessage("O Campo BU Remessa Obrigatrio.");
Exit;
End-If;
*/
&condicao = " where ";
If All(MMC_STOCK_UN) Then
&condicao = &condicao | " business_unit= '" | MMC_STOCK_UN | "'";
End-If;
If All(VENDOR_ID) Then
&condicao = &condicao | " and vendor_id='" | VENDOR_ID | "' ";
Else
WinMessage("O Campo fornecedor Obrigatorio.");
Exit;
End-If;
If All(NF_BRL) Then
&condicao = &condicao | " and nf_brl ='" | NF_BRL | "'";
End-If;
If All(NF_BRL_SERIES) Then
&condicao = &condicao | " and nf_brl_series='" | NF_BRL_SERIES | "'";
End-If;
If All(INV_ITEM_ID) Then
&condicao = &condicao | " and inv_item_id='" | INV_ITEM_ID | "'";
End-If;
&condicao = &condicao | " AND MMC_EDI_FLAG = 'N' ";
For &Q = &L1.ACTIVEROWCOUNT To 1 Step - 1;
If &L1.GetRow(&Q).MMC_TE_WRK.MMC_TE_CONFI_FLG.VALUE <> "Y" Then
&L1.DeleteRow(&Q);
End-If
End-For;
&L1.Select(Record.MMC_TE_S_NF_VW, &condicao);
REM Codigo para validar se existe numero de NF Duplicado ;
REM LIMPA AS NFS QUE NO FORAM SELECIONADAS ;
For &N1 = &L1.ActiveRowCount To 1 Step - 1;
&NF_ID_ANTERIOR = &L1.GetRow(&N1).MMC_TE_S_NF_VW.NF_BRL_ID.VALUE;
&NF_LN_ANTERIOR = &L1.GetRow(&N1).MMC_TE_S_NF_VW.NF_BRL_LINE_NUM.VALUE;
For &N2 = &L1.ActiveRowCount To 1 Step - 1;
If &N1 <> &N2 Then
&NF_ID_NOVA = &L1.GetRow(&N2).MMC_TE_S_NF_VW.NF_BRL_ID.VALUE;
&NF_LN_NOVA = &L1.GetRow(&N2).MMC_TE_S_NF_VW.NF_BRL_LINE_NUM.VALUE;
If (&NF_ID_ANTERIOR = &NF_ID_NOVA) And
(&NF_LN_ANTERIOR = &NF_LN_NOVA) Then
If &L1.GetRow(&N2).MMC_TE_WRK.MMC_TE_CONFI_FLG.VALUE <> "Y" Then
/* mmcb.sds2701.n */
&L1.DeleteRow(&N2);
End-If; /* mmcb.sds2701.n */
End-If;
End-If;
End-For;
End-For;
REM FIM Codigo para validar se existe numero de NF Duplicado ;
End-If;
/********************** mmcb.at2323.en **********************/
[MMC_TE_TRIA_WRK.BUTTON1.FieldChange]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 01/11/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Customizao Sistema de Terceiros - Cria linha do recebimento, automticamente, pel
a OC. *
********** ********************************************************************
******************/
/********************** mmcb.at2323.sn **********************/
If %Page = Page.MMC_TE_RECV_TRIAN Then
&L1 = GetRowset(Scroll.MMC_TE_S_NF_VW);
&L1.Flush();
End-If;
/********************** mmcb.at2323.en **********************/
[MMC_TE_TRIA_WRK.BUTTON2.FieldChange]
/*******************************************************************************
*****************
* Vincius Alves Mello - MMC - 05/10/2010 - mmcb.sds3426 - Sistema Controle Terce
iros
*
* Realizar a verificao entre os itens da NF de retorno e o BOM.
*
*******************************************************************************
*****************/
/********************** mmcb.sds3426.sn **********************/
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange;
If %Page = Page.MMC_TE_RECV_TRIAN Then
&SETID = BUSCA_SETID();
&V_DATA_HORA = %Datetime;
&V_OPRID = %OperatorId;
&rowsetN1 = GetRowset(Scroll.MMC_TE_TRIA_BOM);
&rowsetN2 = GetRowset(Scroll.MMC_TE_S_NF_VW);
If None(MMC_ITEM_PAI) Or
None(MMC_TE_QTD_PAI) Then
WinMessage("Favor informe o Item Pai e a sua Quantidade.");
Exit;
End-If;
For &I = &rowsetN1.ActiveRowCount To 1 Step - 1;
&rowsetN1.DeleteRow(&I);
End-For;
SQLExec("SELECT BUSINESS_UNIT_IN, SHIPTO_ID FROM SYSADM.PS_SHIPTO_TBL WHERE S
ETID=:1 AND BUSINESS_UNIT_RECV=:2", &SETID, NF_HDR_BRL.BUSINESS_UNIT, &BU_INDUST
, &LOC_INDUST);
&SQL = CreateSQL("SELECT X.COMPONENT_ID, SUM(X.QTY_PER) AS QTY_PER FROM ( SEL
ECT CONNECT_BY_ROOT C.INV_ITEM_ID CARRO, C.COMPONENT_ID, C.QTY_PER FROM SYSADM.P
S_EN_BOM_COMPS C WHERE C.BUSINESS_UNIT = :1 AND C.BOM_STATE = 'PR' AND C.BOM_TYP
E = 'PR' AND SYSDATE BETWEEN C.DATE_IN_EFFECT AND C.DATE_OBSOLETE CONNECT BY NOC
YCLE PRIOR C.COMPONENT_ID = C.INV_ITEM_ID START WITH C.INV_ITEM_ID = :3 AND SYSD
ATE BETWEEN C.DATE_IN_EFFECT AND C.DATE_OBSOLETE ORDER BY C.COMPONENT_ID ) X GRO
UP BY X.COMPONENT_ID", &BU_INDUST, &LOC_INDUST, MMC_ITEM_PAI);
&LINHA = 1;
While &SQL.Fetch(&V_COMPONENT_ID, &V_QTY_PER)
&rowsetN1.InsertRow(&LINHA);
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.BUSINESS_UNIT.VALUE = NF_HDR_BRL.
BUSINESS_UNIT;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.NF_BRL.VALUE = NF_HDR_BRL.NF_BRL;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.NF_BRL_SERIES.VALUE = NF_HDR_BRL.
NF_BRL_SERIES;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.VENDOR_ID.VALUE = VENDOR_ID;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.ADDRESS_SEQ_NUM.VALUE = ADDRESS_S
EQ_NUM;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.DT_TIMESTAMP.VALUE = &V_DATA_HORA
;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.SEQ_NBR.VALUE = &LINHA;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.MMC_OPRID.VALUE = &V_OPRID;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.INV_ITEM_ID.VALUE = &V_COMPONENT_
ID;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.DESCR254.VALUE = "-";
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.QTY_PER.VALUE = &V_QTY_PER * MMC_
TE_QTD_PAI;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE = 0;
&LINHA = &LINHA + 1;
End-While;
For &I = &rowsetN2.ActiveRowCount To 1 Step - 1;
If &rowsetN2.GetRow(&I).MMC_TE_WRK.MMC_TE_CONFI_FLG.VALUE = "Y" Then
&statusLinha = "NOT OK";
For &j = &rowsetN1.ActiveRowCount To 1 Step - 1;
If &rowsetN2.GetRow(&I).MMC_TE_S_NF_VW.INV_ITEM_ID.VALUE = &rowsetN1
.GetRow(&j).MMC_TE_TRIA_BOM.INV_ITEM_ID.VALUE And
&rowsetN1.GetRow(&j).MMC_TE_TRIA_BOM.DESCR254.VALUE = "-" Then
&statusLinha = "OK";
&valorTeste = &rowsetN1.GetRow(&j).MMC_TE_TRIA_BOM.QTY_PER_BASE.V
ALUE + &rowsetN2.GetRow(&I).MMC_TE_WRK.QTY_OPEN.VALUE;
&rowsetN1.GetRow(&j).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE = &rowset
N1.GetRow(&j).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE + &rowsetN2.GetRow(&I).MMC_TE_W
RK.QTY_OPEN.VALUE;
Else
If &rowsetN2.GetRow(&I).MMC_TE_S_NF_VW.INV_ITEM_ID.VALUE = &rowse
tN1.GetRow(&j).MMC_TE_TRIA_BOM.INV_ITEM_ID.VALUE And
&rowsetN1.GetRow(&j).MMC_TE_TRIA_BOM.QTY_PER.VALUE > 0 And
&rowsetN1.GetRow(&j).MMC_TE_TRIA_BOM.DESCR254.VALUE = "Item
no encontrado no BOM." Then
&statusLinha = "OK";
&rowsetN1.GetRow(&j).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE = &row
setN1.GetRow(&j).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE + &rowsetN2.GetRow(&I).MMC_T
E_WRK.QTY_OPEN.VALUE;
&rowsetN1.GetRow(&j).MMC_TE_TRIA_BOM.DESCR254.VALUE = "-";
Else
If &rowsetN2.GetRow(&I).MMC_TE_S_NF_VW.INV_ITEM_ID.VALUE = &ro
wsetN1.GetRow(&j).MMC_TE_TRIA_BOM.INV_ITEM_ID.VALUE And
&rowsetN1.GetRow(&j).MMC_TE_TRIA_BOM.DESCR254.VALUE = "I
tem no encontrado no BOM." Then
&statusLinha = "OK";
&rowsetN1.GetRow(&j).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE = &
rowsetN1.GetRow(&j).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE + &rowsetN2.GetRow(&I).MM
C_TE_WRK.QTY_OPEN.VALUE;
End-If;
End-If;
End-If;
End-For;
If &statusLinha = "NOT OK" Then
&rowsetN1.InsertRow(&LINHA);
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.BUSINESS_UNIT.VALUE = NF_HD
R_BRL.BUSINESS_UNIT;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.NF_BRL.VALUE = NF_HDR_BRL.N
F_BRL;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.NF_BRL_SERIES.VALUE = NF_HD
R_BRL.NF_BRL_SERIES;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.VENDOR_ID.VALUE = VENDOR_ID
;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.ADDRESS_SEQ_NUM.VALUE = ADD
RESS_SEQ_NUM;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.DT_TIMESTAMP.VALUE = &V_DAT
A_HORA;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.SEQ_NBR.VALUE = &LINHA;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.MMC_OPRID.VALUE = &V_OPRID;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.INV_ITEM_ID.VALUE = &rowset
N2.GetRow(&I).MMC_TE_S_NF_VW.INV_ITEM_ID.VALUE;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.DESCR254.VALUE = "Item no en
contrado no BOM.";
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.QTY_PER.VALUE = 0;
&rowsetN1.GetRow(&LINHA).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE = &rowse
tN2.GetRow(&I).MMC_TE_WRK.QTY_OPEN.VALUE;
&LINHA = &LINHA + 1;
End-If;
End-If;
End-For;
&rowsetN1.DeleteRow(&LINHA);
For &I = &rowsetN1.ActiveRowCount To 1 Step - 1;
If &rowsetN1.GetRow(&I).MMC_TE_TRIA_BOM.QTY_PER.VALUE <> &rowsetN1.GetRow(
&I).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE And
&rowsetN1.GetRow(&I).MMC_TE_TRIA_BOM.DESCR254.VALUE = "-" Then
If &rowsetN1.GetRow(&I).MMC_TE_TRIA_BOM.QTY_PER.VALUE > 0 And
&rowsetN1.GetRow(&I).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE > 0 Then
&rowsetN1.GetRow(&I).MMC_TE_TRIA_BOM.DESCR254.VALUE = "Quantidade do
BOM (" | &rowsetN1.GetRow(&I).MMC_TE_TRIA_BOM.QTY_PER.VALUE | ") esta diferente
da quantidade da NF (" | &rowsetN1.GetRow(&I).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALU
E | ").";
Else
If &rowsetN1.GetRow(&I).MMC_TE_TRIA_BOM.QTY_PER.VALUE > 0 And
&rowsetN1.GetRow(&I).MMC_TE_TRIA_BOM.QTY_PER_BASE.VALUE = 0 Th
en
&rowsetN1.GetRow(&I).MMC_TE_TRIA_BOM.DESCR254.VALUE = "Item no enc
ontrado na NF.";
Else
If &rowsetN1.GetRow(&I).MMC_TE_TRIA_BOM.DESCR254.VALUE = "-" Then
&rowsetN1.DeleteRow(&I);
End-If;
End-If;
End-If;
Else
If &rowsetN1.GetRow(&I).MMC_TE_TRIA_BOM.DESCR254.VALUE = "-" Then
&rowsetN1.DeleteRow(&I);
End-If;
End-If;
End-For;
End-If;
/********************** mmcb.sds3426.en **********************/
[MMC_TE_TRIA_WRK.CGC_BRL.FieldChange]
/*******************************************************************************
*****************
* Vincius Alves Mello - MMC - 05/10/2010 - mmcb.sds3426
*
* Preenche automaticamente os dados do fornecedor.
*
********************************************************************************
*****************/
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange;
If All(CGC_BRL) Then
&SETID_GERAL = BUSCA_SETID();
VENDOR_ID = "";
ADDRESS_SEQ_NUM = 0;
VNDR_LOC = "";
SQLExec("SELECT A.VENDOR_ID, A.ADDRESS_SEQ_NUM, C.VNDR_LOC FROM SYSADM.PS_VND
=
=
=
=
=
=
=
=
=
=
=
=
"";
&sql2
&sql2
&sql2
&sql2
&sql2
&sql2
&sql2
&sql2
&sql2
&sql2
&sql2
|
|
|
|
|
|
|
|
|
|
|
&sql2
&sql2
&sql2
&sql2
&sql2
&sql2
&sql2
=
=
=
=
=
=
=
&sql2
&sql2
&sql2
&sql2
&sql2
&sql2
&sql2
|
|
|
|
|
|
|
"
"
"
"
"
"
"
AND
AND
AND
AND
AND
AND
AND
A.VNDR_STATUS_PO
B.CGC_BRL
C.SETID
C.VENDOR_ID
C.REMIT_ADDR_SEQ_NUM
C.EFF_STATUS
C.EFFDT
=
=
=
=
=
=
=
'Y' ";
'" | &CGC_BRL | "' ";
B.SETID ";
B.VENDOR_ID ";
B.ADDRESS_SEQ_NUM ";
'A' ";
(SELECT MAX(X.EFFDT) "
;
&sql2 = &sql2 | "
FROM SYSADM.PS_VENDO
R_LOC X ";
&sql2 = &sql2 | "
WHERE X.SETID
= C
.SETID ";
&sql2 = &sql2 | "
AND X.VENDOR_ID = C
.VENDOR_ID ";
&sql2 = &sql2 | "
AND X.VNDR_LOC = C
.VNDR_LOC ";
&sql2 = &sql2 | "
AND X.EFFDT
<= S
YSDATE) ";
SQLExec(&sql2, &VENDOR_ID, &NAME1, &ADDRESS_SEQ_NUM, &VNDR_LOC);
If None(&VENDOR_ID) Then
Error ("No foi possvel localizar os dados do Fornecedor da NF-e.");
End-If;
VENDOR_ID = &VENDOR_ID;
ADDRESS_SEQ_NUM = &ADDRESS_SEQ_NUM;
CGC_BRL = &CGC_BRL;
VNDR_LOC = &VNDR_LOC;
Gray(VNDR_LOC);
If MMC_TE_TIPO_RECEBI = "N" Then
MERCHANDISE_AMT = &MERCHANDISE_AMT;
UnHide(MERCHANDISE_AMT);
Else
MERCHANDISE_AMT = 0;
End-If;
End-If;
Else
SetDefault(MERCHANDISE_AMT);
Hide(MERCHANDISE_AMT);
End-If;
End-If;
[MMC_TE_TRIA_WRK.MMC_ITEM_PAI.FieldChange]
/*******************************************************************************
*****************
* Vincius Alves Mello - MMC - 05/10/2010 - mmcb.sds3426 - Sistema Controle Tercei
ros
*
* Validar se o item pai possui BOM cadastrado.
*
********************************************************************************
*****************/
/********************** mmcb.sds3426.sn **********************/
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange;
If %Page = Page.MMC_TE_RECV_TRIAN Then
If All(MMC_ITEM_PAI) Then
&SETID_GERAL = BUSCA_SETID();
&QTY_COMP = 0;
SQLExec("SELECT BUSINESS_UNIT_IN, SHIPTO_ID FROM SYSADM.PS_SHIPTO_TBL WHER
E SETID=:1 AND BUSINESS_UNIT_RECV=:2", &SETID_GERAL, NF_HDR_BRL.BUSINESS_UNIT, &
BU_INDUST, &LOC_INDUST);
SQLExec("SELECT COUNT(*) AS QTY FROM ( SELECT CONNECT_BY_ROOT C.INV_ITEM_I
D CARRO, C.COMPONENT_ID, C.QTY_PER FROM SYSADM.PS_EN_BOM_COMPS C WHERE C.BUSINES
S_UNIT = :1 AND C.BOM_STATE = 'PR' AND C.BOM_TYPE = 'PR' AND SYSDATE BETWEEN C.D
ATE_IN_EFFECT AND C.DATE_OBSOLETE CONNECT BY NOCYCLE PRIOR C.COMPONENT_ID = C.IN
V_ITEM_ID START WITH C.INV_ITEM_ID = :3 AND SYSDATE BETWEEN C.DATE_IN_EFFECT AND
C.DATE_OBSOLETE ORDER BY C.COMPONENT_ID ) X", &BU_INDUST, &LOC_INDUST, MMC_ITEM
_PAI, &QTY_COMP);
If &QTY_COMP <= 0 Then
Error ("No existem BOM cadastrado para este item.");
End-If;
End-If;
End-If;
/********************** mmcb.sds3426.en **********************/
[MMC_TE_TRIA_WRK.VENDOR_ID.FieldChange]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 23/11/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Preenche automaticamente dados do fornecedor
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Vincius Alves Mello - MMC - 05/10/2010 - mmcb.sds3426 - Sistema Controle Terce
iros
*
* Preencher dados fornecedor
*
*******************************************************************************
*****************/
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange; /*mmcb
.sds3426.ln*/
/********************** mmcb.at2323.sn **********************/
/*SQLExec("Select setid from ps_set_cntrl_tbl where setcntrlvalue = :1", NF_HDR_
BRL.BUSINESS_UNIT, &VAR_SERID);*/ /*mmcb.sds3426.lo*/
If All(VENDOR_ID) Then
/********************** mmcb.sds3426.so **********************/
/*SQLExec("Select A.CGC_BRL, B.ADDR_SEQ_NUM_ORDR, B.DEFAULT_LOC FROM PS_VNDR_
ADDR_SCROL A, PS_VENDOR B where A.SETID = B.SETID AND A.VENDOR_ID = B.VENDOR_ID
AND A.SETID = :1 and A.VENDOR_ID = :2", &VAR_SERID, VENDOR_ID, CGC_BRL, ADDRESS_
SEQ_NUM, VNDR_LOC);*/
/********************** mmcb.sds3426.eo **********************/
/********************** mmcb.sds3426.sn **********************/
&SETID_GERAL = BUSCA_SETID();
CGC_BRL = "";
ADDRESS_SEQ_NUM = 0;
VNDR_LOC = "";
SQLExec("SELECT A.CGC_BRL, A.ADDRESS_SEQ_NUM, C.VNDR_LOC FROM SYSADM.PS_VNDR_
ADDR_SCROL A, SYSADM.PS_VENDOR B, SYSADM.PS_VENDOR_LOC C WHERE A.SETID = B.SETID
AND A.VENDOR_ID = B.VENDOR_ID AND A.SETID = C.SETID AND A.VENDOR_ID = C.VENDOR_
ID AND A.ADDRESS_SEQ_NUM = C.ADDR_SEQ_NUM_ORDR AND C.EFF_STATUS = 'A' AND C.EFFD
T IN ( SELECT MAX(C_X.EFFDT) FROM SYSADM.PS_VENDOR_LOC C_X WHERE C_X.SETID = C.S
ETID AND C_X.VENDOR_ID = C.VENDOR_ID AND C_X.ADDR_SEQ_NUM_ORDR = C.ADDR_SEQ_NUM_
ORDR AND C_X.EFF_STATUS = 'A' ) AND A.SETID = :1 and A.VENDOR_ID = :2 AND ROWNUM
= 1", &SETID_GERAL, VENDOR_ID, CGC_BRL, ADDRESS_SEQ_NUM, VNDR_LOC);
/********************** mmcb.sds3426.en **********************/
&L1 = GetRowset(Scroll.MMC_TE_S_NF_VW);
&L1.Flush();
End-If;
/********************** mmcb.at2323.en **********************/
/********************** mmcb.sds3426.sn **********************/
Gray(VNDR_LOC);
/********************** mmcb.sds3426.en **********************/
[MMC_TE_WRK.BTN_REFRESH.FieldChange]
/*******************************************************************************
*********
Wagner Sorio - MMC - 10/10/2007 - mmcb.at2323 - Sistema Controle Terceiros
Fazer pequisa e Preencher o GRID das Requisies de Solicitao.
********************************************************************************
*********/
/*******************************************************************************
**********
* Leandro Rodrigues da Silva Souza - MMCB - 18/04/2010 - mmcb.sds3239
*
* Projeto Implantao People - Multi Empresa MMCB-SVB.
*
********************************************************************************
**********/
/*******************************************************************************
**********
Wagner Sorio - MMC - 10/10/2007 - mmcb.at2323 - Sistema Controle Terceiros
Fazer pequisa e Preencher o GRID das Requisies de Solicitao.
********************************************************************************
**********/
/*******************************************************************************
**********
* Leandro Rodrigues da Silva Souza - MMCB - 18/04/2010 - mmcb.sds3239
*
* Projeto Implantao People - Multi Empresa MMCB-SVB.
*
********************************************************************************
**********/
/*******************************************************************************
**********
/*
*/ /*mmcb.sds3239.lo */
/*
While None(MMC_TE_RECV_VND.NF_BRL_SERIES)*/ /*mmcb.sds3239.lo */
/*
WinMessage("Serie Nota Fiscal Triangulao em branco");*/ /*mmcb.sds3239.
lo */
/*
&RESULT_MODAL = DoModal(Page.MMC_TE_RECV, " ", - 1, - 1, 0);*/ /*mmcb
.sds3239.lo */
/*
End-While;*/ /*mmcb.sds3239.lo */
/*
*/ /*mmcb.sds3239.lo */
/* End-If;*/ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* If None(MMC_TE_RECV_VND.VENDOR_ID) And*/ /*mmcb.sds3239.lo */
/*
(&RESULT_MODAL = 1) And*/ /*mmcb.sds3239.lo */
/*
MMC_TE_RECV_WRK.MMC_TE_NFSERVI_FLG = "N" And*/ /*mmcb.sds3239.lo */
/*
MMC_TE_TRIA_WRK.MMC_TE_TIPO_RECEBI = "N" And*/ /*mmcb.sds3239.lo */
/*
MMC_TE_NFLN_WRK.MMC_TE_TRIANG_FLG = "N" Then*/ /*mmcb.sds3239.lo */
/*
*/ /*mmcb.sds3239.lo */
/*
While None(MMC_TE_RECV_VND.VENDOR_ID)*/ /*mmcb.sds3239.lo */
/*
WinMessage("Fornecedor Triangulao em branco");*/ /*mmcb.sds3239.lo */
/*
&RESULT_MODAL = DoModal(Page.MMC_TE_RECV, " ", - 1, - 1, 0);*/ /*mmcb
.sds3239.lo */
/*
Exit;*/ /*mmcb.sds3239.lo */
/*
*/ /*mmcb.sds3239.lo */
/*
End-While;*/ /*mmcb.sds3239.lo */
/* End-If;*/ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* &LINHAOC_SELECIONADA = "N";*/ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* &rsMMC_TE_OC_VW = GetRowset(Scroll.MMC_TE_OC_VW);*/ /*mmcb.sds3239.lo */
/* For &I = 1 To &rsMMC_TE_OC_VW.activerowcount;*/ /*mmcb.sds3239.lo */
/*
If &rsMMC_TE_OC_VW.GetRow(&I).MMC_TE_WRK.MMC_TE_CONFI_FLG.VALUE = "Y" Th
en*/ /*mmcb.sds3239.lo */
/*
If (&rsMMC_TE_OC_VW.GetRow(&I).MMC_TE_WRK.QTY_OPEN.VALUE <= 0) Then*/
/*mmcb.sds3239.lo */
/*
While (&rsMMC_TE_OC_VW.GetRow(&I).MMC_TE_WRK.QTY_OPEN.VALUE <= 0)*
/ /*mmcb.sds3239.lo */
/*
WinMessage("Error: Quantidade da Ordem Compra: " | &rsMMC_TE_OC
_VW.GetRow(&I).MMC_TE_OC_VW.PO_ID.VALUE | " Linha: " | &rsMMC_TE_OC_VW.GetRow(&I
).MMC_TE_OC_VW.LINE_NBR.VALUE | " programao " | &rsMMC_TE_OC_VW.GetRow(&I).MMC_TE_
OC_VW.SCHED_NBR.VALUE | " deve ser maior que zero");*/ /*mmcb.sds3239.lo */
/*
&RESULT_MODAL = DoModal(Page.MMC_TE_RECV, " ", - 1, - 1, 0);*/
/*mmcb.sds3239.lo */
/*
End-While;*/ /*mmcb.sds3239.lo */
/*
Else*/ /*mmcb.sds3239.lo */
/*
&LINHAOC_SELECIONADA = "Y";*/ /*mmcb.sds3239.lo */
/*
End-If;*/ /*mmcb.sds3239.lo */
/*
End-If;*/ /*mmcb.sds3239.lo */
/* End-For;*/ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* If &LINHAOC_SELECIONADA = "N" And*/ /*mmcb.sds3239.lo */
/*
MMC_TE_RECV_WRK.MMC_TE_NFSERVI_FLG = "N" And*/ /*mmcb.sds3239.lo */
/*
&RESULT_MODAL = 1 And*/ /*mmcb.sds3239.lo */
/*
(MMC_TE_NFLN_WRK.MMC_TE_TRIANG_FLG = "N") Then*/ /*mmcb.sds3239.lo */
/*
WinMessage("Error: Pelomenos uma Linha da OC deve ser lecionada ou Cliqu
e em Cancelar para Sair da Pagina. ");*/ /*mmcb.sds3239.lo */
/*
&RESULT_MODAL = DoModal(Page.MMC_TE_RECV, " ", - 1, - 1, 0);*/ /*mmcb.sd
s3239.lo */
/* End-If;*/ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* If All(MMC_TE_RECV_WRK.VENDOR_ID) And*/ /*mmcb.sds3239.lo */
/*
All(MMC_TE_TRIA_WRK.VENDOR_ID) Then*/ /*mmcb.sds3239.lo */
/*
Error ("Entrada documento Fiscal de Terceiros Deve ser Triangulao ou Remes
sa e Ordem. No com os dois tipos ao mesmo tempo.");*/ /*mmcb.sds3239.lo */
/* End-If;*/ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* If All(MMC_TE_RECV_WRK.VENDOR_ID) Then*/ /*mmcb.sds3239.lo */
/*
MMC_TE_NFLN_WRK.MMC_TERCEIRO_FLG = "Y";*/ /*mmcb.sds3239.lo */
/* End-If;*/ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* If (MMC_TE_NFLN_WRK.MMC_TE_TRIANG_FLG = "N") Then*/ /*mmcb.sds3239.lo */
/*
*/ /*mmcb.sds3239.lo */
/*
MMC_TE_TRIA_WRK.VENDOR_ID = "";*/ /*mmcb.sds3239.lo */
/*
MMC_TE_TRIA_WRK.MMC_STOCK_UN = "";*/ /*mmcb.sds3239.lo */
/*
MMC_TE_TRIA_WRK.ADDRESS_SEQ_NUM = 0;*/ /*mmcb.sds3239.lo */
/*
MMC_TE_TRIA_WRK.CGC_BRL = "";*/ /*mmcb.sds3239.lo */
/*
MMC_TE_TRIA_WRK.VNDR_LOC = "";*/ /*mmcb.sds3239.lo */
/*
MMC_TE_TRIA_WRK.NF_BRL = "";*/ /*mmcb.sds3239.lo */
/*
MMC_TE_TRIA_WRK.NF_BRL_SERIES = "";*/ /*mmcb.sds3239.lo */
/*
MMC_TE_TRIA_WRK.INV_ITEM_ID = "";*/ /*mmcb.sds3239.lo */
/*
*/ /*mmcb.sds3239.lo */
/*
&L1 = GetRowset(Scroll.MMC_TE_S_NF_VW);*/ /*mmcb.sds3239.lo */
/*
&L1.Flush();*/ /*mmcb.sds3239.lo */
/*
*/ /*mmcb.sds3239.lo */
/* End-If;*/ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* Gray(BTN_REFRESH);*/ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* If &RESULT_MODAL = 0 Then*/ /*mmcb.sds3239.lo */
/*
*/ /*mmcb.sds3239.lo */
/*
&L1OC = GetRowset(Scroll.MMC_TE_OC_VW);*/ /*mmcb.sds3239.lo */
/*
&L1OC.Flush();*/ /*mmcb.sds3239.lo */
/* End-If;*/ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* If &RESULT_MODAL = 1 Then*/ /*mmcb.sds3239.lo */
/*
EndModal(1);*/ /*mmcb.sds3239.lo */
/* End-If;*/ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/*End-If;*/ /*mmcb.sds3239.lo */
/**/ /*mmcb.sds3239.lo */
/*/********************** mmcb.at2323.en **********************/ /*mmcb.sds3239.
lo */
/**/ /*mmcb.sds3239.lo */
/*/********************** mmcb.at2323.sn **********************/ /*mmcb.sds3239.
lo */
/**/ /*mmcb.sds3239.lo */
/*If %Page = Page.MMC_TE_RECV Then*/ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* MMC_TE_RECV_WRK.MMC_TE_NFSERVI_FLG = "N";*/ /*mmcb.sds3239.lo */
/* Gray(MMC_TE_RECV_WRK.MMC_TE_NFSERVI_FLG);*/ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* &LINHA_NF_SELECIONADA = "N";*/ /*mmcb.sds3239.lo */
/* &L1 = GetRowset(Scroll.MMC_TE_S_NF_VW);*/ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* &RESULT_MODAL = DoModal(Page.MMC_TE_RECV_TRIAN, " ", - 1, - 1, 0);*/ /*mmcb
.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* REM LIMPA AS NFS QUE NO FORAM SELECIONADAS ;*/ /*mmcb.sds3239.lo */
/* For &I = &L1.ActiveRowCount To 1 Step - 1;*/ /*mmcb.sds3239.lo */
/*
*/ /*mmcb.sds3239.lo */
/*
If &L1.GetRow(&I).MMC_TE_WRK.MMC_TE_CONFI_FLG.VALUE <> "Y" Then*/ /*mmcb
.sds3239.lo */
/*
&L1.DeleteRow(&I);*/ /*mmcb.sds3239.lo */
/*
End-If*/ /*mmcb.sds3239.lo */
/* End-For;*/ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* &TOTALLN = &L1.ActiveRowCount;*/ /*mmcb.sds3239.lo */
/* For &N = 1 To &TOTALLN;*/ /*mmcb.sds3239.lo */
/*
If &L1.GetRow(&N).MMC_TE_WRK.MMC_TE_CONFI_FLG.VALUE = "Y" Then*/ /*mmcb.
sds3239.lo */
/*
*/ /*mmcb.sds3239.lo */
/*
If &L1.GetRow(&N).MMC_TE_WRK.QTY_OPEN.VALUE <= 0 Then*/ /*mmcb.sds323
9.lo */
/*
While ((&L1.GetRow(&N).MMC_TE_WRK.QTY_OPEN.VALUE <= 0) And*/ /*mmc
b.sds3239.lo */
/*
(&RESULT_MODAL = 1) And*/ /*mmcb.sds3239.lo */
/*
(&L1.GetRow(&N).MMC_TE_WRK.MMC_TE_CONFI_FLG.VALUE = "Y"))*/
/*mmcb.sds3239.lo */
/*
WinMessage("Error: NF: " | &L1.GetRow(&N).MMC_TE_S_NF_VW.NF_BRL
_ID.VALUE | " Linha: " | &L1.GetRow(&N).MMC_TE_S_NF_VW.NF_BRL_LINE_NUM.VALUE | "
deve ser maior que zero");*/ /*mmcb.sds3239.lo */
/*
&RESULT_MODAL = DoModal(Page.MMC_TE_RECV_TRIAN, " ", - 1, - 1,
0);*/ /*mmcb.sds3239.lo */
/*
*/ /*mmcb.sds3239.lo */
/*
End-While;*/ /*mmcb.sds3239.lo */
/*
End-If;*/ /*mmcb.sds3239.lo */
/*
&LINHA_NF_SELECIONADA = "Y";*/ /*mmcb.sds3239.lo */
/*
/*&L1.GetRow(&N).MMC_TE_WRK.QTY_OPEN.VALUE <= 0*/ /*mmcb.sds3239.lo *
/
/*
End-If; /*IF &L1.GetRow(&N).MMC_TE_WRK.MMC_TE_CONFI_FLG.VALUE = "Y"*/ /*
mmcb.sds3239.lo */
/* End-For;*/ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* While (&LINHA_NF_SELECIONADA = "N" And*/ /*mmcb.sds3239.lo */
/*
(&RESULT_MODAL = 1))*/ /*mmcb.sds3239.lo */
/*
WinMessage("Error: Pelomenos uma NF deve ser lecionada ou Clique em Canc
elar para Sair da Pagina. ");*/ /*mmcb.sds3239.lo */
/*
&RESULT_MODAL = DoModal(Page.MMC_TE_RECV_TRIAN, " ", - 1, - 1, 0);*/ /*m
mcb.sds3239.lo */
/*
Exit;*/ /*mmcb.sds3239.lo */
/* End-While;*/ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* REM Codigo para validar se existe numero de NF Duplicado ;*/ /*mmcb.sds3239
.lo */
/* For &N1 = 1 To &L1.ActiveRowCount;*/ /*mmcb.sds3239.lo */
/*
*/ /*mmcb.sds3239.lo */
/*
&NF_ID_ANTERIOR = &L1.GetRow(&N1).MMC_TE_S_NF_VW.NF_BRL_ID.VALUE;*/ /*mm
cb.sds3239.lo */
/*
&NF_LN_ANTERIOR = &L1.GetRow(&N1).MMC_TE_S_NF_VW.NF_BRL_LINE_NUM.VALUE;*
/ /*mmcb.sds3239.lo */
/*
*/ /*mmcb.sds3239.lo */
/*
For &N2 = 1 To &L1.ActiveRowCount;*/ /*mmcb.sds3239.lo */
/*
*/ /*mmcb.sds3239.lo */
/*
If &N1 <> &N2 Then*/ /*mmcb.sds3239.lo */
/*
&NF_ID_NOVA = &L1.GetRow(&N2).MMC_TE_S_NF_VW.NF_BRL_ID.VALUE;*/ /*
mmcb.sds3239.lo */
/*
&NF_LN_NOVA = &L1.GetRow(&N2).MMC_TE_S_NF_VW.NF_BRL_LINE_NUM.VALUE
;*/ /*mmcb.sds3239.lo */
/*
*/ /*mmcb.sds3239.lo */
/*
If (&NF_ID_ANTERIOR = &NF_ID_NOVA) And*/ /*mmcb.sds3239.lo */
/*
(&NF_LN_ANTERIOR = &NF_LN_NOVA) Then*/ /*mmcb.sds3239.lo */
/*
WinMessage("Erro: J exista a NF: " | &NF_ID_NOVA | " Linha: " |
&NF_LN_NONA | " Lista ser Limpa para iniciar a pesquisa novamente.");*/ /*mmcb.sd
s3239.lo */
/*
&L1.Flush();*/ /*mmcb.sds3239.lo */
/*
&RESULT_MODAL = DoModal(Page.MMC_TE_RECV_TRIAN, " ", - 1, - 1,
0);*/ /*mmcb.sds3239.lo */
/*
Exit;*/ /*mmcb.sds3239.lo */
/*
End-If;*/ /*mmcb.sds3239.lo */
/*
End-If;*/ /*mmcb.sds3239.lo */
/*
End-For;*/ /*mmcb.sds3239.lo */
/*
*/ /*mmcb.sds3239.lo */
/* End-For;*/ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* REM FIM Codigo para validar se existe numero de NF Duplicado ;*/ /*mmcb.sds
3239.lo */
/* */ /*mmcb.sds3239.lo */
/* For &W = 1 To &L1.ActiveRowCount;*/ /*mmcb.sds3239.lo */
/*
If None(&L1.GetRow(&W).MMC_TE_WRK.INV_LOT_ID.VALUE) Then*/ /*mmcb.sds323
9.lo */
/*
&L1.GetRow(&W).MMC_TE_WRK.INV_LOT_ID.VALUE = "NONE";*/ /*mmcb.sds3239
.lo */
/*
End-If;*/ /*mmcb.sds3239.lo */
/*
*/ /*mmcb.sds3239.lo */
/*
If None(&L1.GetRow(&W).MMC_TE_WRK.SERIAL_ID.VALUE) Then*/ /*mmcb.sds3239
.lo */
/*
&L1.GetRow(&W).MMC_TE_WRK.SERIAL_ID.VALUE = "NONE";*/ /*mmcb.sds3239.
lo */
/*
End-If;*/ /*mmcb.sds3239.lo */
/*
*/ /*mmcb.sds3239.lo */
/* End-For;*/ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* If (None(MMC_TE_TRIA_WRK.MMC_STOCK_UN) And*/ /*mmcb.sds3239.lo */
/*
(&RESULT_MODAL = 1)) Then*/ /*mmcb.sds3239.lo */
/*
*/ /*mmcb.sds3239.lo */
/*
/*
*/ /*mmcb.sds3239.lo */
/**/ /*mmcb.sds3239.lo */
/*
While None(MMC_TE_TRIA_WRK.MMC_STOCK_UN) And*/ /*mmcb.sds3239.lo */
/*
(&RESULT_MODAL = 1)*/ /*mmcb.sds3239.lo */
/*
WinMessage("Error: BU Controle de Remessa est em branco.");*/ /*mmcb.s
ds3239.lo */
/*
&RESULT_MODAL = DoModal(Page.MMC_TE_RECV_TRIAN, " ", - 1, - 1, 0);*/
/*mmcb.sds3239.lo */
/*
End-While;*/ /*mmcb.sds3239.lo */
/**/ /*mmcb.sds3239.lo */
/*
*/ /*mmcb.sds3239.lo */
/* End-If;*/ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* If All(MMC_TE_TRIA_WRK.VENDOR_ID) Then*/ /*mmcb.sds3239.lo */
/*
MMC_TE_NFLN_WRK.MMC_TERCEIRO_FLG = "Y";*/ /*mmcb.sds3239.lo */
/*
MMC_TE_NFLN_WRK.MMC_TE_TRIANG_FLG = "Y";*/ /*mmcb.sds3239.lo */
/* End-If;*/ /*mmcb.sds3239.lo */
/* */ /*mmcb.sds3239.lo */
/* Gray(BTN_REFRESH);*/ /*mmcb.sds3239.lo */
/* MMC_TE_RECV_WRK.SHIPTO_ID = "";*/ /*mmcb.sds3239.lo */
/* MMC_TE_RECV_WRK.ADDRESS_SEQ_NUM = 0;*/ /*mmcb.sds3239.lo */
/* MMC_TE_RECV_WRK.CGC_BRL = "";*/ /*mmcb.sds3239.lo */
/* MMC_TE_RECV_WRK.VNDR_LOC = "";*/ /*mmcb.sds3239.lo */
/*mmcb.sds3239.eo*/
/*mmcb.sds3239.ln*/
SQLExec("select shipto_id from sysadm.ps_shipto_tbl where setid=:1 and busine
ss_unit_recv=:2", &SETID_GERAL, NF_HDR_BRL.BUSINESS_UNIT, MMC_TE_RECV_WRK.SHIPTO
_ID);
/*mmcb.sds3239.sn*/
SQLExec("Select setid from ps_set_cntrl_tbl where setcntrlvalue = :1", NF_HDR
_BRL.BUSINESS_UNIT.Value, MMC_TE_RECV_WRK.SETID.Value);
SQLExec("SELECT BUSINESS_UNIT_IN FROM PS_SHIPTO_TBL A WHERE A.EFFDT = (SELECT
MAX(B.EFFDT) FROM PS_SHIPTO_TBL B WHERE B.SETID = A.SETID AND B.SHIPTO_ID = A.S
HIPTO_ID AND B.EFFDT <= SYSDATE) And A.setid = :1 And A.shipto_id = :2", MMC_TE_
RECV_WRK.SETID, MMC_TE_RECV_WRK.SHIPTO_ID, MMC_TE_RECV_WRK.BUSINESS_UNIT_IN);
/*SQLExec("select 'Y' from sysadm.ps_mmc_te_recv_par where business_unit_recv
=:1 and eff_status='A' and mmc_cntrl_terc = 'Y' and mmc_te_tipo_recv='2'", NF_HD
R_BRL.BUSINESS_UNIT, &UN_TRIAN);*/ /*mmcb.sds4388.lo*/
SQLExec("select 'Y' from sysadm.ps_mmc_te_recv_par where business_unit_recv=:
1 and eff_status='A' and mmc_cntrl_terc = 'Y' and mmc_te_tipo_recv in ('2','3')"
, NF_HDR_BRL.BUSINESS_UNIT, &UN_TRIAN); /*mmcb.sds4388.ln*/
If &UN_TRIAN <> "Y" Then
Gray(BTN_REFRESH);
Gray(MMC_TE_RECV_WRK.MMC_TE_NFSERVI_FLG);
Else
Gray(MMC_TE_RECV_WRK.SHIPTO_ID);
Gray(MMC_TE_RECV_WRK.VENDOR_ID);
Gray(MMC_TE_RECV_WRK.ADDRESS_SEQ_NUM);
Gray(MMC_TE_RECV_WRK.CGC_BRL);
Gray(MMC_TE_RECV_WRK.VNDR_LOC);
Gray(MMC_TE_RECV_VND.NF_BRL);
Gray(MMC_TE_RECV_VND.NF_BRL_SERIES);
Gray(MMC_TE_RECV_VND.VENDOR_ID);
Gray(MMC_TE_RECV_VND.ADDRESS_SEQ_NUM);
Gray(MMC_TE_RECV_VND.VNDR_LOC);
Gray(MMC_TE_RECV_VND.CGC_BRL);
Gray(MMC_TE_RECV_WRK.PO_ID);
Gray(MMC_TE_RECV_WRK.INV_ITEM_ID);
Gray(MMC_TE_RECV_WRK.BUTTON);
Gray(MMC_TE_RECV_WRK.BUTTON1);
End-If;
/******************************** mmcb.sds4304.sn ***************************
**************/
SQLExec("SELECT 'Y' FROM SYSADM.PS_MMC_TE_RECV_PAR WHERE BUSINESS_UNIT_RECV=:
1 AND EFF_STATUS='A' AND MMC_CNTRL_TERC = 'Y' AND MMC_TE_TIPO_RECV = 3", NF_HDR_
BRL.BUSINESS_UNIT, &UN_PARAMETRIZADA);
If &UN_PARAMETRIZADA = "Y" Then
UnGray(BTN_REFRESH);
End-If;
/******************************** mmcb.sds4304.en ***************************
**************/
If None(MMC_TE_RECV_VND.NF_BRL) And
&RESULT_MODAL = 1 And
MMC_TE_RECV_WRK.MMC_TE_NFSERVI_FLG = "N" And
MMC_TE_TRIA_WRK.MMC_TE_TIPO_RECEBI = "N" And
MMC_TE_NFLN_WRK.MMC_TE_TRIANG_FLG = "N" Then
While (None(MMC_TE_RECV_VND.NF_BRL))
WinMessage("Nota Fiscal Triangulao em branco");
&RESULT_MODAL = DoModal(Page.MMC_TE_RECV, " ", - 1, - 1, 0);
End-While;
End-If;
If None(MMC_TE_RECV_VND.NF_BRL_SERIES) And
(&RESULT_MODAL = 1) And
MMC_TE_RECV_WRK.MMC_TE_NFSERVI_FLG = "N" And
MMC_TE_TRIA_WRK.MMC_TE_TIPO_RECEBI = "N" And
MMC_TE_NFLN_WRK.MMC_TE_TRIANG_FLG = "N" Then
While None(MMC_TE_RECV_VND.NF_BRL_SERIES)
WinMessage("Serie Nota Fiscal Triangulao em branco");
&RESULT_MODAL = DoModal(Page.MMC_TE_RECV, " ", - 1, - 1, 0);
End-While;
End-If;
If None(MMC_TE_RECV_VND.VENDOR_ID) And
(&RESULT_MODAL = 1) And
MMC_TE_RECV_WRK.MMC_TE_NFSERVI_FLG = "N" And
MMC_TE_TRIA_WRK.MMC_TE_TIPO_RECEBI = "N" And
MMC_TE_NFLN_WRK.MMC_TE_TRIANG_FLG = "N" Then
While None(MMC_TE_RECV_VND.VENDOR_ID)
WinMessage("Fornecedor Triangulao em branco");
&RESULT_MODAL = DoModal(Page.MMC_TE_RECV, " ", - 1, - 1, 0);
Exit;
End-While;
End-If;
&LINHAOC_SELECIONADA = "N";
&rsMMC_TE_OC_VW = GetRowset(Scroll.MMC_TE_OC_VW);
For &I = 1 To &rsMMC_TE_OC_VW.activerowcount;
If &rsMMC_TE_OC_VW.GetRow(&I).MMC_TE_WRK.MMC_TE_CONFI_FLG.VALUE = "Y" Then
If (&rsMMC_TE_OC_VW.GetRow(&I).MMC_TE_WRK.QTY_OPEN.VALUE <= 0) Then
While (&rsMMC_TE_OC_VW.GetRow(&I).MMC_TE_WRK.QTY_OPEN.VALUE <= 0)
WinMessage("Error: Quantidade da Ordem Compra: " | &rsMMC_TE_OC_V
W.GetRow(&I).MMC_TE_OC_VW.PO_ID.VALUE | " Linha: " | &rsMMC_TE_OC_VW.GetRow(&I).
MMC_TE_OC_VW.LINE_NBR.VALUE | " programao " | &rsMMC_TE_OC_VW.GetRow(&I).MMC_TE_OC
_VW.SCHED_NBR.VALUE | " deve ser maior que zero");
&RESULT_MODAL = DoModal(Page.MMC_TE_RECV, " ", - 1, - 1, 0);
End-While;
Else
&LINHAOC_SELECIONADA = "Y";
End-If;
End-If;
End-For;
If &LINHAOC_SELECIONADA = "N" And
MMC_TE_RECV_WRK.MMC_TE_NFSERVI_FLG = "N" And
&RESULT_MODAL = 1 And
(MMC_TE_NFLN_WRK.MMC_TE_TRIANG_FLG = "N") Then
WinMessage("Error: Pelomenos uma Linha da OC deve ser lecionada ou Clique
em Cancelar para Sair da Pagina. ");
&RESULT_MODAL = DoModal(Page.MMC_TE_RECV, " ", - 1, - 1, 0);
End-If;
If All(MMC_TE_RECV_WRK.VENDOR_ID) And
All(MMC_TE_TRIA_WRK.VENDOR_ID) Then
Error ("Entrada documento Fiscal de Terceiros Deve ser Triangulao ou Remessa
e Ordem. No com os dois tipos ao mesmo tempo.");
End-If;
If All(MMC_TE_RECV_WRK.VENDOR_ID) Then
MMC_TE_NFLN_WRK.MMC_TERCEIRO_FLG = "Y";
End-If;
If (MMC_TE_NFLN_WRK.MMC_TE_TRIANG_FLG = "N") Then
MMC_TE_TRIA_WRK.VENDOR_ID = "";
MMC_TE_TRIA_WRK.MMC_STOCK_UN = "";
MMC_TE_TRIA_WRK.ADDRESS_SEQ_NUM = 0;
MMC_TE_TRIA_WRK.CGC_BRL = "";
MMC_TE_TRIA_WRK.VNDR_LOC = "";
MMC_TE_TRIA_WRK.NF_BRL = "";
MMC_TE_TRIA_WRK.NF_BRL_SERIES = "";
MMC_TE_TRIA_WRK.INV_ITEM_ID = "";
&L1 = GetRowset(Scroll.MMC_TE_S_NF_VW);
&L1.Flush();
End-If;
Gray(BTN_REFRESH);
If &RESULT_MODAL = 0 Then
&L1OC = GetRowset(Scroll.MMC_TE_OC_VW);
&L1OC.Flush();
End-If;
If &RESULT_MODAL = 1 Then
EndModal(1);
End-If;
End-If;
/********************** mmcb.at2323.en **********************/
/********************** mmcb.at2323.sn **********************/
If %Page = Page.MMC_TE_RECV Then
MMC_TE_RECV_WRK.MMC_TE_NFSERVI_FLG = "N";
Gray(MMC_TE_RECV_WRK.MMC_TE_NFSERVI_FLG);
&LINHA_NF_SELECIONADA = "N";
&L1 = GetRowset(Scroll.MMC_TE_S_NF_VW);
&L2 = GetRowset(Scroll.MMC_TE_TRIA_BOM); /*mmcb.sds3426.ln*/
&RESULT_MODAL = DoModal(Page.MMC_TE_RECV_TRIAN, " ", - 1, - 1, 0);
/************************ mmcb.sds3426.sn ************************/
For &I = &L2.ActiveRowCount To 1 Step - 1;
&L2.DeleteRow(&I);
End-For;
/************************ mmcb.sds3426.en ************************/
REM LIMPA AS NFS QUE NO FORAM SELECIONADAS ;
For &I = &L1.ActiveRowCount To 1 Step - 1;
If &L1.GetRow(&I).MMC_TE_WRK.MMC_TE_CONFI_FLG.VALUE <> "Y" Then
&L1.DeleteRow(&I);
End-If
End-For;
&TOTALLN = &L1.ActiveRowCount;
For &N = 1 To &TOTALLN;
If &L1.GetRow(&N).MMC_TE_WRK.MMC_TE_CONFI_FLG.VALUE = "Y" Then
If &L1.GetRow(&N).MMC_TE_WRK.QTY_OPEN.VALUE <= 0 Then
While ((&L1.GetRow(&N).MMC_TE_WRK.QTY_OPEN.VALUE <= 0) And
(&RESULT_MODAL = 1) And
(&L1.GetRow(&N).MMC_TE_WRK.MMC_TE_CONFI_FLG.VALUE = "Y"))
WinMessage("Error: NF: " | &L1.GetRow(&N).MMC_TE_S_NF_VW.NF_BRL_I
D.VALUE | " Linha: " | &L1.GetRow(&N).MMC_TE_S_NF_VW.NF_BRL_LINE_NUM.VALUE | " d
eve ser maior que zero");
&RESULT_MODAL = DoModal(Page.MMC_TE_RECV_TRIAN, " ", - 1, - 1, 0)
;
End-While;
End-If;
&LINHA_NF_SELECIONADA = "Y";
/*&L1.GetRow(&N).MMC_TE_WRK.QTY_OPEN.VALUE <= 0*/
End-If; /*IF &L1.GetRow(&N).MMC_TE_WRK.MMC_TE_CONFI_FLG.VALUE = "Y"*/
End-For;
While (&LINHA_NF_SELECIONADA = "N" And
(&RESULT_MODAL = 1))
WinMessage("Error: Pelomenos uma NF deve ser lecionada ou Clique em Cancel
ar para Sair da Pagina. ");
&RESULT_MODAL = DoModal(Page.MMC_TE_RECV_TRIAN, " ", - 1, - 1, 0);
Exit;
End-While;
REM Codigo para validar se existe numero de NF Duplicado ;
For &N1 = 1 To &L1.ActiveRowCount;
&NF_ID_ANTERIOR = &L1.GetRow(&N1).MMC_TE_S_NF_VW.NF_BRL_ID.VALUE;
&NF_LN_ANTERIOR = &L1.GetRow(&N1).MMC_TE_S_NF_VW.NF_BRL_LINE_NUM.VALUE;
For &N2 = 1 To &L1.ActiveRowCount;
If &N1 <> &N2 Then
&NF_ID_NOVA = &L1.GetRow(&N2).MMC_TE_S_NF_VW.NF_BRL_ID.VALUE;
&NF_LN_NOVA = &L1.GetRow(&N2).MMC_TE_S_NF_VW.NF_BRL_LINE_NUM.VALUE;
If (&NF_ID_ANTERIOR = &NF_ID_NOVA) And
(&NF_LN_ANTERIOR = &NF_LN_NOVA) Then
WinMessage("Erro: J exista a NF: " | &NF_ID_NOVA | " Linha: " | &N
F_LN_NONA | " Lista ser Limpa para iniciar a pesquisa novamente.");
&L1.Flush();
&RESULT_MODAL = DoModal(Page.MMC_TE_RECV_TRIAN, " ", - 1, - 1, 0)
;
Exit;
End-If;
End-If;
End-For;
End-For;
REM FIM Codigo para validar se existe numero de NF Duplicado ;
For &W = 1 To &L1.ActiveRowCount;
If None(&L1.GetRow(&W).MMC_TE_WRK.INV_LOT_ID.VALUE) Then
&L1.GetRow(&W).MMC_TE_WRK.INV_LOT_ID.VALUE = "NONE";
End-If;
If None(&L1.GetRow(&W).MMC_TE_WRK.SERIAL_ID.VALUE) Then
&L1.GetRow(&W).MMC_TE_WRK.SERIAL_ID.VALUE = "NONE";
End-If;
End-For;
If (None(MMC_TE_TRIA_WRK.MMC_STOCK_UN) And
(&RESULT_MODAL = 1)) Then
/*
While None(MMC_TE_TRIA_WRK.MMC_STOCK_UN) And
(&RESULT_MODAL = 1)
WinMessage("Error: BU Controle de Remessa est em branco.");
&RESULT_MODAL = DoModal(Page.MMC_TE_RECV_TRIAN, " ", - 1, - 1, 0);
End-While;
*/
End-If;
If All(MMC_TE_TRIA_WRK.VENDOR_ID) Then
MMC_TE_NFLN_WRK.MMC_TERCEIRO_FLG = "Y";
MMC_TE_NFLN_WRK.MMC_TE_TRIANG_FLG = "Y";
End-If;
Gray(BTN_REFRESH);
MMC_TE_RECV_WRK.SHIPTO_ID = "";
MMC_TE_RECV_WRK.ADDRESS_SEQ_NUM = 0;
MMC_TE_RECV_WRK.CGC_BRL = "";
MMC_TE_RECV_WRK.VNDR_LOC = "";
MMC_TE_RECV_VND.NF_BRL = "";
MMC_TE_RECV_VND.NF_BRL_SERIES = "";
MMC_TE_RECV_VND.VENDOR_ID = "";
MMC_TE_RECV_VND.ADDRESS_SEQ_NUM = 0;
MMC_TE_RECV_VND.VNDR_LOC = "";
MMC_TE_RECV_VND.CGC_BRL = "";
MMC_TE_RECV_WRK.PO_ID = "";
MMC_TE_RECV_WRK.INV_ITEM_ID = "";
&L1OC = GetRowset(Scroll.MMC_TE_OC_VW);
&L1OC.Flush();
If &RESULT_MODAL = 0 Then
&L1 = GetRowset(Scroll.MMC_TE_S_NF_VW);
&L1.Flush();
&L2 = GetRowset(Scroll.MMC_TE_TRIA_BOM); /*mmcb.sds3426.ln*/
&L2.Flush(); /*mmcb.sds3426.ln*/
End-If;
If MMC_TE_RECV_WRK.MMC_TE_NFSERVI_FLG = "Y" Then
MMC_TE_NFLN_WRK.MMC_TE_TRIANG_FLG = "Y";
End-If;
If &RESULT_MODAL = 1 Then
EndModal(1);
EndModal(1);
End-If;
End-If;
/********************** mmcb.at2323.en **********************/
[MMC_TE_WRK.BTN_REFRESH.RowInit]
/*******************************************************************************
*****
Wagner Sorio - MMC - 10/10/2007 - mmcb.at2323 - Sistema Controle Terceiros
Desabilitar o boto Terceiros caso UN no esteja parametrizada para terceiros.
********************************************************************************
*****/
/********************** mmcb.at2323.sn **********************/
If %Component = Component.NF_INFO_PBL Then
SQLExec("select 'Y' from sysadm.ps_mmc_te_recv_par where business_unit_recv=:
1 and eff_status='A' and mmc_cntrl_terc = 'Y'", NF_HDR_BRL.BUSINESS_UNIT, &UN_PA
RAMETRIZADA);
If &UN_PARAMETRIZADA <> "Y" Then
Gray(BTN_REFRESH);
End-If;
SQLExec("select 'Y' from sysadm.ps_mmc_te_recv_par where business_unit_recv=:
1 and eff_status='A' and mmc_cntrl_terc = 'Y'", NF_HDR_BRL.BUSINESS_UNIT, &UN_PA
RAMETRIZADA);
If &UN_PARAMETRIZADA <> "Y" Then
Gray(BTN_REFRESH);
End-If;
End-If;
/********************** mmcb.at2323.en **********************/
[MMC_TE_WRK.FUNCLIB.SavePostChange]
/*******************************************************************************
*****
Wagner Sorio / Claudio Costa - MMC - 26/10/2007 - mmcb.at2323 - Sistema Controle
Terceiros
Biblioteca de Funes Sistema Terceiros.
********************************************************************************
*****/
/*******************************************************************************
*****
* Wagner Sorio MMC - 19/06/2008 - mmcb.at50856
*
* Adicionar Rotina de Cancelar o Recebimento de Terceiros quando nf for excluida
. *
********************************************************************************
*****/
/*******************************************************************************
*****
* Wagner Sorio MMC - 09/07/2008 - mmcb.hd51767
*
* Exclui NF Servio dos insumos que foram Estornado ou Excluido.
*
********************************************************************************
*****/
/*******************************************************************************
*****
* Wagner Sorio - MMC - 28/05/2008 - mmcb.sds2618 - Retorno Rally
*
* Criao da funao GRAVA_MMC_TE_TRANSAC
*
********************************************************************************
*****/
/*******************************************************************************
*****
* Vincius Alves Mello - MMC - 12/06/2010 - mmcb.hd93658
*
* Retirar mensagem de erro do cadastro do item na tabela BU_ITENS_INV, pois o
*
* sistema consegue estornar o item, mesmo no tendo cadastro na BU_ITENS_INV.
*
* Existe uma SDS para no deixar entrar itens em terceiros que no possuem cadastro
*
* na BU_ITENS_INV.
*
********************************************************************************
*****/
/*******************************************************************************
*****
* Augusto V Net MMC - 29/12/2014 - mmcb.hd225474
*
* Correo de comando update.
*
********************************************************************************
*****/
Declare Function
PostChange;
Declare Function
nge;
Declare Function
tChange;
Declare Function
ange;
=
=
=
=
"";
"
UPDATE SYSADM.PS_RECV_HDR ";
&SQL | "
SET RECV_STATUS
&SQL | "
WHERE BUSINESS_UNIT
= &SQL | "
AND RECEIVER_ID
=
=
'X'";
'" | &P_BUSINESS_UNIT |
SQLExec(&SQL);
&SQL = "";
&SQL = &SQL | " UPDATE SYSADM.PS_RECV_LN_SHIP ";
&SQL = &SQL | "
SET RECV_SHIP_STATUS
= 'X' ";
&SQL = &SQL | "
, PROCESS_COMPLETE
= 'N' ";
&SQL = &SQL | " WHERE BUSINESS_UNIT
= '" | &P_BUSINESS_UNIT |
"' ";
&SQL = &SQL | "
AND RECEIVER_ID
= '" | &P_RECEIVER_ID | "
' ";
SQLExec(&SQL);
&SQL = "";
&SQL = &SQL | " UPDATE SYSADM.PS_RECV_LN_DISTRIB ";
&SQL = &SQL | "
SET RECV_DS_STATUS
= 'X' ";
&SQL = &SQL | " WHERE BUSINESS_UNIT
= '" | &P_BUSINESS_UNIT
| "' ";
&SQL = &SQL | "
AND RECEIVER_ID
= '" | &P_RECEIVER_ID |
"'";
SQLExec(&SQL);
&SQL = "";
&SQL = &SQL | " UPDATE SYSADM.PS_RECV_LN_ASSET ";
&SQL = &SQL | "
SET RECV_AM_STATUS
=
&SQL = &SQL | " WHERE BUSINESS_UNIT
=
| "'";
&SQL = &SQL | "
AND RECEIVER_ID
=
"' ";
SQLExec(&SQL);
'X' ";
'" | &P_BUSINESS_UNIT
'" | &P_RECEIVER_ID |
End-Function;
Function GRAVA_MMC_TE_S_NF_HDR(&PNFH_BUSINESS_UNIT, &PNFH_NF_BRL_ID, &PNFH_NF_BR
L, &PNFH_NF_BRL_SERIES, &PNFH_VENDOR_ID, &PNFH_ADDRESS_SEQ_NUM, &PNFH_IRTAX_BRL_
AMT, &PNFH_MMC_IR_SALDO)
&REC_MMC_TE_S_NF_HDR = CreateRecord(Record.MMC_TE_S_NF_HDR);
&REC_MMC_TE_S_NF_HDR.BUSINESS_UNIT.VALUE = &PNFH_BUSINESS_UNIT;
&REC_MMC_TE_S_NF_HDR.NF_BRL_ID.VALUE = &PNFH_NF_BRL_ID;
&REC_MMC_TE_S_NF_HDR.NF_BRL.VALUE = &PNFH_NF_BRL;
&REC_MMC_TE_S_NF_HDR.NF_BRL_SERIES.VALUE = &PNFH_NF_BRL_SERIES;
&REC_MMC_TE_S_NF_HDR.VENDOR_ID.VALUE = &PNFH_VENDOR_ID;
&REC_MMC_TE_S_NF_HDR.ADDRESS_SEQ_NUM.VALUE = &PNFH_ADDRESS_SEQ_NUM;
&REC_MMC_TE_S_NF_HDR.IRTAX_BRL_AMT.VALUE = &PNFH_IRTAX_BRL_AMT;
&REC_MMC_TE_S_NF_HDR.MMC_IR_SALDO.VALUE = &PNFH_MMC_IR_SALDO;
&REC_MMC_TE_S_NF_HDR.Insert();
End-Function;
Function GRAVA_MMC_TE_S_NF_LN(&PNFL_BUSINESS_UNIT, &PNFL_NF_BRL_ID, &PNFL_NF_BRL
_LINE_NUM, &PNFL_INV_ITEM_ID, &PNFL_INV_LOT_ID, &PNFL_SERIAL_ID, &PNFL_QTY, &PNF
L_QTY_AVAILABLE, &PNFL_ICMSTAX_BRL_AMT, &PNFL_MMC_ICMS_SALDO, &PNFL_IPITAX_BRL_A
MT, &PNFL_MMC_IPI_SALDO, &PNFL_PISTAX_BRL_AMT, &PNFL_MMC_PIS_SALDO, &PNFL_COFINS
TAX_BRL_AMT, &PNFL_MMC_COFINS_SALDO, &PNFL_ISSTAX_BRL_AMT, &PNFL_MMC_ISS_SALDO)
&REC_MMC_TE_S_NF_LN = CreateRecord(Record.MMC_TE_S_NF_LN);
&REC_MMC_TE_S_NF_LN.BUSINESS_UNIT.VALUE = &PNFL_BUSINESS_UNIT;
&REC_MMC_TE_S_NF_LN.NF_BRL_ID.VALUE = &PNFL_NF_BRL_ID;
&REC_MMC_TE_S_NF_LN.NF_BRL_LINE_NUM.VALUE = &PNFL_NF_BRL_LINE_NUM;
&REC_MMC_TE_S_NF_LN.INV_ITEM_ID.VALUE = &PNFL_INV_ITEM_ID;
&REC_MMC_TE_S_NF_LN.QTY.VALUE = &PNFL_QTY;
&REC_MMC_TE_S_NF_LN.QTY_AVAILABLE.VALUE = &PNFL_QTY_AVAILABLE;
&REC_MMC_TE_S_NF_LN.ICMSTAX_BRL_AMT.VALUE = &PNFL_ICMSTAX_BRL_AMT;
&REC_MMC_TE_S_NF_LN.MMC_ICMS_SALDO.VALUE = &PNFL_MMC_ICMS_SALDO;
&REC_MMC_TE_S_NF_LN.IPITAX_BRL_AMT.VALUE = &PNFL_IPITAX_BRL_AMT;
&REC_MMC_TE_S_NF_LN.MMC_IPI_SALDO.VALUE = &PNFL_MMC_IPI_SALDO;
&REC_MMC_TE_S_NF_LN.PISTAX_BRL_AMT.VALUE = &PNFL_PISTAX_BRL_AMT;
&REC_MMC_TE_S_NF_LN.MMC_PIS_SALDO.VALUE = &PNFL_MMC_PIS_SALDO;
&REC_MMC_TE_S_NF_LN.COFINSTAX_BRL_AMT.VALUE = &PNFL_COFINSTAX_BRL_AMT;
&REC_MMC_TE_S_NF_LN.MMC_COFINS_SALDO.VALUE = &PNFL_MMC_COFINS_SALDO;
&REC_MMC_TE_S_NF_LN.ISSTAX_BRL_AMT.VALUE = &PNFL_ISSTAX_BRL_AMT;
&REC_MMC_TE_S_NF_LN.MMC_ISS_SALDO.VALUE = &PNFL_MMC_ISS_SALDO;
&REC_MMC_TE_S_NF_LN.Insert();
End-Function;
Function GRAVA_SALDO_NF_TERCEIRO(&N_BUSINESS_UNIT, &N_NF_BRL_ID, &N_NF_BRL, &N_N
F_BRL_SERIES, &N_VENDOR_ID, &N_ADDRESS_SEQ_NUM, &N_IRTAX_BRL_AMT, &N_MMC_IR_SALD
O, &N_NF_BRL_LINE_NUM, &N_INV_ITEM_ID, &N_INV_LOT_ID, &N_SERIAL_ID, &N_QTY, &N_Q
TY_AVAILABLE, &N_ICMSTAX_BRL_AMT, &N_MMC_ICMS_SALDO, &N_IPITAX_BRL_AMT, &N_MMC_I
PI_SALDO, &N_PISTAX_BRL_AMT, &N_MMC_PIS_SALDO, &N_COFINSTAX_BRL_AMT, &N_MMC_COFI
NS_SALDO, &N_ISSTAX_BRL_AMT, &N_MMC_ISS_SALDO)
If None(&N_QTY) Or
None(&N_QTY_AVAILABLE) Or
&N_QTY <= 0 Or
&N_QTY_AVAILABLE <= 0 Then
Error ("Erro funo GRAVA_SALDO_NF_TERCEIRO QTD em branco");
End-If;
SQLExec("select 'Y' from sysadm.ps_MMC_TE_S_NF_HDR where business_unit=:1 and
nf_brl_id=:2", &N_BUSINESS_UNIT, &N_NF_BRL_ID, &EXISTE);
If &EXISTE <> "Y" Then
GRAVA_MMC_TE_S_NF_HDR(&N_BUSINESS_UNIT, &N_NF_BRL_ID, &N_NF_BRL, &N_NF_BRL
_SERIES, &N_VENDOR_ID, &N_ADDRESS_SEQ_NUM, &N_IRTAX_BRL_AMT, &N_MMC_IR_SALDO);
End-If;
GRAVA_MMC_TE_S_NF_LN(&N_BUSINESS_UNIT, &N_NF_BRL_ID, &N_NF_BRL_LINE_NUM, &N_I
NV_ITEM_ID, &N_INV_LOT_ID, &N_SERIAL_ID, &N_QTY, &N_QTY_AVAILABLE, &N_ICMSTAX_BR
L_AMT, &N_MMC_ICMS_SALDO, &N_IPITAX_BRL_AMT, &N_MMC_IPI_SALDO, &N_PISTAX_BRL_AMT
, &N_MMC_PIS_SALDO, &N_COFINSTAX_BRL_AMT, &N_MMC_COFINS_SALDO, &N_ISSTAX_BRL_AMT
, &N_MMC_ISS_SALDO);
End-Function;
Function GRAVA_TRANSACAO_TERCEIROS(&T_SETID, &T_MMC_TE_SOL_ID, &T_LINE_NBR, &T_B
USINESS_UNIT_BI, &T_NF_BRL_ID, &T_NF_BRL_LINE_NUM, &T_MMC_TE_OPERACAO, &T_BUSINE
SS_UNIT, &T_INV_ITEM_ID, &T_DT_TIMESTAMP, &T_SEQ_NBR, &T_TRANSACTION_GROUP, &T_B
USINESS_UNIT_TO, &T_DT_TIMESTAMP_TO, &T_SEQ_NBR_TO, &T_MMC_TRAN_GROUP, &T_MMC_UN
_ORIGEM, &T_NF_ID_ORIGEM, &T_NF_LINE_ORIGEM)
&REC_MMC_TE_TRANSAC = CreateRecord(Record.MMC_TE_TRANSAC);
&REC_MMC_TE_TRANSAC.SETID.VALUE = &T_SETID;
&REC_MMC_TE_TRANSAC.MMC_TE_SOL_ID.VALUE = &T_MMC_TE_SOL_ID;
&REC_MMC_TE_TRANSAC.LINE_NBR.VALUE = &T_LINE_NBR;
&REC_MMC_TE_TRANSAC.MMC_TE_OPERACAO.VALUE = &T_MMC_TE_OPERACAO;
&REC_MMC_TE_TRANSAC.BUSINESS_UNIT_BI.VALUE = &T_BUSINESS_UNIT_BI;
&REC_MMC_TE_TRANSAC.NF_BRL_ID.VALUE = &T_NF_BRL_ID;
&REC_MMC_TE_TRANSAC.NF_BRL_LINE_NUM.VALUE = &T_NF_BRL_LINE_NUM;
&REC_MMC_TE_TRANSAC.BUSINESS_UNIT.VALUE = &T_BUSINESS_UNIT;
&REC_MMC_TE_TRANSAC.INV_ITEM_ID.VALUE = &T_INV_ITEM_ID;
&REC_MMC_TE_TRANSAC.DT_TIMESTAMP.VALUE = &T_DT_TIMESTAMP;
&REC_MMC_TE_TRANSAC.SEQ_NBR.VALUE = &T_SEQ_NBR;
&REC_MMC_TE_TRANSAC.TRANSACTION_GROUP.VALUE = &T_TRANSACTION_GROUP;
&REC_MMC_TE_TRANSAC.BUSINESS_UNIT_TO.VALUE = &T_BUSINESS_UNIT_TO;
&REC_MMC_TE_TRANSAC.DT_TIMESTAMP_TO.VALUE = &T_DT_TIMESTAMP_TO;
&REC_MMC_TE_TRANSAC.SEQ_NBR_TO.VALUE = &T_SEQ_NBR_TO;
&REC_MMC_TE_TRANSAC.MMC_TRAN_GROUP.VALUE = &T_MMC_TRAN_GROUP;
&REC_MMC_TE_TRANSAC.MMC_UN_ORIGEM.VALUE = &T_MMC_UN_ORIGEM;
&REC_MMC_TE_TRANSAC.MMC_NF_ID_ORIGEM.VALUE = &T_NF_ID_ORIGEM;
&REC_MMC_TE_TRANSAC.MMC_NF_LINE_ORIGEM.VALUE = &T_NF_LINE_ORIGEM;
&REC_MMC_TE_TRANSAC.Insert();
End-Function;
Function AJUSTA_SALDO_NF_TERCEIRO(&N_BUSINESS_UNIT, &N_NF_BRL_ID, &N_NF_BRL_LINE
_NUM, &N_QTY_AVAILABLE, &N_MMC_ICMS_SALDO, &N_MMC_IPI_SALDO, &N_MMC_PIS_SALDO, &
N_MMC_COFINS_SALDO, &N_MMC_ISS_SALDO)
&REC_MMC_TE_OP.SCHED_NBR.VALUE = &IND_SCHED_NBR;
&REC_MMC_TE_OP.BUSINESS_UNIT_IN.VALUE = &IND_BUSINESS_UNIT_IN;
&REC_MMC_TE_OP.NF_BRL_ID_2_BBL.VALUE = &IND_NF_BRL_ID_2_BBL;
&REC_MMC_TE_OP.BUSINESS_UNIT_PF.VALUE = &IND_BUSINESS_UNIT_PF;
&REC_MMC_TE_OP.PRODUCTION_ID.VALUE = &IND_PRODUCTION_ID;
&REC_MMC_TE_OP.INV_ITEM_ID.VALUE = &IND_INV_ITEM_ID;
&REC_MMC_TE_OP.MMC_TE_QTD_PAI.VALUE = &IND_MMC_TE_QTD_PAI;
&REC_MMC_TE_OP.MMC_STAT_PROC2.VALUE = &IND_MMC_STAT_PROC2;
&REC_MMC_TE_OP.Insert();
End-Function;
Function CRIA_NF_SERVICO_UNIFICADO(&PS_BUSINESS_UNIT, &PS_NF_BRL_ID, &PS_NF_ID_T
O)
SQLExec("select business_unit_recv, receiver_id from sysadm.ps_nf_hdr_brl whe
re business_unit=:1 and nf_brl_id =:2", &PS_BUSINESS_UNIT, &PS_NF_BRL_ID, &BUSIN
ESS_UNIT_RECV_FROM, &RECEIVER_ID_FROM);
&NFH1 = "insert into sysadm.ps_nf_hdr_brl (business_unit, nf_brl_id, vendor_i
d, nf_brl, nf_brl_series, nf_brl_type, nf_brl_date, nf_brl_status, nf_status_bbl
, nf_brl_ttl_lines, nf_brl_fatura, max_line, cfo_brl_cd, purch_prop_brl, remit_v
endor, remit_addr_seq_num, remit_setid, remit_loc, ship_from_state, ship_brl_to_
state, origin_method, vendor_setid, vndr_loc, accounting_dt, process_instance, b
usiness_unit_gl, dst_cntrl_id, gross_amt, gross_amt_bse, txn_currency_cd, rt_typ
e, rate_div, ";
&NFH2 = " rate_mult, cur_rt_source, base_currency, dscnt_amt, dscnt_amt_bse,
freight_amt, freight_amt_bse, insurance_brl_amt, insurance_brl_bse, otherexp_brl
_amt, otherexp_brl_bse, pymnt_terms_cd, entered_dt, last_update_dt, merchandise_
amt, merch_amt_bse, isstax_brl_amt, isstax_brl_bse, isstax_brl_cd, isstax_brl_bs
s, inss_brl_retention, inss_brl_ret_bse, irtax_brl_amt, irtax_brl_bse, irtax_brl
_bss, irtax_brl_cd, ipitax_brl_amt, ipitax_brl_bse, ipitax_brl_rcvry, icmstax_br
l_amt, ";
&NFH3 = " icmstax_brl_bse, icmstax_brl_bss, icmstax_brl_rcvry, icmstax_brl_re
tent, icmstax_brl_due, icmssub_brl_amt, icmssub_brl_bse, icmssub_brl_bss, tax_br
l_calc_flg, transport_cd, transport_mode, name1, address1, address2, city_cd_bbl
, city, state, zip, country, net_weight_brl, gross_weight_brl, uom_weight, qty_v
ol_brl, num_vol_brl, trade_vol_brl, type_vol_brl, cgc_brl, ie_brl, freight_pay_b
y_brl, licence_plate_brl, voucher_id, receiver_id, business_unit_recv, oprid_las
t_updt, mtch_status_pbl, inout_flg_pbl, prorate_meth_bbl, frght_prorate_pbl, oth
er_prorate_pbl, icms_compl_amt_pbl, descr100, ";
&NFH4 = " in_process_flg, gross_amt_pbl_div, icmstax_pbl_div, ipitax_pbl_div,
busprocname, appr_rule_set, appr_instance, appr_check_flg, appr_status, dfi_pbl
_apprvl_flg, descr, descr60, lt_grp_id_bbl, ship_to_cust_id, address_seq_ship, e
f_loc_brl, location, destin_bu, bill_to_cust_id, address_seq_num, txn_nat_bbl, i
n_out_cd_bbl, pnd_item_type_bbl, rma_flg_bbl, tie_nf_flg_bbl, acct_flg_bbl, busi
ness_unit_in, rmneio_id_bbl, carrier_id, trnsport_resp_bbl, frght_pmt_resp_bbl,
vehicle_id, ";
&NFH5 = " vehcl_id_state_bbl, ratio_uom_bbl, qty_vol_bbl, num_vol_bbl, dst_id
_ar, cofins_amt_bse_bbl, cofins_bss_amt_bbl, pis_amt_bse_bbl, pis_bss_amt_bbl, s
erv_amt_bbl_bse, rma_id, interunit_flg, cost_adj_sts_pbl, flag_fm_pbl, frt_incr_
bse_bbl, insr_incr_bse_bbl, otex_incr_bse_bbl, collect_cod_brl, dfi_entry_sts_pb
l, grp_id_pbl, cofinst_bseamt_bbl, cofinst_bssamt_bbl, pisst_bse_amt_bbl, ir_bss
_amt_bbl, ir_bse_amt_bbl, inss_bss_amt_bbl, inss_bse_amt_bbl, shipto_id, nf_id_r
End-Function;
CANCELA_RECEBIMENTO_TERCEIROS(&PR_BUSINESS_UNIT, &PR_RECEIVER_ID);
SQLExec("select distinct 'Y' from sysadm.ps_mmc_te_op where business_unit_in=
:1 and nf_brl_id_2_bbl=:2 and mmc_stat_proc2='C'", &PNF_BUSINESS_UNIT, &PNF_NF_B
RL_ID, &EXISTE_PRODU);
If &EXISTE_PRODU = "Y" Then
Error ("NF no pode ser Extornada, pois ja existe Ordem de Produo");
End-If;
_no =:4 and transaction_group='030' and qty < 0 ", &TRAN_BUSINESS_UNIT, &TRAN_I
NV_ITEM_ID, &T_ORDER_NO, &T_ORDER_INT_LINE_NO, &T_030_DT_TIMESTAMP, &T_030_SEQ_N
BR);
If None(&T_030_DT_TIMESTAMP) Or
None(&T_030_SEQ_NBR) Then
Error ("No foi encontrado transao para operao '030'");
End-If;
&TR_SETID = " ";
&TR_MMC_TE_SOL_ID = 0;
&TR_LINE_NBR = 0;
&TR_BUSINESS_UNIT_BI = &TT_BUSINESS_UNIT_BI;
&TR_NF_BRL_ID = &TT_NF_BRL_ID;
&TR_NF_BRL_LINE_NUM = &TT_NF_BRL_LINE_NUM;
&TR_MMC_TE_OPERACAO = &PNF_MMC_TE_OPERACAO;
&TR_BUSINESS_UNIT = &TRAN_BUSINESS_UNIT;
&TR_INV_ITEM_ID = &TRAN_INV_ITEM_ID;
&TR_DT_TIMESTAMP = &T_030_DT_TIMESTAMP;
&TR_SEQ_NBR = &T_030_SEQ_NBR;
&TR_TRANSACTION_GROUP = "030";
&TR_BUSINESS_UNIT_TO = " ";
&TR_DT_TIMESTAMP_TO = Date3(1900, 1, 1);
&TR_SEQ_NBR_TO = 0;
&TR_MMC_TRAN_GROUP = " ";
&TR_MMC_UN_ORIGEM = " ";
&TR_NF_ID_ORIGEM = " ";
&TR_NF_LINE_ORIGEM = 0;
SQLExec("select transaction_group, 'Y' from sysadm.ps_mmc_te_tran
sac where business_unit_bi=:1 and nf_brl_id=:2 and nf_brl_line_num= :3 and mmc_t
e_operacao=:4 ", &TT_BUSINESS_UNIT_BI, &TT_NF_BRL_ID, &TT_NF_BRL_LINE_NUM, &PNF_
MMC_TE_OPERACAO, &GRUPO2, &EXISTE2);
If &EXISTE2 = "Y" And
None(&GRUPO2) Then
SQLExec("update sysadm.ps_mmc_te_transac set business_unit=:1,
dt_timestamp = %DateTimeIn(:2), seq_nbr=:3, transaction_group = :4 where busine
ss_unit_bi=:5 and nf_brl_id=:6 and nf_brl_line_num= :7 and mmc_te_operacao=:8 ",
&TRAN_BUSINESS_UNIT, &T_030_DT_TIMESTAMP, &T_030_SEQ_NBR, &TRAN_TRANSACTION_GRO
UP, &TT_BUSINESS_UNIT_BI, &TT_NF_BRL_ID, &TT_NF_BRL_LINE_NUM, &PNF_MMC_TE_OPERAC
AO);
Else
GRAVA_TRANSACAO_TERCEIROS(&TR_SETID, &TR_MMC_TE_SOL_ID, &TR_LI
NE_NBR, &TR_BUSINESS_UNIT_BI, &TR_NF_BRL_ID, &TR_NF_BRL_LINE_NUM, &TR_MMC_TE_OPE
RACAO, &TR_BUSINESS_UNIT, &TR_INV_ITEM_ID, &TR_DT_TIMESTAMP, &TR_SEQ_NBR, &TR_TR
ANSACTION_GROUP, &TR_BUSINESS_UNIT_TO, &TR_DT_TIMESTAMP_TO, &TR_SEQ_NBR_TO, &TR_
MMC_TRAN_GROUP, &TR_MMC_UN_ORIGEM, &TR_NF_ID_ORIGEM, &TR_NF_LINE_ORIGEM);
End-If;
End-If;
End-If;
End-While;
/* #########################################################
##
## INICIO: Verifica se POPRO, se sim volta o saldo da NF.
##
###########################################################
*/
SQLExec("select distinct 'Y' from sysadm.ps_mmc_te_op where business_unit=
:1 and nf_brl_id = :2", &PNF_BUSINESS_UNIT, &PNF_NF_BRL_ID, &NF_SERVICO);
If &SALDO_NF <> "Y" And
&NF_SERVICO <> "Y" Then
If All(&TT_MMC_UN_ORIGEM) And
All(&TT_MMC_NF_ID_ORIGEM) And
All(&TT_MMC_NF_LINE_ORIGEM) Then
SQLExec("select irtax_brl_amt, mmc_ir_saldo, inv_item_id, qty, qty_a
vailable, icmstax_brl_amt, mmc_icms_saldo, ipitax_brl_amt, mmc_ipi_saldo, pistax
_brl_amt, mmc_pis_saldo, cofinstax_brl_amt, mmc_cofins_saldo, isstax_brl_amt, mm
c_iss_saldo from sysadm.ps_mmc_te_s_nf_vw2 where business_unit=:1 and nf_brl_id=
:2 and nf_brl_line_num = :3 ", &TT_MMC_UN_ORIGEM, &TT_MMC_NF_ID_ORIGEM, &TT_MMC_
NF_LINE_ORIGEM, &SS_IRTAX_BRL_AMT, &SS_MMC_IR_SALDO, &SS_INV_ITEM_ID, &SS_QTY, &
SS_QTY_AVAILABLE, &SS_ICMSTAX_BRL_AMT, &SS_MMC_ICMS_SALDO, &SS_IPITAX_BRL_AMT, &
SS_MMC_IPI_SALDO, &SS_PISTAX_BRL_AMT, &SS_MMC_PIS_SALDO, &SS_COFINSTAX_BRL_AMT,
&SS_MMC_COFINS_SALDO, &SS_ISSTAX_BRL_AMT, &SS_MMC_ISS_SALDO);
SQLExec("select a.irtax_brl_amt, b.qty_nf_brl, b.icmstax_brl_amt, b.
ipitax_brl_amt, b.pistax_brl_amt, b.cofinstax_brl_amt, b.isstax_brl_amt from ps_
nf_hdr_brl a, ps_nf_ln_brl b where b.business_unit =:1 and b.nf_brl_id =:2 and
b.nf_brl_line_num =:3 and a.business_unit = b.business_unit and a.nf_brl_id = b.
nf_brl_id", &TT_BUSINESS_UNIT_BI, &TT_NF_BRL_ID, &TT_NF_BRL_LINE_NUM, &S1_IRTAX_
BRL_AMT, &S1_QTY_NF_BRL, &S1_ICMSTAX_BRL_AMT, &S1_IPITAX_BRL_AMT, &S1_PISTAX_BRL
_AMT, &S1_COFINSTAX_BRL_AMT, &S1_ISSTAX_BRL_AMT);
If %Component <> "DELETE_FISCDOC_PBL" Then
If (&S1_IRTAX_BRL_AMT > (&SS_IRTAX_BRL_AMT - &SS_MMC_IR_SALDO)) T
hen
Error ("Saldo IR insuficiente para fazer cancelamento");
End-If;
If (&S1_QTY_NF_BRL > (&SS_QTY - &SS_QTY_AVAILABLE)) Then
Error ("Saldo QTD insuficiente para fazer cancelamento");
End-If;
Else
Error ("No existe NF de origen para UN: " | &TT_BUSINESS_UNIT_BI | "
NF: " | &TT_NF_BRL_ID | " LINHA: " | &TT_NF_BRL_LINE_NUM);
End-If; /* If All(&TT_MMC_UN_ORIGEM) And All(&TT_MMC_NF_ID_ORIGEM) And
All(&TT_MMC_NF_LINE_ORIGEM) Then */
End-While;
/********************************* mmcb.hd51767.S.N *************************
********/
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
=
=
=
=
=
=
=
"";
"
&SQL
&SQL
&SQL
&SQL
&SQL
|
|
|
|
|
";
&SQL = &SQL |
&SQL = &SQL |
SS_UNIT | "' ";
&SQL = &SQL |
_ID | "' ";
&SQL = &SQL |
&SQL = &SQL |
&SQL = &SQL |
&SQL = &SQL |
&SQL = &SQL |
S_UNIT ";
&SQL = &SQL |
ID ";
&SQL = &SQL |
"
"
AND TMP.NF_BRL_ID_2_BBL
AND TMP.BUSINESS_UNIT
= H.NF_BRL_ID ";
= '" | &PNF_BUSINE
"
AND TMP.NF_BRL_ID
= '" | &PNF_NF_BRL
"
"
"
"
"
)
";
AND NOT EXISTS ";
( ";
SELECT 1 FROM SYSADM.PS_NF_LN_BRL L ";
WHERE L.BUSINESS_UNIT
=
"
"
AND L.NF_BRL_ID
)
H.BUSINES
H.NF_BRL_
";
SQLExec(&SQL);
If None(&TT_BUSINESS_UNIT_BI) Or
&TT_BUSINESS_UNIT_BI = "" Or
&TT_BUSINESS_UNIT_BI = " " Then
Error ("Parametro: TT_BUSINESS_UNIT_BI em branco funo: GRAVA_MMC_TE_TRANSAC
.");
End-If;
If None(&TT_NF_BRL_ID) Or
&TT_NF_BRL_ID = "" Or
&TT_NF_BRL_ID = " " Then
Error ("Parametro: &TT_NF_BRL_ID em branco funo: GRAVA_MMC_TE_TRANSAC .");
End-If;
If None(&TT_NF_BRL_LINE_NUM) Or
&TT_NF_BRL_LINE_NUM = 0 Then
Error ("Parametro: &TT_NF_BRL_LINE_NUM em branco funo: GRAVA_MMC_TE_TRANSAC
.");
End-If;
If None(&TT_MMC_TE_OPERACAO) Or
&TT_MMC_TE_OPERACAO = "" Or
&TT_MMC_TE_OPERACAO = " " Then
Error ("Parametro: &TT_MMC_TE_OPERACAO em branco funo: GRAVA_MMC_TE_TRANSAC
.");
End-If;
If None(&TT_INV_ITEM_ID) Or
&TT_INV_ITEM_ID = "" Or
&TT_INV_ITEM_ID = " " Then
Error ("Parametro: &TT_INV_ITEM_ID em branco funo: GRAVA_MMC_TE_TRANSAC .")
;
End-If;
&REC_MMC_TE_TRANSAC = CreateRecord(Record.MMC_TE_TRANSAC);
&REC_MMC_TE_TRANSAC.BUSINESS_UNIT_BI.VALUE = &TT_BUSINESS_UNIT_BI;
&REC_MMC_TE_TRANSAC.NF_BRL_ID.VALUE = &TT_NF_BRL_ID;
&REC_MMC_TE_TRANSAC.NF_BRL_LINE_NUM.VALUE = &TT_NF_BRL_LINE_NUM;
&REC_MMC_TE_TRANSAC.MMC_TE_OPERACAO.VALUE = &TT_MMC_TE_OPERACAO;
&REC_MMC_TE_TRANSAC.SETID.VALUE = &TT_SETID;
&REC_MMC_TE_TRANSAC.MMC_TE_SOL_ID.VALUE = &TT_MMC_TE_SOL_ID;
&REC_MMC_TE_TRANSAC.LINE_NBR.VALUE = &TT_LINE_NBR;
&REC_MMC_TE_TRANSAC.BUSINESS_UNIT.VALUE = &TT_BUSINESS_UNIT;
&REC_MMC_TE_TRANSAC.INV_ITEM_ID.VALUE = &TT_INV_ITEM_ID;
&REC_MMC_TE_TRANSAC.DT_TIMESTAMP.VALUE = &TT_DT_TIMESTAMP;
&REC_MMC_TE_TRANSAC.SEQ_NBR.VALUE = &TT_SEQ_NBR;
&REC_MMC_TE_TRANSAC.TRANSACTION_GROUP.VALUE = &TT_TRANSACTION_GROUP;
&REC_MMC_TE_TRANSAC.BUSINESS_UNIT_TO.VALUE = &TT_BUSINESS_UNIT_TO;
&REC_MMC_TE_TRANSAC.DT_TIMESTAMP_TO.VALUE = &TT_DT_TIMESTAMP_TO;
&REC_MMC_TE_TRANSAC.SEQ_NBR_TO.VALUE = &TT_SEQ_NBR_TO;
&REC_MMC_TE_TRANSAC.MMC_TRAN_GROUP.VALUE = &TT_MMC_TRAN_GROUP;
&REC_MMC_TE_TRANSAC.MMC_UN_ORIGEM.VALUE = &TT_MMC_UN_ORIGEM;
&REC_MMC_TE_TRANSAC.MMC_NF_ID_ORIGEM.VALUE = &TT_MMC_NF_ID_ORIGEM;
&REC_MMC_TE_TRANSAC.MMC_NF_LINE_ORIGEM.VALUE = &TT_MMC_NF_LINE_ORIGEM;
&REC_MMC_TE_TRANSAC.Insert();
End-Function;
[MMC_TE_WRK.MMC_TE_CONFI_FLG.FieldChange]
/*******************************************************************************
****
* Bleno L Sampaio - MMC - mmcb.sds4924 - 05/12/2014
*
* Otimizar processo Recbto Terceiros via XML
*
*******************************************************************************
****/
If %Page = Page.MMC_TE_RECV_TRIAN Then
If MMC_TE_CONFI_FLG = "Y" Then
If All(MMC_TE_TRIA_WRK.MMC_CHAVE_ACS_NFE) Then
SQLExec("SELECT SUM(QCOM) FROM SYSADM.INFF10_DET WHERE CFG_CNPJFORN = T
O_NUMBER(TRANSLATE(:1, '~./-', '-')) AND CFG_NUMERO_NF = TO_NUMBER(:2) AND CFG_S
ERIE_NF = :3 AND CPROD = :4", MMC_TE_TRIA_WRK.CGC_BRL, NF_HDR_BRL.NF_BRL, NF_HDR
_BRL.NF_BRL_SERIES, MMC_TE_S_NF_VW.INV_ITEM_ID, &qtdNFsaida);
If All(&qtdNFsaida) Then
If MMC_TE_S_NF_VW.QTY_AVAILABLE >= &qtdNFsaida Then
QTY_OPEN = &qtdNFsaida;
Else
WinMessage("A quantidade de itens do XML desta NF " | &qtdNFsaida
| ", logo o saldo no suficiente receber todos os itens desta NF.");
End-If;
End-If;
End-If;
End-If;
End-If;
[MMC_TE_WRK.QTY_OPEN.FieldChange]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 21/11/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Muda Flag das OCs Selecionadas parar 'Y' quando e digitada uma QTD maior que
Zero
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Vincius Alves Mello - MMC - 05/10/2010 - mmcb.sds3426 - Sistema Controle Terce
iros
*
* Realizar a verificao entre os itens da NF de retorno e o BOM.
*
*******************************************************************************
*****************/
[MMC_TE_WRK.SERIAL_ID.FieldChange]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 27/11/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Coloca o mesmo conteudo no campo INV_LOT_ID do campo SERIAL_ID
*
*******************************************************************************
*****************/
/********************** mmcb.at2323.sn **********************/
*/
[MMC_VND_CST_ADD.CUST_ID.FieldChange]
/********************************************************************
* Claudio Henrique da Costa - MMC - AT2138 - 18/09/2007
*
* Alterao para que se relacione um Cliente a cada endereo de
*
* Fornecedor.
*
********************************************************************/
VENDOR_AR.SETID = SETID;
VENDOR_AR.CUST_ID = CUST_ID;
[MMC_VND_CST_ADD.CUST_ID.FieldEdit]
/********************************************************************
* Claudio Henrique da Costa - MMC - AT2138 - 18/09/2007
* Alterao para que se relacione um Cliente a cada endereo de
* Fornecedor.
********************************************************************/
/*********************************************************************
* Vincius Alves Mello - MMC - 30/07/2010 - mmcb.hd96568
* Verificar se ja existe um cliente cadastrado para outro endereo *
* do fornecedor.
*
********************************************************************/
/*********************************************************************
* Bleno Sampaio - MMC - 24/05/2011 - mmcb.hd116432
* Problema ao salvar a tela de vincular Cliente ao fornecedor
*
********************************************************************/
*
*
*
*
&RS0 = GetLevel0();
&RS1 = &RS0(1).GetRowset(Scroll.VENDOR_ADDR);
&PRINCIPAL_MARCADO = "N";
For &i = 1 To &RS1.ActiveRowCount
&RS2 = &RS1(&i).GetRowset(Scroll.MMC_VND_CST_ADD);
&RC1 = &RS2(1).GetRecord(Record.MMC_VND_CST_ADD);
If (&RC1.PRINCIPAL.Value = "Y") Then
&PRINCIPAL_MARCADO = "Y";
End-If;
End-For;
If (&PRINCIPAL_MARCADO = "N") Then
Error ("O Endereo principal deve ser indicado.");
End-If;
End-If;
If %Page = "CUST_VENDOR_INFO" Then
&RS00 = GetLevel0();
&RS0 = &RS00(1).GetRowset(Scroll.VENDOR_AR);
&RC2 = &RS0(1).GetRecord(Record.VENDOR_AR);
&RS1 = &RS0(1).GetRowset(Scroll.VENDOR_ADDR);
&PRINCIPAL_MARCADO = "N";
For &i = 1 To &RS1.ActiveRowCount
&RS2 = &RS1(&i).GetRowset(Scroll.MMC_VND_CST_ADD);
&RC1 = &RS2(1).GetRecord(Record.MMC_VND_CST_ADD);
If (&RC1.PRINCIPAL.Value = "Y") Then
&PRINCIPAL_MARCADO = "Y";
&RC2.CUST_ID.Value = &RC1.CUST_ID.Value;
End-If;
End-For;
If (&PRINCIPAL_MARCADO = "N") Then
Error ("O Endereo principal deve ser indicado.");
End-If;
End-If;
End-If;
[NF_CNFM_BBL_WRK.BUSINESS_UNIT.FieldChange]
AddKeyListItem(NF_HDSR_BBL_VW1.BUSINESS_UNIT,
AddKeyListItem(NF_HDSR_BBL_VW2.BUSINESS_UNIT,
AddKeyListItem(NF_HDSR_BBL_VW3.BUSINESS_UNIT,
AddKeyListItem(NF_HDSR_BBL_VW4.BUSINESS_UNIT,
AddKeyListItem(NF_HDSR_BBL_VW5.BUSINESS_UNIT,
AddKeyListItem(NF_HDSR_BBL_VW6.BUSINESS_UNIT,
AddKeyListItem(NF_HDSR_BBL_VW7.BUSINESS_UNIT,
BUSINESS_UNIT);
BUSINESS_UNIT);
BUSINESS_UNIT);
BUSINESS_UNIT);
BUSINESS_UNIT);
BUSINESS_UNIT);
BUSINESS_UNIT);
[NF_CNFM_BBL_WRK.BUSINESS_UNIT.RowInit]
/*BRLOC-BI Localization Release 1
Author: Mrio Tonizza Pereira
Creation Date: 05/10/99
*/
If %PanelGroup = PanelGroup.NF_CNFM_BBL Then
ScrollFlush(Record.NF_HDR_BBL_VW3);
End-If;
[NF_CNFM_BBL_WRK.CONFIRMED_FLAG.FieldChange]
/*******************************************************************************
*******
Bruno Verosa - MMC - 14/12/2011 mmcb.hd4055 - Customizao para gerar uma nf no peopl
e com algum erro que no valide no Sefaz , tentar confirmar no People este ID , o
People no poder deixar confirmar o ID.
********************************************************************************
********/
/*******************************************************************************
*******
Mauri R. Back - MMC - 23/04/2012 mmcb.hd139017 - Permitir confirmar NF de Rally
nao vai para o triangulus, pois uma serie nova
********************************************************************************
********/
/*******************************************************************************
*******
Filipe/Rosangela Enc.Vinicius Favero - MMC - 30/07/2013 - mmcb.hd179384
Incluir a serie E para no passar pela validao de confirmao da Sefaz, por ser uma
serie de servio.
********************************************************************************
********/
/*
If %Page = Page.NF_CNFM_BBL Then
&BU = FetchValue(Record.NF_HDR_BBL_VW3, CurrentRowNumber(), NF_HDR_BBL_VW3.BU
SINESS_UNIT);
&NF = FetchValue(Record.NF_HDR_BBL_VW3, CurrentRowNumber(), NF_HDR_BBL_VW3.NF
_BRL_ID);
&FLAG = FetchValue(Record.NF_HDR_BBL_VW3, CurrentRowNumber(), CONFIRMED_FLAG)
;
If All(&NF) And
(&FLAG = "Y") Then
SQLExec("SELECT substr(CFO_BRL_CD, 1, 1), NF_BRL_SERIES FROM SYSADM.PS_N
F_HDR_BBL_FS WHERE BUSINESS_UNIT = :1 AND NF_BRL_ID = :2", &BU, &NF, &CFO, &SERI
E);
If &CFO = "7" Then
And
<> "A" And
<> "D1" And
<> "D2" And
<> "0" And
<> "E" And /*mmcb.hd179384.ln*/
<> "A1" Then
CONFIRMED_FLAG = "N";
WinMessage("A Nota Fiscal: " | &NF_ID | " no obteve confirmao da Sefaz.");
End-If;
End-If;
/************************************************************************mmcb.sd
s4055.en*/
[NF_CNFM_BBL_WRK.CONFIRMED_FLAG.RowInit]
Gray(CONFIRMED_FLAG);
[NF_CNFM_BBL_WRK.CONFIRMED_FLAG.SaveEdit]
/********************Begin Localization**************************
|| BRLOC-BI Localization Release 1
|| Rotina que
|| 1. Confere a somatoria das linhas de distribuio por linha de NF
|| Author: Florival Athaide
================================================================*/
Global number &SUMLANC;
Global number &LINHANOTA;
If %Page = Page.NF_CNFM_BBL Then
&BU = FetchValue(Record.NF_HDR_BBL_VW3, CurrentRowNumber(), NF_HDR_BBL_VW3.BU
SINESS_UNIT);
&NF = FetchValue(Record.NF_HDR_BBL_VW3, CurrentRowNumber(), NF_HDR_BBL_VW3.NF
_BRL_ID);
&FLAG = FetchValue(Record.NF_HDR_BBL_VW3, CurrentRowNumber(), CONFIRMED_FLAG)
;
If All(&NF) And
(&FLAG = "Y") Then
/*** JEISON CALDAS - 31/03/09 - HD 65595 - SOLICITADO PELO DARIO RETIRAR C
USTOMIZAO DA PRODUO - INICIO SQLExec("SELECT substr(CFO_BRL_CD, 1, 1) FROM SYSADM.PS_NF_HDR_BBL_FS WHERE BU
SINESS_UNIT = :1 AND NF_BRL_ID = :2", &BU, &NF, &CFO);
If &CFO = "7" Then
SQLExec("SELECT 'Y' FROM SYSADM.PS_MMC_NF_EXP_HDR WHERE BUSINESS_UNIT =
:1 AND NF_BRL_ID = :2", &BU, &NF, &SPED);
If All(&SPED) Then
UpdateValue(CONFIRMED_FLAG, CurrentRowNumber(), "Y");
Else
Error "A Nota Fiscal de ID : " | &NF | " no pode ser confirmada devid
o a falta de informaes de SPED.";
UpdateValue(CONFIRMED_FLAG, CurrentRowNumber(), "N");
End-If;
Else
UpdateValue(CONFIRMED_FLAG, CurrentRowNumber(), "Y");
End-If;
- JEISON CALDAS - 31/03/09 - HD 65595 - SOLICITADO PELO DARIO RETIRAR CUST
OMIZAO DA PRODUO - FIM ***/
UpdateValue(CONFIRMED_FLAG, CurrentRowNumber(), "Y");
End-If;
End-If;
[NF_CNFM_BBL_WRK.CONFIRMED_FLAG.SavePostChange]
/********************Begin Localization**************************
|| BRLOC-BI Localization Release 1
|| Rotina que
|| 1. Confere a somatoria das linhas de distribuio por linha de NF
|| 2. Muda o status do NF_HDR_BRL.NF_STATUS_BBL para 'CNFM' (Confirmed)
||
e as datas de confirmaao para do dia e de contabilizacao para a
||
data de emisso (ISSUE_DT)
|| 3. Muda o status RMNEIO_LINE_BBL.INF_PRC_STATUS_BBL para 'I' (Invoiced)
*
* identificada.
*
*******************************************************************************
**********/
/*******************************************************************************
**********
* Gustavo V. Neto - MMCB - 30/10/2009 - mmcb.sds3239
*
* Projeto Implantao People - Multi Empresa MMCB-SVB.
*
*******************************************************************************
**********/
/*******************************************************************************
**********
* JC800888 Jeison Caldas - 26.11.09 - SDS 3085
*
* Correo SDS2440 - Customizao no considerava mais de uma linha de ativo na nota
*
* fiscal.
*
*******************************************************************************
**********/
/*******************************************************************************
**********
* Itamar Junior - MMCB - 19/08/2009 - mmcb.hd73211
*
* Ajuste para evitar lanamentos duplicados na tabela de transao de terceiros
*
*******************************************************************************
**********/
/*******************************************************************************
**********
* Vincius Alves Mello - MMCB - 23/11/2010 - mmcb.sds3686
*
* Atualizar MMC_ASSET_LOC, quando um ativo for movimentado
*
*******************************************************************************
**********/
/*******************************************************************************
**********
* Mauri/Adercley (Enc. Filipe Rehder) - MMCB - 27/07/2012
- mmcb.hd147325
*
* Otimizar update em embarques de confirmao de NF devido a lentido
*
*******************************************************************************
**********/
/*******************************************************************************
**********
* Vincius Alves Mello - MMC - mmcb.sds4613 - 31/10/2013
*
* Otimizar Completar NF, devido ao processo que gera a 030 na tabela MMC_TE_CON
TR_MT. *
*******************************************************************************
**********/
/*******************************************************************************
**********
* Fernando Camarinha - MMCB - 18/10/2012
- mmcb.sds3884
*
* Novo Sistema de Controle de Pagamentos Comisses de Venda
*
*******************************************************************************
**********/
/*******************************************************************************
**********
* Vincius Alves Mello - MMC - mmcb.sds5105 - 26/01/2015
*
* Ajustes controle de terceiros em nosso poder.
*
*******************************************************************************
**********/
/*******************************************************************************
**********
* Bleno L Sampaio - MMC - mmcb.sds5222 - 23/04/2015
*
* Projeto FWA - Interface de dados de Terceiros entre empresas do grupo
*
*******************************************************************************
**********/
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange; /* mmc
b.sds3239.ln */
/************************************************************************
* Wagner Sorio - MMCB - 01/09/2014 - mmcb.sds4689
*
* Implantao do People DBME
*
*************************************************************************/
/* Declare Function BU_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange; */ /*
mmcb.sds4689.lo */
TOF_MMC.MMC_MERC_TERC
TOF.EFFDT
= 'Y' ";
= TOF_MMC.EFFDT
";
&SQL = &SQL | " AND TOF.EFF_STATUS
&SQL = &SQL | " AND TOF.TOF_PBL
&SQL = &SQL | " AND TOF.EFFDT
&SQL = &SQL | "
AX(XTOF.EFFDT) ";
&SQL = &SQL | "
ADM.PS_TOF_TYPE_PBL XTOF ";
&SQL = &SQL | "
OF.EFFDT
= TOF.EFFDT ";
&SQL = &SQL | "
OF.TOF_PBL
= TOF.TOF_PBL ";
&SQL = &SQL | "
OF.EFF_STATUS = 'A' ";
&SQL = &SQL | "
&SQL = &SQL | " AND SOL_HDR.BUSINESS_UNIT_BI
&SQL = &SQL | " AND SOL_HDR.NF_BRL_ID
&SQL = &SQL | " AND SOL_HDR.SETID
&SQL = &SQL | " AND SOL_HDR.MMC_TE_SOL_ID
";
&SQL = &SQL | " AND LN.BUSINESS_UNIT
BI ";
&SQL = &SQL | " AND LN.NF_BRL_ID
&SQL = &SQL | " AND LN.NF_BRL_LINE_NUM
M ";
&SQL = &SQL | " AND MMC_TE_SOL_STATUS
&SQL = &SQL | " AND LN.INV_ITEM_ID
;
&SQL = &SQL | " AND SOL_LN.MMC_TE_SOL_BUS_UN
&SQL = &SQL | " AND SOL_LN.MMC_TE_SOL_NF_ID
&SQL = &SQL | " AND SOL_LN.MMC_TE_SOL_LN_NF
&SQL = &SQL | " AND TCM.BUSINESS_UNIT
_UN ";
&SQL = &SQL | " AND TCM.NF_BRL_ID
ID ";
&SQL = &SQL | " AND TCM.NF_BRL_LINE_NUM
NF ";
&SQL = &SQL | " AND TCM.TRANSACTION_GROUP
&SQL = &SQL | " AND NOT EXISTS
&SQL = &SQL | "
Y' ";
&SQL = &SQL | "
ADM.PS_MMC_TE_CONTR_MT XTCM ";
&SQL = &SQL | "
CM.BUSINESS_UNIT
= TCM.BUSINESS_UNIT ";
&SQL = &SQL | "
CM.NF_BRL_ID
= TCM.NF_BRL_ID ";
&SQL = &SQL | "
CM.NF_BRL_LINE_NUM = TCM.NF_BRL_LINE_NUM ";
&SQL = &SQL | "
CM.TRANSACTION_GROUP = '030' ";
&SQL = &SQL | "
CM.BUSINESS_UNIT_BI = HDR.BUSINESS_UNIT ";
&SQL = &SQL | "
CM.MMC_NF_BRL_ID_OUT = HDR.NF_BRL_ID ";
&SQL = &SQL | "
CM.MMC_LINE_NUM_OUT = LN.NF_BRL_LINE_NUM ";
&SQL = &SQL | "
= 'A' ";
= TOF_MMC.TOF_PBL ";
= ( ";
SELECT M
FROM SYS
WHERE XT
AND
XT
AND
XT
) ";
= HDR.BUSINESS_UNIT ";
= HDR.NF_BRL_ID ";
= SOL_LN.SETID ";
= SOL_LN.MMC_TE_SOL_ID
= SOL_LN.BUSINESS_UNIT_
= SOL_LN.NF_BRL_ID ";
= SOL_LN.NF_BRL_LINE_NU
<> '5' ";
= SOL_LN.INV_ITEM_ID "
<>
<>
<>
=
= SOL_LN.MMC_TE_SOL_NF_
= SOL_LN.MMC_TE_SOL_LN_
= '020' ";
( ";
SELECT '
FROM SYS
WHERE XT
) ";
AND
XT
AND
XT
AND
XT
AND
XT
AND
XT
AND
XT
&SQL
&SQL
&SQL
&SQL
=
=
=
=
=
=
=
=
=
=
=
=
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
=
=
=
=
E_AMT
"";
" SELECT
&SQL | "
&SQL | "
&SQL | "
&SQL | "
&SQL | "
&SQL | "
&SQL | "
&SQL | "
&SQL | "
&SQL | "
&SQL
&SQL
&SQL
&SQL
|
|
|
|
"
"
"
"
DISTINCT ";
SOL_HDR.SETID, ";
SOL_HDR.MMC_TE_SOL_ID, ";
LN.TOF_PBL, ";
SOL_LN.MMC_TE_SOL_BUS_UN, ";
SOL_LN.MMC_TE_SOL_NF_ID, ";
SOL_LN.MMC_TE_SOL_LN_NF, ";
SOL_LN.MMC_TE_SOL_NF_FORN , ";
SOL_LN.MMC_TE_SOL_SE_FORN, ";
LN.INV_ITEM_ID, ";
LN.QTY_NF_BRL, ";
LN.DESCR, ";
HDR_IN.NF_BRL_DATE, ";
HDR_IN.VENDOR_ID, ";
LN_IN.TAX_CLASS_BRL, ";
=
=
=
=
=
=
=
=
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
|
|
|
|
|
|
|
|
"
"
"
"
"
"
"
"
HDR.BUSINESS_UNIT, ";
HDR.NF_BRL_ID, ";
LN.NF_BRL_LINE_NUM, ";
HDR.SHIP_TO_CUST_ID, ";
SOL_HDR.OPRID, ";
LN.UNIT_OF_MEASURE, ";
SOL_LN.MONETARY_AMOUNT, ";
(LN.QTY_NF_BRL * SOL_LN.MONETARY_AMOUNT) AS MERCHANDIS
=
=
=
=
=
=
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
|
|
|
|
|
|
";
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
= SOL_LN.INV_ITEM_ID
";
&SQL = &SQL | " AND SOL_LN.MMC_TE_SOL_BUS_UN
&SQL = &SQL | " AND SOL_LN.MMC_TE_SOL_NF_ID
&SQL = &SQL | " AND SOL_LN.MMC_TE_SOL_LN_NF
&contSQL = CreateSQL(&SQL);
&TEMP = "X";
While &contSQL.Fetch(&CONTR_SOL_SETID, &CONTR_SOL_ID, &CONTR_TOF_PBL,
&CONTR_MMC_TE_SOL_BUS_UN, &CONTR_MMC_TE_SOL_NF_ID, &CONTR_MMC_TE_SOL_LN_NF, &CON
'" | &CONTR_MMC_T
'" | &CONTR_MMC_T
B.BUSINESS_UNIT
B.NF_BRL_ID
'" | &CONTR_MMC_T
&contSQL1 = CreateSQL(&SQL1);
&contSQL1.Fetch(&CONTR_DESCR, &CONTR_NF_BRL_DATE, &CONTR_VENDOR_ID,
&CONTR_TAX_CLASS_BRL);
&CONTR_TRANSACTION_GROUP = "030";
&CONTR_TRANSACTION_DATE = %Date;
&CONTR_SOURCE_BUS_UNIT = " ";
&CONTR_ORDER_NO = " ";
&CONTR_ORDER_INT_LINE_NO = 0;
&CONTR_ACCOUNT = " ";
&CONTR_MMC_TIPO_AJUST = " ";
&CONTR_MMC_OBS_AJUST = " ";
&CONTR_SHIPTO_ID = " ";
&CONTR_MMC_ISSUE_QTY = &CONTR_QTY_NF_BRL * - 1;
If All(&CONTR_SOL_ID) And
&TEMP = "X" Then
SQLExec("update sysadm.ps_mmc_te_sol_hdr set mmc_te_sol_status='
GRAVA_CONTROLE_MAT_TERC(&CONTR_MMC_TE_SOL_BUS_UN, &CONTR_MMC_TE_SOL
_NF_ID, &CONTR_MMC_TE_SOL_LN_NF, &CONTR_MMC_TE_SOL_NF_FORN, &CONTR_MMC_TE_SOL_SE
_FORN, &CONTR_INV_ITEM_ID, &CONTR_DESCR, &CONTR_VENDOR_ID, &CONTR_NF_BRL_DATE, &
CONTR_TRANSACTION_GROUP, &CONTR_TRANSACTION_DATE, &CONTR_TAX_CLASS_BRL, &CONTR_T
OF_PBL, &CONTR_SOURCE_BUS_UNIT, &CONTR_ORDER_NO, &CONTR_ORDER_INT_LINE_NO, &CONT
R_BUSINESS_UNIT, &CONTR_NF_BRL_ID, &CONTR_NF_BRL_LINE_NUM, &CONTR_SHIP_TO_CUST_I
D, &CONTR_ACCOUNT, &CONTR_MMC_TIPO_AJUST, &CONTR_OPRID, &CONTR_UNIT_OF_MEASURE,
&CONTR_MMC_OBS_AJUST, &CONTR_MMC_ISSUE_QTY, &CONTR_QTY_NF_BRL, &CONTR_UNIT_PRICE
, &CONTR_MERCHANDISE_AMT, &CONTR_SHIPTO_ID);
End-While;
End-If;
End-If;
End-If;
*/
/************************* MMCB.AT2946.EN **************************************
*******/
/************************************* mmcb.sds4613.eo *************************
************/
********************************************/
&SQL_DEMAND = CreateSQL("select B.business_unit,b.demand_source,b.source_bus_
unit, b.order_no, b.order_int_line_no, b.sched_line_no, b.inv_item_id, b.demand_
line_no FROM SYSADM.PS_MMC_NF_RELC_DEV A, SYSADM.PS_SHIP_INV_NF_BRL B WHERE A.BU
SINESS_UNIT_BI = :1 AND A.MMC_NF_bRL_ID_BI = :2 AND B.BUSINESS_UNIT_PO = A.BUSIN
ESS_UNIT AND B.NF_BRL_ID
= A.NF_BRL_ID AND B.DEMAND_SOURCE = 'RT' order b
y B.business_unit,b.demand_source,b.source_bus_unit, b.order_no, b.order_int_lin
e_no, b.sched_line_no, b.inv_item_id, b.demand_line_no", NF_HDR_BBL_VW3.BUSINESS
_UNIT, NF_HDR_BBL_VW3.NF_BRL_ID);
While &SQL_DEMAND.Fetch(&business_unit, &demand_source, &source_bus_unit, &or
der_no, &order_int_line_no, &ched_line_no, &inv_item_id, &demand_line_no)
SQLExec("UPDATE sysadm.ps_ship_inf_inv SET PSSH_COMPLETE = 'N' where busin
ess_unit = :1 AND DEMAND_SOURCE = :2 AND SOURCE_BUS_UNIT = :3 AND ORDER_NO = :
4 and order_int_line_no =:5 and sched_line_no = :6 and inv_item_id = :7 and dem
and_line_no = :8 and PSSH_RUN_STATUS = '1' and PSSH_COMPLETE = 'Y'", &business_u
nit, &demand_source, &source_bus_unit, &order_no, &order_int_line_no, &ched_line
_no, &inv_item_id, &demand_line_no);
End-While;
&SQL_DEMAND.Close();
End-If;
&MES_ATUAL = Month(%Date);
If All(&v_mmc_te_sol_id) Then
/* chc.sn */
SQLExec("SELECT 'E' FROM SYSADM.PS_RMNEIO_LINE_BBL RL WHERE RL.BUSINESS
_UNIT_BI = :1 AND RL.NF_BRL_ID = :2 AND 'X' NOT IN ( SELECT 'X' FROM SYSADM.PS_
MMC_TE_SOL_LN SL WHERE SL.ORDER_NO = RL.ORDER_NO AND SL.INV_ITEM_ID = RL.INV_ITE
M_ID AND SL.QTY = RL.RMNEIO_LIN_QTY_BBL AND SL.ORDER_INT_LINE_NO = RL.ORDER_INT_
LINE_NO ) UNION SELECT 'E' FROM SYSADM.PS_MMC_TE_SOL_LN SL WHERE SL.SETID = :3
AND SL.MMC_TE_SOL_ID = :4 AND 'X' NOT IN ( SELECT 'X' FROM SYSADM.PS_RMNEIO_LIN
E_BBL RL WHERE RL.BUSINESS_UNIT_BI = :5 AND RL.NF_BRL_ID = :6 AND SL.ORDER_NO =
RL.ORDER_NO AND SL.INV_ITEM_ID = RL.INV_ITEM_ID AND SL.QTY = RL.RMNEIO_LIN_QTY_B
BL AND SL.ORDER_INT_LINE_NO = RL.ORDER_INT_LINE_NO )", NF_HDR_BBL_VW3.BUSINESS_U
NIT, NF_HDR_BBL_VW3.NF_BRL_ID, &v_setid, &v_mmc_te_sol_id, NF_HDR_BBL_VW3.BUSINE
SS_UNIT, NF_HDR_BBL_VW3.NF_BRL_ID, &existe_erro_sol_nf);
If None(&existe_erro_sol_nf) Then
/* chc.en */
If &MES_BAIXA <> &MES_ATUAL Then
/*
WinMessage("Error: O MSR de nmero: " | &v_order_no |
" pertence ao ms " | &MES_BAIXA);*/
End-If;
/*------------------------------------------------------------ Verifica Operao fiscal da NF controla terceiro.
-------------------------------------------------------------*/
SQLExec("select tof_pbl from sysadm.ps_nf_ln_brl where business_unit
=:1 and nf_brl_id=:2 and nf_brl_line_num=1 ", NF_HDR_BBL_VW3.BUSINESS_UNIT, &TE_
NF_BRL_ID, &v_tof_pbl);
SQLExec("select a.mmc_cntrl_terc,a.mmc_stock_un from sysadm.ps_mmc_t
e_tof_type a where a.tof_pbl = :1 and a.effdt = (select max(a_ed.effdt) from sys
adm.ps_mmc_te_tof_type a_ed where a.tof_pbl = a_ed.tof_pbl and a_ed.effdt <= sys
date)", &v_tof_pbl, &v_mmc_cntrl_terc, &v_mmc_stock_un);
If &v_mmc_cntrl_terc = "Y" Then
/*------------------------------------------------------------ Verifica se a Solicitao Requisio Reduzida, se no feita a
reduo
-------------------------------------------------------------*/
SQLExec("select ship_id from ps_transaction_inv where business_un
it=:1 and dt_timestamp>=%datetimein(:2) -1 and inv_item_id=:3 and order_no=:4 an
d rownum = 1", &v_source_bus_unit, &v_order_date, &v_item_verifica, &v_order_no,
&v_ship_id);
If None(&v_ship_id) Then
SQLExec("select distinct ship_id from sysadm.ps_ship_inf_inv w
here business_unit=:1 and order_no=:2", &v_source_bus_unit, &v_order_no, &v_ship
id_baixa);
REDUCAO_ESTOQUE(&v_source_bus_unit, &v_shipid_baixa)
End-If;
/*|||||||||||||||||||||||||||||||||||||||||||||
|| VERIRICA SE SOLICITAO TERCEIROS TEM RETORNO.
|| SE A SOLICITAO TERCEIROS NO TIVER RETORNO NO
|| CRIA A CONTROLE ESTOQUE TERCEIROS.
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
If &V_MMC_DATA_LIMITE > 0 Then
&cmdSQL = CreateSQL("select sh.setid,sh.mmc_te_sol_id, sl.line
_nbr,sh.order_date,sh.source_bus_unit,sh.order_no, sl.order_int_line_no, sl.inv_
item_id,sh.business_unit_bi, sl.nf_brl_line_num from sysadm.ps_mmc_te_sol_hdr s
h, sysadm.ps_mmc_te_sol_ln sl where sh.setid = sl.setid and sh.mmc_te_sol_id = s
l.mmc_te_sol_id and sh.setid=:1 and sh.mmc_te_sol_id =:2 and mmc_te_sol_status='
4'", &v_setid, &v_mmc_te_sol_id);
&REC_MMC_TE_TRANSAC = CreateRecord(Record.MMC_TE_TRANSAC);
While &cmdSQL.fetch(&VAR_SETID, &VAR_MMC_TE_SOL_ID, &VAR_LINE_
NBR, &VAR_ORDER_DATE, &VAR_SOURCE_BUS_UNIT, &VAR_ORDER_NO, &VAR_ORDER_INT_LINE_N
O, &VAR_INV_ITEM_ID, &VAR_BUSINESS_UNIT_BI, &VAR_NF_BRL_LINE_NUM)
SQLExec("select business_unit, inv_item_id, %datetimeout(dt
_timestamp), seq_nbr, %datetimeout(dt_timestamp+1/86400),unit_measure_std,qty,de
ptid, distrib_type,transaction_group from sysadm.ps_transaction_inv where busine
ss_unit=:1 and dt_timestamp >= %datetimein(:2) -1 and inv_item_id=:3 and order_n
o=:4 and order_int_line_no=:5", &VAR_SOURCE_BUS_UNIT, &VAR_ORDER_DATE, &VAR_INV_
/*|||||||||||||||||||||||||||||||||||||||||||||
|| Criando entrada na Unidade Estoque Terceiros.
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
&P_BUSINESS_UNIT = &v_mmc_stock_un;
&P_STAGED_DATE = Date3(1900, 1, 1);
&P_INV_LOT_ID = "NONE";
/*&P_INV_ITEM_ID = &TRAN_INV_ITEM_ID; mmcb.hd239977.lo*/
&P_INV_ITEM_ID = &VAR_INV_ITEM_ID; /*mmcb.hd239977.ln*/
&P_SERIAL_ID = "NONE";
SQLExec("select 'Y' from sysadm.ps_bu_items_inv where busin
ess_unit=:1 and inv_item_id =:2 ", &v_mmc_stock_un, &P_INV_ITEM_ID, &EXISTE_BU_I
TEM_INV);
If &EXISTE_BU_ITEM_INV <> "Y" Then
Error ("No existe parametrizao Unidade Negocio: " | &v_mmc_
stock_un | " para Item: " | &P_INV_ITEM_ID);
End-If;
/*SQLExec(" select storage_area,stor_level_1, stor_level_2,
stor_level_3, stor_level_4 from sysadm.ps_default_loc_inv where business_unit=:
1 and inv_item_id=:2 ", &v_mmc_stock_un, &TRAN_INV_ITEM_ID, &TRAN_STORAGE_AREA,
&TRAN_STOR_LEVEL_1, &TRAN_STOR_LEVEL_2, &TRAN_STOR_LEVEL_3, &TRAN_STOR_LEVEL_4);
mmcb.hd239977.lo */
SQLExec(" select storage_area,stor_level_1, stor_level_2, s
tor_level_3, stor_level_4 from sysadm.ps_default_loc_inv where business_unit=:1
and inv_item_id=:2 ", &v_mmc_stock_un, &P_INV_ITEM_ID, &TRAN_STORAGE_AREA, &TRAN
_STOR_LEVEL_1, &TRAN_STOR_LEVEL_2, &TRAN_STOR_LEVEL_3, &TRAN_STOR_LEVEL_4); /*mm
cb.hd239977.ln*/
If None(&TRAN_STORAGE_AREA) Or
None(&TRAN_STOR_LEVEL_1) Or
None(&TRAN_STOR_LEVEL_2) Or
None(&TRAN_STOR_LEVEL_3) Or
None(&TRAN_STOR_LEVEL_4) Then
/*Error ("No existe local de expedio padro na Unidade Tercei
ro: " | &v_mmc_stock_un | " para o Item: " | &TRAN_INV_ITEM_ID | " "); mmcb.hd
239977.lo*/
Error ("No existe local de expedio padro na Unidade Terceiro
: " | &v_mmc_stock_un | " para o Item: " | &P_INV_ITEM_ID | " "); /*mmcb.hd23997
7.ln*/
End-If;
&P_STORAGE_AREA = &TRAN_STORAGE_AREA;
&P_STOR_LEVEL_1 = &TRAN_STOR_LEVEL_1;
&P_STOR_LEVEL_2 = &TRAN_STOR_LEVEL_2;
&P_STOR_LEVEL_3 = &TRAN_STOR_LEVEL_3;
&P_STOR_LEVEL_4 = &TRAN_STOR_LEVEL_4;
&P_CONTAINER_ID = " ";
&P_UNIT_OF_MEASURE = &TRAN_UNIT_MEASURE_STD;
&P_QTY = &TRAN_QTY;
&P_DEPTO = &TRAN_DEPTID;
/**********************************************************
********
&P_DISTRIB_TYPE = &TRAN_DISTRIB_TYPE;
******************************************************************/
&P_DISTRIB_TYPE = "TERCEIROS";
&P_DT_TIMESTAMP = &TRAN_DT_TIMESTAMP_IN;
&P_BUSINESS_UNIT_RECV = &v_mmc_stock_un;
&P_RECEIVER_ID = String(&VAR_MMC_TE_SOL_ID);
&P_RECV_LN_NBR = &VAR_LINE_NBR;
&P_RECV_SHIP_SEQ_NBR = 0;
&P_SOURCE_BUS_UNIT = &VAR_SOURCE_BUS_UNIT;
&P_ORDER_NO = &VAR_ORDER_NO;
&P_ORDER_INT_LINE_NO = &VAR_ORDER_INT_LINE_NO;
&P_PARAMETRO_OPCIONAL = "USA_CUSTO_UNIDADE_ORIGEM";
/*******---------------------------***********
Pegando custo Unidade Baixa para ser uzado unidade Entrada.
*******---------------------------***********/
/*&CUSTO_UN_ESTOQUE = BUSCA_CUSTO_ITEM(&TRAN_BUSINESS_UNIT,
&TRAN_INV_ITEM_ID, &TRAN_DT_TIMESTAMP, &CONFIG_CODE_BAIXA); mmcb.hd239977.ln
*/
&CUSTO_UN_ESTOQUE = BUSCA_CUSTO_ITEM(&v_mmc_stock_un, &P_IN
V_ITEM_ID, &TRAN_DT_TIMESTAMP, &CONFIG_CODE_BAIXA); /*mmcb.hd239977.ln*/
/*******---------------------------***********
FIM Pegando custo Unidade Baixa para ser uzado unidade Entrada.
*******---------------------------***********/
/*
ENTRADA_ESTOQUE(&P_BUSINESS_UNIT, &P_ST
AGED_DATE, &P_INV_LOT_ID, &P_INV_ITEM_ID, &P_SERIAL_ID, &P_STORAGE_AREA, &P_STOR
_LEVEL_1, &P_STOR_LEVEL_2, &P_STOR_LEVEL_3, &P_STOR_LEVEL_4, &P_CONTAINER_ID, &P
_UNIT_OF_MEASURE, &P_QTY, &P_DEPTO, &P_DISTRIB_TYPE, &P_DT_TIMESTAMP, &P_BUSINES
S_UNIT_RECV, &P_RECEIVER_ID, &P_RECV_LN_NBR, &P_RECV_SHIP_SEQ_NBR, &P_SOURCE_BUS
_UNIT, &P_ORDER_NO, &P_ORDER_INT_LINE_NO, &P_CUSTO, &P_CONFIG_CODE); */
ENTRADA_ESTOQUE(&P_BUSINESS_UNIT, &P_STAGED_DATE, &P_INV_LO
T_ID, &P_INV_ITEM_ID, &P_SERIAL_ID, &P_STORAGE_AREA, &P_STOR_LEVEL_1, &P_STOR_LE
VEL_2, &P_STOR_LEVEL_3, &P_STOR_LEVEL_4, &P_CONTAINER_ID, &P_UNIT_OF_MEASURE, &P
_QTY, &P_DEPTO, &P_DISTRIB_TYPE, &P_DT_TIMESTAMP, &P_BUSINESS_UNIT_RECV, &P_RECE
IVER_ID, &P_RECV_LN_NBR, &P_RECV_SHIP_SEQ_NBR, &P_SOURCE_BUS_UNIT, &P_ORDER_NO,
&P_ORDER_INT_LINE_NO, &CUSTO_UN_ESTOQUE, &P_INV_LOT_ID, &P_PARAMETRO_OPCIONAL);
/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||||||||||||||
|| FIM Criando entrada na Unidade Estoque Terceiros.
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||*/
SQLExec("select business_unit, %datetimeout(dt_timestamp),
seq_nbr, transaction_group from sysadm.ps_transaction_inv where business_unit=:1
and dt_timestamp >= %datetimein(:2) -1 and inv_item_id=:3 and receiver_id=:4 an
End-If;
/* IF &V_MMC_DATA_LIMITE > 0 THEN */
/* Else
Error ("Existe uma divergencia Codigo Operao Fiscal"); */
End-If;
/* &v_mmc_cntrl_terc */
/* chc.sn */
End-If;
/* If None(&existe_erro_sol_nf) */
/* chc.en */
End-If;
/* If All(&v_mmc_te_sol_id) */
End-If;
/* If CONFIRMED_FLAG = "Y" */
/* End-For; */
End-If;
/* %Page = Page.NF_CNFM_BBL Then*/
'5' ";
&UPDATE = &UPDATE | "WHERE MMC_TE_SOL_STATUS = '4' ";
&UPDATE = &UPDATE | "AND ( SETID ";
&UPDATE = &UPDATE | "
, MMC_TE_SOL_ID) = ( ";
&UPDATE = &UPDATE | "
SELECT SHD.SETID ";
&UPDATE = &UPDATE | "
,
SHD.MMC_TE_SOL_ID ";
&UPDATE = &UPDATE | "
FROM SYSADM.PS_MMC_TE_SOL_HD
R SHD ";
&UPDATE = &UPDATE | "
,
SYSADM.PS_MMC_TE_SOL_LN
SLN ";
&UPDATE = &UPDATE | "
,
SYSADM.PS_RMNEIO_LINE_B
BL RLB ";
&UPDATE = &UPDATE | "
WHERE SHD.SETID
= :1 ";
&UPDATE = &UPDATE | "
AND SHD.MMC_TE_SOL_STATUS
= '4' ";
&UPDATE = &UPDATE | "
AND SLN.SETID
= SHD.SETID ";
&UPDATE = &UPDATE | "
AND SLN.MMC_TE_SOL_ID
= SHD.MMC_TE_SOL_ID ";
&UPDATE = &UPDATE | "
AND RLB.SOURCE_BUS_UNIT
= SHD.SOURCE_BUS_UNIT ";
&UPDATE = &UPDATE | "
AND RLB.ORDER_NO
= SLN.ORDER_NO ";
&UPDATE = &UPDATE | "
AND RLB.ORDER_INT_LINE_NO
= SLN.ORDER_INT_LINE_NO ";
&UPDATE = &UPDATE | "
AND RLB.BUSINESS_UNIT_BI
= :2 ";
&UPDATE = &UPDATE | "
AND RLB.NF_BRL_ID
= :3 ";
&UPDATE = &UPDATE | "
AND ROWNUM
= 1 ";
&UPDATE = &UPDATE | "
) ";
SQLExec(&UPDATE, &SETID, NF_HDR_BBL_VW3.BUSINESS_UNIT, NF_HDR_BBL_VW3.NF_BRL_
ID);
End-If;
/************************************* mmcb.sds5105.en *************************
************/
3.NF_BRL_ID, &ROWS);
For &LN = 1 To &ROWS
SQLExec("SELECT A.ASSET_ID, C.MMC_TIPO_TRANSF_AM, BH.SHIP_TO_CUST_ID, B
H.NF_BRL, BH.NF_BRL_SERIES, BH.LT_GRP_ID_BBL FROM PS_MMC_FAT_ITM_ATI A, PS_NF_HD
R_BBL_FS BH, PS_NF_LN_BBL_FS B, PS_MMC_ATIVO_OFISC C WHERE A.BUSINESS_UNIT = BH
.BUSINESS_UNIT AND A.NF_BRL_ID = BH.NF_BRL_ID AND A.NF_BRL_LINE_NUM = B.NF_BRL_L
INE_NUM AND B.BUSINESS_UNIT = BH.BUSINESS_UNIT AND B.NF_BRL_ID = BH.NF_BRL_ID A
ND B.TOF_PBL = C.TOF_PBL AND C.MMC_MOVIMENT_ATIVO = 'Y' AND C.EFFDT = (SELECT MA
X(D_ED.EFFDT) FROM PS_MMC_ATIVO_OFISC D_ED WHERE D_ED.TOF_PBL = C.TOF_PBL AND D
_ED.EFFDT <= SYSDATE) AND A.BUSINESS_UNIT = :1 AND A.NF_BRL_ID = :2 AND B.NF_BRL
_LINE_NUM = :3", NF_HDR_BBL_VW3.BUSINESS_UNIT, NF_HDR_BBL_VW3.NF_BRL_ID, &LN, &A
SSET_ID, &TIPO_MOV, &LOCATION, &NF_BRL, &SERIE_NF, &IDGRUPO);
REM SOLICITADO PELO BORGES EM 23.02.10 PARA MOVIMENTAO INTERNA NO GERAR NE
NHUM TRATAMENTO, J QUE SER FEITO NO RECEBIMENTO DA NOTA FISCAL;
If &TIPO_MOV <> "I" Then
/************************** mmcb.sds4689.so ************************
**/
/*
&BU = BU_SETID("COCT1");
*/
/************************** mmcb.sds4689.eo ************************
**/
/************************** mmcb.sds4689.sn ************************
**/
SQLExec("SELECT BUSINESS_UNIT_GL FROM SYSADM.PS_BUS_UNIT_TBL_BI WHER
E BUSINESS_UNIT = :1", NF_HDR_BBL_VW3.BUSINESS_UNIT, &BU);
/************************** mmcb.sds4689.en ************************
**/
&DATA = %Date;
&OPRID = %OperatorId;
&EXISTE_ATI = "N";
SQLExec("SELECT 'Y' FROM PS_ASSET_LOCATION WHERE BUSINESS_UNIT = :1
AND ASSET_ID = :2 AND DOCUMENT_ID = :3", &BU, &ASSET_ID, &NF_BRL, &EXISTE_ATI);
If &EXISTE_ATI <> "Y" Then
If All(&ASSET_ID) Then
REM MOVIMENTAO NAS TABELAS DO ATIVO;
SQLExec("SELECT MAX(EFFSEQ + 1) FROM PS_ASSET_LOCATION WHERE B
USINESS_UNIT = :1 AND ASSET_ID = :2", &BU, &ASSET_ID, &EFFSEQ);
SQLExec("INSERT INTO PS_ASSET_LOCATION (BUSINESS_UNIT, ASSET_I
D, EFFDT, EFFSEQ, LOCATION, DOCUMENT_ID, AUTH_STATUS, AUTHORIZATION_NAME) VALUES
(:1,:2, %DATEIN(:3), :4,:5,:6,:7,:8)", &BU, &ASSET_ID, &DATA, &EFFSEQ, &LOCATION
, &NF_BRL, " ", " ");
End-If;
End-If;
&BU = BU_SETID("COCT1");
*/
/************************** mmcb.sds4689.eo ************************
**/
/************************** mmcb.sds4689.sn ************************
**/
SQLExec("SELECT BUSINESS_UNIT_GL FROM SYSADM.PS_BUS_UNIT_TBL_BI WHER
E BUSINESS_UNIT = :1", NF_HDR_BBL_VW3.BUSINESS_UNIT, &BU);
/************************** mmcb.sds4689.en ************************
**/
&DATA = %Date;
&OPRID = %OperatorId;
&EXISTE_ATI = "N";
SQLExec("SELECT 'Y' FROM PS_ASSET_LOCATION WHERE BUSINESS_UNIT = :1
AND ASSET_ID = :2 AND DOCUMENT_ID = :3", &BU, &ASSET_ID, &NF_BRL, &EXISTE_ATI);
If &EXISTE_ATI <> "Y" Then
If All(&ASSET_ID) Then
SQLExec("SELECT LOCATION FROM PS_ASSET_LOC_VW WHERE BUSINESS_U
NIT = :1 AND ASSET_ID = :2", &BU, &ASSET_ID, &LOCATION_ATUAL);
SQLExec("SELECT MAX(EFFSEQ + 1) FROM PS_ASSET_LOCATION WHERE B
USINESS_UNIT = :1 AND ASSET_ID = :2", &BU, &ASSET_ID, &EFFSEQ);
SQLExec("INSERT INTO PS_ASSET_LOCATION (BUSINESS_UNIT, ASSET_I
D, EFFDT, EFFSEQ, LOCATION, DOCUMENT_ID, AUTH_STATUS, AUTHORIZATION_NAME) VALUES
(:1,:2, %DATEIN(:3), :4,:5,:6,:7,:8)", &BU, &ASSET_ID, &DATA, &EFFSEQ, &LOCATION
_ATUAL, &NF_BRL, " ", " ");
SQLExec("INSERT INTO PS_MMC_ASSET_LOC (BUSINESS_UNIT, ASSET_ID
, EFFDT, EFFSEQ, BUSINESS_UNIT_BI, NF_BRL_ID, NF_BRL_LINE_NUM) VALUES(:1,:2, %DA
TEIN(:3), :4,:5,:6,:7)", &BU, &ASSET_ID, &DATA, &EFFSEQ, NF_HDR_BBL_VW3.BUSINESS
_UNIT, NF_HDR_BBL_VW3.NF_BRL_ID, &LN);
SQLExec("UPDATE PS_BOOK SET LAST_TRANS_DT = %datein(:3), LAST_
ACCOUNTING_DT = %datein(:3) WHERE BUSINESS_UNIT = :1 AND ASSET_ID = :2", &BU, &A
SSET_ID, &DATA);
&SQL = CreateSQL("SELECT CHILD_ASSET_ID FROM SYSADM.PS_PRNT_CH
_VW_ABL WHERE BUSINESS_UNIT = :1 AND ASSET_ID = :2", &BU, &ASSET_ID);
While &SQL.Fetch(&V_CHILD_ASSET_ID)
SQLExec("SELECT MAX(EFFSEQ + 1) FROM PS_ASSET_LOCATION WHER
E BUSINESS_UNIT = :1 AND ASSET_ID = :2", &BU, &V_CHILD_ASSET_ID, &EFFSEQ);
SQLExec("INSERT INTO PS_ASSET_LOCATION (BUSINESS_UNIT, ASSE
T_ID, EFFDT, EFFSEQ, LOCATION, DOCUMENT_ID, AUTH_STATUS, AUTHORIZATION_NAME) VAL
&SQL = "
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
D | "'";
&SQL = &SQL
_UNIT | "'";
| "
| "
| "
SELECT ";
A.LT_GRP_ID_BBL ";
FROM SYSADM.PS_NF_HDR_BRL A ";
WHERE A.NF_BRL_ID
= '" | NF_HDR_BBL_VW3.NF_BRL_I
| "
AND A.BUSINESS_UNIT
= '" | NF_HDR_BBL_VW3.BUSINESS
SQLExec(&SQL, &VAR_LT_GRP_ID_BBL);
SQLExec("select 'Y' from sysadm.ps_mmc_in_rallypar where LT_GRP_ID_BBL =:1 an
d rownum = 1", &VAR_LT_GRP_ID_BBL, &RNF_RALLY);
If &RNF_RALLY = "Y" Then
If None(MMC_RALLY_WRK.SETID) Or
None(MMC_RALLY_WRK.MMC_RALLY_ID) Or
MMC_RALLY_WRK.MMC_RALLY_ID = 0 Then
Error ("Erro Remessa Rally: Grupo Operacao da NF: " | NF_HDR_BBL_VW3.NF
_BRL_ID | " de Remessa Rally, selecione o Rally Relativo a NF.");
Else
&VAR_RALLY_SETID = MMC_RALLY_WRK.SETID;
&VAR_RALLY_ID = MMC_RALLY_WRK.MMC_RALLY_ID;
End-If;
End-If;
If All(&VAR_RALLY_ID) And
&VAR_RALLY_ID > 0 Then
SQLExec("select count(*) from sysadm.ps_mmc_rally where eff_status ='A'",
&NUMERO_RALLY_ATIVO);
If &NUMERO_RALLY_ATIVO <> 1 Then
Error ("Erro Remessa Rally: Existe mais de uma Rally Ativo, acerte o ca
dastro e tente novamente.");
End-If;
CHECA_REMESSA_OPERACAO_PARAM(&VAR_RALLY_SETID, &VAR_RALLY_ID, NF_HDR_BBL_V
W3.BUSINESS_UNIT, NF_HDR_BBL_VW3.NF_BRL_ID, &VAR_LT_GRP_ID_BBL);
/*|||||||||||||||||||||||||||||||||||||||||||||
|| INICIO: Reduo Estoque
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
&SQL3 = "
&SQL3 = &SQL3
&SQL3 = &SQL3
&SQL3 = &SQL3
&SQL3 = &SQL3
&SQL3 = &SQL3
&SQL3 = &SQL3
&SQL3 = &SQL3
INESS_UNIT | "' ";
SELECT
|
|
|
|
|
|
|
"
"
"
"
"
"
"
&SQL3 = &SQL3
L_ID | "' ";
&SQL3 = &SQL3
&SQL3 = &SQL3
&SQL3 = &SQL3
;
&SQL3 = &SQL3
&SQL3 = &SQL3
";
&SQL3 = &SQL3
&SQL3 = &SQL3
&SQL3 = &SQL3
";
&SQL3 = &SQL3
&SQL3 = &SQL3
NO ";
&SQL3 = &SQL3
&SQL3 = &SQL3
&SQL3 = &SQL3
";
&SQL3 = &SQL3
SS_UNIT
";
&SQL3 = &SQL3
_SOURCE
";
&SQL3 = &SQL3
_BUS_UNIT
";
&SQL3 = &SQL3
NO
";
&SQL3 = &SQL3
INT_LINE_NO ";
&SQL3 = &SQL3
LINE_NO
";
&SQL3 = &SQL3
EM_ID
";
&SQL3 = &SQL3
_LINE_NO
";
| "
| "
| "
| "
| "
| "
| "
| "
| "
| "
| "
| "
| "
| "
| "
AND SHIP.BUSINESS_UNIT
D.BUSINE
| "
AND SHIP.DEMAND_SOURCE
D.DEMAND
| "
AND SHIP.SOURCE_BUS_UNIT
D.SOURCE
| "
AND SHIP.ORDER_NO
D.ORDER_
| "
AND SHIP.ORDER_INT_LINE_NO
D.ORDER_
| "
AND SHIP.SCHED_LINE_NO
D.SCHED_
| "
AND SHIP.INV_ITEM_ID
D.INV_IT
| "
AND SHIP.DEMAND_LINE_NO
D.DEMAND
&cmdSQL3 = CreateSQL(&SQL3);
While &cmdSQL3.fetch(&BAIXA_BUSINESS_UNIT, &BAIXA_SHIP_ID)
&SQL_UPDATE
&SQL_UPDATE
&SQL_UPDATE
&SQL_UPDATE
&SQL_UPDATE
SS_UNIT | "' ";
&SQL_UPDATE
";
&SQL_UPDATE
&SQL_UPDATE
&SQL_UPDATE
&SQL_UPDATE
&SQL_UPDATE
&SQL_UPDATE
&SQL_UPDATE
&SQL_UPDATE
&SQL_UPDATE
&SQL_UPDATE
=
=
=
=
=
"
&SQL_UPDATE
&SQL_UPDATE
&SQL_UPDATE
&SQL_UPDATE
|
|
|
|
= &SQL_UPDATE | "
=
=
=
=
=
=
=
=
=
=
&SQL_UPDATE
&SQL_UPDATE
&SQL_UPDATE
&SQL_UPDATE
&SQL_UPDATE
&SQL_UPDATE
&SQL_UPDATE
&SQL_UPDATE
&SQL_UPDATE
&SQL_UPDATE
|
|
|
|
|
|
|
|
|
|
AND
";
&SQL_UPDATE = &SQL_UPDATE | "
&SQL_UPDATE = &SQL_UPDATE | "
&SQL_UPDATE = &SQL_UPDATE | "
&SQL_UPDATE = &SQL_UPDATE | "
V TRAN ";
&SQL_UPDATE = &SQL_UPDATE | "
&SQL_UPDATE = &SQL_UPDATE | "
";
&SQL_UPDATE = &SQL_UPDATE | "
&SQL_UPDATE = &SQL_UPDATE | "
&SQL_UPDATE = &SQL_UPDATE | "
O, ";
&SQL_UPDATE = &SQL_UPDATE | "
";
&SQL_UPDATE = &SQL_UPDATE | "
;
&SQL_UPDATE = &SQL_UPDATE | "
&SQL_UPDATE = &SQL_UPDATE | "
&SQL_UPDATE = &SQL_UPDATE | "
&SQL_UPDATE = &SQL_UPDATE | "
S_UNIT, ";
&SQL_UPDATE = &SQL_UPDATE | "
M_ID, ";
&SQL_UPDATE = &SQL_UPDATE | "
O, ";
&SQL_UPDATE = &SQL_UPDATE | "
NT_LINE_NO, ";
&SQL_UPDATE = &SQL_UPDATE | "
INE_NO, ";
&SQL_UPDATE = &SQL_UPDATE | "
LINE_NO ";
&SQL_UPDATE = &SQL_UPDATE | "
IP_INF_INV SHIP ";
&SQL_UPDATE = &SQL_UPDATE | "
S_UNIT= '" | &BAIXA_BUSINESS_UNIT | "' ";
&SQL_UPDATE = &SQL_UPDATE | "
= '" | &BAIXA_SHIP_ID | "' ";
&SQL_UPDATE = &SQL_UPDATE | "
S_UNIT
= TRAN.BUSINESS_UNIT ";
&SQL_UPDATE = &SQL_UPDATE | "
M_ID
= TRAN.INV_ITEM_ID ";
&SQL_UPDATE = &SQL_UPDATE | "
O
= TRAN.ORDER_NO ";
&SQL_UPDATE = &SQL_UPDATE | "
NT_LINE_NO = TRAN.ORDER_INT_LINE_NO ";
&SQL_UPDATE = &SQL_UPDATE | "
INE_NO
= TRAN.SCHED_LINE_NO ";
&SQL_UPDATE = &SQL_UPDATE | "
LINE_NO
= TRAN.DEMAND_LINE_NO ";
&SQL_UPDATE = &SQL_UPDATE | "
&SQL_UPDATE = &SQL_UPDATE | "
TRAN.SCHED_LINE_NO, ";
TRAN.INV_ITEM_ID, ";
TRAN.DEMAND_LINE_NO ";
FROM SYSADM.PS_TRANSACTION_IN
WHERE ( ";
TRAN.BUSINESS_UNIT,
TRAN.INV_ITEM_ID, ";
TRAN.ORDER_NO, ";
TRAN.ORDER_INT_LINE_N
TRAN.SCHED_LINE_NO,
TRAN.DEMAND_LINE_NO "
) ";
IN ";
( ";
SELECT SHIP.BUSINES
SHIP.INV_ITE
SHIP.ORDER_N
SHIP.ORDER_I
SHIP.SCHED_L
SHIP.DEMAND_
FROM SYSADM.PS_SH
WHERE SHIP.BUSINES
AND SHIP.SHIP_ID
AND SHIP.BUSINES
AND SHIP.INV_ITE
AND SHIP.ORDER_N
AND SHIP.ORDER_I
AND SHIP.SCHED_L
AND SHIP.DEMAND_
) ";
)
";
SQLExec(&SQL_UPDATE);
SQLExec("SELECT DISTINCT SHIP_ID FROM SYSADM.PS_SHIP_INF_INV WHERE BUSI
NESS_UNIT=:1 AND SHIP_ID=:2 AND SHIPPED_FLAG='Y' AND CANCEL_FLAG = 'N' AND PSSH_
&SQL1 =
&SQL1 =
&SQL1 =
&SQL1 =
&SQL1 =
&SQL1 =
&SQL1 =
&SQL1 =
&SQL1 =
&SQL1 =
&SQL1 =
&SQL1 =
&SQL1 =
&SQL1 =
&SQL1 =
&SQL1 =
&SQL1 =
&SQL1 =
&SQL1 =
SS_UNIT | "'
&SQL1 =
| "' ";
&SQL1 =
&SQL1 =
&SQL1 =
&SQL1 =
&SQL1 =
&SQL1 =
&SQL1 =
&SQL1 =
";
&SQL1 =
&SQL1 =
O ";
&SQL1 =
&SQL1 =
&SQL1 =
"
&SQL1
&SQL1
&SQL1
&SQL1
&SQL1
&SQL1
&SQL1
&SQL1
&SQL1
&SQL1
&SQL1
&SQL1
&SQL1
&SQL1
&SQL1
&SQL1
&SQL1
&SQL1
";
&SQL1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
SELECT B.BUSINESS_UNIT,
";
B.NF_BRL_ID,
";
C.BUSINESS_UNIT,
";
B.NF_BRL_LINE_NUM,
";
B.INV_ITEM_ID,
";
B.UNIT_OF_MEASURE,
";
B.QTY_NF_BRL,
";
SHIP.DISTRIB_TYPE,
";
SHIP.BUSINESS_UNIT,
";
SHIP.ORDER_NO,
";
SHIP.ORDER_INT_LINE_NO,
";
SHIP.SCHED_LINE_NO,
";
SHIP.DEMAND_LINE_NO,
";
B.TOF_PBL
";
FROM SYSADM.PS_NF_HDR_BRL A,
";
SYSADM.PS_NF_LN_BRL B,
";
SYSADM.PS_RMNEIO_LINE_BBL C, ";
SYSADM.PS_SHIP_INF_INV SHIP ";
WHERE B.BUSINESS_UNIT = '" | NF_HDR_BBL_VW3.BUSINE
| "
&SQL1
&SQL1
&SQL1
&SQL1
&SQL1
&SQL1
&SQL1
&SQL1
|
|
|
|
|
|
|
|
AND
AND
AND
AND
AND
AND
AND
AND
"
"
"
"
"
"
"
"
&SQL1 | "
&SQL1 | "
&SQL1 | "
&SQL1 | "
&SQL1 | "
&cmdSQL = CreateSQL(&SQL1);
While &cmdSQL.fetch(&VR_BUSINESS_UNIT, &VR_NF_BRL_ID, &VR_BUSINESS_UNIT_IN
, &VR_NF_BRL_LINE_NUM, &VR_INV_ITEM_ID, &VR_UNIT_OF_MEASURE, &VR_QTY_NF_BRL, &VR
_DISTRIB_TYPE, &VR_BUSINESS_UNIT_BAIXA, &VR_ORDER_NO, &VR_ORDER_INT_LINE_NO, &VR
_SCHED_LINE_NO, &VR_DEMAND_LINE_NO, &VR_TOF_PBL)
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
=
=
=
=
=
=
=
=
=
=
=
=
"";
" select ";
&SQL | "
business_unit, ";
&SQL | "
storage_area, ";
&SQL | "
stor_level_1, ";
&SQL | "
stor_level_2, ";
&SQL | "
stor_level_3, ";
&SQL | "
stor_level_4,
";
&SQL | "
DISTRIB_TYPE
";
&SQL | "
from sysadm.ps_mmc_rally r , ";
&SQL | "
sysadm.ps_mmc_in_rallypar inpar ";
&SQL | " where r.setid
= '" | &VAR_RALLY_SETI
&SQL
&SQL
&SQL
&SQL
BBL | "'";
&SQL
;
=
=
=
=
&SQL
&SQL
&SQL
&SQL
D | "'";
|
|
|
|
"
"
"
"
= &SQL | "
and
and
and
and
r.mmc_rally_id
inpar.setid
inpar.mmc_rally_id
inpar.lt_grp_id_bbl
and inpar.tof_pbl
=
=
=
=
" | &VAR_RALLY_ID;
r.setid ";
r.mmc_rally_id ";
'" | &VAR_LT_GRP_ID_
| ".");
End-If;
&P_BUSINESS_UNIT = &VIN_BUSINESS_UNIT;
&P_STAGED_DATE = Date3(1900, 1, 1);
&P_INV_ITEM_ID = &VR_INV_ITEM_ID;
SQLExec("select 'Y' from sysadm.ps_bu_items_inv where business_unit=:1
and inv_item_id =:2 ", &VIN_BUSINESS_UNIT, &VR_INV_ITEM_ID, &EXISTE_BU_ITEM_INV)
;
If &EXISTE_BU_ITEM_INV <> "Y" Then
Error ("Erro Remessa Rally: No existe parametrizao Unidade Negocio: " |
&VIN_BUSINESS_UNIT | " para Item: " | &VR_INV_ITEM_ID);
End-If;
&P_STORAGE_AREA
&P_STOR_LEVEL_1
&P_STOR_LEVEL_2
&P_STOR_LEVEL_3
&P_STOR_LEVEL_4
=
=
=
=
=
&VIN_STORAGE_AREA;
&VIN_STOR_LEVEL_1;
&VIN_STOR_LEVEL_2;
&VIN_STOR_LEVEL_3;
&VIN_STOR_LEVEL_4;
USINESS_UNIT);
End-If;
&TT_BUSINESS_UNIT_BI = &VR_BUSINESS_UNIT;
&TT_NF_BRL_ID = &VR_NF_BRL_ID;
&TT_NF_BRL_LINE_NUM = &VR_NF_BRL_LINE_NUM;
&TT_MMC_TE_OPERACAO = "101";
&TT_SETID = " ";
&TT_MMC_TE_SOL_ID = 0;
&TT_LINE_NBR = 0;
&TT_BUSINESS_UNIT = &VR_BUSINESS_UNIT_BAIXA;
&TT_INV_ITEM_ID = &VR_INV_ITEM_ID;
&TT_DT_TIMESTAMP = &TRAN_DT_TIMESTAMP;
&TT_SEQ_NBR = &TRAN_SEQ_NBR;
&TT_TRANSACTION_GROUP = "030";
&TT_BUSINESS_UNIT_TO = &P_BUSINESS_UNIT;
&TT_DT_TIMESTAMP_TO = &TRAN_020_DT_TIMESTAMP;
&TT_SEQ_NBR_TO = &TRAN_020_SEQ_NBR;
&TT_MMC_TRAN_GROUP = "020";
&TT_MMC_UN_ORIGEM = " ";
&TT_MMC_NF_ID_ORIGEM = " ";
&TT_MMC_NF_LINE_ORIGEM = 0;
GRAVA_MMC_TE_TRANSAC(&TT_BUSINESS_UNIT_BI, &TT_NF_BRL_ID, &TT_NF_BRL_LI
NE_NUM, &TT_MMC_TE_OPERACAO, &TT_SETID, &TT_MMC_TE_SOL_ID, &TT_LINE_NBR, &TT_BUS
INESS_UNIT, &TT_INV_ITEM_ID, &TT_DT_TIMESTAMP, &TT_SEQ_NBR, &TT_TRANSACTION_GROU
P, &TT_BUSINESS_UNIT_TO, &TT_DT_TIMESTAMP_TO, &TT_SEQ_NBR_TO, &TT_MMC_TRAN_GROUP
, &TT_MMC_UN_ORIGEM, &TT_MMC_NF_ID_ORIGEM, &TT_MMC_NF_LINE_ORIGEM);
/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||
|| FIM Criando Transao tabela MMC_TE_TRANSAC.
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||*/
/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||
|| INICIO Gravando Tabelas Linhs NF Rally.
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||*/
&P_SETID = &VAR_RALLY_SETID;
&P_MMC_RALLY_ID = &VAR_RALLY_ID;
&P_BUSINESS_UNIT = &VR_BUSINESS_UNIT;
&P_NF_BRL_ID = &VR_NF_BRL_ID;
&P_NF_BRL_LINE_NUM = &VR_NF_BRL_LINE_NUM;
&P_SEQ_NBR = 1;
&P_MMC_UN_ORIGEM = " ";
&P_MMC_NF_ID_ORIGEM = " ";
&P_MMC_NF_LINE_ORIGEM = 0;
GRAVA_SALDO_LN_RALLY(&P_SETID, &P_MMC_RALLY_ID, &P_BUSINESS_UNIT, &P_NF
_BRL_ID, &P_NF_BRL_LINE_NUM, &P_SEQ_NBR, &P_MMC_UN_ORIGEM, &P_MMC_NF_ID_ORIGEM,
&P_MMC_NF_LINE_ORIGEM);
/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||
&P_SETID = &VAR_RALLY_SETID;
&P_MMC_RALLY_ID = &VAR_RALLY_ID;
&P_BUSINESS_UNIT = NF_HDR_BBL_VW3.BUSINESS_UNIT;
&P_NF_BRL_ID = NF_HDR_BBL_VW3.NF_BRL_ID;
&P_NF_BRL_STATUS = "F";
GRAVA_SALDO_H_RALLY(&P_SETID, &P_MMC_RALLY_ID, &P_BUSINESS_UNIT, &P_NF_BRL
_ID, &P_NF_BRL_STATUS);
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||||||||||||||||||||||||
|| FIM Gravando Tabelas Cabealho NF Rally.
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||*/
/************************* mmcb.sds2720.sn ******************************
**************/
GRAVA_DISTRIB_TYPE_REMESSA(&VAR_RALLY_SETID, &VAR_RALLY_ID, NF_HDR_BBL_VW3
.BUSINESS_UNIT, NF_HDR_BBL_VW3.NF_BRL_ID);
/************************* mmcb.sds2720.en ******************************
**************/
/*##############################################################################
#######
#
F I M R E M E S S A R A L L Y
#
################################################################################
######*/
/************************************* mmcb.at2617.en *************************
************/
&VAR_GRUPO_OF = "";
&SQL = "";
&SQL = "
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
D | "'";
&SQL = &SQL
_UNIT | "'";
| "
| "
| "
| "
SELECT ";
A.LT_GRP_ID_BBL ";
FROM SYSADM.PS_NF_HDR_BRL A ";
WHERE A.NF_BRL_ID
= '" | NF_HDR_BBL_VW3.NF_BRL_I
AND A.BUSINESS_UNIT
= '" | NF_HDR_BBL_VW3.BUSINESS
SQLExec(&SQL, &VAR_GRUPO_OF);
&RNF_RALLY = "";
SQLExec("select 'Y' from sysadm.ps_mmc_rt_rallypar where LT_GRP_ID_BBL =:1 an
d rownum = 1", &VAR_LT_GRP_ID_BBL, &RNF_RALLY);
If &RNF_RALLY = "Y" Then
If None(MMC_RALLY_WRK.SETID) Or
None(MMC_RALLY_WRK.MMC_RALLY_ID) Or
MMC_RALLY_WRK.MMC_RALLY_ID = 0 Then
Error ("Erro Retorno Rally: Grupo Operacao da NF: " | NF_HDR_BBL_VW3.NF
_BRL_ID | " de Remessa Rally, selecione o Rally Relativo a NF.");
Else
&VAR_RT_RALLY_SETID = MMC_RALLY_WRK.SETID;
&VAR_RT_RALLY_ID = MMC_RALLY_WRK.MMC_RALLY_ID;
End-If;
End-If;
If All(&VAR_RT_RALLY_ID) And
&VAR_RT_RALLY_ID > 0 Then
SQLExec("select count(*) from sysadm.ps_mmc_rally where eff_status ='A'",
&NUMERO_RT_RALLY_ATIVO);
If &NUMERO_RT_RALLY_ATIVO <> 1 Then
Error ("Existe mais de uma Rally Ativo, acerte o cadastro e tente novam
ente.");
End-If;
CHECA_RETORNO_OPERACAO_PARAM(&VAR_RT_RALLY_SETID, &VAR_RT_RALLY_ID, NF_HDR
_BBL_VW3.BUSINESS_UNIT, NF_HDR_BBL_VW3.NF_BRL_ID, &VAR_GRUPO_OF);
&SQL = "";
&SQL = " select ";
&SQL = &SQL | "
b.business_unit, ";
&SQL = &SQL | "
b.nf_brl_id, ";
&SQL = &SQL | "
b.nf_brl_line_num, ";
&SQL = &SQL | "
b.inv_item_id, ";
&SQL = &SQL | "
b.qty_nf_brl, ";
&SQL = &SQL | "
b.unit_of_measure, ";
&SQL = &SQL | "
rtpar.business_unit, ";
&SQL = &SQL | "
rtpar.storage_area, ";
&SQL = &SQL | "
rtpar.stor_level_1, ";
&SQL = &SQL | "
rtpar.stor_level_2, ";
&SQL = &SQL | "
rtpar.stor_level_3, ";
&SQL = &SQL | "
rtpar.stor_level_4, ";
&SQL = &SQL | "
rtpar.distrib_type, ";
&SQL = &SQL | "
ROUND ( b.unit_amt_bse_bbl ";
&SQL = &SQL | "
+ (b.ipitax_brl_amt / b.qty_nf_brl) ";
&SQL = &SQL | "
- (b.pis_amt_bbl / b.qty_nf_brl) ";
&SQL = &SQL | "
- (b.cofins_amt_bbl / b.qty_nf_brl) ";
&SQL = &SQL | "
- (b.ipitax_brl_rcvry / b.qty_nf_brl) ";
&SQL = &SQL | "
- (b.icmstax_brl_rcvry / b.qty_nf_brl) ";
&SQL = &SQL | "
- (b.dscnt_amt / b.qty_nf_brl), ";
&SQL = &SQL | "
4 ";
&SQL = &SQL | "
) custo_entrada ";
&SQL = &SQL | " from sysadm.ps_nf_hdr_brl a, ";
&SQL = &SQL | "
sysadm.ps_nf_ln_brl b, ";
&SQL = &SQL | "
sysadm.ps_mmc_rt_rallypar rtpar ";
&SQL = &SQL | " where b.business_unit
= '" | NF_HDR_BBL_VW3.BU
SINESS_UNIT | "'";
&SQL = &SQL | " and b.nf_brl_id
= '" | NF_HDR_BBL_VW3.NF
_BRL_ID | "'";
&SQL = &SQL | " and a.business_unit
= b.business_unit ";
&SQL = &SQL | " and a.nf_brl_id
= b.nf_brl_id ";
&SQL = &SQL | "
and rtpar.setid
= '" | &VAR_RT_RALLY_S
ETID | "'";
&SQL = &SQL | "
and rtpar.mmc_rally_id
= " | &VAR_RT_RALLY_I
D;
and rtpar.lt_grp_id_bbl
and rtpar.tof_pbl
= a.lt_grp_id_bbl ";
= b.tof_pbl ";
&cmdSQL = CreateSQL(&SQL);
While &cmdSQL.Fetch(&VAR_NF_BU, &VAR_NF_ID, &VAR_NF_LN, &VAR_NF_ITEM, &VAR
_NF_QUANTIDADE, &VAR_UM_NF, &VAR_UN_ENTRADA, &VAR_AREA_ENTRADA, &VAR_L1_ENTRADA,
&VAR_L2_ENTRADA, &VAR_L3_ENTRADA, &VAR_L4_ENTRADA, &VAR_DISTRIB_ENTRADA, &VAR_C
USTO_ENTRADA)
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
Y_SETID | "'";
&SQL =
_ID;
&SQL =
"'";
&SQL =
"'";
&SQL =
&SQL =
";
&SQL =
";
&SQL =
";
&SQL =
";
&SQL =
it ";
&SQL =
";
&SQL =
rea
";
&SQL =
l_1
";
&SQL =
2
";
&SQL =
l_3
";
&SQL =
l_4
";
"";
"
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
select
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
";
rmpar.business_unit un_baixa, ";
rmpar.storage_area, ";
rmpar.stor_level_1, ";
rmpar.stor_level_2, ";
rmpar.stor_level_3, ";
rmpar.stor_level_4, ";
rmpar.distrib_type , ";
ph.qty-ph.qty_reserved qtd_disponivel, ";
ph.serial_id, ";
ph.inv_lot_id ";
from
";
sysadm.ps_mmc_rrm_s_vw srm , ";
sysadm.ps_mmc_in_rallypar rmpar, ";
sysadm.ps_physical_inv ph ";
where srm.setid
= '" | &VAR_RT_RALL
&SQL | "
and srm.mmc_rally_id
= " | &VAR_RT_RALLY
&SQL | "
and srm.mmc_un_origem
= '" | &VAR_NF_BU |
&SQL | "
and srm.mmc_nf_id_origem
= '" | &VAR_NF_ID |
&SQL | "
&SQL | "
and srm.mmc_nf_line_origem
and rmpar.setid
= " | &VAR_NF_LN;
= srm.setid
&SQL | "
and rmpar.mmc_rally_id
= srm.mmc_rally_id
&SQL | "
and rmpar.lt_grp_id_bbl
= srm.lt_grp_id_bbl
&SQL | "
and rmpar.tof_pbl
= srm.tof_pbl
&SQL | "
and ph.business_unit
= rmpar.business_un
&SQL | "
and ph.inv_item_id
= srm.inv_item_id
&SQL | "
and ph.storage_area
= rmpar.storage_a
&SQL | "
and ph.stor_level_1
= rmpar.stor_leve
&SQL | "
and ph.stor_level_2
= rmpar.stor_level_
&SQL | "
and ph.stor_level_3
= rmpar.stor_leve
&SQL | "
and ph.stor_level_4
= rmpar.stor_leve
=
=
=
=
=
=
=
=
=
=
"";
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
&SQL
|
|
|
|
|
|
|
|
|
=
=
=
=
=
&VAR_AREA_ENTRADA;
&VAR_L1_ENTRADA;
&VAR_L2_ENTRADA;
&VAR_L3_ENTRADA;
&VAR_L4_ENTRADA;
If None(&P_STORAGE_AREA) Or
None(&P_STOR_LEVEL_1) Or
None(&P_STOR_LEVEL_2) Or
None(&P_STOR_LEVEL_3) Or
None(&P_STOR_LEVEL_4) Then
Error ("Erro Retorno Rally: No foi encontra Endereo para entrda estoqu
e NF: " | &VAR_NF_BU | "-" | &VAR_NF_ID | "-" | &VAR_NF_LN | "-" | &VAR_NF_ITEM)
;
End-If;
&P_CONTAINER_ID = " ";
&P_UNIT_OF_MEASURE = &VAR_UM_NF;
&P_QTY = &VAR_NF_QUANTIDADE;
&P_DEPTO = " ";
&P_DISTRIB_TYPE = &VAR_DISTRIB_ENTRADA;
&P_DT_TIMESTAMP = %Datetime;
&P_BUSINESS_UNIT_RECV = &VAR_NF_BU;
&P_RECEIVER_ID = &VAR_NF_ID;
&P_RECV_LN_NBR = &VAR_NF_LN;
&P_RECV_SHIP_SEQ_NBR = 0;
&P_SOURCE_BUS_UNIT = &VAR_NF_BU;
&P_ORDER_NO = &VAR_NF_ID;
&P_ORDER_INT_LINE_NO = &VAR_NF_LN;
&P_CUSTO = &VAR_CUSTO_ENTRADA;
&P_PARAMETRO_OPCIONAL = "USA_CUSTO_UNIDADE_ORIGEM";
If &P_CUSTO <= 0 Then
Error (" Erro Retorno Rally: No foi possivel encontrar custo para NF:
" | &VAR_NF_BU | "-" | &VAR_NF_ID | "-" | &VAR_NF_LN | "-" | &VAR_NF_ITEM);
End-If;
&P_CONFIG_CODE = &V_INV_LOT_ID;
ENTRADA_ESTOQUE(&P_BUSINESS_UNIT, &P_STAGED_DATE, &P_INV_LOT_ID, &P_INV
_ITEM_ID, &P_SERIAL_ID, &P_STORAGE_AREA, &P_STOR_LEVEL_1, &P_STOR_LEVEL_2, &P_ST
OR_LEVEL_3, &P_STOR_LEVEL_4, &P_CONTAINER_ID, &P_UNIT_OF_MEASURE, &P_QTY, &P_DEP
TO, &P_DISTRIB_TYPE, &P_DT_TIMESTAMP, &P_BUSINESS_UNIT_RECV, &P_RECEIVER_ID, &P_
RECV_LN_NBR, &P_RECV_SHIP_SEQ_NBR, &P_SOURCE_BUS_UNIT, &P_ORDER_NO, &P_ORDER_INT
_LINE_NO, &P_CUSTO, &P_CONFIG_CODE, &P_PARAMETRO_OPCIONAL);
SQLExec("select %DateTimeOut(dt_timestamp), seq_nbr from sysadm.ps_tra
nsaction_inv where business_unit = :1 and inv_item_id= :2 and dt_timestamp >= SY
SDATE -1 and dt_timestamp <= SYSDATE +1 and receiver_id=:3 and recv_ln_nbr =:4 a
nd transaction_group='020' ", &P_BUSINESS_UNIT, &P_INV_ITEM_ID, &P_RECEIVER_ID,
&P_RECV_LN_NBR, &TRANSAC_020_DT_TIMESTAMP, &TRANSAC_020_SEQ_NBR);
If None(&TRANSAC_020_DT_TIMESTAMP) Or
None(&TRANSAC_020_SEQ_NBR) Then
Error ("Retorno Rally Erro: No Possivel encontar Transao 020 para:" | &
P_BUSINESS_UNIT | "-" | &P_INV_ITEM_ID | "-" | &P_RECEIVER_ID | "-" | &P_RECV_LN
_NBR);
End-If;
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|| FIM ROTINA ENTRADA ESTOQUE.
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||
|| INICIO Criando Transao tabela MMC_TE_TRANSAC.
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||*/
&TT_BUSINESS_UNIT_BI = &VAR_NF_BU;
&TT_NF_BRL_ID = &VAR_NF_ID;
&TT_NF_BRL_LINE_NUM = &VAR_NF_LN;
&TT_MMC_TE_OPERACAO = "101";
&TT_SETID = " ";
&TT_MMC_TE_SOL_ID = 0;
&TT_LINE_NBR = 0;
&TT_BUSINESS_UNIT = &V_UN_BAIXA;
&TT_INV_ITEM_ID = &B_INV_ITEM_ID;
&TT_DT_TIMESTAMP = &TRANSAC_030_DT_TIMESTAMP;
&TT_SEQ_NBR = &TRANSAC_030_SEQ_NBR;
&TT_TRANSACTION_GROUP = "030";
&TT_BUSINESS_UNIT_TO = &VAR_UN_ENTRADA;
&TT_DT_TIMESTAMP_TO = &TRANSAC_020_DT_TIMESTAMP;
&TT_SEQ_NBR_TO = &TRANSAC_020_SEQ_NBR;
&TT_MMC_TRAN_GROUP = "020";
&TT_MMC_UN_ORIGEM = " ";
&TT_MMC_NF_ID_ORIGEM = " ";
&TT_MMC_NF_LINE_ORIGEM = 0;
GRAVA_MMC_TE_TRANSAC(&TT_BUSINESS_UNIT_BI, &TT_NF_BRL_ID, &TT_NF_BRL_LI
NE_NUM, &TT_MMC_TE_OPERACAO, &TT_SETID, &TT_MMC_TE_SOL_ID, &TT_LINE_NBR, &TT_BUS
INESS_UNIT, &TT_INV_ITEM_ID, &TT_DT_TIMESTAMP, &TT_SEQ_NBR, &TT_TRANSACTION_GROU
P, &TT_BUSINESS_UNIT_TO, &TT_DT_TIMESTAMP_TO, &TT_SEQ_NBR_TO, &TT_MMC_TRAN_GROUP
, &TT_MMC_UN_ORIGEM, &TT_MMC_NF_ID_ORIGEM, &TT_MMC_NF_LINE_ORIGEM);
/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||
|| FIM Criando Transao tabela MMC_TE_TRANSAC.
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||*/
End-While;
&cmdSQL.Close();
End-If; /* If All(&VAR_RT_RALLY_ID) And &VAR_RT_RALLY_ID > 0 Then */
End-If; /* If CONFIRMED_FLAG = "Y" Then */
/*##############################################################################
#######
#
F I M R E T O R N O R A L L Y
#
################################################################################
######*/
/************************************* mmcb.sds2618.en *************************
************/
AS CGC_BR
, 'NF'
AS NF_BRL
L ";
_TYPE ";
L ";
&ins1 = &ins1
S NF_BRL_SERIES ";
&ins1 = &ins1
&ins1 = &ins1
BBL | "') AS NF_BRL_DATE ";
&ins1 = &ins1
&ins1 = &ins1
&ins1 = &ins1
&ins1 = &ins1
ED_BSE_BBL ";
&ins1 = &ins1
| "
| "
| "
, CFO_BRL_CD ";
, %DateIn('" | NF_HDR_BBL_VW3.NF_ISSUE_DT_
|
|
|
|
,
,
,
,
"
"
"
"
| "
GROSS_AMT_BSE ";
ICMSSUB_BRL_AMT ";
ICMSTAX_BRL_AMT ";
0
, 0
AS ICMSST_R
AS ICMS_RED
_BSE_BBL ";
&ins1
&ins1
&ins1
&ins1
&ins1
=
=
=
=
=
&ins1
&ins1
&ins1
&ins1
&ins1
|
|
|
|
|
"
"
"
"
"
,
,
,
,
,
IPITAX_BRL_AMT ";
PISTAX_BRL_AMT ";
COFINSTAX_BRL_AMT ";
ICMSTAX_BRL_BSS ";
0
AS IPITAX_B
&ins1
&ins1
&ins1
&ins1
&ins1
&ins1
&ins1
&ins1
&ins1
&ins1
&ins1
&ins1
&ins1
&ins1
=
=
=
=
=
=
=
=
=
=
=
=
=
=
&ins1
&ins1
&ins1
&ins1
&ins1
&ins1
&ins1
&ins1
&ins1
&ins1
&ins1
&ins1
&ins1
&ins1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"
"
"
"
"
"
"
"
"
"
"
"
"
"
,
,
,
,
,
,
,
,
,
,
,
,
,
,
PIS_BSS_AMT_BBL ";
COFINS_BSS_AMT_BBL ";
FREIGHT_AMT ";
INSURANCE_BRL_AMT ";
OTHEREXP_BRL_AMT ";
DSCNT_AMT ";
ISSTAX_BRL_AMT ";
IRTAX_BRL_AMT ";
INSS_BRL_RETENTION ";
COFINS_BRL_RETENT ";
PIS_BRL_RETENT ";
CSLL_BRL_RETENT ";
ICMSTAX_BRL_RETENT ";
'N'
AS PROCESS_
RL_BSS ";
FLAG ";
&ins1 = &ins1 | "
, 0
AS PROCESS_
, SYSDATE
AS DT_TIMES
INSTANCE ";
TAMP ";
&ins1 = &ins1 | " FROM SYSADM.PS_NF_HDR_BRL A ";
&ins1 = &ins1 | " WHERE A.BUSINESS_UNIT = :1 ";
&ins1 = &ins1 | "
AND A.NF_BRL_ID
= :2 ";
SQLExec(&ins1, NF_HDR_BBL_VW3.BUSINESS_UNIT, NF_HDR_BBL_VW3.NF_BR
L_ID);
&ins2 = "";
&ins2 = &ins2 | " INSERT INTO SYSADM.PS_" | &tableLN;
&ins2 = &ins2 | " SELECT '" | &business_unit_to | "'
AS BUSIN
AS CGC_B
, 'NF'
AS NF_BR
ESS_UNIT ";
RL ";
L_TYPE ";
L ";
&ins2 = &ins2 | "
, '" | NF_HDR_BBL_VW3.NF_BRL_SERIES | "' A
S NF_BRL_SERIES ";
&ins2 = &ins2 | "
, A.NF_BRL_LINE_NUM
";
&ins2 = &ins2 | "
, NVL( ( SELECT CASE WHEN LENGTH(MT.NF_BR
L) = 9 THEN SUBSTR(MT.NF_BRL , 4,6 ) ELSE LPAD(MT.NF_BRL,6,'0') END
NF_B
RL FROM SYSADM.PS_MMC_TE_CONTR_MT MT WHERE MT.TRANSACTION_GROUP = '030' AND MT.B
USINESS_UNIT_BI = A.BUSINESS_UNIT AND MT.MMC_NF_BRL_ID_OUT = A.NF_BRL_ID AND MT.
MMC_LINE_NUM_OUT = A.NF_BRL_LINE_NUM AND ROWNUM = 1 ), ' ' ) AS MMC_REMESSA_BRL
";
&ins2 = &ins2 | "
, NVL( ( SELECT MT.NF_BRL_SERIES
FRO
M SYSADM.PS_MMC_TE_CONTR_MT MT WHERE MT.TRANSACTION_GROUP = '030' AND MT.BUSINES
S_UNIT_BI = A.BUSINESS_UNIT AND MT.MMC_NF_BRL_ID_OUT = A.NF_BRL_ID AND MT.MMC_LI
NE_NUM_OUT = A.NF_BRL_LINE_NUM AND ROWNUM = 1 ), ' ' ) AS NF_BRL_SERIES_PO ";
&ins2 = &ins2 | "
, PO_ID ";
&ins2 = &ins2 | "
, INV_ITEM_ID ";
&ins2 = &ins2 | "
, QTY_NF_BRL ";
&ins2 = &ins2 | "
, DECODE(UNIT_PRICE, 0, MERCH_AMT_BSE/QTY_
And
<> "A" And
<> "D1" And
<> "0" And
<> "A1" Then
End-If;
/*** BRUNO VEROSA - MMC - mmc.sds4055 - 14/12/2011 - E.N. ***/
End-For;
[NF_CNFM_BBL_WRK.LOG_IN.FieldChange]
/***
BRLOC-BI-HAT-NEW-BEGIN-14/09/2001
Descrio: Painel de informaes de transacoes do invantario ligada as operacoes fisca
is
***/
Evaluate %PanelGroup
When PanelGroup.NF_CNFM_BBL
&RET = DoModal(Page.NF_INV_LOG_BBL, MsgGetText(31000, 108, "Additional Data")
, - 1, - 1, 0);
End-Evaluate;
/***
BRLOC-BI-HAT-NEW-BEGIN-14/09/2001
***/
[NF_CNFM_BBL_WRK.NF_DTL_PB_BBL.FieldChange]
/* BRLBI_01 19/01/1999 Florival Athaide */
BUSINESS_UNIT = NF_HDR_BBL_VW3.BUSINESS_UNIT;
NF_BRL_ID = FetchValue(Record.NF_HDR_BBL_VW3, CurrentRowNumber(), NF_HDR_BBL_VW3
.NF_BRL_ID);
Transfer( True, MenuName."MANAGE_NF_BBL", BarName."INQUIRE", ItemName."NF_INQR_B
BL", Panel."NF_INQR_BBL", "U", NF_HDR_BBL_VW3.BUSINESS_UNIT, NF_BRL_ID);
[NF_CNFM_BBL_WRK.NO_UOM_TYPES.FieldChange]
/* BRLBI_01 19/01/1999 Florival Athaide
Confirm all demand lines.
*/
&N = ActiveRowCount(Record.NF_HDR_BBL_VW3);
For &I = 1 To &N
&NF = FetchValue(Record.NF_HDR_BBL_VW3, &I, NF_HDR_BBL_VW3.NF_BRL_ID);
&FLAG = FetchValue(Record.NF_HDR_BBL_VW3, &I, CONFIRMED_FLAG);
If All(&NF) And
(&FLAG = "Y") Then
UpdateValue(CONFIRMED_FLAG, &I, "N");
End-If;
End-For;
[NF_CNFM_BBL_WRK.REFRESH_BTN.FieldChange]
/* BRLBI_01 19/01/1999 Florival Athaide
Abre e executa a janela de seleo de registros
*/
&TITLE = MsgGetText(31000, 95, "Confirm NF Selection");
NF_BRL_ID = "";
NF_BRL_SERIES = "";
NF_BRL = "";
SetDefault(NF_ISSUE_DT_BBL);
SHIP_TO_CUST_ID = "";
CARRIER_ID = "";
VEHICLE_ID = "";
RMNEIO_ID_BBL = "";
End-If;
[NF_HDR_BRL.ACCOUNTING_DT.FieldEdit]
Declare Function IsDateBetween PeopleCode FUNCLIB_RECV.F_ISDATE FieldFormula;
/*** JEISON CALDAS - 19/04/2006 - HD20763 - Coloca consistencia da data contabil
baseada na parametrizao da unidade. Home > Definir Regras de Negcio > Definir Unid
ades de Negcio > Usar 2 > Definio de Compras - Inicio ***/
If (%Component = "NF_INFO_PBL" Or
%Component = "NF_RECV_PBL") And
All(ACCOUNTING_DT) Then
SQLExec("SELECT ADJ_RECV_DATE_NBR FROM PS_BUS_UNIT_TBL_PM WHERE BUSINESS_UNIT
= :1", BUSINESS_UNIT, &ADJ_RECV_DATE_NBR);
If Not IsDateBetween(ACCOUNTING_DT, &ADJ_RECV_DATE_NBR) Then
&TODAY = %Date;
Error MsgGet(10300, 26, "Missing Message.", ACCOUNTING_DT, &ADJ_RECV_DATE_
NBR, &TODAY);
End-If;
End-If;
/*** JEISON CALDAS - 19/04/2006 - HD20763 - Coloca consistencia da data contabil
baseada na parametrizao da unidade. Home > Definir Regras de Negcio > Definir Unid
ades de Negcio > Usar 2 > Definio de Compras - Fim ***/
[NF_HDR_BRL.ACCOUNTING_DT.RowInit]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 01/11/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Customizao Sistema de Terceiros - Cria linha do recebimento, automticamente, pel
a OC. *
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Wagner Sorio - MMC - 15/06/2009 - mmcb.sds3027 - NF Devoluo
*
* Desabilitar campos da Nota Fiscal para impedir alteraes.
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Vincius Alves Mello - MMC - 14/10/2010 - mmcb.sds3425 - Sistema Controle Terce
iros
*
* O sistema no esta trazendo em alguns casos o preo unitrio dos itens de retorno.
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Bleno L Sampaio - MMC - mmcb.sds4924 - 05/12/2014
*
* Otimizar processo Recbto Terceiros via XML
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Augusto / Joo Roberto Enc(Diego Mota) - MMC - mmcb.hd249968 - 12/08/2015
*
* Ajuste na atribuo do valor da linha no momento da criao da nf
*
*******************************************************************************
*****************/
Local number &numLinha;
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange; /* mmc
b.sds3239.ln */
&SETID_GERAL = BUSCA_SETID(); /* mmcb.sds3239.ln */
/*** JEISON CALDAS - 19/01/06 - ALTERAO BASEADA NO HELP DESK 17589 - INICIO ***/
If %Component = "NF_RECV_PBL" Or
%Component = "NF_INFO_PBL" Or
%Component = "MMC_LANC_GAR" And
%Mode = "A" Then
ACCOUNTING_DT = %Date;
End-If;
/*** JEISON CALDAS - 19/01/06 - ALTERAO BASEADA NO HELP DESK 17589 - FIM ***/
&COUNT = &rowsetNiv1.ActiveRowCount;
VENDOR_ID = MMC_TE_RECV_WRK.VENDOR_ID;
ADDRESS_SEQ_NUM = MMC_TE_RECV_WRK.ADDRESS_SEQ_NUM;
NF_HDR_INFO_WRK.CGC_BRL = MMC_TE_RECV_WRK.CGC_BRL;
VNDR_LOC = MMC_TE_RECV_WRK.VNDR_LOC;
SHIPTO_ID = MMC_TE_RECV_WRK.SHIPTO_ID;
NF_BRL_TYPE = "NF";
SQLExec("select a.location from sysadm.ps_location_tbl a, sysadm.ps_sh
ipto_tbl b where b.setid =:1 and b.shipto_id =:2 and b.effdt = (select max(effdt
) from sysadm.ps_shipto_tbl where setid = b.setid and shipto_id = b.shipto_id) a
nd b.eff_status = 'A' and b.setid = a.setid and b.crtl_location_bbl = a.location
and a.effdt = (select max(effdt) from sysadm.ps_location_tbl where setid = a.se
tid and location = a.location) and a.eff_status = 'A' ", &VAR_SETID, SHIPTO_ID,
&LOCATION);
EF_LOC_BRL = &LOCATION;
For &I = 1 To &rsMMC_TE_OC_VW.ActiveRowCount;
&numLinha = &I;
If &rsMMC_TE_OC_VW.GetRow(&I).MMC_TE_WRK.MMC_TE_CONFI_FLG.VALUE = "Y
" Then
If &rsMMC_TE_OC_VW.GetRow(&I).MMC_TE_WRK.QTY_OPEN.VALUE > 0 Then
If &COUNT > 1 Then
&rowsetNiv1.InsertRow(&COUNT - 1);
End-If;
&rsMMC_TE_OC_VW.GetRow(&I).MMC_TE_WRK.NF_BRL_LINE_NUM.VALUE =
&I; /*mmcb.sds4924.ln*/
&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.ITM_SETID.VALUE = &VAR_SE
TID;
&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.INV_ITEM_ID.VALUE = &rsMM
C_TE_OC_VW.GetRow(&I).MMC_TE_OC_VW.INV_ITEM_ID.VALUE;
SQLExec("select unit_of_measure from ps_itm_vndr_uom_pr where
setid = :1 and inv_item_id = :2 and vendor_id = :3 and vndr_loc = :4 and vendor_
setid = :5", &VAR_SETID, &rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.INV_ITEM_ID.VALUE,
VENDOR_ID, VNDR_LOC, &VAR_SETID, &UNIDADE_MEDIDA);
SQLExec("select tax_class_brl from sysadm.ps_inv_items where s
etid=:1 and inv_item_id=:2 and effdt<= %DateTimeIn(:3) order by setid, inv_item_
id, effdt desc", &VAR_SETID, &rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.INV_ITEM_ID.VA
LUE, %Date, &TAX_CLASS_BRL);
&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.TAX_CLASS_BRL.VALUE = &TA
X_CLASS_BRL;
&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.UNIT_OF_MEASURE.VALUE = &
UNIDADE_MEDIDA;
&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.BUSINESS_UNIT_PO.Value =
&rsMMC_TE_OC_VW.GetRow(&I).MMC_TE_OC_VW.BUSINESS_UNIT.VALUE;
&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.PO_ID.Value = &rsMMC_TE_O
C_VW.GetRow(&I).MMC_TE_OC_VW.PO_ID.VALUE;
&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.QTY_NF_BRL.VALUE = &rsMMC
_TE_OC_VW.GetRow(&I).MMC_TE_WRK.QTY_OPEN.VALUE;
&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.UNIT_PRICE.VALUE = &rsMMC
_TE_OC_VW.GetRow(&I).MMC_TE_OC_VW.PRICE_PO.VALUE;
&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.MERCH_ORIG_AMT_PBL.VALUE
= &rsMMC_TE_OC_VW.GetRow(&I).MMC_TE_WRK.QTY_OPEN.VALUE * &rsMMC_TE_OC_VW.GetRow(
&I).MMC_TE_OC_VW.PRICE_PO.VALUE;
If None(&rsMMC_TE_OC_VW.GetRow(&I).MMC_TE_OC_VW.DESCR254_MIXED
.VALUE) Then
&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.DESCR.VALUE = &rsMMC_T
E_OC_VW.GetRow(&I).MASTER_ITEM_TBL.DESCR.VALUE;
Else
&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.DESCR.VALUE = &rsMMC_T
E_OC_VW.GetRow(&I).MMC_TE_OC_VW.DESCR254_MIXED.VALUE;
End-If;
SQLExec("select A.INVENTORY_ITEM, A.UNIT_MEASURE_STD from PS_M
ASTER_ITEM_TBL A where A.SETID = :1 and A.INV_ITEM_ID = :2", &VAR_SETID, &rowset
Niv1.GetRow(&COUNT).NF_LN_BRL.INV_ITEM_ID.VALUE, &INVENTORY_ITEM, &UNIT_OF_MEASU
RE);
If None(&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.UNIT_OF_MEASURE.V
ALUE) Then
&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.UNIT_OF_MEASURE.VALUE
= &UNIT_OF_MEASURE;
End-If;
If None(&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.INVENTORY_ITEM.VA
LUE) Then
&rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.INVENTORY_ITEM.Value =
&INVENTORY_ITEM;
End-If;
SQLExec("select account from sysadm.ps_itm_purch_vw where seti
d=:1 and inv_item_id =:2 ", &VAR_SETID, &rowsetNiv1.GetRow(&COUNT).NF_LN_BRL.INV
_ITEM_ID.VALUE, &ACCOUNT);
UpdateValue(Record.NF_LN_BRL, &COUNT, BRL_DISTRIB_LN.ACCOUNT,
1, &ACCOUNT);
&COUNT = &COUNT + 1;
End-If;
End-If;
End-For;
Else
/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||||||||
|| Inicio codigo de Triangulao
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||*/
VENDOR_ID = MMC_TE_TRIA_WRK.VENDOR_ID;
ADDRESS_SEQ_NUM = MMC_TE_TRIA_WRK.ADDRESS_SEQ_NUM;
NF_HDR_INFO_WRK.CGC_BRL = MMC_TE_TRIA_WRK.CGC_BRL;
VNDR_LOC = MMC_TE_TRIA_WRK.VNDR_LOC;
NF_BRL_TYPE = "NF";
SQLExec("select setid from sysadm.ps_set_cntrl_tbl where setcntrlvalue
=:1", BUSINESS_UNIT, &VAR_SETID);
&L1NF = GetRowset(Scroll.MMC_TE_S_NF_VW);
&rowsetN1 = GetRowset(Scroll.NF_LN_BRL);
&COUNTADOR = &rowsetN1.ActiveRowCount;
&rowsetN1.GetRow(&COUNTADOR).NF_LN_BRL.INVENTORY_ITEM.VALUE = &NF_IN
VENTORY_ITEM;
If None(&rowsetN1.GetRow(&COUNTADOR).NF_LN_BRL.UNIT_OF_MEASURE.VALUE
) Then
/*Error ("NF ID: " | &L1NF.GetRow(&COUNTADOR).MMC_TE_S_NF_VW.NF_B
RL_ID.VALUE | " est sem Unidade Medida"); */
/* Fabiano Cunha / Claudio Costa - MMC - SDS 3239 - 30/01/2010 Adequao para o sistema de terceiros da SVB */
If (&L1NF.GetRow(&COUNTADOR).MMC_TE_S_NF_VW.NF_BRL_ID.VALUE = "DS
00000001") Or
(&L1NF.GetRow(&COUNTADOR).MMC_TE_S_NF_VW.NF_BRL_ID.VALUE =
"DS00000002") Or
(&L1NF.GetRow(&COUNTADOR).MMC_TE_S_NF_VW.NF_BRL_ID.VALUE =
"DS00000003") Then
&rowsetN1.GetRow(&COUNTADOR).NF_LN_BRL.UNIT_OF_MEASURE.VALUE =
"PC";
Else
Error ("NF ID: " | &L1NF.GetRow(&COUNTADOR).MMC_TE_S_NF_VW.NF_
BRL_ID.VALUE | " est sem Unidade Medida");
End-If;
End-If;
/* Fabiano Cunha / Claudio Costa - MMC - SDS 3239 - 30/01/2010 - Ade
quao para o sistema de terceiros da SVB */
If None(&rowsetN1.GetRow(&COUNTADOR).NF_LN_BRL.INVENTORY_ITEM.VALUE)
Then
SQLExec("select A.INVENTORY_ITEM from PS_MASTER_ITEM_TBL A where
A.SETID = :1 and A.INV_ITEM_ID = :2 ", &SETID_GERAL, &rowsetN1.GetRow(&COUNTADOR
).NF_LN_BRL.INV_ITEM_ID.VALUE, &NF_INVENTORY_ITEM);
&rowsetN1.GetRow(&COUNTADOR).NF_LN_BRL.INVENTORY_ITEM.VALUE = &NF
_INVENTORY_ITEM;
End-If;
SQLExec("select account from sysadm.ps_itm_purch_vw where setid=:1 a
nd inv_item_id =:2 ", &VAR_SETID, &rowsetN1.GetRow(&COUNTADOR).NF_LN_BRL.INV_ITE
M_ID.VALUE, &ACCOUNT);
UpdateValue(Record.NF_LN_BRL, &COUNTADOR, BRL_DISTRIB_LN.ACCOUNT, 1,
&ACCOUNT);
&COUNTADOR = &COUNTADOR + 1;
End-For;
/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||||||||||
|| FIM codigo de Triangulao
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
*/
MMC_TE_OP_OC_WK.BTN_SELECT.Enabled = False;
MMC_TE_OP_OC_WK.BUTTON.Enabled = False;
&L_IND = GetRowset(Scroll.NF_LN_BRL);
For &NIND = 1 To &L_IND.ActiveRowCount;
&L_IND.GetRow(&NIND).MMC_TE_OP_WRK.DESCR.VALUE = "Recebimento NF Servio"
;
End-For;
Else
Page.MMC_TE_NF_OP.Visible = False;
End-If;
End-If;
/********************** mmcb.at2323.en **********************/
/********************** mmcb.sds3027.sn **********************/
If %Component = "NF_INFO_PBL" Then
SQLExec("SELECT 'Y' FROM SYSADM.PS_MMC_NFD_HDR WHERE BUSINESS_UNIT = :1 AND N
F_BRL_ID = :2 ", BUSINESS_UNIT, NF_BRL_ID, &NF_TERCEIROS);
If &NF_TERCEIROS = "Y" Then
Gray(VENDOR_ID);
Gray(ADDRESS_SEQ_NUM);
Gray(NF_HDR_INFO_WRK.CGC_BRL);
End-If;
End-If;
/********************** mmcb.sds3027.sn **********************/
[NF_HDR_BRL.ACCOUNTING_DT.SaveEdit]
/*******************************************************************************
*****************
* Augusto/Lucas (Enc. Bleno Sampaio) - MMC - 02/05/2011 - mmcb.hd115028
*
* Trava para que o sistema no permita incluso de rec. fiscla com data de emisso da
NF
*
* maior que a data contbil do documento.
*
*******************************************************************************
*****************/
/************************mmcb.hd115028.sn************************/
If %Component = "NF_RECV_PBL" Then
If NF_BRL_DATE > ACCOUNTING_DT Then
Error ("A data de emisso da NF no pode ser maior que a data contbil! ");
End-If;
End-If;
/************************mmcb.hd115028.sn************************/
[NF_HDR_BRL.ACCOUNT_FLOW_PBL.SavePreChange]
/*******************************************************************************
*******
End-For;
End-If;
/*** JEISON CALDAS - 02/11/2005 - TRATAMENTO PARA LEVAR ALTERAO DO CABECALHO PARA
AS LINHAS DO DOCUMENTO FISCAL - FIM ***/
/* mmcb.sds3445.sn */
Carrega_Redespacho_Fornecedor();
/* mmcb.sds3445.en */
[NF_HDR_BRL.ADDRESS_SEQ_NUM.FieldEdit]
/***************************************************************************
* Bleno L Sampaio - 07/02/2012 - mmcb.hd133155
*
* Corrigir validao de NF j existente comtemplando tambm a data da NF. *
****************************************************************************/
/**** BRLOC-PO-AO-FIX:R-ASIQUE-EP2NX - 11/10/2000 ***/
/**** Valida o numero/serie da NF ***********/
Function nf_num_valid_brl();
If All(NF_BRL) And
All(VENDOR_ID) And
All(ADDRESS_SEQ_NUM) And
All(NF_BRL_SERIES) Then
SQLExec("Select A.CGC_BRL FROM PS_VNDR_ADDR_SCROL A where A.SETID = :1 and
A.VENDOR_ID = :2 and A.ADDRESS_SEQ_NUM = :3", VENDOR_SETID, VENDOR_ID, ADDRESS_
SEQ_NUM, &CGC_BRL);
If All(&CGC_BRL) Then
&RETURN = "";
/*************************************mmcb.hd133155.so*****************
********************/
/*SQLExec("Select 'X' from PS_NF_HDR_BRL A, PS_VNDR_ADDR_SCROL B where
B.CGC_BRL = :1 AND A.VENDOR_SETID = B.SETID AND A.VENDOR_ID = B.VENDOR_ID and A.
ADDRESS_SEQ_NUM = B.ADDRESS_SEQ_NUM and A.NF_BRL = :2 and A.NF_BRL_SERIES = :3 a
nd A.NF_BRL_ID <> :4 and A.NF_BRL_STATUS <> 'X' AND A.INOUT_FLG_PBL = 'I'", &CGC
_BRL, NF_BRL, NF_BRL_SERIES, NF_BRL_ID, &RETURN);*/
/*************************************mmcb.hd133155.eo*****************
********************/
/*************************************mmcb.hd133155.sn*****************
********************/
SQLExec("Select 'X' from PS_NF_HDR_BRL A, PS_VNDR_ADDR_SCROL B where B.
CGC_BRL = :1 AND A.VENDOR_SETID = B.SETID AND A.VENDOR_ID = B.VENDOR_ID and A.AD
DRESS_SEQ_NUM = B.ADDRESS_SEQ_NUM and A.NF_BRL = :2 and A.NF_BRL_SERIES = :3 and
A.NF_BRL_ID <> :4 and A.NF_BRL_STATUS <> 'X' AND A.INOUT_FLG_PBL = 'I' AND A.NF
_BRL_DATE = %datein(:5)", &CGC_BRL, NF_BRL, NF_BRL_SERIES, NF_BRL_ID, NF_BRL_DAT
E, &RETURN);
/*************************************mmcb.hd133155.en*****************
********************/
If All(&RETURN) Then
Error MsgGet(28000, 2, "This Nota Fiscal already exists.");
End-If;
Else
/*************************************mmcb.hd133155.so*****************
********************/
/*SQLExec("Select 'X' from PS_NF_HDR_BRL where NF_BRL = :1 and VENDOR_I
D = :2 and NF_BRL_SERIES = :3 and NF_BRL_ID <> :4 and NF_BRL_STATUS <> 'X' AND I
BUSPROCNAME = &BUSPROCNAME_PBL;
APPR_RULE_SET = &APPR_RULE_SET_PBL;
Else
APPR_STATUS = "A";
DFI_PBL_APPRVL_FLG = "P";
End-If;
End-If;
/* BRLOC-PO - RELEASE 8.00 - HAT - 17/04/01 - END */
[NF_HDR_BRL.BUSINESS_UNIT.FieldFormula]
/*******************************************************************************
*******
* Vinicius Montijo Favero - MMC - 11/03/2015 - mmcb.sds5100
*
* Ajuste de Dados Incorretos no Registro ou Faturamento
*
********************************************************************************
*******/
/***********************************mmcb.sds5100 s.n****************************
*****************/
Function valida_somatoria_linhas(&tabela, &campo, &valor_hdr);
&TOTAL = 0;
For &LINE_ROW = 1 To ActiveRowCount(@&tabela)
&linha = FetchValue(@&campo, &LINE_ROW);
&TOTAL = &TOTAL + &linha;
End-For;
&position = Find(".", &campo);
&campo2 = Substring(&campo, &position + 1, Len(&campo));
&campo_descr = &campo2;
SQLExec("SELECT LONGNAME FROM PSDBFLDLABLLANG WHERE FIELDNAME = :1 AND LABEL_
ID = :2 AND LANGUAGE_CD = 'POR'", &campo2, &campo2, &campo_descr);
If &TOTAL <> &valor_hdr Then
Error ("A somatoria do valor do campo " | &campo_descr | " ( " | &campo2 |
" ) -> " | &TOTAL | ", no bate com o valor do cabealho - > " | &valor_hdr);
End-If;
End-Function;
/***********************************mmcb.sds5100 e.n****************************
*****************/
[NF_HDR_BRL.BUSINESS_UNIT.RowInit]
/*******************************************************************************
*
* Fabiano Cunha - MMCB - 05/11/2009
- mmcb.sds3239
*
* Projeto Implantao People - Multi Empresa MMCB-SVB.
*******************************************************************************
*/
/************************************************************************
* Wagner Sorio - MMCB - 01/09/2014 - mmcb.sds4689
*
* Implantao do People DBME
*
*************************************************************************/
/* Declare Function BU_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange; */ /*
mmcb.sds4689.lo */
Declare Function MMC_BUSINESS_UNIT PeopleCode MMC_BUS_UNIT.BUSINESS_UNIT SavePos
tChange; /* mmcb.sds4689.ln */
Declare Function Sugestion_Amount PeopleCode RECV_HD_WRK_PBL.NF_SUG_AMOUNT_PBL F
ieldFormula;
/* fabiano cunha - 21/10/2005 - adequacao da versao 7 para 8 - sera usada na tab
ela MMC_CCG_WRK */
PanelGroup string &MMC_CCG_LANCAR_NF;
PanelGroup string &MMC_CCG_NROS;
PanelGroup string &MMC_CCG_OSSEQ;
If %Component = "NF_RECV_PBL" Or
%Component = "NF_INFO_PBL" Then
Sugestion_Amount();
/* BRLOC-PO-HAT-8.00-24/04/01 - Gray - Qdo. c/Recebimento */
If %Component = Component.NF_RECV_PBL Then
If %Mode <> "A" Then
&po_id = FetchValue(NF_LN_BRL.PO_ID, 1);
If All(&po_id) Then
Gray(PYMNT_TERMS_CD);
Gray(VNDR_LOC);
Gray(PAY_TRM_BSE_DT_OPT);
End-If;
Gray(NF_BRL);
Gray(NF_BRL_SERIES);
Gray(NF_BRL_DATE);
Gray(VENDOR_ID);
Gray(NF_HDR_INFO_WRK.CGC_BRL);
Gray(ADDRESS_SEQ_NUM);
If All(EF_LOC_BRL) Then
Gray(EF_LOC_BRL);
End-If;
Gray(SHIPTO_ID);
Gray(VNDR_LOC);
&TOTSHIP_ROW = ActiveRowCount(Record.NF_LN_BRL);
For &SHIP_ROW = 1 To &TOTSHIP_ROW
Gray(NF_LN_BRL.INV_ITEM_ID, &SHIP_ROW);
Gray(NF_LN_BRL.DESCR, &SHIP_ROW);
End-For;
End-If;
/**** INICIO - AUGUSTO VILARINHO NETO - 25/11/2005 - Libera campo de desc
rio do item para alterao do usurio ****/
&TOTSHIP_ROW = ActiveRowCount(Record.NF_LN_BRL);
For &SHIP_ROW = 1 To &TOTSHIP_ROW
/********************** mmcb.sds4689.so **********************/
/* If ((BUSINESS_UNIT = "POIND") Or
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-05/04/01
No executar o cdigo se o Component = 'DFI_CANCEL_PBL' (Cancelamento de Doc. Fiscal
) ou 'REOPEN_FISCDOC_PBL' (Reabertura de Doc. Fiscal) ou 'DELETE_FISCDOC_PBL' (D
eleo de Doc. Fiscal) ou 'CLOSE_FISCDOC_PBL' (Encerramento de Doc. Fiscal).
*/
Declare Function Validate_Calc PeopleCode FUNCLIB_PBL.VALIDATION_NF_PBL FieldFor
mula;
Declare Function NF_LOG PeopleCode RECV_HD_WRK_PBL.NF_NAV_L1 FieldFormula;
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-BEGIN-05/04/01 */
If %Component <> Component.DFI_CANCEL_PBL And
%Component <> Component.REOPEN_FISCDOC_PBL And
%Component <> Component.DELETE_FISCDOC_PBL And
%Component <> Component.MMC_NF_ALTERA And /*mmcb.sds5100 l.n*/
%Component <> Component.MMC_NF_FA_ALTERA And /*mmcb.sds5100 l.n*/
%Component <> Component.MMC_NF_STAT_CONT And /*mmcb.sds5100 l.n*/
%Component <> Component.CLOSE_FISCDOC_PBL And
%Component <> Component.MMC_NF_INFO_AVRG And
%Component <> Component.DFI_APPROVAL_PBL Then
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-END-05/04/01 */
/* Efetua validao dos campos do documento fiscal, se houve problema na validao o
status da NF deve ser tornar OPEN */
If VENDOR_ID <> "001327" Or
NF_BRL_STATUS = "O" Then
&VALIDATE_FLG = Validate_Calc();
If &VALIDATE_FLG And
NF_BRL_STATUS = "F" Then
NF_HDR_INFO_WRK.NF_BRL_STATUS = "O";
NF_BRL_STATUS = "O";
Error MsgGet(30000, 214, "Errors found when trying to complete the Fisc
al Document!");
End-If;
End-If;
If GetLevel0()(1).GetRowset(Scroll.RECV_NF_LOG_PBL).ActiveRowCount >= 1 And
All(GetLevel0()(1).GetRowset(Scroll.RECV_NF_LOG_PBL)(1).GetRecord(Recor
d.RECV_NF_LOG_PBL).SEQUENCE_NBR.Value) Then
Warning MsgGet(30000, 215, "Warning! Check the Log for Messages.");
NF_LOG();
End-If;
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-BEGIN-05/04/01 */
End-If
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-END-05/04/01 */
[NF_HDR_BRL.BUSINESS_UNIT.SavePostChange]
/*******************************************************************************
*****************
* Claudio Henrique da Costa - MMC - 07/03/2007 - mmcb.hd29508
*
* Correcao do programa para atualizar a tabela MMC_CONTR_DEVOL.
*
/*******************************************************************************
*****************
* Itamar Junior - MMCB - 10/08/2009 - mmcb.hd72747 - Evitando que uma linha exis
tente seja
*
* removida do sistema, evitando que ocorra a duplicidade na conta corrente do co
ncessionrio
*
********************************************************************************
*****************/
/*******************************************************************************
*****************
* Gustavo Vilarinho - MMCB - 27/07/2010 - mmcb.sds2719 - Armazenagem entre unida
de
*
********************************************************************************
*****************/
/*******************************************************************************
*****************
Fernando Camarinha - MMCB - 21/11/2012 - mmcb.sds3884
Novo Sistema de Controle de Pagamentos Comisses de Venda
********************************************************************************
*****************/
/*******************************************************************************
*****************
Itamar Junior - MMCB - 06/06/2014
- mmcb.hd203166
Ajustando a gravao dos lanamentos de estorno na Journal, para as NFs de Comisses,
pois quando uma NF tem mais de uma linha e consequentemente est atendendo mais de
uma OC, o sistema
estava gravando apenas os lanamentos da primeira linha da NF
********************************************************************************
*****************/
/*******************************************************************************
*****************
Douglas Jesus Rodovalho - MMCB - 25/09/2014
- mmcb.hd214121
Ajustando a gravao dos lanamentos de na Journal, pois a concatenao da NF_DOC e NF_BRL
_SERIES
esta ultrapassando o tamanho de 10 dgitos em alguns casos gerando erro na gravao no
campo PROC_PART_ID.
********************************************************************************
*****************/
/*******************************************************************************
*******
* Vinicius Montijo Favero - MMC - 11/03/2015 - mmcb.sds5100
*
* Ajuste de Dados Incorretos no Registro ou Faturamento
*
********************************************************************************
*******/
Declare Function nf_match PeopleCode RECV_HD_WRK_PBL.NF_NAV_L1 FieldFormula;
Declare Function nf_LOG PeopleCode RECV_HD_WRK_PBL.NF_NAV_L1 FieldFormula;
/********************* MMCB.sds3884.sn *********************/
Declare Function get_journal_id PeopleCode FUNCLIB_GL.JOURNAL_ID FieldFormula;
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange;
/********************* MMCB.sds3884.en *********************/
Local Rowset &linhas, &CONTROLE;
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-29/01/01
No chamar a rotina de Matching se for cancelamento / reabertura / deleo / encerrame
nto.*/
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-BEGIN-29/01/01 */
If %Component <> Component.DFI_CANCEL_PBL And
%Component <> Component.REOPEN_FISCDOC_PBL And
%Component <> Component.DELETE_FISCDOC_PBL And
%Component <> Component.CLOSE_FISCDOC_PBL And
%Component <> Component.MMC_NF_ALTERA And /*mmcb.sds5100 l.n*/
%Component <> Component.MMC_NF_STAT_CONT And /*mmcb.sds5100 l.n*/
&PROC_INSTANCE = &PROC_INSTANCE + 1;
End-If;
&primer = "Y";
SQLExec("UPDATE PS_DIV_MTCH_PBL SET PROCESS_INSTANCE = :1, DIV_CH
K_PBL = 'Y', DIV_ACTN_PBL = :2 WHERE BUSINESS_UNIT = :3 AND NF_BRL_ID = :4 AND N
F_BRL_LINE_NUM = :5 AND MATCH_CNTRL_ID = :6 AND MATCH_RULE_ID = :7", &PROC_INSTA
NCE, &div_act, BUSINESS_UNIT, NF_BRL_ID, &LINE_ROW, &CNTRL_ID, &RULE_ID);
End-If;
If &check = "N" Then
/*
RowFlush(Record.NF_LN_BRL, &LINE_ROW, Record.DIV
_MTCH_PBL, &DIV_ROW);*/
DeleteRow(Record.NF_LN_BRL, &LINE_ROW, Record.DIV_MTCH_PBL, &DIV_
ROW);
End-If;
End-For;
SQLExec("delete from PS_DIV_MTCH_PBL WHERE BUSINESS_UNIT = :1 AND NF_BR
L_ID = :2 AND NF_BRL_LINE_NUM = :3 AND DIV_CHK_PBL = 'N'", BUSINESS_UNIT, NF_BRL
_ID, &LINE_ROW);
End-For;
/*Verifica se recebimento fiscal est relacionado a recebimento fsico*/
If All(RECEIVER_ID) Then
/*verifica se recebimento fsico com PO ou sem PO */
&po_id = FetchValue(NF_LN_BRL.PO_ID, 1);
If All(&po_id) Then
&SQLWHERE = "A.MTCH_RCV_PO_PBL = 'Y'";
Else
&SQLWHERE = "A.MTCH_RCV_WPO_PBL = 'Y'";
End-If;
Else
&SQLWHERE = "A.MTCH_RCV_TP_PBL = 'Y'";
End-If;
/* Popula record com divergncias do processo de matching se existir */
&SQL = CreateSQL("SELECT A.MATCH_RULE_ID, C.MATCH_CNTRL_ID, C.SETID FROM P
S_MTCH_SYS_RULES A, PS_MTCH_RULES C WHERE C.MATCH_CNTRL_ID = :1 AND C.MATCH_RULE
_ID = A.MATCH_RULE_ID AND " | &SQLWHERE | "", &CNTRL_MTCH);
While &SQL.Fetch(&MTCHID, &MTCNTRLID, &SETID)
/*BRLOC-PO-APP-8.01-30/10/01-C1SSUDA-VB35J-BEGIN*/
/* Alterado o valor para o field PROCESS_INSTANCE para acerto no Unix e
SyBase */
SQLExec("INSERT INTO PS_DIV_MTCH_PBL ( BUSINESS_UNIT, NF_BRL_ID, NF_BRL
_LINE_NUM, MATCH_RULE_ID, DIV_ACTN_PBL, DIV_CHK_PBL,MATCH_CNTRL_ID,SETID,PROCESS
_INSTANCE) SELECT A.BUSINESS_UNIT, A.NF_BRL_ID, A.NF_BRL_LINE_NUM, B.MATCH_RULE_
ID, ' ','N','" | &MTCNTRLID | "','" | &SETID | "',0 FROM PS_NF_MTCH_PBL A, PS_MT
CH_SYS_RULES B WHERE A.BUSINESS_UNIT = :1 AND B.MATCH_RULE_ID = '" | &MTCHID | "
' %SQL(" | "AP_MATCH_" | &MTCHID | ") AND A.NF_BRL_ID = :2 AND A.NF_BRL_ID NOT I
N (SELECT NF_BRL_ID FROM PS_DIV_MTCH_PBL WHERE BUSINESS_UNIT = A.BUSINESS_UNIT A
ND NF_BRL_ID = A.NF_BRL_ID AND NF_BRL_LINE_NUM = A.NF_BRL_LINE_NUM AND B.MATCH_R
ULE_ID = MATCH_RULE_ID AND DIV_CHK_PBL = 'Y')", BUSINESS_UNIT, NF_BRL_ID);
/*BRLOC-PO-APP-8.01-30/10/01-C1SSUDA-VB35J-END*/
End-While;
&SQL.Close();
SQLExec("SELECT COUNT(*) FROM PS_DIV_MTCH_PBL WHERE BUSINESS_UNIT = :1 AND
NF_BRL_ID = :2 AND DIV_CHK_PBL = 'N'", BUSINESS_UNIT, NF_BRL_ID, &TOTLN);
If &TOTLN > 0 Then
NF_HDR_INFO_WRK.NF_BRL_STATUS = "O";
NF_BRL_STATUS = "O";
SQLExec("UPDATE PS_NF_HDR_BRL SET NF_BRL_STATUS = 'O' WHERE BUSINESS_UN
IT = :1 AND NF_BRL_ID = :2", BUSINESS_UNIT, NF_BRL_ID);
13, :14, :15, :16, :17, :18, :19, :20, %DATEIN(:21), :22, :23, :24, :25, :26, :2
7, :28, :29, %DATEIN(:30),:31, :32, :33, :34, :35, :36, :37, :38, :39, :40, :41,
:42, :43, :44, :45, %DATEIN(:46), :47, :48)", &BU_GL, &JOURNAL_ID, %Date, 0, &J
LINE, "GERENCIAL", &MMC_ACCOUNT_D_P, &MMC_DEPTID_PGT, &INV_PROD4, " ", " ", "BRL
", " ", &VAL_LAN, "N", 0, " ", 0, "PROVISAO COMISSO SOBRE VENDAS", 0, %Date, "BRL
", " ", &VAL_LAN, 1, 1, 0, " ", " ", %Date, " ", "ONL", &HIST1, &HIST2, &HIST3,
&HIST4, " ", " ", " ", " ", " ", " ", " ", " ", " ", %Date, "N", " ");
/*** Insero das linhas positivas na jornal line cp - SE LN POSITIVA DBITO
***/
SQLExec("INSERT INTO SYSADM.PS_MMC_JRNL_LN_CP (BUSINESS_UNIT, JOURNAL_I
D, JOURNAL_DATE, UNPOST_SEQ, JOURNAL_LINE, LEDGER, ACCOUNT, DEPTID, ACCOUNT_TO,
MONETARY_AMOUNT, DEBIT_CREDIT, MMC_HISTORICO, SOURCE, JRNL_LN_REF, HIST_PART_BRL
_1, HIST_PART_BRL_2, HIST_PART_BRL_3, HIST_PART_BRL_4, ITEM, ITEM_LINE, MMC_REF_
CONTR,CAP_NUM,CAP_SEQUENCE,MMC_TIPO_LANCTO) VALUES (:1, :2, %DATEIN(:3), :4, :5,
:6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17, :18, :19, :20, :21, :22
, :23, :24)", &BU_GL, &JOURNAL_ID, %Date, 0, &JLINE, "CONTABIL", &MMC_ACCOUNT_D_
P, &MMC_DEPTID_PGT, &MMC_ACCOUNT_C_P, &VAL_LAN, "D", "PROVISAO COMISSO SOBRE VEND
AS", "ONL", " ", &HIST1, &HIST2, &HIST3, &HIST4, " ", 0, " ", " ", 0, " ");
&JLINE = &JLINE + 1;
/*** CONTBIL - Insero das linhas negativas na jornal line ***/
SQLExec("INSERT INTO SYSADM.PS_JRNL_LN(BUSINESS_UNIT, JOURNAL_ID, JOURN
AL_DATE, UNPOST_SEQ, JOURNAL_LINE, LEDGER, ACCOUNT, DEPTID, PRODUCT, PROJECT_ID,
AFFILIATE, CURRENCY_CD, STATISTICS_CODE, MONETARY_AMOUNT, MOVEMENT_FLAG, STATIS
TIC_AMOUNT, JRNL_LN_REF, SUSPENDED_LINE, LINE_DESCR, JRNL_LINE_STATUS, JOURNAL_L
INE_DATE, FOREIGN_CURRENCY, RT_TYPE, FOREIGN_AMOUNT, RATE_DIV, RATE_MULT, PROCES
S_INSTANCE, DOC_TYPE, DOC_SEQ_NBR, DOC_SEQ_DATE, DOC_SEQ_STATUS, JRNL_LINE_SOURC
E, HIST_PART_BRL_1, HIST_PART_BRL_2, HIST_PART_BRL_3, HIST_PART_BRL_4, ALTACCT,
OPERATING_UNIT, SCENARIO, BUSINESS_UNIT_PC, ACTIVITY_ID, ANALYSIS_TYPE, RESOURCE
_TYPE, RESOURCE_CATEGORY, RESOURCE_SUB_CAT, BUDGET_DT, BUDGET_LINE_STATUS, CLOSI
NG_STATUS) VALUES (:1, :2, %DATEIN(:3), :4, :5, :6, :7, :8, :9, :10, :11, :12, :
13, :14, :15, :16, :17, :18, :19, :20, %DATEIN(:21), :22, :23, :24, :25, :26, :2
7, :28, :29, %DATEIN(:30),:31, :32, :33, :34, :35, :36, :37, :38, :39, :40, :41,
:42, :43, :44, :45, %DATEIN(:46), :47, :48)", &BU_GL, &JOURNAL_ID, %Date, 0, &J
LINE, "CONTABIL", &MMC_ACCOUNT_C_P, &MMC_DEPTID_PGT, &INV_PROD4, " ", " ", "BRL"
, " ", &VAL_LAN_NEG, "N", 0, " ", 0, "PROVISAO COMISSO SOBRE VENDAS", 0, %Date, "
BRL", " ", &VAL_LAN_NEG, 1, 1, 0, " ", " ", %Date, " ", "ONL", &HIST1, &HIST2, &
HIST3, &HIST4, " ", " ", " ", " ", " ", " ", " ", " ", " ", %Date, "N", " ");
/*** GERENCIAL - Insero das linhas negativas na jornal line ***/
SQLExec("INSERT INTO SYSADM.PS_JRNL_LN(BUSINESS_UNIT, JOURNAL_ID, JOURN
AL_DATE, UNPOST_SEQ, JOURNAL_LINE, LEDGER, ACCOUNT, DEPTID, PRODUCT, PROJECT_ID,
AFFILIATE, CURRENCY_CD, STATISTICS_CODE, MONETARY_AMOUNT, MOVEMENT_FLAG, STATIS
TIC_AMOUNT, JRNL_LN_REF, SUSPENDED_LINE, LINE_DESCR, JRNL_LINE_STATUS, JOURNAL_L
INE_DATE, FOREIGN_CURRENCY, RT_TYPE, FOREIGN_AMOUNT, RATE_DIV, RATE_MULT, PROCES
S_INSTANCE, DOC_TYPE, DOC_SEQ_NBR, DOC_SEQ_DATE, DOC_SEQ_STATUS, JRNL_LINE_SOURC
E, HIST_PART_BRL_1, HIST_PART_BRL_2, HIST_PART_BRL_3, HIST_PART_BRL_4, ALTACCT,
OPERATING_UNIT, SCENARIO, BUSINESS_UNIT_PC, ACTIVITY_ID, ANALYSIS_TYPE, RESOURCE
_TYPE, RESOURCE_CATEGORY, RESOURCE_SUB_CAT, BUDGET_DT, BUDGET_LINE_STATUS, CLOSI
NG_STATUS) VALUES (:1, :2, %DATEIN(:3), :4, :5, :6, :7, :8, :9, :10, :11, :12, :
13, :14, :15, :16, :17, :18, :19, :20, %DATEIN(:21), :22, :23, :24, :25, :26, :2
7, :28, :29, %DATEIN(:30),:31, :32, :33, :34, :35, :36, :37, :38, :39, :40, :41,
:42, :43, :44, :45, %DATEIN(:46), :47, :48)", &BU_GL, &JOURNAL_ID, %Date, 0, &J
LINE, "GERENCIAL", &MMC_ACCOUNT_C_P, &MMC_DEPTID_PGT, &INV_PROD4, " ", " ", "BRL
", " ", &VAL_LAN_NEG, "N", 0, " ", 0, "PROVISAO COMISSO SOBRE VENDAS", 0, %Date,
"BRL", " ", &VAL_LAN_NEG, 1, 1, 0, " ", " ", %Date, " ", "ONL", &HIST1, &HIST2,
&HIST3, &HIST4, " ", " ", " ", " ", " ", " ", " ", " ", " ", %Date, "N", " ");
/*** Insero das linhas negativas na jornal line cp - SE LN NEGATIVA CREDI
TO ***/
SQLExec("INSERT INTO SYSADM.PS_MMC_JRNL_LN_CP (BUSINESS_UNIT, JOURNAL_I
D, JOURNAL_DATE, UNPOST_SEQ, JOURNAL_LINE, LEDGER, ACCOUNT, DEPTID, ACCOUNT_TO,
MONETARY_AMOUNT, DEBIT_CREDIT, MMC_HISTORICO, SOURCE, JRNL_LN_REF, HIST_PART_BRL
_1, HIST_PART_BRL_2, HIST_PART_BRL_3, HIST_PART_BRL_4, ITEM, ITEM_LINE, MMC_REF_
CONTR,CAP_NUM,CAP_SEQUENCE,MMC_TIPO_LANCTO) VALUES (:1, :2, %DATEIN(:3), :4, :5,
:6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17, :18, :19, :20, :21, :22
, :23, :24)", &BU_GL, &JOURNAL_ID, %Date, 0, &JLINE, "CONTABIL", &MMC_ACCOUNT_C_
P, &MMC_DEPTID_PGT, &MMC_ACCOUNT_D_P, &VAL_LAN_NEG, "C", "PROVISAO COMISSO SOBRE
VENDAS", "ONL", " ", &HIST1, &HIST2, &HIST3, &HIST4, " ", 0, " ", " ", 0, " ");
SQLExec("INSERT INTO SYSADM.PS_JRNL_HEADER VALUES (:1, :2, %DATEIN(:3),
:4, :5, :6, :7, :8, %DATEIN(:9), :10, :11, :12, :13, %DATEIN(:14), :15, :16, %D
ATEIN(:17), :18, :19, :20, :21, :22, :23, :24, :25, :26, :27, :28, :29, :30,:31,
:32, :33, %DATEIN(:34), :35, :36, %DATEIN(:37), :38, :39, %DATETIMEIN(:40), :41
, :42, :43, :44, %DATEIN(:45), :46, :47, :48, :49, :50, %DATEIN(:51), :52, :53,
:54, :55, :56, :57, :58, %DATETIMEIN(:59), :60, :61, :62, :63)", &BU_GL, &JOURNA
L_ID, %Date, 0, &BU_GL, "N", &ANO, &MES, %Date, "ACTUALS", " ", "Y", "N", "", 0,
"S", "", &JLINE, &TOT_VAL, &TOT_VAL, 0, "ONL", " ", "V", "V", "V", "N", "0", "N
", "N", " ", " ", 0, %Date, 0, 0, %Date, 0, "VPPOR", %Date, "PROVISAO COMISSO SOB
RE VENDAS", "BRL", "BRL", "CRRNT", %Date, 1, 1, "NVS", " ", " ", %Date, " ", " "
, "N", "N", 1, "N", " ", "", 0, "N", &HIST2, &HIST1);
End-If;
End-For; /*** mmcb.hd203166.ln ***/
End-If;
/************************ mmcb.sds3884.sn *****************************/
[NF_HDR_BRL.BUSINESS_UNIT.SavePreChange]
/*******************************************************************************
****
* Leandro Rodrigues da Silva Souza - MMC - mmcb.sds4924.v2 - 18/12/2014
* Otimizar processo Recbto Terceiros via XML
*
*******************************************************************************
****/
/*******************************************************************************
*******
* Vinicius Montijo Favero - MMC - 11/03/2015 - mmcb.sds5100
*
* Ajuste de Dados Incorretos no Registro ou Faturamento
*
********************************************************************************
*******/
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-19/01/01
No executar o cdigo se o Component = 'DFI_CANCEL_PBL' (Cancelamento de Doc. Fiscal
) ou 'REOPEN_FISCDOC_PBL' (Reabertura de Doc. Fiscal) ou 'DELETE_FISCDOC_PBL' (D
eleo de Doc. Fiscal) ou 'CLOSE_FISCDOC_PBL' (Encerramento de Doc. Fiscal).
*/
Declare Function Comp_Fiscal_Doc_NoEdit PeopleCode FUNCLIB_PBL.COMP_DOCS FieldFo
rmula;
Declare Function Pop_rcv_po PeopleCode FUNCLIB_PBL.MATCH_VALID_PBL FieldFormula;
Declare Function Pop_rcv_wpo PeopleCode FUNCLIB_PBL.MATCH_VALID_PBL FieldFormula
;
Declare Function Pop_rcv_tp PeopleCode FUNCLIB_PBL.MATCH_VALID_PBL FieldFormula;
Declare Function Sugestion_Calc PeopleCode RECV_HD_WRK_PBL.NF_SUG_CALC_PBL_PB Fi
eldChange;
Declare Function Calc_Tax_Receb_Terceiro PeopleCode FUNCLIB_PBL.COMP_DOCS FieldF
ormula; /*mmcb.sds4292.v2.ln*/
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-BEGIN-23/03/01 */
If %Component <> Component.DFI_CANCEL_PBL And
%Component <> Component.REOPEN_FISCDOC_PBL And
%Component <> Component.DELETE_FISCDOC_PBL And
%Component <> Component.CLOSE_FISCDOC_PBL And
%Component <> Component.MMC_NF_INFO_AVRG And
%Component <> Component.MMC_NF_ALTERA And /*mmcb.sds5100 l.n*/
%Component <> Component.MMC_NF_STAT_CONT And /*mmcb.sds5100 l.n*/
%Component <> Component.DFI_APPROVAL_PBL Then
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-END-23/03/01 */
/*BRLOC-PO-HAT-8.00-13/02/01 - Composio dos campos no editveis */
/********************* mmcb.sds4924.v2.so **********************************
Sugestion_Calc("RCV", "N");
Comp_Fiscal_Doc_NoEdit();
********************* mmcb.sds4924.v2.eo *********************************/
/* BRLOC-PO-HAT-8.00-13/02/01 - END */
/***************************** mmcb.sds4924.v2.sn ***************************
**/
If MMC_TE_NFLN_WRK.MMC_TERCEIRO_FLG = "Y" And
Substring(NF_BRL_SERIES, 1, 1) <> "S" Then
/* Realiza cpia dos valores da NF de Sada para este Recebimento. */
/* mmcb.sds4924.v2.sn */
&calculoTerceiro = Calc_Tax_Receb_Terceiro();
If &calculoTerceiro = "N" Then
Sugestion_Calc("RCV", "N");
End-If;
/* mmcb.sds4924.v2.en */
/* Faz a somatria dos campos de impostos para o cabealho. */
Comp_Fiscal_Doc_NoEdit();
Else
Sugestion_Calc("RCV", "N");
Comp_Fiscal_Doc_NoEdit();
End-If;
/***************************** mmcb.sds4924.v2en ****************************
*/
VOUCHER_FLOW_PBL = "V";
End-If;
If FetchValue(NF_LN_BRL.FLOW_STATUS_PBL, &LN_ROW) = "A" Then
ACCOUNT_FLOW_PBL = "A";
End-If;
End-For;
/*BRLPO-HAT-8.01-11/07/01 - END */
/*BRLOC-PO-APP-8.00-05/04/01-BEGIN */
/*** Armazena os dados para as regras de matching j verificadas ***/
/*Verifica se recebimento fiscal est relacionado a recebimento fsico*/
/*****
SQLExec("DELETE FROM PS_NF_MTCH_PBL WHERE BUSINESS_UNIT = :1 AND NF_BRL_ID =
:2", BUSINESS_UNIT, NF_BRL_ID);
***/
&Ln_ActiveRows = ActiveRowCount(Record.NF_LN_BRL);
For &LN_ROW = 1 To &Ln_ActiveRows
DeleteRow(Record.NF_LN_BRL, &LN_ROW, Record.NF_MTCH_PBL, 1);
End-For;
/* Sugesto dos dados de SETUP que sero utilizadas no processo de matching*/
Sugestion_Calc("MTC", "");
If All(RECEIVER_ID) Then
/*verifica se recebimento fsico com PO ou sem PO */
&po_id = FetchValue(NF_LN_BRL.PO_ID, 1);
If All(&po_id) Then
/* chama funo para popular dados do recebimento fiscal com com fsico com P
O*/
Pop_rcv_po();
Else
/*chama funo para popular dados do recebimento fiscal com fsico sem PO*/
Pop_rcv_wpo();
End-If;
Else
/*chama funo para popular dados da entrada direta do recebimento fiscal*/
Pop_rcv_tp();
End-If;
/*BRLOC-PO-APP-8.00-05/04/01-END */
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-BEGIN-23/03/01 */
End-If
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-END-23/03/01 */
[NF_HDR_BRL.BUSINESS_UNIT.SearchInit]
If %OperatorId = "WO800282" Then
WinMessage("PASSEI AQUI");
End-If;
[NF_HDR_BRL.BUSINESS_UNIT.Workflow]
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-29/03/01
- Sends e-mails about suggested actions.
End-While;
&SUG_ACTIONS_TXT = &SUG_ACTIONS_TXT | Char(13) | Char(10) | %Datetime | " Use
rID " | %UserId;
&Query_Actions.Close();
RECV_HD_WRK_PBL.WF_SUG_ACT_SUB_PBL = &SUBJECT;
RECV_HD_WRK_PBL.WF_SUG_ACT_TXT_PBL = &SUG_ACTIONS_TXT;
&TEMP = TriggerBusinessEvent(BusProcess."BRLPO_MANAGE_FISCAL_DOC_BP", BusActi
vity."BRLPO_MAINTAIN_FISCAL_DOC_ACT", BusEvent."Suggested Actions");
End-Function;
Function SendMatchingRules
/* Define os BINDs para a serem utilizados como argumentos na funo Get_Message
*/
&BIND1 = VENDOR_ID;
&BIND2 = VENDOR.VENDOR_NAME_SHORT;
&BIND3 = NF_BRL;
&BIND4 = NF_BRL_SERIES;
&BIND5 = NF_BRL_TYPE;
&BIND6 = NF_BRL_ID;
If %Component = Component.NF_RECV_PBL Then
&BIND7 = "- Receiver ID: " | RECEIVER_ID;
Else /* %Component = Component.NF_INFO_PBL */
&BIND7 = "";
End-If;
&MESSAGE_SET_NBR = 30000;
&MESSAGE_NBR = 168;
/* Busca Subject e Texto */
Get_Message(&MESSAGE_SET_NBR, &MESSAGE_NBR, &BIND1, &BIND2, &BIND3, &BIND4, &
BIND5, &BIND6, &BIND7, &SUBJECT, &MATCH_RULES_TXT);
/* Busca as regras de matching de acordo com as divergncias apuradas */
&RS_MATCH_RULES = CreateRowset(Record.DIV_MTCH_PBL);
&RS_MATCH_RULES.Fill("WHERE FILL.BUSINESS_UNIT = :1 AND FILL.NF_BRL_ID = :2 A
ND EXISTS(SELECT 'X' FROM PS_MTCH_SYS_RULES MSR WHERE MSR.MATCH_RULE_ID = FILL.M
ATCH_RULE_ID AND MSR.MTCH_WRK_FLG_PBL = 'Y')", BUSINESS_UNIT, NF_BRL_ID);
/* Prepara Texto Matching Rules */
&OLD_LINE_NUM = 0;
For &I = 1 To &RS_MATCH_RULES.ActiveRowCount
/* Linha */
&LINE_NUM = &RS_MATCH_RULES.GetRow(&I).GetRecord(Record.DIV_MTCH_PBL).GetF
ield(Field.NF_BRL_LINE_NUM).Value;
If &LINE_NUM <= 0 Then
/* No h nada para ser processado. No h divergncias */
Break;
End-If;
/* Inicializa Labels */
If &OLD_LINE_NUM = 0 Then
&LINE_LABEL = &RS_MATCH_RULES.GetRow(&I).GetRecord(Record.DIV_MTCH_PBL)
.GetField(Field.NF_BRL_LINE_NUM).GetShortLabel("NF_BRL_LINE_NUM");
&RULE_LABEL = &RS_MATCH_RULES.GetRow(&I).GetRecord(Record.DIV_MTCH_PBL)
.GetField(Field.MATCH_RULE_ID).GetShortLabel("MATCH_RULE_ID");
&ACTION_LABEL = &RS_MATCH_RULES.GetRow(&I).GetRecord(Record.DIV_MTCH_PB
L).GetField(Field.DIV_ACTN_PBL).GetShortLabel("DIV_ACTN_PBL");
End-If;
/* Regra */
&RULE_ID = &RS_MATCH_RULES.GetRow(&I).GetRecord(Record.DIV_MTCH_PBL).GetFi
eld(Field.MATCH_RULE_ID).Value;
/* Descrio da Regra */
SQLExec("SELECT DESCRLONG FROM PS_MTCH_MSG_VW WHERE MATCH_RULE_ID = :1", &
RULE_ID, &RULE_DESCR);
If &RULE_DESCR = "" Then
SQLExec("SELECT DESCR254 FROM PS_MTCH_SYS_RULES WHERE MATCH_RULE_ID = :
1", &RULE_ID, &RULE_DESCR);
End-If;
/* Action */
&ACTION_ID = &RS_MATCH_RULES.GetRow(&I).GetRecord(Record.DIV_MTCH_PBL).Get
Field(Field.DIV_ACTN_PBL).Value;
/* Action description */
SQLExec("SELECT DESCR FROM PS_DIV_ACTN_PBL WHERE DIV_ACTN_PBL = :1", &ACTI
ON_ID, &ACTION_DESCR);
/* Trata quebra da linha */
If &OLD_LINE_NUM <> &LINE_NUM Then
&OLD_LINE_NUM = &LINE_NUM;
&MATCH_RULES_TXT = &MATCH_RULES_TXT | Char(13) | Char(10) | Char(13) |
Char(10);
&MATCH_RULES_TXT = &MATCH_RULES_TXT | &LINE_LABEL | ": " | String(&LINE
_NUM) | Char(13) | Char(10);
End-If;
&MATCH_RULES_TXT = &MATCH_RULES_TXT | "- " | &RULE_LABEL | ": " | &RULE_ID
| Char(13) | Char(10);
&MATCH_RULES_TXT = &MATCH_RULES_TXT | " " | &RULE_DESCR | Char(13) | Char
(10);
&MATCH_RULES_TXT = &MATCH_RULES_TXT | " " | &ACTION_LABEL | ": " | &ACTIO
N_ID;
&MATCH_RULES_TXT = &MATCH_RULES_TXT | " " | &ACTION_DESCR | Char(13) | Cha
r(10);
&MATCH_RULES_TXT = &MATCH_RULES_TXT | Char(13) | Char(10);
End-For;
&MATCH_RULES_TXT = &MATCH_RULES_TXT | Char(13) | Char(10) | %Datetime | " Use
rID: " | %UserId;
RECV_HD_WRK_PBL.WF_MTCH_SUB_PBL = &SUBJECT;
RECV_HD_WRK_PBL.WF_MTCH_TXT_PBL = &MATCH_RULES_TXT;
If &LINE_NUM > 0 Then
&TEMP = TriggerBusinessEvent(BusProcess."BRLPO_MANAGE_FISCAL_DOC_BP", BusA
ctivity."BRLPO_MAINTAIN_FISCAL_DOC_ACT", BusEvent."Matching Rules");
End-If;
End-Function;
/*************** Main Line *****************/
/* Fabiano Cunha - 21/10/2005 - Adequao verso 7 para 8 - incluso do panelGroup MMC_L
ANC_GAR */
If ((%Component = Component.NF_INFO_PBL Or
%Component = Component.NF_RECV_PBL Or
%Component = Component.MMC_LANC_GAR) And
(FieldChanged(NF_BRL_STATUS) Or
FieldChanged(APPR_STATUS)) And
/*- It sets the DFI approval status according the DFI approval flag and enable/d
isable the business process and approval rule fields */
If (DFI_PBL_APPRVL_FLG = "P") Then
Gray(BUSPROCNAME);
Gray(APPR_RULE_SET);
APPR_STATUS = "A";
Else
UnGray(BUSPROCNAME);
UnGray(APPR_RULE_SET);
APPR_STATUS = "P";
End-If;
/* BRLOC-PO-APP-8.00-15/12/00-END*/
[NF_HDR_BRL.DSCNT_AMT.SavePreChange]
/*******************************************************************************
*******
* Vinicius Montijo Favero - MMC - 11/03/2015 - mmcb.sds5100
*
* Ajuste de Dados Incorretos no Registro ou Faturamento
*
********************************************************************************
*******/
Declare Function valida_somatoria_linhas PeopleCode BUSINESS_UNIT FieldFormula;
/*mmcb.sds5100.L.N*/
/**********mmcb.sds5100.s.n**********/
If %Component = "MMC_NF_ALTERA" Then
&campo = "NF_LN_BRL.DSCNT_AMT";
&tabela = "Record.NF_LN_BRL";
&valor_hdr = DSCNT_AMT;
valida_somatoria_linhas(&tabela, &campo, &valor_hdr);
End-If;
/**********mmcb.sds5100.e.n**********/
[NF_HDR_BRL.DST_CNTRL_ID.SaveEdit]
/*******************************************************************************
*****
* Wagner Sorio - MMC - 17/06/2008 - mmcb.hd50003
*
* Buscar codigo modelo contabil a partir do cadastro do fornecedor.
*
********************************************************************************
*****/
/************************************ mmcb.hd50003 S.N. ************************
****/
Declare Function PEGA_MODELO_CONTABIL PeopleCode PO_HDR.DST_CNTRL_ID SaveEdit;
&VAR_DST_CNTRL_ID = PEGA_MODELO_CONTABIL(VENDOR_ID, VNDR_LOC);
&VAR_DST_CNTRL_ID = PEGA_MODELO_CONTABIL(VENDOR_ID, VNDR_LOC);
If All(&VAR_DST_CNTRL_ID) And
&VAR_DST_CNTRL_ID <> " " And
&VAR_DST_CNTRL_ID <> "" Then
If &VAR_DST_CNTRL_ID <> DST_CNTRL_ID Then
DST_CNTRL_ID = &VAR_DST_CNTRL_ID;
End-If;
End-If;
/************************************ mmcb.hd50003 E.N. ************************
****/
[NF_HDR_BRL.FREIGHT_AMT.FieldChange]
/*******************************************************************************
*******
* Vinicius Montijo Favero - MMC - 11/03/2015 - mmcb.sds5100
*
* Ajuste de Dados Incorretos no Registro ou Faturamento
*
********************************************************************************
*******/
Declare Function Calc_Freight_Amt PeopleCode FUNCLIB_PBL.EXP_PRORATE_PBL FieldFo
rmula;
If %Component <> "MMC_NF_ALTERA" Then /*mmcb.sds5100.L.N*/
If FRGHT_PRORATE_PBL = "A" Then
Calc_Freight_Amt();
End-If;
End-If; /*mmcb.sds5100.L.N*/
[NF_HDR_BRL.FREIGHT_AMT.SavePreChange]
/*******************************************************************************
*******
* Vinicius Montijo Favero - MMC - 11/03/2015 - mmcb.sds5100
*
* Ajuste de Dados Incorretos no Registro ou Faturamento
*
********************************************************************************
*******/
Declare Function valida_somatoria_linhas PeopleCode BUSINESS_UNIT FieldFormula;
/*mmcb.sds5100.L.N*/
/**********mmcb.sds5100.s.n**********/
If %Component = "MMC_NF_ALTERA" Then
&campo = "NF_LN_BRL.FREIGHT_AMT";
&tabela = "Record.NF_LN_BRL";
&valor_hdr = FREIGHT_AMT;
Else
UnGray(FRGHT_PRORATE_PBL);
End-If;
End-For;
/*
UnGrays Freight field if Prorate = "Manual" else
Grays Freight field and Calculate Prorate */
If FRGHT_PRORATE_PBL = "M" Then
UnGray_Freight_Amt();
Else
Gray_Freight_Amt();
Calc_Freight_Amt();
End-If;
/*BRLOC-PO-APP-8.00-10/01/01-END */
End-If;
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-BEGIN-03/04/01 */
End-If
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-END-03/04/01 */
[NF_HDR_BRL.GROSS_AMT.RowInit]
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-23/03/01
No executar o cdigo se o Component = 'DFI_CANCEL_PBL' (Cancelamento de Doc. Fiscal
) ou 'REOPEN_FISCDOC_PBL' (Reabertura de Doc. Fiscal) ou 'DELETE_FISCDOC_PBL' (D
eleo de Doc. Fiscal) ou 'CLOSE_FISCDOC_PBL' (Encerramento de Doc. Fiscal).
*/
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-BEGIN-23/03/01 */
If %Component <> Component.DFI_CANCEL_PBL And
%Component <> Component.REOPEN_FISCDOC_PBL And
%Component <> Component.DELETE_FISCDOC_PBL And
%Component <> Component.CLOSE_FISCDOC_PBL And
%Component <> Component.NF_INQ_PBL And
%Component <> Component.MTCH_INQ_PBL Then
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-END-23/03/01 */
If %Component = Component.NF_RECV_PBL Or
%Component = Component.NF_INFO_PBL Then
If %Mode <> "A" Then
RECV_HD_WRK_PBL.GROSS_AMT_PBL_WRK = GROSS_AMT;
RECV_HD_WRK_PBL.ICMS_AMT_PBL_WRK = ICMSTAX_BRL_AMT;
RECV_HD_WRK_PBL.IPI_AMT_PBL_WRK = IPITAX_BRL_AMT;
End-If;
End-If;
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-BEGIN-23/03/01 */
End-If
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-END-23/03/01 */
[NF_HDR_BRL.ICMSSUB_BRL_AMT.SavePreChange]
/*******************************************************************************
*******
* Vinicius Montijo Favero - MMC - 11/03/2015 - mmcb.sds5100
*
* Ajuste de Dados Incorretos no Registro ou Faturamento
*
********************************************************************************
*******/
Declare Function valida_somatoria_linhas PeopleCode BUSINESS_UNIT FieldFormula;
/*mmcb.sds5100.L.N*/
/**********mmcb.sds5100.s.n**********/
If %Component = "MMC_NF_ALTERA" Then
&campo = "NF_LN_BRL.ICMSSUB_BRL_AMT";
&tabela = "Record.NF_LN_BRL";
&valor_hdr = ICMSSUB_BRL_AMT;
valida_somatoria_linhas(&tabela, &campo, &valor_hdr);
End-If;
/**********mmcb.sds5100.e.n**********/
[NF_HDR_BRL.ICMSSUB_BRL_BSS.FieldChange]
/* BRLOC - PO - MFGO - RESOLUTION ID: 594875 - BEGIN - 20/12/2004 */
/* Cdigo para atualizar o campo ICMSSUB_BRL_BSS na tabela NF_LN_BRL */
&ICMSSUB_BSS = ICMSSUB_BRL_BSS;
&NF_LINE_MAXROW = ActiveRowCount(Record.NF_LN_BRL);
For &NF_LINE_ROW = 1 To &NF_LINE_MAXROW
&ICMSSUB_AMT = FetchValue(NF_LN_BRL.ICMSSUB_BRL_AMT, &NF_LINE_ROW);
If All(&ICMSSUB_AMT) Then
UpdateValue(NF_LN_BRL.ICMSSUB_BRL_BSS, &NF_LINE_ROW, &ICMSSUB_BSS);
End-If;
End-For;
/* BRLOC - PO - MFGO - RESOLUTION ID: 594875 - END - 20/12/2004 */
[NF_HDR_BRL.ICMSTAX_BRL_AMT.FieldChange]
/*******************************************************************************
*******
* Vinicius Montijo Favero - MMC - 11/03/2015 - mmcb.sds5100
*
* Ajuste de Dados Incorretos no Registro ou Faturamento
*
********************************************************************************
*******/
/**********mmcb.sds5100.s.n**********/
If %Component = "MMC_NF_ALTERA" Then
If ICMSTAX_BRL_AMT = 0 Then
For &LINE_ROW = 1 To ActiveRowCount(Record.NF_LN_BRL)
UpdateValue(NF_LN_BRL.ICMSTAX_BRL_PCT, &LINE_ROW, 0);
UpdateValue(NF_LN_BRL.ICMSTAX_BRL_AMT, &LINE_ROW, 0);
UpdateValue(NF_LN_BRL.ICMSTAX_BRL_BSS, &LINE_ROW, 0);
End-For;
End-If;
End-If;
/**********mmcb.sds5100.e.n**********/
[NF_HDR_BRL.ICMSTAX_BRL_AMT.SavePostChange]
/*******************************************************************************
*******
* Vinicius Montijo Favero - MMC - 11/03/2015 - mmcb.sds5100
*
* Ajuste de Dados Incorretos no Registro ou Faturamento
*
********************************************************************************
*******/
Declare Function valida_somatoria_linhas PeopleCode BUSINESS_UNIT FieldFormula;
/*mmcb.sds5100.L.N*/
/**********mmcb.sds5100.s.n**********/
If %Component = "MMC_NF_ALTERA" Then
&campo = "NF_LN_BRL.ICMSTAX_BRL_AMT";
&tabela = "Record.NF_LN_BRL";
&valor_hdr = ICMSTAX_BRL_AMT;
valida_somatoria_linhas(&tabela, &campo, &valor_hdr);
End-If;
/**********mmcb.sds5100.e.n**********/
/*** JEISON CALDAS - ATIV.1993 - 16/02/07 - Validao de ICMS para nfs de remessa da
garantia - Inicio ***/
If %Component = Component.NF_INFO_PBL And
NF_HDR_INFO_WRK.NF_BRL_STATUS = "F" And
ICMSTAX_BRL_AMT > 0 Then
REM VALIDA SE TEM CONTROLE DE GARANTIA;
SQLExec("SELECT A.CUST_ID FROM PS_MMC_VINF_OS_HDR A WHERE A.VENDOR_ID = :1 AN
D A.NF_BRL = :2 AND A.NF_BRL_SERIES = :3", VENDOR_ID, NF_BRL, NF_BRL_SERIES, &CU
ST_ID);
If All(&CUST_ID) Then
REM ATUALIZA O VALOR DA TABELA DE CABEALHO;
SQLExec("SELECT SUM(ICMSTAX_BRL_AMT) FROM PS_MMC_VINF_OS_LN WHERE VENDOR_I
D = :1 AND NF_BRL = :2 AND NF_BRL_SERIES = :3 AND DATA_LIMITE < %DATEIN(:4)", VE
NDOR_ID, NF_BRL, NF_BRL_SERIES, NF_BRL_DATE, &ICMS_GAR);
SQLExec("UPDATE PS_MMC_VINF_OS_HDR SET ICMSTAX_BRL_AMT = :4 WHERE VENDOR_I
D = :1 AND NF_BRL = :2 AND NF_BRL_SERIES = :3", VENDOR_ID, NF_BRL, NF_BRL_SERIES
, &ICMS_GAR);
REM PROCESSO DE INSERO DE LINHA NA GARANTIA;
&FIELDS = "BUSINESS_UNIT, CUST_ID, MMC_CCG_NROS, MMC_CCG_OSSEQ, NF_BRL, NF
_BRL_SERIES, MMC_CCG_LANC_LN, MMC_CCG_PEND_LN, MMC_CCG_DT_LANC, MMC_CCG_DESC_LAN
C, MMC_CCG_COD_LANC, MMC_CCG_VLR_LANC";
&DATA = %Date;
SQLExec("SELECT MAX(MMC_CCG_LANC_LN + 1)FROM PS_MMC_CCG_LANCMTO", &LANC_LN
);
SQLExec("INSERT INTO PS_MMC_CCG_LANCMTO ( " | &FIELDS | ") VALUES (:1, :2,
:3, :4, :5, :6, :7, :8, %DATEIN(:9), :10, :11, :12)", "MMCSA", &CUST_ID, " ", "
", NF_BRL, NF_BRL_SERIES, &LANC_LN, 0, &DATA, "CRED.DE GARANTIA-ICMS REMESSA",
25, :26, :27, :28, :29, %DATEIN(:30), :31, :32, :33, :34, :35, :36, :37, :38, :3
9, :40, :41, :42, :43, :44, :45, %DATEIN(:46), :47, :48";
&VALUES_JRNL_BAL = ":1, :2, %DATEIN(:3), :4, :5, :6, :7, :8, :9, :10, :11,
:12, :13, :14, :15, :16, :17, :18, :19, :20";
/***
BUSCA CONTAS DE CRDITO E DBITO;
***/
SQLExec("SELECT B.ACCOUNT FROM PS_MMC_CCG_CLI_CC A, PS_BANK_ACCT_CHRT B WH
ERE A.BANK_SETID = B.SETID AND A.BANK_CD = B.BANK_CD AND A.BANK_ACCT_KEY = B.BAN
K_ACCT_KEY AND A.BANK_CD = B.BANK_CD_CPTY AND A.BANK_CD = B.COUNTERPARTY AND B.B
ANK_ACCT_LED_TYPE = 'C' AND A.CUST_ID = :1", &HIST4, &ACCOUNT_CRED);
SQLExec("SELECT MMC_CCG_ACCOUNT_D FROM PS_MMC_CCG_PARAMET", &ACCOUNT_DEB);
/***
GERA PROXIMO NUMERO DE JOURNAL_ID
***/
SQLExec("SELECT TO_CHAR(JOURNAL_NUM_ASSIGN +1, '0000000000') FROM PS_INSTA
LLATION_FS", &JOURNAL_ID);
SQLExec("UPDATE PS_INSTALLATION_FS SET JOURNAL_NUM_ASSIGN = JOURNAL_NUM_A
SSIGN + 1");
/***
INSERE CABEALHO
***/
SQLExec("INSERT INTO PS_JRNL_HEADER (" | &CAMPOS_JRNL_HEADER | ") VALUES("
| &VALUES_JRNL_HEADER | ")", "MMCSA", &JOURNAL_ID, &DATA, 0, "MMCSA", "N", &ANO
, &MES, &DATA, "ACTUALS", " ", "N", "N", "", 0, "S", "", 2, ICMSTAX_BRL_AMT, ICM
STAX_BRL_AMT, 0, "CC", NF_BRL, "V", "V", "V", "N", "O", "N", "N", " ", " ", 0, "
", 0, 0, &DATA, 0, &OPERATORID, &DATETIME, " ", "BRL", "BRL", " ", &DATA, 1, 1,
"PNL", " ", " ", &DATA, " ", " ", "N", "V", 1, " ", " ", "", " ", " ", " ", " ")
;
/***
INSERE LINHAS
***/
&ACCOUNT = &ACCOUNT_CRED;
&LEDGER_BAL = "CONTABIL";
For &LN = 1 To 2
&MONETARY_AMOUNT = &MONETARY_AMOUNT * - 1;
SQLExec("INSERT INTO PS_JRNL_LN (" | &CAMPOS_JRNL_LN | ") VALUES(" | &V
ALUES_JRNL_LN | ")", "MMCSA", &JOURNAL_ID, &DATA, 0, &LN, "CONTABIL", &ACCOUNT,
" ", " ", " ", " ", "BRL", " ", &MONETARY_AMOUNT, "N", 0, " ", 0, "CONTA CORRENT
E GARANTIA - ICMS", "0", &DATA, "BRL", " ", &MONETARY_AMOUNT, 1, 1, 0, " ", " ",
&DATA, " ", "PNL", &HIST1, &HIST2, &HIST3, &HIST4, " ", " ", " ", " ", " ", " "
, " ", " ", " ", &DATA, "N", " ");
SQLExec("INSERT INTO PS_JRNL_LN (" | &CAMPOS_JRNL_LN | ") VALUES(" | &V
ALUES_JRNL_LN | ")", "MMCSA", &JOURNAL_ID, &DATA, 0, &LN, "GERENCIAL", &ACCOUNT,
" ", " ", " ", " ", "BRL", " ", &MONETARY_AMOUNT, "N", 0, " ", 0, "CONTA CORREN
TE GARANTIA - ICMS", "0", &DATA, "BRL", " ", &MONETARY_AMOUNT, 1, 1, 0, " ", " "
, &DATA, " ", "PNL", &HIST1, &HIST2, &HIST3, &HIST4, " ", " ", " ", " ", " ", "
", " ", " ", " ", &DATA, "N", " ");
SQLExec("INSERT INTO PS_JRNL_CF_BAL_TBL(" | &CAMPOS_JRNL_BAL | ") VALUE
S(" | &VALUES_JRNL_BAL | ")", "MMCSA", &JOURNAL_ID, &DATA, 0, &LEDGER_BAL, "MMCS
A", "BRL", "BRL", 0, ICMSTAX_BRL_AMT, 0, ICMSTAX_BRL_AMT, 0, ICMSTAX_BRL_AMT, 0,
ICMSTAX_BRL_AMT, 0, 0, 0, 2);
&ACCOUNT = &ACCOUNT_DEB;
&LEDGER_BAL = "GERENCIAL";
End-For;
/*** JEISON CALDAS - ATIV.2434 - 09/11/07 - Contabilizao dos Crditos de ICMS
da Garantia - Fim ***/
End-If;
End-If;
[NF_HDR_BRL.ICMSTAX_BRL_RCVRY.SavePreChange]
/*******************************************************************************
*******
* Vinicius Montijo Favero - MMC - 11/03/2015 - mmcb.sds5100
*
* Ajuste de Dados Incorretos no Registro ou Faturamento
*
********************************************************************************
*******/
Declare Function valida_somatoria_linhas PeopleCode BUSINESS_UNIT FieldFormula;
/*mmcb.sds5100.L.N*/
/**********mmcb.sds5100.s.n**********/
If %Component = "MMC_NF_ALTERA" Then
&campo = "NF_LN_BRL.ICMSTAX_BRL_RCVRY";
&tabela = "Record.NF_LN_BRL";
&valor_hdr = ICMSTAX_BRL_RCVRY;
valida_somatoria_linhas(&tabela, &campo, &valor_hdr);
If ICMSTAX_BRL_RCVRY > ICMSTAX_BRL_AMT Or
IPITAX_BRL_RCVRY > IPITAX_BRL_AMT Or
PIS_AMT_BSE_BBL > PISTAX_BRL_AMT Or
COFINS_AMT_BSE_BBL > COFINSTAX_BRL_AMT Then
Error ("Possui crdito de imposto maior do que o valor tributado!");
End-If;
If ACCOUNTING_DT < NF_BRL_DATE Then
Error ("Data contbil no pode ser menor do que a data da emisso!");
End-If;
End-If;
/**********mmcb.sds5100.e.n**********/
[NF_HDR_BRL.IE_BRL.FieldEdit]
/* BRLOC-BI - IEDV - Localization Release 1
Author: Sylvio A. Brito
Data: 05/02/2001
*/
Declare Function IE_Check PeopleCode IE_BRL FieldFormula;
Evaluate %PanelGroup
When "RECV_PO"
When "NF_INFO_BRL"
&STATE = RECV_HDR_NOPO.STATE;
Break;
When "MMC_LANC_GAR"
STATE = STATE;
Break;
When "RECV_PO_NONE"
STATE = STATE;
Break;
When-Other
&STATE = "";
Break;
End-Evaluate;
If All(IE_BRL) Then
If IE_Check(IE_BRL, &STATE) = False Then
Error MsgGet(31000, 158, "Invalid IE number.");
End-If;
End-If;
/* BRLOC-BI - IEDV */
[NF_HDR_BRL.IE_BRL.FieldFormula]
/* BRLOC-BI - IEDV - Localization Release 1
Author: Sylvio A. Brito
Data: 05/02/2001
Description: Calcula os DVs da IE, e faz validao da IE entrada.
*/
Function IE_CheckSP(&IE) Returns boolean ;
&TAM = Len(&IE);
If &TAM < 12 Then
Return False;
Else
&POS = 0;
&PONT = 0;
&MOLD = "";
&T12 = 0;
&T09 = 0;
For &I = 1 To &TAM
&CH = Substring(&IE, &I, 1);
Evaluate &CH
When "0"
When "1"
When "2"
When "3"
When "4"
When "5"
When "6"
When "7"
When "8"
When "9"
&POS = &POS + 1;
&VL = Value(&CH);
Evaluate &POS
When 1
&T09 = &T09 + (&VL * 1);
&T12 = &T12 + (&VL * 3);
&MOLD = &MOLD | &CH;
Break;
When 2
&T09 = &T09 + (&VL * 3);
&T12 = &T12 + (&VL * 2);
&MOLD = &MOLD | &CH;
Break;
When 3
&T09 = &T09 + (&VL * 4);
&T12 = &T12 + (&VL * 10);
&MOLD = &MOLD | &CH;
Break;
When 4
&T09 = &T09 + (&VL * 5);
&T12 = &T12 + (&VL * 9);
&MOLD = &MOLD | &CH;
Break;
When 5
&T09 = &T09 + (&VL * 6);
&T12 = &T12 + (&VL * 8);
&MOLD = &MOLD | &CH;
Break;
When 6
&T09 = &T09 + (&VL * 7);
&T12 = &T12 + (&VL * 7);
&MOLD = &MOLD | &CH;
Break;
When 7
&T09 = &T09 + (&VL * 8);
&T12 = &T12 + (&VL * 6);
&MOLD = &MOLD | &CH;
Break;
When 8
&T09 = &T09 + (&VL * 10);
&T12 = &T12 + (&VL * 5);
&MOLD = &MOLD | &CH;
Break;
When 9
&T12 = &T12 + (&VL * 4);
&T09 = Mod(&T09, 11);
&CH = Right(RTrim(String(&T09)), 1);
&MOLD = &MOLD | &CH;
Break;
When 10
&T12 = &T12 + (&VL * 3);
&MOLD = &MOLD | &CH;
Break;
When 11
&T12 = &T12 + (&VL * 2);
&MOLD = &MOLD | &CH;
Break;
When 12
&T12 = Mod(&T12, 11);
&CH = Right(RTrim(String(&T12)), 1);
&MOLD = &MOLD | &CH;
Break;
End-Evaluate;
Break;
When "."
If &I <> 4 And
&I <> 8 And
[NF_HDR_BRL.INSURANCE_BRL_AMT.FieldChange]
/*******************************************************************************
*******
* Vinicius Montijo Favero - MMC - 11/03/2015 - mmcb.sds5100
*
* Ajuste de Dados Incorretos no Registro ou Faturamento
*
********************************************************************************
*******/
Declare Function Calc_Other_Exp_Amt PeopleCode FUNCLIB_PBL.EXP_PRORATE_PBL Field
Formula;
Declare Function valida_somatoria_linhas PeopleCode BUSINESS_UNIT FieldFormula;
/*mmcb.sds5100.L.N*/
If %Component <> "MMC_NF_ALTERA" Then /*mmcb.sds5100 l.n*/
/*BRLOC-PO-APP-8.00-02/04/01-BEGIN */
If OTHER_PRORATE_PBL = "A" Then
Calc_Other_Exp_Amt();
End-If;
/*BRLOC-PO-APP-8.00-02/04/01-END */
[NF_HDR_BRL.IPITAX_BRL_AMT.SavePreChange]
/*******************************************************************************
*******
* Vinicius Montijo Favero - MMC - 11/03/2015 - mmcb.sds5100
*
* Ajuste de Dados Incorretos no Registro ou Faturamento
*
********************************************************************************
*******/
Declare Function valida_somatoria_linhas PeopleCode BUSINESS_UNIT FieldFormula;
/*mmcb.sds5100.L.N*/
/**********mmcb.sds5100.s.n**********/
If %Component = "MMC_NF_ALTERA" Then
&campo = "NF_LN_BRL.IPITAX_BRL_AMT";
&tabela = "Record.NF_LN_BRL";
&valor_hdr = IPITAX_BRL_AMT;
valida_somatoria_linhas(&tabela, &campo, &valor_hdr);
End-If;
/**********mmcb.sds5100.e.n**********/
[NF_HDR_BRL.IPITAX_BRL_RCVRY.SavePreChange]
/*******************************************************************************
*******
* Vinicius Montijo Favero - MMC - 11/03/2015 - mmcb.sds5100
*
* Ajuste de Dados Incorretos no Registro ou Faturamento
*
********************************************************************************
*******/
Declare Function valida_somatoria_linhas PeopleCode BUSINESS_UNIT FieldFormula;
/*mmcb.sds5100.L.N*/
/**********mmcb.sds5100.s.n**********/
If %Component = "MMC_NF_ALTERA" Then
&campo = "NF_LN_BRL.IPITAX_BRL_RCVRY";
&tabela = "Record.NF_LN_BRL";
&valor_hdr = IPITAX_BRL_RCVRY;
valida_somatoria_linhas(&tabela, &campo, &valor_hdr);
End-If;
/**********mmcb.sds5100.e.n**********/
[NF_HDR_BRL.ISSTAX_BRL_AMT.FieldChange]
/*** JEISON CALDAS - 25/04/2004 - CUSTOMIZAO CRIAO VOUCHER PARA IMPOSTO S.N. ***/
If %PanelGroup = "MMC_LANC_GAR" Then
If All(ISSTAX_BRL_AMT) And
All(MMC_CCG_WRK.MMC_CCG_NROS) Then
UnGray(MMC_CCG_WRK.MMC_YES_NO);
If MMC_CCG_WRK.MMC_YES_NO <> "S" Then
MMC_CCG_WRK.MMC_YES_NO = "S";
WinMessage("O Flag para gerar voucher para o ISS foi ativado automatica
mente, caso NO seja necessrio gerar o voucher desabilite esta opo!", 48, "Ateno");
End-If;
Else
MMC_CCG_WRK.MMC_YES_NO = "N";
End-If;
End-If;
/*** JEISON CALDAS - 25/04/2004 - CUSTOMIZAO CRIAO VOUCHER PARA IMPOSTO E.N. ***/
[NF_HDR_BRL.LAST_UPDATE_DT.RowInit]
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-24/04/01
Se for um processo de cancelamento, reabertura ou encerramento a LAST_UPDATE_DT
recebe como default a data atual do sistema.
*/
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-BEGIN-24/04/01 */
If %Component = Component.DFI_CANCEL_PBL Or
%Component = Component.REOPEN_FISCDOC_PBL Or
%Component = Component.CLOSE_FISCDOC_PBL Then
LAST_UPDATE_DT = %Date;
End-If;
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-END-24/04/01 */
[NF_HDR_BRL.LAST_UPDATE_DT.SaveEdit]
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-24/04/01
Se for um processo de cancelamento, reabertura ou encerramento a LAST_UPDATE_DT
no pode ser maior que a data do sistema
*/
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-BEGIN-24/04/01 */
If %Component = Component.DFI_CANCEL_PBL Or
%Component = Component.REOPEN_FISCDOC_PBL Or
%Component = Component.CLOSE_FISCDOC_PBL Then
If LAST_UPDATE_DT > %Date Then
Error MsgGet(30000, 192, "Date cannot be bigger than system date!");
End-If;
Else
/* Fabiano Cunha - 28/12/2005 - Adequao da verso 7 para 8 -Colocacao na clausual
component */
If %Component <> Component.DFI_APPROVAL_PBL Then
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-END-24/04/01 */
/* BRLOC PO - APP - 8.00 - 11/12/00 - BEGIN */
LAST_UPDATE_DT = %Date;
/* BRLOC PO - APP - 8.00 - 11/12/00 - END */
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-BEGIN-24/04/01 */
End-If;
End-If;
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-END-24/04/01 */
[NF_HDR_BRL.MERCHANDISE_AMT.SavePreChange]
/*******************************************************************************
*******
* Vinicius Montijo Favero - MMC - 11/03/2015 - mmcb.sds5100
*
* Ajuste de Dados Incorretos no Registro ou Faturamento
*
********************************************************************************
*******/
Declare Function valida_somatoria_linhas PeopleCode BUSINESS_UNIT FieldFormula;
/*mmcb.sds5100.L.N*/
/**********mmcb.sds5100.s.n**********/
If %Component = "MMC_NF_ALTERA" Then
&campo = "NF_LN_BRL.MERCHANDISE_AMT";
&tabela = "Record.NF_LN_BRL";
&valor_hdr = MERCHANDISE_AMT;
valida_somatoria_linhas(&tabela, &campo, &valor_hdr);
End-If;
/**********mmcb.sds5100.e.n**********/
[NF_HDR_BRL.NF_BRL.FieldChange]
/* BRLOC PO - APP - 8.00 - 11/12/00 - BEGIN */
/* - Fatura number, by defualt, is equal to NF number*/
If All(NF_BRL) Then
NF_BRL_FATURA = NF_BRL;
End-If;
/* BRLOC PO - APP - 8.00 - 11/12/00 - END */
[NF_HDR_BRL.NF_BRL.FieldEdit]
Declare Function nf_num_valid_brl PeopleCode ADDRESS_SEQ_NUM FieldEdit;
/* BRLOC PM - 23/JUL/97 - It is not possible to have the same vendor/nf_brl/ser
ies more than once */
/**BRLPO-SHN-DEC-99 - Included validation on CCG Vendor**/
/**** BRLOC-PO-AO-FIX:R-ASIQUE-EP2NX - 11/10/2000 ***/
/**** Substituido codigo de validao pela chamada da funo que ira fazer a validacao *
**/
nf_num_valid_brl();
[NF_HDR_BRL.NF_BRL.RowInit]
/* BRLOC PO - APP - 8.00 - 11/12/00 - BEGIN */
/* - Fatura number, by defualt, is equal to NF number*/
If All(NF_BRL) Then
NF_BRL_FATURA = NF_BRL;
End-If;
/* BRLOC PO - APP - 8.00 - 11/12/00 - END */
[NF_HDR_BRL.NF_BRL.SaveEdit]
Declare Function nf_num_valid_brl PeopleCode FUNCLIB_PBL.VALIDATION_NF_PBL Field
Formula;
/***************************** Begin Localization ****************************
BRLOC-PO-AO-8.00
Author:
Artur M. Oguma
Date:
25/04/2001
Description:
Verifica duplicidade de NF/Serie
----------------------------------------------------------------------------*/
/* BRLPO-FCF-8.01 - 19/03/02 *** ADICIONA NF_BRL_DATE COMO CRITERIO DE VERIFICAO D
E DUPLICIDADE ***/
If %Component = Component.NF_INFO_PBL Or
%Component = Component.NF_RECV_PBL Or
%Component = Component.MMC_LANC_GAR Then
nf_num_valid_brl(NF_HDR_INFO_WRK.CGC_BRL, VENDOR_ID, ADDRESS_SEQ_NUM, NF_BRL,
NF_BRL_SERIES, BUSINESS_UNIT, RECEIVER_ID, NF_BRL_DATE, NF_BRL_ID);
End-If;
[NF_HDR_BRL.NF_BRL_DATE.FieldChange]
If %Component = "NF_INFO_PBL" Then
/*** JC800888 - JEISON CALDAS - 30/07/2006 - Atividade 1713 - Busca primeiro
a parametrizao dentro do cadastro de compras, caso no encontre faz busca original Inicio ***/
SQLExec("SELECT TMG_DAY_INCR_VAL FROM PS_PYMT_TRMS_NET A, PS_PYMT_TRMS_TIME B
WHERE A.SETID = B.SETID AND A.NET_TRMS_TIME_ID = B.PAY_TRMS_TIME_ID AND A.P
YMNT_TERMS_CD = :1", PYMNT_TERMS_CD, &DAY_INCREMENT);
If None(&DAY_INCREMENT) Then
REM Atividade 1713 - FIM;
SQLExec("SELECT C.DAY_INCREMENT FROM PS_PAY_TRMS_TBL A, PS_PAY_TRM_BRL_MU
L B, PS_PAY_TRMS_TIME C WHERE A.PYMNT_TERMS_CD = :1 AND A.SETID = B.SETID AND
A.PYMNT_TERMS_CD = B.PYMNT_TERMS_CD AND B.SEQ_NUM = 1 AND B.SETID = C.SETID AND
B.PYMNT_TRM_BRL_REF = C.PAY_TRMS_TIME_ID", PYMNT_TERMS_CD, &DAY_INCREMENT);
If None(&DAY_INCREMENT) Then
SQLExec("SELECT B.DAY_INCREMENT FROM PS_PAY_TRMS_NET A, PS_PAY_TRMS_TIM
E B WHERE A.SETID = 'MMCSA' AND A.PYMNT_TERMS_CD= :1 AND A.SETID = B.SETID AND
A.PAY_TRMS_TIME_ID = B.PAY_TRMS_TIME_ID", PYMNT_TERMS_CD, &DAY_INCREMENT);
End-If;
End-If;
MMC_TEMP.END_DATE = AddToDate(NF_BRL_DATE, 0, 0, &DAY_INCREMENT);
End-If;
[NF_HDR_BRL.NF_BRL_DATE.RowInit]
/* Criado por Andercio Calasans Junior - Grupo Quanam - 12/07/2006 - Incio */
/*****************************************************************************
Fabiano Cunha - MMC 29/11/2006 - mmcb.HD26773 - A data de Emissao do documento
fiscal quando de notas de terceiros,fica em branco e o sistema usava a data
atual.
******************************************************************************/
Global string &data_emissaoNF; /********* mmcb.HD26773 - l.n ********/
If %Component = Component.NF_INFO_PBL Or
%Component = Component.MMC_TERC Or
%Component = Component.MMC_TERC_OC Or
%Component = Component.MMC_TERC_OC Then
/* Criado por Andercio Calasans Junior - Grupo Quanam - 12/07/2006 - Fim */
End-If;
End-If;
/******************************* mmcb.sds5100 e.n ******************************
*/
[NF_HDR_BRL.NF_BRL_ID.SavePreChange]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 17/12/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Customizao Sistema de Terceiros - Cria numerao NF Terceiros
*
/*******************************************************************************
*****************
* Itamar Junior - MMCB - 03/08/2009 - mmcb.hd70264 - Ajuste para evitar conflit
o numerao NF, *
* quando dois usurios tentam criar registro ao mesmo tempo com mesmo nmero
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Vinicius Montijo Favero - MMC - 11/03/2015 - mmcb.sds5100
*
* Ajuste de Dados Incorretos no Registro ou Faturamento
*
********************************************************************************
*****************/
/********************** mmcb.at2323.sn **********************/
Declare Function MMC_NUMERACAO_ID PeopleCode MMC_NUMERACAO.MMC_NUMERACAO_ID Save
PostChange;
/********************** mmcb.at2323.en **********************/
/*BRLOC - PO - APP - 8.00 - 11/12/00 BEGIN */
Function do_leading_zeros();
&CHECK_NUM = 10;
For &LOOP_NUM = 1 To &FIELD_SIZE
&TEST_NUM = &CHECK_NUM - 1;
If &NF_ID <= &TEST_NUM Then
&CUT_OFF = &FIELD_SIZE - &LOOP_NUM;
&RIGHT_HALF = Right(&NF_CHAR, &LOOP_NUM);
&LEFT_HALF = Rept("0", &CUT_OFF);
NF_BRL_ID = &LEFT_HALF | &RIGHT_HALF;
Break;
Else
&CHECK_NUM = &CHECK_NUM * 10;
End-If;
End-For;
End-Function;
/* Updating NF last used number */
Function do_bu();
End-If;
If FieldChanged(NF_BRL_DATE) Then
SQLExec("Insert into SYSADM.ps_mmc_nf_alt_hdr(BUSINESS_UNIT, NF_BRL_ID, SE
Q_NBR, OPRID, DT_TIMESTAMP,DESCR254, RECNAME, FIELDNAME, OLDVALUE, NEWVALUE, NF_
BRL_LINE_NUM) values (:1,:2,:3,:4,SYSDATE,:5,'NF_HDR_BRL','NF_BRL_DATE',:6,:7,0)
", BUSINESS_UNIT, NF_BRL_ID, &SEQUENCIA, %UserId, MMC_NF_ALT_WRK.DESCR254, NF_HD
R_BRL.NF_BRL_DATE.OriginalValue, NF_BRL_DATE);
End-If;
If FieldChanged(GROSS_AMT) Then
SQLExec("SELECT 'Y' FROM SYSADM.PS_NF_HDR_BRL A WHERE A.BUSINESS_UNIT = :1
AND A.NF_BRL_ID = :2 AND EXISTS (SELECT 'Y' FROM SYSADM.PS_VOUCHER B, SYSADM.PS
_PYMNT_VCHR_XREF C WHERE A.BUSINESS_UNIT = B.BUSINESS_UNIT_PO AND A.NF_BRL_ID =
B.NF_BRL_ID AND B.BUSINESS_UNIT = C.BUSINESS_UNIT AND B.VOUCHER_ID = C.VOUCHER_I
D AND C.PYMNT_ID = ' ' AND B.ENTRY_STATUS <> 'X' AND C.PYMNT_SELCT_STATUS = 'P')
", BUSINESS_UNIT, NF_BRL_ID, &voucher_pago);
SQLExec("SELECT 'Y' FROM SYSADM.PS_VOUCHER WHERE BUSINESS_UNIT_PO = :1 AND
NF_BRL_ID = :2 AND POST_STATUS_AP <> 'P'", BUSINESS_UNIT, NF_BRL_ID, &voucher_n
_cont);
SQLExec("SELECT 'Y' FROM SYSADM.PS_VOUCHER WHERE BUSINESS_UNIT_PO = :1 AND
NF_BRL_ID = :2 AND POST_STATUS_AP = 'P'", BUSINESS_UNIT, NF_BRL_ID, &voucher_co
ntab);
If All(&voucher_pago) Or
All(&voucher_contab) Then
Error ("O valor bruto esta sendo alterado e existe um voucher pago ou c
ontabilizado para essa nota, no possivel realizar a alterao!");
End-If;
If All(&voucher_n_cont) And
None(&voucher_pago) Then
Error ("Voc esta alterando o valor bruto da nota, porm existe voucher par
a ela e o mesmo no foi pago e nem contabilizado, favor entrar em contato com o Co
ntas a pagar e solicitar a excluso do voucher.");
End-If;
SQLExec("Insert into SYSADM.ps_mmc_nf_alt_hdr(BUSINESS_UNIT, NF_BRL_ID, SE
Q_NBR, OPRID, DT_TIMESTAMP,DESCR254, RECNAME, FIELDNAME, OLDVALUE, NEWVALUE, NF_
BRL_LINE_NUM) values (:1,:2,:3,:4,SYSDATE,:5,'NF_HDR_BRL','GROSS_AMT',:6,:7,0)",
BUSINESS_UNIT, NF_BRL_ID, &SEQUENCIA, %UserId, MMC_NF_ALT_WRK.DESCR254, NF_HDR_
BRL.GROSS_AMT.OriginalValue, GROSS_AMT);
End-If;
If FieldChanged(MERCHANDISE_AMT) Then
SQLExec("Insert into SYSADM.ps_mmc_nf_alt_hdr(BUSINESS_UNIT, NF_BRL_ID, SE
Q_NBR, OPRID, DT_TIMESTAMP,DESCR254, RECNAME, FIELDNAME, OLDVALUE, NEWVALUE, NF_
BRL_LINE_NUM) values (:1,:2,:3,:4,SYSDATE,:5,'NF_HDR_BRL','MERCHANDISE_AMT',:6,:
7,0)", BUSINESS_UNIT, NF_BRL_ID, &SEQUENCIA, %UserId, MMC_NF_ALT_WRK.DESCR254, N
F_HDR_BRL.MERCHANDISE_AMT.OriginalValue, MERCHANDISE_AMT);
End-If;
If FieldChanged(FREIGHT_AMT) Then
End-If;
If FieldChanged(PISTAX_BRL_AMT) Then
SQLExec("Insert into SYSADM.ps_mmc_nf_alt_hdr(BUSINESS_UNIT, NF_BRL_ID, SE
Q_NBR, OPRID, DT_TIMESTAMP,DESCR254, RECNAME, FIELDNAME, OLDVALUE, NEWVALUE, NF_
BRL_LINE_NUM) values (:1,:2,:3,:4,SYSDATE,:5,'NF_HDR_BRL','PISTAX_BRL_AMT',:6,:7
,0)", BUSINESS_UNIT, NF_BRL_ID, &SEQUENCIA, %UserId, MMC_NF_ALT_WRK.DESCR254, NF
_HDR_BRL.PISTAX_BRL_AMT.OriginalValue, PISTAX_BRL_AMT);
End-If;
If FieldChanged(COFINSTAX_BRL_AMT) Then
SQLExec("Insert into SYSADM.ps_mmc_nf_alt_hdr(BUSINESS_UNIT, NF_BRL_ID, SE
Q_NBR, OPRID, DT_TIMESTAMP,DESCR254, RECNAME, FIELDNAME, OLDVALUE, NEWVALUE, NF_
BRL_LINE_NUM) values (:1,:2,:3,:4,SYSDATE,:5,'NF_HDR_BRL','COFINSTAX_BRL_AMT',:6
,:7,0)", BUSINESS_UNIT, NF_BRL_ID, &SEQUENCIA, %UserId, MMC_NF_ALT_WRK.DESCR254,
NF_HDR_BRL.COFINSTAX_BRL_AMT.OriginalValue, COFINSTAX_BRL_AMT);
End-If;
If FieldChanged(ICMSTAX_BRL_RCVRY) Then
SQLExec("Insert into SYSADM.ps_mmc_nf_alt_hdr(BUSINESS_UNIT, NF_BRL_ID, SE
Q_NBR, OPRID, DT_TIMESTAMP,DESCR254, RECNAME, FIELDNAME, OLDVALUE, NEWVALUE, NF_
BRL_LINE_NUM) values (:1,:2,:3,:4,SYSDATE,:5,'NF_HDR_BRL','ICMSTAX_BRL_RCVRY',:6
,:7,0)", BUSINESS_UNIT, NF_BRL_ID, &SEQUENCIA, %UserId, MMC_NF_ALT_WRK.DESCR254,
NF_HDR_BRL.ICMSTAX_BRL_RCVRY.OriginalValue, ICMSTAX_BRL_RCVRY);
End-If;
If FieldChanged(IPITAX_BRL_RCVRY) Then
SQLExec("Insert into SYSADM.ps_mmc_nf_alt_hdr(BUSINESS_UNIT, NF_BRL_ID, SE
Q_NBR, OPRID, DT_TIMESTAMP,DESCR254, RECNAME, FIELDNAME, OLDVALUE, NEWVALUE, NF_
BRL_LINE_NUM) values (:1,:2,:3,:4,SYSDATE,:5,'NF_HDR_BRL','IPITAX_BRL_RCVRY',:6,
:7,0)", BUSINESS_UNIT, NF_BRL_ID, &SEQUENCIA, %UserId, MMC_NF_ALT_WRK.DESCR254,
NF_HDR_BRL.IPITAX_BRL_RCVRY.OriginalValue, IPITAX_BRL_RCVRY);
End-If;
If FieldChanged(PIS_AMT_BSE_BBL) Then
SQLExec("Insert into SYSADM.ps_mmc_nf_alt_hdr(BUSINESS_UNIT, NF_BRL_ID, SE
Q_NBR, OPRID, DT_TIMESTAMP,DESCR254, RECNAME, FIELDNAME, OLDVALUE, NEWVALUE, NF_
BRL_LINE_NUM) values (:1,:2,:3,:4,SYSDATE,:5,'NF_HDR_BRL','PIS_AMT_BSE_BBL',:6,:
7,0)", BUSINESS_UNIT, NF_BRL_ID, &SEQUENCIA, %UserId, MMC_NF_ALT_WRK.DESCR254, N
F_HDR_BRL.PIS_AMT_BSE_BBL.OriginalValue, PIS_AMT_BSE_BBL);
End-If;
If FieldChanged(COFINS_AMT_BSE_BBL) Then
SQLExec("Insert into SYSADM.ps_mmc_nf_alt_hdr(BUSINESS_UNIT, NF_BRL_ID, SE
Q_NBR, OPRID, DT_TIMESTAMP,DESCR254, RECNAME, FIELDNAME, OLDVALUE, NEWVALUE, NF_
BRL_LINE_NUM) values (:1,:2,:3,:4,SYSDATE,:5,'NF_HDR_BRL','COFINS_AMT_BSE_BBL',:
6,:7,0)", BUSINESS_UNIT, NF_BRL_ID, &SEQUENCIA, %UserId, MMC_NF_ALT_WRK.DESCR254
, NF_HDR_BRL.COFINS_AMT_BSE_BBL.OriginalValue, COFINS_AMT_BSE_BBL);
End-If;
FREIGHT_AMT_BSE = FREIGHT_AMT;
INSURANCE_BRL_BSE = INSURANCE_BRL_AMT;
OTHEREXP_BRL_BSE = OTHEREXP_BRL_AMT;
DSCNT_AMT_BSE = DSCNT_AMT;
ICMSSUB_BRL_BSE = ICMSSUB_BRL_AMT;
&TOTAL = 0;
For &LINE_ROW = 1 To ActiveRowCount(Record.NF_LN_BRL)
&linha = FetchValue(NF_LN_BRL.ICMSTAX_BRL_BSS, &LINE_ROW);
&TOTAL = &TOTAL + &linha;
End-For;
ICMSTAX_BRL_BSS = &TOTAL;
&TOTAL2 = 0;
For &LINE_ROW2 = 1 To ActiveRowCount(Record.NF_LN_BRL)
&linha2 = FetchValue(NF_LN_BRL.PIS_BSS_AMT_BBL, &LINE_ROW2);
&TOTAL2 = &TOTAL2 + &linha2;
End-For;
PIS_BSS_AMT_BBL = &TOTAL2;
&TOTAL3 = 0;
For &LINE_ROW3 = 1 To ActiveRowCount(Record.NF_LN_BRL)
&linha3 = FetchValue(NF_LN_BRL.COFINS_BSS_AMT_BBL, &LINE_ROW3);
&TOTAL3 = &TOTAL3 + &linha3;
End-For;
COFINS_BSS_AMT_BBL = &TOTAL3;
&TOTAL4 = 0;
For &LINE_ROW4 = 1 To ActiveRowCount(Record.NF_LN_BRL)
&linha4 = FetchValue(NF_LN_BRL.ICMSSUB_BRL_BSS, &LINE_ROW4);
&TOTAL4 = &TOTAL4 + &linha4;
End-For;
ICMSSUB_BRL_BSS = &TOTAL4;
&VALIDA_NOTA_EXISTE = "N";
SQLExec("select 'Y' from sysadm.ps_nf_hdr_brl WHERE NF_BRL = :1 AND NF_BRL_SE
RIES = :2 AND REMIT_VENDOR = :3 AND REMIT_ADDR_SEQ_NUM = :4 AND NF_BRL_ID <> :5"
, NF_BRL, NF_BRL_SERIES, REMIT_VENDOR, REMIT_ADDR_SEQ_NUM, NF_BRL_ID, &VALIDA_NO
TA_EXISTE);
If &VALIDA_NOTA_EXISTE = "Y" Then
Error ("J existe uma nota com esse numero e serie para esse fornecedor.");
End-If;
End-If;
/******************************* mmcb.sds5100 e.n ******************************
*/
[NF_HDR_BRL.NF_BRL_SERIES.FieldEdit]
Declare Function nf_num_valid_brl PeopleCode ADDRESS_SEQ_NUM FieldEdit;
/* BRLOC PM - 23/JUL/97 - It is not possible to have the same vendor/nf_brl/seri
es more than once */
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Wagner Sorio - MMC - 06/12/2010 - mmcb.sds3627
*
* Folha Autonomo
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Mauri Rodrigo Back - MMC - 22/12/2011 - mmcb.sds4041
*
* Grava os dados de redespacho para notas fiscais filhotes de importao
*
* GKO.
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Vinicius Montijo Favero - MMC - 03/07/2014 - mmcb.sds4827
*
* Criao de tela de recebimento de DANFE
*
* Quando o documento for excluido ser limpado os dados referentes na tabela MMC_
REC_DANF
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Vincius Alves Mello - MMC - mmcb.sds5322 - 06/08/2015
*
* Estornar baixa controle de terceiros em nosso poder, referente a NF de sada vi
nculda
*
* anula sada.
*
*******************************************************************************
*****************/
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange; /* mmc
b.sds4041.ln */
/******************************** mmcb.sds3627.S.N *****************************
*****/
Declare Function CANCELA_NOTA_RPA PeopleCode MMC_RPA_WK.FUNCLIB SavePostChange;
/******************************** mmcb.sds3627.E.N *****************************
*****/
/********************** mmcb.at2323.sn **********************/
Declare Function CANCELA_NF_TERCEIRO PeopleCode MMC_TE_WRK.FUNCLIB SavePostChang
e;
If %Component = Component.DELETE_FISCDOC_PBL Or
%Component = Component.DFI_CANCEL_PBL Then
&MMC_TE_OPERACAO = " ";
as linhas
= "";
= &DELETE
= &DELETE
= &DELETE
= &DELETE
= &DELETE
= &DELETE
= &DELETE
= &DELETE
"DELETE ";
"FROM PS_MMC_TE_CONTR_MT ";
"WHERE ( BUSINESS_UNIT ";
"
, NF_BRL_ID ";
"
, NF_BRL_LINE_NUM ";
"
, DT_TIMESTAMP ";
"
, SEQ_NBR
) IN ( ";
"
SELECT BUSINESS_UNI
T ";
&DELETE = &DELETE | "
&DELETE = &DELETE | "
,
,
NF_BRL_ID ";
NF_BRL_LINE_
DT_TIMESTAMP
,
SEQ_NBR ";
FROM PS_MMC_NFD_ECT
WHERE MMC_NFR_BU =
AND
NUM ";
";
NP ";
:1 ";
MMC_NFR_ID =
:2 ";
&DELETE = &DELETE | "
SQLExec(&DELETE, BUSINESS_UNIT, NF_BRL_ID);
) ";
End-If;
/******************************** mmcb.sds3627.E.N *****************************
*****/
/************************************ mmcb.sds4041.sn **************************
**********/
If (%Component = Component.NF_INFO_PBL Or
%Component = Component.NF_RECV_PBL) And
NF_BRL_STATUS = "F" And
INOUT_FLG_PBL = "I" Then
&SETID = BUSCA_SETID();
&OF_NF_FILHA = "N";
&N1 = GetLevel0()(1).GetRowset(Scroll.NF_LN_BRL);
For &LN = 1 To &N1.ActiveRowCount;
&OF_FILHA = &N1.GetRow(&LN).GetRecord(Record.NF_LN_BRL).TOF_PBL.VALUE;
End-For;
SQLExec("SELECT 'Y' FROM SYSADM.PS_MMC_TOF_NF_FIL WHERE TOF_PBL = :1", &OF_FI
LHA, &OF_NF_FILHA);
If &OF_NF_FILHA = "Y" Then
&UF_EX = "N";
SQLExec("SELECT 'Y' FROM SYSADM.PS_VENDOR_ADDR B WHERE B.SETID =:1 AND B.V
ENDOR_ID =:2 AND B.ADDRESS_SEQ_NUM =:3 AND B.EFFDT = (SELECT MAX(B_ED.EFFDT) FRO
M SYSADM.PS_VENDOR_ADDR B_ED WHERE B.SETID = B_ED.SETID AND B.VENDOR_ID = B_ED.V
ENDOR_ID AND B.ADDRESS_SEQ_NUM = B_ED.ADDRESS_SEQ_NUM) AND B.STATE = 'EX'", &SET
ID, VENDOR_ID, ADDRESS_SEQ_NUM, &UF_EX);
If &UF_EX = "Y" Then
SQLExec("SELECT I.CARRIER_ID,TRIM(C.W6_URF_ENT),1 FROM SYSADM.SF1010 A,
SYSADM.SW6010 C, SYSADM.SA4010 D, SYSADM.PS_CARRIER_ID I, SYSADM.PS_CAR_ID_NBRS
_BBL B WHERE A.F1_FILIAL = '01' AND A.F1_DOC LIKE '%' ||TRIM(:1)|| '%' AND A.F1_
SERIE LIKE '%' ||TRIM(:2)|| '%' AND A.F1_FORNECE LIKE '%'|| TRIM(:3) || '%' AND
A.D_E_L_E_T_ = ' ' AND C.W6_FILIAL = ' ' AND C.W6_HAWB = A.F1_HAWB AND C.D_E_L_E
_T_ = ' ' AND D.A4_FILIAL = ' ' AND D.A4_COD = C.W6_TRANNAC AND D.D_E_L_E_T_ = '
' AND I.SETID =:4 AND I.SETID = B.SETID AND I.CARRIER_ID = B.CARRIER_ID AND I.E
FFDT = (SELECT MAX(EFFDT) FROM SYSADM.PS_CARRIER_ID CI WHERE CI.SETID = I.SETID
AND I.CARRIER_ID = CI.CARRIER_ID AND CI.EFFDT <= SYSDATE) AND B.EFFDT =(SELECT M
AX(EFFDT) FROM SYSADM.PS_CARRIER_ID CI WHERE CI.SETID = I.SETID AND I.CARRIER_ID
= CI.CARRIER_ID AND CI.EFFDT <= SYSDATE) AND B.STD_ID_NUM_QUAL = 'CNJ' AND REPL
ACE(REPLACE(REPLACE(B.STD_ID_NUM,'.',''),'-',''),'/','') = TRIM(D.A4_CGC)", NF_B
RL, NF_BRL_SERIES, VENDOR_ID, &SETID, &REDESP_CARRIER_ID, &MMC_GKO_PORTO, &LINHA
_REDESPACHO);
If &LINHA_REDESPACHO = 1 Then
SQLExec("DELETE SYSADM.PS_MMC_GKO_REDESP WHERE BUSINESS_UNIT = :1 AN
D NF_BRL_ID = :2", BUSINESS_UNIT, NF_BRL_ID);
If &MMC_GKO_PORTO = "" Then
**********/
/************************************ mmcb.sds4827.sn **************************
**********/
If %Component = Component.DELETE_FISCDOC_PBL Or
%Component = Component.DFI_CANCEL_PBL Then
SQLExec("SELECT 'Y' FROM SYSADM.PS_MMC_REC_DANF WHERE NF_BRL_ID = :1 and BUSI
NESS_UNIT_RECV = :2", NF_BRL_ID, BUSINESS_UNIT, &ret_rec_danfe);
If &ret_rec_danfe = "Y" Then
SQLExec("UPDATE SYSADM.PS_MMC_REC_DANF SET BUSINESS_UNIT_RECV = ' ', NF_BR
L_ID = ' ', RECEIPT_DT = NULL, REC_DANF_STATUS = 'PND' WHERE BUSINESS_UNIT_RECV
= :1 AND NF_BRL_ID = :2", BUSINESS_UNIT, NF_BRL_ID);
End-If;
End-If;
/************************************ mmcb.sds4827.en **************************
**********/
[NF_HDR_BRL.NF_BRL_STATUS.SavePreChange]
/*******************************************************************************
**********
* Claudio Henrique da Costa - MMC - 03/08/2007 - mmcb.at1791
*
* Alterao para no permitir salvar Recebimento como concluido se a OC no estiver
*
* aprovada.
*
*******************************************************************************
**********/
If %Component <> "DELETE_FISCDOC_PBL" Then
SQLExec("SELECT PH.PO_STATUS FROM SYSADM.PS_NF_LN_BRL NL, SYSADM.PS_PO_HDR PH
WHERE NL.BUSINESS_UNIT = :1 AND NL.NF_BRL_ID = :2 AND NL.BUSINESS_UNIT_PO = PH.
BUSINESS_UNIT AND NL.PO_ID = PH.PO_ID ", BUSINESS_UNIT, NF_BRL_ID, &EXISTE_PO_N
_APROV);
If (All(&EXISTE_PO_N_APROV) And
(&EXISTE_PO_N_APROV <> "D")) Then
Error ("VERIFIQUE STATUS DA(S) ORDEM(S) DE COMPRA(S) - ORDEM(S) AINDA NO DE
SPACHADA(S). ")
End-If;
End-If;
[NF_HDR_BRL.NF_BRL_TTL_LINES.FieldDefault]
/* BRLOC - PO - 8.00 - NAS - 27/09/2001 - BEGIN */
/* The total of the lines of the FD must be changed to '1' when a new FD is crea
ted by the typewriter (this number has impact on FD Archival process) */
/* FABIANO CUNHA - 21/10/2005 - Adequaao da verso 7 para 8 */
If %Mode = "A" And
%Component = Component.NF_INFO_PBL Or
%Component = Component.MMC_LANC_GAR Then
NF_BRL_TTL_LINES = 1;
End-If;
/* BRLOC - PO - 8.00 - NAS - 27/09/2001 - END */
[NF_HDR_BRL.NF_BRL_TYPE.FieldChange]
/*Declare Function Calc_SumToHeader PeopleCode RECV_HD_WRK_PBL.NF_SUG_CALC_PBL_P
B FieldChange;
Declare Function Calc_Gross_Amt PeopleCode RECV_HD_WRK_PBL.NF_SUG_CALC_PBL_PB Fi
eldChange;*/
Local Rowset &RS_NF_LN_BRL, &RS_BRL_DISTRIB;
Local number &ROW_LN, &ROW_DS;
/* BRLOC - PO - APP - 8.00 - 09/01/01 - BEGIN */
/* Disponibiliza o painel de notas fiscais relacionadas e
Trata campos de Nota Fiscal se o documento no de transporte */
Function gray_trsp_data();
/* Cleans transportation data */
SetDefault(TRANSPORT_CD);
SetDefault(TRANSPORT_MODE);
SetDefault(NAME1);
SetDefault(ZIP);
SetDefault(ADDRESS1);
SetDefault(ADDRESS2);
SetDefault(CITY);
SetDefault(STATE);
SetDefault(CGC_BRL);
SetDefault(IE_BRL);
SetDefault(TRADE_VOL_BRL);
SetDefault(NUM_VOL_BRL);
SetDefault(TYPE_VOL_BRL);
SetDefault(QTY_VOL_BRL);
SetDefault(GROSS_WEIGHT_BRL);
SetDefault(NET_WEIGHT_BRL);
SetDefault(UOM_WEIGHT);
SetDefault(FREIGHT_PAY_BY_BRL);
SetDefault(LICENCE_PLATE_BRL);
/* Grays transportation data */
Gray(TRANSPORT_CD);
Gray(TRANSPORT_MODE);
Gray(NAME1);
Gray(ZIP);
Gray(ADDRESS1);
Gray(ADDRESS2);
Gray(CITY);
Gray(STATE);
Gray(CGC_BRL);
Gray(IE_BRL);
Gray(TRADE_VOL_BRL);
Gray(NUM_VOL_BRL);
Gray(TYPE_VOL_BRL);
Gray(QTY_VOL_BRL);
Gray(GROSS_WEIGHT_BRL);
Gray(NET_WEIGHT_BRL);
Gray(UOM_WEIGHT);
Gray(FREIGHT_PAY_BY_BRL);
Gray(LICENCE_PLATE_BRL);
End-Function;
Function ungray_trsp_data();
Function Gray_hdr_ICMSSUB_data();
SetDefault(ICMSSUB_BRL_AMT);
SetDefault(ICMSSUB_BRL_BSS);
SetDefault(ICMSSUB_BRL_BSE);
Gray(ICMSSUB_BRL_AMT);
Gray(ICMSSUB_BRL_BSS);
Gray(ICMSSUB_BRL_BSE);
End-Function;
Function UnGray_hdr_ICMSSUB_data();
UnGray(ICMSSUB_BRL_AMT);
UnGray(ICMSSUB_BRL_BSS);
UnGray(ICMSSUB_BRL_BSE);
End-Function;
Function gray_line_data(&ROW1);
/* Cleans line fields */
UpdateValue(NF_LN_BRL.TAX_CLASS_BRL, &ROW1, "");
UpdateValue(NF_LN_BRL.IPITAX_BRL_PCT, &ROW1, 0);
UpdateValue(NF_LN_BRL.IPITAX_BRL_AMT, &ROW1, 0);
UpdateValue(NF_LN_BRL.IPITAX_BRL_BSS, &ROW1, 0);
UpdateValue(NF_LN_BRL.TAX_TYPE_BRL, &ROW1, "");
UpdateValue(NF_LN_BRL.IPI_CRLIM_PCT_PBL, &ROW1, 0);
UpdateValue(NF_LN_BRL.IPI_EXTCR_PCT_PBL, &ROW1, 0);
UpdateValue(NF_LN_BRL.FREIGHT_AMT, &ROW1, 0);
UpdateValue(NF_LN_BRL.INSURANCE_BRL_AMT, &ROW1, 0);
UpdateValue(NF_LN_BRL.OTHEREXP_BRL_AMT, &ROW1, 0);
UpdateValue(NF_LN_BRL.ICMS_COMPL_FLG_PBL, &ROW1, "N");
/* Grays line fields */
Gray(NF_LN_BRL.TAX_CLASS_BRL, &ROW1);
Gray(NF_LN_BRL.IPITAX_BRL_PCT, &ROW1);
Gray(NF_LN_BRL.IPITAX_BRL_AMT, &ROW1);
Gray(NF_LN_BRL.IPITAX_BRL_BSS, &ROW1);
Gray(NF_LN_BRL.TAX_TYPE_BRL, &ROW1);
Gray(NF_LN_BRL.IPI_CRLIM_PCT_PBL, &ROW1);
Gray(NF_LN_BRL.IPI_EXTCR_PCT_PBL, &ROW1);
Gray(NF_LN_BRL.FREIGHT_AMT, &ROW1);
Gray(NF_LN_BRL.INSURANCE_BRL_AMT, &ROW1);
Gray(NF_LN_BRL.OTHEREXP_BRL_AMT, &ROW1);
Gray(NF_LN_BRL.ICMS_COMPL_FLG_PBL, &ROW1);
End-Function;
Function ungray_line_data(&ROW1);
/* Ungrays line fields */
UnGray(NF_LN_BRL.TAX_CLASS_BRL, &ROW1);
UnGray(NF_LN_BRL.IPITAX_BRL_PCT, &ROW1);
UnGray(NF_LN_BRL.IPITAX_BRL_AMT, &ROW1);
UnGray(NF_LN_BRL.IPITAX_BRL_BSS, &ROW1);
UnGray(NF_LN_BRL.TAX_TYPE_BRL, &ROW1);
UnGray(NF_LN_BRL.IPI_CRLIM_PCT_PBL, &ROW1);
UnGray(NF_LN_BRL.IPI_EXTCR_PCT_PBL, &ROW1);
UnGray(NF_LN_BRL.ICMS_COMPL_FLG_PBL, &ROW1);
If FRGHT_PRORATE_PBL = "M" Then
UnGray(NF_LN_BRL.FREIGHT_AMT, &ROW1);
End-If;
If OTHER_PRORATE_PBL = "M" Then
UnGray(NF_LN_BRL.INSURANCE_BRL_AMT, &ROW1);
UnGray(NF_LN_BRL.OTHEREXP_BRL_AMT, &ROW1);
End-If;
End-Function;
Function Gray_Line_ICMSSUB_Data(&ROW1);
UpdateValue(NF_LN_BRL.ICMSSUB_BRL_AMT, &ROW1, 0);
Gray(NF_LN_BRL.ICMSSUB_BRL_AMT, &ROW1);
End-Function;
Function UnGray_Line_ICMSSUB_Data(&ROW1);
UnGray(NF_LN_BRL.ICMSSUB_BRL_AMT, &ROW1);
End-Function;
Function gray_acctg_data(&ROW1, &ROW2);
/*** BRLOC-PO-AO-24/04/2002 - ICE Resolution 100957 - Alterado de MERCHANDISE
_AMT para MERCH_ORIG_AMT_PBL **/
/* Cleans accounting fields */
UpdateValue(Record.NF_LN_BRL, &ROW1, BRL_DISTRIB_LN.MERCH_ORIG_AMT_PBL, &ROW2
, 0);
UpdateValue(Record.NF_LN_BRL, &ROW1, BRL_DISTRIB_LN.ACCOUNT, &ROW2, "");
UpdateValue(Record.NF_LN_BRL, &ROW1, BRL_DISTRIB_LN.DEPTID, &ROW2, "");
UpdateValue(Record.NF_LN_BRL, &ROW1, BRL_DISTRIB_LN.PRODUCT, &ROW2, "");
UpdateValue(Record.NF_LN_BRL, &ROW1, BRL_DISTRIB_LN.PROJECT_ID, &ROW2, "");
/* Grays accounting fields */
Gray(Record.NF_LN_BRL, &ROW1, BRL_DISTRIB_LN.MERCH_ORIG_AMT_PBL, &ROW2);
Gray(Record.NF_LN_BRL, &ROW1, BRL_DISTRIB_LN.ACCOUNT, &ROW2);
Gray(Record.NF_LN_BRL, &ROW1, BRL_DISTRIB_LN.DEPTID, &ROW2);
Gray(Record.NF_LN_BRL, &ROW1, BRL_DISTRIB_LN.PRODUCT, &ROW2);
Gray(Record.NF_LN_BRL, &ROW1, BRL_DISTRIB_LN.PROJECT_ID, &ROW2);
End-Function;
Function ungray_acctg_data(&ROW1, &ROW2);
/*** BRLOC-PO-AO-24/04/2002 - ICE Resolution 100957 - Alterado de MERCHANDISE
_AMT para MERCH_ORIG_AMT_PBL **/
/* Ungrays accounting fields */
UnGray(Record.NF_LN_BRL, &ROW1, BRL_DISTRIB_LN.MERCH_ORIG_AMT_PBL, &ROW2);
UnGray(Record.NF_LN_BRL, &ROW1, BRL_DISTRIB_LN.ACCOUNT, &ROW2);
UnGray(Record.NF_LN_BRL, &ROW1, BRL_DISTRIB_LN.DEPTID, &ROW2);
UnGray(Record.NF_LN_BRL, &ROW1, BRL_DISTRIB_LN.PRODUCT, &ROW2);
UnGray(Record.NF_LN_BRL, &ROW1, BRL_DISTRIB_LN.PROJECT_ID, &ROW2);
End-Function;
/****************************** Main Program *****************************/
If NF_TYPE_BRL.NF_BRL_TYPE_FLG <> "Y" Then
Gray(RECV_HD_WRK_PBL.NF_MULTI_BRL_PB);
Else
/* BRLPO-HAT-8.01-10/07/01 - Alterado para NF_TYPE_BRL.NF_BRL_TYPE_FLG - tof
por linha */
/* If TOF_TYPE_PBL.TOF_VOUCHER_PBL = "N" Then */
If NF_TYPE_BRL.NF_BRL_TYPE_FLG = "N" Then
/* BRLPO-HAT-8.01-10/07/01 - END */
Gray(RECV_HD_WRK_PBL.NF_MULTI_BRL_PB);
Else
UnGray(RECV_HD_WRK_PBL.NF_MULTI_BRL_PB);
End-If;
/*Sum to Header some fields from Recv Line Ship
Calc_SumToHeader();
/* Calculates Gross Amount
Calc_Gross_Amt();*/
End-If;
/* BRLOC-PO-SAM-Release 8-14/09/2001-SAOKI-3J9WQ-NEW-BEGIN */
If NF_TYPE_BRL.DOC_CLASS_BBL = "CT" Then
gray_trsp_data();
gray_hdr_data();
If NF_TYPE_BRL.NF_BRL_SUBST_FLG = "Y" Then
Gray_hdr_ICMSSUB_data();
Else
UnGray_hdr_ICMSSUB_data();
End-If;
For &I = 1 To ActiveRowCount(Record.NF_LN_BRL);
gray_line_data(&I);
If NF_TYPE_BRL.NF_BRL_SUBST_FLG = "Y" Then
Gray_Line_ICMSSUB_Data(&I);
Else
UnGray_Line_ICMSSUB_Data(&I);
End-If;
End-For;
Else
ungray_trsp_data();
ungray_hdr_data();
UnGray_hdr_ICMSSUB_data();
For &I = 1 To ActiveRowCount(Record.NF_LN_BRL);
ungray_line_data(&I);
UnGray_Line_ICMSSUB_Data(&I);
End-For;
End-If;
/* BRLOC-PO-SAM-Release 8-14/09/2001-SAOKI-3J9WQ-NEW-END */
/*BRLOC-PO - HAT - Takes InterUnit Flag value from nf type. */
INTERUNIT_FLG = NF_TYPE_BRL.INTERUNIT_FLG;
/*BRLOC-PO- HAT - END*/
/* BRLOC - PO - NAS - 8.00 - 03/09/01 - BEGIN */
If INTERUNIT_FLG = "Y" Then
UnHide(BUSINESS_UNIT_IN);
Else
Hide(BUSINESS_UNIT_IN);
End-If;
/* BRLOC - PO - NAS - 8.00 - 03/09/01 - END */
/*** BRLOC-PO-AO-24/07/2001 - Habilita/desabilita link para ajuste de custo
********************************************************************************
******/
If NF_TYPE_BRL.ADJ_COST_FLG_PBL = "Y" Then
&ADJ_COST = True;
Else
&ADJ_COST = False;
End-If;
&RS_NF_LN_BRL = GetRowset().GetRow(1).GetRowset(Scroll.NF_LN_BRL);
For &ROW_LN = 1 To &RS_NF_LN_BRL.ActiveRowCount
&RS_BRL_DISTRIB = &RS_NF_LN_BRL(&ROW_LN).GetRowset(Scroll.BRL_DISTRIB_LN);
For &ROW_DS = 1 To &RS_BRL_DISTRIB.ActiveRowCount
&RS_BRL_DISTRIB(&ROW_DS).NF_DIST_PBL_WRK.NF_GOTO_INV_PBL.Enabled = &ADJ_CO
ST;
End-For;
End-For;
*****
* Wagner Sorio - MMC - 01/12/2008 - mmcb.hd59717
*
* Adicinar o criterio nf_brl_date na verificao Documento Fiscal existe.
*
********************************************************************************
****/
/******************************************************************************
*Rafael Taveira - MMC - 22/05/2012 - mmcb.sds3808
*Verifica se o usurio tem permisso para salvar o documento
*******************************************************************************
******/
/**** INICIO - AUGUSTO VILARINHO NETO - 24/11/2005 - Verifica se existe o docum
ento fiscal para o fornecedor especificado ****/
If %Component = Component.NF_INFO_PBL Then
/**** Atualmente No Considera a data de emissao do documento fiscal - para evi
tar de erros na entrada de dados ****/
/********************************************* mmcb.hd59717.so **************
*******************************/
/*
SQLExec("SELECT 'X' FROM PS_NF_HDR_BRL WHERE VENDOR_ID = :1 AND NF_BRL = :2 A
ND NF_BRL_SERIES = :3 AND NF_BRL_ID <> :4 AND ADDRESS_SEQ_NUM = :5 AND NF_BRL_ST
ATUS <> 'X'", VENDOR_ID, NF_BRL, NF_BRL_SERIES, NF_BRL_ID, ADDRESS_SEQ_NUM, &RET
URN);
*/
/********************************************* mmcb.hd59717.eo **************
*******************************/
/********************************************* mmcb.hd59717.sn **************
*******************************/
SQLExec("SELECT 'X' FROM PS_NF_HDR_BRL WHERE VENDOR_ID = :1 AND NF_BRL = :2 A
ND NF_BRL_SERIES = :3 AND NF_BRL_ID <> :4 AND ADDRESS_SEQ_NUM = :5 AND NF_BRL_ST
ATUS <> 'X' AND NF_BRL_DATE = %DATEIN(:6) ", VENDOR_ID, NF_BRL, NF_BRL_SERIES, N
F_BRL_ID, ADDRESS_SEQ_NUM, NF_BRL_DATE, &RETURN);
/********************************************* mmcb.hd59717.en **************
*******************************/
If All(&RETURN) Then
Error MsgGet(30000, 121, "This Fiscal Document already exists.");
End-If;
/**** Comentado - Fiscalmente correto Considera a data de emissao do document
o fiscal
SQLExec("Select 'X' from PS_NF_HDR_BRL A, PS_VNDR_ADDR_SCROL B where A.NF_
BRL = :1 and A.NF_BRL_SERIES = :2 AND A.VENDOR_SETID = B.SETID AND A.VENDOR_ID =
B.VENDOR_ID and A.ADDRESS_SEQ_NUM = B.ADDRESS_SEQ_NUM AND B.CGC_BRL = :3 and A.
NF_BRL_STATUS <> 'X' AND NF_BRL_DATE = %DATEIN(:4)", NF_BRL, NF_BRL_SERIES, NF_H
DR_INFO_WRK.CGC_BRL, NF_BRL_DATE, &RETURN);
If All(&RETURN) Then
Error MsgGet(30000, 121, "This Fiscal Document already exists.");
End-If;
*****/
End-If;
/**** FIM - AUGUSTO VILARINHO NETO - 24/11/2005 - Verifica se existe o document
o fiscal para o fornecedor especificado ****/
/********************************************* mmcb.sds3808.sn
**********************************************/
If %Component = Component.NF_RECV_PBL Then
If All(NF_BRL_TYPE) Then
&VALIDA = " ";
&RECEBIMENTO = " ";
SQLExec("SELECT DISTINCT 'Y' FROM PS_MMC_ACES_REC_LN LN,PS_MMC_ACES_REC_HD
HD WHERE HD.BUSINESS_UNIT = :1 AND LN.BUSINESS_UNIT = :1 AND HD.STATUS = 'A' AN
D LN.OPRID = HD.OPRID AND HD.OPRID =(SELECT REC.OPRID FROM PS_RECV_HDR REC WHERE
REC.BUSINESS_UNIT = :1 AND REC.RECEIVER_ID = :5 AND REC.NF_BRL = :2 AND REC.NF_
BRL_SERIES = :3) AND LN.NF_BRL_TYPE = :4", BUSINESS_UNIT, NF_BRL, NF_BRL_SERIES,
NF_BRL_TYPE, RECEIVER_ID, &VALIDA);
SQLExec("SELECT DISTINCT RECEIVER_TYPE FROM PS_MMC_ACES_REC_LN LN,PS_MMC_A
CES_REC_HD HD WHERE HD.BUSINESS_UNIT = :1 AND LN.BUSINESS_UNIT = :1 AND HD.STATU
S = 'A' AND LN.OPRID = HD.OPRID AND HD.OPRID =(SELECT REC.OPRID FROM PS_RECV_HDR
REC WHERE REC.BUSINESS_UNIT = :1 AND REC.RECEIVER_ID = :5 AND REC.NF_BRL = :2 A
ND REC.NF_BRL_SERIES = :3)", BUSINESS_UNIT, NF_BRL, NF_BRL_SERIES, NF_BRL_TYPE,
RECEIVER_ID, &RECEBIMENTO);
If &RECEBIMENTO = "02" And
&VALIDA <> "Y" Then
Error MsgGet(9999, 99, "Usurio no autorizado a efetuar recebimento!");
End-If;
End-If;
End-If;
/********************************************* mmcb.sds3808.sn
**********************************************/
[NF_HDR_BRL.NF_BRL_TYPE.SavePreChange]
/* Desassocia as NFs vinculadas ao alterar o tipo de doc. fiscal */
If %Component = Component.NF_INFO_PBL Or
%Component = Component.NF_RECV_PBL Then
&MULTIID = FetchValue(NF_MULTI_BRL.NF_BRL_MULTI_ID, 1);
If NF_TYPE_BRL.NF_BRL_TYPE_FLG = "N" And
All(&MULTIID) Then
GetLevel0()(1).GetRowset(Scroll.NF_MULTI_BRL).Flush();
End-If;
End-If;
[NF_HDR_BRL.ORIGIN_METHOD.SaveEdit]
/* BRLOC-PO-APP-8.00-11/12/00-BEGIN*/
/* Determina Origin Method baseado no panelgroup */
/* Fabiano cunha 21/10/2005 - Adequao da verso 7 para 8 */
/**********mmcb.sds5100.e.n**********/
[NF_HDR_BRL.OTHER_PRORATE_PBL.FieldChange]
Declare Function UnGray_Other_Amt PeopleCode FUNCLIB_PBL.EXP_PRORATE_PBL FieldFo
rmula;
Declare Function Gray_Other_Amt PeopleCode FUNCLIB_PBL.EXP_PRORATE_PBL FieldForm
ula;
Declare Function Calc_Other_Exp_Amt PeopleCode FUNCLIB_PBL.EXP_PRORATE_PBL Field
Formula;
/*BRLOC-PO-APP-8.00-02/04/01-BEGIN */
/*
UnGrays Other Expenses/Insurance fields if Prorate = "Manual" else
Grays Other Expenses/Insurance fields and Calculate Prorate */
If OTHER_PRORATE_PBL = "M" Then
UnGray_Other_Amt();
Else
Gray_Other_Amt();
Calc_Other_Exp_Amt();
End-If;
/*BRLOC-PO-APP-8.00-02/04/01-END */
[NF_HDR_BRL.OTHER_PRORATE_PBL.RowInit]
Declare Function UnGray_Other_Amt PeopleCode FUNCLIB_PBL.EXP_PRORATE_PBL FieldFo
rmula;
Declare Function Gray_Other_Amt PeopleCode FUNCLIB_PBL.EXP_PRORATE_PBL FieldForm
ula;
Declare Function Calc_Other_Exp_Amt PeopleCode FUNCLIB_PBL.EXP_PRORATE_PBL Field
Formula;
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-03/04/01
No executar o cdigo se o Component = 'DFI_CANCEL_PBL' (Cancelamento de Doc. Fiscal
) ou 'REOPEN_FISCDOC_PBL' (Reabertura de Doc. Fiscal) ou 'DELETE_FISCDOC_PBL' (D
eleo de Doc. Fiscal) ou 'CLOSE_FISCDOC_PBL' (Encerramento de Doc. Fiscal).
*/
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-BEGIN-03/04/01 */
If %Component <> Component.DFI_CANCEL_PBL And
%Component <> Component.REOPEN_FISCDOC_PBL And
%Component <> Component.DELETE_FISCDOC_PBL And
%Component <> Component.CLOSE_FISCDOC_PBL And
%Component <> Component.NF_INQ_PBL And
%Component <> Component.MTCH_INQ_PBL Then
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-END-03/04/01 */
If %Component = Component.NF_RECV_PBL Or
%Component = Component.NF_INFO_PBL Then
/*BRLOC-PO-APP-8.00-10/01/01-BEGIN */
/* Desabilita campos de rateio de frete, seguro e outras despesas, quando
recebimento fiscal for relacionado a um recebimento fsico com Ordem de Compra*/
&LINE_MAXROW = ActiveRowCount(Record.NF_LN_BRL);
For &LINE_ROW = 1 To &LINE_MAXROW
&po_id = FetchValue(NF_LN_BRL.PO_ID, &LINE_ROW);
If All(&po_id) Then
REM Gray(OTHER_PRORATE_PBL);
Else
UnGray(OTHER_PRORATE_PBL);
End-If;
End-For;
/*
UnGrays Other Expenses/Insurance fields if Prorate = "Manual" el
se
/**********mmcb.sds5100.e.n**********/
/*BRLOC - PO - GTM - 19/05/04 - MP164 - ICE Resoltuion ID: 157028 - BEGIN*/
If All(PISTAX_BRL_AMT) And
PISTAX_BRL_AMT > GROSS_AMT Then
Error MsgGet(28000, 11, "Valor no pode ser maior que o valor da Nota");
End-If;
/*BRLOC - PO - GTM - 19/05/04 - MP164 - ICE Resoltuion ID: 157028 - END*/
[NF_HDR_BRL.PISTAX_BRL_AMT.SavePreChange]
/*******************************************************************************
*******
* Vinicius Montijo Favero - MMC - 11/03/2015 - mmcb.sds5100
*
* Ajuste de Dados Incorretos no Registro ou Faturamento
*
********************************************************************************
*******/
Declare Function valida_somatoria_linhas PeopleCode BUSINESS_UNIT FieldFormula;
/*mmcb.sds5100.L.N*/
/**********mmcb.sds5100.s.n**********/
If %Component = "MMC_NF_ALTERA" Then
&campo = "NF_LN_BRL.PISTAX_BRL_AMT";
&tabela = "Record.NF_LN_BRL";
&valor_hdr = PISTAX_BRL_AMT;
valida_somatoria_linhas(&tabela, &campo, &valor_hdr);
If PISTAX_BRL_AMT <> 0 And
None(COFINSTAX_BRL_AMT) Or
None(PISTAX_BRL_AMT) And
COFINSTAX_BRL_AMT <> 0 Then
Error ("Os campos de PIS/Cofins devem estar nas mesmas condies.")
End-If;
If PIS_AMT_BSE_BBL <> 0 And
None(COFINS_AMT_BSE_BBL) Or
None(PIS_AMT_BSE_BBL) And
COFINS_AMT_BSE_BBL <> 0 Then
Error ("Os campos de PIS/Cofins devem estar nas mesmas condies.")
End-If;
End-If;
/**********mmcb.sds5100.e.n**********/
[NF_HDR_BRL.PIS_AMT_BSE_BBL.SavePreChange]
/*******************************************************************************
*******
* Vinicius Montijo Favero - MMC - 11/03/2015 - mmcb.sds5100
*
Else
REM BUSCA PARAMETRIZAO DOS CADASTROS DE COMPRA;
/**********************************************************************
********** Fabiano Cunha - MMC - 17/10/2006 - mmcb.HD26117 - Alterando o progra
ma que busca o numero de dias para considerar, ano e mes e nao somente dias ****
********************************************************************************
*******************************************/
/********* mmcb.HD26117 - s.n ***********/
SQLExec("SELECT A.PYMNT_TERMS_CD, (B.TMG_DAY_INCR_VAL + (b.TMG_MONTH_IN
CR_VAL*30)+ (b.TMG_YEAR_INCR_VAL *356)) FROM sysadm.PS_PYMT_TRMS_NET A, sysadm.P
S_PYMT_TRMS_TIME B WHERE A.SETID = B.SETID AND A.NET_TRMS_TIME_ID = B.PAY_TRMS_
TIME_ID AND (B.TMG_DAY_INCR_VAL + (b.TMG_MONTH_INCR_VAL*30)+ (b.TMG_YEAR_INCR_VA
L *356)) >= :1 ORDER BY (B.TMG_DAY_INCR_VAL + (b.TMG_MONTH_INCR_VAL*30) + (b.TMG
_YEAR_INCR_VAL *356))", &COND_INC, &NEW_PYMNT, &DAY_INC);
/********* mmcb.HD26117 - e.n ***********/
/********* mmcb.HD26117 - s.o **********
SQLExec("SELECT A.PYMNT_TERMS_CD, B.TMG_DAY_INCR_VAL FROM PS_PYMT_TR
MS_NET A, PS_PYMT_TRMS_TIME B WHERE A.SETID = B.SETID AND A.NET_TRMS_TIME_ID = B
.PAY_TRMS_TIME_ID AND B.TMG_DAY_INCR_VAL >= :1 ORDER BY B.TMG_DAY_INCR_VAL", &CO
ND_INC, &NEW_PYMNT, &DAY_INC);
End-If; ********* mmcb.HD26117 - e.o ***********/
If All(&NEW_PYMNT) Then
PYMNT_TERMS_CD = &NEW_PYMNT;
MMC_TEMP.END_DATE = AddToDate(NF_BRL_DATE, 0, 0, &DAY_INC);
End-If;
End-If;
End-If;
End-If;
/***************************** mmcb.sds3425.sn *****************************/
If %Page = "NF_INFO_HDR_PBL" And
%Component = "NF_INFO_PBL" Then
If MMC_TE_NFLN_WRK.MMC_TERCEIRO_FLG = "Y" And
MMC_TE_RECV_WRK.MMC_TE_NFSERVI_FLG = "N" Then
SQLExec("SELECT PYMNT_TERMS_CD FROM SYSADM.PS_VNDR_ADDR_SCROL A, SYSADM.PS
_VENDOR_LOC B WHERE B.SETID = A.SETID AND B.VENDOR_ID = A.VENDOR_ID AND B.REMIT_
ADDR_SEQ_NUM = A.ADDRESS_SEQ_NUM AND A.CGC_BRL=:1", MMC_TE_RECV_WRK.CGC_BRL, PYM
NT_TERMS_CD);
End-If;
End-If;
/***************************** mmcb.sds3425.en *****************************/
[NF_HDR_BRL.PYMNT_TERMS_CD.SaveEdit]
/*** JEISON CALDAS - VALIDAO DE CONDIO DE PAGAMENTO DA NF DENTRO DO PRAZO - INICIO *
**/
/*******************************************************************************
*********
* Renato/Rosangela Enc.Vinicius Favero mmc.hd170222
24/04/2013
*
* Ajustar a data para criao da condio de pagamento ajustando o prazo de 3 para 1
*
********************************************************************************
********/
If (%Component = "NF_INFO_PBL" Or
%Component = "NF_RECV_PBL") And
VOUCHER_FLOW_PBL <> "N" And
PYMNT_TERMS_CD <> "PERMU" And
PYMNT_TERMS_CD <> "PATRO" Then
/******************************hd170222.so******************************
&DT_PGTO = AddToDate(%Date, 0, 0, 3);
******************************hd170222.eo******************************/
/******************************hd170222.sn******************************/
&DT_PGTO = AddToDate(%Date, 0, 0, 1);
/******************************hd170222.en******************************/
If None(MMC_TEMP.END_DATE) Then
MMC_TEMP.END_DATE = NF_BRL_DATE;
End-If;
If MMC_TEMP.END_DATE < &DT_PGTO Then
&COND_INC = (&DT_PGTO - MMC_TEMP.END_DATE) + (MMC_TEMP.END_DATE - NF_BRL_D
ATE);
REM BUSCA NOVA CONDIO DE PAGAMENTO SATISFATORIA;
SQLExec("SELECT A.PYMNT_TERMS_CD, B.DAY_INCREMENT FROM PS_PAY_TRMS_NET A,
PS_PAY_TRMS_TIME B, PS_PYMT_TR_EFF_VW C WHERE A.SETID = 'MMCSA' AND A.SETID = B.
SETID AND A.PAY_TRMS_TIME_ID = B.PAY_TRMS_TIME_ID AND A.SETID = C.SETID AND A.P
YMNT_TERMS_CD = C.PYMNT_TERMS_CD AND B.DAY_INCREMENT >= :1 ORDER BY B.DAY_INCREM
ENT", &COND_INC, &NEW_PYMNT, &DAY_INC);
If All(&NEW_PYMNT) Then
PYMNT_TERMS_CD = &NEW_PYMNT;
MMC_TEMP.END_DATE = AddToDate(NF_BRL_DATE, 0, 0, &DAY_INC);
Else
REM BUSCA PARAMETRIZAO DOS CADASTROS DE COMPRA;
/**********************************************************************
********** Fabiano Cunha - MMC - 17/10/2006 - mmcb.HD26117 - Alterando o progra
ma que busca o numero de dias para considerar, ano e mes e nao somente dias ****
********************************************************************************
*******************************************/
/********* mmcb.HD26117 - s.n ***********/
SQLExec("SELECT A.PYMNT_TERMS_CD, (B.TMG_DAY_INCR_VAL + (b.TMG_MONTH_IN
CR_VAL*30)+ (b.TMG_YEAR_INCR_VAL *356)) FROM sysadm.PS_PYMT_TRMS_NET A, sysadm.P
S_PYMT_TRMS_TIME B WHERE A.SETID = B.SETID AND A.NET_TRMS_TIME_ID = B.PAY_TRMS_
TIME_ID AND (B.TMG_DAY_INCR_VAL + (b.TMG_MONTH_INCR_VAL*30)+ (b.TMG_YEAR_INCR_VA
L *356)) >= :1 ORDER BY (B.TMG_DAY_INCR_VAL + (b.TMG_MONTH_INCR_VAL*30) + (b.TMG
_YEAR_INCR_VAL *356))", &COND_INC, &NEW_PYMNT, &DAY_INC);
/********* mmcb.HD26117 - e.n ***********/
/********* mmcb.HD26117 - s.o **********
SQLExec("SELECT A.PYMNT_TERMS_CD, B.TMG_DAY_INCR_VAL FROM PS_PYMT_TR
MS_NET A, PS_PYMT_TRMS_TIME B WHERE A.SETID = B.SETID AND A.NET_TRMS_TIME_ID = B
.PAY_TRMS_TIME_ID AND B.TMG_DAY_INCR_VAL >= :1 ORDER BY B.TMG_DAY_INCR_VAL", &CO
ND_INC, &NEW_PYMNT, &DAY_INC);
End-If; ******** mmcb.HD26117 - e.o ***********/
If All(&NEW_PYMNT) Then
PYMNT_TERMS_CD = &NEW_PYMNT;
MMC_TEMP.END_DATE = AddToDate(NF_BRL_DATE, 0, 0, &DAY_INC);
Else
Error ("Condio de pagamento insuficiente para pagamento do voucher den
tro do vencimento!");
End-If;
End-If;
End-If;
End-If;
/*** JEISON CALDAS - VALIDAO DE CONDIO DE PAGAMENTO DA NF DENTRO DO PRAZO - FIM ***/
[NF_HDR_BRL.RECEIVER_ID.RowInit]
/*BRLOC - PO - APP - 8.00 - 06/12/00 */
/*Descrio: Inibir o Recevier_id para a entrada direta de documento fiscal */
If %PanelGroup = PanelGroup.NF_INFO_PBL Then
Hide(RECEIVER_ID)
End-If;
/*** JEISON CALDAS - ATIV.1950 - 25/09/2007 - Automatizao do Rateio de NF Compleme
ntar - Inicio ***/
/*** JEISON CALDAS - ATIV.XXXX - 28/04/2008 - Processo alterado para s rateio qua
ndo processo estiver completo
If %Component = "NF_RECV_PBL" And
%Mode = "A" Then
SQLExec("SELECT B.DESCR254_MIXED FROM SYSADM.PS_RECV_LN_DISTRIB A, SYSADM.PS_
RECV_LN_SHIP B, SYSADM.PS_MMC_ACCOUNT_AVR C WHERE A.BUSINESS_UNIT = :1 AND A.REC
EIVER_ID = :2 AND A.BUSINESS_UNIT = B.BUSINESS_UNIT AND A.RECEIVER_ID = B.RECEIV
ER_ID AND A.RECV_LN_NBR = B.RECV_LN_NBR AND A.RECV_SHIP_SEQ_NBR = B.RECV_SHIP_SE
Q_NBR AND A.ACCOUNT = C.ACCOUNT AND C.STATUS = 'A'", BUSINESS_UNIT, RECEIVER_ID
, &PROCESSO);
If All(&PROCESSO) Then
ScrollFlush(Record.MMC_R_FRETEN);
ScrollSelectNew(1, Record.MMC_R_FRETEN, Record.MMC_ACCO_AVR_VW, "WHERE BUS
INESS_UNIT = :1 AND RECEIVER_ID = :2", BUSINESS_UNIT, RECEIVER_ID);
End-If;
End-If;
***/
/*** JEISON CALDAS - ATIV.1950 - 25/09/2007 - Automatizao do Rateio de NF Compleme
ntar - Fim ***/
[NF_HDR_BRL.RECEIVER_ID.SavePostChange]
/*******************************************************************************
*
* Fabiano Cunha - MMCB - 07/11/2009
- mmcb.sds3239
*
* Projeto Implantao People - Multi Empresa MMCB-SVB.
*******************************************************************************
*/
/*******************************************************************************
*
* Mauri R. Back - MMCB - 04/04/2012
- mmcb.hd135384
*
* No ratear itens que so veiculos.
*
*******************************************************************************
*/
/************************************************************************
* Wagner Sorio - MMCB - 01/09/2014 - mmcb.sds4689
*
* Implantao do People DBME
*
*************************************************************************/
/************************************************************************
* Wagner Sorio - MMCB - 30/03/2015 mmcb.hd235084
*
* O programa que gera as notas fiscais no est obedecendo
*
* a separao de empresas.
*
************************************************************************/
/* Declare Function BU_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange; */ /*
mmcb.sds4689.lo */
/*** JEISON CALDAS - ATIV.1950 - 17/10/2007 - Automatizao do Rateio de NF Compleme
ntar - Inicio ***/
If %Component = "NF_RECV_PBL" And
NF_HDR_INFO_WRK.NF_BRL_STATUS = "F" Then
REM PEGA TOTAL DE LINHAS DO RECEBIMENTO FISICO;
SQLExec("SELECT COUNT(*) FROM PS_RECV_LN_SHIP WHERE BUSINESS_UNIT = :1 AND RE
CEIVER_ID = :2", BUSINESS_UNIT, RECEIVER_ID, &LINHAS_RECEB);
For &LN = 1 To &LINHAS_RECEB
REM LIMPA VARIAVEIS;
&ITEM = " ";
&DESCR = " ";
&BU_PO = " ";
&NF_BRL_ID_MAE = " ";
REM BUSCA CONTA CONTABIL, PROCESSO E CD.DO ITEM DO RECEBIMENTO FISICO;
SQLExec("SELECT A.ACCOUNT, B.DESCR254_MIXED, B.INV_ITEM_ID FROM PS_RECV_LN
_DISTRIB A, PS_RECV_LN_SHIP B WHERE A.BUSINESS_UNIT = B.BUSINESS_UNIT AND A.RECE
IVER_ID = B.RECEIVER_ID AND A.RECV_LN_NBR = B.RECV_LN_NBR AND A.BUSINESS_UNIT =
:1 AND A.RECEIVER_ID = :2 AND A.RECV_LN_NBR = :3", BUSINESS_UNIT, RECEIVER_ID,
&LN, &ACCOUNT, &DESCR, &ITEM);
REM VALIDA SE CONTA REFERE-SE A DESPESA DE IMPORTAO;
SQLExec("SELECT 'Y' FROM PS_MMC_ACCOUNT_AVR WHERE STATUS = 'A' AND ACCOUNT
= :1", &ACCOUNT, &NF_RAT);
&IMP_PROCESS = Substring(&DESCR, 1, 3);
&IMP_PROCESS_SUZ = Substring(&DESCR, 1, 2);
If &NF_RAT = "Y" And
&IMP_PROCESS <> "MJE" And
&IMP_PROCESS_SUZ <> "BN" And
&IMP_PROCESS_SUZ <> "BT" Then
SQLExec("SELECT 'Y' FROM PS_MMC_RAT_CONT_IM WHERE BUSINESS_UNIT = :1 AN
D MMC_NF_BRL_ID_SERV = :2 AND RECEIVER_ID = :3 AND RECV_LN_NBR = :4", BUSINESS_U
NIT, NF_BRL_ID, RECEIVER_ID, &LN, &JA_LANCADA);
If &JA_LANCADA <> "Y" Then
REM VERIFICA SE POPULOU VIEW DE RATEIO(POSSUI NF MAE/IMPORTACAO);
/************************** mmcb.sds4689.so ************************
**/
/*
SQLExec("SELECT BUSINESS_UNIT, NF_BRL_ID FROM PS_NF_HD
R_BRL WHERE NF_BRL_DATE > TO_CHAR(SYSDATE - 90, 'DD/MM/YYYY') AND BUSINESS_UNIT
IN (:1, :2, :3) AND DESCR100 = :4", BU_SETID("CPNA1"), BU_SETID("CPID1"), BU_SET
ID("CPRV1"), &DESCR, &BU_PO, &NF_BRL_ID_MAE); */
/************************** mmcb.sds4689.eo ************************
**/
/************************** mmcb.hd235084.so ***********************
***/
/* SQLExec("SELECT A.BUSINESS_UNIT, A.NF_BRL_ID FROM SYSADM.PS_NF_HD
R_BRL A , SYSADM.PS_BUS_UNIT_TBL_PM B WHERE A.NF_BRL_DATE > TO_CHAR(SYSDATE - 90
, 'DD/MM/YYYY') AND A.BUSINESS_UNIT IN ( SELECT BUSINESS_UNIT FROM SYSADM.PS_MMC
_BUS_UNIT WHERE MMC_BUS_UNIT_TIPO IN ('POPROD' , 'POINDI' , 'POREVE') AND STATU
S = 'A' ) AND A.DESCR100 = :1 AND B.BUSINESS_UNIT_GL = A.BUSINESS_UNIT_GL AND B.
BUSINESS_UNIT = :2 ", &DESCR, BUSINESS_UNIT, &BU_PO, &NF_BRL_ID_MAE); */
/************************** mmcb.sds4689.eo ************************
**/
/************************** mmcb.hd235084.sn ***********************
***/
&SQL = "
End-If;
/* Busca estabelecimento fiscal */
&EF_LOC_BRL = get_ef_loc_brl(&SETID, SHIPTO_ID);
EF_LOC_BRL = &EF_LOC_BRL;
/* Inibe boto de recalculo quando o SHIPTO alterado, pois o sistema deve pegar no
vamente os dados do setup, para fazer os clculos dos impostos */
/*Gray(RECV_HD_WRK_PBL.NF_RECALC_PBL);*/
/*BRLOC - PO - APP - 8.00 - 16/01/01 - END */
/*
/*
/*
/*
/*
If
"");
0);
0);
0);
EF_LOC_BRL = &EF_LOC_BRL;
/* BRLOC-IN-NAS - RELEASE 8.0 - BEGIN - 24/04/01 */
/* Ensures that distribution business unit has been filled when */
/* InterUnit Flag is 'Y' or at last one stockable inventory item exists. *
/
&SETID = GetSetId("BUSINESS_UNIT", BUSINESS_UNIT, "NF_TYPE_BRL", "");
SQLExec("SELECT BUSINESS_UNIT_IN FROM PS_SHIPTO_TBL WHERE SETID = :1 AND S
HIPTO_ID = :2 AND EFFDT = (SELECT MAX(EFFDT) FROM PS_SHIPTO_TBL A WHERE SETID =
:1 AND SHIPTO_ID = :2 AND EFFDT <= %DATEIN(:3))", &SETID, SHIPTO_ID, NF_BRL_DATE
, &BU_IN_REL_SHIPTO);
BUSINESS_UNIT_IN = &BU_IN_REL_SHIPTO;
End-If;
End-If;
[NF_HDR_BRL.TRANSPORT_CD.FieldChange]
/* BRLOC - PO - APP - 8.00 - 10/01/01 - BEGIN */
Function gray_trsp_data();
Gray(NAME1);
Gray(ZIP);
Gray(ADDRESS1);
Gray(ADDRESS2);
Gray(CITY);
Gray(STATE);
Gray(CGC_BRL);
Gray(IE_BRL);
End-Function;
Function setdef_trsp_data();
SetDefault(NAME1);
SetDefault(ZIP);
SetDefault(ADDRESS1);
SetDefault(ADDRESS2);
SetDefault(CITY);
SetDefault(STATE);
SetDefault(CGC_BRL);
SetDefault(IE_BRL);
End-Function;
Function ungray_trsp_data();
UnGray(NAME1);
UnGray(ZIP);
UnGray(ADDRESS1);
UnGray(ADDRESS2);
UnGray(CITY);
UnGray(STATE);
UnGray(CGC_BRL);
UnGray(IE_BRL);
End-Function;
If All(TRANSPORT_CD) Then
setdef_trsp_data();
gray_trsp_data();
Else
ungray_trsp_data();
End-If;
/* BRLOC - PO - APP - 8.00 - 10/01/01 - END */
[NF_HDR_BRL.TRANSPORT_CD.RowInit]
Declare Function gray_trsp_data PeopleCode TRANSPORT_CD FieldChange;
/* BRLOC - PO - APP - 8.00 10/01/01 - BEGIN */
/* Com o cdigo da transportadora, alguns campos no so necessrios */
If %PanelGroup = PanelGroup.NF_INFO_PBL Then
If All(TRANSPORT_CD) Then
gray_trsp_data();
End-If;
End-If;
/* BRLOC - PO - APP - 8.00 10/01/01 - END */
[NF_HDR_BRL.TRANSPORT_CD.SavePreChange]
/*******************************************************************************
***
* Claudio Henrique da Costa - MMCB - 03/12/2010 - mmcb.sds3445
*
* Interface - GKO - People
*
*******************************************************************************
***/
/*******************************************************************************
***********
* Mauri Rodrigo Back - MMC - 22/12/2011 - mmcb.sds4041
*
* Desabilita o cdigo pois nao esta informando a mensagem (ja comentada) e estava
dando *
* problema no redespacho
*
*******************************************************************************
**********/
/* MMCB.SDS4041.SO */
/*
If ((%Component = "NF_INFO_PBL" Or
%Component = "NF_RECV_PBL") And
(%Menu = "MANAGE_NF")) Then
If None(TRANSPORT_CD) Then
SQLExec("SELECT 'Y' FROM SYSADM.PS_MMC_GKO_NFTP_OT O, SYSADM.PS_MMC_INSTAL
L M WHERE O.SETID = M.SETID AND O.EFFDT = ( SELECT MAX(OI.EFFDT) FROM SYSADM.PS_
MMC_GKO_NFTP_OT OI WHERE O.SETID = OI.SETID AND O.NF_BRL_TYPE = OI.NF_BRL_TYPE)
AND O.NF_BRL_TYPE = :1 AND O.MMC_GKO_NF_TYPE_OT = 'Y'", NF_BRL_TYPE, &EXIGE_TRAN
SPORTADORA);
If (All(&EXIGE_TRANSPORTADORA) And
&EXIGE_TRANSPORTADORA = "Y") Then
rem WinMessage("A Transportadora deve ser informada!");
End-If;
End-If;
End-If;
*/
/* MMCB.SDS4041.EO */
[NF_HDR_BRL.VENDOR_ID.FieldChange]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 01/11/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Customizao Sistema de Terceiros - Preenche automaticamente o codigo do forneced
or
*
* Pagina de Industrializao.
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Claudio Henrique da Costa - MMCB - 14/12/2010 - mmcb.sds3445
*
* Interface - GKO - People
*
*******************************************************************************
*****************
* Bleno L Sampaio (Enc. Filipe) - MMCB - 28/11/2011 - mmcb.hd129436
*
* Ajustar select para buscar apenas endereos ativos.
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Filipe Rehder - MMCB - 10/09/2013 - mmcb.hd182991
*
* Corrigir campo de local default do fornecedor
*
*******************************************************************************
*****************/
Declare Function GetPayTrm PeopleCode VENDOR_ID FieldFormula;
/*************************************** mmcb.sds3445.sn ***********************
****************/
Function Carrega_Redespacho_Fornecedor()
/* If %Component = "NF_INFO_PBL" Or
%Component = "NF_RECV_PBL" Then
If %Mode = "A" Then
&ROWSET_REDESP = GetRowset(Scroll.MMC_GKO_REDESP);
&ROWSET_REDESP.Flush();
For &N1 = 1 To &ROWSET_REDESP.ActiveRowCount
&ROWSET_REDESP.DeleteRow(&N1);
End-For;
If None(ADDRESS_SEQ_NUM) Then
ADDRESS_SEQ_NUM = 1;
End-If;
&SQL = CreateSQL("SELECT P.MMC_GKO_NOORDEM, P.CARRIER_ID, P.TRNSPORT_RE
SP_BBL, P.FRGHT_PMT_RESP_BBL, P.TRANSPORT_MODE FROM SYSADM.PS_MMC_GKO_PARRD_E P
WHERE P.SETID = (SELECT SETID FROM SYSADM.PS_MMC_INSTALL) AND P.EFFDT = (SELECT
MAX(PI.EFFDT) FROM SYSADM.PS_MMC_GKO_PARRD_E PI WHERE P.SETID = PI.SETID AND P.V
ENDOR_ID = PI.VENDOR_ID AND P.ADDRESS_SEQ_NUM = PI.ADDRESS_SEQ_NUM AND P.MMC_GK
O_NOORDEM = PI.MMC_GKO_NOORDEM AND PI.EFFDT <= TO_DATE(SYSDATE)) AND P.EFF_STATU
S = 'A' AND P.VENDOR_ID = :1 AND P.ADDRESS_SEQ_NUM = :2 ORDER BY MMC_GKO_NOORDEM
", VENDOR_ID, ADDRESS_SEQ_NUM);
While &SQL.Fetch(&P_MMC_GKO_NOORDEM, &P_CARRIER_ID, &P_TRNSPORT_RESP_BB
L, &P_FRGHT_PMT_RESP_BBL, &P_TRANSPORT_MODE)
&P_MODO_FRETE = " ";
If (&P_TRANSPORT_MODE = "RODOV") Then
&P_MODO_FRETE = "ROAD";
End-If;
If (&P_TRANSPORT_MODE = "AEREO") Then
&P_MODO_FRETE = "AIR";
End-If;
If (&P_TRANSPORT_MODE = "SEA") Then
&P_MODO_FRETE = "SEA";
End-If;
&ROWSET_REDESP.InsertRow(&P_MMC_GKO_NOORDEM);
&ROWSET_REDESP.GetRow(&P_MMC_GKO_NOORDEM).MMC_GKO_REDESP.BUSINESS_UN
IT.VALUE = BUSINESS_UNIT;
&ROWSET_REDESP.GetRow(&P_MMC_GKO_NOORDEM).MMC_GKO_REDESP.NF_BRL_ID.V
ALUE = NF_BRL_ID;
&ROWSET_REDESP.GetRow(&P_MMC_GKO_NOORDEM).MMC_GKO_REDESP.MMC_GKO_NOO
RDEM.VALUE = &P_MMC_GKO_NOORDEM;
&ROWSET_REDESP.GetRow(&P_MMC_GKO_NOORDEM).MMC_GKO_REDESP.MMC_GKO_CDT
RPREDES.VALUE = &P_CARRIER_ID;
&ROWSET_REDESP.GetRow(&P_MMC_GKO_NOORDEM).MMC_GKO_REDESP.MMC_GKO_DSL
OTE.VALUE = " ";
&ROWSET_REDESP.GetRow(&P_MMC_GKO_NOORDEM).MMC_GKO_REDESP.MMC_GKO_MEI
OTRP.VALUE = &P_MODO_FRETE;
End-While;
End-If;
End-If;
*/
End-Function;
/*************************************** mmcb.sds3445.en ***********************
****************/
/* Inibe boto de recalculo quando o fornecedor alterado, pois o sistema deve pega
r novamente os dados do setup, para fazer os clculos dos impostos */
/*Gray(RECV_HD_WRK_PBL.NF_RECALC_PBL);*/
/* Obtem CGC e endereo */
/* FABIANO CUNHA - FC800958 - 18/10/2005 - Adequacao da versao 7 pra 8 */
/* If %PanelGroup = PanelGroup.NF_INFO_PBL Then */
If %PanelGroup = PanelGroup.NF_INFO_PBL Or
%PanelGroup = "MMC_LANC_GAR" Then
If All(VENDOR_ID) Then
/*** JEISON CALDAS - 25/03/06 - SELECT ABAIXO ALTERADO POR PEGAR SEQUENCIA
DO ENDEREO DO CABEALHO
SQLExec("Select A.CGC_BRL, B.ADDR_SEQ_NUM_ORDR, A.PAY_TRMS_DIV_PBL, B.COLL
ECT_COD_BRL, B.DEFAULT_LOC FROM PS_VNDR_ADDR_SCROL A, PS_VENDOR B where A.SETID
= B.SETID AND A.VENDOR_ID = B.VENDOR_ID AND A.SETID = :1 and A.VENDOR_ID = :2",
VENDOR.SETID, VENDOR_ID, NF_HDR_INFO_WRK.CGC_BRL, ADDRESS_SEQ_NUM, &PAY_TRMS, CO
LLECT_COD_BRL, VNDR_LOC); ***/
/*************************************** mmcb.hd129436.so ****************
***********************/
/* Valmir Tavares - MMCB - Select alterado para trazer o CPF do fornecedor
- Inicio */
/*SQLExec("Select A.CGC_BRL, A.CPF_BRL, A.ADDRESS_SEQ_NUM, A.PAY_TRMS_DIV_
PBL, B.COLLECT_COD_BRL, A.DESCR FROM PS_VNDR_ADDR_SCROL A, PS_VENDOR B where A.S
ETID = B.SETID AND A.VENDOR_ID = B.VENDOR_ID AND A.SETID = :1 and A.VENDOR_ID =
:2", VENDOR.SETID, VENDOR_ID, NF_HDR_INFO_WRK.CGC_BRL, NF_HDR_INFO_WRK.CPF_BRL,
ADDRESS_SEQ_NUM, &PAY_TRMS, COLLECT_COD_BRL, VNDR_LOC); */
BRLOC-PO-APP-8.00-24/08/01-END */
BRLOC-PO-APP-8.00-16/01/01-BEGIN*/
Habilita ou no o link para entrada de parcelas de pagamento */
&PAY_TRMS = "Y" Then
UnGray(RECV_HD_WRK_PBL.XFR_TERMS_PB);
Else
Gray(RECV_HD_WRK_PBL.XFR_TERMS_PB);
End-If;
/* Altera campo work de acordo com o fornecedor */
RECV_HD_WRK_PBL.CRT_ESTABID_PBL = VENDOR.ESTABID;
FRGHT_PRORATE_PBL = VENDOR.FRGHT_PRORATE_PBL;
OTHER_PRORATE_PBL = VENDOR.OTHER_PRORATE_PBL;
/* Busca o Estado Origem */
[NF_HDR_BRL.VENDOR_ID.RowInit]
/*******************************************************************************
*
* Augusto Vilarinho Neto - MMCB - 05/11/2009 - mmcb.sds3239
*
* Projeto Implantao People - Multi Empresa MMCB-SVB.
*
*******************************************************************************
*/
/************************************************************************
* Wagner Sorio - MMCB - 01/09/2014 - mmcb.sds4689
*
* Implantao do People DBME
*
*************************************************************************/
/* Declare Function BU_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange; */ /*
mmcb.sds4689.lo */
Declare Function MMC_BUSINESS_UNIT PeopleCode MMC_BUS_UNIT.BUSINESS_UNIT SavePos
tChange; /* mmcb.sds4689.ln */
Global string &BU_CONTROL_REMESSA_TERC;
Global boolean &MMC_ENTRAPOR_ITEM, &MMC_ENTRAPOR_PACABADO, &MMC_ENTRAPOR_PACABAD
ONF, &MMC_ENTRAPOR_TRIANGULACAO;
/*BRLOC-PO-APP-8.00-30/08/2001-BEGIN */
/* Obtem CGC quando entra com no modo de alterao*/
/* FABIANO CUNHA - 22/10/2005 - Adequao da Verso 7 pra 8 */
If %Mode <> "A" Then
If %PanelGroup = PanelGroup.NF_INFO_PBL Or
%PanelGroup = Component.MMC_LANC_GAR Or
%Component = Component.MMC_LANC_GAR_ND Then
If All(VENDOR_ID) And
None(ADDRESS_SEQ_NUM) Then
SQLExec("Select A.CGC_BRL FROM PS_VNDR_ADDR_SCROL A, PS_VENDOR B where
A.SETID = B.SETID AND A.VENDOR_ID = B.VENDOR_ID AND A.SETID = :1 and A.VENDOR_ID
= :2 AND A.ADDRESS_SEQ_NUM = B.ADDR_SEQ_NUM_ORDR ", VENDOR.SETID, VENDOR_ID, NF
_HDR_INFO_WRK.CGC_BRL);
Else
SQLExec("Select A.CGC_BRL FROM PS_VNDR_ADDR_SCROL A, PS_VENDOR B where
A.SETID = B.SETID AND A.VENDOR_ID = B.VENDOR_ID AND A.SETID = :1 and A.VENDOR_ID
= :2 AND A.ADDRESS_SEQ_NUM = :3 ", VENDOR.SETID, VENDOR_ID, ADDRESS_SEQ_NUM, NF
_HDR_INFO_WRK.CGC_BRL);
End-If;
End-If;
End-If;
/* BRLOC PO-APP-8.00- 30/08/01 - END*/
/* WSG */
If %Component = Component.NF_INFO_PBL Or
%Component = Component.MMC_TERC Or
%Component = Component.MMC_TERC_OC Then
MMC_TERC_OC_WRK.VENDOR_ID = VENDOR_ID;
REM DUILIO CROCE - GRUPO QUANAM - 11/04/2006 - CONTROLE DE BOTOES NA PAGE.NF_
INFO_LN_PBL;
If %Component = Component.NF_INFO_PBL Then
MMC_TERC_OC_WRK.MMC_BTN_OC.Visible = False;
MMC_NF_LN_WRK.BUTTON1.Visible = False;
MMC_NF_LN_WRK.MMC_BTN_VINC_REMES.Visible = False;
REM FABIO GetLevel0()(1).MMC_NF_LN_WRK.BUTTON.Visible = False;
If &MMC_ENTRAPOR_ITEM = True Then
REM NO TEM LINK;
REM &MMC_ENTRAPOR_ITEM = False;
End-If;
If &MMC_ENTRAPOR_PACABADO = True Then
REM FABIO GetLevel0()(1).MMC_NF_LN_WRK.BUTTON.Visible = True;
REM &MMC_ENTRAPOR_PACABADO = False;
End-If;
If &MMC_ENTRAPOR_PACABADONF = True Then
MMC_NF_LN_WRK.BUTTON1.Visible = True;
REM FABIO GetLevel0()(1).MMC_NF_LN_WRK.BUTTON.Visible = True;
REM &MMC_ENTRAPOR_PACABADONF = False;
End-If;
If &MMC_ENTRAPOR_TRIANGULACAO = True Then
MMC_TERC_OC_WRK.MMC_BTN_OC.Visible = True;
MMC_NF_LN_WRK.MMC_BTN_VINC_REMES.Visible = True;
REM &MMC_ENTRAPOR_TRIANGULACAO = False;
End-If;
End-If;
REM DUILIO CROCE - GRUPO QUANAM - 11/04/2006 -
DE BOTOES NA PAGE.NF_INFO_LN_PBL;
Else
If %Component = Component.NF_RECV_PBL Then /* FABIO - 06/06/2006 */
MMC_TERC_OC_WRK.MMC_BTN_OC.Visible = False;
MMC_NF_LN_WRK.BUTTON1.Visible = False;
MMC_NF_LN_WRK.MMC_BTN_VINC_REMES.Visible = False;
End-If;
End-If;
/* WSG */
/*BRLOC-PO-APP-8.00-30/08/2001-BEGIN */
/* Disponibiliza campo Data Base quando tipo de data - User Defined*/
If PAY_TRM_BSE_DT_OPT = "U" Then
UnHide(PAYTRMS_DT_BSE_PBL);
Else
SetDefault(PAYTRMS_DT_BSE_PBL);
Hide(PAYTRMS_DT_BSE_PBL);
End-If;
/* BRLOC PO-APP-8.00- 30/08/01 - END*/
/*** JEISON CALDAS - 20/10/06 - ATIV. 1784 - CONTROLE DE ADIANTAMENTO PARA FORNE
CEDORES - INICIO ***/
If %Component = Component.NF_RECV_PBL Then
SQLExec("SELECT 'X' FROM PS_MMC_FORNEC_ADTO WHERE VENDOR_ID = :1 AND STATUS =
'A'", VENDOR_ID, &RETURN);
/********************** mmcb.sds4689.so **********************/
/* If &RETURN = "X" And
(BUSINESS_UNIT = "POPRO" Or
BUSINESS_UNIT = "POIND") Then*/
/********************** mmcb.sds4689.eo **********************/
/********************** mmcb.sds4689.sn **********************/
If &RETURN = "X" And
(BUSINESS_UNIT = MMC_BUSINESS_UNIT("POPROD", BUSINESS_UNIT) Or
BUSINESS_UNIT = MMC_BUSINESS_UNIT("POINDI", BUSINESS_UNIT)) Then
/********************** mmcb.sds4689.en **********************/
UnHide(MMC_CONTR_ADTO.MMC_VALOR_ADTO);
UnHide(MMC_CONTR_ADTO.MMC_VALOR);
Else
Hide(MMC_CONTR_ADTO.MMC_VALOR_ADTO);
Hide(MMC_CONTR_ADTO.MMC_VALOR);
End-If;
Else
Hide(MMC_CONTR_ADTO.MMC_VALOR_ADTO);
Hide(MMC_CONTR_ADTO.MMC_VALOR);
End-If;
/*** JEISON CALDAS - 20/10/06 - ATIV. 1784 - CONTROLE DE ADIANTAMENTO PARA FORNE
CEDORES - FIM ***/
[NF_HDR_BRL.VNDR_LOC.FieldChange]
Declare Function GetPayTrm PeopleCode VENDOR_ID FieldFormula;
/* BRLOC-AP - FRG - 21-SET-98 - Obriga o campo "vendor Location"a receber pelo m
enos o valor default para o fornecedor*/
If None(VNDR_LOC) Then
VNDR_LOC = VENDOR.DEFAULT_LOC;
End-If;
/*BRLOC-PO-NAS-8.00-06/09/01-BEGIN */
/*Busca o Payment Terms e a data base de pagto. do fornecedor */
GetPayTrm();
/*BRLOC - PO - APP - 8.00 - 16/01/01 - END */
[NF_HDR_BRL.VNDR_LOC.SaveEdit]
/*******************************************************************************
*****************
* Wagner Sorio - MMC - 29/02/2008- mmcb.hd49956 - Sistema Controle Terceiros
*
* No deixar salvar campo VNDR_LOC invalido.
*
*****************************************************************************
*******************/
/*******************************************************************************
*******************
Fabiano Cunha - MMC - SDS 3239 - mmcb3239 - Adequao para Multi-empresa
********************************************************************************
*******************/
/********************** mmcb.hd49956.sn **********************/
If %Component = "NF_INFO_PBL" And
MMC_TE_NFLN_WRK.MMC_TERCEIRO_FLG = "Y" And
NF_BRL_STATUS = "F" Then
&SETID = GetSetId("BUSINESS_UNIT", BUSINESS_UNIT, "VENDOR", ""); /*MMCB.SDS32
39-L.N */
/**************** MMCB.SDS3239-S.O *****************/
REM SQLExec(" SELECT 'Y' FROM SYSADM.PS_VENDOR_LOC A WHERE A.SETID = 'MMCSA'
AND A.VENDOR_ID =:1 AND A.VNDR_LOC =:2 AND A.EFFDT = (SELECT MAX(A_ED.EFFDT) FRO
M SYSADM.PS_VENDOR_LOC A_ED WHERE A.SETID = A_ED.SETID AND A.VENDOR_ID = A_ED.VE
NDOR_ID AND A.VNDR_LOC = A_ED.VNDR_LOC) AND A.EFF_STATUS = 'A' ", VENDOR_ID, VND
R_LOC, &LOCAL_EXISTE);
/**************** MMCB.SDS3239-E.O *****************/
/**************** MMCB.SDS3239-S.N *****************/
SQLExec(" SELECT 'Y' FROM SYSADM.PS_VENDOR_LOC A WHERE A.SETID = :1 AND A.VEN
DOR_ID =:2 AND A.VNDR_LOC =:3 AND A.EFFDT = (SELECT MAX(A_ED.EFFDT) FROM SYSADM.
PS_VENDOR_LOC A_ED WHERE A.SETID = A_ED.SETID AND A.VENDOR_ID = A_ED.VENDOR_ID A
ND A.VNDR_LOC = A_ED.VNDR_LOC) AND A.EFF_STATUS = 'A' ", &SETID, VENDOR_ID, VNDR
_LOC, &LOCAL_EXISTE);
/**************** MMCB.SDS3239-E.N *****************/
If &LOCAL_EXISTE <> "Y" Then
Error (" Erro: Local " | VNDR_LOC | " no e valido para o fornecedor: " | VE
NDOR_ID);
End-If;
End-If;
/********************** mmcb.hd49956.sn **********************/
[NF_HDR_INFO_WRK.CGC_BRL.FieldChange]
/*******************************************************************************
*****
* Rafael Cruz - MMC - 26/09/2008 - mmcb.hd56498
*
* Utilizar mesma customizacao para pegar dados de estado e origem.
*
********************************************************************************
*****/
/*******************************************************************************
*
* Gustavo V. Neto - MMCB - 30/10/2009 - mmcb.sds3239
*
* Projeto Implantao People - Multi Empresa MMCB-SVB.
*******************************************************************************
*/
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange; /* mmc
b.sds3239.ln */
/*BRLOC-PO-APP-8.00-26/03/01-BEGIN */
/* Busca informaes do fornecedor quando o CNPJ alterado */
If All(CGC_BRL) Then
/* BRLOC - PO - FFR - RELEASE 8.0SP2 - BEGIN - 01/08/2001 */
/* Descrio : Incidente NSANTOS-2W0X5 - Foi alterado o :3 para :2*/
SQLExec("SELECT A.ADDRESS_SEQ_NUM, A.PAY_TRMS_DIV_PBL,B.COLLECT_COD_BRL,B.DEF
AULT_LOC FROM PS_VNDR_ADDR_SCROL A, PS_VENDOR B WHERE A.SETID = B.SETID AND A.VE
NDOR_ID = B.VENDOR_ID AND A.SETID = :1 AND A.ADDRESS_SEQ_NUM = B.ADDR_SEQ_NUM_OR
DR AND A.CGC_BRL = :2", VENDOR.SETID, CGC_BRL, NF_HDR_BRL.ADDRESS_SEQ_NUM, &PAY_
TRMS, NF_HDR_BRL.COLLECT_COD_BRL, NF_HDR_BRL.VNDR_LOC);
/* BRLOC - PO - FFR - RELEASE 8.0SP2 - END - 01/08/2001 */
End-If;
/* Inibe boto de recalculo quando o cgc alterado, pois o sistema deve pegar novam
ente os dados do setup, para fazer os clculos dos impostos */
Gray(RECV_HD_WRK_PBL.NF_RECALC_PBL);
/*BRLOC-PO-APP-8.00-26/03/01-END */
/* BRLOC - PO - FFR - 12/02/2003 - ICE Resolution ID: 118011 - Begin */
/* Busca cdigo de withholding do fornecedor, quando o CNPJ preenchido */
SQLExec("SELECT A.WTHD_CD FROM PS_VENDOR_LOC A WHERE A.SETID = :1 AND A.VENDOR_I
D = :2 AND A.VNDR_LOC = :3 AND A.EFFDT = (SELECT MAX(EFFDT) FROM PS_VENDOR_LOC B
WHERE A.SETID = B.SETID AND A.VENDOR_ID = B.VENDOR_ID AND A.VNDR_LOC = B.VNDR_L
OC AND B.EFFDT <= %DATEIN(:4))", VENDOR.SETID, NF_HDR_BRL.VENDOR_ID, NF_HDR_BRL.
VNDR_LOC, NF_HDR_BRL.NF_BRL_DATE, &WTHD_CD);
For &I = 1 To ActiveRowCount(Record.NF_LN_BRL)
UpdateValue(NF_LN_BRL.WTHD_CD, &I, &WTHD_CD);
End-For;
/* BRLOC - PO - FFR - 12/02/2003 - ICE Resolution ID: 118011 - End */
NF_HDR_BRL.ADDRESS_SEQ_NUM = VNDR_CGC_PBL_VW.ADDRESS_SEQ_NUM;
/*BRLOC-PO-APP-8.01-15/08/01-BEGIN*/
/* incluso do flag IN_OUT_CD_BBL na seleo de Notas Fiscais de entrada */
If All(CGC_BRL) Then
/*************************** mmcb.hd74337.so ***************************/
/*SQLExec("Select distinct 'X' from PS_NF_HDR_BRL where NF_BRL = :1 and VENDO
R_ID IN (SELECT A.VENDOR_ID FROM PS_VNDR_ADDR_SCROL A WHERE A.SETID = 'MMCSA' AN
D A.CGC_BRL = :2) AND ADDRESS_SEQ_NUM IN (SELECT B.ADDRESS_SEQ_NUM FROM PS_VNDR_
ADDR_SCROL B WHERE B.SETID = 'MMCSA' AND B.CGC_BRL = :2) and NF_BRL_SERIES = :3
and NF_BRL_STATUS <> 'X' AND INOUT_FLG_PBL = 'I' AND IN_OUT_CD_BBL = 'I'", NF_HD
R_BRL.NF_BRL, CGC_BRL, NF_HDR_BRL.NF_BRL_SERIES, &RETURN);*/
/*************************** mmcb.hd74337.eo ***************************/
/*************************** mmcb.sds3239.so ***************************/
/*************************** mmcb.hd74337.sn ***************************/
/*
SQLExec("Select distinct 'X' from PS_NF_HDR_BRL where NF_BRL = :1 and VENDOR_
ID IN (SELECT A.VENDOR_ID FROM PS_VNDR_ADDR_SCROL A WHERE A.SETID = 'MMCSA' AND
A.CGC_BRL = :2) AND ADDRESS_SEQ_NUM IN (SELECT B.ADDRESS_SEQ_NUM FROM PS_VNDR_AD
DR_SCROL B WHERE B.SETID = 'MMCSA' AND B.CGC_BRL = :2) and NF_BRL_SERIES = :3 an
d NF_BRL_DATE = to_date(:4,'yyyy-mm-dd') and NF_BRL_STATUS <> 'X' AND INOUT_FLG_
PBL = 'I' AND IN_OUT_CD_BBL = 'I'", NF_HDR_BRL.NF_BRL, CGC_BRL, NF_HDR_BRL.NF_BR
L_SERIES, NF_HDR_BRL.NF_BRL_DATE, &RETURN);
*/
/*************************** mmcb.hd74337.en ***************************/
/*************************** mmcb.sds3239.eo ***************************/
/*************************** mmcb.sds3239.sn ***************************/
SQLExec("Select distinct 'X' from PS_NF_HDR_BRL where NF_BRL = :1 and VENDOR_
ID IN (SELECT A.VENDOR_ID FROM PS_VNDR_ADDR_SCROL A WHERE A.SETID = :2 AND A.CGC
_BRL = :3) AND ADDRESS_SEQ_NUM IN (SELECT B.ADDRESS_SEQ_NUM FROM PS_VNDR_ADDR_SC
ROL B WHERE B.SETID = :4 AND B.CGC_BRL = :5) and NF_BRL_SERIES = :6 and NF_BRL_D
ATE = to_date(:7,'yyyy-mm-dd') and NF_BRL_STATUS <> 'X' AND INOUT_FLG_PBL = 'I'
AND IN_OUT_CD_BBL = 'I'", NF_HDR_BRL.NF_BRL, &SETID, CGC_BRL, &SETID, CGC_BRL, N
F_HDR_BRL.NF_BRL_SERIES, NF_HDR_BRL.NF_BRL_DATE, &RETURN);
/*************************** mmcb.sds3239.en ***************************/
Else
/*************************** mmcb.hd74337.so ***************************/
/*SQLExec("Select 'X' from PS_NF_HDR_BRL where NF_BRL = :1 and VENDOR_ID = :2
and NF_BRL_SERIES = :3 AND AND ADDRESS_SEQ_NUM = :4 and NF_BRL_STATUS <> 'X'
AND INOUT_FLG_PBL = 'I' AND IN_OUT_CD_BBL = 'I'", NF_HDR_BRL.NF_BRL, NF_HDR_BRL.
VENDOR_ID, NF_HDR_BRL.NF_BRL_SERIES, NF_HDR_BRL.ADDRESS_SEQ_NUM, &RETURN);*/
/*************************** mmcb.hd74337.eo ***************************/
/*************************** mmcb.hd74337.sn ***************************/
SQLExec("Select 'X' from PS_NF_HDR_BRL where NF_BRL = :1 and VENDOR_ID = :2 a
nd NF_BRL_SERIES = :3 AND AND ADDRESS_SEQ_NUM = :4 and NF_BRL_DATE = to_date(:
5,'yyyy-mm-dd') and NF_BRL_STATUS <> 'X' AND INOUT_FLG_PBL = 'I' AND IN_OUT_CD_B
BL = 'I'", NF_HDR_BRL.NF_BRL, NF_HDR_BRL.VENDOR_ID, NF_HDR_BRL.NF_BRL_SERIES, NF
_HDR_BRL.ADDRESS_SEQ_NUM, NF_HDR_BRL.NF_BRL_DATE, &RETURN);
/*************************** mmcb.hd74337.en ***************************/
End-If;
/*BRLOC-PO-APP-8.01-15/08/01-END*/
If All(&RETURN) Then
Error MsgGet(30000, 193, "This Nota Fiscal already exists.");
End-If;
/* BRLOC - PO - APP - 8.00 - 09/01/2001 - END */
[NF_HDR_INFO_WRK.CGC_BRL.RowInit]
/*** Jeison Caldas - 29/08/07 - Ativ.2253 - Melhorias no processo de
o ***/
If %Component = "NF_RECV_PBL" And
%Mode <> "A" Then
SQLExec("SELECT CGC_BRL FROM PS_VNDR_ADDR_SCROL WHERE VENDOR_ID =
ESS_SEQ_NUM = :2", NF_HDR_BRL.VENDOR_ID, NF_HDR_BRL.ADDRESS_SEQ_NUM,
End-If;
/*** Jeison Caldas - 29/08/07 - Ativ.2253 - Melhorias no processo de
**/
EDI - Inici
:1 AND ADDR
CGC_BRL);
EDI - Fim *
[NF_HDR_INFO_WRK.MMC_BOTAO.FieldChange]
/* Valmir Tavares - HQS - 29.11.2005 - Adequao para o PSOFT8 - Inicio */
If %Page = Page.NF_INFO_HDR_PBL Then
&BUSINESS_UNIT = MMC_RECV_HDR.BUSINESS_UNIT;
&RECEIVER_ID = MMC_RECV_HDR.RECEIVER_ID;
&MMC_DESCR1A = MMC_DIGITAL_WRK.MMC_NOME_ARQ;
/*MMC_RECV_HDR.MMC_NOME_ARQ;*/
/* &MMC_DESCR1 = "FILE://mmcserver\Doc_Digital\" | &MMC_DESCR1A;Djalma - Su
bstituido pela linha abaixo devido a alteracao das pastas nos servidores*/
&MMC_DESCR1 = "FILE:\\fsspoorg01\FileServer\Administrativo\Contabilidade\376
- Recebimento Fiscal - SPO\Doc_Digital\" | &MMC_DESCR1A;
ViewURL(&MMC_DESCR1);
End-If;
/* Valmir Tavares - HQS - 29.11.2005 - Adequao para o PSOFT8 - Fim */
[NF_HDR_INFO_WRK.NF_BRL_STATUS.FieldChange]
/*BRLOC-PO-HAT-8.00-06/04/01-BEGIN */
/* Atualiza o Status da Header */
If All(NF_BRL_STATUS) Then
NF_HDR_BRL.NF_BRL_STATUS = NF_BRL_STATUS;
End-If;
/*BRLOC-PO-HAT-8.00-06/04/01-END */
[NF_HDR_INFO_WRK.NF_BRL_STATUS.RowInit]
/*BRLOC-PO-HAT-8.00-06/04/01-BEGIN */
/* Move o Status da header para a working*/
NF_BRL_STATUS = NF_HDR_BRL.NF_BRL_STATUS;
/*BRLOC-PO-HAT-8.00-06/04/01-END */
[NF_HDR_INFO_WRK.NF_BRL_STATUS.SaveEdit]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 21/11/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Customizao Sistema de Terceiros - Customizao para forar Usuario a Mudar Status da
NF
*
* para completo Quando NF for de Terceiros.
*
*******************************************************************************
*****************/
/*******************************************************************************
****
* Leandro Rodrigues da Silva Souza - MMCB - 06/07/2009 - MMCB.SDS3141 - Valida
* Serie Por Tipo De Documento
********************************************************************************
****/
/*******************************************************************************
*****
* Wagner Sorio - MMC - 06/12/2010 - mmcb.sds3627 - Folha Autonomo
*
********************************************************************************
*****/
/*******************************************************************************
*****
* Adercley E. Maral - MMC - 13/06/2011 - mmcb.hd143179 - Correcao para 9 digito
s *
********************************************************************************
*****/
/******************************** mmcb.sds3627.S.N *****************************
*****/
Declare Function BUSCA_DADOS_RPA PeopleCode MMC_RPA_WK.FUNCLIB SavePostChange;
Declare Function BUSCA_PERIDO_AUTONOMO PeopleCode MMC_RPA_WK.FUNCLIB SavePostCha
nge;
/******************************** mmcb.sds3627.E.N *****************************
*****/
/************************** MMCB.SDS3141.SN **************************/
Declare Function VALIDA_TIPO_DOCUMENTO PeopleCode MMC_NF_SERIE_WK.NF_BRL_SERIES
FieldFormula;
If ((%Component = Component.NF_RECV_PBL) Or
(%Component = Component.MMC_LANC_GAR) Or
(%Component = Component.NF_INFO_PBL) Or
%Component = Component.NF_INFO_HDR_PBL) Then
If NF_BRL_STATUS = "F" Then
VALIDA_TIPO_DOCUMENTO(%Component, MMC_TE_NFLN_WRK.MMC_TERCEIRO_FLG, NF_BRL
_STATUS, NF_HDR_BRL.NF_BRL_TYPE, NF_HDR_BRL.NF_BRL_SERIES);
End-If;
End-If;
/************************** MMCB.SDS3141.EN **************************/
/********************** mmcb.at2323.sn **********************/
If %Component = "NF_INFO_PBL" And
MMC_TE_NFLN_WRK.MMC_TERCEIRO_FLG = "Y" And
NF_BRL_STATUS <> "F" Then
Error ("Esta uma NF de Terceiros. Para salva-la o Status deve ser: Completo."
);
End-If;
/********************** mmcb.at2323.en **********************/
/******************************** mmcb.sds3627.S.N *****************************
*****/
If (%Component = Component.NF_INFO_PBL Or
* Alterao para zerar ICMS para frete destinado a Zona Franca de Manaus
*
* GKO.
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Bleno L Sampaio - MMC - 13/04/2012 - mmcb.hd138301
*
* Sistema no estava gravando PO_ID na linha da NF para alguns casos.
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Vincius Alvs Mello - MMC - 30/05/2012 - mmcb.hd141963
*
* O nmero do RMA e igual ao do NF_BRL, entretanto o nmero da nota foi alterado
*
* para 9 dgitos e o RMA continuou com 6 dgitos.
*
********************************************************************************
*****************/
/*******************************************************************************
*****************
* Bleno L Sampaio - MMC - 14/06/2012 - mmcb.sds4160
*
* Processo de Aplicao de Voucher de Adiantamento - Inserir na tabela de processame
nto o ID da *
* nota quando a OC referenciada tiver cronograma de adiantamento aprovado.
*
********************************************************************************
*****************/
/*******************************************************************************
*****************
* Rafael da Cruz Nascimento - MMCB.SDS4304 - 21/03/2013
*
* Ordem de Produo em Unidade de Terceiros
*
********************************************************************************
*****************/
/*******************************************************************************
*****************
* Renato / Rosangela Enc. Vinicius Favero - MMCB.HD171529 - 30/04/2013
*
* Verificar se j existe linha antes de inserir
*
********************************************************************************
*****************/
/*******************************************************************************
*****************
* Vincius Alves Mello - MMC - 30/04/2013 - mmcb.hd170820
*
* No verificar se a rea e Wip para SVB.
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
"
&SELECT2
&SELECT2
&SELECT2
&SELECT2
|
|
|
|
"
"
"
"
End-Function;
/********************** mmcb.sds2822.en **********************/
/********************** mmcb.at2323.en **********************/
/*** JEISON CALDAS - 30/03/07 - ATIV. 2068 - EDI FORNECEDOR
Este processo atualiza as notas fiscais de EDI como processadas - Inicio *
**/
&SETID = BUSCA_SETID(); /* mmcb.sds3239.ln */
If %Component = Component.NF_INFO_PBL And
NF_BRL_STATUS = "F" Then
REM CABECALHO;
SQLExec("UPDATE PS_MMC_EDI_HDR SET PROCESS_FLAG = 'Y' WHERE BUSINESS_UNIT = :
1 AND CGC_BRL = :2 AND NF_BRL = :3 AND NF_BRL_SERIES
= :4 AND PROCESS_FLAG <>
'Y'", NF_HDR_BRL.BUSINESS_UNIT, CGC_BRL, NF_HDR_BRL.NF_BRL, NF_HDR_BRL.NF_BRL_S
ERIES);
REM LINHA;
SQLExec("UPDATE PS_MMC_EDI_LN SET PROCESS_FLAG = 'Y' WHERE BUSINESS_UNIT = :1
AND CGC_BRL = :2 AND NF_BRL = :3 AND NF_BRL_SERIES
= :4 AND PROCESS_FLAG <>
'Y'", NF_HDR_BRL.BUSINESS_UNIT, CGC_BRL, NF_HDR_BRL.NF_BRL, NF_HDR_BRL.NF_BRL_S
ERIES);
End-If;
/*** JEISON CALDAS - 30/03/07 - ATIV. 2068 - EDI FORNECEDOR
Este processo atualiza as notas fiscais de EDI como processadas - Fim ***/
/********************** mmcb.at2323.sn **********************/
If %Component = Component.NF_INFO_PBL And
MMC_TE_NFLN_WRK.MMC_TERCEIRO_FLG = "Y" And
NF_BRL_STATUS = "F" Then
&FLAG_EXECUTOU = "N";
&ULTIMA_LINHA = "N";
&NF_NIVEL1 = GetRowset(Scroll.NF_LN_BRL);
If MMC_TE_NFLN_WRK.MMC_TE_TRIANG_FLG = "N" Then
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||
INICIO CRIANDO RECEBIMENTO REMESSA E ORDEM
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
&PO_NIVEL1 = GetRowset(Scroll.MMC_TE_OC_VW);
If &FLAG_EXECUTOU = "N" Then
&PAR_RECEIVER_ID = MMC_NUMERACAO_ID(1);
End-If;
&PAR_NF_BRL_ID = NF_HDR_BRL.NF_BRL_ID;
&PAR_PRECO_UNITARIO = &NF_NIVEL1.GetRow(&LN).NF_LN_BRL.UNIT_PRICE.VALUE
;
&PAR_RECV_LN_NBR = &LN;
&PAR_RECV_SHIP_SEQ_NBR = 1;
/*
&PAR_SETID = "MMCSA"; */ /* mmcb.sds3239.lo */
&PAR_SETID = &SETID; /* mmcb.sds3239.ln */
/*
SQLExec("select inventory_item from sysadm.ps_master_item_tbl
where setid='MMCSA' and inv_item_id=:1", &NF_NIVEL1.GETROW(&LN).NF_LN_BRL.INV_I
TEM_ID.VALUE, &ITEM_ESTOQUE); */ /* mmcb.sds3239.lo */
SQLExec("select inventory_item from sysadm.ps_master_item_tbl where set
id=:1 and inv_item_id=:2", &SETID, &NF_NIVEL1.GETROW(&LN).NF_LN_BRL.INV_ITEM_ID.
VALUE, &ITEM_ESTOQUE); /* mmcb.sds3239.ln */
If &ITEM_ESTOQUE <> "Y" Then
Error ("Item: " | &NF_NIVEL1.GETROW(&LN).NF_LN_BRL.INV_ITEM_ID.VALUE
| " no de estoque");
End-If;
SQLExec("select distrib_type from sysadm.ps_mmc_te_recv_par where busin
ess_unit_recv=:1 and eff_status='A'", NF_HDR_BRL.BUSINESS_UNIT, &PAR_DISTRIB_TYP
E);
If None(&PAR_DISTRIB_TYPE) Or
&PAR_DISTRIB_TYPE = "" Or
&PAR_DISTRIB_TYPE = " " Then
Error ("No foi possivel localicar distribuio para UN: " | NF_HDR_BRL.BU
SINESS_UNIT);
End-If;
CRIA_RECEBIMENTO_FISICO(&PAR_BUSINESS_UNIT, &PAR_RECEIVER_ID, &PAR_RECV
_LN_NBR, &PAR_RECV_SHIP_SEQ_NBR, &PAR_PO_ID, &PAR_LINE_NBR, &PAR_SCHED_NBR, &PAR
_QTD_ACEITA, &PAR_NF_BRL, &PAR_NF_BRL_SERIES, &PAR_NF_BRL_DATE, &ULTIMA_LINHA, &
PAR_CUSTO_TERCEIRO_FLG, &PAR_CUSTO_TERCEIRO, &PAR_NF_BRL_ID, &PAR_PRECO_UNITARIO
, &PAR_DISTRIB_TYPE, &PAR_SETID);
rem
geraPreRecebimento(&PAR_BUSINESS_UNIT, &PAR_RECEIVER_ID, &P
AR_RECV_LN_NBR, "Y"); /** MMCB.SDS3562.LN **/
/*geraPreRecebimento(&PAR_BUSINESS_UNIT, &PAR_RECEIVER_ID, &PAR_RECV_LN
_NBR);*/ /** MMCB.SDS3562.LN **/
&NF_BRL_LINE_NUM = &NF_NIVEL1.GetRow(&LN).NF_LN_BRL.NF_BRL_LINE_NUM.VAL
UE;
SQLExec("update sysadm.ps_nf_ln_brl set business_unit_recv=:1, receiver
_id=:2, recv_ln_nbr=:3, recv_ship_seq_nbr=:4, po_id=:5 where business_unit=:6 an
d nf_brl_id=:7 and nf_brl_line_num=:8", NF_HDR_BRL.BUSINESS_UNIT, &PAR_RECEIVER_
ID, &PAR_RECV_LN_NBR, &PAR_RECV_SHIP_SEQ_NBR, &PAR_PO_ID, NF_HDR_BRL.BUSINESS_UN
IT, NF_HDR_BRL.NF_BRL_ID, &NF_BRL_LINE_NUM);
&FLAG_EXECUTOU = "Y";
/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||
End-If;
GRAVA_SALDO_NF_TERCEIRO(&N_BUSINESS_UNIT, &N_NF_BRL_ID, &N_NF_BRL, &N_N
F_BRL_SERIES, &N_VENDOR_ID, &N_ADDRESS_SEQ_NUM, &N_IRTAX_BRL_AMT, &N_MMC_IR_SALD
O, &N_NF_BRL_LINE_NUM, &N_INV_ITEM_ID, &N_INV_LOT_ID, &N_SERIAL_ID, &N_QTY, &N_Q
TY_AVAILABLE, &N_ICMSTAX_BRL_AMT, &N_MMC_ICMS_SALDO, &N_IPITAX_BRL_AMT, &N_MMC_I
PI_SALDO, &N_PISTAX_BRL_AMT, &N_MMC_PIS_SALDO, &N_COFINSTAX_BRL_AMT, &N_MMC_COFI
NS_SALDO, &N_ISSTAX_BRL_AMT, &N_MMC_ISS_SALDO);
/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||
|| FIM Criando saldo Estoque Terceiros.
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||*/
End-For;
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||
FIM CRIANDO RECEBIMENTO REMESSA E ORDEM
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
Else
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||
INICIO TRIANGULAO
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
SQLExec("select distrib_type, deptid from sysadm.ps_mmc_te_recv_par where
business_unit_recv=:1 and mmc_te_tipo_recv='2' and mmc_cntrl_terc='Y'", NF_HDR_B
RL.BUSINESS_UNIT, &VAR_DISTRIB_TYPE, &VAR_DEPTID);
&L1_NF = GetRowset(Scroll.NF_LN_BRL);
&L1_NF_TRIAN = GetRowset(Scroll.MMC_TE_S_NF_VW);
If &FLAG_EXECUTOU = "N" Then
&PAR_RECEIVER_ID = MMC_NUMERACAO_ID(1);
End-If;
&NUM_LINHAS_NF = &L1_NF.ActiveRowCount;
REM UNIDADE ESTOQUE TRIANGULAO;
/*
SQLExec("select business_unit_in from sysadm.ps_shipto_tbl where se
tid='MMCSA' and business_unit_recv=:1", NF_HDR_BRL.BUSINESS_UNIT, &TRI_BU_ESTOQU
E); */ /* mmcb.sds3239.lo */
SQLExec("select business_unit_in from sysadm.ps_shipto_tbl where setid= :1
and business_unit_recv=:2", &SETID, NF_HDR_BRL.BUSINESS_UNIT, &TRI_BU_ESTOQUE);
/* mmcb.sds3239.ln */
/*
Error ("SETID " | &SETID | " " | &TRI_BU_ESTOQUE | " - " | NF_HDR_
BRL.BUSINESS_UNIT); AQUI */
If None(&TRI_BU_ESTOQUE) Then
Error ("No foi possivel encontrar UN Estoque para Unidade Recebimento: "
| NF_HDR_BRL.BUSINESS_UNIT);
End-If;
&PAR_BUSINESS_UNIT_IN = &TRI_BU_ESTOQUE;
/*
&PAR_BUSINESS_UNIT_GL = "MMCSA"; */ /* mmcb.sds3239.lo */
&PAR_BUSINESS_UNIT_GL = &SETID; /* mmcb.sds3239.ln */
&PAR_DESCR_ITEM = &L1_NF.GetRow(&INT).NF_LN_BRL.DESCR.VALUE;
/*
SQLExec("select account from sysadm.ps_itm_purch_vw where se
tid='MMCSA' and inv_item_id =:1 ", &PAR_INV_ITEM_ID, &PAR_ACCOUNT); */ /* mmcb.s
ds3239.lo */
SQLExec("select account from sysadm.ps_itm_purch_vw where setid=:1 and
inv_item_id =:2 ", &SETID, &PAR_INV_ITEM_ID, &PAR_ACCOUNT); /* mmcb.sds3239.ln *
/
&PAR_DEPTID = &VAR_DEPTID;
If MMC_TE_RECV_WRK.MMC_TE_NFSERVI_FLG = "Y" Then
&PAR_BUSINESS_UNIT_PO = &L1_NF.GetRow(&INT).MMC_TE_OP_WRK.BUSINESS_U
NIT_PO.VALUE;
&PAR_PO_ID = &L1_NF.GetRow(&INT).MMC_TE_OP_WRK.PO_ID.VALUE;
&PAR_PO_LINE_NBR = &L1_NF.GetRow(&INT).MMC_TE_OP_WRK.LINE_NBR.VALUE;
&PAR_PO_SCHED_NBR = &L1_NF.GetRow(&INT).MMC_TE_OP_WRK.SCHED_NBR.VALU
E;
If None(&PAR_BUSINESS_UNIT_PO) Or
None(&PAR_PO_ID) Or
None(&PAR_PO_LINE_NBR) Or
None(&PAR_PO_SCHED_NBR) Then
Error ("Error existe valores em branco com informaes Ordem Compra d
e Industrializao. ");
End-If;
Else
&PAR_PO_ID = " ";
&PAR_PO_LINE_NBR = 0;
&PAR_PO_SCHED_NBR = 0;
&PAR_BUSINESS_UNIT_PO = NF_HDR_BRL.BUSINESS_UNIT;
End-If;
/*SQLExec("select inventory_item from sysadm.ps_master_item_tbl where s
etid='MMCSA' and inv_item_id=:1", &PAR_INV_ITEM_ID, &ITEM_ESTOQUE);*/ /*mmcb.sds
3239.lo*/
SQLExec("select inventory_item from sysadm.ps_master_item_tbl where set
id=:1 and inv_item_id=:2", &SETID, &PAR_INV_ITEM_ID, &ITEM_ESTOQUE); /*mmcb.sds3
239.ln*/
If &ITEM_ESTOQUE <> "Y" Then
Error ("Item: " | &PAR_INV_ITEM_ID | " no de estoque");
End-If;
/*SQLExec("select distrib_type from sysadm.ps_mmc_te_recv_par where bus
iness_unit_recv=:1 and eff_status='A' and mmc_te_tipo_recv='2'", NF_HDR_BRL.BUSI
NESS_UNIT, &PAR_DISTRIB_TYPE);*/ /*mmcb.sds4388.lo*/
SQLExec("select distrib_type from sysadm.ps_mmc_te_recv_par where busin
ess_unit_recv=:1 and eff_status='A' and mmc_te_tipo_recv IN ('2','3')", NF_HDR_B
RL.BUSINESS_UNIT, &PAR_DISTRIB_TYPE); /*mmcb.sds4388.ln*/
If None(&PAR_DISTRIB_TYPE) Or
&PAR_DISTRIB_TYPE = "" Or
&PAR_DISTRIB_TYPE = " " Then
Error ("No foi possivel localicar distribuio para UN: " | NF_HDR_BRL.BU
SINESS_UNIT);
End-If;
CRIA_RECV_FISICO_TRIAN(&PAR_BUSINESS_UNIT, &PAR_RECEIVER_ID, &PAR_RECV_
LN_NBR, &PAR_RECV_SHIP_SEQ_NBR, &PAR_VENDOR_ID, &PAR_VNDR_LOC, &PAR_NF_BRL, &PAR
_NF_BRL_SERIES, &PAR_NF_BRL_DATE, &PAR_ADDRESS_SEQ_NUM, &PAR_SHIPTO_ID, &PAR_SET
ID, &PAR_DEPTID, &PAR_INV_ITEM_ID, &PAR_INV_LOT_ID, &PAR_SERIAL_ID, &PAR_UNIT_OF
_MEASURE, &PAR_QTD, &PAR_PRECO_UNITARIO, &PAR_CUSTO_TERCEIRO_FLG, &PAR_CUSTO_TER
CEIRO, &PAR_BUSINESS_UNIT_IN, &PAR_BUSINESS_UNIT_GL, &PAR_BUSINESS_UNIT_PO, &PAR
_PO_ID, &PAR_PO_LINE_NBR, &PAR_PO_SCHED_NBR, &PAR_DESCR_ITEM, &PAR_ACCOUNT, &ULT
IMA_LINHA, &PAR_DISTRIB_TYPE);
rem
geraPreRecebimento(&PAR_BUSINESS_UNIT, &PAR_RECEIVER_ID, &P
AR_RECV_LN_NBR, "Y"); /** MMCB.SDS3562.LN **/
/*geraPreRecebimento(&PAR_BUSINESS_UNIT, &PAR_RECEIVER_ID, &PAR_RECV_LN
_NBR);*/ /** MMCB.SDS3562.LN **/
&NF_BRL_LINE_NUM = &L1_NF.GetRow(&INT).NF_LN_BRL.NF_BRL_LINE_NUM.VALUE;
/****************************************mmcb.hd138301.so**************
**************************/
/*SQLExec("update sysadm.ps_nf_ln_brl set business_unit_recv=:1, receiv
er_id=:2, recv_ln_nbr=:3, recv_ship_seq_nbr=:4, po_id=:5 where business_unit=:6
and nf_brl_id=:7 and nf_brl_line_num=:8", NF_HDR_BRL.BUSINESS_UNIT, &PAR_RECEIVE
R_ID, &L1_NF.GetRow(&INT).NF_LN_BRL.NF_BRL_LINE_NUM.VALUE, &L1_NF.GetRow(&INT).N
F_LN_BRL.NF_BRL_LINE_NUM.VALUE, " ", NF_HDR_BRL.BUSINESS_UNIT, NF_HDR_BRL.NF_BRL
_ID, &L1_NF.GetRow(&INT).NF_LN_BRL.NF_BRL_LINE_NUM.VALUE);*/
/****************************************mmcb.hd138301.eo**************
**************************/
/****************************************mmcb.hd138301.sn**************
**************************/
SQLExec("update sysadm.ps_nf_ln_brl set business_unit_recv=:1, receiver
_id=:2, recv_ln_nbr=:3, recv_ship_seq_nbr=:4, po_id=:5 where business_unit=:6 an
d nf_brl_id=:7 and nf_brl_line_num=:8", NF_HDR_BRL.BUSINESS_UNIT, &PAR_RECEIVER_
ID, &L1_NF.GetRow(&INT).NF_LN_BRL.NF_BRL_LINE_NUM.VALUE, &L1_NF.GetRow(&INT).NF_
LN_BRL.NF_BRL_LINE_NUM.VALUE, &PAR_PO_ID, NF_HDR_BRL.BUSINESS_UNIT, NF_HDR_BRL.N
F_BRL_ID, &L1_NF.GetRow(&INT).NF_LN_BRL.NF_BRL_LINE_NUM.VALUE);
/****************************************mmcb.hd138301.en**************
**************************/
If (&PAR_RECEIVER_ID) <> "NONE" Then /* mmcb.hd233763.ln */
SQLExec("update sysadm.ps_recv_hdr set recv_status = 'M', intfc_asse
t = 'N', intfc_inventory = 'N', intfc_mg = 'N', flg_nf_fiscal_pbl = 'N' where bu
siness_unit=:1 and receiver_id=:2", NF_HDR_BRL.BUSINESS_UNIT, &PAR_RECEIVER_ID);
End-If; /* mmcb.hd233763.ln */
&FLAG_EXECUTOU = "Y";
/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||
|| Austando saldo Estoque Terceiros.
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||*/
If MMC_TE_RECV_WRK.MMC_TE_NFSERVI_FLG = "N" Then
&N1_BUSINESS_UNIT = &L1_NF_TRIAN.GetRow(&INT).MMC_TE_S_NF_VW.BUSINES
S_UNIT.VALUE;
&N1_NF_BRL_ID = &L1_NF_TRIAN.GetRow(&INT).getrecord(Record.MMC_TE_S_
NF_VW).NF_BRL_ID.VALUE;
&N1_NF_BRL_LINE_NUM = &L1_NF_TRIAN.GetRow(&INT).MMC_TE_S_NF_VW.NF_BR
L_LINE_NUM.VALUE;
&N1_QTY_AVAILABLE = &L1_NF.GetRow(&INT).NF_LN_BRL.QTY_NF_BRL.VALUE;
&N1_MMC_ICMS_SALDO = &L1_NF.GetRow(&INT).NF_LN_BRL.ICMSTAX_BRL_AMT.V
ALUE;
&N1_MMC_IPI_SALDO = &L1_NF.GetRow(&INT).NF_LN_BRL.IPITAX_BRL_AMT.VAL
UE;
&N1_MMC_PIS_SALDO = &L1_NF.GetRow(&INT).NF_LN_BRL.PISTAX_BRL_AMT.VAL
UE;
&N1_MMC_COFINS_SALDO = &L1_NF.GetRow(&INT).NF_LN_BRL.COFINSTAX_BRL_A
MT.VALUE;
&N1_MMC_ISS_SALDO = &L1_NF.GetRow(&INT).NF_LN_BRL.ISSTAX_BRL_AMT.VAL
UE;
AJUSTA_SALDO_NF_TERCEIRO(&N1_BUSINESS_UNIT, &N1_NF_BRL_ID, &N1_NF_BR
L_LINE_NUM, &N1_QTY_AVAILABLE, &N1_MMC_ICMS_SALDO, &N1_MMC_IPI_SALDO, &N1_MMC_PI
S_SALDO, &N1_MMC_COFINS_SALDO, &N1_MMC_ISS_SALDO);
End-If;
/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||||||||
|| FIM Ajustando saldo Estoque Terceiros.
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||*/
End-For;
/* SQLExec("update sysadm.ps_nf_hdr_brl set voucher_flow_pbl='N' where bus
iness_unit=:1 and nf_brl_id=:2", NF_HDR_BRL.BUSINESS_UNIT, NF_HDR_BRL.NF_BRL_ID)
; */
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||
FIM TRIANGULAO
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
End-If;
/* IF MMC_TE_NFLN_WRK.MMC_TE_TRIANG_FLG = "N" THEN */
If (&PAR_RECEIVER_ID) <> "NONE" Then /* mmcb.hd233763.ln */
SQLExec("update sysadm.ps_recv_hdr set flg_nf_fiscal_pbl='Y' where busines
s_unit=:1 and receiver_id=:2 ", NF_HDR_BRL.BUSINESS_UNIT, &PAR_RECEIVER_ID);
End-If; /* mmcb.hd233763.ln */
SQLExec("update sysadm.ps_nf_hdr_brl set business_unit_recv=:1, receiver_id=:
2 where business_unit=:3 and nf_brl_id=:4", NF_HDR_BRL.BUSINESS_UNIT, &PAR_RECEI
VER_ID, NF_HDR_BRL.BUSINESS_UNIT, NF_HDR_BRL.NF_BRL_ID);
/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|| INICIO BAIXA NA TRIANGULAO
||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
If MMC_TE_NFLN_WRK.MMC_TE_TRIANG_FLG = "Y" And
MMC_TE_RECV_WRK.MMC_TE_NFSERVI_FLG = "N" Then
REM *******************************************;
REM PEGA UNIDADE NEGOCIO ESTOQUE;
REM *******************************************;
/* SQLExec("select business_unit_in from sysadm.ps_mmc_te_recv_par where b
usiness_unit_recv =:1 and eff_status='A' and mmc_cntrl_terc='Y'", NF_HDR_BRL.BUS
INESS_UNIT, &B_BUSINESS_UNIT); */
For &B = 1 To &L1_NF.ActiveRowCount;
&BUNITS = &L1_NF_TRIAN.GetRow(&B).MMC_TE_S_NF_VW.BUSINESS_UNIT.VALUE;
&NFS = &L1_NF_TRIAN.GetRow(&B).MMC_TE_S_NF_VW.NF_BRL_ID.VALUE;
/*
SQLExec("SELECT T.MMC_STOCK_UN, COUNT( DISTINCT T.MMC_STOCK_
UN ) FROM SYSADM.PS_NF_LN_BRL N, SYSADM.PS_MMC_TE_TOF_TYPE T WHERE N.BUSINESS_
UNIT = :1 AND N.NF_BRL_ID = :2 AND T.TOF_PBL = N.TOF_PBL AND 'O' = ( SELECT INOU
T_FLG_PBL FROM SYSADM.PS_NF_HDR_BRL WHERE BUSINESS_UNIT = N.BUSINESS_UNIT AND NF
_BRL_ID = N.NF_BRL_ID ) AND T.EFFDT = (SELECT MAX(TI.EFFDT) FROM SYSADM.PS_MMC_T
E_TOF_TYPE TI WHERE TI.TOF_PBL = T.TOF_PBL ) GROUP BY T.MMC_STOCK_UN UNION SEL
ECT S.BUSINESS_UNIT_IN, COUNT( DISTINCT S.BUSINESS_UNIT_IN) FROM SYSADM.PS_SHI
PTO_TBL S WHERE S.SETID = 'MMCSA' AND S.BUSINESS_UNIT_RECV = :3 AND 'I' = ( SEL
ECT INOUT_FLG_PBL FROM SYSADM.PS_NF_HDR_BRL WHERE BUSINESS_UNIT = :4 AND NF_BRL_
ID = :5 ) AND S.EFFDT = ( SELECT MAX(SI.EFFDT) FROM SYSADM.PS_SHIPTO_TBL SI WHER
E SI.SETID = S.SETID AND SI.BUSINESS_UNIT_RECV = S.BUSINESS_UNIT_RECV ) GROUP BY
S.BUSINESS_UNIT_IN", &BUNITS, &NFS, &BUNITS, &BUNITS, &NFS, &B_BUSINESS_UNIT, &
CONTA_BU); */ /* mmcb.sds3239.lo */
SQLExec("SELECT T.MMC_STOCK_UN, COUNT( DISTINCT T.MMC_STOCK_UN ) FROM
SYSADM.PS_NF_LN_BRL N, SYSADM.PS_MMC_TE_TOF_TYPE T WHERE N.BUSINESS_UNIT = :1 A
ND N.NF_BRL_ID = :2 AND T.TOF_PBL = N.TOF_PBL AND 'O' = ( SELECT INOUT_FLG_PBL F
ROM SYSADM.PS_NF_HDR_BRL WHERE BUSINESS_UNIT = N.BUSINESS_UNIT AND NF_BRL_ID = N
.NF_BRL_ID ) AND T.EFFDT = (SELECT MAX(TI.EFFDT) FROM SYSADM.PS_MMC_TE_TOF_TYPE
TI WHERE TI.TOF_PBL = T.TOF_PBL ) GROUP BY T.MMC_STOCK_UN UNION SELECT S.BUSI
NESS_UNIT_IN, COUNT( DISTINCT S.BUSINESS_UNIT_IN) FROM SYSADM.PS_SHIPTO_TBL S W
HERE S.SETID = :3 AND S.BUSINESS_UNIT_RECV = :4 AND 'I' = ( SELECT INOUT_FLG_PB
L FROM SYSADM.PS_NF_HDR_BRL WHERE BUSINESS_UNIT = :5 AND NF_BRL_ID = :6 ) AND S.
EFFDT = ( SELECT MAX(SI.EFFDT) FROM SYSADM.PS_SHIPTO_TBL SI WHERE SI.SETID = S.S
ETID AND SI.BUSINESS_UNIT_RECV = S.BUSINESS_UNIT_RECV ) GROUP BY S.BUSINESS_UNIT
_IN", &BUNITS, &NFS, &SETID, &BUNITS, &BUNITS, &NFS, &B_BUSINESS_UNIT, &CONTA_BU
); /* mmcb.sds3239.ln */
If (&NFS = "DS00000001") Or
(&NFS = "DS00000002") Or
(&NFS = "DS00000003") Then
&B_BUSINESS_UNIT = "ESTEC"; /* CLAUDIO FABIANO */
&CONTA_BU = 1;
End-If;
If &B = 1 Then
&BUNITS_TEMP = &B_BUSINESS_UNIT;
End-If;
If None(&B_BUSINESS_UNIT) Or
&CONTA_BU <> 1 Then
/*Error ("Unidades de Negcio de retirada de material diferentes para
linhas da NF ( " | &BUNITS | " - " | &NFS | " - " | &BUNITS | " - " | &BUNITS |
" - " | &NFS | " - " | &B_BUSINESS_UNIT | " )");*/
End-If;
If None(&B_BUSINESS_UNIT) Then
Error ("No foi possivel encontar Unidade Negocio Estoque");
End-If;
If &BUNITS_TEMP <> &B_BUSINESS_UNIT Then
Error ("Unidades de Negcio de retirada de material diferentes para li
nhas da NF");
End-If;
&B_INV_ITEM_ID = &L1_NF_TRIAN.GetRow(&B).MMC_TE_S_NF_VW.INV_ITEM_ID.VAL
UE;
&B_INV_LOT_ID = &L1_NF_TRIAN.GetRow(&B).MMC_TE_WRK.INV_LOT_ID.VALUE;
&B_SERIAL_ID = &L1_NF_TRIAN.GetRow(&B).MMC_TE_WRK.SERIAL_ID.VALUE;
&B_CONTAINER_ID = " ";
rem este select ja pega QTD do item convertida do Recebimento de proces
so;
SQLExec("select qty_sh_recvd_suom, UNIT_MEASURE_STD from sysadm.ps_recv
_ln_ship where business_unit =:1 and receiver_id =:2 and recv_ln_nbr= :3 and rec
v_ship_seq_nbr=:4", NF_HDR_BRL.BUSINESS_UNIT, &PAR_RECEIVER_ID, &L1_NF.GetRow(&B
).NF_LN_BRL.NF_BRL_LINE_NUM.VALUE, &L1_NF.GetRow(&B).NF_LN_BRL.NF_BRL_LINE_NUM.V
ALUE, &B_QTD, &B_UNIT_OF_MEASURE);
If None(&B_UNIT_OF_MEASURE) Or
None(&B_QTD) Then
Error ("Erro Unidade Medida ou Qtd no Recebimento: " | &PAR_RECEIVER
_ID | " Item: " | &L1_NF.GetRow(&B).NF_LN_BRL.INV_ITEM_ID.VALUE);
End-If;
&B_DT_TIMESTAMP = %Datetime;
&B_ORDER_NO = &L1_NF.GetRow(&B).NF_LN_BRL.NF_BRL_ID.VALUE;
&B_ORDER_INT_LINE_NO = &L1_NF.GetRow(&B).NF_LN_BRL.NF_BRL_LINE_NUM.VALU
E;
&B_TRANSACTION_DATE = %Date;
&SELECT1
&SELECT1
&SELECT1
&SELECT1
&SELECT1
&SELECT1
&SELECT1
&SELECT1
&SELECT1
&SELECT1
&SELECT1
&SELECT1
UANTIDADE ";
&SELECT1
=
=
=
=
=
=
=
=
=
=
=
=
"
&SELECT1
&SELECT1
&SELECT1
&SELECT1
&SELECT1
&SELECT1
&SELECT1
&SELECT1
&SELECT1
&SELECT1
&SELECT1
|
|
|
|
|
|
|
|
|
|
|
= &SELECT1 | "
If None(&DF_STORAGE_AREA) Or
None(&DF_STOR_LEVEL_1)
None(&DF_STOR_LEVEL_2)
None(&DF_STOR_LEVEL_3)
None(&DF_STOR_LEVEL_4)
Or
Or
Or
Then
=
=
=
=
=
&DF_STORAGE_AREA;
&DF_STOR_LEVEL_1;
&DF_STOR_LEVEL_2;
&DF_STOR_LEVEL_3;
&DF_STOR_LEVEL_4;
End-If;
&B_DEPTID = &VAR_DEPTID;
&B_DISTRIB_TYPE = &VAR_DISTRIB_TYPE;
&B_SHIP_ID = " ";
&B_SOURCE_BUS_UNIT = &L1_NF_TRIAN.GetRow(&B).MMC_TE_S_NF_VW.BUSINESS_UN
IT.VALUE;
/*********************************************** mmcb.hd111096.sn *****
******************************************/
If (None(&B_INV_LOT_ID) Or
&B_INV_LOT_ID = " ") Then
&B_INV_LOT_ID = "NONE";
End-If;
If (None(&B_SERIAL_ID) Or
&B_SERIAL_ID = " ") Then
&B_SERIAL_ID = "NONE";
End-If;
/*********************************************** mmcb.hd111096.en *****
******************************************/
BAIXA_ESTOQUE(&B_BUSINESS_UNIT, &B_INV_ITEM_ID, &B_INV_LOT_ID, &B_QTD,
&B_UNIT_OF_MEASURE, &B_SERIAL_ID, &B_DT_TIMESTAMP, &B_ORDER_NO, &B_ORDER_INT_LIN
E_NO, &B_TRANSACTION_DATE, &B_STORAGE_AREA, &B_STOR_LEVEL_1, &B_STOR_LEVEL_2, &B
_STOR_LEVEL_3, &B_STOR_LEVEL_4, &B_DEPTID, &B_DISTRIB_TYPE, &B_SHIP_ID, &B_SOURC
E_BUS_UNIT);
SQLExec("select %DateTimeOut(dt_timestamp), seq_nbr from sysadm.ps_tra
nsaction_inv where business_unit = :1 and inv_item_id= :2 and dt_timestamp >= SY
SDATE -1 and dt_timestamp <= SYSDATE +1 and order_no=:3 and order_int_line_no =:
4 and transaction_group='030' ", &B_BUSINESS_UNIT, &B_INV_ITEM_ID, &B_ORDER_NO,
&B_ORDER_INT_LINE_NO, &TRANSAC_DT_TIMESTAMP, &TRANSAC_SEQ_NBR);
If None(&TRANSAC_DT_TIMESTAMP) Or
None(&TRANSAC_SEQ_NBR) Then
Error (" Erro: 1 - No foi encontradao DT_TIMESTAMP ou SEQ_NBR para gr
avar na tabela Transao Terceiros.");
End-If;
&TR_SETID = " ";
&TR_MMC_TE_SOL_ID = 0;
&TR_LINE_NBR = 0;
&TR_BUSINESS_UNIT_BI = NF_HDR_BRL.BUSINESS_UNIT;
&TR_NF_BRL_ID = NF_HDR_BRL.NF_BRL_ID;
&TR_NF_BRL_LINE_NUM = &L1_NF.GetRow(&B).NF_LN_BRL.NF_BRL_LINE_NUM.VALUE
;
&TR_MMC_TE_OPERACAO = "100";
&TR_BUSINESS_UNIT = &B_BUSINESS_UNIT;
&TR_INV_ITEM_ID = &B_INV_ITEM_ID;
&TR_DT_TIMESTAMP = &TRANSAC_DT_TIMESTAMP;
&TR_SEQ_NBR = &TRANSAC_SEQ_NBR;
&TR_TRANSACTION_GROUP = "030";
&TR_BUSINESS_UNIT_TO = " ";
&TR_DT_TIMESTAMP_TO = Date3(1900, 1, 1);
&TR_SEQ_NBR_TO = 0;
&TR_MMC_TRAN_GROUP = " ";
&TR_MMC_UN_ORIGEM = &L1_NF_TRIAN.GetRow(&B).MMC_TE_S_NF_VW.BUSINESS_UNI
T.VALUE;
&TR_NF_ID_ORIGEM = &L1_NF_TRIAN.GetRow(&B).MMC_TE_S_NF_VW.NF_BRL_ID.VAL
UE;
&TR_NF_LINE_ORIGEM = &L1_NF_TRIAN.GetRow(&B).MMC_TE_S_NF_VW.NF_BRL_LINE
_NUM.VALUE;
GRAVA_TRANSACAO_TERCEIROS(&TR_SETID, &TR_MMC_TE_SOL_ID, &TR_LINE_NBR, &
TR_BUSINESS_UNIT_BI, &TR_NF_BRL_ID, &TR_NF_BRL_LINE_NUM, &TR_MMC_TE_OPERACAO, &T
*/
/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|| FIM BAIXA NA TRIANGULAO
||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| */
/*===========================================================================
=
INICIO: Gerando Entrada Estoque
============================================================================*/
/****************************************************************************
*********************************************
SQLExec("select 'X' from ps_recv_hdr a , ps_vendor b where a.vendor_setid = b
.setid and a.vendor_id = b.vendor_id and (a.recv_status = 'R' or a.intfc_asset =
'Y' or a.intfc_inventory = 'Y' or a.intfc_mg = 'Y') and a.flg_nf_fiscal_pbl = '
Y' and exists ( select 'X' from ps_nf_hdr_brl where ps_nf_hdr_brl.business_unit_
recv = a.business_unit and ps_nf_hdr_brl.receiver_id = a.receiver_id and ps_nf_h
dr_brl.nf_brl_status <> 'O' and ps_nf_hdr_brl.nf_brl_status <> 'X' and ps_nf_hdr
_brl.appr_status = 'A') and a.business_unit=:1 and a.receiver_id=:2", NF_HDR_BRL
.BUSINESS_UNIT, &PAR_RECEIVER_ID, &RECV_NO_PROCESSO);
If &RECV_NO_PROCESSO = "X" Then
********************************************************************************
********************************/
SQLExec("select business_unit_in from sysadm.ps_mmc_te_recv_par where busines
s_unit_recv =:1 and eff_status='A' and mmc_cntrl_terc='Y'", NF_HDR_BRL.BUSINESS_
UNIT, &BU_ESTOQUE);
If None(&BU_ESTOQUE) Then
SQLExec(" select distinct business_unit_in from sysadm.ps_recv_ln_ship whe
re business_unit =:1 and receiver_id =:2 and rownum = 1 ", NF_HDR_BRL.BUSINESS_U
NIT, &PAR_RECEIVER_ID, &BU_ESTOQUE);
&REMESSA_CONTA_ORDEM = "N";
Else
&REMESSA_CONTA_ORDEM = "Y";
End-If;
&xSQL1 = "select d.lot_id, d.container_id, b.inv_item_id, d.serial_id, b.rece
iver_id, b.recv_ln_nbr, b.recv_ship_seq_nbr, a.business_unit, c.distrib_line_num
, c.recv_ship_seq_nbr, c.po_id, c.line_nbr, b.inspect_status, d.actual_cost, b.c
onversion_rate, b.qty_ln_inv_suom, b.unit_measure_std, a.vendor_id, b.production
_id, e.op_seq, d.storage_code, c.distrib_type, b.config_code, c.account, c.altac
ct, c.operating_unit, c.deptid, c.product, c.project_id, c.activity_id, c.resour
ce_type, c.resource_category, c.resource_sub_cat, c.analysis_type, c.business_un
it_pc, c.consigned_flag from ps_recv_hdr a, ";
&xSQL2 = " ps_recv_ln_ship b, ps_recv_ln_distrib c, ps_recv_ln_asset d, ps_re
cv_ln_insp e where a.business_unit = :1 and a.receiver_id = :2 and a.business_u
nit = b.business_unit and a.receiver_id = b.receiver_id and b.business_unit = c.
business_unit and b.receiver_id = c.receiver_id and b.recv_ln_nbr = c.recv_ln_nb
r and b.recv_ship_seq_nbr = c.recv_ship_seq_nbr and b.business_unit = d.business
_unit and b.receiver_id = d.receiver_id and b.recv_ln_nbr = d.recv_ln_nbr and b.
recv_ship_seq_nbr = d.recv_ship_seq_nbr and b.business_unit = e.business_unit an
d b.receiver_id = e.receiver_id and b.recv_ln_nbr = e.recv_ln_nbr ";
&xSQL = &xSQL1 | &xSQL2;
&sqlRECV = CreateSQL(&xSQL, NF_HDR_BRL.BUSINESS_UNIT, &PAR_RECEIVER_ID);
While &sqlRECV.fetch(&R_LOT_ID, &R_CONTAINER_ID, &R_INV_ITEM_ID, &R_SERIAL_ID
, &R_RECEIVER_ID, &R_RECV_LN_NBR, &R_RECV_SHIP_SEQ_NBR, &R_BUSINESS_UNIT, &R_DIS
TRIB_LINE_NUM, &R_RECV_SHIP_SEQ_NBR, &R_PO_ID, &R_LINE_NBR, &R_INSPECT_STATUS, &
R_ACTUAL_COST, &R_CONVERSION_RATE, &R_QTY_LN_INV_SUOM, &R_UNIT_MEASURE_STD, &R_V
ENDOR_ID, &R_PRODUCTION_ID, &R_OP_SEQ, &R_STORAGE_CODE, &R_DISTRIB_TYPE, &R_CONF
IG_CODE, &R_ACCOUNT, &R_ALTACCT, &R_OPERATING_UNIT, &R_DEPTID, &R_PRODUCT, &R_PR
OJECT_ID, &R_ACTIVITY_ID, &R_RESOURCE_TYPE, &R_RESOURCE_CATEGORY, &R_RESOURCE_SU
B_CAT, &R_ANALYSIS_TYPE, &R_BUSINESS_UNIT_PC, &R_CONSIGNED_FLAG)
/*
/*################################
## Endereo estoque Padro ITEM.
##################################
*/
SQLExec("select a.storage_area, a.stor_level_1, a.stor_level_2, a.stor_lev
el_3, a.stor_level_4 from sysadm.ps_mmc_end_por_sis a where a.mmc_sistema = '01'
and a.business_unit= :1 and a.mmc_te_tipo_local='1' and a.effdt = ( select max
(b.effdt) from sysadm.ps_mmc_end_por_sis b where b.mmc_sistema = a.mmc_sistema a
nd b.business_unit = a.business_unit and a.mmc_te_tipo_local = b.mmc_te_tipo_loc
al) and a.eff_status='A'", NF_HDR_BRL.BUSINESS_UNIT, &ET_STORAGE_AREA, &ET_STOR_
LEVEL_1, &ET_STOR_LEVEL_2, &ET_STOR_LEVEL_3, &ET_STOR_LEVEL_4);
If None(&ET_STORAGE_AREA) Or
None(&ET_STOR_LEVEL_1)
None(&ET_STOR_LEVEL_2)
None(&ET_STOR_LEVEL_3)
None(&ET_STOR_LEVEL_4)
Or
Or
Or
Then
Or
Or
Or
Then
de Expedio Padro para UN: " | &BU_ESTOQUE | " It
Else
&P_STORAGE_AREA
&P_STOR_LEVEL_1
&P_STOR_LEVEL_2
&P_STOR_LEVEL_3
&P_STOR_LEVEL_4
=
=
=
=
=
&ET_STORAGE_AREA;
&ET_STOR_LEVEL_1;
&ET_STOR_LEVEL_2;
&ET_STOR_LEVEL_3;
&ET_STOR_LEVEL_4;
End-If;
&IN_DISTRIB_TYPE = &R_DISTRIB_TYPE;
SQLExec("select %DateOut(po_dt) from sysadm.ps_po_hdr where business_unit=
:1 and po_id=:2", &R_BUSINESS_UNIT, &R_PO_ID, &IN_PO_DT);
/*************************************************************************
*
Modificao para entrar diretamente estoque
*************************************************************************/
&P_BUSINESS_UNIT = &BU_ESTOQUE;
&P_STAGED_DATE = Date3(1900, 1, 1);
&P_INV_LOT_ID = &R_LOT_ID;
&P_INV_ITEM_ID = &R_INV_ITEM_ID;
&P_SERIAL_ID = &R_SERIAL_ID;
&P_CONTAINER_ID = &R_CONTAINER_ID;
&P_UNIT_OF_MEASURE = &R_UNIT_MEASURE_STD;
&P_QTY = &R_QTY_LN_INV_SUOM;
&P_DEPTO = &R_DEPTID;
&P_DISTRIB_TYPE = &R_DISTRIB_TYPE;
&P_DT_TIMESTAMP = %Datetime;
&P_BUSINESS_UNIT_RECV = &R_BUSINESS_UNIT;
&P_RECEIVER_ID = &R_RECEIVER_ID;
&P_RECV_LN_NBR = &R_RECV_LN_NBR;
&P_RECV_SHIP_SEQ_NBR = &R_RECV_SHIP_SEQ_NBR;
&P_SOURCE_BUS_UNIT = &R_BUSINESS_UNIT;
&P_CUSTO = &P_CUSTO;
&P_CONFIG_CODE = &R_CONFIG_CODE;
If MMC_TE_NFLN_WRK.MMC_TE_TRIANG_FLG = "N" Or
MMC_TE_RECV_WRK.MMC_TE_NFSERVI_FLG = "Y" Then
&P_PARAMETRO_OPCIONAL = "USA_CUSTO_ENTRADA_NF";
&P_CUSTO = &CUSTO_POTER;
/*
If MMC_TE_NFLN_WRK.MMC_TE_TRIANG_FLG = "Y" Then
&P_CUSTO = &CUSTO_POTER;
Else
&P_CUSTO = &PAR_CUSTO_TERCEIRO;
End-If
*/
Else
SQLExec("SELECT TT.BUSINESS_UNIT, TT.INV_ITEM_ID, %DateTimeOut(TT.DT_TI
MESTAMP), TT.SEQ_NBR, TI.INV_LOT_ID FROM SYSADM.PS_MMC_TE_TRANSAC TT, SYSADM.PS_
NF_LN_BRL NL, SYSADM.PS_TRANSACTION_INV TI WHERE TT.BUSINESS_UNIT_BI = NL.BUSINE
SS_UNIT AND TT.NF_BRL_ID = NL.NF_BRL_ID AND TT.NF_BRL_LINE_NUM = NL.NF_BRL_LINE_
NUM AND TT.BUSINESS_UNIT = TI.BUSINESS_UNIT AND TT.INV_ITEM_ID = TI.INV_ITEM_ID
AND TT.DT_TIMESTAMP = TI.DT_TIMESTAMP AND TT.SEQ_NBR = TI.SEQ_NBR AND NL.BUSINES
S_UNIT = :1 AND NL.RECEIVER_ID = :2 AND NL.RECV_LN_NBR = :3", NF_HDR_BRL.BUSINES
S_UNIT, &R_RECEIVER_ID, &R_RECV_LN_NBR, &BC_BUSINESS_UNIT, &BC_INV_ITEM_ID, &BC_
DT_TIMESTAMP, &BC_SEQ_NBR, &BC_INV_LOT_ID);
If All(&BC_BUSINESS_UNIT) Then
&P_CUSTO = BUSCA_CUSTO_ITEM(&BC_BUSINESS_UNIT, &BC_INV_ITEM_ID, &BC_
DT_TIMESTAMP, &BC_INV_LOT_ID);
&P_PARAMETRO_OPCIONAL = "USA_CUSTO_UNIDADE_ORIGEM";
/*If %UserId = "DC804013" Then
&P_CUSTO = 0.1;
End-If;*/
If &P_CUSTO = 0 Or
None(&P_CUSTO) Then
Error ("Erro: No foi possivel encontrar custo para parametro Funo: B
USCA_CUSTO_ITEM ");
End-If;
Else
/*
ITEM"); */
End-If;
If None(&TRAN_DT_TIMESTAMP) Or
None(&TRAN_SEQ_NBR) Then
Error (" Erro: 2 - No foi encontradao DT_TIMESTAMP ou SEQ_NBR para grava
r na tabela Transao Terceiros. " | " UN Estoque: " | &BU_ESTOQUE | " NF Item: " |
&NF_ITEM | " Data NF: " | &DATA_HORA | " Recebimento: " | &RECV_RECEIVER_ID | "
Linha: " | &RECV_RECV_LN_NBR | " Seq NBR: " | &RECV_RECV_SHIP_SEQ_NBR);
End-If;
If MMC_TE_NFLN_WRK.MMC_TE_TRIANG_FLG = "N" Or
MMC_TE_RECV_WRK.MMC_TE_NFSERVI_FLG = "Y" Then
&T_SETID = " ";
&T_MMC_TE_SOL_ID = 0;
&T_LINE_NBR = 0;
&T_BUSINESS_UNIT_BI = NF_HDR_BRL.BUSINESS_UNIT;
&T_NF_BRL_ID = NF_HDR_BRL.NF_BRL_ID;
&T_NF_BRL_LINE_NUM = &NF_NF_BRL_LINE_NUM;
&T_MMC_TE_OPERACAO = "100";
&T_BUSINESS_UNIT = " ";
&T_INV_ITEM_ID = &NF_ITEM;
&T_DT_TIMESTAMP = Date3(1900, 1, 1);
&T_SEQ_NBR = 0;
&T_TRANSACTION_GROUP = " ";
&T_BUSINESS_UNIT_TO = &BU_ESTOQUE;
&T_DT_TIMESTAMP_TO = &TRAN_DT_TIMESTAMP;
&T_SEQ_NBR_TO = &TRAN_SEQ_NBR;
&T_MMC_TRAN_GROUP = "020";
&T_MMC_UN_ORIGEM = " ";
&T_NF_ID_ORIGEM = " ";
&T_NF_LINE_ORIGEM = 0;
/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||
|| FIM Populando Tabela Transao Terceiros.
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||*/
/* End-If; */ /* If &RECV_NO_PROCESSO = "X" Then
*/
/*===========================================================================
=
FIM: Gerando Entrada Estoque
============================================================================*/
/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||
|| INICIO GRAVANDO INDUSTRIALIZAO TERCEIROS.
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||*/
If MMC_TE_RECV_WRK.MMC_TE_NFSERVI_FLG = "Y" Then
&NF_SERV = GetRowset(Scroll.NF_LN_BRL);
For &CONTNF = 1 To &NF_SERV.ActiveRowCount;
&IND_BUSINESS_UNIT = &NF_SERV.GetRow(&CONTNF).NF_LN_BRL.BUSINESS_UNIT.V
ALUE;
&IND_NF_BRL_ID = &NF_SERV.GetRow(&CONTNF).NF_LN_BRL.NF_BRL_ID.VALUE;
&IND_NF_BRL_LINE_NUM = &NF_SERV.GetRow(&CONTNF).NF_LN_BRL.NF_BRL_LINE_N
UM.VALUE;
&IND_BUSINESS_UNIT_PO = &NF_SERV.GetRow(&CONTNF).MMC_TE_OP_WRK.BUSINESS
_UNIT_PO.VALUE;
&IND_PO_ID = &NF_SERV.GetRow(&CONTNF).MMC_TE_OP_WRK.PO_ID.VALUE;
&IND_LINE_NBR = &NF_SERV.GetRow(&CONTNF).MMC_TE_OP_WRK.LINE_NBR.VALUE;
&IND_SCHED_NBR = &NF_SERV.GetRow(&CONTNF).MMC_TE_OP_WRK.SCHED_NBR.VALUE
;
&IND_BUSINESS_UNIT_IN = &NF_SERV.GetRow(&CONTNF).MMC_TE_OP_WRK.BUSINESS
_UNIT_IN.VALUE;
&IND_NF_BRL_ID_2_BBL = &NF_SERV.GetRow(&CONTNF).MMC_TE_OP_WRK.NF_BRL_ID
_2_BBL.VALUE;
&VBOM_QTY_PER = &LOG_BOM.GetRow(&I).MMC_TE_TRIA_BOM.QTY_PER.VALUE;
&VBOM_QTY_PER_BASE = &LOG_BOM.GetRow(&I).MMC_TE_TRIA_BOM.QTY_PER_BASE.V
ALUE;
SQLExec("INSERT INTO SYSADM.PS_MMC_TE_TRIA_BOM VALUES (:1, :2, :3, :4,
:5, SYSDATE, :6, :7, :8, :9, :10, :11)", &VBOM_BUSINESS_UNIT, &VBOM_NF_BRL, &VBO
M_NF_BRL_SERIES, &VBOM_VENDOR_ID, &VBOM_ADDRESS_SEQ_NUM, &VBOM_SEQ_NBR, &VBOM_MM
C_OPRID, &VBOM_INV_ITEM_ID, &VBOM_DESCR254, &VBOM_QTY_PER, &VBOM_QTY_PER_BASE);
&VBOM_SEQ_NBR = &VBOM_SEQ_NBR + 1;
End-For;
/*************************** mmcb.sds3426.en ***************************/
End-If;
/*===========================================================================
====================================*/
REM NF SERVIO UNIFICADO PASSO 01;
If MMC_TE_TRIA_WRK.MMC_TE_TIPO_RECEBI = "Y" Then
&PS_BUSINESS_UNIT = NF_HDR_BRL.BUSINESS_UNIT;
&PS_NF_BRL_ID = NF_HDR_BRL.NF_BRL_ID;
&PS_NF_ID_TO = MMC_NUMERACAO_ID(3);
If None(&PS_NF_ID_TO) Then
Error ("No foi possivel localizar NF Servio Unificado destino.");
End-If;
CRIA_NF_SERVICO_UNIFICADO(&PS_BUSINESS_UNIT, &PS_NF_BRL_ID, &PS_NF_ID_TO);
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||
|| INICIO - Gravando dados de parametros para ser carregado pela NF Servio gerad
a
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
*/
SQLExec("delete from sysadm.ps_mmc_te_nf_tmp where business_unit_in=:1 and
nf_brl_id_2_bbl=:2", NF_HDR_BRL.BUSINESS_UNIT, &PS_NF_ID_TO);
&REC_MMC_TE_NF_TMP = CreateRecord(Record.MMC_TE_NF_TMP);
&REC_MMC_TE_NF_TMP.BUSINESS_UNIT.VALUE = NF_HDR_BRL.BUSINESS_UNIT;
&REC_MMC_TE_NF_TMP.NF_BRL_ID.VALUE = NF_HDR_BRL.NF_BRL_ID;
&REC_MMC_TE_NF_TMP.BUSINESS_UNIT_IN.VALUE = NF_HDR_BRL.BUSINESS_UNIT;
&REC_MMC_TE_NF_TMP.NF_BRL_ID_2_BBL.VALUE = &PS_NF_ID_TO;
&REC_MMC_TE_NF_TMP.Insert();
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|||
|| FIM - Gravando dados de parametros para ser carregado pela NF Servio gerada
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
*/
/****************************************
Cria RECORD pesquisa para o painel.
******************************************/
&R = CreateRecord(Record.NF_PBL_SRCH_VW2);
&R.BUSINESS_UNIT.VALUE = &PS_BUSINESS_UNIT;
&R.NF_BRL_ID.VALUE = &PS_NF_ID_TO;
Transfer( True, MenuName.MANAGE_NF, BarName.USE, ItemName.NF_INFO_PBL, Pag
e.NF_INFO_HDR_PBL, "U", &R);
End-If;
REM FIM NF SERVIO UNIFICADO PASSO 01;
/*|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||||||
|| FIM GRAVANDO INDUSTRIALIZAO TERCEIROS.
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
||||||||||||||||||||*/
/********************** mmcb.HD64180.sn **********************/
Gray(NF_BRL_STATUS);
/********************** mmcb.HD64180.en **********************/
End-If;
/* Component = Component.NF_INFO_PBL And MMC_TE_NFLN_WRK.MMC_TERCEIRO_FLG = "Y"
And NF_BRL_STATUS = "F" Then */
/********************** mmcb.at2323.en **********************/
&MAT_TAX_CLASS_BRL = &MAT_LINHAS_NF.GetRow(&MAT_LN).NF_LN_BRL.TAX_CLASS
_BRL.VALUE;
&MAT_INV_ITEM_ID = &MAT_LINHAS_NF.GetRow(&MAT_LN).NF_LN_BRL.INV_ITEM_ID
.VALUE;
&MAT_NF_BRL_LINE_NUM = &MAT_LINHAS_NF.GetRow(&MAT_LN).NF_LN_BRL.NF_BRL_
LINE_NUM.VALUE;
&MAT_BUSINESS_UNIT = NF_HDR_BRL.BUSINESS_UNIT;
&MAT_NF_BRL_ID = NF_HDR_BRL.NF_BRL_ID;
&MAT_NF_BRL = NF_HDR_BRL.NF_BRL;
&MAT_NF_BRL_SERIES = NF_HDR_BRL.NF_BRL_SERIES;
&MAT_DESCR = &MAT_LINHAS_NF.GetRow(&MAT_LN).NF_LN_BRL.DESCR.VALUE;
&MAT_VENDOR_ID = NF_HDR_BRL.VENDOR_ID.Value;
&MAT_NF_BRL_DATE = NF_HDR_BRL.NF_BRL_DATE;
&MAT_TRANSACTION_GROUP = "020";
&MAT_TRANSACTION_DATE = %Date;
&MAT_SOURCE_BUS_UNIT = " ";
&MAT_ORDER_NO = " ";
&MAT_ORDER_INT_LINE_NO = 0;
&MAT_CUST_ID = " ";
&MAT_BUSINESS_UNIT_BI = " ";
&MAT_MMC_NF_BRL_ID_OUT = " ";
&MAT_MMC_LINE_NUM_OUT = 0;
&MAT_ACCOUNT = " ";
&MAT_MMC_TIPO_AJUST = " ";
&MAT_OPRID = %UserId;
&MAT_UNIT_OF_MEASURE = &MAT_LINHAS_NF.GetRow(&MAT_LN).NF_LN_BRL.UNIT_OF
_MEASURE.VALUE;
&MAT_MMC_OBS_AJUST = " ";
&MAT_MMC_ISSUE_QTY = &MAT_LINHAS_NF.GetRow(&MAT_LN).NF_LN_BRL.QTY_NF_BR
L.VALUE;
&MAT_QTY_NF_BRL = &MAT_LINHAS_NF.GetRow(&MAT_LN).NF_LN_BRL.QTY_NF_BRL.V
ALUE;
&MAT_UNIT_PRICE = &MAT_LINHAS_NF.GetRow(&MAT_LN).NF_LN_BRL.UNIT_PRICE.V
ALUE;
&MAT_MERCHANDISE_AMT = &MAT_LINHAS_NF.GetRow(&MAT_LN).NF_LN_BRL.MERCHAN
DISE_AMT.VALUE;
&MAT_SHIPTO_ID = NF_HDR_BRL.SHIPTO_ID;
&SQL =
&SQL =
&SQL =
PO_LINE_SHIP
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
"";
&SQL | " SELECT COUNT( DISTINCT(D.DEPTID) )";
&SQL | " FROM SYSADM.PS_PO_HDR A, SYSADM.PS_PO_LINE B, SYSADM.PS_
C, SYSADM.PS_PO_LINE_DISTRIB D ";
&SQL | " WHERE A.BUSINESS_UNIT = :1 ";
&SQL | "
AND A.PO_ID = :2 ";
&SQL | "
AND A.PO_STATUS NOT IN ('X') ";
&SQL | "
AND B.BUSINESS_UNIT = A.BUSINESS_UNIT ";
&SQL | "
AND B.PO_ID = A.PO_ID ";
&SQL | "
AND C.BUSINESS_UNIT = B.BUSINESS_UNIT ";
&SQL | "
AND C.PO_ID = B.PO_ID ";
&SQL | "
AND C.LINE_NBR = B.LINE_NBR ";
&SQL | "
AND C.CANCEL_STATUS NOT IN ('X') ";
&SQL | "
AND D.BUSINESS_UNIT = C.BUSINESS_UNIT ";
&SQL | "
AND D.PO_ID = C.PO_ID ";
&SQL | "
AND D.LINE_NBR = C.LINE_NBR ";
&SQL | "
AND D.SCHED_NBR = C.SCHED_NBR ";
/*
&SQL =
&SQL =
&SQL =
PO_LINE_SHIP
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
&SQL =
"";
&SQL | " SELECT DISTINCT D.DEPTID ";
&SQL | " FROM SYSADM.PS_PO_HDR A, SYSADM.PS_PO_LINE B, SYSADM.PS_
C, SYSADM.PS_PO_LINE_DISTRIB D ";
&SQL | " WHERE A.BUSINESS_UNIT = :1 ";
&SQL | "
AND A.PO_ID = :2 ";
&SQL | "
AND A.PO_STATUS NOT IN ('X') ";
&SQL | "
AND B.BUSINESS_UNIT = A.BUSINESS_UNIT ";
&SQL | "
AND B.PO_ID = A.PO_ID ";
&SQL | "
AND C.BUSINESS_UNIT = B.BUSINESS_UNIT ";
&SQL | "
AND C.PO_ID = B.PO_ID ";
&SQL | "
AND C.LINE_NBR = B.LINE_NBR ";
&SQL | "
AND C.CANCEL_STATUS NOT IN ('X') ";
&SQL | "
AND D.BUSINESS_UNIT = C.BUSINESS_UNIT ";
&SQL | "
AND D.PO_ID = C.PO_ID ";
&SQL | "
AND D.LINE_NBR = C.LINE_NBR ";
&SQL | "
AND D.SCHED_NBR = C.SCHED_NBR ";
Or
Or
Or
Then
Error ("ERRO! O ITEM [" | &CONTR_INV_ITEM_ID | "] nao esta com o LOC
AL DE ARMAZENAGEM PADRAO definido na Unidade [" | &BU_ARMAZENAGEM | "]! Corrija
seu cadastro antes de prosseguir em: Home > Manter Itens > Definir Itens > Usar
> Locais de Armazenagem Padro!");
Else
/* Verifica se a Unidade de Medida da NF eh a mesma unidade de medid
a padrao do item */
SQLExec("SELECT UNIT_OF_MEASURE, CONVERSION_RATE, QTY_PRECISION FROM
PS_INV_ITEM_UOM WHERE SETID = :1 AND INV_ITEM_ID = :2 AND DFLT_UOM_STOCK = 'Y'"
, &SETID, &CONTR_INV_ITEM_ID, &UNIT_OF_MEASURE_STD, &CONVERSION_RATE, &QTY_PRECI
SION);
If None(&UNIT_OF_MEASURE_STD) Then
Error ("ERRO! No existe unidade de medida padro definida para o ITE
M [" | &CONTR_INV_ITEM_ID | "] em: Home > Manter Itens > Definir Itens > Usar >
Definio de Item. Corrija o cadastro!");
End-If;
/* Verifica se a unidade de medida da nota eh a padrao. Se for, fica
tudo igual */
If &DEFAULT_UOM = &UNIT_OF_MEASURE Then
&QTY_BASE = &QTY;
Else
/* Quando eh diferente, busca a taxa de conversao para a unidade
da nota */
SQLExec("SELECT CONVERSION_RATE, QTY_PRECISION FROM PS_INV_ITEM_U
OM WHERE SETID = :1 AND INV_ITEM_ID = :2 AND UNIT_OF_MEASURE = :3", &SETID, &CON
TR_INV_ITEM_ID, &UNIT_OF_MEASURE, &CONVERSION_RATE_NF, &QTY_PRECISION_NF);
If None(&CONVERSION_RATE_NF) Or
&CONVERSION_RATE_NF <= 0 Then
Error ("ERRO! Taxa de converso inexistente ou igual a zero para
o ITEM [" | &CONTR_INV_ITEM_ID | "] e UNIDADE DE MEDIDA [" | &UNIT_OF_MEASURE |
"]. Corrija o cadastro!");
End-If;
&QTY_BASE = &CONVERSION_RATE_NF * &QTY;
End-If;
/* Preenche as variaveis usadas daqui pra baixo */
&SOURCE_BUS_UNIT = &CONTR_BUSINESS_UNIT;
&RECEIVER_ID = &NF_BRL_ID;
&RECV_LN_NBR = &NF_LINE;
&ORDER_NO = &NF_BRL_ID;
&ORDER_INT_LINE_NO = &NF_LINE;
&SOURCE_BUS_UNIT = &CONTR_BUSINESS_UNIT;
&INV_LOT_ID = "NONE";
&SERIAL_ID = "NONE";
&PO_ID = " ";
&DEPT_ID = " ";
&ACCOUNT = " ";
&DISTRIB_TYPE = " ";
&ANALYSIS_TYPE = " ";
&SHIP_ID = " ";
&TRANSACTION_SOURCE = " ";
&BUSINESS_UNIT_PO = " ";
&CONTAINER_ID = " ";
&LAST_ORDER = " ";
&PRICE_PO = "0";
&DISTRIB_LINE_NUM = "0";
&DISTRIB_SEQ_NUM = "0";
&SCHED_LINE_NO = "0";
&DEMAND_LINE_NO = "0";
&SCHED_LINE_NO = "0";
&PROCESS_INSTANCE = "0";
&RECV_SHIP_SEQ_NBR = "0";
&OPR_ID = %OperatorId;
&STAGED_TYPE = "1";
&STAGED_DATE = "1900-01-01";
&TRANSACTION_GROUP = "720";
&PROCESS_FLAG = "N";
&DT_TIMESTAMP = %Datetime;
&TRANSACTION_DATE = %Date;
/* 3 - Insere a movimentao na TRANSACTION_INV - transao 720 */
/* Define o SEQ_NBR */
SQLExec("SELECT NVL( MAX( SEQ_NBR +1 ), 1 ) FROM SYSADM.PS_TRANSACTI
ON_INV WHERE BUSINESS_UNIT = :1 AND INV_ITEM_ID = :2 AND DT_TIMESTAMP = %DateTim
eIn(:3)", &BU_ARMAZENAGEM, &CONTR_INV_ITEM_ID, &DT_TIMESTAMP, &SEQ_NBR);
GRAVA_TRANSACTION(&BU_ARMAZENAGEM, &CONTR_INV_ITEM_ID, &DT_TIMESTAMP
, &SEQ_NBR, &SOURCE_BUS_UNIT, &ORDER_NO, &ORDER_INT_LINE_NO, &SCHED_LINE_NO, &DE
MAND_LINE_NO, &STAGED_DATE, &INV_LOT_ID, &SERIAL_ID, &ARM_STORAGE_AREA, &ARM_STO
R_LEVEL_1, &ARM_STOR_LEVEL_2, &ARM_STOR_LEVEL_3, &ARM_STOR_LEVEL_4, &RECEIVER_ID
, &RECV_LN_NBR, &TRANSACTION_GROUP, &TRANSACTION_DATE, &QTY_BASE, &QTY, &UNIT_OF
_MEASURE_STD, &UNIT_OF_MEASURE, &OPR_ID, &ACCOUNT, &DEPT_ID, &PO_ID, &DISTRIB_LI
NE_NUM, &DISTRIB_SEQ_NUM, &RECV_SHIP_SEQ_NBR, &PRICE_PO, &ANALYSIS_TYPE, &VENDOR
_ID, &STAGED_TYPE, &DISTRIB_TYPE, &BUSINESS_UNIT_PO, &TRANSACTION_SOURCE, &CONVE
RSION_RATE, &PROCESS_INSTANCE, &PROCESS_FLAG, &SHIP_ID);
/* 4 - Verifica se o item ja existe na PHYSICAL_INV. Se existir, atu
aliza. Se no existir, faz um INSERT */
ATUALIZA_PHYSICAL_INV_720(&BU_ARMAZENAGEM, &STAGED_DATE, &INV_LOT_ID
****/
/* Se o TOF das linhas estiver em branco, move o TOF informado na Header */
&LN_MAXROW = ActiveRowCount(Scroll.NF_LN_BRL);
For &LN_ROW = 1 To &LN_MAXROW
&TOF_LINE = FetchValue(NF_LN_BRL.TOF_PBL, &LN_ROW);
If None(&TOF_LINE) Then
UpdateValue(NF_LN_BRL.TOF_PBL, &LN_ROW, TOF_PBL);
End-If;
End-For;
TofTxtHdr();
End-If;
/*** JEISON CALDAS - 02/11/2005 - TRATAMENTO PARA LEVAR ALTERAO DO CABECALHO PARA
AS LINHAS DO DOCUMENTO FISCAL - INCIO ***/
/* Gustavo adequacao para nota de debito or %component = component.mmc_lanc_gar_
nd */
If (%Component = Component.NF_RECV_PBL Or
%Component = Component.NF_INFO_PBL Or
%Component = Component.MMC_LANC_GAR Or
%Component = Component.MMC_LANC_GAR_ND) And
All(TOF_PBL) Then
REM SINALIZA SE OF VAI OU NO GERAR VOUCHER;
SQLExec("SELECT A.TOF_VOUCHER_PBL FROM PS_TOF_TYPE_PBL A WHERE A.TOF_PBL = :1
AND A.EFFDT = (SELECT MAX(A_ED.EFFDT) FROM PS_TOF_TYPE_PBL A_ED WHERE A.TOF_PB
L = A_ED.TOF_PBL)", TOF_PBL, &VOUCHE);
If (&VOUCHE = "N") Then
MMC_TEMP.MMC_MRB_VOUCHER = "NGV";
Else
MMC_TEMP.MMC_MRB_VOUCHER = "SGV";
End-If;
REM JEISON 12/11/05 - FAZ TRATAMENTO PARA VALIDAR SE GERA OU NAO VOUCHER NO C
ABECALHO - INICIO;
SQLExec("SELECT A.TOF_VOUCHER_PBL FROM PS_TOF_TYPE_PBL A WHERE A.TOF_PBL = :1
AND A.EFF_STATUS = 'A' AND A.EFFDT = (SELECT MAX(B.EFFDT)FROM PS_TOF_TYPE_PBL B
WHERE B.TOF_PBL = A.TOF_PBL AND B.EFF_STATUS = A.EFF_STATUS)", TOF_PBL, &RET_VC
H);
If &RET_VCH = "Y" Then
NF_HDR_BRL.VOUCHER_FLOW_PBL = "V";
/* SQLExec("SELECT B.PAY_TRM_BSE_DT_OPT, B.PYMNT_TERMS_CD FROM PS_BUS_UNIT
_TBL_PM A, PS_BUS_UNIT_OPT_PM B WHERE A.BUSINESS_UNIT = :1 AND B.PRCS_OPTION_ID
= A.PRCS_OPTION_ID AND B.SETID = :2 AND B.EFFDT = (SELECT MAX(C.EFFDT) FROM PS_B
US_UNIT_OPT_PM C WHERE C.SETID = B.SETID AND C.PRCS_OPTION_ID = B.PRCS_OPTION_ID
AND C.EFFDT <= %DateIn(:3))", NF_HDR_BRL.BUSINESS_UNIT, "MMCSA", NF_HDR_BRL.NF_
BRL_DATE, NF_HDR_BRL.PAY_TRM_BSE_DT_OPT, &PYMNT_TERMS); */ /* mmcb.sds3239.lo */
SQLExec("SELECT B.PAY_TRM_BSE_DT_OPT, B.PYMNT_TERMS_CD FROM PS_BUS_UNIT_TB
L_PM A, PS_BUS_UNIT_OPT_PM B WHERE A.BUSINESS_UNIT = :1 AND B.PRCS_OPTION_ID = A
.PRCS_OPTION_ID AND B.SETID = :2 AND B.EFFDT = (SELECT MAX(C.EFFDT) FROM PS_BUS_
UNIT_OPT_PM C WHERE C.SETID = B.SETID AND C.PRCS_OPTION_ID = B.PRCS_OPTION_ID AN
D C.EFFDT <= %DateIn(:3))", NF_HDR_BRL.BUSINESS_UNIT, &SETID, NF_HDR_BRL.NF_BRL_
DATE, NF_HDR_BRL.PAY_TRM_BSE_DT_OPT, &PYMNT_TERMS); /* mmcb.sds3239.lo */
If None(NF_HDR_BRL.PYMNT_TERMS_CD) Then
NF_HDR_BRL.PYMNT_TERMS_CD = &PYMNT_TERMS
End-If;
Else
NF_HDR_BRL.VOUCHER_FLOW_PBL = "N";
NF_HDR_BRL.PYMNT_TERMS_CD = " ";
End-If;
REM JEISON 12/11/05 - FAZ TRATAMENTO PARA VALIDAR SE GERA OU NAO VOUCHER NO C
ABECALHO - FIM;
REM BUSCA ESTADO E PAIS DO FORNECEDOR;
/* SQLExec("SELECT STATE, COUNTRY FROM PS_VENDOR_ADDR WHERE SETID = 'MMCSA' A
ND VENDOR_ID = :1 AND ADDRESS_SEQ_NUM = :2 AND EFF_STATUS = 'A'", NF_HDR_BRL.VEN
DOR_ID, NF_HDR_BRL.ADDRESS_SEQ_NUM, &STATE, &COUNTRY); */ /* mmcb.sds3239.lo */
SQLExec("SELECT STATE, COUNTRY FROM PS_VENDOR_ADDR WHERE SETID = :1 AND VENDO
R_ID = :2 AND ADDRESS_SEQ_NUM = :3 AND EFF_STATUS = 'A'", &SETID, NF_HDR_BRL.VEN
DOR_ID, NF_HDR_BRL.ADDRESS_SEQ_NUM, &STATE, &COUNTRY); /* mmcb.sds3239.ln */
/******************************************* mmcb.hd78522.so ****************
***************************/
/*
REM CHECA LOCAL DE ENTREGA SP OU GO ;
If (NF_HDR_BRL.SHIPTO_ID = "LCPTS" Or
NF_HDR_BRL.SHIPTO_ID = "LDEFS" Or
NF_HDR_BRL.SHIPTO_ID = "LINDS" Or
NF_HDR_BRL.SHIPTO_ID = "LOVIN" Or
NF_HDR_BRL.SHIPTO_ID = "LVEIN" Or
NF_HDR_BRL.SHIPTO_ID = "LVPEC" Or
NF_HDR_BRL.SHIPTO_ID = "LVVEI" Or
NF_HDR_BRL.SHIPTO_ID = "LMKTS" Or
NF_HDR_BRL.SHIPTO_ID = "LREVS" Or
NF_HDR_BRL.SHIPTO_ID = "LCPTS" Or
NF_HDR_BRL.SHIPTO_ID = "SO PAULO") Then
&ENTREGA = "SP";
Else
&ENTREGA = "GO";
End-If;
*/
/******************************************* mmcb.hd78522.eo ****************
***************************/
/*******************************************
***************************/
/*******************************************
***************************/
/*&ENTREGA = NF_HDR_BRL.SHIP_BRL_TO_STATE;*/
/*******************************************
***************************/
/*******************************************
***************************/
mmcb.hd79085.so ****************
mmcb.hd78522.sn ****************
mmcb.hd78522.en ****************
mmcb.hd79085.eo ****************
REM LINHAS;
UpdateValue(NF_LN_BRL.ICMSTAX_BRL_BSS, &LN_ROW, 0);
UpdateValue(NF_LN_BRL.ICMSTAX_BRL_PCT, &LN_ROW, 0);
UpdateValue(NF_LN_BRL.ICMSTAX_BRL_RED, &LN_ROW, 0);
UpdateValue(NF_LN_BRL.ICMSTAX_BRL_AMT, &LN_ROW, 0);
UpdateValue(NF_LN_BRL.ICMSSUB_BRL_AMT, &LN_ROW, 0);
UpdateValue(NF_LN_BRL.ICMS_COMPL_AMT_PBL, &LN_ROW, 0);
UpdateValue(NF_LN_BRL.COEF_BASE_ICMS_PBL, &LN_ROW, 0);
UpdateValue(NF_LN_WRK_PBL.ICMS_COMPL_PCT_PBL, &LN_ROW, 0);
UpdateValue(NF_LN_BRL.IPITAX_BRL_BSS,
UpdateValue(NF_LN_BRL.IPITAX_BRL_PCT,
UpdateValue(NF_LN_BRL.IPITAX_BRL_RED,
UpdateValue(NF_LN_BRL.IPITAX_BRL_AMT,
Gray(NF_LN_BRL.ICMSTAX_STS_BBL,
Gray(NF_LN_BRL.ICMSTAX_BRL_BSS,
Gray(NF_LN_BRL.ICMSTAX_BRL_PCT,
Gray(NF_LN_BRL.ICMSTAX_BRL_RED,
Gray(NF_LN_BRL.ICMSTAX_BRL_AMT,
Gray(NF_LN_BRL.ICMSSUB_BRL_AMT,
&LN_ROW,
&LN_ROW,
&LN_ROW,
&LN_ROW,
0);
0);
0);
0);
&LN_ROW);
&LN_ROW);
&LN_ROW);
&LN_ROW);
&LN_ROW);
&LN_ROW);
Gray(NF_LN_BRL.IPITAX_STS_BBL, &LN_ROW);
Gray(NF_LN_BRL.IPITAX_BRL_BSS, &LN_ROW);
Gray(NF_LN_BRL.IPITAX_BRL_PCT, &LN_ROW);
Gray(NF_LN_BRL.IPITAX_BRL_RED, &LN_ROW);
Gray(NF_LN_BRL.IPITAX_BRL_AMT, &LN_ROW);
Else
UnGray(NF_HDR_BRL.IPITAX_BRL_AMT);
UnGray(NF_HDR_BRL.ICMSTAX_BRL_AMT);
UnGray(NF_HDR_BRL.ICMSTAX_BRL_BSS);
UnGray(NF_HDR_BRL.ICMSSUB_BRL_BSS);
UnGray(NF_HDR_BRL.ICMSSUB_BRL_AMT);
UnGray(NF_LN_BRL.ICMSTAX_STS_BBL, &LN_ROW);
UnGray(NF_LN_BRL.ICMSTAX_BRL_BSS, &LN_ROW);
UnGray(NF_LN_BRL.ICMSTAX_BRL_PCT, &LN_ROW);
UnGray(NF_LN_BRL.ICMSTAX_BRL_RED, &LN_ROW);
UnGray(NF_LN_BRL.ICMSTAX_BRL_AMT, &LN_ROW);
UnGray(NF_LN_BRL.ICMSSUB_BRL_AMT, &LN_ROW);
End-If;
End-For;
End-If;
/*** JEISON CALDAS - 02/11/2005 - TRATAMENTO PARA LEVAR ALTERAO DO CABECALHO PARA
AS LINHAS DO DOCUMENTO FISCAL - FIM ***/
/*** JEISON CALDAS - BUSCA PARAMETRIZAO DE TABELA CUSTOMIZADA MMC_PARAMET_OFS - IN
ICIO ***/
If (%Component = Component.NF_RECV_PBL Or
%Component = Component.NF_INFO_PBL Or
%Component = Component.MMC_LANC_GAR Or
%Component = Component.MMC_LANC_GAR_ND) And
All(TOF_PBL) Then
&VL_MSG_BOX = WinMessage("Deseja alterar campos baseado na Parametrizao da Oper
. Fiscal ?", 3, "Alterar campos para def. OF?");
SQLExec("SELECT PO_ID FROM PS_RECV_LN_SHIP WHERE BUSINESS_UNIT = :1 AND RECEI
VER_ID = :2", NF_HDR_BRL.BUSINESS_UNIT, NF_HDR_BRL.RECEIVER_ID, &PO_ID);
If &VL_MSG_BOX = 6 Then
SQLExec("SELECT INV_ITEM_ID, DESCR254_MIXED, QTY_LN_RECVD_VUOM, DEPTID, NF
_BRL_TYPE, CATEGORY_ID FROM PS_MMC_PARAMET_OFS WHERE TOF_PBL = :1 AND STATUS = '
ungray_line_data(&I);
UnGray_Line_ICMSSUB_Data(&I);
End-For;
End-If;
NF_HDR_BRL.INTERUNIT_FLG = NF_TYPE_BRL.INTERUNIT_FLG;
If NF_HDR_BRL.INTERUNIT_FLG = "Y" Then
UnHide(NF_HDR_BRL.BUSINESS_UNIT_IN);
Else
Hide(NF_HDR_BRL.BUSINESS_UNIT_IN);
End-If;
End-If;
End-If;
End-If;
/* Valmir Tavares - HQS - 09.01.2006 - Busca a condio de pagamento na OC - Inicio
*/
/***
If %Component = Component.NF_RECV_PBL Then
&PO_BU = FetchValue(FIS_SHIP_PBL_WS.BUSINESS_UNIT_PO, 1);
&PO_ID = FetchValue(FIS_SHIP_PBL_WS.PO_ID, 1);
SQLExec("select PYMNT_TERMS_CD FROM PS_PO_HDR WHERE BUSINESS_UNIT = :1 AND PO
_ID = :2", &PO_BU, &PO_ID, &PYMNT_TERMS_CD);
If All(&PYMNT_TERMS_CD) Then
NF_HDR_BRL.PYMNT_TERMS_CD = &PYMNT_TERMS_CD;
End-If;
End-If;
***/
/* Valmir Tavares - HQS - 09.01.2006 - Busca a condio de pagamento na OC - Fim */
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 03/05/2006 - Inicio
Mostra ou no o vinculo de Ordem de Compra, dependendo do CFOP da Linha */
Hab_Desab_Vinc_OC();
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 03/05/2006 - Fim */
[NF_HDR_INFO_WRK.TOF_PBL.RowInit]
/********************************************************************
Gustavo Vilarinho Neto - mmcb - 09/12/2009 - mmcb.sds3239 - Implantao People - Sof
t SVB
*********************************************************************/
Declare Function gray_trsp_data PeopleCode NF_HDR_BRL.NF_BRL_TYPE FieldChange;
Declare Function gray_hdr_data PeopleCode NF_HDR_BRL.NF_BRL_TYPE FieldChange;
Declare Function Gray_hdr_ICMSSUB_data PeopleCode NF_HDR_BRL.NF_BRL_TYPE FieldCh
ange;
Declare Function UnGray_hdr_ICMSSUB_data PeopleCode NF_HDR_BRL.NF_BRL_TYPE Field
Change;
Declare Function Gray_Line_ICMSSUB_Data PeopleCode NF_HDR_BRL.NF_BRL_TYPE FieldC
hange;
Declare Function gray_line_data PeopleCode NF_HDR_BRL.NF_BRL_TYPE FieldChange;
Declare Function UnGray_Line_ICMSSUB_Data PeopleCode NF_HDR_BRL.NF_BRL_TYPE Fiel
dChange;
Declare Function ungray_trsp_data PeopleCode NF_HDR_BRL.NF_BRL_TYPE FieldChange;
Declare Function ungray_hdr_data PeopleCode NF_HDR_BRL.NF_BRL_TYPE FieldChange;
Declare Function ungray_line_data PeopleCode NF_HDR_BRL.NF_BRL_TYPE FieldChange;
/* BRLPO - HAT - 8.01 - 06/07/01 - Sugere valor Default para TOF - TOF por linha
*/
/* Gustavo adequacao para nota de debito or %component = component.mmc_lanc_gar_
nd */
If %Component = Component.NF_RECV_PBL Or
%Component = Component.NF_INFO_PBL Or
%Component = Component.MMC_LANC_GAR Or
%Component = Component.MMC_LANC_GAR_ND Then
/* Sugere valor do TOF da BU */
If %Mode = "A" Then
/*************************** mmcb.sds3239.so ************************/
/*
TOF_PBL = BUS_UNIT_TBL_PM.TOF_PBL;
*/
/*************************** mmcb.sds3239.eo ************************/
End-If;
SQLExec("SELECT DESCRSHORT FROM PS_TOF_TYPE_PBL WHERE TOF_PBL = :1 AND EFFDT
= (SELECT MAX(EFFDT) FROM PS_TOF_TYPE_PBL A WHERE TOF_PBL = :1 AND EFFDT <= %DAT
EIN(:2))", TOF_PBL, NF_HDR_BRL.NF_BRL_DATE, &DESCR);
DESCR = &DESCR;
REM SINALIZA SE OF VAI OU NO GERAR VOUCHER;
SQLExec("SELECT A.TOF_VOUCHER_PBL FROM PS_TOF_TYPE_PBL A WHERE A.TOF_PBL = :1
AND A.EFFDT = (SELECT MAX(A_ED.EFFDT) FROM PS_TOF_TYPE_PBL A_ED WHERE A.TOF_PB
L = A_ED.TOF_PBL)", TOF_PBL, &VOUCHE);
If (&VOUCHE = "N") Then
MMC_TEMP.MMC_MRB_VOUCHER = "NGV";
Else
MMC_TEMP.MMC_MRB_VOUCHER = "SGV";
End-If;
End-If;
/* BRLPO - HAT - 8.01 - 06/07/01 - END */
REM FAZ TRATAMENTO DE CAMPOS BASEADOS NAS PARAMETRIZAES DE OPERAO FISCAL;
If %Component = Component.NF_RECV_PBL Then
SQLExec("SELECT INV_ITEM_ID, DESCR254_MIXED, QTY_LN_RECVD_VUOM, DEPTID, NF_BR
L_TYPE FROM PS_MMC_PARAMET_OFS WHERE TOF_PBL = :1 AND STATUS = 'A'", TOF_PBL, &P
ITEM, &PDESCR, &PQTY, &PDEPTID, &NF_TYPE);
&LN_ATIVAS = ActiveRowCount(Scroll.NF_LN_BRL);
If All(&PITEM) Then
SQLExec("SELECT INVENTORY_ITEM, UNIT_MEASURE_STD FROM PS_MASTER_ITEM_TBL W
HERE SETID = 'MMCSA' AND INV_ITEM_ID = :1", &PITEM, &ESTOQUE, &UNIT_OF_MEASURE);
&SETID_ITEM = GetSetId("BUSINESS_UNIT", NF_HDR_BRL.BUSINESS_UNIT, "MASTER_
ITEM_TBL", "");
&RECNAME = "ITM_PURCH_VW";
&FIELDNAME = "BUSINESS_UNIT";
SQLExec("SELECT DESCR254_MIXED FROM PS_PURCH_ITEM_ATTR WHERE SETID = :1 A
ND INV_ITEM_ID = :2", &SETID_ITEM, &PITEM, &DESCR254_MIXED);
&ACCDFT = FetchValue(ITM_PURCH_VW.ACCOUNT, 1);
If &ESTOQUE <> "N" Then
SQLExec("select a.descr from ps_itm_purch_fs a, ps_set_cntrl_rec b wher
e a.inv_item_id = :1 and b.setcntrlvalue = :2 and b.recname = :3 and b.setid =
a.setid", &PITEM, NF_HDR_BRL.BUSINESS_UNIT, &RECNAME, &DESCR);
Else
&DESCR = "";
End-If;
For &LN = 1 To &LN_ATIVAS
UpdateValue(NF_LN_BRL.INV_ITEM_ID, &LN, &PITEM);
&ACCDFT = FetchValue(ITM_PURCH_VW.ACCOUNT, &LN);
UpdateValue(Record.NF_LN_BRL, &LN, BRL_DISTRIB_LN.ACCOUNT, 1, &ACCDFT);
UpdateValue(NF_LN_BRL.DESCR, &LN, &DESCR);
UpdateValue(NF_LN_BRL.ITM_SETID, &LN, &SETID_ITEM);
UpdateValue(NF_LN_BRL.UNIT_OF_MEASURE, &LN, &UNIT_OF_MEASURE);
UpdateValue(NF_LN_BRL.DESCR254_MIXED, &LN, &DESCR254_MIXED);
If All(&DESCR) Then
Gray(NF_LN_BRL.DESCR, &LN);
End-If;
End-For;
End-If;
REM FAZ TRATAMENTO PARA O CAMPO DE DESCRIO;
If All(&PDESCR) Then
For &LN = 1 To &LN_ATIVAS
UpdateValue(NF_LN_BRL.DESCR, &LN, &PDESCR);
End-For;
End-If;
REM FAZ TRATAMENTO PARA O CAMPO QUANTIDADE;
If All(&PQTY) Then
For &LN = 1 To &LN_ATIVAS
UpdateValue(NF_LN_BRL.QTY_NF_BRL, &LN, &PQTY);
&PUNITP = FetchValue(NF_LN_BRL.UNIT_PRICE, &LN);
If All(&PUNITP) Then
&PVALUE = RoundCurrency(&PQTY * &PUNITP, NF_HDR_BRL.BASE_CURRENCY, N
F_HDR_BRL.NF_BRL_DATE);
UpdateValue(NF_LN_BRL.MERCH_ORIG_AMT_PBL, &LN, &PQTY);
End-If;
End-For;
End-If;
REM FAZ TRATAMENTO PARA O CAMPO DEPARTAMENTO;
If All(&PDEPTID) Then
For &LN = 1 To &LN_ATIVAS
UpdateValue(Record.NF_LN_BRL, &LN, BRL_DISTRIB_LN.DEPTID, 1, &PDEPTID);
End-For;
End-If;
REM FAZ TRATAMENTO PARA O CAMPO TIPO NF;
If All(&NF_TYPE) Then
NF_HDR_BRL.NF_BRL_TYPE = &NF_TYPE;
/****************************** Main Program ****************************
*/
If NF_TYPE_BRL.NF_BRL_TYPE_FLG <> "Y" Then
Gray(RECV_HD_WRK_PBL.NF_MULTI_BRL_PB);
Else
If NF_TYPE_BRL.NF_BRL_TYPE_FLG = "N" Then
Gray(RECV_HD_WRK_PBL.NF_MULTI_BRL_PB);
Else
UnGray(RECV_HD_WRK_PBL.NF_MULTI_BRL_PB);
End-If;
End-If;
End-For;
End-If;
/* BRLPO - HAT - 8.00 - 20/06/01 - END */
[NF_LN_BRL.BUSINESS_UNIT.SavePostChange]
/*******************************************************************************
*******
* Vinicius Montijo Favero - MMC - 11/03/2015 - mmcb.sds5100
*
* Ajuste de Dados Incorretos no Registro ou Faturamento
*
********************************************************************************
******/
29943 *
* Alterao para corrigir o problema de notas fiscais de terceiros "POTER" com mais
*
* de um item de uma ou mais ordens de compra
*
*******************************************************************************
**********/
/*******************************************************************************
**********
* Fabiano Cunha - MMCB - 05/11/2009
- mmcb.sds3239
*
* Projeto Implantao People - Multi Empresa MMCB-SVB.
*
*******************************************************************************
**********/
/*******************************************************************************
**********
* Wagner Sorio - MMCB - 01/09/2014 - mmcb.sds4689
*
* Implantao do People DBME
*
********************************************************************************
**********/
/*******************************************************************************
**********
* Augusto/Joo Roberto (Enc. Joo Couto) - MMCB - 19/08/2015 - mmcb.hd250656
*
* Correo para que as notas alteradas na tela de manuteno de NF no criem um novo
*
* recebimento.
*
********************************************************************************
**********/
/* Declare Function BU_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange; */ /*
mmcb.sds4689.lo */
Declare Function MMC_BUSINESS_UNIT PeopleCode MMC_BUS_UNIT.BUSINESS_UNIT SavePos
tChange; /* mmcb.sds4689.ln */
Declare Function Cria_Recb_Fisico PeopleCode MMC_TERC_WRK.BUSINESS_UNIT_IN Field
Formula;
If %Component <> Component.MMC_NF_ALTERA Then /* mmcb.hd250656.ln */
/* If BUSINESS_UNIT = "POTER" Then */ /* mmcb.sds3239.lo */
/* If BUSINESS_UNIT = BU_SETID("CPTR1") Then */ /* mmcb.sds4689.lo */
If BUSINESS_UNIT = MMC_BUSINESS_UNIT("POTERC", BUSINESS_UNIT) Then /* mmcb.sd
s4689.ln */
If NF_BRL_LINE_NUM < 2 Then
SQLExec(" UPDATE PS_BUS_UNIT_TBL_PM SET RECV_ID_LAST_USED = RECV_ID_LAS
T_USED + 1 WHERE BUSINESS_UNIT = :1", BUSINESS_UNIT);
SQLExec("SELECT
FROM PS_BUS_UNIT_TBL_PM
Else
SQLExec("SELECT
FROM PS_BUS_UNIT_TBL_PM
End-If;
REPLACE(TO_CHAR(RECV_ID_LAST_USED,'0000000009'),' ','')
WHERE BUSINESS_UNIT = :1", BUSINESS_UNIT, &PREC_ID);
REPLACE(TO_CHAR(RECV_ID_LAST_USED,'0000000009'),' ','')
WHERE BUSINESS_UNIT = :1", BUSINESS_UNIT, &PREC_ID);
/*BRLOC-PO-APP-8.00-09/04/01-BEGIN */
/* No necessrio o preenchimento do CFOP quando a opo de escriturao fiscal do OF es
iver Nenhum */
If TOF_TYPE_PBL.TOF_TAX_BOOK_PBL = "N" Then
WinMessage(MsgGet(30000, 82, "CFOP is not necessary for this type of chose
n TOF."));
CFOP_INCOM_PBL = " ";
CFOP_EXT_CD_BBL = " ";
End-If;
/*** JEISON CALDAS - 25/11/05 - BASEADO EM CFOP PARAMETRIZADO INIBE CAMPO DE
CDIGO DE RETENO - INCIO ***/
/* Gustavo adequacao para nota de debito or %component = component.mmc_lanc_g
ar_nd */
If (%Component = Component.NF_RECV_PBL Or
%Component = Component.NF_INFO_PBL Or
%Component = Component.MMC_LANC_GAR Or
%Component = Component.MMC_LANC_GAR_ND) And
All(CFOP_INCOM_PBL) Then
SQLExec("SELECT 'X' FROM PS_MMC_CFOP_CODRET WHERE SETID = 'MMCSA' AND CFO_
BRL_CD = :1", CFOP_INCOM_PBL, &CFOP_BLOQ);
If &CFOP_BLOQ = "X" Then
WTHD_CD = " ";
Gray(WTHD_CD);
Else
UnGray(WTHD_CD);
End-If;
End-If;
/*** JEISON CALDAS - 25/11/05 - BASEADO EM CFOP PARAMETRIZADO INIBE CAMPO DE
CDIGO DE RETENO - FIM ***/
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 26/04/2006 - Inicio
Alterao de melhoria para habilitar / desabilitar link "Vincular Ordem de Compra
" */
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 20/06/2006
Alterado campo de BUTTON para BUTTONOFFLINE.
Alterado tambm Scroll de MMC_TERC_OC para MMC_CT_NFLN_TRI */
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 21/06/2006
Ao excluir o vnculo com OC, ser excludo tambm o vnculo com a memria (Rowset) global
&MMC_LinhaNF_LinhasOC, baseado em SEQNUM, que contm o nmero da Linha */
If %Page = Page.NF_INFO_LN_PBL And
%Component = Component.NF_INFO_PBL Then
If &MMC_ENTRAPOR_PACABADO Or
&MMC_ENTRAPOR_PACABADONF Then
MMC_NF_LN_WRK.BUTTON.Visible = False;
MMC_NF_LN_WRK.BUTTON.Enabled = False;
SQLExec("Select MMC_CNTRL_TERC From PS_CFO_BRL_TBL Where SETID = :1 And
CFO_BRL_CD = :2", ITM_SETID, CFOP_INCOM_PBL, &MMC_CNTRL_TERC);
If &MMC_CNTRL_TERC = "Y" Then
MMC_NF_LN_WRK.BUTTONOFFLINE.Visible = True;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 02/06/2006 - In
icio */
&MMC_TERC_OC_RS = GetRowset(Scroll.MMC_CT_NFLN_TRI);
If All(&MMC_TERC_OC_RS.GetRow(1).MMC_CT_NFLN_TRI.LINE_NBR.Value) The
n
MMC_NF_LN_WRK.BUTTONOFFLINE.Enabled = False;
Else
MMC_NF_LN_WRK.BUTTONOFFLINE.Enabled = True;
End-If;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 02/06/2006 - Fi
m */
Else
MMC_NF_LN_WRK.BUTTONOFFLINE.Enabled = False;
MMC_NF_LN_WRK.BUTTONOFFLINE.Visible = False;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 02/06/2006 - In
icio */
&MMC_TERC_OC_RS = GetRowset(Scroll.MMC_CT_NFLN_TRI);
For &i2 = &MMC_TERC_OC_RS.ActiveRowCount To 1 Step - 1
&MMC_TERC_OC_RS.FlushRow(&i2);
End-For;
PO_ID = "";
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 02/06/2006 - Fi
m */
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 21/06/2006 - In
icio */
For &i2 = &MMC_LinhaNF_LinhasOC.ActiveRowCount To 1 Step - 1
If &MMC_LinhaNF_LinhasOC.GetRow(&i2).MMC_TERC_OC.SEQNUM.Value = N
F_BRL_LINE_NUM Then
&MMC_LinhaNF_LinhasOC.DeleteRow(&i2);
Break;
End-If;
End-For;
If &MMC_LinhaNF_LinhasOC.ActiveRowCount = 0 Then
&MMC_LinhaNF_LinhasOC.Flush();
End-If;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 21/06/2006 - Fi
m */
End-If;
Else
MMC_NF_LN_WRK.BUTTONOFFLINE.Enabled = False;
MMC_NF_LN_WRK.BUTTONOFFLINE.Visible = False;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 02/06/2006 - Inici
o */
&MMC_TERC_OC_RS = GetRowset(Scroll.MMC_CT_NFLN_TRI);
For &i2 = &MMC_TERC_OC_RS.ActiveRowCount To 1 Step - 1
&MMC_TERC_OC_RS.FlushRow(&i2);
End-For;
PO_ID = "";
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 02/06/2006 - Fim *
/
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 21/06/2006 - Inici
o */
For &i2 = &MMC_LinhaNF_LinhasOC.ActiveRowCount To 1 Step - 1
If &MMC_LinhaNF_LinhasOC.GetRow(&i2).MMC_TERC_OC.SEQNUM.Value = NF_B
RL_LINE_NUM Then
&MMC_LinhaNF_LinhasOC.DeleteRow(&i2);
Break;
End-If;
End-For;
If &MMC_LinhaNF_LinhasOC.ActiveRowCount = 0 Then
&MMC_LinhaNF_LinhasOC.Flush();
End-If;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 21/06/2006 - Fim *
/
End-If;
End-If;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 26/04/2006 - Fim */
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 26/04/2006 - Cdigo Antigo
- Inicio */
/****************************************************************************
***********/
/* MMC - ASM - 23/02/2006 - Cuando cambia el item, debo consultar nuevamente
para saber si activo el link de vincular con Orden de Compra */
rem ASM SQLExec("Select MMC_CNTRL_TERC From PS_CFO_BRL_TBL Where SETID = :1 A
nd CFO_BRL_CD = :2 And MMC_CNTRL_TERC = 'Y'", ITM_SETID, CFO_BRL_CD, &MMC_CNTRL_
TERC);
/* MMC - ASM - El valor de CFO_BRL_CD se debe obtener en la linea del campo C
FOP_INCOM_PBL */
/*
SQLExec("Select MMC_CNTRL_TERC From PS_CFO_BRL_TBL Where SETID = :1 And CFO_BRL_
CD = :2 And MMC_CNTRL_TERC = 'Y'", ITM_SETID, CFOP_INCOM_PBL, &MMC_CNTRL_TERC);
If All(&MMC_CNTRL_TERC) Then
MMC_NF_LN_WRK.BUTTON.Enabled = True;
Else
MMC_NF_LN_WRK.BUTTON.Enabled = False;
End-If;
*/
/* MMC - ASM - Fin */
/****************************************************************************
********/
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 26/04/2006 - Cdigo Antigo
- Fim */
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 26/04/2006 - Fim */
End-If; /*mmcb.sds5100 l.n*/
[NF_LN_BRL.CFOP_INCOM_PBL.FieldFormula]
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 26/04/2006 - Inicio
Utilizao de Variveis para verifcar se foi utilizado Controle de Terceiros */
Global boolean &MMC_ENTRAPOR_ITEM, &MMC_ENTRAPOR_PACABADO, &MMC_ENTRAPOR_PACABAD
ONF, &MMC_ENTRAPOR_TRIANGULACAO, &MMC_Controle_Terceiros;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 26/04/2006 - Fim */
Local string &MMC_CNTRL_TERC;
Local Rowset &Level1, &MMC_TERC_OC_RS;
Local number &i, &i2;
Global Rowset &MMC_LinhaNF_LinhasOC; /* Fabio - 21/06/2006 */
Global boolean &criou_RS_MMC_TERC_OC; /* Fabio - 21/06/2006 */
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 03/05/2006 - Inicio
Funo Habilitar ou Desabilitar Vnculo de Ordem de Compra em todas as Linhas da NF
*/
Function Hab_Desab_Vinc_OC()
If &criou_RS_MMC_TERC_OC = False Then
&criou_RS_MMC_TERC_OC = True;
&MMC_LinhaNF_LinhasOC = CreateRowset(Record.MMC_TERC_OC);
End-If;
/* MMC - ASM - 25/02/2005 - Codigo que activa o desactiva el link de "Vincula
r Ordem de Compra" */
&Level1 = GetLevel0()(1).GetRowset(Scroll.NF_LN_BRL);
For &i = 1 To &Level1.ActiveRowCount
/* MMC - ASM - 23/02/2006 - El valor de CFO_BRL_CD se debe obtener en la l
inea del campo CFOP_INCOM_PBL */
/****** MMC_CT_09 - Cdigo antigo...
SQLExec("Select MMC_CNTRL_TERC From PS_CFO_BRL_TBL Where SETID = :1 And CFO_B
RL_CD = :2 And MMC_CNTRL_TERC = 'Y'", &Level1(&i).NF_LN_BRL.ITM_SETID.Value, &Le
vel1(&i).NF_LN_BRL.CFOP_INCOM_PBL.Value, &MMC_CNTRL_TERC);
****** MMC_CT_09 - Cdigo antigo... */
/*
If All(&MMC_CNTRL_TERC) Then
&Level1(&i).MMC_NF_LN_WRK.BUTTON.Enabled = True;
Else
&Level1(&i).MMC_NF_LN_WRK.BUTTON.Enabled = False;
End-If;
*/
/* MMC_CT_09 - Novo cdigo */
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 20/06/2006
Alterado campo de BUTTON para BUTTONOFFLINE.
Alterado tambm Scroll de MMC_TERC_OC para MMC_CT_NFLN_TRI */
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 21/06/2006
Ao excluir o vnculo com OC, ser excludo tambm o vnculo com a memria (Rowset) global
&MMC_LinhaNF_LinhasOC, baseado em SEQNUM, que contm o nmero da Linha */
If &MMC_Controle_Terceiros And
(&MMC_ENTRAPOR_PACABADO Or
&MMC_ENTRAPOR_PACABADONF) And
%Component = Component.NF_INFO_PBL Then
MMC_NF_LN_WRK.BUTTON.Visible = False;
MMC_NF_LN_WRK.BUTTON.Enabled = False;
SQLExec("Select MMC_CNTRL_TERC From PS_CFO_BRL_TBL Where SETID = :1 And
CFO_BRL_CD = :2", &Level1(&i).NF_LN_BRL.ITM_SETID.Value, &Level1(&i).NF_LN_BRL.
CFOP_INCOM_PBL.Value, &MMC_CNTRL_TERC);
If &MMC_CNTRL_TERC = "Y" Then
&Level1(&i).MMC_NF_LN_WRK.BUTTONOFFLINE.Visible = True;
&MMC_TERC_OC_RS = &Level1(&i).GetRowset(Scroll.MMC_CT_NFLN_TRI);
If All(&MMC_TERC_OC_RS.GetRow(1).MMC_CT_NFLN_TRI.LINE_NBR.Value) The
n
&Level1(&i).MMC_NF_LN_WRK.BUTTONOFFLINE.Enabled = False;
Else
&Level1(&i).MMC_NF_LN_WRK.BUTTONOFFLINE.Enabled = True;
End-If;
Else
&Level1(&i).MMC_NF_LN_WRK.BUTTONOFFLINE.Enabled = False;
&Level1(&i).MMC_NF_LN_WRK.BUTTONOFFLINE.Visible = False;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 02/06/2006 - In
icio */
&MMC_TERC_OC_RS = &Level1(&i).GetRowset(Scroll.MMC_CT_NFLN_TRI);
For &i2 = &MMC_TERC_OC_RS.ActiveRowCount To 1 Step - 1
&MMC_TERC_OC_RS.FlushRow(&i2);
End-For;
&Level1(&i).NF_LN_BRL.PO_ID.Value = "";
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 02/06/2006 - Fi
m */
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 21/06/2006 - In
icio */
For &i2 = &MMC_LinhaNF_LinhasOC.ActiveRowCount To 1 Step - 1
If &MMC_LinhaNF_LinhasOC.GetRow(&i2).MMC_TERC_OC.SEQNUM.Value = &
Level1(&i).NF_LN_BRL.NF_BRL_LINE_NUM.Value Then
&MMC_LinhaNF_LinhasOC.DeleteRow(&i2);
Break;
End-If;
End-For;
If &MMC_LinhaNF_LinhasOC.ActiveRowCount = 0 Then
&MMC_LinhaNF_LinhasOC.Flush();
End-If;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 21/06/2006 - Fi
m */
End-If;
Else
&Level1(&i).MMC_NF_LN_WRK.BUTTONOFFLINE.Enabled = False;
&Level1(&i).MMC_NF_LN_WRK.BUTTONOFFLINE.Visible = False;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 02/06/2006 - Inici
o */
/* WELBE 11/07/2006 Comentado pois no deve limpar a scroll neste caso
&MMC_TERC_OC_RS = &Level1(&i).GetRowset(Scroll.MMC_CT_NFLN_TRI);
For &i2 = &MMC_TERC_OC_RS.ActiveRowCount To 1 Step - 1
&MMC_TERC_OC_RS.FlushRow(&i2);
End-For; */
REM WELBE 11/07/2006 &Level1(&i).NF_LN_BRL.PO_ID.Value = "";
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 02/06/2006 - Fim *
/
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 21/06/2006 - Inici
o */
/* WELBE 11/07/2006 Comentado pois no deve limpar a scroll neste caso
For &i2 = &MMC_LinhaNF_LinhasOC.ActiveRowCount To 1 Step - 1
If &MMC_LinhaNF_LinhasOC.GetRow(&i2).MMC_TERC_OC.SEQNUM.Value = &Lev
el1(&i).NF_LN_BRL.NF_BRL_LINE_NUM.Value Then
&MMC_LinhaNF_LinhasOC.DeleteRow(&i2);
Break;
End-If;
End-For;
If &MMC_LinhaNF_LinhasOC.ActiveRowCount = 0 Then
&MMC_LinhaNF_LinhasOC.Flush();
End-If;
*/
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 21/06/2006 - Fim *
/
End-If;
End-For;
/* MMC -ASM */
End-Function;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 03/05/2006 - Fim */
[NF_LN_BRL.CFOP_INCOM_PBL.RowInit]
If %Mode = "A" Then
If TOF_TYPE_PBL.TOF_TAX_BOOK_PBL = "N" Then
CFOP_INCOM_PBL = " ";
CFOP_EXT_CD_BBL = " ";
End-If;
End-If;
/*** JEISON CALDAS - 25/11/05 - BASEADO EM CFOP PARAMETRIZADO INIBE CAMPO DE CDIG
O DE RETENO - INCIO ***/
If (%Component = Component.NF_RECV_PBL Or
%Component = Component.NF_INFO_PBL Or
%Component = Component.MMC_LANC_GAR) And
All(CFOP_INCOM_PBL) Then
SQLExec("SELECT 'X' FROM PS_MMC_CFOP_CODRET WHERE SETID = 'MMCSA' AND CFO_BRL
_CD = :1", CFOP_INCOM_PBL, &CFOP_BLOQ);
If &CFOP_BLOQ = "X" Then
WTHD_CD = " ";
Gray(WTHD_CD);
Else
UnGray(WTHD_CD);
End-If;
End-If;
/*** JEISON CALDAS - 25/11/05 - BASEADO EM CFOP PARAMETRIZADO INIBE CAMPO DE CDIG
O DE RETENO - FIM ***/
[NF_LN_BRL.COFINSST_PCT_BBL.RowInit]
/*******************************************************************************
****
* Wagner Sorio - MMC - 20/05/2009 - mmcb.sds3027 - NF Devoluo
* Customizao nos cauculos de NF devolucao.
********************************************************************************
****/
/***************************** mmcb.sds3027.sn *********************************
****/
If %Component = Component.NF_INQ_PBL Then
Gray(COFINSST_PCT_BBL);
Gray(COFINST_BSSAMT_BBL);
Gray(COFINST_BSEAMT_BBL);
Gray(PISST_PCT_BBL);
Gray(PISST_BSS_AMT_BBL);
Gray(PISST_BSE_AMT_BBL);
Gray(ICMSST_PCT_BBL);
Gray(ICMSSUB_BRL_BSS);
Gray(ICMSSUB_BRL_AMT);
End-If;
/***************************** mmcb.sds3027.en *********************************
***/
[NF_LN_BRL.COFINSTAX_BRL_AMT.SaveEdit]
/*******************************************************************************
***
* Claudio Henrique da Costa - MMCB - 16/08/2006 - mmcb.hd24104
*
* Customizacao para que seja verificado se existe PIS e COFINS para o tipo de
*
* Finalidade.
*
*******************************************************************************
***/
/*******************************************************************************
***
* Claudio Henrique da Costa - MMCB - 10/12/2009 - mmcb.sds3239
*
* Projeto Implantao People - Multi Empresa MMCB-SVB.
*
*******************************************************************************
***/
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange; /* mmc
b.sds3239.ln */
&SETID = BUSCA_SETID(); /* mmcb.sds3239.ln */
/********************** mmcb.sds3239.so **********************/
/* SQLExec("SELECT COFINS_CALC_PBL FROM SYSADM.PS_BRL_PO_PROP WHERE SETID = 'MMC
SA' AND PURCH_PROP_BRL = :1", PURCH_PROP_BRL, &Exige_COFINS);
*
*
mais travar no s
a situao tributaria inco
ou no lanamento."
mais travar no s
a situao tributaria inco
&LINE_ROW = ActiveRowCount();
If ICMS_COMPL_FLG_PBL = "N" Then
UpdateValue(ICMS_COMPL_AMT_PBL, &LINE_ROW, 0);
End-If;
[NF_LN_BRL.INSURANCE_BRL_AMT.FieldChange]
/*******************************************************************************
*******
* Vinicius Montijo Favero - MMC - 11/03/2015 - mmcb.sds5100
*
* Ajuste de Dados Incorretos no Registro ou Faturamento
*
********************************************************************************
*******/
Declare Function Calc_Other_Exp_Amt PeopleCode FUNCLIB_PBL.EXP_PRORATE_PBL Field
Formula;
If %Component <> "MMC_NF_ALTERA" Then /*mmcb.sds5100 l.n*/
/*BRLOC-PO-APP-8.00-02/04/01-BEGIN */
/*Calc Freight Line Amt if Prorate = "Amount" */
If NF_HDR_BRL.OTHER_PRORATE_PBL = "A" Then
Calc_Other_Exp_Amt();
End-If;
/*BRLOC-PO-APP-8.00-02/04/01-END */
End-If; /*mmcb.sds5100 l.n*/
[NF_LN_BRL.INV_ITEM_ID.FieldChange]
/*******************************************************************************
*****************
* Itamar Junior - MMCB - 04/08/2009 - mmcb.hd72532 - Ajuste para que a descrio da
s embalagens*
* apaream na tela de recebimento
*
*******************************************************************************
*****************/
/*******************************************************************************
*****************
* Bleno Sampaio - MMCB - 26/09/2011- mmcb.hd125448
*
* Correo em SQL que mantinha fixo o SETID da MMCSA, fora do padro multi-empresa
*
*******************************************************************************
*****************/
Declare Function
la;
Declare Function
a;
Declare Function
Declare Function
Declare Function
b.hd125448.ln */
&VENDOR_ESTABID = VENDOR.ESTABID;
If &state_FROM = &STATE_TO Then
&TIPO = "E";
Else
&TIPO = "I";
End-If;
/* BRLPO-HAT-8.01-10/07/01 - Substitudo TOF da Header pelo TOF da Line - Tof p
or linha */
/* CFOP_Values(&SETID, "I", &VENDOR_ESTABID, &estabid_to, NF_HDR_BRL.TOF_PBL
, PURCH_PROP_BRL, &TIPO, CFOP_INCOM_PBL, CFOP_EXT_CD_BBL); */
REM JEISON CALDAS - 02/11/05 - CAMPO DE CFOP NO DEVE SER TRATADO NO ITEM ;
REM CFOP_Values(&SETID, "I", &VENDOR_ESTABID, TOF_PBL, PURCH_PROP_BRL, &TIPO,
CFOP_INCOM_PBL, CFOP_EXT_CD_BBL) - JC800888 02/11/05;
/* BRLPO-HAT-8.01-10/07/01 - END */
/*brloc-po-app-8.01-18/09/01-end */
End-Function;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 26/04/2006 - Cdigo Antigo Inicio
/* Cdigo abaixo comentado. H uma melhoria aps verificao de Item Alterado */
/*******************************************************************************
********/
/* MMC - ASM - Cuando cambia el item, debo consultar nuevamente para saber si ac
tivo el link
de vincular con Orden de Compra */
rem ASM SQLExec("Select MMC_CNTRL_TERC From PS_CFO_BRL_TBL Where SETID = :1 And
CFO_BRL_CD = :2 And MMC_CNTRL_TERC = 'Y'", ITM_SETID, CFO_BRL_CD, &MMC_CNTRL_TER
C);
/* MMC - ASM - El valor de CFO_BRL_CD se debe obtener en la linea del campo CFOP
_INCOM_PBL */
/* antigo inicio...
SQLExec("Select MMC_CNTRL_TERC From PS_CFO_BRL_TBL Where SETID = :1 And CFO_BRL_
CD = :2 And MMC_CNTRL_TERC = 'Y'", ITM_SETID, CFOP_INCOM_PBL, &MMC_CNTRL_TERC);
If All(&MMC_CNTRL_TERC) Then
MMC_NF_LN_WRK.BUTTON.Enabled = True;
Else
MMC_NF_LN_WRK.BUTTON.Enabled = False;
End-If;
antigo fim... */
/* MMC - ASM - Fin */
/*******************/
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 26/04/2006 - Cdigo Antigo Fim */
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 02/05/2006 - Inicio
Ao alterar o cdigo do Item, verificar se o usurio quer realmente alterar tal in
formao. Se isso for confirmado, a varivel que indica que a pgina adveio de Controle
de Terceiros - Produto Acabado ou Produto Acabado-NF Servio passar a ser falsa. Se
no, volta para o valor antigo (que foi guardado em FieldEdit) */
If %Page = Page.NF_INFO_LN_PBL And
%Component = Component.NF_INFO_PBL Then
If &MMC_Controle_Terceiros And
&MMC_CT_GERAOP Then
If NF_LN_BRL.INV_ITEM_ID.IsChanged Then
&Resposta = WinMessage(MsgGet(9999, 99, "Essa NF de Retorno no gerar Orde
m de Produo. Deseja Continuar?"), 4, "Advertncia");
If &Resposta = %MsgResult_Yes Then
&MMC_CT_GERAOP = False;
Hab_Desab_Vinc_OC();
LimpaVincOP();
Else
INV_ITEM_ID = &OldINVITEMID;
End-If;
End-If;
End-If;
End-If;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 02/05/2006 - Fim */
[NF_LN_BRL.INV_ITEM_ID.FieldEdit]
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 02/05/2006 - Inicio
Variveis utilizadas para controle de criao ou no de Ordem de Produo */
Global boolean &MMC_ENTRAPOR_ITEM, &MMC_ENTRAPOR_PACABADO, &MMC_ENTRAPOR_PACABAD
ONF, &MMC_ENTRAPOR_TRIANGULACAO, &MMC_Controle_Terceiros;
Component string &OldINVITEMID;
If None(INVENTORY_ITEM) Then
If All(DESCR) Then
INVENTORY_ITEM = "N";
End-If;
End-If;
REM *** Atribue conta contbil do item para a linha de distribuio ***;
If All(INV_ITEM_ID) Then
&LINE_ROW = CurrentRowNumber();
&DIST_ROW = 1;
REM Alterada a record onde buscada a Conta. Caso no seja encontrado valor n
enhum a busca volta a ser feita na record original ;
SQLExec("select ACCOUNT from PS_PURCH_ITEM_BU where SETID = :1 and INV_ITE
M_ID = :2 AND BUSINESS_UNIT = :3", &SETID_ITEM, INV_ITEM_ID, BUSINESS_UNIT, &ACC
DFT);
If None(&ACCDFT) Then
&ACCDFT = FetchValue(ITM_PURCH_VW.ACCOUNT, &LINE_ROW);
End-If;
UpdateValue(Record.NF_LN_BRL, &LINE_ROW, BRL_DISTRIB_LN.ACCOUNT, &DIST_ROW
, &ACCDFT);
End-If;
*/
End-If;
REM MMC - ASM - 18/02/2006 - Copio parte del cdigo del FieldChange para aca - FIN
;
Rem *** DUILIO CROCE - GRUPO QUANAM - 04/04/2006 - CDIGO RETIRADO *** */;
[NF_LN_BRL.INV_ITEM_ID.SaveEdit]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 24/12/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Customizao Sistema de Terceiros - No deixar ITEM estoque em nf servio .
*
*******************************************************************************
*****************/
/********************** mmcb.at2323.sn **********************/
/*
If %Component = "NF_INFO_PBL" And
MMC_TE_NFLN_WRK.MMC_TERCEIRO_FLG = "Y" And
MMC_TE_RECV_WRK.MMC_TE_NFSERVI_FLG = "Y" Then
SQLExec("select a.inventory_item from ps_master_item_tbl a where a.setid ='MM
CSA' and a.inv_item_id =:1 ", INV_ITEM_ID, &ITEM_ESTOQUE);
If &ITEM_ESTOQUE = "Y" Then
Error ("Item: " | INV_ITEM_ID | " de estoque, no pode ser salvo em NF Servio
.");
End-If;
End-If;
*/
/********************** mmcb.at2323.en **********************/
[NF_LN_BRL.INV_ITEM_ID.SavePostChange]
/*******************************************************************************
**********
Jeferson Rodrigues - MMC - 22/07/2009 - mmcb.hd70635 - Correcao Erro ao excluir
a linha do documento fiscal
********************************************************************************
**********/
If %Page = Page.NF_INFO_LN_PBL And
%Component = Component.NF_INFO_PBL Then
/*** mmcb.hd70635.so ***/
/*
If None(INV_ITEM_ID) Then
Error (" obrigatrio informar o Cdigo do Item! Verificar a linha: " | NF_BRL_L
INE_NUM);
End-If;
*/
/*** mmcb.hd70635.eo ***/
/*********************************************************************
* Claudio Henrique da Costa - MMC - 29/08/2007 - mmcb.AT2117
*
* Alterao para que o sistema determine situao tributrias dos
*
* impostos como sendo Outras quando as alquotas forem 0 (zero).
*
*********************************************************************/
If (%Component = Component.NF_RECV_PBL Or /* mmcb.at2117.sn */
%Component = Component.NF_INFO_PBL Or
%Component = Component.MMC_LANC_GAR) Then
SQLExec("SELECT IPITAX_STS_BBL FROM SYSADM.PS_MMC_VINC_OF_IMP WHERE TOF_PBL =
:1", TOF_PBL, &PARAMETRO_IPI);
If IPITAX_BRL_PCT = 0 And
None(&PARAMETRO_IPI) Then
IPITAX_STS_BBL = "OUTR"
End-If;
End-If; /* mmcb.at2117.en */
[NF_LN_BRL.ITEM_ORIGIN_BBL.FieldChange]
/************************************************************************
* Mauri R. Back - MMCB - mmcb.sds4359 - 09/08/2013
*
* Replicar Origem para todos os itens
*
************************************************************************/
/********************** mmcb.sds4359.sn *********************************/
/*Painel de Entrada Direta e Entrada com Recebimento*/
If %Component = Component.NF_INFO_PBL Or
%Component = Component.NF_RECV_PBL Then
&LN_ATIVAS = ActiveRowCount(Scroll.NF_LN_BRL);
/*Caso tiver mais de uma linha*/
If &LN_ATIVAS > 1 Then
/*Recupera se o usuario deseja alterar origem em todas as linhas*/
&MSG_BOX = WinMessage("Deseja alterar a Origem em todas as linhas do docum
ento fiscal?", 3, "Alterar Origem?");
/*Se deve ser alterado a origem em todas as linhas*/
If &MSG_BOX = 6 Then
For &LN = 1 To &LN_ATIVAS
UpdateValue(ITEM_ORIGIN_BBL, &LN, ITEM_ORIGIN_BBL);
End-For;
End-If; /**** FIM MENSAGEM ****/
End-If; /**** FIM LINHAS ATIVAS ****/
End-If; /**** FIM COMPONENTE ****/
/********************** mmcb.sds4359.en *********************************/
[NF_LN_BRL.MERCHANDISE_AMT.FieldChange]
/*******************************************************************************
*********
BRLOC-PO-AO-24/04/2002 - ICE Resolution 100957
- Este cdigo foi comentado e movido para o campo MERCH_ORIG_AMT_PBL, pois este c
ampo deixou de ser editvel sendo substituido pelo campo MERCH_ORIG_AMT_PBL.
********************************************************************************
**********
If All(QTY_NF_BRL) And
All(MERCHANDISE_AMT) Then
UNIT_PRICE = RoundCurrency(MERCHANDISE_AMT / QTY_NF_BRL, NF_HDR_BRL.BASE_CURR
ENCY, NF_HDR_BRL.NF_BRL_DATE);
MERCH_AMT_BSE = MERCHANDISE_AMT;
End-If;
If All(DSCNT_PCT) Then
DSCNT_AMT = RoundCurrency(DSCNT_PCT / 100 * MERCHANDISE_AMT, BASE_CURRENCY, N
F_HDR_BRL.NF_BRL_DATE);
End-If;
DERIVED_BRL_AP.MERCH_AMT_DSCNT = MERCHANDISE_AMT - DSCNT_AMT;
*** BRLOC-PO-AO-24/04/2002 - ICE Resolution 100957 - END ***********************
**************/
[NF_LN_BRL.MERCH_ORIG_AMT_PBL.FieldChange]
/* BRLOC - PO - FFR - 23/01/2003 - ICE Resolution ID 115947 - BEGIN */
Declare Function ATUALIZA_DISTRIB PeopleCode UNIT_PRICE FieldChange;
/* BRLOC - PO - FFR - 23/01/2003 - ICE Resolution ID 115947 - END */
/*** BRLOC-PO-AO-24/04/2002 - ICE Resolution 100957
- Cdigo movido do campo NF_LN_BRL.MERCHANDISE_AMT que foi substituido pelo campo
MERCH_ORIG_AMT_PBL.
***************************************************************************/
If %Component = Component.NF_RECV_PBL Then
If All(PO_ID) Then
SQLExec("SELECT PRICE_PO FROM PS_RECV_LN_SHIP WHERE BUSINESS_UNIT = :1 AND
RECEIVER_ID = :2 AND RECV_LN_NBR = :3 AND RECV_SHIP_SEQ_NBR = :4", BUSINESS_UNI
T, RECEIVER_ID, RECV_LN_NBR, RECV_SHIP_SEQ_NBR, &valor_antes);
If All(&valor_antes) Then
&valor_antes = &valor_antes * QTY_NF_BRL;
Else
&valor_antes = PriorValue(MERCH_ORIG_AMT_PBL);
End-If;
If (MERCH_ORIG_AMT_PBL > &valor_antes) Then
MERCH_ORIG_AMT_PBL = &valor_antes;
WinMessage("O valor nao pode ser aumentado.");
/* mmcb.sds2895 - s.n. */
Else
If (MERCH_ORIG_AMT_PBL < &valor_antes) Then
MERCH_ORIG_AMT_PBL = &valor_antes;
WinMessage("O valor nao pode ser diminudo.");
End-If;
/* mmcb.sds2895 - e.n. */
End-If;
End-If;
End-If;
If All(QTY_NF_BRL) And
All(MERCH_ORIG_AMT_PBL) Then
UNIT_PRICE = RoundCurrency(MERCH_ORIG_AMT_PBL / QTY_NF_BRL, NF_HDR_BRL.BASE_C
URRENCY, NF_HDR_BRL.NF_BRL_DATE);
End-If;
If All(DSCNT_PCT) Then
DSCNT_AMT = RoundCurrency(DSCNT_PCT / 100 * MERCH_ORIG_AMT_PBL, BASE_CURRENCY
, NF_HDR_BRL.NF_BRL_DATE);
End-If;
DERIVED_BRL_AP.MERCH_AMT_DSCNT = MERCH_ORIG_AMT_PBL - DSCNT_AMT;
/* BRLOC - PO - FFR - 23/01/2003 - ICE Resolution ID 115947 - BEGIN */
/* Descrio: Atualiza as linhas de distribuio, quando o preo total
preenchido na linha, ao invs do preo unitrio*/
ATUALIZA_DISTRIB();
/* BRLOC - PO - FFR - 23/01/2003 - ICE Resolution ID 115947 - END */
[NF_LN_BRL.NF_BRL_ID.SavePostChange]
/*
&SQL = "
INSERT INTO sysadm.ps_nf_ln_brl ";
&SQL = &SQL | "(business_unit, nf_brl_id, nf_brl_line_num, total_distribs,";
&SQL = &SQL | "
max_distrib_line, business_unit_po, po_id, itm_set
id,";
&SQL = &SQL | "
inv_item_id, descr, merchandise_amt, merch_amt_bs
e, qty_nf_brl,";
&SQL = &SQL | "
statistic_amount, unit_of_measure, unit_price, fr
eight_amt_bse,";
&SQL = &SQL | "
freight_amt, insurance_brl_amt, insurance_brl_bse
,";
&SQL = &SQL | "
otherexp_brl_amt, otherexp_brl_bse, dscnt_amt, ds
cnt_amt_bse,";
&SQL = &SQL | "
dscnt_pct, error_flag, business_unit_recv, receiv
er_id,";
&SQL = &SQL | "
recv_ln_nbr, recv_ship_seq_nbr, shipto_id, txn_cu
rrency_cd,";
&SQL = &SQL | "
base_currency, currency_cd, cfo_brl_cd, purch_pro
p_brl,";
&SQL = &SQL | "
tax_class_brl, ipitax_brl_bse, ipitax_brl_amt, ip
itax_brl_pct,";
&SQL = &SQL | "
ipitax_brl_rcvry, ipitax_brl_bss, tax_type_brl, i
cmstax_brl_bse,";
&SQL = &SQL | "
icmstax_brl_amt, icmstax_brl_pct, icmstax_brl_red
,";
&SQL = &SQL | "
icmstax_brl_rcvry, icmstax_brl_bss, icmssub_brl_a
mt,";
&SQL = &SQL | "
icmssub_brl_bse, icmstax_brl_due, icmstax_brl_ret
ent,";
&SQL = &SQL | "
cfop_incom_pbl, cfop_ext_cd_bbl, ipi_crlim_pct_pb
l,";
&SQL = &SQL | "
ipi_extcr_pct_pbl, icms_crlim_pct_pbl, icms_extcr
_pct_pbl,";
&SQL = &SQL | "
icms_compl_pct_pbl, icms_compl_amt_pbl, icmstax_p
bl_div,";
&SQL = &SQL | "
ipitax_pbl_div, tof_pbl, nf_line_type_bbl, rmneio
_line_no_bbl,";
&SQL = &SQL | "
demand_source, source_bus_unit, product_id, kit_l
ine_nbr,";
&SQL = &SQL | "
item_origin_bbl, sit_trib_icms_bbl, int_tax_class
_brl,";
&SQL = &SQL
brl_amt,";
&SQL = &SQL
s_pbl";
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
&SQL = &SQL
| "
| "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
)";
VALUES (:1, :2, :3, 8,";
1, 'POIND', '0000000108', 'MMCSA',";
' ', 'FABIANO TESTE', 300, 300, 1,";
0, 'UND', 300, 0,";
0, 0, 0,";
0, 0, 0, 0,";
0, 'N', 'POIND', '0000000026',";
1, 1, ' ', 'BRL',";
'BRL', 'BRL', '9.99', 'USO',";
' ', 0, 0, 0,";
0, 300, ' ', 0,";
0, 0, 0,";
0, 300, 0,";
0, 0, 0,";
'9.99', ' ', 0,";
0, 0, 0,";
0, 0, 0,";
0, 'PSERV', ' ', 0,";
' ', ' ', ' ', 0,";
' ', ' ', ' ',";
0, 0, 0,";
0, 0, 0,";
0, 0, 0, 0,";
0, 0, 0, 0,";
0, 0, 0, 0,";
0, 0, 0,";
0, 0, 0,";
0, 0, ' ',";
' ', ' ', ' ',";
' ', ' ', ' ',";
' ', 0, 0,";
0, 0, 0,";
0, 0, 0, 0,";
' ', ' ', ' ', 'N',";
'N', 0, 0,";
0, ' ', 0, ' ',";
' ', ' ', 'N',";
0, 0, 0,";
0, 0, 0,";
0, 0, 0,";
0, 0, 0, 0,";
0, 0, 0, 0,";
0, 0, 0, ' ',";
'Q', NULL, ' ', ' ',";
0, ' ', ' ', ' ',";
' ', ' ', ' ', ' ',";
' ', ' ', 0,";
NULL, ' ', 0,";
0, 0, 0,";
0, ' ', ' ',";
' ', ' ', 0,";
0, 0, 0,";
0, ' ', ' '";
);";
&REC.ICMSSUB_BRL_AMT.VALUE = ICMSSUB_BRL_AMT;
&REC.ICMSSUB_BRL_BSE.VALUE = ICMSSUB_BRL_BSE;
&REC.ICMSTAX_BRL_DUE.VALUE = ICMSTAX_BRL_DUE;
&REC.ICMSTAX_BRL_RETENT.VALUE = ICMSTAX_BRL_RETENT;
&REC.CFOP_INCOM_PBL.VALUE = CFOP_INCOM_PBL;
&REC.CFOP_EXT_CD_BBL.VALUE = CFOP_EXT_CD_BBL;
&REC.IPI_CRLIM_PCT_PBL.VALUE = IPI_CRLIM_PCT_PBL;
&REC.IPI_EXTCR_PCT_PBL.VALUE = IPI_EXTCR_PCT_PBL;
&REC.ICMS_CRLIM_PCT_PBL.VALUE = ICMS_CRLIM_PCT_PBL;
&REC.ICMS_EXTCR_PCT_PBL.VALUE = ICMS_EXTCR_PCT_PBL;
&REC.ICMS_COMPL_PCT_PBL.VALUE = ICMS_COMPL_PCT_PBL;
&REC.ICMS_COMPL_AMT_PBL.VALUE = ICMS_COMPL_AMT_PBL;
&REC.ICMSTAX_PBL_DIV.VALUE = ICMSTAX_PBL_DIV;
&REC.IPITAX_PBL_DIV.VALUE = IPITAX_PBL_DIV;
&REC.TOF_PBL.VALUE = TOF_PBL;
&REC.NF_LINE_TYPE_BBL.VALUE = NF_LINE_TYPE_BBL;
&REC.RMNEIO_LINE_NO_BBL.VALUE = RMNEIO_LINE_NO_BBL;
&REC.DEMAND_SOURCE.VALUE = DEMAND_SOURCE;
&REC.SOURCE_BUS_UNIT.VALUE = SOURCE_BUS_UNIT;
&REC.PRODUCT_ID.VALUE = PRODUCT_ID;
&REC.KIT_LINE_NBR.VALUE = KIT_LINE_NBR;
&REC.ITEM_ORIGIN_BBL.VALUE = ITEM_ORIGIN_BBL;
&REC.SIT_TRIB_ICMS_BBL.VALUE = SIT_TRIB_ICMS_BBL;
&REC.INT_TAX_CLASS_BRL.VALUE = INT_TAX_CLASS_BRL;
&REC.UNIT_AMT_BSE_BBL.VALUE = UNIT_AMT_BSE_BBL;
&REC.NET_AMT_BSE_BBL.VALUE = NET_AMT_BSE_BBL;
&REC.UNIT_COST.VALUE = UNIT_COST;
&REC.COFINS_BSS_AMT_BBL.VALUE = COFINS_BSS_AMT_BBL;
&REC.COFINS_PCT_BBL.VALUE = COFINS_PCT_BBL;
&REC.COFINS_AMT_BBL.VALUE = COFINS_AMT_BBL;
&REC.COFINS_AMT_BSE_BBL.VALUE = COFINS_AMT_BSE_BBL;
&REC.PIS_BSS_AMT_BBL.VALUE = PIS_BSS_AMT_BBL;
&REC.PIS_PCT_BBL.VALUE = PIS_PCT_BBL;
&REC.PIS_AMT_BBL.VALUE = PIS_AMT_BBL;
&REC.PIS_AMT_BSE_BBL.VALUE = PIS_AMT_BSE_BBL;
&REC.ISSTAX_BRL_BSS.VALUE = ISSTAX_BRL_BSS;
&REC.ISSTAX_BRL_PCT.VALUE = ISSTAX_BRL_PCT;
&REC.ISSTAX_BRL_AMT.VALUE = ISSTAX_BRL_AMT;
&REC.ISSTAX_BRL_BSE.VALUE = ISSTAX_BRL_BSE;
&REC.MVA_PCT_BBL.VALUE = MVA_PCT_BBL;
&REC.LT_IPI_BSE_BBL.VALUE = LT_IPI_BSE_BBL;
&REC.LT_ICMS_BSE_BBL.VALUE = LT_ICMS_BSE_BBL;
&REC.LT_ICMS_ST_BSE_BBL.VALUE = LT_ICMS_ST_BSE_BBL;
&REC.LT_PIS_BSE_BBL.VALUE = LT_PIS_BSE_BBL;
&REC.LT_COFINS_BSE_BBL.VALUE = LT_COFINS_BSE_BBL;
&REC.LT_ISS_BSE_BBL.VALUE = LT_ISS_BSE_BBL;
&REC.FIN_CHG_PCT_BBL.VALUE = FIN_CHG_PCT_BBL;
&REC.FINCHG_AMT_BBL.VALUE = FINCHG_AMT_BBL;
&REC.FINCHG_AMT_BSE_BBL.VALUE = FINCHG_AMT_BSE_BBL;
&REC.NET_UNIT_PRICE.VALUE = NET_UNIT_PRICE;
&REC.NF_ACT_TMPL_BBL.VALUE = NF_ACT_TMPL_BBL;
&REC.ICMSTAX_STS_BBL.VALUE = ICMSTAX_STS_BBL;
&REC.ICMSSUB_STS_BBL.VALUE = ICMSSUB_STS_BBL;
&REC.IPITAX_STS_BBL.VALUE = IPITAX_STS_BBL;
&REC.ISSTAX_STS_BBL.VALUE = ISSTAX_STS_BBL;
&REC.IRTAX_STS_BBL.VALUE = IRTAX_STS_BBL;
&REC.INSSTAX_STS_BBL.VALUE = INSSTAX_STS_BBL;
&REC.IPI_IN_ICMSBAS_BBL.VALUE = IPI_IN_ICMSBAS_BBL;
&REC.ICMS_RED_BSE_BBL.VALUE = ICMS_RED_BSE_BBL;
&REC.ICMSST_RED_BSE_BBL.VALUE = ICMSST_RED_BSE_BBL;
&REC.IPI_RED_BSE_BBL.VALUE = IPI_RED_BSE_BBL;
&REC.ISS_RED_BSE_BBL.VALUE = ISS_RED_BSE_BBL;
&REC.ICMSSUB_BRL_BSS.VALUE = ICMSSUB_BRL_BSS;
&REC.IR_RED_BSE_BBL.VALUE = IR_RED_BSE_BBL;
&REC.INSS_RED_BSE_BBL.VALUE = INSS_RED_BSE_BBL;
&REC.ICMSST_PCT_BBL.VALUE = ICMSST_PCT_BBL;
&REC.GROSS_AMT_BSE.VALUE = GROSS_AMT_BSE;
&REC.DST_ID_DIS.VALUE = DST_ID_DIS;
&REC.DST_ID_REV.VALUE = DST_ID_REV;
&REC.DST_ID_SUR.VALUE = DST_ID_SUR;
&REC.INVENTORY_ITEM.VALUE = INVENTORY_ITEM;
&REC.COST_ADJ_STS_PBL.VALUE = COST_ADJ_STS_PBL;
&REC.FRT_INCR_BSE_BBL.VALUE = FRT_INCR_BSE_BBL;
&REC.INSR_INCR_BSE_BBL.VALUE = INSR_INCR_BSE_BBL;
&REC.OTEX_INCR_BSE_BBL.VALUE = OTEX_INCR_BSE_BBL;
&REC.WTHD_CD.VALUE = WTHD_CD;
&REC.PROCESS_INSTANCE.VALUE = PROCESS_INSTANCE;
&REC.DESCR254_MIXED.VALUE = DESCR254_MIXED;
&REC.PYMNT_TERMS_CD.VALUE = PYMNT_TERMS_CD;
&REC.PAY_TRM_BSE_DT_OPT.VALUE = PAY_TRM_BSE_DT_OPT;
&REC.ICMS_COMPL_FLG_PBL.VALUE = ICMS_COMPL_FLG_PBL;
&REC.COFINST_BSSAMT_BBL.VALUE = COFINST_BSSAMT_BBL;
&REC.COFINSST_PCT_BBL.VALUE = COFINSST_PCT_BBL;
&REC.COFINSST_AMT_BBL.VALUE = COFINSST_AMT_BBL;
&REC.COFINST_BSEAMT_BBL.VALUE = COFINST_BSEAMT_BBL;
&REC.LT_COFINSSTBSE_BBL.VALUE = LT_COFINSSTBSE_BBL;
&REC.PISST_BSS_AMT_BBL.VALUE = PISST_BSS_AMT_BBL;
&REC.PISST_PCT_BBL.VALUE = PISST_PCT_BBL;
&REC.PISST_AMT_BBL.VALUE = PISST_AMT_BBL;
&REC.PISST_BSE_AMT_BBL.VALUE = PISST_BSE_AMT_BBL;
&REC.LT_PISS_BSE_BBL.VALUE = LT_PISS_BSE_BBL;
&REC.IR_BSS_AMT_BBL.VALUE = IR_BSS_AMT_BBL;
&REC.IR_PCT_BBL.VALUE = IR_PCT_BBL;
&REC.IR_BSE_AMT_BBL.VALUE = IR_BSE_AMT_BBL;
&REC.IR_AMT_BBL.VALUE = IR_AMT_BBL;
&REC.LT_IRBSE_BBL.VALUE = LT_IRBSE_BBL;
&REC.INSS_BSS_AMT_BBL.VALUE = INSS_BSS_AMT_BBL;
&REC.INSS_PCT_BBL.VALUE = INSS_PCT_BBL;
&REC.INSS_BSE_AMT_BBL.VALUE = INSS_BSE_AMT_BBL;
&REC.INSS_AMT_BBL.VALUE = INSS_AMT_BBL;
&REC.LT_INSSBSE_BBL.VALUE = LT_INSSBSE_BBL;
&REC.IF_BRL.VALUE = IF_BRL;
&REC.DISTRIB_MTHD_FLG.VALUE = DISTRIB_MTHD_FLG;
&REC.PAYTRMS_DT_BSE_PBL.VALUE = PAYTRMS_DT_BSE_PBL;
&REC.FLOW_STATUS_PBL.VALUE = FLOW_STATUS_PBL;
&REC.RTV_ID.VALUE = RTV_ID;
&REC.RTV_LN_NBR.VALUE = RTV_LN_NBR;
&REC.FLOW_ID_BBL.VALUE = FLOW_ID_BBL;
&REC.FLOW_BUS_UNIT_IN.VALUE = FLOW_BUS_UNIT_IN;
&REC.STORAGE_AREA.VALUE = STORAGE_AREA;
&REC.STOR_LEVEL_1.VALUE = STOR_LEVEL_1;
&REC.STOR_LEVEL_2.VALUE = STOR_LEVEL_2;
&REC.STOR_LEVEL_3.VALUE = STOR_LEVEL_3;
&REC.STOR_LEVEL_4.VALUE = STOR_LEVEL_4;
&REC.FLOW_SHIP_ID_BBL.VALUE = FLOW_SHIP_ID_BBL;
&REC.FLOW_LOCATION_BBL.VALUE = FLOW_LOCATION_BBL;
&REC.ICMS_DISCOUNT_BBL.VALUE = ICMS_DISCOUNT_BBL;
&REC.DT_FLOW_BBL.VALUE = DT_FLOW_BBL;
&REC.COEF_BASE_FLG_PBL.VALUE = COEF_BASE_FLG_PBL;
&REC.COEF_BASE_ICMS_PBL.VALUE = COEF_BASE_ICMS_PBL;
&REC.COEF_BASE_IPI_PBL.VALUE = COEF_BASE_IPI_PBL;
&REC.MERCH_ORIG_AMT_PBL.VALUE = MERCH_ORIG_AMT_PBL;
&REC.IPITAX_BRL_RED.VALUE = IPITAX_BRL_RED;
&REC.COEF_BASE_COFI_PBL.VALUE = COEF_BASE_COFI_PBL;
&REC.CF_IPI_ID_PBL.VALUE = CF_IPI_ID_PBL;
&REC.CF_ICMS_ID_PBL.VALUE = CF_ICMS_ID_PBL;
&REC.CF_PIS_ID_PBL.VALUE = CF_PIS_ID_PBL;
&REC.CF_COFINS_ID_PBL.VALUE = CF_COFINS_ID_PBL;
&REC.COEF_BASE_PIS_PBL.VALUE = COEF_BASE_PIS_PBL;
&REC.COFI_CRLIM_PCT_PBL.VALUE = COFI_CRLIM_PCT_PBL;
&REC.PIS_CRLIM_PCT_PBL.VALUE = PIS_CRLIM_PCT_PBL;
&REC.COFINSTAX_BRL_AMT.VALUE = COFINSTAX_BRL_AMT;
&REC.PISTAX_BRL_AMT.VALUE = PISTAX_BRL_AMT;
&REC.PIS_TAX_STATUS_PBL.VALUE = PIS_TAX_STATUS_PBL;
&REC.COFI_TX_STATUS_PBL.VALUE = COFI_TX_STATUS_PBL;
SQLExec(" SELECT 'Y' FROM SYSADM.PS_NF_LN_BRL WHERE BUSINESS_UNIT = :1 AND
NF_BRL_ID= :2 AND NF_BRL_LINE_NUM = :3 ", BUSINESS_UNIT, NF_BRL_ID, NF_BRL_LINE
_NUM, &EXISTE_NF);
If &EXISTE_NF = "Y" Then
&REC.Update();
Else
&REC.Insert();
End-If;
End-If;
End-If;
*/
[NF_LN_BRL.NF_BRL_ID.SavePreChange]
/*******************************************************************************
*******
* Vinicius Montijo Favero - MMC - 11/03/2015 - mmcb.sds5100
*
* Ajuste de Dados Incorretos no Registro ou Faturamento
*
********************************************************************************
*******/
/******************************* mmcb.sds5100 s.n ******************************
*/
If %Component = "MMC_NF_ALTERA" Then
SQLExec("SELECT NVL(MAX(SEQ_NBR),0) FROM PS_MMC_NF_ALT_HDR WHERE BUSINESS_UNI
T = :1 AND NF_BRL_ID = :2", BUSINESS_UNIT, NF_BRL_ID, &SEQUENCIA);
If FieldChanged(FREIGHT_AMT) Then
SQLExec("Insert into SYSADM.ps_mmc_nf_alt_hdr(BUSINESS_UNIT, NF_BRL_ID, SE
Q_NBR, OPRID, DT_TIMESTAMP,DESCR254, RECNAME, FIELDNAME, OLDVALUE, NEWVALUE, NF_
BRL_LINE_NUM) values (:1,:2,:3,:4,SYSDATE,:5,'NF_LN_BRL','FREIGHT_AMT',:6,:7,:8)
", BUSINESS_UNIT, NF_BRL_ID, &SEQUENCIA, %UserId, MMC_NF_ALT_WRK.DESCR254, NF_LN
_BRL.FREIGHT_AMT.OriginalValue, FREIGHT_AMT, NF_BRL_LINE_NUM);
End-If;
If FieldChanged(INSURANCE_BRL_AMT) Then
SQLExec("Insert into SYSADM.ps_mmc_nf_alt_hdr(BUSINESS_UNIT, NF_BRL_ID, SE
Q_NBR, OPRID, DT_TIMESTAMP,DESCR254, RECNAME, FIELDNAME, OLDVALUE, NEWVALUE, NF_
BRL_LINE_NUM) values (:1,:2,:3,:4,SYSDATE,:5,'NF_LN_BRL','INSURANCE_BRL_AMT',:6,
:7,:8)", BUSINESS_UNIT, NF_BRL_ID, &SEQUENCIA, %UserId, MMC_NF_ALT_WRK.DESCR254,
NF_LN_BRL.INSURANCE_BRL_AMT.OriginalValue, INSURANCE_BRL_AMT, NF_BRL_LINE_NUM);
End-If;
If FieldChanged(OTHEREXP_BRL_AMT) Then
SQLExec("Insert into SYSADM.ps_mmc_nf_alt_hdr(BUSINESS_UNIT, NF_BRL_ID, SE
Q_NBR, OPRID, DT_TIMESTAMP,DESCR254, RECNAME, FIELDNAME, OLDVALUE, NEWVALUE, NF_
BRL_LINE_NUM) values (:1,:2,:3,:4,SYSDATE,:5,'NF_LN_BRL','OTHEREXP_BRL_AMT',:6,:
7,:8)", BUSINESS_UNIT, NF_BRL_ID, &SEQUENCIA, %UserId, MMC_NF_ALT_WRK.DESCR254,
NF_LN_BRL.OTHEREXP_BRL_AMT.OriginalValue, OTHEREXP_BRL_AMT, NF_BRL_LINE_NUM);
End-If;
If FieldChanged(DSCNT_AMT) Then
SQLExec("Insert into SYSADM.ps_mmc_nf_alt_hdr(BUSINESS_UNIT, NF_BRL_ID, SE
Q_NBR, OPRID, DT_TIMESTAMP,DESCR254, RECNAME, FIELDNAME, OLDVALUE, NEWVALUE, NF_
BRL_LINE_NUM) values (:1,:2,:3,:4,SYSDATE,:5,'NF_LN_BRL','DSCNT_AMT',:6,:7,:8)",
BUSINESS_UNIT, NF_BRL_ID, &SEQUENCIA, %UserId, MMC_NF_ALT_WRK.DESCR254, NF_LN_B
RL.DSCNT_AMT.OriginalValue, DSCNT_AMT, NF_BRL_LINE_NUM);
End-If;
If FieldChanged(ICMSTAX_BRL_RCVRY) Then
SQLExec("Insert into SYSADM.ps_mmc_nf_alt_hdr(BUSINESS_UNIT, NF_BRL_ID, SE
Q_NBR, OPRID, DT_TIMESTAMP,DESCR254, RECNAME, FIELDNAME, OLDVALUE, NEWVALUE, NF_
BRL_LINE_NUM) values (:1,:2,:3,:4,SYSDATE,:5,'NF_LN_BRL','ICMSTAX_BRL_RCVRY',:6,
:7,:8)", BUSINESS_UNIT, NF_BRL_ID, &SEQUENCIA, %UserId, MMC_NF_ALT_WRK.DESCR254,
NF_LN_BRL.ICMSTAX_BRL_RCVRY.OriginalValue, ICMSTAX_BRL_RCVRY, NF_BRL_LINE_NUM);
End-If;
If FieldChanged(IPITAX_BRL_RCVRY) Then
SQLExec("Insert into SYSADM.ps_mmc_nf_alt_hdr(BUSINESS_UNIT, NF_BRL_ID, SE
Q_NBR, OPRID, DT_TIMESTAMP,DESCR254, RECNAME, FIELDNAME, OLDVALUE, NEWVALUE, NF_
BRL_LINE_NUM) values (:1,:2,:3,:4,SYSDATE,:5,'NF_LN_BRL','IPITAX_BRL_RCVRY',:6,:
7,:8)", BUSINESS_UNIT, NF_BRL_ID, &SEQUENCIA, %UserId, MMC_NF_ALT_WRK.DESCR254,
NF_LN_BRL.IPITAX_BRL_RCVRY.OriginalValue, IPITAX_BRL_RCVRY, NF_BRL_LINE_NUM);
End-If;
If FieldChanged(PIS_AMT_BBL) Then
SQLExec("Insert into SYSADM.ps_mmc_nf_alt_hdr(BUSINESS_UNIT, NF_BRL_ID, SE
Q_NBR, OPRID, DT_TIMESTAMP,DESCR254, RECNAME, FIELDNAME, OLDVALUE, NEWVALUE, NF_
BRL_LINE_NUM) values (:1,:2,:3,:4,SYSDATE,:5,'NF_LN_BRL','PIS_AMT_BBL',:6,:7,:8)
", BUSINESS_UNIT, NF_BRL_ID, &SEQUENCIA, %UserId, MMC_NF_ALT_WRK.DESCR254, NF_LN
_BRL.PIS_AMT_BBL.OriginalValue, PIS_AMT_BBL, NF_BRL_LINE_NUM);
End-If;
If FieldChanged(COFINS_AMT_BBL) Then
SQLExec("Insert into SYSADM.ps_mmc_nf_alt_hdr(BUSINESS_UNIT, NF_BRL_ID, SE
Q_NBR, OPRID, DT_TIMESTAMP,DESCR254, RECNAME, FIELDNAME, OLDVALUE, NEWVALUE, NF_
If FieldChanged(PIS_PCT_BBL) Then
SQLExec("Insert into SYSADM.ps_mmc_nf_alt_hdr(BUSINESS_UNIT, NF_BRL_ID, SE
Q_NBR, OPRID, DT_TIMESTAMP,DESCR254, RECNAME, FIELDNAME, OLDVALUE, NEWVALUE, NF_
BRL_LINE_NUM) values (:1,:2,:3,:4,SYSDATE,:5,'NF_LN_BRL','PIS_PCT_BBL',:6,:7,:8)
", BUSINESS_UNIT, NF_BRL_ID, &SEQUENCIA, %UserId, MMC_NF_ALT_WRK.DESCR254, NF_LN
_BRL.PIS_PCT_BBL.OriginalValue, PIS_PCT_BBL, NF_BRL_LINE_NUM);
End-If;
If FieldChanged(PIS_BSS_AMT_BBL) Then
SQLExec("Insert into SYSADM.ps_mmc_nf_alt_hdr(BUSINESS_UNIT, NF_BRL_ID, SE
Q_NBR, OPRID, DT_TIMESTAMP,DESCR254, RECNAME, FIELDNAME, OLDVALUE, NEWVALUE, NF_
BRL_LINE_NUM) values (:1,:2,:3,:4,SYSDATE,:5,'NF_LN_BRL','PIS_BSS_AMT_BBL',:6,:7
,:8)", BUSINESS_UNIT, NF_BRL_ID, &SEQUENCIA, %UserId, MMC_NF_ALT_WRK.DESCR254, N
F_LN_BRL.PIS_BSS_AMT_BBL.OriginalValue, PIS_BSS_AMT_BBL, NF_BRL_LINE_NUM);
End-If;
If FieldChanged(PISTAX_BRL_AMT) Then
SQLExec("Insert into SYSADM.ps_mmc_nf_alt_hdr(BUSINESS_UNIT, NF_BRL_ID, SE
Q_NBR, OPRID, DT_TIMESTAMP,DESCR254, RECNAME, FIELDNAME, OLDVALUE, NEWVALUE, NF_
BRL_LINE_NUM) values (:1,:2,:3,:4,SYSDATE,:5,'NF_LN_BRL','PISTAX_BRL_AMT',:6,:7,
:8)", BUSINESS_UNIT, NF_BRL_ID, &SEQUENCIA, %UserId, MMC_NF_ALT_WRK.DESCR254, NF
_LN_BRL.PISTAX_BRL_AMT.OriginalValue, PISTAX_BRL_AMT, NF_BRL_LINE_NUM);
End-If;
If FieldChanged(ICMSTAX_BRL_PCT) Then
SQLExec("Insert into SYSADM.ps_mmc_nf_alt_hdr(BUSINESS_UNIT, NF_BRL_ID, SE
Q_NBR, OPRID, DT_TIMESTAMP,DESCR254, RECNAME, FIELDNAME, OLDVALUE, NEWVALUE, NF_
BRL_LINE_NUM) values (:1,:2,:3,:4,SYSDATE,:5,'NF_LN_BRL','ICMSTAX_BRL_PCT',:6,:7
,:8)", BUSINESS_UNIT, NF_BRL_ID, &SEQUENCIA, %UserId, MMC_NF_ALT_WRK.DESCR254, N
F_LN_BRL.ICMSTAX_BRL_PCT.OriginalValue, ICMSTAX_BRL_PCT, NF_BRL_LINE_NUM);
End-If;
If FieldChanged(ICMSTAX_BRL_AMT) Then
SQLExec("Insert into SYSADM.ps_mmc_nf_alt_hdr(BUSINESS_UNIT, NF_BRL_ID, SE
Q_NBR, OPRID, DT_TIMESTAMP,DESCR254, RECNAME, FIELDNAME, OLDVALUE, NEWVALUE, NF_
BRL_LINE_NUM) values (:1,:2,:3,:4,SYSDATE,:5,'NF_LN_BRL','ICMSTAX_BRL_AMT',:6,:7
,:8)", BUSINESS_UNIT, NF_BRL_ID, &SEQUENCIA, %UserId, MMC_NF_ALT_WRK.DESCR254, N
F_LN_BRL.ICMSTAX_BRL_AMT.OriginalValue, ICMSTAX_BRL_AMT, NF_BRL_LINE_NUM);
End-If;
If FieldChanged(ICMSTAX_BRL_BSS) Then
SQLExec("Insert into SYSADM.ps_mmc_nf_alt_hdr(BUSINESS_UNIT, NF_BRL_ID, SE
Q_NBR, OPRID, DT_TIMESTAMP,DESCR254, RECNAME, FIELDNAME, OLDVALUE, NEWVALUE, NF_
BRL_LINE_NUM) values (:1,:2,:3,:4,SYSDATE,:5,'NF_LN_BRL','ICMSTAX_BRL_BSS',:6,:7
,:8)", BUSINESS_UNIT, NF_BRL_ID, &SEQUENCIA, %UserId, MMC_NF_ALT_WRK.DESCR254, N
F_LN_BRL.ICMSTAX_BRL_BSS.OriginalValue, ICMSTAX_BRL_BSS, NF_BRL_LINE_NUM);
End-If;
If FieldChanged(ICMSSUB_BRL_AMT) Then
SQLExec("Insert into SYSADM.ps_mmc_nf_alt_hdr(BUSINESS_UNIT, NF_BRL_ID, SE
Q_NBR, OPRID, DT_TIMESTAMP,DESCR254, RECNAME, FIELDNAME, OLDVALUE, NEWVALUE, NF_
BRL_LINE_NUM) values (:1,:2,:3,:4,SYSDATE,:5,'NF_LN_BRL','ICMSSUB_BRL_AMT',:6,:7
,:8)", BUSINESS_UNIT, NF_BRL_ID, &SEQUENCIA, %UserId, MMC_NF_ALT_WRK.DESCR254, N
[NF_LN_BRL.NF_BRL_LINE_NUM.RowDelete]
/* BRLOC PM 23/JUL/97 - NF Total Lines */
If NF_HDR_BRL.NF_BRL_STATUS = "V" Then
Error MsgGet(30000, 194, "You cannot delete a NF line if the NF has been vouc
hered.");
End-If;
&ROWS = NF_HDR_BRL.NF_BRL_TTL_LINES;
If &ROWS <> 0 Then
&ROWS = &ROWS - 1;
End-If;
NF_HDR_BRL.NF_BRL_TTL_LINES = &ROWS;
[NF_LN_BRL.NF_BRL_LINE_NUM.RowInsert]
/*******************************************************************************
****
* Vincius Alves Mello - MMC - 28/07/2010 - mmcb.hd97139
*
* Erro ao inserir uma nova linha na NF de devoluo, onde o sistema no esta
* pegando a ltima linha da NF
*
********************************************************************************
****/
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 07/06/2006 - Inicio */
Global boolean &MMC_ENTRAPOR_ITEM, &MMC_ENTRAPOR_PACABADO, &MMC_ENTRAPOR_PACABAD
ONF, &MMC_ENTRAPOR_TRIANGULACAO;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 07/06/2006 - Fim */
If NF_HDR_BRL.NF_BRL_STATUS = "V" Then
Error MsgGet(30000, 195, "You cannot add a NF line if the NF has been voucher
ed.");
End-If;
/* BRLOC PM 23/JUL/97 - NF Lines auto numbering */
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 07/06/2006 - Inicio */
If %Component = Component.NF_INFO_PBL And
(&MMC_ENTRAPOR_ITEM = True Or
&MMC_ENTRAPOR_PACABADO = True Or
&MMC_ENTRAPOR_PACABADONF = True Or
&MMC_ENTRAPOR_TRIANGULACAO = True) Then
NF_HDR_BRL.MAX_LINE = GetLevel0().GetRow(1).GetRowset(Scroll.NF_LN_BRL).Activ
eRowCount - 1;
End-If;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 07/06/2006 - Fim */
/************************** mmcb.hd97139.sn **************************/
&QTY_LINHAS = ActiveRowCount(NF_BRL_LINE_NUM) - 1;
If NF_HDR_BRL.MAX_LINE <> &QTY_LINHAS Or
NF_HDR_BRL.NF_BRL_TTL_LINES <> &QTY_LINHAS Then
NF_HDR_BRL.MAX_LINE = &QTY_LINHAS;
NF_HDR_BRL.NF_BRL_TTL_LINES = &QTY_LINHAS;
End-If;
/************************** mmcb.hd97139.en **************************/
NF_BRL_LINE_NUM = NF_HDR_BRL.MAX_LINE + 1;
NF_HDR_BRL.MAX_LINE = NF_HDR_BRL.MAX_LINE + 1;
NF_HDR_BRL.NF_BRL_TTL_LINES = NF_HDR_BRL.NF_BRL_TTL_LINES + 1;
[NF_LN_BRL.OTHEREXP_BRL_AMT.FieldChange]
/*******************************************************************************
*******
* Vinicius Montijo Favero - MMC - 11/03/2015 - mmcb.sds5100
*
* Ajuste de Dados Incorretos no Registro ou Faturamento
*
********************************************************************************
*******/
Declare Function Calc_Other_Exp_Amt PeopleCode FUNCLIB_PBL.EXP_PRORATE_PBL Field
Formula;
If %Component <> "MMC_NF_ALTERA" Then /*mmcb.sds5100 l.n*/
/*BRLOC-PO-APP-8.00-02/04/01-BEGIN */
If NF_HDR_BRL.OTHER_PRORATE_PBL = "A" Then
Calc_Other_Exp_Amt();
End-If;
/*BRLOC-PO-APP-8.00-02/04/01-END */
End-If; /*mmcb.sds5100 l.n*/
[NF_LN_BRL.PISTAX_BRL_AMT.SaveEdit]
/*******************************************************************************
***
* Claudio Henrique da Costa - MMCB - 16/08/2006 - mmcb.hd24104
*
* Customizacao para que seja verificado se existe PIS e COFINS para o tipo de
*
* Finalidade.
*
*******************************************************************************
***/
/*******************************************************************************
***
* Claudio Henrique da Costa - MMCB - 10/12/2009 - mmcb.sds3239
*
* Projeto Implantao People - Multi Empresa MMCB-SVB.
*
*******************************************************************************
***/
/*******************************************************************************
*******
* Vinicius Montijo Favero - MMC - 11/03/2015 - mmcb.sds5100
*
* Ajuste de Dados Incorretos no Registro ou Faturamento
*
********************************************************************************
*******/
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange; /* mmc
b.sds3239.ln */
&SETID = BUSCA_SETID(); /* mmcb.sds3239.ln */
REM IPI ;
SQLExec("SELECT 'X' FROM PS_EXC_RCRT_PBL
L = 'CIPI' AND CRITERIA_ID_PBL = 'FINO' AND
_BRL, &RET_IPI);
If &RET_IPI = "X" Then
IPITAX_BRL_RCVRY = IPITAX_BRL_AMT;
Else
IPITAX_BRL_RCVRY = 0;
End-If;
REM PIS ;
SQLExec("SELECT 'X' FROM PS_EXC_RCRT_PBL
L = 'CPIS' AND CRITERIA_ID_PBL = 'FINO' AND
_BRL, &RET_PIS);
If &RET_PIS = "X" Then
PIS_AMT_BBL = PISTAX_BRL_AMT;
Else
PIS_AMT_BBL = 0;
End-If;
REM COFINS ;
SQLExec("SELECT 'X' FROM PS_EXC_RCRT_PBL WHERE SETID = 'MMCSA' AND RULE_ID_PB
L = 'CCOFI' AND CRITERIA_ID_PBL = 'FINO' AND CRITERIA_VALUE_PBL = :1", PURCH_PRO
P_BRL, &RET_COFI);
If &RET_COFI = "X" Then
COFINS_AMT_BBL = COFINSTAX_BRL_AMT;
Else
COFINS_AMT_BBL = 0;
End-If;
End-If;
/*** JEISON CALDAS - Atualiza valor do imposto a recuperar - Final - 02/05/06 **
*/
[NF_LN_BRL.PURCH_PROP_BRL.SavePostChange]
/*******************************************************************************
******
* Vincius Alves Mello - MMCB - 23/11/2010 - mmcb.sds3686
*
* Atualizar MMC_ASSET_LOC, quando um ativo for movimentado
*
********************************************************************************
*****/
/*******************************************************************************
******
* Vincius Alves Mello - MMC - mmcb.sds164807 - 22/02/2013
*
* O campo DOCUMENT_ID da tabela PS_ASSET_LOCATION so aceita 12 caracteres e tem
*
* casos onde o nmero da nota mais a sria e maior que este campo.
*
********************************************************************************
*****/
/************************************************************************
* Wagner Sorio - MMCB - 01/09/2014 - mmcb.sds4689
*
* Implantao do People DBME
*
*************************************************************************/
/* Declare Function BU_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange; */ /*
mmcb.sds4689.lo */
/*** JC800888 Jeison Caldas - 26.11.09 - SDS 3085 - Controle Transferncia de Ativ
o - Acrescentada linha de histrico - Inicio ***/
If %Component = Component.NF_INFO_PBL And
NF_HDR_INFO_WRK.NF_BRL_STATUS = "F" Then
REM VERIFICO SE ITEM DE ATIVO E SE ESTAVA CONTROLADO NA EMISSO DE NOTAS;
SQLExec("SELECT B.MMC_TIPO_TRANSF_AM, C.ASSET_ID, C.BUSINESS_UNIT FROM SYSADM
.PS_MMC_NFD_LINE A, SYSADM.PS_MMC_ATIVO_OFISC B, SYSADM.PS_MMC_FAT_ITM_ATI C WH
ERE A.BUSINESS_UNIT = :1 AND A.NF_BRL_ID
= :2 AND A.NF_BRL_LINE_NUM = :3 AND
A.TOF_PBL = B.TOF_PBL AND B.EFFDT = (SELECT MAX(BM.EFFDT) FROM SYSADM.PS_MMC_
ATIVO_OFISC BM WHERE B.TOF_PBL = BM.TOF_PBL) AND B.MMC_MOVIMENT_ATIVO = 'Y' AND
A.MMC_UN_ORIGEM = C.BUSINESS_UNIT AND A.MMC_NF_ID_ORIGEM = C.NF_BRL_ID AND A.MMC
_NF_LINE_ORIGEM = C.NF_BRL_LINE_NUM", BUSINESS_UNIT, NF_BRL_ID, NF_BRL_LINE_NUM,
&TIPO_TRANS, &ASSET_ID, &BU_FAT);
REM FAZ EXTORNO DO LANAMENTO POR TIPO DE TRANSAO;
If All(&ASSET_ID) Then
/* &BU = BU_SETID("COCT1"); */ /*mmcb.sds4689.lo*/
/************************** mmcb.sds4689.sn **************************/
SQLExec("SELECT BUSINESS_UNIT_GL FROM SYSADM.PS_BUS_UNIT_TBL_PM WHERE BUSI
NESS_UNIT = :1 ", BUSINESS_UNIT, &BU);
/************************** mmcb.sds4689.en **************************/
&DATA = NF_HDR_BRL.ACCOUNTING_DT;
&OPRID = %OperatorId;
&NF_BRL = NF_HDR_BRL.NF_BRL | "-" | NF_HDR_BRL.NF_BRL_SERIES;
&LOCATION = NF_HDR_BRL.EF_LOC_BRL;
/************************* mmcb.hd164807.sn *************************/
If Len(&NF_BRL) > 12 Then
&NUM_NF_BRL = Value(NF_HDR_BRL.NF_BRL);
&NF_BRL = Substring((String(&NUM_NF_BRL) | "-" | NF_HDR_BRL.NF_BRL_SERI
ES), 1, 12);
End-If;
/************************* mmcb.hd164807.en *************************/
If None(&LOCATION) Then
SQLExec("SELECT A.LOCATION, A.BUSINESS_UNIT_GL FROM PS_BUS_UNIT_TBL_BI
A WHERE A.BUSINESS_UNIT = :1", &BU_FAT, &LOCATION, &BU);
End-If;
REM MOVIMENTAO NAS TABELAS DO ATIVO;
REM VERIFICA SE NOTA ESTA SENDO SALVA PELA SEGUNDA VEZ E J EXISTE LANAMENTO;
SQLExec("SELECT 'Y' FROM SYSADM.PS_ASSET_LOCATION WHERE BUSINESS_UNIT = :1
AND ASSET_ID = :2 AND EFFDT = %datein(:3) AND LOCATION = :4", &BU, &ASSET_ID, &
DATA, &LOCATION, &LCTO_EXISTE);
If &LCTO_EXISTE <> "Y" Then
SQLExec("SELECT MAX(EFFSEQ + 1) FROM PS_ASSET_LOCATION WHERE BUSINESS_U
NIT = :1 AND ASSET_ID = :2", &BU, &ASSET_ID, &EFFSEQ);
SQLExec("INSERT INTO PS_ASSET_LOCATION (BUSINESS_UNIT, ASSET_ID, EFFDT,
EFFSEQ, LOCATION, DOCUMENT_ID, AUTH_STATUS, AUTHORIZATION_NAME) VALUES(:1,:2, %
End-If;
End-If;
End-If;
End-If;
/*** JC800888 Jeison Caldas - 26.11.09 - SDS 3085 - Controle Transferncia de Ativ
o - Acrescentada linha de histrico - Fim ***/
[NF_LN_BRL.QTY_NF_BRL.FieldChange]
Declare Function ATUALIZA_DISTRIB PeopleCode UNIT_PRICE FieldChange;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 02/05/2006 - Inicio
Variveis utilizadas para controle de criao ou no de Ordem de Produo */
Declare Function Hab_Desab_Vinc_OC PeopleCode CFOP_INCOM_PBL FieldFormula;
Global boolean &MMC_ENTRAPOR_ITEM, &MMC_ENTRAPOR_PACABADO, &MMC_ENTRAPOR_PACABAD
ONF, &MMC_ENTRAPOR_TRIANGULACAO, &MMC_Controle_Terceiros, &MMC_CT_GERAOP;
Component number &OldQtyNFBrl;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 02/05/2006 - Fim */
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 20/06/2006 - Inicio
Ao alterar Quantidade ou Cdigo de Item, ou inserir ou excluir Item, ser desvincula
do de OP */
Declare Function LimpaVincOP PeopleCode MMC_TERC_WRK.BUSINESS_UNIT_IN FieldFormu
la;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 20/06/2006 - Fim */
/*** BRLOC-PO-AO-24/04/2002 - ICE Resolution 100957 - Alterado de MERCHANDISE_AM
T para MERCH_ORIG_AMT_PBL **/
/* BRLOC-PO-APP-8.00-15/12/00-BEGIN*/
/*- Amount based on qty and unit price */
If All(QTY_NF_BRL) And
All(UNIT_PRICE) Then
MERCH_ORIG_AMT_PBL = RoundCurrency(QTY_NF_BRL * UNIT_PRICE, NF_HDR_BRL.BASE_C
URRENCY, NF_HDR_BRL.NF_BRL_DATE);
ATUALIZA_DISTRIB();
End-If;
/* BRLOC-PO-APP-8.00-15/12/00-END*/
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 02/05/2006 - Inicio
Ao alterar a quantidade do Item, verificado se o usurio quer realmente alterar ta
l informao. Se isso for confirmado, a varivel que indica que a pgina adveio de Contr
ole de Terceiros - Produto Acabado ou Produto Acabado-NF Servio passar a ser falsa
. Seno, volta para o valor antigo (que foi guardado em FieldEdit) */
If %Page = Page.NF_INFO_LN_PBL And
%Component = Component.NF_INFO_PBL Then
If &MMC_Controle_Terceiros And
&MMC_CT_GERAOP Then
If NF_LN_BRL.QTY_NF_BRL.IsChanged Then
&Resposta = WinMessage(MsgGet(9999, 99, "Essa NF de Retorno no gerar Orde
m de Produo. Deseja Continuar?"), 4, "Advertncia");
If &Resposta = %MsgResult_Yes Then
&MMC_CT_GERAOP = False;
Hab_Desab_Vinc_OC();
LimpaVincOP();
Else
QTY_NF_BRL = &OldQtyNFBrl;
End-If;
End-If;
End-If;
End-If;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 02/05/2006 - Fim */
[NF_LN_BRL.QTY_NF_BRL.FieldEdit]
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 02/05/2006 - Inicio
Variveis utilizadas para controle de criao ou no de Ordem de Produo */
Global boolean &MMC_ENTRAPOR_ITEM, &MMC_ENTRAPOR_PACABADO, &MMC_ENTRAPOR_PACABAD
ONF, &MMC_ENTRAPOR_TRIANGULACAO, &MMC_Controle_Terceiros;
Component number &OldQtyNFBrl;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 02/05/2006 - Fim */
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 02/05/2006 - Inicio
Ao alterar a quantidade do Item, guardado o valor antigo, para verificar se o
usurio quer realmente alterar tal informao. Se isso for confirmado no evento Field
Change, a varivel que indica que a pgina adveio de Controle de Terceiros - Produto
Acabado ou Produto Acabado-NF Servio passar a ser falsa */
If %Page = Page.NF_INFO_LN_PBL Then
If &MMC_Controle_Terceiros And
(&MMC_ENTRAPOR_PACABADO Or
&MMC_ENTRAPOR_PACABADONF) Then
&OldQtyNFBrl = Value(LTrim(RTrim(Substitute(NF_LN_BRL.QTY_NF_BRL.Formatted
Value, ",", "."))));
End-If;
End-If;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 02/05/2006 - Fim */
[NF_LN_BRL.QTY_NF_BRL.RowInit]
/*** JEISON CALDAS - 12/11/2005 - CUSTOMIZAO PARA PERMITIR ALTERAO DE QUANTIDADE DE
UM RECEBIMENTO COM ORIGEM NO RECEBIMENTO FISICO - INICIO ***/
If %Component = "NF_RECV_PBL" Then
Gray(QTY_NF_BRL);
End-If;
/*** JEISON CALDAS - 12/11/2005 - CUSTOMIZAO PARA PERMITIR ALTERAO DE QUANTIDADE DE
UM RECEBIMENTO COM ORIGEM NO RECEBIMENTO FISICO - FIM ***/
[NF_LN_BRL.SHIPTO_ID.SavePostChange]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 29/02/2008- mmcb.at2323 - Sistema Contro
le Terceiros
*
* No deixar salvar local de entrega em branco para recebimento terceiros.
*****************************************************************************
*******************/
/********************** mmcb.at2323.sn **********************/
If %Component = "NF_INFO_PBL" And
MMC_TE_NFLN_WRK.MMC_TERCEIRO_FLG = "Y" And
NF_HDR_BRL.NF_BRL_STATUS = "F" Then
SQLExec("UPDATE SYSADM.PS_NF_LN_BRL SET SHIPTO_ID=:1 WHERE BUSINESS_UNIT=:2 A
ND NF_BRL_ID=:3 AND NF_BRL_LINE_NUM=:4 ", NF_HDR_BRL.SHIPTO_ID, BUSINESS_UNIT, N
F_BRL_ID, NF_BRL_LINE_NUM);
End-If;
/********************** mmcb.at2323.en **********************/
[NF_LN_BRL.TAX_CLASS_BRL.FieldChange]
/*******************************************************************************
***
* Claudio Henrique da Costa - MMCB - 22/01/2010 - mmcb.sds3239
*
* Projeto Implantao People - Multi Empresa MMCB-SVB.
*
*******************************************************************************
***/
/*******************************************************************************
***
* Filipe/Rosangela Enc. Rafael Taveira - MMCB - 07/08/2013 - mmcb.hd180299
*
* Comentario campos da PO_LINE pois no existe referencia na tela, ocasionando er
ro*
*******************************************************************************
***/
/*******************************************************************************
****
* Wagner Sorio - MMCB - 05/06/2014 - mmcb.sds4689
*
* Implantao do People DBME
*
********************************************************************************
****/
/*******************************************************************************
****
* Vinicius Montijo Favero - MMC - 11/03/2015 - mmcb.sds5100
*
* Ajuste de Dados Incorretos no Registro ou Faturamento
*
********************************************************************************
****/
/****************************************** mmcb.sds4689.sn ********************
**********************/
Function BUSCA_WTHD_CD_ANT_LEI(&PAR_SETID, &PAR_TAX_CLASS_BRL, &PAR_BUSINESS_UNI
T_PO) Returns string
&SQL = "
SELECT F.WTHD_CD
";
FROM PS_MMC_NCM_ANT_LEI E,
";
PS_MMC_NCM_ANT_HDR F
";
WHERE E.SETID = :1
";
";
&SQL = &SQL | "
AND F.BUSINESS_UNIT_PO = :3
";
********************************************************************************
***********************/
/*******************************************************************************
*
* Leandro Rodrigues da Silva Souza - MMCB - 29/03/2012 - SDS4156
*
* Alterao para considerar a data efetiva prevista para o cadastro de NCM
*******************************************************************************
*/
/*******************************************************************************
*
* Wagner Sorio - MMCB - 06/07/2012 - mmcb.sds4207
*
* Adequao dos sistemas para incorporao PEA SVB.
*
*******************************************************************************
*/
/*******************************************************************************
****
* Wagner Sorio - MMCB - 05/06/2014 - mmcb.sds4689
*
* Implantao do People DBME
*
********************************************************************************
****/
Declare Function MMC_BUSINESS_UNIT PeopleCode MMC_BUS_UNIT.BUSINESS_UNIT SavePos
tChange; /* mmcb.sds4207.ln */
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange; /* mmc
b.sds3239.ln */
Declare Function BUSCA_WTHD_CD_ANT_LEI PeopleCode TAX_CLASS_BRL FieldChange; /*
mmcb.sds4689.ln */
&SETID = BUSCA_SETID(); /* mmcb.sds3239.ln */
If ((%Component = Component.NF_INFO_PBL Or
%Component = Component.NF_RECV_PBL) And
/********************** mmcb.sds3239.sn **********************/
(BUSINESS_UNIT <> MMC_BUSINESS_UNIT("POINDI", BUSINESS_UNIT) And
BUSINESS_UNIT <> MMC_BUSINESS_UNIT("POCET", BUSINESS_UNIT) And
BUSINESS_UNIT <> MMC_BUSINESS_UNIT("POMKT", BUSINESS_UNIT))) Then
/********************** mmcb.sds3239.en **********************/
SQLExec("SELECT IT.TAX_CLASS_BRL FROM SYSADM.PS_INV_ITEMS IT WHERE IT.SETID =
:1 AND IT.INV_ITEM_ID = :2 AND IT.EFFDT = (SELECT MAX(EFFDT) FROM SYSADM.PS_INV
_ITEMS ITI WHERE ITI.SETID = IT.SETID AND ITI.INV_ITEM_ID = IT.INV_ITEM_ID AND I
TI.EFFDT <=SYSDATE)", &SETID, INV_ITEM_ID, &TAX_ATUAL); /* mmcb.SDS4156.ln */
If All(&TAX_ATUAL) Then
TAX_CLASS_BRL = &TAX_ATUAL;
SQLExec("SELECT PS.BUSINESS_UNIT, PS.PO_ID, PS.LINE_NBR, PS.SCHED_NBR, PS.
TAX_CLASS_BRL FROM SYSADM.PS_RECV_LN_DISTRIB RD, SYSADM.PS_PO_LINE_SHIP PS WHERE
RD.BUSINESS_UNIT = :1 AND RD.RECEIVER_ID = :2 AND RD.RECV_LN_NBR = :3 AND RD.R
ECV_SHIP_SEQ_NBR = :4 AND RD.BUSINESS_UNIT_PO = PS.BUSINESS_UNIT AND RD.PO_ID =
PS.PO_ID AND RD.LINE_NBR = PS.LINE_NBR AND RD.SCHED_NBR = PS.SCHED_NBR", BUSINE
SS_UNIT, RECEIVER_ID, NF_BRL_LINE_NUM, RECV_SHIP_SEQ_NBR, &PO_BU, &PO_ID, &PO_LI
NE, &PO_SCHED, &PO_TAX);
SQLExec("UPDATE SYSADM.PS_PO_LINE_SHIP PS SET PS.TAX_CLASS_BRL = :1 WHERE
PS.BUSINESS_UNIT = :2 AND PS.PO_ID = :3 AND PS.LINE_NBR = :4 AND PS.SCHED_NBR =
:5", &TAX_ATUAL, &PO_BU, &PO_ID, &PO_LINE, &PO_SCHED);
/*--------------------------------------------------------------------------------------------*/
/******************************************* mmcb.sds4689.so *************
******************************/
/* SQLExec("SELECT F.WTHD_CD from ps_mmc_ncm_ant_lei E, PS_MMC_NCM_ANT_HDR
F where E.SETID = :1 AND E.SETID = F.SETID AND SUBSTR(E.MMC_PREFIXO_NCM,1,LENGT
H(RTRIM(E.MMC_PREFIXO_NCM))) = SUBSTR(:2,1, LENGTH(RTRIM(E.MMC_PREFIXO_NCM))) AN
D SUBSTR(:2,1, 4) NOT IN ('4011', '4013') ", &SETID, &TAX_ATUAL, &WTHD_CD); */
/******************************************* mmcb.sds4689.eo *************
******************************/
/***************************************** mmcb.sds4689.sn ***************
**************************/
If None(BUSINESS_UNIT) Then
Error ("Erro: No foi possivel encontrar unidade de Negocio para buscar o
NCM Antecipao da Lei");
End-If;
&WTHD_CD = BUSCA_WTHD_CD_ANT_LEI(&SETID, &TAX_ATUAL, BUSINESS_UNIT);
/***************************************** mmcb.sds4689.en ***************
**************************/
If None(&WTHD_CD) Then
&WTHD_CD = " ";
End-If;
WTHD_CD = &WTHD_CD;
SQLExec("UPDATE SYSADM.PS_PO_LINE PS SET PS.WTHD_CD = :1 WHERE PS.BUSINESS
_UNIT = :2 AND PS.PO_ID = :3 AND PS.LINE_NBR = :4 ", &WTHD_CD, &PO_BU, &PO_ID, &
PO_LINE);
End-If;
/*******************************************************************************
***
* Claudio Henrique da Costa - MMCB - 08/01/2010 - mmcb.sds3239
*
* Projeto Implantao People - Multi Empresa MMCB-SVB.
*
*******************************************************************************
***/
/************************************************************************
* Itamar Junior - MMCB - mmcb.hd75050 - 28/09/2009
* Adicionando novo local de destino fixo no programa.
************************************************************************/
Declare Function TofTxtHdr PeopleCode RECV_HD_WRK_PBL.REFRESH_TXT_PB_PBL FieldCh
ange;
Declare Function ATUALIZA_DISTRIB PeopleCode UNIT_PRICE FieldChange;
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange; /* mmc
b.sds3239.ln */
/* BRLPO - HAT - 8.01 - 05/07/01 - Popula FLOW_STATUS_PBL, verifica se os TOFs so
iguais para mover para a work da header e grava os textos legais, atualiza NF_H
DR_BRL.VOUCHER_FLOW_PBL e NF_HDR_BRL.ACCOUNT_FLOW_PBL */
Global boolean &MMC_ENTRAPOR_PACABADO, &MMC_ENTRAPOR_PACABADONF;
Global Rowset &MMC_LinhaNF_LinhasOC; /* FABIO - 21/06/2006 */
Local Rowset &MMC_TERC_OC_RS;
&SETID = BUSCA_SETID(); /* mmcb.sds3239.ln */
If %Component = Component.NF_RECV_PBL Or
%Component = Component.NF_INFO_PBL Then
NF_HDR_BRL.ACCOUNT_FLOW_PBL = "N";
NF_HDR_BRL.VOUCHER_FLOW_PBL = "N";
FLOW_STATUS_PBL = TOF_TYPE_PBL.FLOW_STATUS_PBL;
&LN_MAXROW = ActiveRowCount(Scroll.NF_LN_BRL);
&TOF_EQ = "==";
For &LN_ROW = 1 To &LN_MAXROW
&TOF_CUR = FetchValue(TOF_PBL, &LN_ROW);
If &LN_ROW = 1 Then
&TOF_ANT = &TOF_CUR;
End-If;
If &TOF_ANT <> &TOF_CUR Then
&TOF_EQ = "<>";
End-If;
/* atualiza VOUCHER_FLOW_PBL E ACCOUNT_FLOW_PBL */
If FetchValue(FLOW_STATUS_PBL, &LN_ROW) = "V" Then
NF_HDR_BRL.VOUCHER_FLOW_PBL = "V";
End-If;
If FetchValue(FLOW_STATUS_PBL, &LN_ROW) = "A" Then
NF_HDR_BRL.ACCOUNT_FLOW_PBL = "A";
End-If;
End-For;
If &TOF_EQ = "<>" Then
NF_HDR_INFO_WRK.TOF_PBL = "
NF_HDR_INFO_WRK.DESCR = "
";
";
Else
NF_HDR_INFO_WRK.TOF_PBL = &TOF_CUR;
NF_HDR_INFO_WRK.DESCR = TOF_TYPE_PBL.DESCRSHORT;
End-If;
TofTxtHdr();
End-If;
/*BRLPO - HAT - 8.01 - 05/07/01 - END */
/*** JEISON CALDAS - 13/10/05 - Migrao da verso 7 para verso da customizao que altera
campos baseado na operao fiscal - Inicio ***/
/* Gustavo adequacao para nota de debito or %component = component.mmc_lanc_gar_
nd */
If (%Component = Component.NF_RECV_PBL Or
%Component = Component.NF_INFO_PBL Or
%Component = Component.MMC_LANC_GAR Or
%Component = Component.MMC_LANC_GAR_ND) And
All(TOF_PBL) Then
REM ATUALIZA DEFINIO DOS CAMPOS DE ICMS E IPI;
IPITAX_STS_BBL = "";
ICMSTAX_STS_BBL = "";
SQLExec("SELECT IPITAX_STS_BBL, ICMSTAX_STS_BBL, PIS_TAX_STATUS_PBL, COFI_TX_
STATUS_PBL FROM PS_MMC_VINC_OF_IMP WHERE TOF_PBL = :1", TOF_PBL, IPITAX_STS_BBL,
ICMSTAX_STS_BBL, PIS_TAX_STATUS_PBL, COFI_TX_STATUS_PBL);
/* mmcb.at2117.sn */
SQLExec("SELECT IPITAX_STS_BBL, ICMSTAX_STS_BBL FROM SYSADM.PS_MMC_VINC_OF_IM
P WHERE TOF_PBL = :1", TOF_PBL, &PARAMETRO_IPI, &PARAMETRO_ICMS);
If ICMSTAX_BRL_PCT = 0 And
None(&PARAMETRO_ICMS) Then
ICMSTAX_STS_BBL = "OUTR"
End-If;
If IPITAX_BRL_PCT = 0 And
None(&PARAMETRO_IPI) Then
IPITAX_STS_BBL = "OUTR"
End-If; /* mmcb.at2117.en */
REM SINALIZA SE OF VAI OU NO GERAR VOUCHER;
SQLExec("SELECT A.TOF_VOUCHER_PBL FROM PS_TOF_TYPE_PBL A WHERE A.TOF_PBL = :1
AND A.EFFDT = (SELECT MAX(A_ED.EFFDT) FROM PS_TOF_TYPE_PBL A_ED WHERE A.TOF_PB
L = A_ED.TOF_PBL)", TOF_PBL, &VOUCHE);
If (&VOUCHE = "N") Then
MMC_CATALAO_WRK.MMC_MRB_VOUCHER = "NGV";
Else
MMC_CATALAO_WRK.MMC_MRB_VOUCHER = "SGV";
End-If;
REM BUSCA ESTADO E PAIS DO FORNECEDOR;
/* SQLExec("SELECT STATE, COUNTRY FROM PS_VENDOR_ADDR WHERE SETID = 'MMCSA' A
ND VENDOR_ID = :1 AND ADDRESS_SEQ_NUM = :2 AND EFF_STATUS = 'A'", NF_HDR_BRL.VEN
DOR_ID, NF_HDR_BRL.ADDRESS_SEQ_NUM, &STATE, &COUNTRY); */ /* mmcb.sds3239.lo */
SQLExec("SELECT STATE, COUNTRY FROM PS_VENDOR_ADDR WHERE SETID = :1 AND VENDO
R_ID = :2 AND ADDRESS_SEQ_NUM = :3 AND EFF_STATUS = 'A'", &SETID, NF_HDR_BRL.VEN
SP OU GO ;
"LCPTS" Or
= "LDEFS" Or
= "LINDS" Or
= "LOVIN" Or
= "LVEIN" Or
= "LVPEC" Or
= "LVVEI" Or
= "LMKTS" Or
= "LREVS" Or
= "LCPTS" Or
= "LMOGI" Or
= "SO PAULO") Then
Gray(ICMSTAX_BRL_BSS);
Gray(ICMSTAX_BRL_PCT);
Gray(ICMSTAX_BRL_RED);
Gray(ICMSTAX_BRL_AMT);
Gray(ICMSSUB_BRL_AMT);
Else
UnGray(ICMSTAX_STS_BBL);
UnGray(ICMSTAX_BRL_BSS);
UnGray(ICMSTAX_BRL_PCT);
UnGray(ICMSTAX_BRL_RED);
UnGray(ICMSTAX_BRL_AMT);
UnGray(ICMSSUB_BRL_AMT);
End-If;
End-If;
/*** JEISON CALDAS - BUSCA PARAMETRIZAO DE TABELA CUSTOMIZADA MMC_PARAMET_OFS - IN
ICIO ***/
/* Gustavo adequacao para nota de debito or %component = component.mmc_lanc_gar_
nd */
If (%Component = Component.NF_RECV_PBL Or
%Component = Component.NF_INFO_PBL Or
%Component = Component.MMC_LANC_GAR Or
%Component = Component.MMC_LANC_GAR_ND) And
All(TOF_PBL) Then
&VL_MSG_BOX = WinMessage("Deseja alterar campos baseado na Parametrizao da Oper
. Fiscal ?", 3, "Alterar campos para def. OF?");
If &VL_MSG_BOX = 6 Then
SQLExec("SELECT INV_ITEM_ID, DESCR254_MIXED, QTY_LN_RECVD_VUOM, DEPTID, CA
TEGORY_ID FROM PS_MMC_PARAMET_OFS WHERE TOF_PBL = :1 AND STATUS = 'A'", TOF_PBL,
&PITEM, &PDESCR, &PQTY, &PDEPTID, &CATEGORY);
&LN_ATIVAS = ActiveRowCount(Scroll.NF_LN_BRL);
If All(&PITEM) And
None(PO_ID) Then
/* SQLExec("SELECT INVENTORY_ITEM, UNIT_MEASURE_STD FROM PS_MASTER_ITEM
_TBL WHERE SETID = 'MMCSA' AND INV_ITEM_ID = :1", &PITEM, &ESTOQUE, &UNIT_OF_MEA
SURE); */ /* mmcb.sds3239.lo */
SQLExec("SELECT INVENTORY_ITEM, UNIT_MEASURE_STD FROM PS_MASTER_ITEM_TB
L WHERE SETID = :1 AND INV_ITEM_ID = :2", &SETID, &PITEM, &ESTOQUE, &UNIT_OF_MEA
SURE); /* mmcb.sds3239.ln */
&SETID_ITEM = GetSetId("BUSINESS_UNIT", BUSINESS_UNIT, "MASTER_ITEM_TBL
", "");
&RECNAME = "ITM_PURCH_VW";
&FIELDNAME = "BUSINESS_UNIT";
SQLExec("SELECT PRICE_LIST, DESCR254_MIXED FROM PS_PURCH_ITEM_ATTR WHER
E SETID = :1 AND INV_ITEM_ID = :2", &SETID_ITEM, &PITEM, &UNIT_PRICE, &DESCR254_
MIXED);
&ACCDFT = FetchValue(ITM_PURCH_VW.ACCOUNT, 1);
If &ESTOQUE <> "N" Then
SQLExec("select a.descr from ps_itm_purch_fs a, ps_set_cntrl_rec b w
here a.inv_item_id = :1 and b.setcntrlvalue = :2 and b.recname = :3 and b.setid
= a.setid", &PITEM, BUSINESS_UNIT, &RECNAME, &DESCR);
Else
&DESCR = "";
End-If;
For &LN = 1 To &LN_ATIVAS
UpdateValue(INV_ITEM_ID, &LN, &PITEM);
UpdateValue(DESCR, &LN, &DESCR);
UpdateValue(ITM_SETID, &LN, &SETID_ITEM);
UpdateValue(UNIT_OF_MEASURE, &LN, &UNIT_OF_MEASURE);
UpdateValue(DESCR254_MIXED, &LN, &DESCR254_MIXED);
If All(&DESCR) Then
Gray(DESCR, &LN);
End-If;
End-For;
End-If;
REM FAZ TRATAMENTO PARA CATEGORIA/CONTA;
If All(&CATEGORY) And
None(PO_ID) Then
/* SQLExec("SELECT ACCOUNT FROM PS_ITM_CAT_TBL WHERE SETID = :1 AND CAT
EGORY_ID = :2", "MMCSA", &CATEGORY, &CONTA); */ /* mmcb.sds3239.lo */
SQLExec("SELECT ACCOUNT FROM PS_ITM_CAT_TBL WHERE SETID = :1 AND CATEGO
RY_ID = :2", &SETID, &CATEGORY, &CONTA); /* mmcb.sds3239.ln */
For &LN = 1 To &LN_ATIVAS
UpdateValue(Record.NF_LN_BRL, &LN, BRL_DISTRIB_LN.ACCOUNT, 1, &CONTA
);
End-For;
End-If;
REM FAZ TRATAMENTO PARA O CAMPO DE DESCRIO;
If All(&PDESCR) And
None(PO_ID) Then
For &LN = 1 To &LN_ATIVAS
UpdateValue(DESCR, &LN, &PDESCR);
End-For;
End-If;
REM FAZ TRATAMENTO PARA O CAMPO QUANTIDADE;
If All(&PQTY) And
None(PO_ID) Then
For &LN = 1 To &LN_ATIVAS
UpdateValue(QTY_NF_BRL, &LN, &PQTY);
&PUNITP = FetchValue(UNIT_PRICE, &LN);
If All(&PUNITP) Then
&PVALUE = RoundCurrency(&PQTY * &PUNITP, NF_HDR_BRL.BASE_CURRENCY
, NF_HDR_BRL.NF_BRL_DATE);
End-If;
End-For;
ATUALIZA_DISTRIB();
End-If;
REM FAZ TRATAMENTO PARA O CAMPO DEPARTAMENTO;
If All(&PDEPTID) And
None(PO_ID) Then
For &LN = 1 To &LN_ATIVAS
UpdateValue(Record.NF_LN_BRL, &LN, BRL_DISTRIB_LN.DEPTID, 1, &PDEPTI
D);
End-For;
End-If;
End-If;
End-If;
End-If;
Else
MMC_NF_LN_WRK.BUTTONOFFLINE.Enabled = False;
MMC_NF_LN_WRK.BUTTONOFFLINE.Visible = False;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 02/06/2006 - Inicio *
/
&MMC_TERC_OC_RS = GetRowset(Scroll.MMC_CT_NFLN_TRI);
For &i2 = &MMC_TERC_OC_RS.ActiveRowCount To 1 Step - 1
&MMC_TERC_OC_RS.FlushRow(&i2);
End-For;
PO_ID = "";
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 02/06/2006 - Fim */
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 21/06/2006 - Inicio *
/
For &i2 = &MMC_LinhaNF_LinhasOC.ActiveRowCount To 1 Step - 1
If &MMC_LinhaNF_LinhasOC.GetRow(&i2).MMC_TERC_OC.SEQNUM.Value = NF_BRL_
LINE_NUM Then
&MMC_LinhaNF_LinhasOC.DeleteRow(&i2);
Break;
End-If;
End-For;
If &MMC_LinhaNF_LinhasOC.ActiveRowCount = 0 Then
&MMC_LinhaNF_LinhasOC.Flush();
End-If;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 21/06/2006 - Fim */
End-If;
End-If;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 26/04/2006 - Fim */
[NF_LN_BRL.TOF_PBL.RowInit]
/*******************************************************************************
**************/
/* MMC - ASM - 20/02/2006 - Se agrega logica para cargar el prompt table segun s
i se ingresa mediante pgina customizada o PS Standar */
/*******************************************************************************
**************/
/*********************************************************************
* Claudio Henrique da Costa - MMC - 31/08/2007 - mmcb.AT2117
*
* Alterao para que o sistema determine situao tributrias dos
*
* impostos como sendo Outras quando as alquotas forem 0 (zero).
*
*********************************************************************/
/*******************************************************************************
***
* Claudio Henrique da Costa - MMCB - 25/08/2011 - mmcb.sds3445
*
* Interface - GKO - People
*
*******************************************************************************
***/
Global boolean &MMC_Controle_Terceiros;
Component boolean &triangulacionOrig; /* Esta variable viene del PostBuild del C
omponent, con el valor original de la variable &triangulacion */
/*
If (&MMC_Controle_Terceiros = True Or
&triangulacionOrig = True) Then
DERIVED.EDITTABLE = "MMC_TOF_TYPE_VW";
Else
DERIVED.EDITTABLE = "TOF_TYPE_PBL";
End-If;
*/
/* MMC - ASM - 20/02/2006 - Se agrega logica para cargar el prompt table segun s
i se ingresa mediante pgina customizada o PS Standar - Fin */
/*******************************************************************************
**************/
/* BRLPO - HAT - 8.01 - 05/07/01 - Inicia valor Default para o TOF e FLOW_STATUS
_PBL */
If %Component = Component.NF_RECV_PBL Or
%Component = Component.NF_INFO_PBL Then
/* Sugere valor do TOF da BU */
If %Mode = "A" Then
NF_HDR_BRL.ACCOUNT_FLOW_PBL = "N";
NF_HDR_BRL.VOUCHER_FLOW_PBL = "N";
TOF_PBL = BUS_UNIT_TBL_PM.TOF_PBL;
FLOW_STATUS_PBL = TOF_TYPE_PBL.FLOW_STATUS_PBL;
If TOF_TYPE_PBL.FLOW_STATUS_PBL = "V" Then
NF_HDR_BRL.VOUCHER_FLOW_PBL = "V"
Else
If TOF_TYPE_PBL.FLOW_STATUS_PBL = "A" Then
NF_HDR_BRL.ACCOUNT_FLOW_PBL = "A"
End-If
End-If
End-If;
End-If;
/*** JEISON CALDAS - 13/10/05 - Migrao da verso 7 para verso da customizao que altera
campos baseado na operao fiscal - Inicio ***/
/* Gustavo adequacao para nota de debito or %component = component.mmc_lanc_gar_
nd */
If (%Component = Component.NF_RECV_PBL Or
%Component = Component.NF_INFO_PBL Or
%Component = Component.MMC_LANC_GAR Or
%Component = Component.MMC_LANC_GAR_ND) And
All(TOF_PBL) Then
REM ATUALIZA DEFINIO DOS CAMPOS DE ICMS E IPI;
/* mmcb.sds3445.sn */
SQLExec("SELECT 'Y' FROM SYSADM.PS_MMC_GKO_NF_IF WHERE MMC_GKO_BU_NF_FRET = :
1 AND MMC_GKO_ID_NF_FRET = :2", BUSINESS_UNIT, NF_BRL_ID, &NF_FROM_GKO);
If &NF_FROM_GKO = "Y" Then
&ICMSTAX_STS_BBL_GKO = ICMSTAX_STS_BBL;
End-If;
/* mmcb.sds3445.en */
SQLExec("SELECT IPITAX_STS_BBL, ICMSTAX_STS_BBL, PIS_TAX_STATUS_PBL, COFI_TX_
STATUS_PBL FROM PS_MMC_VINC_OF_IMP WHERE TOF_PBL = :1", TOF_PBL, IPITAX_STS_BBL,
ICMSTAX_STS_BBL, PIS_TAX_STATUS_PBL, COFI_TX_STATUS_PBL);
REM SINALIZA SE OF VAI OU NO GERAR VOUCHER;
SQLExec("SELECT A.TOF_VOUCHER_PBL FROM PS_TOF_TYPE_PBL A WHERE A.TOF_PBL = :1
UnGray(ICMSTAX_BRL_BSS);
UnGray(ICMSTAX_BRL_PCT);
UnGray(ICMSTAX_BRL_RED);
UnGray(ICMSTAX_BRL_AMT);
UnGray(ICMSSUB_BRL_AMT);
End-If;
End-If;
/*** JEISON CALDAS - 13/10/05 - Migrao da verso 7 para verso da customizao que altera
campos baseado na operao fiscal - Final ***/
[NF_LN_BRL.TOF_PBL.SavePreChange]
Declare Function TofTxtHdr PeopleCode RECV_HD_WRK_PBL.REFRESH_TXT_PB_PBL FieldCh
ange;
/* BRLPO - HAT - 8.01 - 05/07/01 - Popula FLOW_STATUS_PBL, verifica se os TOFs so
iguais para mover para a work da header e grava os textos legais, atualiza NF_H
DR_BRL.VOUCHER_FLOW_PBL e NF_HDR_BRL.ACCOUNT_FLOW_PBL */
If %Component = Component.NF_RECV_PBL Or
%Component = Component.NF_INFO_PBL Then
NF_HDR_BRL.ACCOUNT_FLOW_PBL = "N";
NF_HDR_BRL.VOUCHER_FLOW_PBL = "N";
FLOW_STATUS_PBL = TOF_TYPE_PBL.FLOW_STATUS_PBL;
&LN_MAXROW = ActiveRowCount(Scroll.NF_LN_BRL);
&TOF_EQ = "==";
For &LN_ROW = 1 To &LN_MAXROW
&TOF_CUR = FetchValue(TOF_PBL, &LN_ROW);
If &LN_ROW = 1 Then
&TOF_ANT = &TOF_CUR;
End-If;
If &TOF_ANT <> &TOF_CUR Then
&TOF_EQ = "<>";
End-If;
/* atualiza VOUCHER_FLOW_PBL E ACCOUNT_FLOW_PBL */
If FetchValue(FLOW_STATUS_PBL, &LN_ROW) = "V" Then
NF_HDR_BRL.VOUCHER_FLOW_PBL = "V";
End-If;
If FetchValue(FLOW_STATUS_PBL, &LN_ROW) = "A" Then
NF_HDR_BRL.ACCOUNT_FLOW_PBL = "A";
End-If;
End-For;
If &TOF_EQ = "<>" Then
NF_HDR_INFO_WRK.TOF_PBL
NF_HDR_INFO_WRK.DESCR =
Else
NF_HDR_INFO_WRK.TOF_PBL
NF_HDR_INFO_WRK.DESCR =
End-If;
TofTxtHdr();
End-If;
= "
"
";
";
= &TOF_CUR;
TOF_TYPE_PBL.DESCRSHORT;
If All(PO_ID) Then
&valor_antes = PriorValue(UNIT_PRICE);
SQLExec("SELECT PRICE_PO FROM PS_RECV_LN_SHIP WHERE BUSINESS_UNIT = :1 AND
RECEIVER_ID = :2 AND RECV_LN_NBR = :3 AND RECV_SHIP_SEQ_NBR = :4", BUSINESS_UNI
T, RECEIVER_ID, RECV_LN_NBR, RECV_SHIP_SEQ_NBR, &valor_antes);
If (UNIT_PRICE > &valor_antes) Then
UNIT_PRICE = &valor_antes;
WinMessage("O preco nao pode ser aumentado.");
/* mmcb.sds2895 - s.n. */
Else
If (UNIT_PRICE < &valor_antes) Then
UNIT_PRICE = &valor_antes;
WinMessage("O preco nao pode ser diminudo.");
End-If;
/* mmcb.sds2895 - e.n. */
End-If;
End-If;
End-If;
/* BRLOC-PO-APP-8.00-15/12/00-BEGIN*/
/*- Amount based on qty and unit price */
If All(QTY_NF_BRL) And
All(UNIT_PRICE) Then
MERCH_ORIG_AMT_PBL = RoundCurrency(QTY_NF_BRL * UNIT_PRICE, NF_HDR_BRL.BASE_C
URRENCY, NF_HDR_BRL.NF_BRL_DATE);
/*BRLOC-PO-APP-8.00-22/08/2001-BEGIN*/
/*Atualiza o valor de desconto */
DSCNT_AMT = RoundCurrency(DSCNT_PCT / 100 * MERCH_ORIG_AMT_PBL, BASE_CURRENCY
, %Date);
/*BRLOC-PO-APP-8.00-22/08/2001-END*/
End-If;
ATUALIZA_DISTRIB();
/* BRLOC-PO-APP-8.00-15/12/00-END*/
/*** BRLOC-PO-AO-24/04/2002 - ICE Resolution 100957 - END **/
[NF_LN_BRL.WTHD_CD.FieldChange]
/**** INICIO - AUGUSTO VILARINHO NETO - 12/11/2005 - Opo de alterar o cdigo de ret
eno para todas linhas na Entrada Direta de Documento Fiscal ****/
If (%Component = Component.NF_RECV_PBL Or
%Component = Component.NF_INFO_PBL Or
%Component = Component.MMC_LANC_GAR) Then
&LN_ATIVAS = ActiveRowCount(Scroll.NF_LN_BRL);
If &LN_ATIVAS > 1 Then
&VL_MSG_BOX = WinMessage("Deseja alterar cdigo de reteno para todas as linhas
do documento fiscal?", 3, "Alterar codigo de reteno?");
If &VL_MSG_BOX = 6 Then
For &LN = 1 To &LN_ATIVAS
UpdateValue(WTHD_CD, &LN, WTHD_CD);
End-For;
End-If; /**** FIM MENSAGEM ****/
End-If; /**** FIM LINHAS ATIVAS ****/
End-If; /**** FIM COMPONENTE ****/
/**** INICIO - AUGUSTO VILARINHO NETO - 12/11/2005 - Opo de alterar o codigo de r
eteno para todas linhas na Entrada Direta de Documento Fiscal ****/
/*** JEISON CALDAS - 12/03/07 - ATIV.2045 Cd. de Arrecadao por linha do recebimento
- Inicio ***/
If %Page = Page.NF_INFO_LN_PBL Then
ScrollFlush(Record.MMC_COD_RETL_VW);
ScrollSelect(1, Record.MMC_COD_RETL_VW, Record.MMC_COD_RETL_VW, "WHERE WTHD_C
D = :1", WTHD_CD);
End-If
/*** JEISON CALDAS - 12/03/07 - ATIV.2045 Cd. de Arrecadao por linha do recebimento
- Fim ***/
[NF_LN_BRL.WTHD_CD.RowInit]
/* BRLOC-PO-APP-8.00-26/03/01-BEGIN */
/* Description: Default code from vendor */
Declare Function do_IR_code PeopleCode FUNCLIB_BRL_NF.VENDOR_ID FieldFormula;
/* Fabiano Cunha - 29/01/2006 - Foi retirado a busca do codigo de retencao do ca
dastro do fornecedor para apenas doc fiscal direto. A pedido do Christiano Ribei
ro
If (%PanelGroup = PanelGroup.NF_INFO_PBL) Then
WTHD_CD = do_IR_code(NF_HDR_BRL.VENDOR_ID);
End-If;
*/
/*BRLOC-PO-APP-8.00-26/03/01-END*/
/*** JEISON CALDAS - 12/03/07 - ATIV.2045 Cd. de Arrecadao por linha do recebimento
- Inicio ***/
If %Component = Component.NF_INFO_PBL And
%Mode <> "A" Then
ScrollFlush(Record.MMC_COD_RETL_VW);
ScrollSelect(1, Record.MMC_COD_RETL_VW, Record.MMC_COD_RETL_VW, "WHERE WTHD_C
D = :1", WTHD_CD);
End-If;
/*** JEISON CALDAS - 12/03/07 - ATIV.2045 Cd. de Arrecadao por linha do recebimento
- Fim ***/
[NF_LN_BRL.WTHD_CD.SaveEdit]
/*****************************************************************************
* Wagner Sorio - MMC - 20/05/2008 - mmcb.hd49255
*
* Customizao parar corrigir preenchimento indevido do campo WTHD_CD
*
******************************************************************************/
/****************************************************************************
Claudio Henrique da Costa - MMC - 26/11/2008 - mmcb.sds2905
Alterao para que o sistema carrege o NCM atual da atualizao do Item.
*****************************************************************************/
/*****************************************************************************
* Wagner Sorio - MMC - 19/08/2009 - mmcb.hd72238
*
* Customizao parar corrigir preenchimento indevido do campo WTHD_CD
*
/*******************************************************************************
*
* Fabiano Cunha - MMCB - 05/11/2009
- mmcb.sds3239
*
* Projeto Implantao People - Multi Empresa MMCB-SVB.
*******************************************************************************
*/
/* Itamar Junior - MMCB - 28/09/2009 - mmcb.hd75356
*
* Inserindo a noVa unidade de negcio POMGI no preenchimento do campo WTHD_CD*
******************************************************************************/
/*******************************************************************************
*
* Wagner Sorio - MMCB - 06/07/2012 - mmcb.sds4207
*
* Adequao dos sistemas para incorporao PEA SVB.
*
*******************************************************************************
*/
/*******************************************************************************
****
* Wagner Sorio - MMCB - 05/06/2014 - mmcb.sds4689
*
* Implantao do People DBME
*
********************************************************************************
****/
Declare Function MMC_BUSINESS_UNIT PeopleCode MMC_BUS_UNIT.BUSINESS_UNIT SavePos
tChange; /* mmcb.sds4207.ln */
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange; /* mmc
b.sds3239.ln */
Declare Function BUSCA_WTHD_CD_ANT_LEI PeopleCode TAX_CLASS_BRL FieldChange; /*
mmcb.sds4689.ln */
&SETID = BUSCA_SETID(); /* mmcb.sds3239.ln */
/************************* mmcb.sds2905.sn *************************/
If ((%Component = Component.NF_INFO_PBL Or
%Component = Component.NF_RECV_PBL) And
/******************************** mmcb.sds4207.sn ************************
********/
(BUSINESS_UNIT <> MMC_BUSINESS_UNIT("POINDI", BUSINESS_UNIT) And
BUSINESS_UNIT <> MMC_BUSINESS_UNIT("POCET", BUSINESS_UNIT) And
BUSINESS_UNIT <> MMC_BUSINESS_UNIT("POMKT", BUSINESS_UNIT))) Then
/******************************** mmcb.sds4207.en /**************************
******/
SQLExec("SELECT IT.TAX_CLASS_BRL FROM SYSADM.PS_INV_ITEMS IT WHERE IT.SETID =
:1 AND IT.INV_ITEM_ID = :2 AND IT.EFFDT = (SELECT MAX(EFFDT) FROM SYSADM.PS_INV
_ITEMS ITI WHERE ITI.SETID = IT.SETID AND ITI.INV_ITEM_ID = IT.INV_ITEM_ID)", &S
ETID, INV_ITEM_ID, &TAX_ATUAL); /* mmcb.sds3239.ln */
Else
&TAX_ATUAL = TAX_CLASS_BRL;
End-If;
If ((%Component = Component.NF_INFO_PBL Or
%Component = Component.NF_RECV_PBL) And
/******************************** mmcb.sds4207.sn ************************
********/
(BUSINESS_UNIT <> MMC_BUSINESS_UNIT("POINDI", BUSINESS_UNIT) And
BUSINESS_UNIT <> MMC_BUSINESS_UNIT("POCET", BUSINESS_UNIT) And
BUSINESS_UNIT <> MMC_BUSINESS_UNIT("POMKT", BUSINESS_UNIT))) Then
/******************************** mmcb.sds4207.en /**************************
******/
/* SQLExec("SELECT F.WTHD_CD from ps_mmc_ncm_ant_lei E, PS_MMC_NCM_ANT_HDR F
where E.SETID = :1 AND E.SETID = F.SETID AND SUBSTR(E.MMC_PREFIXO_NCM,1,LENGTH(R
TRIM(E.MMC_PREFIXO_NCM))) = SUBSTR(:2,1, LENGTH(RTRIM(E.MMC_PREFIXO_NCM))) AND S
UBSTR(:2,1, 4) NOT IN ('4011', '4013') ", &SETID, &TAX_ATUAL, &WTHD_CD); */
If None(&WTHD_CD) Then
SQLExec("select 'Y' from ps_master_item_tbl where setid = :1 and inv_item_
id = :2 and inventory_item = 'Y'", &SETID, INV_ITEM_ID, &ITEM); /* mmcb.sds3239.
ln */
If &ITEM = "Y" Then
Gray(WTHD_CD);
/************************************** mmcb.hd49255.s.n **************
************************/
If WTHD_CD <> "" And
WTHD_CD <> " "
/************************* mmcb.sds2905.sn **********************
***/
And
TAX_CLASS_BRL <> &TAX_ATUAL And
(BUSINESS_UNIT <> MMC_BUSINESS_UNIT("POINDI", BUSINESS_UNIT) And
BUSINESS_UNIT <> MMC_BUSINESS_UNIT("POCET", BUSINESS_UNIT) And
BUSINESS_UNIT <> MMC_BUSINESS_UNIT("POMKT", BUSINESS_UNIT))
/************************* mmcb.sds2905.en *************************
/
Then
WinMessage("Sistema detectou preenchimento indevido do campo WTHD_CD
(Reteno) na NF: " | BUSINESS_UNIT | " - " | NF_BRL_ID | " - " | NF_BRL_LINE_NUM |
" - " | INV_ITEM_ID | " - " | TAX_CLASS_BRL | " foi preenchido incorretamente c
om o valor: " | WTHD_CD | " sistema corrigira o valor para espao em branco.");
WTHD_CD = " ";
ScrollFlush(Record.MMC_COD_RETL_VW);
End-If;
/************************************** mmcb.hd49255.e.n **************
************************/
End-If;
Else
SQLExec("SELECT 'Y' FROM PS_MMC_ESTAB_TYPE A, PS_VENDOR B WHERE A.SETID =
:1 AND A.SETID = B.SETID AND B.VENDOR_ID = :2 AND A.ESTABID = B.ESTABID", &SETID
, NF_HDR_BRL.VENDOR_ID, &EXISTE); /* mmcb.sds3239.ln */
If &EXISTE = "Y" Then
Gray(WTHD_CD);
SetDefault(WTHD_CD);
/************************************** mmcb.hd49255.s.n **************
************************/
/*************************** mmcb.hd72238.SO **************************
********/
/*
(Reteno) na NF: " | BUSINESS_UNIT | " - " | NF_BRL_ID | " - " | NF_BRL_LINE_NUM |
" - " | INV_ITEM_ID | " - " | TAX_CLASS_BRL | " foi preenchido incorretamente c
om o valor: " | WTHD_CD | " sistema corrigira o valor para espao em branco.");
WTHD_CD = " ";
End-If;
/************************************** mmcb.hd49255.e.n **************
************************/
Else
WTHD_CD = &WTHD_CD;
UnGray(WTHD_CD);
End-If;
End-If;
End-If;
/*** JEISON CALDAS - 29/08/06 - mmcb.AT1563 - Faz validao do Cdigo de Reteno na Nota
Fiscal - Fim ***/
[RECV_LN_SHIP.BUSINESS_UNIT_IN.FieldDefault]
Declare Function BUSCA_SETID PeopleCode MMC_BU_SETID.SETID SavePreChange; /* mmc
b.sds3239.ln */
/*
** Valmir Tavares - HQS - 06.08.2004 - 932 - Inicio.
*/
If %PanelGroup = "RECV_PO" Then
If %Mode = "A" Then
/*********************** mmcb.sds3239.so ***********************/
/*
SQLExec("SELECT A.BUSINESS_UNIT_IN FROM PS_SHIPTO_TBL A WHERE A.EFFDT = (S
ELECT MAX(A_ED.EFFDT) FROM PS_SHIPTO_TBL A_ED WHERE A.SETID = A_ED.SETID AND A.S
HIPTO_ID = A_ED.SHIPTO_ID) AND A.EFF_STATUS = 'A' AND A.SETID = 'MMCSA' AND A.BU
SINESS_UNIT_RECV = :1 AND A.SHIPTO_ID = :2", BUSINESS_UNIT, SHIPTO_ID, &RESULT);
*/
/*********************** mmcb.sds3239.eo ***********************/
/*********************** mmcb.sds3239.sn ***********************/
&SETID = BUSCA_SETID();
SQLExec("SELECT A.BUSINESS_UNIT_IN FROM PS_SHIPTO_TBL A WHERE A.EFFDT = (S
ELECT MAX(A_ED.EFFDT) FROM PS_SHIPTO_TBL A_ED WHERE A.SETID = A_ED.SETID AND A.S
HIPTO_ID = A_ED.SHIPTO_ID) AND A.EFF_STATUS = 'A' AND A.SETID = :1 AND A.BUSINES
S_UNIT_RECV = :2 AND A.SHIPTO_ID = :3", &SETID, BUSINESS_UNIT, SHIPTO_ID, &RESUL
T);
/*********************** mmcb.sds3239.en ***********************/
BUSINESS_UNIT_IN = &RESULT;
End-If;
End-If;
/*
** Valmir Tavares - HQS - 06.08.2004 - 932 - Fim.
*/
[RECV_LN_SHIP.CONVERSION_RATE.SaveEdit]
/*******************************************************************************
***
* Vinicius Alves Mello - MMCB - 08/10/2010 - mmcb.hd102333
*
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-END-19/01/01 */
If %Mode <> "A" Then
&CURR_ROW = CurrentRowNumber();
&rs_data = GetLevel0()(1).GetRowset(Scroll.RECV_LN_SHIP);
&rs_data(&CURR_ROW).RECV_LN_SHIP_WK.DESCR.Label = Substring(&rs_data(&CURR
_ROW).RECV_LN_SHIP.DESCR254_MIXED.Value, 1, 30);
End-If;
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-BEGIN-19/01/01 */
End-If;
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-END-19/01/01 */
/*** JEISON CALDAS 03/11/05 - Tratamento para ser possivel acrescentar o chassi
do veiculo - Inicio ***/
If %Component <> "RECV_PO" Then
Gray(DESCR254_MIXED);
End-If;
/*** JEISON CALDAS 03/11/05 - Tratamento para ser possivel acrescentar o chassi
do veiculo - Fim ***/
[RECV_LN_SHIP.DUE_DT.FieldDefault]
/***********************************/
/* APRD: R-BSLOSS-ZV8WB
EMM */
/* Bundle: R-NDAVE-3L7TE
*/
/* Date: March 4, 2002
*/
/* Changed from = "Y" to = "N"
*/
/***********************************/
If RECV_HDR.PO_RECEIPT_FLG = "N" Then
DUE_DT = %Date;
End-If;
[RECV_LN_SHIP.DUE_DT.SaveEdit]
/*******************************************************************************
*****************
* Mauri Rodrigo Back - MMC - mmcb.sds4483 - 07/08/2013
*
* Apenas poder fazer recebimento com data futura quem estiver parametrizado
*
* Painel: Administrar Compras > Gerenciar Recebimentos > Usar > Lib. Recebimento
no Program. *
********************************************************************************
*****************/
/**************** MMCB.SDS4483.SN ****************/
If %Component = Component.RECV_PO Then
If RECV_HDR.RECV_STATUS <> "X" Then
&DATA_ATUAL = %Date;
&HOJE = %Date;
If DUE_DT > &HOJE Then
/* Verifica se a Unidade est parametrizada no painel Administrar Compras
> Gerenciar Recebimentos > Usar > Lib. Recebimento no Program */
SQLExec("SELECT 'Y', MMC_DIAS_LATENCIA FROM SYSADM.PS_MMC_RECV_LIB WHER
E BUSINESS_UNIT = :1 AND STATUS = 'A'", BUSINESS_UNIT, &BUOK, &DIASLATENCIA);
If &BUOK = "Y" Then
&DIA = 0;
/*Apenas acrescenta a dias latencia se for dia util*/
While &DIA < &DIASLATENCIA
/*Verifica se o dia util*/
SQLExec("SELECT %datein(:1)+:2 FROM DUAL WHERE TO_CHAR(%datein(:1
),'d') NOT IN (1,7)", &DATA_ATUAL, &DIA, &new_data);
If All(&new_data) Then
&DIA = &DIA + 1;
End-If;
/*Limite dias*/
&DATA_ATUAL = &DATA_ATUAL + 1;
End-While;
If &DATA_ATUAL < DUE_DT And
&DATA_ATUAL > &HOJE Then
Error ("Para o recebimento de linhas de programao com Datas Futuras
solicite Autorizao ao Departamento Planejamento e Compras de Materiais. Evento: M
MC_TEMP.DUE_DT.SaveEdit");
End-If; /*&DIASTOTAL<DUE_DT*/
End-If; /**&BUOK=Y**/
End-If; /**DUE_DT>&HOJE**/
End-If; /**RECV_HDR.RECV_STATUS<>X**/
End-If; /**Component**/
/**************** MMCB.SDS4483.EN ****************/
[RECV_LN_SHIP.DUE_TIME.FieldDefault]
/***********************************/
/* APRD: R-BSLOSS-ZV8WB
EMM */
/* Bundle: R-NDAVE-3L7TE
*/
/* Date: March 4, 2002
*/
/* Changed from = "Y" to = "N"
*/
/***********************************/
If RECV_HDR.PO_RECEIPT_FLG = "N" Then
DUE_TIME = %Time;
End-If;
[RECV_LN_SHIP.INSPECT_DTTM.SavePreChange]
If None(INSPECT_DTTM) And
All(QTY_SH_INSPD) Then
INSPECT_DTTM = %Datetime;
End-If;
[RECV_LN_SHIP.INV_ITEM_ID.FieldChange]
Declare Function Get_BU_ATTR PeopleCode FUNCLIB_PM_SQL.BU_ATTR FieldFormula;
Declare Function get_asset_flds PeopleCode FUNCLIB_PM_SQL.INV_ITEM_ID FieldFormu
la;
Declare Function MasterItemFlds PeopleCode FUNCLIB_PM_SQL.CONVERSION_RATE FieldF
ormula;
/* Incident 4478500
begin 1 of 2 */
Declare Function GetItmConvRate PeopleCode FUNCLIB_PM_SQL.CONVERSION_RATE FieldF
ormula;
Declare Function Get_Conv_Rate PeopleCode FUNCLIB_PM_SQL.CONVERSION_RATE FieldFo
rmula;
/* Incident 4478500
end 1 of 2 */
Declare Function GetItmVenLocDfls PeopleCode FUNCLIB_PM_SQL.VENDOR_ID FieldFormu
la;
Declare Function get_cur_xchng_rt PeopleCode FUNCLIB_PM_SQL.CURRENCY_CD FieldFor
mula;
Declare Function DflStockUOM PeopleCode FUNCLIB_RECV.RECEIVER_STATUS FieldFormul
a;
Declare Function GetDflAA PeopleCode FUNCLIB_RECV.RECEIVER_STATUS FieldFormula;
Declare Function POSet_Alt_Prompt PeopleCode FUNCLIB_PM.ALTACCT FieldFormula;
Declare Function GetDflLoc PeopleCode FUNCLIB_RECV.NO_PO_PB FieldFormula;
Declare Function GetDflAmBu PeopleCode FUNCLIB_RECV.NO_PO_PB FieldFormula;
Declare Function get_gl_base_currency PeopleCode FUNCLIB_PM_SQL.CURRENCY_CD Fiel
dFormula;
Declare Function SetConsignFlg PeopleCode RECV_HDR_WK.CONSIGNED_FLAG FieldChange
;
Declare Function GetBUItmInfo PeopleCode RECV_HDR_WK.CONSIGNED_FLAG FieldChange;
Declare Function RecvDescWkUpd PeopleCode RECV_HDR_WK.PB_SELECT_PO FieldChange;
Declare Function Gray_Line_PB PeopleCode RECV_HDR_WK.LINE_SELECT FieldChange;
Declare Function TtlLnQtyAssetInv PeopleCode RECV_HDR_WK.FUNCLIB FieldChange;
/* PO8.0SP1 Begin */
Declare Function AmtOnlyCheck PeopleCode RECV_HDR_WK.FUNCLIB FieldFormula;
/* PO8.0SP1 End */
Declare Function DevTrkItem PeopleCode FUNCLIB_RECV.CONVERSION_RATE FieldFormula
;
Function UpdDistFlds(&LINE_ROW, &CONSIGNED_FLAG)
&AMBU = "";
&FIN_AM_SW = "";
&PROFILE_ID = "";
&OPRID = OPRID;
GetDflLoc(&OPRID, &LOCATION);
&SETID = FetchValue(ITM_SETID, &LINE_ROW);
&INV_ITEM_ID = FetchValue(INV_ITEM_ID, &LINE_ROW);
get_asset_flds(&SETID, &INV_ITEM_ID, &PROFILE_ID);
If All(&PROFILE_ID) Then
&POBU = FetchValue(BUSINESS_UNIT, &LINE_ROW);
GetDflAmBu(&POBU, &AMBU, &FIN_AM_SW);
End-If;
&BUIN_DFL = RECV_HDR_WK.BUSINESS_UNIT_IN;
GetBUItmInfo(&LINE_ROW, &BUIN_DFL, &NON_OWN_FLAG, &CONSIGNED_FLAG, &UOM_CONV_
FLAG, &BU_ITM_VALID, &STORAGE_AREA, &STOR_LEVEL_1, &STOR_LEVEL_2, &STOR_LEVEL_3,
&STOR_LEVEL_4);
If &BU_ITM_VALID <> "Y" Then
&BUIN_DFL = " ";
End-If;
&HOLD_BUIN = &BUIN_DFL;
&HOLD_LINE = &LINE_ROW;
&DIST_MAXROW = ActiveRowCount(Scroll.RECV_LN_SHIP, &LINE_ROW, Scroll.RECV_LN_
DISTRIB);
For &DIST_ROW = 1 To &DIST_MAXROW;
&PRODUCT = FetchValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.PRODUCT, &DI
ST_ROW);
If None(&PRODUCT) Then
UpdateValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.PRODUCT, &DIST_ROW,
PURCH_ITEM_WRK.PRODUCT);
End-If;
&CURRENCY_CD = FetchValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.CURRENCY
_CD, &DIST_ROW);
&PREV_CUR = &CURRENCY_CD;
If None(&CURRENCY_CD) Then
&CURRENCY_CD = CURRENCY_CD;
UpdateValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.CURRENCY_CD, &DIST_
ROW, CURRENCY_CD);
End-If;
&GL_BU = FetchValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.BUSINESS_UNIT_
GL, &DIST_ROW);
&BASE_CURRENCY = FetchValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.CURREN
CY_CD_BASE, &DIST_ROW);
&PREV_BASE = &BASE_CURRENCY;
If None(&GL_BU) Then
UpdateValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.BUSINESS_UNIT_GL, &
DIST_ROW, RECV_HDR_WK.BUSINESS_UNIT_GL);
&GL_BU = RECV_HDR_WK.BUSINESS_UNIT_GL;
get_gl_base_currency(&GL_BU, &BASE_CURRENCY);
UpdateValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.CURRENCY_CD_BASE, &
DIST_ROW, &BASE_CURRENCY);
End-If;
If &CURRENCY_CD <> &PREV_CUR Or
&BASE_CURRENCY <> &PREV_BASE Then
get_cur_xchng_rt(RECV_HDR_WK.CUR_RT_TYPE, &CURRENCY_CD, &BASE_CURRENCY,
RECV_HDR.RECEIPT_DT, &RATE_MULT, &RATE_DIV, &RATE_DATE);
UpdateValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.RATE_DIV, &DIST_ROW
, &RATE_DIV);
UpdateValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.RATE_MULT, &DIST_RO
W, &RATE_MULT);
UpdateValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.RT_TYPE, &DIST_ROW,
RECV_HDR_WK.CUR_RT_TYPE);
End-If;
&ACCOUNT = FetchValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.ACCOUNT, &DI
ST_ROW);
If None(&ACCOUNT) Then
UpdateValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.ACCOUNT, &DIST_ROW,
PURCH_ITEM_WRK.ACCOUNT);
End-If;
&ACCOUNT = FetchValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.ACCOUNT, &DI
ST_ROW);
/*SMR - 02/02/06 - INICIO - A pedido da Katia Santos foi acrescentado camp
os para exibir descrio da conta contbil e do departamento*/
SQLExec("SELECT DESCR FROM PS_ACC_DESCR_LANG WHERE ACCOUNT = :1 AND LANGUA
GE_CD = 'POR'", &ACCOUNT, &ACCTG_DESCR);
UpdateValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DIST_WK.ACCOUNT_DESCR, &DIST_R
OW, &ACCTG_DESCR);
&DEPT_ID = FetchValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.DEPTID, &DIS
T_ROW);
If &DEPT_ID <> "" Then
SQLExec("SELECT DESCR FROM PS_DEPTID_MON_LANG WHERE DEPTID = :1 AND LAN
GUAGE_CD = 'POR'", &DEPT_ID, &DEPT_DESCR);
UpdateValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DIST_WK.DEPTID_DESCR, &DIST
_ROW, &DEPT_DESCR);
End-If;
/*SMR - 02/02/06 - FIM*/
&GL_BU = FetchValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.BUSINESS_UNIT_
GL, &DIST_ROW);
GetDflAA(&GL_BU, &ACCOUNT, &AA_OPTN, &DFL_ALTACCT);
If &AA_OPTN = "Y" Then
&ALTACCT = FetchValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.ALTACCT,
&DIST_ROW);
If None(&ALTACCT) Then
If All(PURCH_ITEM_WRK.ALTACCT) Then
UpdateValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.ALTACCT, &DIS
T_ROW, PURCH_ITEM_WRK.ALTACCT);
Else
UpdateValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.ALTACCT, &DIS
T_ROW, &DFL_ALTACCT);
End-If;
POSet_Alt_Prompt("", "", Record.RECV_LN_SHIP, &LINE_ROW, Record.RECV
_LN_DISTRIB, &DIST_ROW, Record.GL_ACCT_BUGL_VW, Record.ALTACCT_BUGL_VW, "");
End-If;
End-If;
If All(&AMBU, &PROFILE_ID) Then
UpdateValue(RECV_LN_WK.ASSET_FLG, &LINE_ROW, "Y");
&DIST_AMBU = FetchValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.BUSINES
S_UNIT_AM, &DIST_ROW);
If &AMBU <> &DIST_AMBU Then
UpdateValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.BUSINESS_UNIT_AM
, &DIST_ROW, &AMBU);
End-If;
&DIST_PROFILE = FetchValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.PROF
ILE_ID, &DIST_ROW);
If &PROFILE_ID <> &DIST_PROFILE Then
UpdateValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.PROFILE_ID, &DIS
T_ROW, &PROFILE_ID);
End-If;
&DIST_AMSW = FetchValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.BUSINES
S_UNIT_AM, &DIST_ROW);
If &FIN_AM_SW <> &DIST_AMSW Then
UpdateValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.FINANCIAL_ASSET_
SW, &DIST_ROW, &FIN_AM_SW);
End-If;
End-If;
&LOCATION = FetchValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.LOCATION, &
DIST_ROW);
If None(&LOCATION) Then
UpdateValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.LOCATION, &DIST_ROW
, &LOCATION);
End-If;
&BU_IN = FetchValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.BUSINESS_UNIT_
IN, &DIST_ROW);
If None(&BU_IN) Then
&BU_IN = &BUIN_DFL;
UpdateValue(RECV_LN_NBR, &LINE_ROW, RECV_LN_DISTRIB.BUSINESS_UNIT_IN, &
DIST_ROW, &BU_IN);
End-If;
If &HOLD_BUIN <> &BU_IN Or
&HOLD_LINE <> &LINE_ROW Then
&HOLD_BUIN = &BU_IN;
&HOLD_LINE = &LINE_ROW;
GetBUItmInfo(&LINE_ROW, &BU_IN, &NON_OWN_FLAG, &CONSIGNED_FLAG, &UOM_CO
End-If;
/* Calculate PRICE_PO_BSE */
If CURRENCY_CD = CURRENCY_CD_BASE Then
PRICE_PO_BSE = PRICE_PO;
Else
get_cur_xchng_rt(RECV_HDR_WK.CUR_RT_TYPE, CURRENCY_CD, CURRENCY_CD_BASE, R
ECV_HDR.RECEIPT_DT, &RATE_MULT, &RATE_DIV, &RATE_DATE);
If &RATE_DIV > 0 Then
PRICE_PO_BSE = RoundCurrency(PRICE_PO * &RATE_MULT / &RATE_DIV, CURRENC
Y_CD_BASE, &RATE_DATE);
Else
PRICE_PO_BSE = RoundCurrency(PRICE_PO, CURRENCY_CD_BASE, &RATE_DATE);
End-If;
End-If;
&REJECT_DAYS = PURCH_ITEM_WRK.REJECT_DAYS;
&QTY_RECV_TOL_PCT = PURCH_ITEM_WRK.QTY_RECV_TOL_PCT;
&RJCT_OVER_TOL_FLAG = PURCH_ITEM_WRK.RJCT_OVER_TOL_FLAG;
&RECV_PARTIAL_FLG = PURCH_ITEM_WRK.RECV_PARTIAL_FLG;
&MODEL = PURCH_ITEM_WRK.MODEL;
UpdateValue(RECV_LN_WK.ITEM_LIMITS_FLG, &LINE_ROW, "Y");
UpdateValue(RECV_LN_WK.REJECT_DAYS, &LINE_ROW, &REJECT_DAYS);
UpdateValue(RECV_LN_WK.RJCT_OVER_TOL_FLAG, &LINE_ROW, &RJCT_OVER_TOL_FLAG);
UpdateValue(RECV_LN_WK.RECV_PARTIAL_FLG, &LINE_ROW, &RECV_PARTIAL_FLG);
UpdateValue(RECV_LN_WK.MODEL, &LINE_ROW, &MODEL);
INSPECT_CD = PURCH_ITEM_WRK.INSPECT_CD;
IST_DISTRIB_STATUS = "N";
MasterItemFlds(ITM_SETID, INV_ITEM_ID, UNIT_MEASURE_STD, LOT_CONTROL, SERIAL_
CONTROL, MFG_ID, MFG_ITM_ID, CATEGORY_ID, &CONSIGNED_FLAG);
DevTrkItem(ITM_SETID, INV_ITEM_ID, &DEVICE_TRK);
UpdateValue(DEVICE_TRACKING, &LINE_ROW, &DEVICE_TRK);
GetItmVenLocDfls(ITM_SETID, INV_ITEM_ID, RECV_HDR.VENDOR_SETID, RECV_HDR.VEND
OR_ID, RECV_HDR.VNDR_LOC, ITM_ID_VNDR, &VNDR_CATALOG_ID, COUNTRY_IST_ORIGIN, &IS
T_REGION_ORIGIN, &VNDR_UOM, CONVERSION_RATE);
RECEIPT_UM = &VNDR_UOM;
RECEIVE_UOM = &VNDR_UOM;
/* Incident 4478500
begin 2 of 2 */
&CONVERSION_RATE = CONVERSION_RATE;
If None(&CONVERSION_RATE) Then
GetItmConvRate(ITM_SETID, INV_ITEM_ID, RECEIPT_UM, &CONVERSION_RATE);
If None(&CONVERSION_RATE) Then
Get_Conv_Rate(RECEIPT_UM, UNIT_MEASURE_STD, &CONVERSION_RATE);
If None(&CONVERSION_RATE) Then
&CONVERSION_RATE = 1.0
End-If;
End-If;
CONVERSION_RATE = &CONVERSION_RATE;
End-If;
/* Incident 4478500
end 2 of 2 */
CONVERT_STK_TO_STD = 1.0;
CONVERT_TO_PO = 1.0;
DflStockUOM(ITM_SETID, INV_ITEM_ID, &DFL_STK_UOM, &CNV_RATE);
If None(&DFL_STK_UOM) Then
&DFL_STK_UOM = UNIT_MEASURE_STD;
&CNV_RATE = 1.0;
Else
If None(&CNV_RATE) Then
&CNV_RATE = 1.0;
End-If;
End-If;
&CNV_TO_STD = CONVERSION_RATE;
&CNV_TO_STK = Round((&CNV_TO_STD * (1 / &CNV_RATE)), 8);
CONVERT_TO_STK = &CNV_TO_STK;
CONVERT_STK_TO_STD = &CNV_RATE;
RECV_STOCK_UOM = &DFL_STK_UOM;
UpdDistFlds(&LINE_ROW, &CONSIGNED_FLAG);
End-Function;
/* Mainline */
If RECV_HDR.PO_RECEIPT_FLG = "N" Then
/* fabiano Cunha - 06/02/2006 - verificar se o itm esta cadastrado ou no na un
idade de estoque */
SQLExec("select 'x' from ps_bu_items_inv where business_unit = :1 and inv_ite
m_id = :2", BUSINESS_UNIT_IN, INV_ITEM_ID, &result);
If None(&result) Then
Error "item no esta cadastrado na unidade -" | BUSINESS_UNIT_IN;
End-If;
&PRIOR_ITM = PriorValue(INV_ITEM_ID);
If INV_ITEM_ID <> &PRIOR_ITM Then
&LINE_ROW = CurrentRowNumber();
GetItemData(&LINE_ROW);
TtlLnQtyAssetInv(&LINE_ROW);
RecvDescWkUpd(&LINE_ROW);
Gray_Line_PB();
End-If;
/* PO8.0SP1 Begin */
&LINE_ROW = CurrentRowNumber();
AmtOnlyCheck(&LINE_ROW);
/* PO8.0SP1 End */
End-If;
[RECV_LN_SHIP.INV_ITEM_ID.FieldEdit]
/***************************************************************************
* Claudio Henrique da Costa - MMC - 22/11/2006 - mmcb.at1931
*
* Alteracao para que aceite recebimento POTER independente do Item
*
***************************************************************************/
Global boolean &MMC_ENTRAPOR_ITEM, &MMC_ENTRAPOR_PACABADO, &MMC_ENTRAPOR_PACABAD
ONF, &MMC_ENTRAPOR_TRIANGULACAO; /* chc */
If RECV_HDR.PO_RECEIPT_FLG = "Y" Then
If &MMC_ENTRAPOR_TRIANGULACAO <> True Then /* mmcb.at1931.n */
Error MsgGet(10300, 138, "Missing Message.");
End-If; /* mmcb.at1931.n */
End-If;
[RECV_LN_SHIP.OPRID.FieldDefault]
/* RECV_LN_SHIP.OPRID.FIELDDEFAULT */
OPRID = %OperatorId;
[RECV_LN_SHIP.OP_SEQUENCE.SaveEdit]
/*
APRD R-CMORSE-DT4AF
(Begin)
/* RECV_LN_SHIP.OP_SEQUENCE.SaveEdit
*/
*/
[RECV_LN_SHIP.PO_ID.FieldFormula]
/*****************************************************************************
* Vincius Alves Mello - MMC - mmcb.hd77195 - 04/11/2009
* Fazer com que o sistema traga o nmero da ordem de compra e a data de
* vencimento do recebimento.
*****************************************************************************/
/****************************** mmcb.hd77195.sn *****************************/
If %Component = Component.RECV_PO And
%Page = Page.RECV_WPO Then
If All(PO_ID) Then
MMC_TEMP.PO_ID = PO_ID;
SQLExec("SELECT TO_CHAR(C.DUE_DT,'DD/MM/YYYY') FROM SYSADM.PS_PO_HDR A, SY
SADM.PS_PO_LINE B, SYSADM.PS_PO_LINE_SHIP C WHERE A.BUSINESS_UNIT = B.BUSINESS_U
NIT AND A.PO_ID = B.PO_ID AND B.BUSINESS_UNIT = C.BUSINESS_UNIT AND B.PO_ID = C.
PO_ID AND B.LINE_NBR = C.LINE_NBR AND A.PO_STATUS <> 'X' AND B.CANCEL_STATUS <>
'X' AND C.CANCEL_STATUS <> 'X' AND A.BUSINESS_UNIT = :1 AND A.PO_ID = :2 AND B.L
INE_NBR = :3 AND C.SCHED_NBR = :4", BUSINESS_UNIT_PO, PO_ID, LINE_NBR, SCHED_NBR
, &dataVencimento);
If All(&dataVencimento) Then
MMC_TEMP.DUE_DT = DateValue(&dataVencimento);
End-If;
End-If;
End-If;
/****************************** mmcb.hd77195.en *****************************/
[RECV_LN_SHIP.PO_ID.SaveEdit]
/**************************************************************************
* Vincius Alves Mello - MMC - mmcb.hd86592 - 31/03/2010
* Incluir trava para conta de investimento, validando PAA
**************************************************************************/
/**************************************************************************
* Vincius Alves Mello - MMC - mmcb.hd83985 - 06/05/2010
* Bloquear a entrada de OCs que no foram aprovadas pelo Ativo
*
**************************************************************************/
/**************************************************************************
* Vinicius Mello - MMC - mmcb.hd91926 - 21/05/2010 (Enc. Bleno Sampaio) *
* Acertar a customizao do hd83985 do Vincius para desconsiderar quando *
* for cancelar o recebimento.
**************************************************************************/
/*************************************************************************
* Mauri R. Back - MMC - 13/07/2012 - mmcb.hd146171
*
* Retirar Validao de Aprovao de MP382.
*
*************************************************************************/
/*************************************************************************
* Wagner Sorio - MMC - 08/02/2013 - mmcb.hd164098
*
* Erro na busca dos dados de Oramento.
*
*************************************************************************/
/*************************************************************************
* Mairany Cristina - MMC - 27/08/2013 - mmcb.sds4523
*
* Alterao da Mensagem de Erro Recebimento Fisico.
*
*************************************************************************/
*
*
*
End-If;*/
/***************************** mmcb.sds4523.eo ******************
***********/
/***************************** mmcb.sds4523.sn ******************
***********/
SQLExec("SELECT A.DEPTID, A.PROJECT_ID FROM SYSADM.PS_CAP_DET A W
HERE A.BUSINESS_UNIT = :1 AND A.CAP_NUM = :2 AND A.CAP_SEQUENCE = :3", &BUSINESS
_UNIT_GL, &CAP_NUM, &CAP_SEQUENCE, &DEPTID_CAP_DET, &PROJECT_ID_CAP_DET);
If &DEPTID <> &DEPTID_CAP_DET Then
Error ("O departamento da ordem de compra o '" | &DEPTID | "'
e o departamento do PAA o '" | &DEPTID_CAP_DET | "'. Corrija o departamento ou e
ntre em contato com a Controladoria.");
End-If;
If &PROJECT_ID <> &PROJECT_ID_CAP_DET Then
Error ("O projeto da ordem de compra o '" | &PROJECT_ID | "' e
o ID de projeto do PAA '" | &PROJECT_ID_CAP_DET | "'. Corrija o projeto ou entr
e em contato com a Controladoria.");
End-If;
/***************************** mmcb.sds4523.en ******************
***********/
Else
Error ("No foi possvel recuperar os dados do projeto e PAA da OC "
| BUSINESS_UNIT_PO | " - " | PO_ID | " linha " | LINE_NBR | ".");
End-If;
Else
Error ("A conta " | &ACCOUNT | " e uma conta de investimento, sendo
que no existe uma OC relacionada a este recebimento.");
End-If;
End-If;
End-If; /**mmcb.hd91926.ln**/
End-If;
/***************************** mmcb.hd86592.en ****************************/
If All(&necessitaBuIn) Then
SQLExec("SELECT 'Y' AS ITEM_ESTOQUE FROM SYSADM.PS_MASTER_ITEM_TBL A WH
ERE A.SETID=:1 AND A.INV_ITEM_ID=:2 AND A.INVENTORY_ITEM = 'Y'", &SETID, INV_ITE
M_ID, &V_ITEM_ESTOQUE);
If All(&V_ITEM_ESTOQUE) Then
Error ("A quantidade que ser armazenada esta errada (Linha: " | RECV_
LN_NBR | " Item: " | INV_ITEM_ID | " QTD Rec: " | QTY_SH_RECVD | " TX: " | CONVE
RSION_RATE | " QTD Est: " | QTY_LN_INV_SUOM | ").");
End-If;
End-If;
End-If;
End-If;
/********************************* mmcb.hd102333.en ****************************
***/
[RECV_LN_SHIP.QTY_SH_ACCPT.FieldChange]
/* RECV_LN_SHIP.QTY_SH_ACCPT.FIELDCHANGE */
Declare Function ChgQtyShAccptRuom PeopleCode RECV_LN_SHIP_WK.QTY_SH_ACCPT Field
Change;
/* Update Accepted Qty and Merchandise Amount for Schedule and Sum Up to Receipt
Line
------------------------------------------ */
Function Fch_QtyShAccptRuom();
&SHIP_ROW = CurrentRowNumber();
&PRIOR_QTY = PriorValue(QTY_SH_ACCPT, &SHIP_ROW);
remark change receipt uom qty and update amt for current Receipt schedule;
ChgQtyShAccptRuom(&SHIP_ROW, &PRIOR_QTY);
End-Function;
/* MainLine ----------- */
Fch_QtyShAccptRuom();
[RECV_LN_SHIP.QTY_SH_ACCPT.FieldEdit]
/* RECV_LN_SHIP.QTY_SH_ACCPT FieldEdit */
Declare Function CheckQtyShAccptRuom PeopleCode RECV_LN_SHIP_WK.QTY_SH_ACCPT Fie
ldChange;
Function Fed_QtyShAccptRuom();
&SHIP_ROW = CurrentRowNumber();
&PRIOR_QTY = PriorValue(QTY_SH_ACCPT, &SHIP_ROW);
&QTY_SH_ACCPT = FetchValue(QTY_SH_ACCPT, &SHIP_ROW);
CheckQtyShAccptRuom(&SHIP_ROW, &QTY_SH_ACCPT, &PRIOR_QTY);
End-Function;
/* Mainline */
Fed_QtyShAccptRuom();
[RECV_LN_SHIP.QTY_SH_ACCPT.RowInit]
/* RECV_LN_SHIP.QTY_SH_ACCPT RowInit */
/*BRLOC-IN-MFF-R2-07/05/1999
Do not allow the following code to run if panel group is Unhold Receipt
*/
If %PanelGroup <> PanelGroup.RECV_UNHOLD_PBL Then
/*BRLOC-IN-END*/
If RECV_SHIP_STATUS = "M" Then
&LINE_ROW = CurrentRowNumber(1);
&INV_FLG = FetchValue(RECV_LN_WK.INV_FLG, &LINE_ROW);
If &INV_FLG = "Y" And
/** Added Following 1 Line for the FIx R-JMACIA-ME2VU ***/
None(PRODUCTION_ID, OP_SEQUENCE) Then
Gray(RECV_HDR_WK.PB_CANCEL_RECPT);
Gray(RECV_HDR_WK.PB_RECV_STATUS);
Gray(RECV_LN_WK.PB_CANCEL_ITEM);
Gray(QTY_SH_ACCPT);
Gray(QTY_SH_INSPD);
Gray(QTY_SH_RECVD);
Gray(QTY_SH_REJCT);
End-If;
End-If;
/*BRLOC-IN-MFF-R2-07/05/1999*/
End-If;
/*BRLOC-IN-END*/
[RECV_LN_SHIP.QTY_SH_ACCPT.SavePreChange]
/* RECV_LN_SHIP.QTY_SH_ACCPT SavePreChg */
Declare Function SubReceiptUpd PeopleCode FUNCLIB_RECV.F_MFGID FieldFormula;
Declare Function UpdLCLnStuff PeopleCode RECV_LN_SHIP_WK.QTY_SH_ACCPT FieldChang
e;
Declare Function UpdDistLCStuff PeopleCode RECV_LN_SHIP_WK.FUNCLIB FieldChange;
/* Mainline */
&SHIP_ROW = CurrentRowNumber();
If FieldChanged(QTY_SH_ACCPT, &SHIP_ROW) Then
&PROCESSED = FetchValue(PROCESS_COMPLETE, &SHIP_ROW);
If &PROCESSED = "Y" Then
UpdLCLnStuff(&SHIP_ROW);
&DIST_ROW_MAX = ActiveRowCount(Scroll.RECV_LN_SHIP, &SHIP_ROW, Scroll.RECV
_LN_DISTRIB);
For &DIST_ROW = 1 To &DIST_ROW_MAX
UpdDistLCStuff(&SHIP_ROW, &DIST_ROW);
End-For;
End-If;
&OP_SEQUENCE = FetchValue(OP_SEQUENCE, &SHIP_ROW);
&PRODUCTION_ID = FetchValue(PRODUCTION_ID, &SHIP_ROW);
&RCVSHIPSTAT = FetchValue(MOVE_STAT_MFG, &SHIP_ROW);
If Not None(&OP_SEQUENCE, &PRODUCTION_ID) And
&RCVSHIPSTAT = "M" Or
&RCVSHIPSTAT = "X" Then
&PRIOR_QTY_SUOM = FetchValue(RECV_LN_SHIP_WK.QTY_SH_ACCPT_SUOM, &SHIP_ROW)
;
&ACCPT_QTY_SUOM = FetchValue(QTY_SH_ACCPT_SUOM, &SHIP_ROW);
&PRIOR_REJ_QTY_SUOM = FetchValue(RECV_LN_SHIP_WK.QTY_SH_REJCT_SUOM, &SHIP_
ROW);
&REJCT_QTY_SUOM = FetchValue(QTY_SH_REJCT_SUOM, &SHIP_ROW);
&ACTION = FetchValue(REJECT_ACTION, &SHIP_ROW);
If &PRIOR_QTY_SUOM <> &ACCPT_QTY_SUOM Or
&PRIOR_REJ_QTY_SUOM <> &REJCT_QTY_SUOM Then
&BU_IN = FetchValue(BUSINESS_UNIT_IN, &SHIP_ROW);
/* MainLine
----------- */
Fch_QtyShInspdRuom();
[RECV_LN_SHIP.QTY_SH_INSPD.FieldEdit]
/* * * PO 8.02 Prf (Start) */
If RECV_HDR.PO_RECEIPT_FLG = "N" And
None(INV_ITEM_ID) Then
Error MsgGet(10300, 221, "Missing Message.");
End-If;
/* * * PO 8.02 Prf (End)
*/
&SHIP_ROW = CurrentRowNumber();
&RQTY = FetchValue(QTY_SH_RECVD, &SHIP_ROW);
If QTY_SH_INSPD > &RQTY Then
Error (MsgGet(10300, 112, "Inspection quantity cannot be greater than receive
d quantity."));
End-If;
[RECV_LN_SHIP.QTY_SH_INSPD_SUOM.FieldChange]
/* RECV_LN_SHIP.QTY_SH_INSPD_SUOM.FIELDCHANGE */
/* Update Inspected Qty for Schedule and Sum Up to Receipt Line
----------------------------------------- */
Function Fch_QtyShInspdSuom();
remark change std uom qty and update amt for current Receipt schedule;
&SHIP_ROW = CurrentRowNumber();
&CONV = FetchValue(CONVERSION_RATE, &SHIP_ROW);
&CR = (1 / &CONV);
QTY_SH_INSPD_VUOM = QTY_SH_INSPD_SUOM * &CR;
End-Function;
/* MainLine
----------- */
Fch_QtyShInspdSuom();
[RECV_LN_SHIP.QTY_SH_INSPD_VUOM.FieldChange]
/* RECV_LN_SHIP.QTY_SH_INSPD_VUOM.FIELDCHANGE */
/* Update Inspected Qty for Schedule and Sum Up to Receipt Line
------------------------------------------ */
Function Fch_QtyShInspdVuom();
remark change std uom qty and update amt for current Receipt schedule;
&SHIP_ROW = CurrentRowNumber();
&CR = FetchValue(CONVERSION_RATE, &SHIP_ROW);
QTY_SH_INSPD_SUOM = QTY_SH_INSPD_VUOM * &CR;
End-Function;
/* MainLine
----------- */
Fch_QtyShInspdVuom();
[RECV_LN_SHIP.QTY_SH_RECVD.FieldChange]
/* RECV_LN_SHIP.QTY_SH_RECVD.FIELDCHANGE */
/* Update Received Qty for Schedule ----------------------- */
Declare Function Fch_QtyShAccptRuom PeopleCode QTY_SH_ACCPT FieldChange;
Declare Function qty_precision_round PeopleCode FUNCLIB_FS.QTY_PRECISION FieldFo
rmula;
Function Fch_QtyShRecvdRuom();
remark change Receipt uom qty for current Receipt schedule;
&SHIP_ROW = CurrentRowNumber();
&CR_RUOM_TO_VUOM = FetchValue(CONVERT_TO_PO, &SHIP_ROW);
/* 07-18-02 EW Incident #510059002 Begin */
/* &CR_RUOM_TO_SUOM = FetchValue(CONVERSION_RATE, &SHIP_ROW); */
&CR_VUOM_TO_SUOM = FetchValue(CONVERSION_RATE, &SHIP_ROW);
&CR_RUOM_TO_SUOM = Round((&CR_VUOM_TO_SUOM * &CR_RUOM_TO_VUOM), 4);
&SETID = FetchValue(ITM_SETID, &SHIP_ROW);
&INV_ITEM_ID = FetchValue(INV_ITEM_ID, &SHIP_ROW);
&RECEIVE_UOM = FetchValue(RECEIVE_UOM, &SHIP_ROW);
&QTY_SH_RECVD = FetchValue(QTY_SH_RECVD, &SHIP_ROW);
&CONVERT_TO_RECV = 1.0;
&QTY_PRECISION = "";
&ROUND_RULE = "";
qty_precision_round(&SETID, " ", &QTY_SH_RECVD, &INV_ITEM_ID, &RECEIVE_UOM, "
", &QTY_PRECISION, &ROUND_RULE, &CONVERT_TO_RECV);
/* PO 8.0 SP2 (Begin)
*/
If &QTY_SH_RECVD > 99999999999.9999 Then
&QTY_SH_RECVD = PriorValue(QTY_SH_RECVD, &SHIP_ROW);
End-If;
/* PO 8.0 SP2 (End)
*/
QTY_SH_RECVD = &QTY_SH_RECVD;
&PRIOR_RCV_VUOM = FetchValue(QTY_SH_RECVD_VUOM, &SHIP_ROW);
&QTY_SH_RECVD_VUOM = Round(QTY_SH_RECVD * &CR_RUOM_TO_VUOM, 4);
/* &RECEIPT_UM = FetchValue(RECEIPT_UM, &SHIP_ROW);
&QTY_PRECISION = "";
&ROUND_RULE = "";
qty_precision_round(&SETID, " ", &QTY_SH_RECVD_VUOM, &INV_ITEM_ID, &RECEIPT_U
M, " ", &QTY_PRECISION, &ROUND_RULE, &CR_RUOM_TO_VUOM);*/
QTY_SH_RECVD_VUOM = &QTY_SH_RECVD_VUOM;
/* &QTY_SH_RECVD_SUOM = Round(QTY_SH_RECVD_VUOM * &CR_RUOM_TO_SUOM, 4);*/
&QTY_SH_RECVD_SUOM = (QTY_SH_RECVD * &CR_RUOM_TO_SUOM);
&UNIT_MEASURE_STD = FetchValue(UNIT_MEASURE_STD, &SHIP_ROW);
&QTY_PRECISION = "";
&ROUND_RULE = "";
/* qty_precision_round(&SETID, " ", &QTY_SH_RECVD_VUOM, &INV_ITEM_ID, &UNIT_M
EASURE_STD, " ", &QTY_PRECISION, &ROUND_RULE, &CR_RUOM_TO_SUOM); */
qty_precision_round(&SETID, " ", &QTY_SH_RECVD_SUOM, &INV_ITEM_ID, &UNIT_MEAS
URE_STD, " ", &QTY_PRECISION, &ROUND_RULE, &CR_RUOM_TO_SUOM);
/* 07-18-02 EW Incident #510059002 End */
QTY_SH_RECVD_SUOM = &QTY_SH_RECVD_SUOM;
QTY_SH_NETRCV_VUOM = QTY_SH_NETRCV_VUOM + (QTY_SH_RECVD_VUOM - &PRIOR_RCV_VUO
M);
End-Function;
/* MainLine ------------- */
Fch_QtyShRecvdRuom();
Fch_QtyShAccptRuom();
[RECV_LN_SHIP.QTY_SH_RECVD.FieldEdit]
/*******************************************************************************
************************************
* Leandro Rodrigues da Silva Souza - MMC - 05/12/2007 - mmcb.AT1923 - Adicionado
ao painel RECV_WPO.POR
*
*Alterada a forma de validao da quantidade recebida.
********************************************************************************
***********************************/
/*******************************************************************************
***********************************
* Wagner Sorio - MMC - 14/04/2008 - mmcb.HD47226
*
* No deixar receber mais que quantidade Saldo Ordem Compra
*
********************************************************************************
***********************************/
Declare Function Fed_QtyShAccptRuom PeopleCode QTY_SH_ACCPT FieldEdit;
Declare Function CheckQtyShAccptRuom PeopleCode RECV_LN_SHIP_WK.QTY_SH_ACCPT Fie
ldChange;
Declare Function qty_precision_round PeopleCode FUNCLIB_FS.QTY_PRECISION FieldFo
rmula;
Local Rowset &RS0, &RS1; /* mmcb.AT1923.n */
Local Record &RS2, &RS3; /* mmcb.AT1923.n */
Function AdjAcceptQty();
&SHIP_ROW = CurrentRowNumber();
/* PO 8.0 SP2 (Begin)
*/
&SETID = FetchValue(ITM_SETID, &SHIP_ROW);
&INV_ITEM_ID = FetchValue(INV_ITEM_ID, &SHIP_ROW);
&RECEIVE_UOM = FetchValue(RECEIVE_UOM, &SHIP_ROW);
&QTY_SH_RECVD = FetchValue(QTY_SH_RECVD, &SHIP_ROW);
&CONVERT_TO_RECV = 1.0;
&QTY_PRECISION = "";
&ROUND_RULE = "";
qty_precision_round(&SETID, " ", &QTY_SH_RECVD, &INV_ITEM_ID, &RECEIVE_UOM, "
", &QTY_PRECISION, &ROUND_RULE, &CONVERT_TO_RECV);
If &QTY_SH_RECVD > 99999999999.9999 Then
Error MsgGet(10300, 224, "Quantity value entered is to large after UOM rou
nding is applied.");
End-If;
&CR_RUOM_TO_VUOM = FetchValue(CONVERT_TO_PO, &SHIP_ROW);
&QTY_SH_RECVD_VUOM = Round(QTY_SH_RECVD * &CR_RUOM_TO_VUOM, 4);
&RECEIPT_UM = FetchValue(RECEIPT_UM, &SHIP_ROW);
&QTY_PRECISION = "";
&ROUND_RULE = "";
qty_precision_round(&SETID, " ", &QTY_SH_RECVD_VUOM, &INV_ITEM_ID, &RECEIPT_U
M, " ", &QTY_PRECISION, &ROUND_RULE, &CR_RUOM_TO_VUOM);
If &QTY_SH_RECVD_VUOM > 99999999999.9999 Then
Error MsgGet(10300, 224, "Quantity value entered is to large after UOM rou
nding is applied.");
End-If;
&CR_RUOM_TO_SUOM = FetchValue(CONVERSION_RATE, &SHIP_ROW);
&QTY_SH_RECVD_SUOM = Round(QTY_SH_RECVD_VUOM * &CR_RUOM_TO_SUOM, 4);
&UNIT_MEASURE_STD = FetchValue(UNIT_MEASURE_STD, &SHIP_ROW);
&QTY_PRECISION = "";
&ROUND_RULE = "";
qty_precision_round(&SETID, " ", &QTY_SH_RECVD_SUOM, &INV_ITEM_ID, &UNIT_MEAS
URE_STD, " ", &QTY_PRECISION, &ROUND_RULE, &CR_RUOM_TO_SUOM);
If &QTY_SH_RECVD_SUOM > 99999999999.9999 Then
Error MsgGet(10300, 224, "Quantity value entered is to large after UOM rou
nding is applied.");
End-If;
/* PO 8.0 SP2 (End)
*/
&PRIOR_QTY = PriorValue(QTY_SH_RECVD);
&V_LINHA = CurrentRowNumber();
&V_BUSINESS_UNIT = FetchValue(BUSINESS_UNIT_PO, &V_LINHA);
&V_PO_ID = FetchValue(PO_ID, &V_LINHA);
&V_LINE_NBR = FetchValue(LINE_NBR, &V_LINHA);
&V_SCHED_NBR = FetchValue(SCHED_NBR, &V_LINHA);
&V_QTY_SH_RECVD = FetchValue(QTY_SH_RECVD, &V_LINHA);
/*
SQLExec("select qty_po from sysadm.ps_mmc_te_oc_vw where business_unit=:1 and
po_id =:2 and line_nbr=:3 and sched_nbr =:4", &V_BUSINESS_UNIT, &V_PO_ID, &V_LI
NE_NBR, &V_SCHED_NBR, &SALDO_OC);
*/
If All(&V_BUSINESS_UNIT) Then
&SQL_SALDO = "
SELECT ";
&SQL_SALDO = &SQL_SALDO | "
BUSINESS_UNIT , ";
&SQL_SALDO = &SQL_SALDO | "
PO_ID , ";
&SQL_SALDO = &SQL_SALDO | "
LINE_NBR, ";
&SQL_SALDO = &SQL_SALDO | "
SCHED_NBR , ";
&SQL_SALDO = &SQL_SALDO | "
QTY_PO ";
&SQL_SALDO = &SQL_SALDO | " FROM ( SELECT A.BUSINESS_UNIT , ";
&SQL_SALDO = &SQL_SALDO | "
A.PO_ID , ";
&SQL_SALDO = &SQL_SALDO | "
B.LINE_NBR ,";
&SQL_SALDO = &SQL_SALDO | "
C.SCHED_NBR , ";
&SQL_SALDO = &SQL_SALDO | "
A.VENDOR_ID , ";
&SQL_SALDO = &SQL_SALDO | "
A.VNDR_LOC , ";
&SQL_SALDO = &SQL_SALDO | "
A.ADDRESS_SEQ_NUM , ";
&SQL_SALDO = &SQL_SALDO | "
B.ITM_SETID , ";
&SQL_SALDO = &SQL_SALDO | "
B.INV_ITEM_ID , ";
&SQL_SALDO = &SQL_SALDO | "
B.CANCEL_STATUS , ";
&SQL_SALDO = &SQL_SALDO | "
C.DUE_DT , ";
&SQL_SALDO = &SQL_SALDO | "
C.PRICE_PO , ";
&SQL_SALDO = &SQL_SALDO | "
C.QTY_PO - ( SELECT CASE WHEN S
UM(QTY_SH_RECVD) IS NOT NULL THEN ";
&SQL_SALDO = &SQL_SALDO | "
SUM(QTY_SH_RECVD) ";
&SQL_SALDO = &SQL_SALDO | "
ELSE ";
&SQL_SALDO = &SQL_SALDO | "
0 ";
&SQL_SALDO = &SQL_SALDO | "
END VAL ";
&SQL_SALDO = &SQL_SALDO | "
FR
OM SYSADM.PS_RECV_LN_SHIP RS , ";
&SQL_SALDO = &SQL_SALDO | "
SYSADM.PS_RECV_HDR RH ";
&SQL_SALDO = &SQL_SALDO | "
WHE
RE RS.BUSINESS_UNIT = C.BUSINESS_UNIT ";
&SQL_SALDO = &SQL_SALDO | "
A
ND RS.PO_ID = C.PO_ID ";
&SQL_SALDO = &SQL_SALDO | "
A
ND RS.LINE_NBR = C.LINE_NBR ";
&SQL_SALDO = &SQL_SALDO | "
A
ND RS.SCHED_NBR = C.SCHED_NBR ";
&SQL_SALDO = &SQL_SALDO | "
A
ND RH.BUSINESS_UNIT = RS.BUSINESS_UNIT ";
&SQL_SALDO = &SQL_SALDO | "
A
ND RH.RECEIVER_ID = RS.RECEIVER_ID ";
&SQL_SALDO = &SQL_SALDO | "
A
Error ("A quantidade recebida no pode ser maior que Unidade Negocio: " |
&V_BUSINESS_UNIT | " OC: " | &V_PO_ID | " Linha: " | &V_LINE_NBR | " Programao: "
| &V_SCHED_NBR | " Quantidade: " | &SALDO_OC);
End-If;
End-If;
End-If;
/***************************** mmcb.HD47226.en *****************************/
=
=
=
=
GetLevel0();
&RS0(1).GetRowset(Scroll.RECV_LN_SHIP);
&RS1(1).GetRecord(Record.MMC_PO_DET_WRK);
&RS0(1).GetRecord(Record.MMC_PO_DET_WRK);
&TOTAL = 0;
For &i = 1 To &RS1.ActiveRowCount
&QTY_REC = 0;
&VALOR_UNT = 0;
&VALOR_TOTAL = 0;
&QTY_REC = &RS1(&i).RECV_LN_SHIP.QTY_SH_RECVD.Value;
&VALOR_UNT = &RS1(&i).GetRecord(Record.MMC_PO_DET_WRK).PRICE_PO.Value;
&VALOR_TOTAL = &VALOR_UNT * &QTY_REC;
&TOTAL = &TOTAL + &VALOR_TOTAL
End-For;
&RS3.PRICE_BASE.Value = &TOTAL;
End-If;*/
/***************************** MMCB.AT1923 - E.N *******************************
/
[RECV_LN_SHIP.QTY_SH_RECVD.PrePopup]
Evaluate %Panel
When = Panel.RECV_WPO
/* Disable menu entry if transaction already processed by interface(s) */
If RECV_LN_MATCH_OPT = "F" Or
MOVE_STAT_INV = "M" Or
MOVE_STAT_AM = "M" Or
MOVE_STAT_MFG = "M" Then
DisableMenuItem(BarName.RECV_QTY_CLONE_POPUP, ItemName.RECV_QTY_CLONE);
End-If;
End-Evaluate;
[RECV_LN_SHIP.QTY_SH_RECVD.SaveEdit]
/* Valmir Tavares - HQS - Validar quantidade recebida - Inicio */
/*
If %Component = "RECV_PO" Then
&SHIP_ROW = CurrentRowNumber();
&QTY_RECEBIDA = FetchValue(QTY_SH_RECVD, &SHIP_ROW);
&INV_ITEM_ID = FetchValue(INV_ITEM_ID, &SHIP_ROW);
&BU_PO = FetchValue(BUSINESS_UNIT_PO, &SHIP_ROW);
&PO_ID = FetchValue(PO_ID, &SHIP_ROW);
SQLExec("SELECT B.QTY_PO FROM PS_PO_LINE A, PS_PO_LINE_SHIP B WHERE A.BUSINES
S_UNIT = B.BUSINESS_UNIT AND A.PO_ID = B.PO_ID AND A.LINE_NBR = B.LINE_NBR AND A
.BUSINESS_UNIT = :1 AND A.PO_ID = :2 AND A.INV_ITEM_ID = :3", &BU_PO, &PO_ID, &I
NV_ITEM_ID, &QTY_PO);
If All(&QTY_PO) Then
&QTY_RECV = &QTY_RECEBIDA - PO_PICK_ORD_WS.QTY_PRIOR_RECEIPT;
If &QTU_RECV > &QTY_PO Then
Error ("A quantidade recebida no pode ser maior que a quantidade da OC."
);
End-If;
End-If;
End-If;
*/
/* Valmir Tavares - HQS - Validar quantidade recebida - Fim */
[RECV_LN_SHIP.QTY_SH_RECVD_SUOM.FieldChange]
/* RECV_LN_SHIP.QTY_SH_RECVD_SUOM.FIELDCHANGE */
/* Update Received Qty for Schedule ------------------------- */
Declare Function Fch_QtyShAccptSuom PeopleCode QTY_SH_ACCPT_SUOM FieldChange;
Function Fch_QtyShRecvdSuom();
remark change std uom qty for current Receipt schedule;
&SHIP_ROW = CurrentRowNumber();
&CONV = FetchValue(CONVERSION_RATE, &SHIP_ROW);
&CR = (1 / &CONV);
QTY_SH_RECVD_VUOM = QTY_SH_RECVD_SUOM * &CR;
remark default accepted qty if no inspection required;
&INSPECT_CD = FetchValue(INSPECT_CD, &SHIP_ROW);
If &INSPECT_CD = "N" Then
If None(QTY_SH_ACCPT_SUOM) Then
QTY_SH_ACCPT_SUOM = QTY_SH_RECVD_SUOM;
Fch_QtyShAccptSuom();
End-If;
End-If;
End-Function;
/* MainLine
------------- */
Fch_QtyShRecvdSuom();
[RECV_LN_SHIP.QTY_SH_RECVD_VUOM.FieldChange]
/* RECV_LN_SHIP.QTY_SH_RECVD_VUOM.FIELDCHANGE */
/* Update Received Qty for Schedule ----------------------------------- */
Declare Function Fch_QtyShAccptVuom PeopleCode QTY_SH_ACCPT_VUOM FieldChange;
Function Fch_QtyShRecvdVuom();
remark change std uom qty for current Receipt schedule;
&SHIP_ROW = CurrentRowNumber();
&CR = FetchValue(CONVERSION_RATE, &SHIP_ROW);
QTY_SH_RECVD_SUOM = QTY_SH_RECVD_VUOM * &CR;
remark default accepted qty if no inspection required;
&INSPECT_CD = FetchValue(INSPECT_CD, &SHIP_ROW);
If &INSPECT_CD = "N" Then
If None(QTY_SH_ACCPT_VUOM) Then
QTY_SH_ACCPT_VUOM = QTY_SH_RECVD_VUOM;
Fch_QtyShAccptVuom();
End-If;
End-If;
End-Function;
/* MainLine
------------- */
Fch_QtyShRecvdVuom();
[RECV_LN_SHIP.QTY_SH_REJCT.FieldChange]
/* RECV_LN_SHIP.QTY_SH_REJCT.FIELDCHANGE */
/* Update Rejected Qty for Schedule and Sum Up to Receipt Line
------------------------------------------ */
Declare Function Fch_QtyShAccptRuom PeopleCode QTY_SH_ACCPT FieldChange;
Declare Function qty_precision_round PeopleCode FUNCLIB_FS.QTY_PRECISION FieldFo
rmula;
Function Fch_QtyShRejctRuom();
&SHIP_ROW = CurrentRowNumber();
remark change receipt uom qty for current Receipt schedule;
&CR_RUOM_TO_VUOM = FetchValue(CONVERT_TO_PO, &SHIP_ROW);
&CR_RUOM_TO_SUOM = FetchValue(CONVERT_TO_STK, &SHIP_ROW);
&CONVERT_STK_TO_STD = FetchValue(CONVERT_STK_TO_STD, &SHIP_ROW);
&PRIOR_REJ_VUOM = FetchValue(QTY_SH_REJCT_VUOM, &SHIP_ROW);
&SETID = FetchValue(ITM_SETID, &SHIP_ROW);
&INV_ITEM_ID = FetchValue(INV_ITEM_ID, &SHIP_ROW);
&RECEIVE_UOM = FetchValue(RECEIVE_UOM, &SHIP_ROW);
&QTY_SH_REJCT = FetchValue(QTY_SH_REJCT, &SHIP_ROW);
&CONVERT_TO_RECV = 1.0;
&QTY_PRECISION = "";
&ROUND_RULE = "";
qty_precision_round(&SETID, " ", &QTY_SH_REJCT, &INV_ITEM_ID, &RECEIVE_UOM, "
", &QTY_PRECISION, &ROUND_RULE, &CONVERT_TO_RECV);
QTY_SH_REJCT = &QTY_SH_REJCT;
/* 07-18-02 EW Incident #510059002 Begin */
/* &QTY_SH_REJCT_SUOM = Round(QTY_SH_REJCT * &CR_RUOM_TO_SUOM, 4); */
&QTY_SH_REJCT_SUOM = Round(QTY_SH_REJCT * &CR_RUOM_TO_SUOM * &CONVERT_STK_TO_
STD, 4);
&UNIT_MEASURE_STD = FetchValue(UNIT_MEASURE_STD, &SHIP_ROW);
&QTY_PRECISION = "";
&ROUND_RULE = "";
&PRIOR_QTY = PriorValue(QTY_SH_REJCT);
RECV_LN_SHIP_WK.QTY_SH_REJCT = &PRIOR_QTY;
End-If;
End-If;
End-If;
AdjAcceptQty();
[RECV_LN_SHIP.QTY_SH_REJCT_SUOM.FieldChange]
/* RECV_LN_SHIP.QTY_SH_REJCT_SUOM.FIELDCHANGE */
/* Update Rejected Qty for Schedule and Sum Up to Receipt Line
------------------------------------------ */
Function Fch_QtyShRejctSuom();
remark change std uom qty for current Receipt schedule;
&SHIP_ROW = CurrentRowNumber();
&CONV = FetchValue(CONVERSION_RATE, &SHIP_ROW);
&CR = (1 / &CONV);
QTY_SH_REJCT_VUOM = QTY_SH_REJCT_SUOM * &CR;
End-Function;
/* MainLine
------------- */
If Not IsModal() Then
Fch_QtyShRejctSuom();
End-If;
If None(QTY_SH_REJCT_SUOM) Then
REJECT_ACTION = "";
REJECT_REASON = "";
RMA_ID = "";
RMA_LINE_NBR = 0;
End-If;
[RECV_LN_SHIP.QTY_SH_REJCT_VUOM.FieldChange]
/* RECV_LN_SHIP.QTY_SH_REJCT_VUOM.FIELDCHANGE */
/* Update Rejected Qty for Schedule and Sum Up to Receipt Line
------------------------------------------ */
Function Fch_QtyShRejctVuom();
remark change std uom qty for current Receipt schedule;
&SHIP_ROW = CurrentRowNumber();
&CR = FetchValue(CONVERSION_RATE, &SHIP_ROW);
QTY_SH_REJCT_SUOM = QTY_SH_REJCT_VUOM * &CR;
End-Function;
/* MainLine
------------- */
If Not IsModal() Then
Fch_QtyShRejctVuom();
End-If;
If None(QTY_SH_REJCT_VUOM) Then
REJECT_ACTION = "";
REJECT_REASON = "";
RMA_ID = "";
RMA_LINE_NBR = 0;
End-If;
[RECV_LN_SHIP.RECEIPT_DTTM.SavePreChange]
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-21/06/01
Para as funcionalidades de Cancelamento / Reabertura / Deleo / Encerramento de Doc
1 CASE
* CR = BOX
1 CASE
* 2 (Box/Case) = 2 Boxes
Conv_Rate = Uom_To/Uom_From
= (Std Uom/Uom_From)/(Std Uom/Uom_To)
= (Std Uom/CASE/ Std Uom/BOX)
= 12/6 = 2 box/case
The Conversion rate to std are always found by first looking in the item vendor
uom table, itm_vndr_uom, for a conversion rate to the std uom
10001 Office Depot CASE 12
10001 Office Depot BOX
6
if these conversion rates are found, then the ratio between these two ratios
is the
conversion rate between the two uoms
EA/CASE = 12 ( 1 CASE * EA/CASE (12) = 12 EA)
EA/BOX = 6
BOX/CASE = 12/6 = 2 ( 1 CASE * BOX/CASE (2) = 2 BOXES)
if an item does not have a vendor specific conversion rate to std then the c
onversion rate for that item to the std uom is looked for in the general uom tab
le,
ps_convert_tbl, by calling get_conv_rate(uom, std uom , conv rate).
This means that depending on the type of conversion rate you are trying to fi
nd
you may have to repeat the search for each uom.
Uom From - Uom To ( Case to Box )
(Convert_to_Stk or Conversion_Rate type)
ItmVndrConversionRate( Case, Conv_Rate1 )
if not found call Get_Conv_Rate( Case, EA, Conv_Rate1)
(Convert_to_Stk or Conversion_Rate type)
ItmVndrConversionRate( Box, Conv_Rate2 )
if not found call Get_Conv_Rate( Box, EA, Conv_Rate2)
take ratio, Convert Rate = Conv_Rate1/Conv_Rate2
(Convert_To_Po type)
*/
Function RecvUom(&LINE_ROW) Returns boolean ;
&CONVERSION_RATE = FetchValue(CONVERSION_RATE, &LINE_ROW);
&CONVERT_STK_TO_STD = FetchValue(CONVERT_STK_TO_STD, &LINE_ROW);
&RECEIVE_UOM = FetchValue(RECEIVE_UOM, &LINE_ROW);
&RECV_STOCK_UOM = FetchValue(RECV_STOCK_UOM, &LINE_ROW);
&STD_UOM = FetchValue(UNIT_MEASURE_STD, &LINE_ROW);
&ITM_SETID = FetchValue(ITM_SETID, &LINE_ROW);
&INV_ITEM_ID = FetchValue(INV_ITEM_ID, &LINE_ROW);
&VENDOR_SETID = RECV_HDR.VENDOR_SETID;
&VENDOR_ID = RECV_HDR.VENDOR_ID;
&VNDR_LOC = RECV_HDR.VNDR_LOC;
ItmVndrLocConvRate(&ITM_SETID, &INV_ITEM_ID, &VENDOR_SETID, &VENDOR_ID, &VNDR
_LOC, &RECEIVE_UOM, &CONVERT_TO_STD);
If None(&CONVERT_TO_STD) Then
GetItmConvRate(&ITM_SETID, &INV_ITEM_ID, &RECEIVE_UOM, &CONVERT_TO_STD);
If None(&CONVERT_TO_STD) Then
Get_Conv_Rate(&RECEIVE_UOM, &STD_UOM, &CONVERT_TO_STD);
End-If;
End-If;
If All(&CONVERT_TO_STD) Then
&CONVERT_TO_PO = Round(&CONVERT_TO_STD / &CONVERSION_RATE, 8);
GrayRecvLn(&LINE_ROW);
End-If;
/*
PO8.0SP1 End
*/
If MOVE_STAT_INV = "M" Then
Gray(RECV_HDR_WK.PB_CANCEL_RECPT);
Gray(RECV_HDR_WK.PB_RECV_STATUS);
Gray(RECV_LN_WK.PB_CANCEL_ITEM);
Gray(RECV_HDR.HOLD_INVENTORY);
/* R-DSWIRS-PM6NF RT 11/13/2001
Gray(RECV_HDR_WK.CB_HOLD_RECPT); */
Gray(QTY_SH_ACCPT);
Gray(QTY_SH_INSPD);
Gray(QTY_SH_RECVD);
Gray(QTY_SH_REJCT);
Gray(RECEIVE_UOM);
End-If;
If RECV_SHIP_STATUS = "M" Then
Gray(RECV_HDR_WK.PB_RECV_STATUS);
End-If;
/* * * PO 8.02 Prf (End) */
If %Mode <> "A" Then
&LINE_ROW = CurrentRowNumber();
&RECV_BU = BUSINESS_UNIT;
&RECV_ID = RECEIVER_ID;
&RECV_LN = RECV_LN_NBR;
&TABLE = "S";
&PANELGROUP = %PanelGroup;
check_rtv(&RECV_BU, &RECV_ID, &RECV_LN, &TABLE, &LINE_ROW, &DIST_ROW, &ASS
ET_ROW, &PANELGROUP);
/* 101899 - re-activate code to set AM & INV Stat hyperlinks */
/* * * PO 8.02 Prf (Start) */
&CURR_ROW = CurrentRowNumber();
&rs_data = GetLevel0()(1).GetRowset(Scroll.RECV_LN_SHIP);
&rs_data(&CURR_ROW).RECV_LN_SHIP_WK.DESCR.Label = Substring(&rs_data(&CURR
_ROW).RECV_LN_SHIP.DESCR254_MIXED.Value, 1, 30);
If MOVE_STAT_AM = "N" Then
Hide(RECV_LN_SHIP_WK.MOVE_STAT_AM);
Else
GetShortXlatName("MOVE_STAT_AM", MOVE_STAT_AM, &SHORTDESC);
&rs_data(&CURR_ROW).RECV_LN_SHIP_WK.MOVE_STAT_AM.Label = &SHORTDESC;
End-If;
If MOVE_STAT_INV = "N" Then
Hide(RECV_LN_SHIP_WK.MOVE_STAT_INV);
Else
GetShortXlatName("MOVE_STAT_INV", MOVE_STAT_INV, &SHORTDESC);
&rs_data(&CURR_ROW).RECV_LN_SHIP_WK.MOVE_STAT_INV.Label = &SHORTDESC;
End-If; /* 101899 - end of reactivated code */
&DEVICE_TRACK = FetchValue(DEVICE_TRACKING, &CURR_ROW);
If &DEVICE_TRACK = "N" Then
Hide(RECV_LN_SHIP_WK.GOTO_DEVICE_TRK, &CURR_ROW);
Else
UnHide(RECV_LN_SHIP_WK.GOTO_DEVICE_TRK, &CURR_ROW);
GetShortXlatName("GOTO_DEVICE_TRK", &DEVICE_TRACK, &SHORTDESC);
&rs_data(&CURR_ROW).RECV_LN_SHIP_WK.GOTO_DEVICE_TRK.Label = &SHORTDESC;
End-If;
End-If;
If RECV_HDR.PO_RECEIPT_FLG = "Y" Then
Gray(DEVICE_TRACKING);
End-If;
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-BEGIN-19/01/01 */
End-If;
/* BRLOC-PO-SAM-RELEASE 8.0-NEW-END-19/01/01 */
[RECV_LN_SHIP.RECV_STOCK_UOM.FieldChange]
Declare Function GetStockUOMRate PeopleCode FUNCLIB_RECV.RECEIVER_STATUS FieldFo
rmula;
Function ChgStkUom()
GetStockUOMRate(ITM_SETID, INV_ITEM_ID, RECV_STOCK_UOM, &CNV_RATE);
If None(&CNV_RATE) Then
&CNV_RATE = 1.0;
End-If;
CONVERT_TO_STK = Round((CONVERSION_RATE * (1 / &CNV_RATE)), 8);
CONVERT_STK_TO_STD = &CNV_RATE;
End-Function;
/*
Mainline */
If RECV_LN_WK.UOM_CONV_FLAG <> "0" Then
&PREV_STK_UOM = PriorValue(RECV_STOCK_UOM);
remark warn user that changing the stocking UOM will disable certain batch fu
nctionality;
&MSGBOXTEXT = MsgGetText(10300, 143, "Missing Message.");
&RETURN_CD = MessageBox(36, &MSGBOXTEXT, 10300, 144, "Missing Message.");
If &RETURN_CD <> 6 Then
RECV_STOCK_UOM = &PREV_STK_UOM;
Else
ChgStkUom();
End-If;
Else
ChgStkUom();
End-If;
[RECV_LN_SHIP.RECV_STOCK_UOM.FieldEdit]
/* RECV_LN_SHIP.RECV_STOCK_UOM.FieldEdit
*/
/* * * PO 8.02 Prf (Start)
*/
If RECV_HDR.PO_RECEIPT_FLG = "N" And
None(INV_ITEM_ID) Then
Error MsgGet(10300, 221, "Missing Message.");
End-If;
/* * * PO 8.02 Prf (End)
*/
[RECV_LN_SHIP.REJECT_REASON.SaveEdit]
/* RECV_LN_SHIP.REJECT_REASON.SAVEEDIT */
/* must provide a rejection reason if item rejected
-------------------------- */
If RECV_SHIP_STATUS <> "X" Then
If All(QTY_SH_REJCT) Then
If None(REJECT_REASON) Then
Error (MsgGet(10300, 41, "Missing Message."));
Else
If None(REJECT_ACTION) Then
Error (MsgGet(10300, 42, "Missing Message."));
End-If;
End-If;
End-If;
End-If;
[RECV_LN_SHIP.REVISION.FieldChange]
/* RECV_LN_SHIP.REVISION FieldChange */
Declare Function GetPORev PeopleCode FUNCLIB_RECV.RECEIVER_STATUS FieldFormula;
&SHIP_ROW = CurrentRowNumber();
GetPORev(BUSINESS_UNIT_PO, PO_ID, LINE_NBR, SCHED_NBR, &POREV);
If All(&POREV) And
REVISION <> &POREV Then
&MSGBOXTEXT = MsgGetText(10300, 155, "Missing Message.");
&RETURN_CD = MessageBox(36, &MSGBOXTEXT, 10300, 156, "Missing Message.", &POR
EV);
If &RETURN_CD <> 6 Then
REVISION = PriorValue(REVISION, &SHIP_ROW);
End-If;
End-If;
[DFI_CANCEL_PBL.GBL.SavePostChange]
Declare Function MMC_Registro_Saida_REV PeopleCode MMC_TERC_WRK.BUSINESS_UNIT_IN
FieldFormula;
Declare Function MMC_Registro_Saida PeopleCode MMC_TERC_WRK.BUSINESS_UNIT_IN Fie
ldFormula;
/* MMC - NFC - 15/02/06 */
Local Rowset &NF_Retorno, &NF_Retorno_Linhas;
Local SQL &sql_BCT, &sql_MMC_TERC_OC;
Local Record &MMC_TERC_REC;
Local Record &MMC_TERC_OC_REC;
Local Record &MMC_TERC_TRI_REC;
Local Record &MMC_TRANS_TERC_REC;
Local Rowset &BCT_CTL_RS;
Local Row &BCT_CTL_ROW;
Local Row &BCT_DTL_ROW;
Local Record &BCT_CTL_REC;
Local Record &BCT_DTL_REC;
Local Rowset &RS_ALL, &RS;
Local Record &recHDR, &recLN;
If NF_BRL_PNL_WRK.NF_CANCEL_PBL_PB.Value = "Y" Then
/* Fluxo Reverso de Processos */
&recHDR = CreateRecord(Record.NF_HDR_BRL);
&recLN = CreateRecord(Record.NF_LN_BRL);
&BUSINESS_UNIT = NF_HDR_BRL.BUSINESS_UNIT.Value;
&NF_BRL_ID = NF_HDR_BRL.NF_BRL_ID.Value;
&SQL1
F_BRL_ID
&SQL2
F_BRL_ID
=
=
=
=
While &SQL1.Fetch(&recHDR)
&recHDR.CopyFieldsTo(&RS_ALL(1).NF_HDR_BRL);
&I = 1;
While &SQL2.Fetch(&recLN)
If &I > 1 Then
rem &RS.InsertRow(&I - 1);
&NF_Retorno_Linhas.InsertRow(&I - 1);
End-If;
rem &recLN.CopyFieldsTo(&RS(&I).NF_LN_BRL);
&recLN.CopyFieldsTo(&NF_Retorno_Linhas(&I).NF_LN_BRL);
&I = &I + 1;
End-While;
End-While;
MMC_Registro_Saida_REV(&RS_ALL);
/*Reversin de Entrada con parmetro "D" = sentido*/
MMC_Registro_Saida(&RS_ALL, "D");
/**** Dados na tabela MMC_TERC ****/
SQLExec("delete from PS_MMC_TERC WHERE BUSINESS_UNIT_PO =:1 AND MMC_RETORNO_B
RL_ID=:2", &RS_ALL(1).NF_HDR_BRL.BUSINESS_UNIT.Value, &RS_ALL(1).NF_HDR_BRL.NF_B
RL_ID.Value);
/**** ****/
/**** MMC_TRANS_TERC ****/
SQLExec("delete from PS_MMC_TRANS_TERC WHERE BUSINESS_UNIT_PO =:1 AND MMC_RE
TORNO_BRL_ID=:2", &RS_ALL(1).NF_HDR_BRL.BUSINESS_UNIT.Value, &RS_ALL(1).NF_HDR_B
RL.NF_BRL_ID.Value);
/**** ****/
/**** MMC_TERC_TRI ****/
SQLExec("delete from PS_MMC_TERC_TRI WHERE BUSINESS_UNIT =:1 AND NF_BRL_ID=:2
", &RS_ALL(1).NF_HDR_BRL.BUSINESS_UNIT.Value, &RS_ALL(1).NF_HDR_BRL.NF_BRL_ID.Va
lue);
/**** ****/
/**** MMC_TERC_OC ****/
&sql_MMC_TERC_OC = CreateSQL("select BUSINESS_UNIT_PO, PO_ID FROM PS_MMC_TERC
_OC WHERE BUSINESS_UNIT =:1 AND NF_BRL_ID=:2", &RS_ALL(1).NF_HDR_BRL.BUSINESS_UN
IT.Value, &RS_ALL(1).NF_HDR_BRL.NF_BRL_ID.Value);
While &sql_MMC_TERC_OC.Fetch(&BUSINESS_UNIT_PO, &PO_ID)
SQLExec("delete from PS_MMC_TERC_OC WHERE BUSINESS_UNIT =:1 AND NF_BRL_ID=
:2 and LINE_NBR=:3", &RS_ALL(1).NF_HDR_BRL.BUSINESS_UNIT.Value, &RS_ALL(1).NF_HD
R_BRL.NF_BRL_ID.Value, &NF_Retorno_Linhas(&j).NF_LN_BRL.LINE_NBR.Value);
SQLExec("Update PS_PO_HDR Set RECV_STATUS = 'P' Where BUSINESS_UNIT = :1 A
nd PO_ID = :2", &BUSINESS_UNIT_PO, &PO_ID);
End-While;
/**** Producto acabado ****/
/*Proyecto: MMC_CT_08 - Sara Costas - 22feb2006 - Procuro as claves da tabela
PS_BCT_CTL relacionadas com a NF- Inicio*/
SQLExec("select BUSINESS_UNIT_1, EIP_CTL_ID FROM PS_MMC_BCT_AUX WHERE BUSINES
S_UNIT =:1 AND NF_BRL_ID =:2 ", &RS_ALL(1).NF_HDR_BRL.BUSINESS_UNIT.Value, &RS_A
LL(1).NF_HDR_BRL.NF_BRL_ID.Value, &BUSINESS_UNIT, &EIP_CTL_ID);
/*Proyecto: MMC_CT_08 - Sara Costas - 22feb2006 - Procuro as claves da tabela
PS_BCT_CTL relacionadas com a NF- Fin*/
[NF_INFO_PBL.GBL.PreBuild]
/*******************************************************************************
*****************
* Wagner Sorio / Claudio Costa - MMC - 13/12/2007 - mmcb.at2323 - Sistema Contr
ole Terceiros *
* Customizao Sistema de Terceiros - Oculta Pagina de Industrializao
*
*******************************************************************************
*****************/
/* BRLPO - HAT - RELEASE 8.00 - 05/01/01 - Quando Type Writer Hide para seleo de R
ecebimento Fsico */
Hide(RCV_PICK_PBL_WK.SELECT_RCV_ALL_BRL);
/* BRLPO - HAT - RELEASE 8.00 - 05/01/01 - END */
/* MMC - NFC - 23/01/2006 */
MMC_NF_HDR_WRK.BUSINESS_UNIT.Visible = True;
/* MMC - NFC */
Rowset
Rowset
number
number
string
Record
Rowset
Rowset
&Level1;
&Level2;
&RecibidoTodo;
&Recibido;
&Status;
&MMC_PO_TERCO_VW;
&AuxLevel2;
&Level1NFServ;
/* MMC - ASM */
/* WSG */
Global Rowset &MMC_NF_Retorno_LinhasOC;
/* WSG */
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 21/06/2006 - Inicio */
Global boolean &criou_RS_MMC_TERC_OC;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 21/06/2006 - Fim */
&MMC_TERC_REC = CreateRecord(Record.MMC_TERC);
&MMC_TRANS_TERC_REC = CreateRecord(Record.MMC_TRANS_TERC);
&LinhasRS = GetLevel0()(1).GetRowset(Scroll.NF_LN_BRL);
/* Alterado por Welbe S. de Gasperi - Grupo Quanam - 07/03/2006 - Incio */
If NF_HDR_INFO_WRK.NF_BRL_STATUS.Value = "F" Then
/* Alterado por Welbe S. de Gasperi - Grupo Quanam - 07/03/2006 - Fim */
If &MMC_ENTRAPOR_ITEM = True Or
&MMC_ENTRAPOR_PACABADO = True Or
&MMC_ENTRAPOR_PACABADONF = True Or
&MMC_ENTRAPOR_TRIANGULACAO = True Then
If &MMC_Controle_Terceiros = True Then
/* MMC - NF - 06/01/2006 : Funo que permite simular a sada mercadoria. Uti
liza-se o Component Interface MMC_TRANS_CI, que esta unido ao componente PUTAWAY
_ENTRY1_INV (Rota: Home > Controlar Estoque > Armazenar Estoque > Usar > Armazen
agem Expressa) */
/*Proyecto: MMC_CT_02_02 - Invoca funo sada de mercadoria e comenta a funo M
MC_Registro_Saida_O_Entrada- Sara Costas - 07feb2006 - Inicio*/
rem MMC_Registro_Saida_O_Entrada(GetLevel0(), "S");
If All(&BU_CONTROL_REMESSA_TERC) Then
MMC_Registro_Entrada(GetLevel0(), "R", &BU_CONTROL_REMESSA_TERC);
Else
MMC_Registro_Saida(GetLevel0(), "O");
/*Proyecto: MMC_CT_02_02 - Invoca funo entrada de mercadoria e comenta
a funo MMC_Registro_Saida_O_Entrada - Sara Costas - 07feb2006 - Fin*/
rem MMC_Registro_Saida_O_Entrada(GetLevel0(), "E");
/* MMC - ASM - Si es item de servicio se inserta entrada (020) y se
llama a la funcion de Entrada con parametro "S" (Servicio) */
/* MMC - ASM - 23/02/2006 - El valor de CFO_BRL_CD se debe obtener e
n la linea, del campo CFOP_INCOM_PBL*/
SQLExec("Select MMC_CNTRL_TERC From PS_CFO_BRL_TBL Where SETID = :1
And CFO_BRL_CD = :2 And MMC_CNTRL_TERC = 'Y'", &LinhasRS(1).NF_LN_BRL.ITM_SETID.
Value, &LinhasRS(1).NF_LN_BRL.CFOP_INCOM_PBL.Value, &MMC_CNTRL_TERC);
If &MMC_CNTRL_TERC = "Y" Then
MMC_Registro_Entrada(GetLevel0(), "S", "");
Else
MMC_Registro_Entrada(GetLevel0(), "C", "");
End-If;
/* MMC - ASM */
&MMC_TRANS_TERC_REC = &MMC_TRANS_TERC_RS(&k).MMC_TRANS_TERC;
&MMC_TRANS_TERC_REC.MMC_RETORNO_BRL_ID.Value = NF_HDR_BRL.NF_B
RL_ID.Value;
&MMC_TRANS_TERC_REC.DATE_TO.Value = NF_HDR_BRL.NF_BRL_DATE.Val
ue;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 27/06/200
6 - Inicio */
/* Valorizao da Linha da NF em MMC_TRANS_TERC, para vincular com
TRANSACTION_INV e
considerar o mesmo item da mesma NF de Remessa.
Quando for por Item, basta valorizar com o nmero sequencial.
Quando for por Produto Acabado ou Produto Acabado-NF,
verifica-se se o mesmo item e a mesma quantidade */
If &MMC_ENTRAPOR_ITEM = True Then
&MMC_TRANS_TERC_REC.NF_BRL_LINE_NUM.Value = &k;
Else
If &MMC_ENTRAPOR_PACABADO = True Or
&MMC_ENTRAPOR_PACABADONF = True Then
For &ix = &k To &LinhasRS.ActiveRowCount
If &LinhasRS.GetRow(&ix).NF_LN_BRL.INV_ITEM_ID.Value
= &MMC_TRANS_TERC_RS(&k).MMC_TRANS_TERC.INV_ITEM_ID.Value And
&LinhasRS.GetRow(&ix).NF_LN_BRL.QTY_NF_BRL.Valu
e = (&MMC_TRANS_TERC_RS(&k).MMC_TRANS_TERC.QTY.Value * - 1) Then
&MMC_TRANS_TERC_REC.NF_BRL_LINE_NUM.Value = &ix;
Break;
End-If;
End-For;
End-If;
End-If;
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 27/06/200
6 - Fim */
&MMC_TRANS_TERC_REC.Insert();
End-If; /* FABIO - 29/06/2006 */
End-For;
/**** Producto acabado ****/
/* Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 06/06/2006 - In
icio
Colocada condio 1 = 0 para no executar os comandos abaixo
Projeto MMC_CT_09 - Fabio Sobral - Grupo Quanam - 06/06/2006 - Fi
m */
If All(&MMC_Produto_Acabado, &MMC_Cantidad_Produto_Acabado) And
1 = 0 Then
For &i = 1 To &BCT_CTL_RS.ActiveRowCount
&BCT_CTL_ROW = &BCT_CTL_RS(&i);
&BCT_CTL_ROW.BCT_CTL_REC.Insert();
/*Proyecto: MMC_CT_08 - Sara Costas - 22feb2006 - Insert em ta
bela auxliar que relaciona a NF com a tabela BCT_CTL, para a cancelamento da NF
- Inicio*/
&MMC_BCT_AUX_REC = CreateRecord(Record.MMC_BCT_AUX);
&MMC_BCT_AUX_REC.BUSINESS_UNIT.value = NF_HDR_BRL.BUSINESS_UNI
T.Value;
&MMC_BCT_AUX_REC.NF_BRL_ID.value = NF_HDR_BRL.NF_BRL_ID.Value;
&MMC_BCT_AUX_REC.BUSINESS_UNIT_1.VALUE = &BCT_CTL_ROW.BCT_CTL_
REC.BUSINESS_UNIT.Value;
&MMC_BCT_AUX_REC.EIP_CTL_ID.value = &BCT_CTL_ROW.BCT_CTL_REC.E
IP_CTL_ID.Value;
&MMC_BCT_AUX_REC.INSERT();