Skip to Content
0
Former Member
Feb 11, 2005 at 08:21 PM

DELIVERY DATE PROBLEM

38 Views

I have been trying to create a Purchase Order in SAP using the code below:

<%

option explicit

Private Function fillRecordX(Byref Record, Byref RecordX )

Dim iFieldCount

RecordX.AddNew

For iFieldCount = 0 To Record.Fields.Count - 1

' response.Write "Name = " + Record.Fields.Item(iFieldCount).Name + "<br>"

' response.Write "DefinedSize = " + cstr(RecordX.Fields(Record.Fields.Item(iFieldCount).Name).DefinedSize) + "<br>"

If (CStr(Record.Fields.Item(iFieldCount).Value) <> "") Then

If ((RecordX.Fields(Record.Fields.Item(iFieldCount).Name).DefinedSize = 2)) then ' And _

'(RecordX.Fields(Record.Fields.Item(iFieldCount).Name).Type = 200)) Then

RecordX.Fields(Record.Fields.Item(iFieldCount).Name).Value = "X"

End If

End If

Next

RecordX.Update

end function

Private Function writeFields(oResult, name)

Response.Write "<b>" + name + ":</b><br><br>"

dim i

If Not (oResult Is Nothing) Then

while not oResult.EOF

For i = 0 To oResult.Fields.Count - 1

Response.Write cstr(oResult.Fields(i).Name) + " = " + cstr(oResult.Fields(i).Value) + " <br>"

next

Response.Write "<br><br><br>"

oResult.MoveNext

wend

end if

end function

Dim oBAPI

Dim oPOHeader

Dim oPOHeaderX

Dim oPOItem

Dim oPOItemX

Dim oPOSchedule

Dim oPOScheduleX

Dim OPOAccount

Dim OPOAccountX

Dim POCond

Dim POCondX

Dim POCondHeader

Dim POCondHeaderX

Dim oResult

Dim POTxtItem

Dim PoTxtHeader

Dim PoSchedule

Dim PoScheduleX

Dim PoAccount

Dim PoAccountX

Set oBAPI = CreateObject("SAP.PurchaseOrder.1")

oBAPI.Destination = "DCOM-COKE4-DESENV"

'PO HEADER %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

OBapi.DimAs "BapiCreateFromData1", "POHEADER", oPOHeader

oPOHeader.AddNew

oPOHeader.Fields("DOC_TYPE").Value = "NB"

oPOHeader.Fields("CREAT_DATE").Value = "2005/04/13"

oPOHeader.Fields("PMNTTRMS").Value = "C020"

oPOHeader.Fields("INCOTERMS1").Value = "CIF"

oPOHeader.Fields("INCOTERMS2").Value = "CIF obs"

oPOHeader.Fields("CURRENCY").Value = "BRL"

oPOHeader.Fields("EXCH_RATE").Value = "1"

oPOHeader.Fields("PURCH_ORG").Value = "OCJP"

oPOHeader.Fields("PUR_GROUP").Value = "GJP"

oPOHeader.Fields("COMP_CODE").Value = "PROD"

oPOHeader.Fields("ITEM_INTVL").Value = "00010"

oPOHeader.Fields("VENDOR").Value = "0000300555"

oPOHeader.Fields("LANGU").Value = "P"

oPOHeader.Fields("LANGU_ISO").Value = "PT"

oPOHeader.Update

' POHEADERX

OBapi.DimAs "BapiCreateFromData1", "POHEADERX", oPOHeaderX

fillRecordX oPOHeader, oPOHeaderX

'PO ITEMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

OBapi.DimAs "BapiCreateFromData1", "POITEM", oPOItem

oPOItem.AddNew

oPOItem.Fields("PO_ITEM").Value = "00010"

oPOItem.Fields("SHORT_TEXT").Value = "Texto curto teste Deliv"

oPOItem.Fields("MATERIAL").Value = "N14010005"

oPOItem.Fields("PLANT").Value = "CECG"

oPOItem.Fields("QUANTITY").Value = "20.000"

oPOItem.Fields("PO_UNIT").Value = "UN"

oPOItem.Fields("NET_PRICE").Value = "17,250"

oPOItem.Fields("TAX_CODE").Value = "C1"

oPOItem.Fields("ACCTASSCAT").Value = "K"

oPOItem.Fields("PRICE_UNIT").Value = "1"

oPOItem.Fields("BRAS_NBM").Value = "0099999999"

oPOItem.Update

'oPOItemX

OBapi.DimAs "BapiCreateFromData1", "POITEMX", oPOItemX

fillRecordX oPOItem, oPOItemX

oPOItemX.Fields("PO_ITEM").Value = "00010"

oPOItemX.Update

' PoSchedule %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

OBapi.DimAs "BapiCreateFromData1", "POSCHEDULE", PoSchedule

