Hi Moorthy,
Thanks for all your efforts. Sorry for getting delayed in responding. Once again, yes I can apply it through the screen but I noticed that, while applying it shows the in Originating currency (Foreign Currency), may be that's what is the clue, as taRMApply class doesn't take any currency parameter to pass. Anyways, kindly see the below screen shot of the error, which clearly indicates that either of the document (ApplyTo OR ApplyFrom) is not in the Functional currency. This error means that, this taRMApply class doesn't support foreign currency transactions. I've also pasted the source code in the last below this error screen shot.
Your valuable input is appreciated.
Thanks.
AZEEM.

Private Sub BtnApply_Click(sender As Object, e As EventArgs) Handles BtnApply.Click
Dim MySQL As String
Dim MyPosSql As String
Dim CheckCust As String
CheckCust = ""
MySqlConn.ConnectionString = "data source=XYZ;initial catalog=ABC;uid=sa;password=admin;packet size=4096;MultipleActiveResultSets=True"
Using eConCall As New eConnectMethods
Try
MySqlConn.Open()
Label4.Text = Now.TimeOfDay.ToString
ComeToStartAgain:
'For Functional / Local Currency transactions this query
'MySQL = "SELECT CUSTNMBR, DOCNUMBR, DOCDATE, RMDTYPAL, ORTRXAMT, CURTRXAM FROM RM20101 WHERE RMDTYPAL IN('7','8') AND "
'MySQL = MySQL + " TRXDSCRN LIKE '%IMPORT%' AND (DOCDATE>='" + Me.DTPicker1.Value.Date + "' AND DOCDATE<='" + Me.DTPicker2.Value.Date + "') AND "
'MySQL = MySQL + " CURTRXAM>0 and CUSTNMBR> '" + CheckCust + "' AND LEFT(CUSTNMBR,1)='3' ORDER BY CUSTNMBR, RMDTYPAL, DOCDATE, DOCNUMBR"
'For Foreign Currency transactions this query
MySQL = "SELECT CUSTNMBR, DOCNUMBR, DOCDATE, RMDTYPAL, ORCTRXAM, CURNCYID FROM MC020102 WHERE RMDTYPAL IN('7','8') AND "
'MySQL = MySQL + " TRXDSCRN LIKE '%IMPORT%' AND "
MySQL = MySQL + " (DOCDATE>='" + Me.DTPicker1.Value.Date + "' AND DOCDATE<='" + Me.DTPicker2.Value.Date + "') AND "
MySQL = MySQL + " ORCTRXAM>0 and CUSTNMBR> '" + CheckCust + "' AND LEFT(CUSTNMBR,1)='3' ORDER BY CUSTNMBR, RMDTYPAL, DOCDATE, DOCNUMBR"
MySQLCmd.CommandText = MySQL.ToString
MySQLCmd.Connection = MySqlConn
MyNegSQLDataReader = MySQLCmd.ExecuteReader
MyRecCountCmd.CommandText = "SELECT COUNT(*) FROM RM20101 WHERE RMDTYPAL IN('7','8') AND TRXDSCRN LIKE '%IMPORT%' AND (DOCDATE>='" + Me.DTPicker1.Value.Date + "' AND DOCDATE<='" + Me.DTPicker2.Value.Date + "') AND LEFT(CUSTNMBR,1)='3' AND CURTRXAM>0"
MyRecCountCmd.Connection = MySqlConn
If MyNegSQLDataReader.HasRows = False Then
Label5.Text = Now.TimeOfDay.ToString
Label5.Refresh()
MsgBox("Completed Application.", MsgBoxStyle.Information, "Dot Net Application.")
Exit Sub
End If
Dim i As Integer = 0
Dim MyRecCount As Int64
MyRecCount = MyRecCountCmd.ExecuteScalar
MyRecCountCmd.Dispose()
While MyNegSQLDataReader.Read()
i += 1
MyNegDocType = MyNegSQLDataReader.Item(3)
MyNegCustNmbr = MyNegSQLDataReader.GetString(0)
MyNegDocNumber = MyNegSQLDataReader.GetString(1)
MyNegNumber = MyNegSQLDataReader.Item(4)
Label1.Text = "Customer#: " & MyNegCustNmbr & " Negative Doc#: " & MyNegDocNumber
Label1.Refresh()
Label3.Text = "Record#: " & i & " of " & MyRecCount.ToString
Label3.Refresh()
'For Functional / Local Currency transactions this query
'MyPosSql = "SELECT CUSTNMBR, DOCNUMBR, DOCDATE, RMDTYPAL, ORTRXAMT, CURTRXAM FROM RM20101 WHERE RMDTYPAL IN('1','3','4','5','6') AND "
'MyPosSql = MyPosSql + " CUSTNMBR='" + MyNegCustNmbr + "' AND LEFT(CUSTNMBR,1)='3' AND (DOCDATE>='" + Me.DTPicker1.Value.Date + "' AND DOCDATE<='" + Me.DTPicker2.Value.Date + "') "
'MyPosSql = MyPosSql + " AND CURTRXAM>0 ORDER BY CUSTNMBR, DOCDATE, DOCNUMBR"
'For Foreign Currency transactions this query
MyPosSql = "SELECT CUSTNMBR, DOCNUMBR, DOCDATE, RMDTYPAL, ORCTRXAM, CURNCYID FROM MC020102 WHERE RMDTYPAL IN('1','3','4','5','6') AND "
MyPosSql = MyPosSql + " CUSTNMBR='" + MyNegCustNmbr + "' AND LEFT(CUSTNMBR,1)='3' AND (DOCDATE>='" + Me.DTPicker1.Value.Date + "' AND DOCDATE<='" + Me.DTPicker2.Value.Date + "') "
MyPosSql = MyPosSql + " AND ORCTRXAM>0 ORDER BY CUSTNMBR, DOCDATE, DOCNUMBR"
MyPosSQLCmd.CommandText = MyPosSql.ToString
MyPosSQLCmd.Connection = MySqlConn
MyPosSQLDataReader = MyPosSQLCmd.ExecuteReader
If MyPosSQLDataReader.HasRows = False Then
MyPosSQLDataReader.Close()
MyNegSQLDataReader.Close()
'GoTo ComeHereDarling
CheckCust = MyNegCustNmbr
GoTo ComeToStartAgain
End If
Label1.Text = Label1.Text & " Negative Amount: " & MyNegNumber
Label1.Refresh()
While MyPosSQLDataReader.Read
If MyNegNumber > 0 Then
MyPosDocType = MyPosSQLDataReader.Item(3)
MyPosCustNmbr = MyPosSQLDataReader.GetString(0)
MyPosDocNumber = MyPosSQLDataReader.GetString(1)
MyPosNumber = MyPosSQLDataReader.Item(4)
Label2.Text = "Customer#: " & MyPosCustNmbr & " Positive Doc#: " & MyPosDocNumber & " Positive Amount: " & MyPosNumber
Label2.Refresh()
SerializeApplyWriteOffsObject("ApplyDocs.xml")
Dim XmlDoc As New Xml.XmlDocument
Dim ApplyDocument As String
Dim sConnectionString As String
Dim ApplyRec As String
XmlDoc.Load("ApplyDocs.xml")
ApplyDocument = XmlDoc.OuterXml
sConnectionString = "data source=XYZ;initial catalog=ABC;integrated security=SSPI;packet size=4096"
ApplyRec = eConCall.CreateTransactionEntity(sConnectionString, ApplyDocument)
MyPosSQLDataReader.Close()
MyNegSQLDataReader.Close()
End If
GoTo ComeToStartAgain
End While
MyPosSQLDataReader.Close()
MyNegSQLDataReader.Close()
GoTo ComeToStartAgain
ComeToNextNegRec:
End While
Catch Exp As eConnectException
MsgBox(Exp.ToString())
Catch ex As Exception
MsgBox(ex.ToString())
Finally
MyPosSQLDataReader.Close()
MyNegSQLDataReader.Close()
eConCall.Dispose()
MyConn.Close()
End Try
End Using
End Sub
Public Sub SerializeApplyWriteOffsObject(ByVal filename As String)
Try
'Create an array that holds two taSopLineIvcInsert_ItemsTaSopLineIvcInsert XML node objects
'Dim LineItems(1) As taSopLineIvcInsert_ItemsTaSopLineIvcInsert
Dim MyType As New RMApplyType
Dim MyTransaction(0) As taRMApply
'Dim MyGroupChild As RMParentIDChildType
'Create a taSopLineIvcInsert_ItemsTaSopLineIvcInsert XML node object
'Populate the XML node object
MyTransaction(0) = New taRMApply()
With MyTransaction(0)
.APFRDCNM = MyNegDocNumber
.APFRDCTY = MyNegDocType
.APPLYDATE = Me.DTPicker2.Value.Date
If MyNegNumber = MyPosNumber Then
.APPTOAMT = MyNegNumber
ElseIf MyNegNumber > MyPosNumber Then
.APPTOAMT = MyPosNumber
ElseIf MyNegNumber < MyPosNumber Then
.APPTOAMT = MyNegNumber
End If
.APTODCNM = MyPosDocNumber
.APTODCTY = MyPosDocType
'.DISTKNAM = 0
.GLPOSTDT = Me.DTPicker2.Value.Date
'.WROFAMNT = .APPTOAMT
'ReInitializeVariables()
End With
Dim eConnect As New eConnectType()
ReDim Preserve eConnect.RMApplyType(0)
MyType.taRMApply = MyTransaction(0)
'MyType.taParentIDChild_Items = m
'MyType.taRMDistribution_Items = MyDistributions
eConnect.RMApplyType(0) = MyType
'Create a file and stream to use to serialize the XML document to a file
Dim fs As New FileStream(filename, FileMode.Create)
Dim writer As New XmlTextWriter(fs, New UTF8Encoding)
'Serialize the XML document to the file
Dim serializer As New XmlSerializer(GetType(eConnectType))
serializer.Serialize(writer, eConnect)
writer.Close()
Catch ex As ApplicationException
Console.Write(ex.ToString)
End Try
End Sub