// Recodificare randuri D300

xa_rnd := {}
AADD(xa_rnd,{"42","44"})
AADD(xa_rnd,{"41","43"})
AADD(xa_rnd,{"40","42"})
AADD(xa_rnd,{"39","41"})
AADD(xa_rnd,{"38","40"})
AADD(xa_rnd,{"37","39"})
AADD(xa_rnd,{"36","38"})
AADD(xa_rnd,{"35","37"})
AADD(xa_rnd,{"34","36"})
AADD(xa_rnd,{"33","35"})
AADD(xa_rnd,{"32","34"})
AADD(xa_rnd,{"31","33"})
AADD(xa_rnd,{"30","32"})
AADD(xa_rnd,{"29","31"})
AADD(xa_rnd,{"28","30"})
AADD(xa_rnd,{"27","29"})
AADD(xa_rnd,{"26","28"})

xa_camp :=  {"SP1C1 ","SP1C2 ","SP1C24",         "SP1C31","SP1C32","SP1C4 ","SP1C8 ",;
             "SP1D1 ","SP1D2 ","SP1D24","SP1D28","SP1D3 ",         "SP1D4 ","SP1D8 "}
// #IF !h_UseAlias("p1")
//     Abandon()
// #ENDIF

DBSETORDER(0)    
DBGOTOP()
// parcurge fisierul P1
#WHILE !EOF()
    #IF p1->SP1020="JC"
        // parcurge randurile D300 din xa_rnd
        xx_k := 1
        #WHILE xx_k <= LEN(xa_rnd)
            // parcurge campurile P1 dintr-o inregistrare
            xx_j := 1
            #WHILE xx_j <= LEN(xa_camp)
                xx_nr := FIELDPOS(xa_camp[xx_j])
                #IF xx_nr>0
                    xx_val := FIELDGET(xx_nr)
                    xx_val := STRTRAN(xx_val,xa_rnd[xx_k,1],xa_rnd[xx_k,2])
                    FIELDPUT(xx_nr, xx_val) 
                #ELSE
                    h_PutLine("*** Campul "+xa_camp[xx_j]+" absent din Corespondente TVA")
                #ENDIF
                xx_j := xx_j+1
            #ENDDO    
            xx_k := xx_k+1
        #ENDDO   
    #ENDIF    
    DBSKIP()
#ENDDO 
h_PutLine("    Recodificat randurile JC din Corespondente TVA")
      
// h_CloseAlias("p1")
//