Menghitung Parsing ISO 8583 dengan foxpro

Ini cuma cara sederhana (maksudnya cara yg saya bisa😀 akalin )

langsung aja yaa, cara ngitungnya ada disini bacanya

https://lmanxp.wordpress.com/2011/04/09/parsing-iso8583/

dan dengan sintak foxpro

 


Clear
Create Cursor siso ( nbit C(3),cTipe C(10),nPanjang N(3),nfix N(3))
Insert Into siso Values("1","b",32,0)
Insert Into siso Values("7","n",10,0)
Insert Into siso Values("11","n",6,0)
Insert Into siso Values("33","n",11,1)
Insert Into siso Values("70","n",3,0)
iso8583("080082200000800000000400000000000000000000590100000103123001")
Function iso8583(cIso)
Local lnbaris[30],lnbits[30],dataMit[15]

*MTI
cMti=Substr(cIso,1,4)
*MTI Sisa
cSisa=Substr(cIso,Len(cMti)+1)

huruf1=Left(cSisa,1)
*Panjang Bit map hex2bin
nPBitmap=hex2bin(huruf1)
nPBitmap=Iif(Left(nPBitmap,1)="0",16,32)

*Bit 1 Lokasi BitMap
nDataSisa=Substr(cSisa,1,nPBitmap)

*sisa BitMap
nSisa=Substr(cSisa,nPBitmap+1)
*Bit 1
datasisa=nSisa

j=0
lnUrut=""
lnurutxx=""
i=0
For i=1 To Len(nDataSisa)
lnurutxx=hex2bin(Substr(nDataSisa,i,1))
lnUrutx=lnUrut+lnurutxx
lnUrut=lnUrutx
Endfor
i=0

*hitung Bitmap Aktif=1
For i=1 To Len(lnUrut)
lnaktif=Substr(lnUrut,i,1)
If Alltrim(lnaktif)="1"
j=j+1
lnbaris[j]=i
Endif
Endfor
j=0
x=0

Select siso
Scan
x=x+1
lnBit=nbit
lcTipe=cTipe
lnPanjang=nPanjang
lnfix=nfix
If ALLTRIM(lcTipe)="b"
Loop
ENDIF
*panjang statis
If lnfix=0
ctmp=Substr(datasisa,1,lnPanjang)
If Len(ctmp)=lnPanjang
If lcTipe="n"
dataMit[x] = Substr(datasisa,1,lnPanjang)
Else
dataMit[x]= Alltrim(Substr(datasisa,1,lnPanjang))
Endif
datasisa=Substr(datasisa,lnPanjang+1,Len(datasisa)-lnPanjang)
Endif

ELSE
*panjang Dinamis
nLen = Len(Alltrim(Str(lnPanjang)))
ctmp=Substr(datasisa,1,nLen)
If Len(ctmp)=nLen
cNum=INT(val(ctmp))
datasisa=Substr(datasisa,nLen,Len(datasisa)+nLen)

cTmp2= Substr(datasisa,1+1,cNum)
If Len(cTmp2)=cNum
If lcTipe="n"
dataMit[x] =INT(Val(cTmp2))
Else
dataMit[x] =cTmp2
Endif
datasisa=Substr(datasisa,(cNum+1)+1,Len(datasisa)-cNum)
Endif
Endif
Endif

Endscan
i=0
For i=1 To 15
If Vartype(dataMit[i])="L"
Loop
Endif
?IIF(VARTYPE(dataMit[i])="N",ALLTRIM(STR(dataMit[i])),dataMit[i])
Endf
Endfunc

Function hex2bin
Parameters cHexString

Store '' To cBinString, cBinString1
Store Len(cHexString) To nStrLen
For zzz = 1 To nStrLen
cBinString = cBinString + ;
Padl(dec2basx(Int(Val('0x' + Substr(cHexString, zzz, 1))), 2), 4, '0')
Next
Return cBinString

Function dec2basx
Parameters nTempNum, nNewBase

Store 0 To nWorkVal,;
remainder,;
dividend,;
nextnum,;
digit

nWorkVal = nTempNum
ret_str = ''

Do While .T.
digit = Mod(nWorkVal, nNewBase)
dividend = nWorkVal / nNewBase
nWorkVal = Int(dividend)

Do Case
Case digit = 10
ret_str = 'a' + ret_str
Case digit = 11
ret_str = 'b' + ret_str
Case digit = 12
ret_str = 'c' + ret_str
Case digit = 13
ret_str = 'd' + ret_str
Case digit = 14
ret_str = 'e' + ret_str
Case digit = 15
ret_str = 'f' + ret_str
Otherwise
ret_str = Ltrim(Str(digit)) + ret_str
Endcase

If nWorkVal = 0
Exit
Endif ( nWorkVal = 0 )
Enddo ( .T. )
Return ret_str

dan hasilnya

1

OK ini cuma contoh😀

 

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: