I have the following mission to develop in advp, I will try to explain what I am trying to do. I need to print transport labels indicating the Ex 1/2 and 2/2 volumes on the printout if the note contains two volumes, this is already printing right. Now comes the challenge, I have to print these labels by typing a range of Ex notes. Note 063923 through 063924, note 063923 contains a line that is an item with 2 volumes blz, while the second note 063924 contains a single product divided by lots different, so the note generates 2 items because they are different batches but they are still 2 volumes in which case I have to print data from the first line checked the volume Ex. 1/2 and data from the second line 2/2, I do not know if I could explain myself but anything is at my disposal. Thank you.
Follow my advpl code
User Function xEtiqPallet
*-----------------------*
Local _cPerg := 'xEtiqPallet'
Local cQuery := ""
Local _nLin := 0
Local _cRota := 'B'
Local _cTpImp := UppER(AllTrim(GetMV('PC_ITERFRQ',.F.,'DATAMAX')))
PutSx1(_cPerg,"01","Nota Fiscal De: ","Nota Fiscal De: ","Nota
Fiscal De: ","mv_ch01","C",09,00,00,"G",""
,"SF2","","","mv_par01","","","","","","","","","","","","","","","","")
PutSx1(_cPerg,"02","Nota Fiscal Ate: ","Nota Fiscal Ate: ","Nota
Fiscal Ate: ","mv_ch02","C",09,00,00,"G",""
,"SF2","","","mv_par02","","","","","","","","","","","","","","","","")
PutSx1(_cPerg,"03","Serie Nota Fiscal: ","Serie Nota Fiscal: ","Serie
Nota Fiscal: ","mv_ch03","C",03,00,00,"G","" ,""
,"","","mv_par03","","","","","","","","","","","","","","","","")
IF !Pergunte(_cPerg,.T.)
Return
EndIF
cQuery := " SELECT DISTINCT " + CRLF
cQuery += " SD2.D2_ITEM AS ITEM, " + CRLF
cQuery += " SD2.D2_DOC AS NOTA, " + CRLF
cQuery += " SA1.A1_NOME AS CLIENTE, " + CRLF
cQuery += " CONCAT(RTRIM(SB1.B1_COD), ' - ', SB1.B1_DESC) AS PRODUTO, " +
CRLF
cQuery += " SB1.B1_FABRIC AS FABRICANTE," + CRLF
cQuery += " CAST(SB5.B5_QE1 AS NUMERIC(15,3)) AS PESOL," + CRLF
cQuery += " (SB5.B5_QE1 * CAST(SB1.B1_PESBRU AS NUMERIC(15,3))) AS
PESOB," + CRLF
cQuery += " SD2.D2_LOTECTL AS LOTE," + CRLF
cQuery += " SB8.B8_DFABRIC AS FABRICACAO," + CRLF
cQuery += " SD2.D2_DTVALID AS VALIDADE," + CRLF
cQuery += " SC6.C6_PEDCLI AS PEDCLIENTE, " + CRLF
cQuery += " SC6.C6_NUMPCOM AS PEDCOMP, " + CRLF
cQuery += " SD2.D2_QUANT / SB5.B5_QE1 AS VOLUME, " + CRLF
cQuery += " SF2.F2_VOLUME1 AS VOLUME1 " + CRLF
cQuery += " FROM " +RetSqlName("SD2")+ " SD2(NOLOCK), " + CRLF
cQuery += " " +RetSqlName("SA1")+ " SA1(NOLOCK), " + CRLF
cQuery += " " +RetSqlName("SB1")+ " SB1(NOLOCK), " + CRLF
cQuery += " " +RetSqlName("SB8")+ " SB8(NOLOCK), " + CRLF
cQuery += " " +RetSqlName("SB5")+ " SB5(NOLOCK), " + CRLF
cQuery += " " +RetSqlName("SF2")+ " SF2(NOLOCK), " + CRLF
cQuery += " " +RetSqlName("SC6")+ " SC6(NOLOCK) " + CRLF
cQuery += " WHERE SD2.D2_DOC BETWEEN '"+MV_PAR01+"' AND '" +MV_PAR02+"' "
+ CRLF
cQuery += " AND SB8.B8_LOCAL = '01' " + CRLF
cQuery += " AND SD2.D2_SERIE = '"+MV_PAR03+"' " + CRLF
cQuery += " AND SD2.D2_FILIAL = '" + xFilial ("SD2") + "'" + CRLF
cQuery += " AND SB1.B1_FILIAL = '" + xFilial ("SB1") + "'" + CRLF
cQuery += " AND SB8.B8_FILIAL = '" + xFilial ("SB8") + "'" + CRLF
cQuery += " AND SB5.B5_FILIAL = '" + xFilial ("SB5") + "'" + CRLF
cQuery += " AND SC6.C6_FILIAL = '" + xFilial ("SC6") + "'" + CRLF
cQuery += " AND SA1.A1_COD = SD2.D2_CLIENTE " + CRLF
cQuery += " AND SB1.B1_COD = SD2.D2_COD " + CRLF
cQuery += " AND SB8.B8_LOTECTL = SD2.D2_LOTECTL " + CRLF
cQuery += " AND SB5.B5_COD = SB1.B1_COD " + CRLF
cQuery += " AND SF2.F2_DOC = SD2.D2_DOC " + CRLF
cQuery += " AND SC6.C6_NOTA = SD2.D2_DOC " + CRLF
cQuery += " AND SD2.D_E_L_E_T_ = '' " + CRLF
cQuery += " AND SA1.D_E_L_E_T_ = '' " + CRLF
cQuery += " AND SB1.D_E_L_E_T_ = '' " + CRLF
cQuery += " AND SB8.D_E_L_E_T_ = '' " + CRLF
cQuery += " AND SB5.D_E_L_E_T_ = '' " + CRLF
cQuery += " AND SF2.D_E_L_E_T_ = '' " + CRLF
cQuery += " AND SC6.D_E_L_E_T_ = '' " + CRLF
cQuery += " ORDER BY SD2.D2_DOC " + CRLF
If Select("ETQ") > 0
Dbselectarea("ETQ")
ETQ->(DbClosearea())
EndIf
TcQuery cQuery New Alias "ETQ"
ETQ->(DbGotop())
TCSetField( 'ETQ', "FABRICACAO", "D" )
TCSetField( 'ETQ', "VALIDADE", "D" )
Do While ETQ->(!EOF())
For nVol := 1 To ETQ->VOLUME
IF Empty(ETQ->CLIENTE)
MsgInfo('Revise os parametros!!','Atenção')
Return
EndIF
_cMsg := 'Armazenar em Lugar Fresco e seco, protegido do calor e umidade'
IF _cTpImp == 'DATAMAX'
MSCBPRINTER("DATAMAX","LPT1",,,.F.,,,,)
EndIF
MSCBCHKStatus(.F.)
MSCBBEGIN(1,6)
_nLin := 30
MSCBSAY(_nLin,010,"CLIENTE: " +ALLTRIM(ETQ->CLIENTE) ,_cRota,"5","1,1")
_nLin+=10
MSCBSAY(_nLin,010,"NOTA: " +ALLTRIM(ETQ->NOTA) ,_cRota,"5","1,1")
MSCBSAY(_nLin,050,"VOL.: " +CVALTOCHAR(nVol)+ "/" +CVALTOCHAR(ETQ->VOLUME) ,_cRota,"5","1,1")
_nLin+=10
MSCBSAY(_nLin,010,"PRODUTO: " +ALLTRIM(ETQ->PRODUTO) ,_cRota,"5","1,1")
_nLin+=10
MSCBSAY(_nLin,010,"FABRICANTE: " +ALLTRIM(ETQ->FABRICANTE) ,_cRota,"5","1,1")
_nLin+=10
MSCBSAY(_nLin,010,"LOTE: " +ALLTRIM(ETQ->LOTE) ,_cRota,"5","1,1")
MSCBSAY(_nLin,80,"FABRICACAO: " +OemToAnsi(Dtoc(ETQ->FABRICACAO)) ,_cRota,"5","1,1")
MSCBSAY(_nLin,150,"VALIDADE: " +OemToAnsi(Dtoc(ETQ->VALIDADE)) ,_cRota,"5","1,1")
_nLin+=10
MSCBSAY(_nLin,010,"P.LIQ.: " +TRANSFORM(ETQ->PESOL, '@E 999.999') +"KG" ,_cRota,"5","1,1")
MSCBSAY(_nLin,110,"P.BRURTO: " +TRANSFORM(ETQ->PESOB, '@E 999.999') +"KG" ,_cRota,"5","1,1")
_nLin+=10
MSCBSAY(_nLin,010,"PROD. CLIENTE: " +ALLTRIM(ETQ->PEDCOMP) ,_cRota,"5","1,1")
MSCBSAY(_nLin,110,"PED. CLIENTE: " +ALLTRIM(ETQ->PEDCLIENTE) ,_cRota,"5","1,1")
_nLin+=10
MSCBSAY(_nLin,006,_cMsg ,_cRota,"2","2,1")
MSCBInfoEti("Etiqueta Pallet","11x21")
MSCBEND()
Next nVol
ETQ->(Dbskip())
EndDo
MSCBCLOSEPRINTER()
Return