2013 Feb 06 4:43 PM
Hi
My requirement is to reterive the record based upon two conditions.
For example:
1. With the Employee Number.
2. Last updated record.
Table will have more than one record for one particular Employee Number.
I am not sure how to specify the option to reterive only the lastupdated record (eg. Max of date).
tOptions.Rows.Add
tOptions(1, "TEXT") = "EMP = '101' AND "
tOptions.Rows.Add
tOptions(1, "TEXT") = "LAST = Max(LASTDATE)"
Could anybody please help me how to specify the condition.
Thanks in Advance
Abirami
Hi
My requirement is to reterive the record based upon two conditions.
For example:
1. With the Employee Number.
2. Last updated record.
Table will have more than one record for one particular Employee Number.
I am not sure how to specify the option to reterive only the lastupdated record (eg. Max of date).
tOptions.Rows.Add
tOptions(1, "TEXT") = "EMP = '101' AND "
tOptions.Rows.Add
tOptions(1, "TEXT") = "LAST = Max(LASTDATE)"
Could anybody please help me how to specify the condition.
Thanks in Advance
Abirami
2013 Feb 06 5:11 PM
Do you need a select query?
IF yes.
_____________________________
Select * from EMP_TABLE into table it_emp_tab where EMP_NO EQ '101'.
" Now internal table it_emp will have multiple records.
Sort it_emp descending by last_updated_field.
READ it_emp into wa_emp index 1.
_________________________
If you are not looking for select queries then please give more details about your issue.
Thanks and regards,
Bharathi
2013 Feb 06 6:13 PM
Hi Abirami,
The table OPTIONS is meant to store WHERE clausules, I don't think you can order right there, I think you should only use Employee number, then you will get all the records corresponding to that employee, and then you can manipulate that information ( order it the way you want ) in the programming language you're using to consume that RFC.
Best regards,
@hugo_dc
2013 Feb 07 12:12 PM
Thanks for the response. That issue is resolved.
Now I have some other issue.
Im taking input for the query from Excel sheet and writing back the extracted field.
My code is retrieving data from table only for the first record and for others its showing "INVALID FIELD"
Could you please help me to resolve this issue?
Sub CallFunctionModule()
Dim sap As Object
Dim conn As Object
Dim fb As Object
Dim tOptions As Object
Dim tFields As Object
Dim tData As Object
Dim RowData$()
Dim j, i, k, x, y As Long
Dim firsttime As Integer
Dim achange As String
Set sap = CreateObject("SAP.Functions")
Set conn = sap.Connection
conn.System = "xxx"
conn.client = "100"
conn.user = "ABIRAMI"
conn.Password = "xx"
conn.Language = "EN"
Set functionCtrl = CreateObject("SAP.Functions")
Set sapconnection = functionCtrl.Connection
If conn.logon(0, False) <> True Then
MsgBox "No connection to R/3!", vbOKOnly, "comment"
Else
For x = 2 To 10
Set fb = sap.Add("RFC_READ_TABLE")
With fb
.exports("QUERY_TABLE") = "TABLEDATA"
.exports("DELIMITER") = "|"
End With
Set tOptions = fb.tables("OPTIONS")
Set tFields = fb.tables("FIELDS")
Set tData = fb.tables("DATA")
For x = 1 to 10
achange = Sheet1.Cells(x, 2).Value
MsgBox achange
tOptions.Rows.Add
tOptions(1, "TEXT") = "AENNR = " & achange & " AND"
tOptions.Rows.Add
tOptions(2, "TEXT") = "REL_FLAG <> 'X' "
MsgBox "I am here point3"
tFields.Rows.Add
tFields(1, "FIELDNAME") = "BNAME"
If fb.call Then
j = tData.ROWCOUNT
MsgBox j
If j > 0 Then
n = 14
k = 1
For i = 1 To j
RowData = Split(tData(i, "WA"), "|")
Sheet1.Cells(x, n).Value = RowData(k - 1)
n = n + 1
Next
End If
Else
' MsgBox "Till Point3"
' MsgBox fb.Exception, vbOKOnly, "comment"
End If
Next
Next
Set tFields = Nothing
Set tData = Nothing
Set tOptions = Nothing
Set fb = Nothing
conn.logoff
End If
Set conn = Nothing
Set sap = Nothing
End Sub
2013 Aug 28 12:48 PM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |