User Function MT103IPC()Local n := ParamIXB[1]
Local nPosItem := aScan(aHeader,{|x| Alltrim(x[2]) == 'D1_ITEM'})
Local aSavCols := aClone(aCols)
Local aSavHeader := aClone(aHeader)
Local nPosRat := aScan(aRatAFN,{|x| x[1] == aCols[n][nPosItem]})
aHeader := {}
If nPosRat == 0
aAdd(aRatAFN,{aCols[n][nPosItem],{}})
nPosRat := Len(aRatAFN)
Else
aRatAFN[nPosRat][2] := {}
EndIf
If !Empty(SC7->C7_NUMSC)
//ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
//³ Montagem do aHeader ³
//ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
dbSelectArea('SX3')
dbSetOrder(1)
MsSeek('AFN')
While !EOF() .And. (x3_arquivo == 'AFN')
IF X3USO(x3_usado) .AND. cNivel >= x3_nivel
AADD(aHeader,{ TRIM(x3titulo()), x3_campo, x3_picture,;
x3_tamanho, x3_decimal, x3_valid,;
x3_usado, x3_tipo, x3_arquivo,x3_context } )
Endif
If AllTrim(x3_campo) == 'AFN_QUANT'
nPosPerc := Len(aHeader)
EndIf
dbSkip()
End
If ( !Empty(SC7->C7_NUMSC) )
If ( SC7->C7_TIPO==1 )
If ( Empty(SC7->C7_NUMCOT) )
dbSelectArea('SC1')
dbSetOrder(1)
If MsSeek(xFilial('SC1')+SC7->C7_NUMSC+SC7->C7_ITEMSC)
dbSelectArea('AFG')
dbSetOrder(2)
MsSeek(xFilial()+SC1->C1_NUM+SC1->C1_ITEM)
nPosRat := aScan(aRatAFN,{|x| x[1] == aCols[n][nPosItem]})
While !Eof() .And. xFilial()+SC1->C1_NUM+SC1->C1_ITEM==;
AFG_FILIAL+AFG_NUMSC+AFG_ITEMSC
If AFG->AFG_REVISA==PmsAF8Ver(AFG->AFG_PROJET)
aADD(aRatAFN[nPosRat][2],Array(Len(aHeader)+1))
For ny := 1 to Len(aHeader)
Do Case
Case Alltrim(aHeader[ny][2]) == 'AFN_PROJET'
aRatAFN[nPosRat][2][Len(aRatAFN[nPosRat][2])][ny] := AFG->AFG_PROJET
Case Alltrim(aHeader[ny][2]) == 'AFN_TAREFA'
aRatAFN[nPosRat][2][Len(aRatAFN[nPosRat][2])][ny] := AFG->AFG_TAREFA
Case Alltrim(aHeader[ny][2]) == 'AFN_REVISA'
aRatAFN[nPosRat][2][Len(aRatAFN[nPosRat][2])][ny] := AFG->AFG_REVISA
Case Alltrim(aHeader[ny][2]) == 'AFN_QUANT'
aRatAFN[nPosRat][2][Len(aRatAFN[nPosRat][2])][ny] := AFG->AFG_QUANT
Case Alltrim(aHeader[ny][2]) == 'AFN_TRT'
aRatAFN[nPosRat][2][Len(aRatAFN[nPosRat][2])][ny] := AFG->AFG_TRT
EndCase
aRatAFN[nPosRat][2][Len(aRatAFN[nPosRat][2])][Len(aHeader)+1] := .F.
Next ny
EndIf
dbSelectArea('AFG')
dbSkip()
End
EndIf
Else
dbSelectArea('SC8')
dbSetOrder(3)
If MsSeek(xFilial('SC8')+SC7->C7_NUMCOT+SC7->C7_PRODUTO+SC7->C7_FORNECE+SC7->C7_LOJA+SC7->C7_NUM+SC7->C7_ITEM)
dbSelectArea('SC1')
dbSetOrder(5)
MsSeek(xFilial('SC1')+SC8->C8_NUM+SC8->C8_PRODUTO+SC8->C8_IDENT)
While ( !Eof() .And. xFilial('SC1') == SC1->C1_FILIAL .And.;
SC8->C8_NUM == SC1->C1_COTACAO .And.;
SC8->C8_PRODUTO == SC1->C1_PRODUTO .And.;
SC8->C8_IDENT == SC1->C1_IDENT )
dbSelectArea('AFG')
dbSetOrder(2)
MsSeek(xFilial()+SC1->C1_NUM+SC1->C1_ITEM)
While !Eof() .And. xFilial()+SC1->C1_NUM+SC1->C1_ITEM==;
AFG_FILIAL+AFG_NUMSC+AFG_ITEMSC
If AFG->AFG_REVISA==PmsAF8Ver(AFG->AFG_PROJET)
aADD(aRatAFN[nPosRat][2],Array(Len(aHeader)+1))
For ny := 1 to Len(aHeader)
Do Case
Case Alltrim(aHeader[ny][2]) == 'AFN_PROJET'
aRatAFN[nPosRat][2][Len(aRatAFN[nPosRat][2])][ny] := AFG->AFG_PROJET
Case Alltrim(aHeader[ny][2]) == 'AFN_TAREFA'
aRatAFN[nPosRat][2][Len(aRatAFN[nPosRat][2])][ny] := AFG->AFG_TAREFA
Case Alltrim(aHeader[ny][2]) == 'AFN_REVISA'
aRatAFN[nPosRat][2][Len(aRatAFN[nPosRat][2])][ny] := AFG->AFG_REVISA
Case Alltrim(aHeader[ny][2]) == 'AFN_QUANT'
aRatAFN[nPosRat][2][Len(aRatAFN[nPosRat][2])][ny] := AFG->AFG_QUANT
Case Alltrim(aHeader[ny][2]) == 'AFN_TRT'
aRatAFN[nPosRat][2][Len(aRatAFN[nPosRat][2])][ny] := AFG->AFG_TRT
EndCase
aRatAFN[nPosRat][2][Len(aRatAFN[nPosRat][2])][Len(aHeader)+1] := .F.
Next ny
EndIf
dbSelectArea('AFG')
dbSkip()
End
dbSelectArea('SC1')
dbSkip()
EndDo
EndIf
EndIf
Else
dbSelectArea('SC3')
dbSetOrder(1)
If MsSeek(xFilial('SC3')+SC7->C7_NUMSC+SC7->C7_ITEMSC)
dbSelectArea('AFL')
dbSetOrder(2)
MsSeek(xFilial()+SC3->C3_NUM+SC3->C3_ITEM)
nPosRat := aScan(aRatAFN,{|x| x[1] == aCols[n][nPosItem]})
While !Eof() .And. xFilial()+SC3->C3_NUM+SC3->C3_ITEM==;
AFL_FILIAL+AFL_NUMCP+AFL_ITEMCP
If AFL->AFL_REVISA==PmsAF8Ver(AFL->AFL_PROJET)
aADD(aRatAFN[nPosRat][2],Array(Len(aHeader)+1))
For ny := 1 to Len(aHeader)
Do Case
Case Alltrim(aHeader[ny][2]) == 'AFN_PROJET'
aRatAFN[nPosRat][2][Len(aRatAFN[nPosRat][2])][ny] := AFL->AFL_PROJET
Case Alltrim(aHeader[ny][2]) == 'AFN_TAREFA'
aRatAFN[nPosRat][2][Len(aRatAFN[nPosRat][2])][ny] := AFL->AFL_TAREFA
Case Alltrim(aHeader[ny][2]) == 'AFN_REVISA'
aRatAFN[nPosRat][2][Len(aRatAFN[nPosRat][2])][ny] := AFL->AFL_REVISA
Case Alltrim(aHeader[ny][2]) == 'AFN_QUANT'
aRatAFN[nPosRat][2][Len(aRatAFN[nPosRat][2])][ny] := AFL->AFL_QUANT
Case Alltrim(aHeader[ny][2]) == 'AFN_TRT'
aRatAFN[nPosRat][2][Len(aRatAFN[nPosRat][2])][ny] := AFL->AFL_TRT
EndCase
aRatAFN[nPosRat][2][Len(aRatAFN[nPosRat][2])][Len(aHeader)+1] := .F.
Next ny
EndIf
dbSelectArea('AFL')
dbSkip()
End
EndIf
EndIf
EndIf
EndIf
aCols := aClone(aSavCols)
aHeader := aClone(aSavHeader)
Return