eConnect 10.0 SLPRSNID & SALSTERR not importing in new line items - dynamics-gp

The following code helps to import a sales line to an invoice:
Dim LineItems(dtItem.Rows.Count) As taSopLineIvcInsert_ItemsTaSopLineIvcInsert
Dim salesLine As New taSopLineIvcInsert_ItemsTaSopLineIvcInsert
'Create Invoice Sales lines
For Each dr In dtItem.Rows
With salesLine
.CUSTNMBR = dr.Item("acctno")
.SOPNUMBE = invoiceNumber
.SOPTYPE = 3
.DOCID = "STD INV"
.QUANTITY = dr.Item("Qty")
.ITEMNMBR = dr.Item("Item")
.ITEMDESC = dr.Item("Memo")
.UNITPRCE = dr.Item("SalesPrice")
.XTNDPRCE = dr.Item("Credit")
.TAXAMNT = 0
.UOFM = "Each"
.SALSTERR = "GENERAL"
.ReqShipDate = dtHdr.Rows(0).Item("InvoiceDate").ToString()
.FUFILDAT = dr.Item("Date1").ToString()
.ACTLSHIP = dr.Item("Date1").ToString()
'.NONINVEN = 0
.DOCDATE = dtHdr.Rows(0).Item("InvoiceDate").ToString()
.SLPRSNID = "C1"
End With
LineItems(rowCtr) = salesLine
rowCtr = rowCtr + 1
Next
The fields for SLPRSNID & SALSTERR are just ignored. The invoice itself is being created with all the line items. ANY ideas from anyone with experience using this API are appreciated!

