hi thomas i m rupesh from india
i need your help please help me
i m able to connect through sap but can not map the data as same as in bapi parameter
bapi reaired parameter is
BAPI Name : Y_BAPI_VALIDATE_LEAVE
Import parameters :
Parameter name Data type length
EMPLOYEENUMBER Number 8
START_DATE Date 8 (Format YYYYMMDD)
START_FULL_DAY Char 1 (1 for full day and blank for half day)
END_DATE Date 8 (Format YYYYMMDD)
END_FULL_DAY Char 1 (1 for full day and blank for half day)
LEAVE_TYPE Number 4
Export parameters :
Parameter name Data type length
LEAVE_DAYS Number 8 (will not give any data at this point of time)
OK_TAG Char 1 (‘Y’ for successful validation, ‘N’ for error)
TEXTLINE Char 255 (User message)
and my code is
Sub Initialize
On Error Goto errorhandler
Dim session As New lcsession
Dim target As New LCConnection("sap")
target.Database = "Y_BAPI_VALIDATE_LEAVE"
'Here is the BAPI that we want to access.
target.Userid = "P00149513"
target.Password = "RUPANTAR"
target.Client="120"
target.Destination="RQA.TATASTEEL.COM"
target.SystemNo=00
target.Language="EN"
target.Server="133.0.1.85"
target.Connect
'If this line executes without error, then we are successfully logged in to the
'SAP system.
Dim fldLst As New LCFieldList
Dim fldresult As New LCFieldList
Dim field As LCField
Dim number As New LCNumeric
target.Metadata = "*"
number.text = "00149513"
Set field = fldLst.Append("EMPLOYEENUMBER",LCTYPE_NUMERIC)
Call field.setnumeric (1, number)
'Dim flddate As New LCDatetime (2006,11,04)
Dim flddate As New LCDatetime (2006,11,04)
Set field = fldLst.Append("START_DATE", LCTYPE_DATETIME)
Call field.setdatetime (1, temp)
Set field = fldLst.Append("START_FULL_DAY",LCTYPE_TEXT)
field.text = "1"
Dim flddate1 As New LCDatetime (2006,11,20)
Set field = fldLst.Append("END_DATE", LCTYPE_DATETIME)
Call field.setdatetime (1, flddate1)
Set field = fldLst.Append("END_FULL_DAY", LCTYPE_TEXT)
field.text = "1"
number.text = "0052"
Set field = fldLst.Append("LEAVE_TYPE",LCTYPE_NUMERIC)
Call field.setnumeric (1, number)
Dim count, counter2 As Integer
target.MapByName = True
count = target.call(fldLst, 1, fldresult)
Dim index As Long
Call target.Fetch (fldresult, 1, 1)
Set field = fldresult.lookup("OK_TAG", index)
If field.text(0) <> ""Then
Print "OK_TAG = " & field.text (0)
End If
Set field = fldresult.lookup("TEXTLINE", index)
If field.text(0) <> "" Then
Print "TEXTLINE= " & field.text (0)
End If
Exit Sub
errorhandler:
Dim Msg As String
Dim Msgcode As Long
Dim status As Integer
Dim result As String
If session.status <> LCSUCCESS Then
status = session.GetStatus(result, Msgcode, Msg)
End If
Msgbox result
End Sub
here error message come is exectly like that
“filed mapping failed due to a missing field,connecter ‘sap’ method-call-”
I have also code of bapi
FUNCTION Y_BAPI_VALIDATE_LEAVE .
*"----------------------------------------------------------------------
""Local interface:
*" IMPORTING
*" VALUE(EMPLOYEENUMBER) LIKE ZBAPI_IMPORT-EMPLOYEENUMBER
*" VALUE(START_DATE) LIKE ZBAPI_IMPORT-START_DATE
*" VALUE(START_FULL_DAY) LIKE ZBAPI_IMPORT-START_FULL_DAY
*" VALUE(END_DATE) LIKE ZBAPI_IMPORT-END_DATE
*" VALUE(END_FULL_DAY) LIKE ZBAPI_IMPORT-END_FULL_DAY
*" VALUE(LEAVE_TYPE) LIKE ZBAPI_IMPORT-LEAVE_TYPE
*" EXPORTING
*" VALUE(LEAVE_DAYS) LIKE ZBAPI_EXPORT-LEAVE_DAYS
*" VALUE(OK_TAG) LIKE ZBAPI_EXPORT-OK_TAG
*" VALUE(TEXTLINE) LIKE ZBAPI_EXPORT-TEXTLINE
*" VALUE(RETURN) LIKE BAPIRETURN STRUCTURE BAPIRETURN
*"----------------------------------------------------------------------
DATA: G_YEAR1 TYPE SY-DATUM,
G_YEAR2 TYPE SY-DATUM.
DATA: T_2001 LIKE PA2001 OCCURS 0 WITH HEADER LINE.
G_YEAR1+0(4) = START_DATE+0(4).
G_YEAR1+4(2) = ‘01’.
G_YEAR1+6(2) = ‘01’.
G_YEAR2+0(4) = START_DATE+0(4).
G_YEAR2+4(2) = ‘12’.
G_YEAR2+6(2) = ‘31’.
OK_TAG = ‘Y’.
IF LEAVE_TYPE EQ ‘0052’.
SELECT * FROM PA2001 INTO TABLE T_2001
WHERE PERNR = EMPLOYEENUMBER
AND SUBTY = '0052'
AND BEGDA GE G_YEAR1
AND ENDDA LE G_YEAR2.
IF SY-SUBRC EQ 0.
TEXTLINE = 'Error : LTC already applied for the current year'.
OK_TAG = 'Y'.
RETURN.
ENDIF.
IF START_DATE < SY-DATUM.
TEXTLINE = 'Error : Pls apply manually for past period LTC.'.
OK_TAG = 'N'.
RETURN.
ENDIF.
ENDIF.
OK_TAG = ‘Y’.
TEXTLINE = ‘OK. Please proceed with your leave application’.
ENDFUNCTION.
please help me i m very needful.
thanks in advance
i m waiting for ur reply