Great Plain Stored Procedure [taSopLineIvcInsert] Error 5313 - gp

Sql procedure error codes returned:
Error Number = 5313 Stored Procedure taSopLineIvcInsert Error Description = Unit of Measure does not exist for the Unit of Measure Schedule being used
Node Identifier Parameters: taSopLineIvcInsert
SOPNUMBE = FXINV17-0183253
SOPTYPE = 3
Related Error Code Parameters for Node : taSopLineIvcInsert
NONINVEN = Note: This parameter was not passed in, no value for the parameter will be returned.
UOFM = EA
<taSopLineIvcInsert>
<SOPTYPE>3</SOPTYPE>
<SOPNUMBE>FXINV17-0183253</SOPNUMBE>
<CUSTNMBR>CCT-136</CUSTNMBR>
<DOCDATE>26/9/2017</DOCDATE>
<ITEMNMBR>DVG-013</ITEMNMBR>
<UNITPRCE>30.00000</UNITPRCE>
<QUANTITY>1.00000</QUANTITY>
<ITEMDESC>DRIED MUSHROOM</ITEMDESC>
<DOCID>STDINV </DOCID>
<DEFEXTPRICE>1</DEFEXTPRICE>
<UOFM>EA</UOFM>
</taSopLineIvcInsert>

The error message is coming from the Microsoft Dynamics GP eConnect
API. eConnect stored procedure taSopLineIvcInsert, performs
validation on the data to ensure the imported transaction complies
with the Dynamics GP business rules.
The 5313 error is indicating that the UOM Schedule assigned to item
DVG-013 does not contain the Unit of Measure value of "EA" that was
passed in with the SOP transaction.
Please login to Dynamics GP, open the Item Maintenance window, select
item DVG-013, and then check the UOM Schedule ID assigned to that
item. Then click on the UOM Schedule ID link and review the list of
acceptable values for that UOM Schedule. You may see a value of
"Each", but not "EA".

Related

Snowflake Tasks causing error in timezone in queries

I am running a simple insert query inside a stored procedure with to_timeatamp_ntz("column value") along with other columns.
This works fine when I am running it with the snowflake UI and logged in with my account.
This works fine when I am calling it using python scripts from my visual studio instance.
The same stored procedure fails when it is being called by a scheduled task.
I am thinking if it has something to do with the user's timezone of 'System' vs my time zone.
Execution error in store procedure LOAD_Data(): Failed to cast variant
value "2019-11-27T13:42:03.221Z" to TIMESTAMP_NTZ At
Statement.execute, line 24 position 57
I tried to provide timezone as session parameters in task and in the stored proc but does not seem to be addressing the issue. Any ideas?
I'm guessing (since you didn't include the SQL statement that causes the error) that you are trying to bind a Date object when creating a Statement object. That won't work.
The only parameters you can bind are numbers, strings, null, and the special SfDate object that you can only get from a result set (to my knowledge). Most other parameters must be converted to string using mydate.toJSON(), JSON.stringify(myobj), etc., before binding, eg:
var stmt = snowflake.createStatement(
{ sqlText: `SELECT :1::TIMESTAMP_LTZ NOW`, binds: [(new Date).toJSON()] }
);
Date object errors can be misleading, because Date objects causing an error can be converted and displayed as strings in the error message.
I found the issue:
my Task was using a copy paste effect similar to this:
CREATE TASK TASK_LOAD_an_sp
WAREHOUSE = COMPUTE_WH
TIMEZONE = 'US/Eastern'
SCHEDULE = 'USING CRON 0/30 * * * * America/New_York'
TIMESTAMP_INPUT_FORMAT = 'YYYY-MM-DD HH24'
AS
Call LOAD_an_sp();
The Timestamp input format was causing this.

How to write a SELECT for a field of type "quantity" in SET_GET_ENTITY method?

