by Vijender Singh » Mon May 13, 2013 5:25 pm
Dim sAVEStatusbar, TimeLmt
Dim ChannelNumber As Single 'DDE Channel ID
Dim ConvDDE As String 'String to be used in creating Conversations
Dim Temp As Variant 'Misc Field
Dim FE As String, Transaction As Integer, Counter As Integer
Dim ScreensFilledIn As Integer, ScreensProcessed As Integer
Dim TabC As String, VDU As Object
Dim ValueDate As String, PostingDate As String
ScreensFilledIn = 1
FE = "field exit"
TabC = "tab field,"
Transaction = 7 'Transactions start from row number 7 in this spreadsheet
Set VDU = Workbooks(ActiveWorkbook.Name).Worksheets("VDU")
sAVEStatusbar = Application.DisplayStatusBar
Application.DisplayStatusBar = True
'set up errorhandling
On Error GoTo ErrorHandler ' Enable error-handling routine.
Application.EnableCancelKey = xlErrorHandler 'Cancel key will trigger errorhandling
'Initialise the conversation
Temp = InputBox("Which Session is HUB in? (Valid answers, A,B,C etc)")
ChannelNumber = DDEInitiate("IBM5250", "Session" & Temp)
'First check that we are in correct screen
' in this case from position 94 (94/80 = line 1, position 14)
Temp = Application.DDERequest(ChannelNumber, "EPS(13,3,1)")
If Temp(5) <> "C34" Then
MsgBox "You are Not in the Right Screen!" & vbCrLf & _
"Transfer Aborted!", vbCritical + vbOKOnly, "Not in C34 Screen"
ErrorHandler: ' Error-handling routine.
End If
'**************************************************************************************
Function CreateVDUTrans(VDU As Object, Transaction As Integer, ChannelNumber) As String
'**************************************************************************************
Dim Screen1, Screen2, Branch
Dim FE As String
Dim TabB As String, ConvDDE_a As String, ConvDDE_b As String
'The purpose of this function is to read one transaction record from Excel and
'transfer it to HUB
FE = "field exit"
TabB = "tab field"
Branch = """" & VDU.Range("A" & Transaction) & """," & FE & ","
Screen1 = VDUAccessFnc(WrkShtID:=VDU, TransCount:=Transaction, ColumnNo:="B", _
TrueVal:=TabB, FalseVal:=FE) & ","
Screen2 = VDUAccessFnc(WrkShtID:=VDU, TransCount:=Transaction, ColumnNo:="C", _
TrueVal:=TabB, FalseVal:=FE) & ","
'Add it all up to prepare to upload to HUB
ConvDDE_a = (Screen1 & " " & Screen2)
ConvDDE_b = "[SENDKEY(ChannelNumber, 275, ConvDDE_a)]"
End Function
This is what i wrote on Excel to execute on PCOM IBM 5250.
The first one is to find out if i am on correct screen if yes, then execute the second funtion.
On excel sheet A1 has a number value. I have divided that into 2 on B and C. Where Screen1 is mentioned on B7 and Screen2 is mentioned on C7.
I want to send the data on B7 and C7 to the said screen on Pcom. But i am unable to send it to the 275 (03/033) On status bar.
Please help or guide me to a helpfull forum for a quick responce.