PoSchedule.AddNew

PoSchedule.Fields("PO_ITEM").Value = "00010"

PoSchedule.Fields("SCHED_LINE").Value = "0001"

PoSchedule.Fields("DEL_DATCAT_EXT").Value = "D"

PoSchedule.Fields("DELIVERY_DATE").Value = "2005/04/12"

PoSchedule.Fields("QUANTITY").Value = "20.000"

PoSchedule.Fields("DELIV_TIME").Value = "2005/04/12 08:45:00"

PoSchedule.Fields("PO_DATE").Value = "2005/04/12"

PoSchedule.Update

OBapi.DimAs "BapiCreateFromData1", "POSCHEDULEX", PoScheduleX

fillRecordX PoSchedule, PoScheduleX

' Preenche campos nao triviais de PoScheduleX.

PoScheduleX.Fields("PO_ITEM").Value = "00010"

PoScheduleX.Fields("SCHED_LINE").Value = "0001"

' PoAccount %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

OBapi.DimAs "BapiCreateFromData1", "POACCOUNT", PoAccount

PoAccount.AddNew

PoAccount.Fields("PO_ITEM").Value = "00010"

PoAccount.Fields("COSTCENTER").Value = "0000017306"

PoAccount.Update

OBapi.DimAs "BapiCreateFromData1", "POACCOUNTX", PoAccountX

fillRecordX PoAccount, PoAccountX

' Preenche campos nao triviais de PoScheduleX.

PoAccountX.Fields("PO_ITEM").Value = "00010"

' PoCond %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

OBapi.DimAs "BapiCreateFromData1", "POCOND", PoCond

OBapi.DimAs "BapiCreateFromData1", "POCONDX", PoCondX

POCond.AddNew

POCond.Fields("ITM_NUMBER").Value = "00010"

POCond.Fields("COND_TYPE").Value = "PBXX"

POCond.Fields("COND_VALUE").Value = ""

POCond.Fields("CURRENCY").Value = "BRL"

POCond.Fields("CHANGE_ID").Value = "U"

POCond.Update

fillRecordX PoCond, PoCondX

' Preenche campos nao triviais de PoScheduleX.

PoCondX.Fields("ITM_NUMBER").Value = "00010"

POCond.AddNew

POCond.Fields("ITM_NUMBER").Value = "00010"

POCond.Fields("COND_TYPE").Value = "PBXX"

POCond.Fields("COND_VALUE").Value = "5,100"

POCond.Fields("CURRENCY").Value = "BRL"

POCond.Fields("CHANGE_ID").Value = "U"

POCond.Update

fillRecordX PoCond, PoCondX

' Preenche campos nao triviais de PoScheduleX.

PoCondX.Fields("ITM_NUMBER").Value = "00010"

' Result %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

OBapi.DimAs "BapiCreateFromData1", "return", oResult

response.Write "Input values<br>"

writeFields oPOHeader, "oPOHeader"

writeFields oPOHeaderX, "oPOHeaderX"

writeFields oPOItem, "oPOItem"

writeFields oPOItemX, "oPOItemX"

'writeFields oPOSchedule, "oPOSchedule"

'writeFields oPOScheduleX, "oPOScheduleX"

'writeFields OPOAccount, "OPOAccount"

'writeFields OPOAccountX, "OPOAccountX"

writeFields POCond, "POCond"

writeFields POCondX, "POCondX"

'writeFields POCondHeader, "POCondHeader"

'writeFields POCondHeaderX, "POCondHeaderX"

'writeFields oResult, "oResult"

'writeFields POTxtItem, "POTxtItem"

'writeFields PoTxtHeader, "PoTxtHeader"

writeFields PoSchedule, "PoSchedule"

writeFields PoScheduleX, "PoScheduleX"

writeFields PoAccount, "PoAccount"

writeFields PoAccountX, "PoAccountX"

' bapi Call %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

'oBAPI.BapiCreateFromData1 oPOHeader, oResult, , , oPOItem, oPOHeaderX, oPOItemX, PoSchedule, PoScheduleX, PoAccount, ,PoAccountX, PoCond, PoCondX, , , , , , , , , , , , , , ,PoTxtHeader, POTxtItem

' Show result %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Response.Write "<br><br><br>"

Response.Write "<b>Result:</b><br>"

dim i

while not oResult.EOF

For i = 0 To oResult.Fields.Count - 1

Response.Write cstr(oResult.Fields(i).Name) + " = " + cstr(oResult.Fields(i).Value) + " <br>"

next

Response.Write "<br><br><br>"

oResult.MoveNext

wend

'oBAPI.RollBackWork()

oBapi.CommitWork()

%>

CAN ANYONE TELL ME WHY THE DELIVERY DATE IN SAP IS ALWAYS THE ACTUAL DATE???