I want to select a single row with all columns from my table zbookings. zbookings table has a structure based on zbooking data structure - see tables below.
Table ZBOOKINGS:
Structure ZBOOKING:
My BOOKINGSET_GET_ENTITY method:
method BOOKINGSET_GET_ENTITY.
DATA: ls_keytab TYPE LINE OF /IWBEP/T_MGW_NAME_VALUE_PAIR,
i_carrid TYPE string,
i_connid TYPE string,
i_fldate TYPE string,
i_bookid TYPE string.
LOOP AT it_key_tab INTO ls_keytab.
CASE ls_keytab-name.
WHEN 'Carrid'.
i_carrid = ls_keytab-value.
WHEN 'Connid'.
i_connid = ls_keytab-value.
WHEN 'Fldate'.
i_fldate = ls_keytab-value.
WHEN 'Bookid'.
i_bookid = ls_keytab-value.
ENDCASE.
ENDLOOP.
SELECT SINGLE *
INTO CORRESPONDING FIELDS OF er_entity
FROM ybookings AS a
WHERE
a~carrid = i_carrid AND
a~connid = i_connid AND
a~fldate = i_fldate AND
a~bookid = i_bookid.
endmethod.
I tested it via SAP Gateway Client. It's OK when I remove column luggweight from my SELECT SINGLE * statement. However when I select all columns via SELECT SINGLE *, then it outputs an error
Runtime Error: 'SAPSQL_PARSER_TODO_WARNING'`
<?xml version="1.0" encoding="UTF-8"?>
<error>
<code>SAPSQL_PARSER_TODO_WARNING</code>
<message>Runtime Error: 'SAPSQL_PARSER_TODO_WARNING'.
The OData request processing has been abnormal terminated. If "Runtime Error"
is not initial, launch transaction ST22 for details and analysis. Otherwise,
launch transaction SM21 for system log analysis.</message>
<timestamp>20190905144432</timestamp>
</error>
As you can see the problem is with luggweight field which is of quantity type and its typing method is Type ref to. When I check my BOOKINGSET_GET_ENTITY method via ctr+F2 it outputs a warning:
The database field or the result type of the aggregate function LUGGWEIGHT and the component "LUGGWEIGHT" of "ER_ENTITY" are not compatible.
How should I modify my SELECT query / BOOKINGSET_GET_ENTITY method for it to work?
Luggweight field's typing method should be set to Types (not Type ref to) when creating / modifying zbooking data structure.

How to execute Report given the results of a previously executed Report in ABAP

My problem is the following:
I have one report called Y5000112.
My colleagues always execute it manually once with selection screen variant V1 and then execute it a second time with variant V2 adding the results of the first execution to the selection.
Those results in this case are PERNR.
My goal:
Automate this - execute that query twice with one click and automatically fill the PERNR selection of the second execution with the PERNR results of the first execution.
I found out how to trigger a report execution and after that another one, how to set it to a certain variant and got this far - [EDIT] after the first answer I got a bit further but I still have no idea how to loop through my results and put them into the next Report submit:
DATA: t_list TYPE TABLE OF abaplist.
* lt_seltab TYPE TABLE OF rsparams,
* ls_selline LIKE LINE OF lt_seltab.
SUBMIT Y5000114
USING SELECTION-SET 'MA OPLAN TEST'
EXPORTING LIST TO MEMORY
AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = t_list
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE 'Unable to get list from memory'.
ELSE.
* I want to fill ls_seltab here with all pernr (table pa0020) but I haven't got a clue how to do this
* LOOP AT t_list.
* WRITE /t_list.
* ENDLOOP.
SUBMIT Y5000114
* WITH-SELECTION-TABLE ls_seltab
USING SELECTION-SET 'MA OPLAN TEST2'
AND RETURN.
ENDIF.
P.S.
I'm not very familiar with ABAP so if I didn't provide enough Information just let me know in the comments and I'll try to find out whatever you need to know in order to solve this.
Here's my imaginary JS-Code that can express very generally what I'm trying to accomplish.
function submitAndReturnExport(Reportname,VariantName,OptionalPernrSelection)
{...return resultObject;}
var t_list = submitAndReturnExport("Y5000114","MA OPLAN TEST");
var pernrArr = [];
for (var i in t_list)
{
pernrArr.push(t_list[i]["pernr"]);
}
submitAndReturnExport("Y5000114","MA OPLAN TEST2",pernrArr);
It's not that easy as it supposed to, so there won't be any one-line snippet. There is no standard way of getting results from report. Try EXPORTING LIST TO MEMORY clause, but consider that the report may need to be adapted:
SUBMIT [report_name]
WITH SELECTION-TABLE [rspar_tab]
EXPORTING LIST TO MEMORY
AND RETURN.
The result of the above statement should be read from memory and adapted for output:
call function 'LIST_FROM_MEMORY'
TABLES
listobject = t_list
EXCEPTIONS
not_found = 1
others = 2.
if sy-subrc <> 0.
message 'Unable to get list from memory' type 'E'.
endif.
call function 'WRITE_LIST'
TABLES
listobject = t_list
EXCEPTIONS
EMPTY_LIST = 1
OTHERS = 2
.
if sy-subrc <> 0.
message 'Unable to write list' type 'E'.
endif.
Another (and more efficient approach, IMHO) is to gain access to resulting grid via class cl_salv_bs_runtime_info. See the example here
P.S. Executing the same report with different parameters which are mutually-dependent (output pars of 1st iteration = input pars for the 2nd) is definitely a bad design, and those manipulations should be done internally. As for me one'd better rethink the whole architecture of the report.

PXDatabase should accept PXDbType.Udt in Acumatica ERP

How can I call a stored procedure in Acumatica via PXDataBase which has as input parameter User defined type?
For example, I have the following type:
CREATE TYPE [dbo].[string_list_tblType] AS TABLE(
[RefNbr] [nvarchar](10) NOT NULL,
PRIMARY KEY CLUSTERED
(
[RefNbr] ASC
)WITH (IGNORE_DUP_KEY = OFF)
)
GO
I have the following stored procedure:
CREATE PROCEDURE [dbo].[GetListOfAPInvoices]
#APInvoices as string_list_tblType readonly,
AS
BEGIN
select * from APInvoice a where a.RefNbr in (select RefNbr from #APInvoices)
END
and following fragment of C# code:
var par = new SqlParameter("APInvoices", dt);
par.SqlDbType = SqlDbType.Structured;
par.TypeName = "dbo.string_list_tblType";
par.UdtTypeName = "dbo.string_list_tblType";
par.ParameterName = "APInvoices";
PXSPParameter p1 = new PXSPInParameter("#APInvoices", PXDbType.Udt, par);
var pars = new List<PXSPParameter> { p1};
var results = PXDatabase.Execute(sqlCommand, pars.ToArray());
but when I execute my C# code I'm receiving error message:
UdtTypeName property must be set for UDT parameters
When I debugged with reflector class PXSqlDatabaseProvider, method
public override object[] Execute(string procedureName, params PXSPParameter[] pars)
I noticed that
using (new PXLongOperation.PXUntouchedScope(Thread.CurrentThread))
{
command.ExecuteNonQuery();
}
command.Parameters.Items has my method parameters, but item which is related to Udt type is null. I need to know how to pass user defined table type. Has anybody tried this approach?
Unfortunately UDT parameters are not supported in Acumatica's PXDatabase.Execute(..) method and there is no way to pass one to a stored procedure using the built-in functionality of the platform.
Besides, when writing data-retrieval procedures like the one in your example, you should acknowledge that BQL-based data-retrieval facilities do a lot of work to match company masks, filter out records marked as DeletedDatabaseRecord and apply some other internal logic. If you chose to fetch data with plain select wrapped into a stored procedure you bypass all this functionality. Hardly is this something that you want to achieve.
If you absolutely want to use a stored procedure to get some records from the database but don't want the above side-effect, one option is to create an auxiliary table in the DB and select records into it using a procedure. Then in the application you add a DAC mapped to this new table and use it to get data from the table by means of PXSelect or similar thing.
Coming back to your particular example of fetching some ARInvoices by the list of their numbers, you could try using dynamic BQL composition to achieve something like this with Acumatica data access facilities.

Unit Price Attribute Not Visible in Quickbooks Desktop API

I don't see the Unit Price attribute available in the Item Class when it comes to QBD. Its available in QBO. I am trying to download and fill a database using the items entered via Quickbooks desktop version. Can someone help please?
How can I get the Unit Price for an item in Intuit.Ipp.Data.Qbd.Item?
Extra Information Added after comment by Shivan Raptor (7-Nov-2013)
I am having a Quickbooks Pro Trial 2014 UK version installed in my computer. I have created a company file and items for the company. When I create an item I can enter a Price to that item. Quickbooks must be saving it somewhere. I need to access it using the Quickbooks API from my .Net application.
I am interested on the stock items here. I am using Intuit.Ipp.Data.Qbd.Item class to access it. Am I using the right class? If you go to the API documentation the Item class has a field called Unit Price but its not listed when you actually check from the .Net application.
Shivan Raptor wanted the code (8-Nov-2013)
Given below is the code snippet. If you understand the question properly you would realize it cannot give a run time error because you cannot compile a code if you write it with object attributes that are not exposed. And the compiler error is kind of obvious too:
ATTRIBUTE_NAME not present in CLASS_NAME
In this case, ATTRIBUTE_NAME = UnitPrice and CLASS_NAME = Intuit.Ipp.Data.Qbd.Item (this is already there in the first post itself)
The relevant code sample is given below. Its the code behind of an ASP.Net page.
Try
Dim varItemBL As New BL.ItemManagement
'Preparing Query
Dim qbdItemQuery As New Intuit.Ipp.Data.Qbd.ItemQuery
qbdItemQuery.ItemElementName = Intuit.Ipp.Data.Qbd.ItemChoiceType4.StartPage
qbdItemQuery.Item = "1"
qbdItemQuery.ChunkSize = "10"
'Quering Quickbooks Desktop
Dim qbdItems = qbdItemQuery.ExecuteQuery(Of Intuit.Ipp.Data.Qbd.Item)(context).ToList
'Synchronising Items from Quickbooks to MyDigiRep
For i As Integer = 0 To qbdItems.Count - 1
Dim varUnitPrice As Decimal
'Checking whether Unit Price is entered
If qbdItems(i).UnitPrice Is Nothing Then
varUnitPrice = 0
Else
varUnitPrice = qbdItems(i).UnitPrice.Amount
End If
'Synchronising Item with the MyDigiRep database
varItemBL.fnAddItemsAPI(qbdItems(i).Name, "NS", varUnitPrice, _
qbdItems(i).UOMAbbrv, HttpContext.Current.Session("companyID"), _
qbdItems(i).Id.Value)
Next
'Updating UI to display synchronisation results
lblItemSycnStatus.Text = qbdItems.Count & " Item Records Synchronised."
Catch ex As Exception
lblItemSycnStatus.Text = "Item Records Synchronisation Failed."
End Try
The version of the Intuit.Ipp.Data.dll is 2.1.12.0

Resources