Since we are not integrating SOP commissions data, importing SLPRSNID & SALSTERR on line items using code like above is not supported. However, eConnect does expose pre and post stored procedures to customize business logic. The following was added in taSopHdrIvcInsertPost to implement the import:
/** Custom Business Logic */
if ((#I_vSLPRSNID <> '') and (#I_vSALSTERR <> ''))
begin
update SOP10200
set SLPRSNID = #I_vSLPRSNID, SALSTERR = #I_vSALSTERR
where SOPNUMBE = #I_vSOPNUMBE and SOPTYPE = #I_vSOPTYPE
end
/** Custom Business Logic */
NOTE: with this implementation, the specific SLPRSNID & SALSTERR will have to be provided to the line items, it will not automatically post from header data, or any customer setup data in GP - your integration has to pass the values in.

Related

Wildcards/patterns with .Tables("PARA") when executing RFC INST_EXECUTE_REPORT

I'm using Excel and VBA to get SAP to download data from SAP through RFC using INST_EXECUTE_REPORT.
It works like a charm when I have specific input parameters. I just build up .Tables("PARA") with the screen name of the parameter and the desired value. I can even use this method for date ranges.
The challenge is when I don't know exactly the input parameters. For example, I wanted to identify all internal orders with a specific text in the description, e.g. CODE40.
Is there any way to use wildcards with INST_EXECUTE_REPORT? When the program passed into INST_EXECUTE_REPORT is executed normally as a transaction on screen, I can set the parameter to *CODE40* and SAP automatically applies a wildcard search. But I can't get that to work with VBA.
I can simulate using wildcards when accessing individual tables with BBP_RFC_READ_TABLE by using LIKE statements in the selection option, but I need a similar functionality for whole reports, not individual tables.
Can anyone help?
Best regards,
The code I'm using is as follows:
Set ObjR3_EXECUTE_REPORT = ObjR3.Add("INST_EXECUTE_REPORT")
With ObjR3_EXECUTE_REPORT
Set ObjR3_EXECUTE_REPORT_Name = .Exports("PROGRAM")
Set ObjR3_EXECUTE_REPORT_Para = .Tables("PARA")
Set ObjR3_EXECUTE_REPORT_Result = .Tables("RESULT_TAB")
Set ObjR3_EXECUTE_REPORT_Output = .Tables("OUTPUT_TAB")
End With
ObjR3_EXECUTE_REPORT_Name.Value = ReportName
'Build up the table with the fields to be selected
f = 1
For a = LBound(aParameters) To UBound(aParameters)
aParameterPair = aParameters(a)
aParameterInput = aParameterPair(UBound(aParameterPair))
sParameterName = aParameterPair(LBound(aParameterPair))
For c = LBound(aParameterInput) To UBound(aParameterInput)
sParameterInput = aParameterInput(c)
ObjR3_EXECUTE_REPORT_Para.AppendRow
ObjR3_EXECUTE_REPORT_Para(f, "PARA_NAME") = sParameterName
ObjR3_EXECUTE_REPORT_Para(f, "PARA_VALUE") = sParameterInput
Debug.Print sParameterName & " " & sParameterInput
f = f + 1
Next c
Next a

How can i add this other condition to this code?

i have this subroutine that i use to make labels. for some reason i cant just make another subroutine where instead of "CGI_SAMPLE_LABEL" it uses "YCI_SAMPLE_LABEL" because of other subroutines. any suggestions on how i can add this so that it chooses either one or the other. if tried using WHERE OR but that didn't work. i edited some of the tags because LIMS basic language is also like smalltalk.
LabelType = "CGI_SAMPLE_LABEL"
pTableNameStr = "SAMPLE"
pLabelNameStr = "CGI_SAMPLE_LABEL"
'Breakpoint(aReason)
NumSamples = Ubound(selectedObjects, 1)
FOR X = 1 TO NumSamples
SampleNumber = selectedObjects[x]
pKeyNameArr[1] = SampleNumber
pNumLabelsInt = 1
pLabelNameStr = "CGI_SAMPLE_LABEL"
pReasonStr = "Auto Label Generation"
pActivityStr = "Label printed for sample logged event"
GOSUB FN_LABEL_PRINT_ALL
NEXT 'Sample
RETURN

How to export text from annotation fields in Nuance Power PDF to Excel using VBA?

I am trying to export some text from annotation fields in Nuance Power PDF to Excel using VBA. I added the Nuance Power PDF reference to Excel VBA (PDF Plus).
I used it and it works well but the text returned from fields is empty.
Set PDFApp = CreateObject("NuancePDF.App")
Set dvDoc = CreateObject("NuancePDF.DVDoc")
dvDoc.Open("\\adpdc-2\Users$\a.goudinoux\Documents\Macro Formulaire\fiche.pdf")
Set ddDoc = dvDoc.GetDDDoc()
Set ddPage = ddDoc.AcquirePage(0)
nbannots = ddPage.GetNumAnnots() - 1
For i = 0 To nbannots
Texte = ""
Set ddAnnot = ddPage.GetAnnot(i)
Set ddText = ddDoc.CreateTextSelect(0, ddAnnot.GetRect())
ThisWorkbook.Sheets(1).Cells(1, i) = ddAnnot.GetTitle()
For k = 0 To ddText.GetNumText()
Texte = Texte & ddText.GetText(k)
Next
ThisWorkbook.Sheets(1).Cells(2, i) = Texte
Next
Part of the PDF document :
Results :
As you can see the first line is working but not the second one.
I thought the problem was with ddText but ddText.GetNumText() gives the right number of text elements in the text selection (ex : 2, 5, 4, etc...) when I run my program in Debug Mode.
I think the problem is from the function GetText(k).
I made it work once but I can't find my code back..
Do you see any mistake ?
Either your annotations are more complex than indicated or you're overthinking it.
Just read the annotation with GetContents and call it a day.
Set PDFApp = CreateObject("NuancePDF.App")
Set dvDoc = CreateObject("NuancePDF.DVDoc")
dvDoc.Open("\\adpdc-2\Users$\a.goudinoux\Documents\Macro Formulaire\fiche.pdf")
Set ddDoc = dvDoc.GetDDDoc()
Set ddPage = ddDoc.AcquirePage(0)
nbannots = ddPage.GetNumAnnots() - 1
For i = 0 To nbannots
Set ddAnnot = ddPage.GetAnnot(i)
ThisWorkbook.Sheets(1).Cells(1, i) = ddAnnot.GetTitle
ThisWorkbook.Sheets(1).Cells(2, i) = ddAnnot.GetContents
Next i

How to add Calculated Member to Pivot Table via Python win32

I'm trying to add a calculated column into this pivot table that is being generated via a python script with import win32com.client.
Code is posted below that is generating the pivot table. I'm not sure how to add a column. In VBA it would be wb.PivotTable.CalculatedField.Add but that didn't work (at least the syntax I tried).
I'm trying to calculate [OoCUnits] / [GrossUnits]
#Make Pivot version with four weeks data
Excel = win32com.client.gencache.EnsureDispatch('Excel.Application')
win32c = win32com.client.constants
wb = Excel.Workbooks.Open(filename)
ws3 = wb.Worksheets('Dataset')
cl1 = ws3.Cells(1,1)
cl2 = ws3.Cells(max_row,max_col)
PivotSourceRange = ws3.Range(cl1,cl2)
ws3.Activate()
PivotSourceRange.Select()
wb.Sheets.Add (After=wb.Sheets(3))
ws4 = wb.Worksheets(4)
ws4.Name = 'Pivot'
cl3 = ws4.Cells(4,1)
PivotTargetRange = ws4.Range(cl3,cl3)
PivotTableName = 'OoCPivot'
#Make Pivot Table
PivotCache = wb.PivotCaches().Create(SourceType=win32c.xlDatabase, SourceData=PivotSourceRange, Version=win32c.xlPivotTableVersion14)
PivotTable = PivotCache.CreatePivotTable(TableDestination=PivotTargetRange, TableName=PivotTableName, DefaultVersion=win32c.xlPivotTableVersion14)
PivotTable.PivotFields('Product Name').Orientation = win32c.xlRowField
PivotTable.PivotFields('Product Name').Position = 1
PivotTable.PivotFields('Customer Number').Orientation = win32c.xlPageField
PivotTable.PivotFields('Customer Number').Position = 1
PivotTable.PivotFields('Customer Name').Orientation = win32c.xlPageField
PivotTable.PivotFields('Customer Name').Position = 2
PivotTable.PivotFields('Week Ending Date').Orientation = win32c.xlColumnField
PivotTable.PivotFields('Week Ending Date').Position = 1
DataField = PivotTable.AddDataField(PivotTable.PivotFields('GrossUnits'))
DataField.NumberFormat = '#0.00'
DataField = PivotTable.AddDataField(PivotTable.PivotFields('OoCUnits'))
DataField.NumberFormat = '#0.00'
I'm inserting the values with the DataField. The script is not presenting any issues as is.
EDIT: The exact code I implemented to solve. The last two lines are just formatting. I'm including in case it helps someone else.
CalcField = PivotTable.CalculatedFields().Add('OoC Unit %','= OoCUnits / GrossUnits')
DataField = PivotTable.AddDataField(PivotTable.PivotFields('OoC Unit %'))
DataField.NumberFormat = '#%'
PivotTable.DisplayErrorString = True
Actually, the method is PivotTable.CalculatedFields().Add() according to docs. Consider placing below at bottom:
CalcField = PivotTable.CalculatedFields().Add("OC_GrossPct", "= OoCUnits / GrossUnits")
PivotTable.PivotFields("OC_GrossPct").Orientation = win32c.xlDataField

How to Display resolved Names in Excel Formulas

Is there an easy way for me to turn the following, if only for a second, into real SQL?:
=IFERROR(eagle("SELECT SUM("&selectedmonth&")/1000, ("& ytdformula & ")/1000 AS YTD, sum(Budget)*"&sMonthIndex&"/12000
FROM ["&environment&"].[dbo].[SD_"&selectedyear&"_flat" & IF(selectedCurrency="USD","","_EUR") &"]
WHERE 1=1
"&IF(selectedDepartment="All",""," AND department = '"&selectedDepartment&"'")&"
"&IF(selectedproduct="All",""," AND product = '"&selectedproduct&"'")&"
"&IF(AND(getMacro=FALSE,getRatesNSU=FALSE),
IF(selecteddivision="All",""," AND division='"&selecteddivision&"'"),
IF(getMacro=TRUE," AND (division = 'Commodities' OR division = 'FX Products' OR division = 'Rate Products')"," AND (division = 'Rate Products' OR product = 'IB Non-Strategic Unit')"))&"
"&IF(exclSMG=FALSE,""," AND Division <> 'Systematic Market Making'")&"
"&IF(selectedsubdivision="All",""," AND subdivision = '"&selectedsubdivision&"'")&"
"&IF(selectedcluster="All",""," AND cluster = '"&selectedcluster&"'")&"
"&IF(selectedregion="All",""," AND region = '"&selectedregion&"'")&"
"&IF(selectedBiz="All",""," AND business_unit IN "&selectedBiz),connectionString),0)
Put the word stop in front of this line of code then paste the following into the VBA Immediate window with a question mark in front of it.
?"SELECT SUM("&selectedmonth&")/1000, ("& ytdformula & ")/1000 AS YTD, sum(Budget)*"&sMonthIndex&"/12000
FROM ["&environment&"].[dbo].[SD_"&selectedyear&"_flat" & IF(selectedCurrency="USD","","_EUR") &"]
WHERE 1=1
"&IF(selectedDepartment="All",""," AND department = '"&selectedDepartment&"'")&"
"&IF(selectedproduct="All",""," AND product = '"&selectedproduct&"'")&"
"&IF(AND(getMacro=FALSE,getRatesNSU=FALSE),
IF(selecteddivision="All",""," AND division='"&selecteddivision&"'"),
IF(getMacro=TRUE," AND (division = 'Commodities' OR division = 'FX Products' OR division = 'Rate Products')"," AND (division = 'Rate Products' OR product = 'IB Non-Strategic Unit')"))&"
"&IF(exclSMG=FALSE,""," AND Division <> 'Systematic Market Making'")&"
"&IF(selectedsubdivision="All",""," AND subdivision = '"&selectedsubdivision&"'")&"
"&IF(selectedcluster="All",""," AND cluster = '"&selectedcluster&"'")&"
"&IF(selectedregion="All",""," AND region = '"&selectedregion&"'")&"
"&IF(selectedBiz="All",""," AND business_unit IN "&selectedBiz),connectionString),0)
The Immediate window will concatenate all the variables and literals into the SQL String that it is attempting to execute.
IF there is errors in the SQL, you should be able to copy the SQL into the QBE editor to get the error message the compiler cannot reconcile.

Resources