Public Sub fSave()
If rsTrans.State = 1 Then rsTrans.Close
rsTrans.Open "select * From Trans_R where EmpNo='XXX'", DB, adOpenKeyset, adLockOptimistic
rsTrans.AddNew
rsTrans!EmpNo = Text(0)
rsTrans!Fep_No = "01"
rsTrans!Dev_Type = "R"
rsTrans!Dev_Id = "0009"
If rsCard.State = 1 Then rsCard.Close
rsCard.Open "Select Card_Number From vCardGate Where EMPID='" & Trim(Text(0)) & "'", DB, adOpenKeyset, adLockOptimistic
If rsCard.RecordCount > 0 Then
rsTrans!Tr_Data = rsCard!Card_Number
End If
rsTrans!Tr_Date = Text(2)
rsTrans!Company = Combo1
rsTrans!Tr_User = USRID
If Option1(0).Value = True Then
rsTrans!Tr_Time = Text(3)
rsTrans!Tr_Code = "0"
rsTrans!Tr_Priority = "00"
rsTrans.Update
Else
rsTrans!Tr_Time = Text(3)
rsTrans!Tr_Code = "9"
rsTrans!Tr_Priority = "00"
rsTrans.Update
End If
For i = 0 To 3
Text(i) = ""
Next
CmdEnabled Me, "2"
Text(0).SetFocus
End Sub
Senin, 31 Desember 2007
Cara pemanggilan di program
Pada sub main program, untuk lengkapnya silahkan lihat di baha ini
Public Sub Main()
On Error Resume Next
'get connection info
Dim Server, Userid, Password, Database As String
Dim dwLCID As Long
Dim Maunyakita As String
SetinganAsliDiKomputerUser = GetCurrentDateFormat
Maunyakita = "dd/MM/yyyy"
dwLCID = GetSystemDefaultLCID()
iniFile = Trim(Command())
If iniFile = "" Then iniFile = "HRD.ini"
10:
Server = GetIni("Connect", "Server")
If Server = "" Then
' frmConnect.Show vbModal
GoTo 10
End If
Userid = GetIni("Connect", "Userid")
Password = LCase(Decrypt(GetIni("Connect", "Password")))
Database = GetIni("Connect", "Database")
AttcDir = GetIni("Attachment", "Folder")
TempDir = Environ("TEMP")
ConnectS = "Provider=SQLOLEDB.1;" _
& "Persist Security Info=False;" _
& "User ID=" & Userid & ";" _
& "Password=" & Password & ";" _
& "Initial Catalog=" & Database & ";" _
& "Data Source=" & Server
ConnectRpt = "dsn=" & Server & ";dsq=" & Database & ";uid=" & Userid & ";pwd=" & Password & ";"
DB.CursorLocation = adUseClient
DB.Open ConnectS
'datSQL.conn.ConnectionString = ConnectS
If Err.Number <> 0 Then
frmConnect.Show vbModal
GoTo 10
End If
On Error GoTo LocalErr
frmLogin.Show vbModal
If frmLogin.Succeeded Then
frmMDIMain.Show
End If
Unload frmLogin
Call Regset
Exit Sub
LocalErr:
ShowError "Connection Fail !"
End
End Sub
Public Sub Main()
On Error Resume Next
'get connection info
Dim Server, Userid, Password, Database As String
Dim dwLCID As Long
Dim Maunyakita As String
SetinganAsliDiKomputerUser = GetCurrentDateFormat
Maunyakita = "dd/MM/yyyy"
dwLCID = GetSystemDefaultLCID()
iniFile = Trim(Command())
If iniFile = "" Then iniFile = "HRD.ini"
10:
Server = GetIni("Connect", "Server")
If Server = "" Then
' frmConnect.Show vbModal
GoTo 10
End If
Userid = GetIni("Connect", "Userid")
Password = LCase(Decrypt(GetIni("Connect", "Password")))
Database = GetIni("Connect", "Database")
AttcDir = GetIni("Attachment", "Folder")
TempDir = Environ("TEMP")
ConnectS = "Provider=SQLOLEDB.1;" _
& "Persist Security Info=False;" _
& "User ID=" & Userid & ";" _
& "Password=" & Password & ";" _
& "Initial Catalog=" & Database & ";" _
& "Data Source=" & Server
ConnectRpt = "dsn=" & Server & ";dsq=" & Database & ";uid=" & Userid & ";pwd=" & Password & ";"
DB.CursorLocation = adUseClient
DB.Open ConnectS
'datSQL.conn.ConnectionString = ConnectS
If Err.Number <> 0 Then
frmConnect.Show vbModal
GoTo 10
End If
On Error GoTo LocalErr
frmLogin.Show vbModal
If frmLogin.Succeeded Then
frmMDIMain.Show
End If
Unload frmLogin
Call Regset
Exit Sub
LocalErr:
ShowError "Connection Fail !"
End
End Sub
Kamis, 08 November 2007
SAP Module MM Create Material Master
Pada pembuatan Material Master kali ini kita akan buat Untuk Stock Item(Spare Part)
1. Gunakan TCode(MM01)
2. - Pilih Industry Sector (misalkan C Chemical)
- Material Type (lihat Browse - pilih Spare part)
3. Pilih -Basic Data
- Purchasing
- Purchase Order Text
- MRP 1
- MRP 2
- MRP 3
- General Plant Storage 1
- General Plant Storage 2
- Accounting 1
ENTER
4. Plant : 1000
5. Tab Basic Data
- Description
- Base unit of measurement
- Material Group
- Basic data Text
6. Tab Purchasing
- Optional untuk Batch management
7. Optional Purchase Order text, digunakan untuk pada saat pembuatan PO akan otomatis akan ikut
8. Tab MRP 1
- MRP Type : V1
- Minimum Reorder Point
- MRP Controller :001
- Maximum Stock
9. Tab MRP 2
- Storage loc for EP
10. Tab MRP3
- Avalibility check
11. Tab General Plant Data Stor 1
- Storage bin
12. Tab General Plant Data Stor 2
- Stock Determ. Group
13. Tab Accounting 1
- Valuation Class
- Price Control : V (untuk Average) atau S(Untuk Stnadrad), tergantung materialnya
- Price Unit
- Moving Average
14. SAVE
1. Gunakan TCode(MM01)
2. - Pilih Industry Sector (misalkan C Chemical)
- Material Type (lihat Browse - pilih Spare part)
3. Pilih -Basic Data
- Purchasing
- Purchase Order Text
- MRP 1
- MRP 2
- MRP 3
- General Plant Storage 1
- General Plant Storage 2
- Accounting 1
ENTER
4. Plant : 1000
5. Tab Basic Data
- Description
- Base unit of measurement
- Material Group
- Basic data Text
6. Tab Purchasing
- Optional untuk Batch management
7. Optional Purchase Order text, digunakan untuk pada saat pembuatan PO akan otomatis akan ikut
8. Tab MRP 1
- MRP Type : V1
- Minimum Reorder Point
- MRP Controller :001
- Maximum Stock
9. Tab MRP 2
- Storage loc for EP
10. Tab MRP3
- Avalibility check
11. Tab General Plant Data Stor 1
- Storage bin
12. Tab General Plant Data Stor 2
- Stock Determ. Group
13. Tab Accounting 1
- Valuation Class
- Price Control : V (untuk Average) atau S(Untuk Stnadrad), tergantung materialnya
- Price Unit
- Moving Average
14. SAVE
VB and SQL Server 7
Biasanya kita kesulitan untuk membuat connection string ke SQL Server. Ini contoh script dan file text yg di baca.
Taruh di Modules
' All variables for data connection
Global DB As New ADODB.Connection
Global ConnectS As String
Global ConnectRpt As String
Global rpt1 As String
Global sConn, asik As String
Global mDB1 As New ADODB.Connection
'Variable for Users
Global USRIDX As String
Global USRID As String
Global USRPWD As String
Global USRNAME As String
Global USRGRP As String
Global USRAUTH As String
Global USRDESC As String
Global USRRPT As String
' for edit INI file
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Private gstrKeyValue As String * 256
iniFile = Trim(Command())
If iniFile = "" Then iniFile = "HRD.ini"
Server = GetIni("Connect", "Server")
If Server = "" Then
frmConnect.Show vbModal
GoTo 10
End If
Userid = GetIni("Connect", "Userid")
Password = LCase(Decrypt(GetIni("Connect", "Password")))
Database = GetIni("Connect", "Database")
AttcDir = GetIni("Attachment", "Folder")
TempDir = Environ("TEMP")
ConnectS = "Provider=SQLOLEDB.1;" _
& "Persist Security Info=False;" _
& "User ID=" & Userid & ";" _
& "Password=" & Password & ";" _
& "Initial Catalog=" & Database & ";" _
& "Data Source=" & Server
DB.CursorLocation = adUseClient
DB.Open ConnectS
Public Sub SetIni(iSection As String, iKey As String, iValue As String)
Dim lonSts As String
lonSts = WritePrivateProfileString(iSection, iKey, iValue, App.Path & "\" & iniFile)
End Sub
Public Function GetIni(iSection As String, iKey As String, Optional iDefault As String)
Dim lonSts As String
lonSts = GetPrivateProfileString(iSection, iKey, iDefault, gstrKeyValue, 256, App.Path & "\" & iniFile)
If lonSts > 0 Then
GetIni = Left(gstrKeyValue, lonSts)
Else
GetIni = ""
End If
End Function
Public Function LPAD(iInp As String, iL As Long, iCH As String)
Dim sT As String
If Len(iInp) < st =" iInp" st =" iCH">= iL
If Len(sT) > iL Then
sT = Right(sT, iL)
End If
LPAD = sT
Else
LPAD = iInp
End If
End Function
Public Function RPAD(iInp As String, iL As Long, iCH As String)
Dim sT As String
If Len(iInp) < st =" iInp" st =" sT">= iL
If Len(sT) > iL Then
sT = Left(sT, iL)
End If
RPAD = sT
Else
RPAD = iInp
End If
End Function
buat text file dengan nama HRD.ini, dan isinya sbb
[Connect]
Server=(nama server SQL SERVER)
Userid=sa
Password=(password sa)
Database=(Nama Databasenya)
Taruh di Modules
' All variables for data connection
Global DB As New ADODB.Connection
Global ConnectS As String
Global ConnectRpt As String
Global rpt1 As String
Global sConn, asik As String
Global mDB1 As New ADODB.Connection
'Variable for Users
Global USRIDX As String
Global USRID As String
Global USRPWD As String
Global USRNAME As String
Global USRGRP As String
Global USRAUTH As String
Global USRDESC As String
Global USRRPT As String
' for edit INI file
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Private gstrKeyValue As String * 256
iniFile = Trim(Command())
If iniFile = "" Then iniFile = "HRD.ini"
Server = GetIni("Connect", "Server")
If Server = "" Then
frmConnect.Show vbModal
GoTo 10
End If
Userid = GetIni("Connect", "Userid")
Password = LCase(Decrypt(GetIni("Connect", "Password")))
Database = GetIni("Connect", "Database")
AttcDir = GetIni("Attachment", "Folder")
TempDir = Environ("TEMP")
ConnectS = "Provider=SQLOLEDB.1;" _
& "Persist Security Info=False;" _
& "User ID=" & Userid & ";" _
& "Password=" & Password & ";" _
& "Initial Catalog=" & Database & ";" _
& "Data Source=" & Server
DB.CursorLocation = adUseClient
DB.Open ConnectS
Public Sub SetIni(iSection As String, iKey As String, iValue As String)
Dim lonSts As String
lonSts = WritePrivateProfileString(iSection, iKey, iValue, App.Path & "\" & iniFile)
End Sub
Public Function GetIni(iSection As String, iKey As String, Optional iDefault As String)
Dim lonSts As String
lonSts = GetPrivateProfileString(iSection, iKey, iDefault, gstrKeyValue, 256, App.Path & "\" & iniFile)
If lonSts > 0 Then
GetIni = Left(gstrKeyValue, lonSts)
Else
GetIni = ""
End If
End Function
Public Function LPAD(iInp As String, iL As Long, iCH As String)
Dim sT As String
If Len(iInp) < st =" iInp" st =" iCH">= iL
If Len(sT) > iL Then
sT = Right(sT, iL)
End If
LPAD = sT
Else
LPAD = iInp
End If
End Function
Public Function RPAD(iInp As String, iL As Long, iCH As String)
Dim sT As String
If Len(iInp) < st =" iInp" st =" sT">= iL
If Len(sT) > iL Then
sT = Left(sT, iL)
End If
RPAD = sT
Else
RPAD = iInp
End If
End Function
buat text file dengan nama HRD.ini, dan isinya sbb
[Connect]
Server=(nama server SQL SERVER)
Userid=sa
Password=(password sa)
Database=(Nama Databasenya)
Langganan:
Postingan (Atom)