Date Difference Query Syntax Formatted Search
Hi Experts,
My client renders a service(warehousing of Cargo) on time and material basis,therefore the Quantity column of the AR Invoice represents the number of days the cargo was warehoused.
I want to create a formatted search with reference to a query on this field to help me compute the number of days automatically. The number of days is normally calculated by Subtracting the the Admission date(Serial Number Details Table "OSRI", field "InDate" from the document date of the invoice) from the AR invoice document date.
Considering that the Item is serial number managed, the item serial number will connect the Serial Number details table to the AR Invoice table.
Can anybody help me with the syntax of the query that will achieve the above for me.
Waiting to hear from you .
Thanks
If you have many serial numbers for an item, there will be no way to identify which serial number was actually selected in the invoice till the time the Invoice is added.
So knowing the Serial Number that was selected on that Invoice is important and what you select in the Serial number selection window on the Invoice is stored in temporary location and cannot be referencing by looking into OSRI table.
If there are multiple serial numbers with different InDate's, how could you calculate?
Is there a Delivery Step? Delivery > Invoice
OR
Do you copy SO > AR Invoice directly
Suda
Similar Messages
-
SQL query for formatted search
Hi guys and expertise,
I have this one problem where i need to do the formatted search,below is my example query that i have done
declare @itemcode varchar (20)
set @itemcode = (select x.itemcode from OITM x where x.ItemCode=[%])
declare @itmgrp varchar(50)
set @itmgrp=(select y.itmsgrpnam from OITB y where y.ItmsGrpNam=[%1])
select
CASE
when @itemcode = 'Item Descriptions 1' then @itmgrp
else t0.ItmsGrpNam
end
from OITB t0 inner join
OITM t1 on t0.ItmsGrpCod=t1.ItmsGrpCod
where t1.itemcode=@itemcode
***correct me if i'm wrong
the condition is :-
whenever the user selection is 'Item Descriptions 1' user will have to select the product group name else
if the user selection is not equal to "Item Descriptions 1", automatically the product group name will be default according
to the item code itself.
i wonder if it's possible? if it is, then i suppose there should be a way,right?Hi Gordon...
Thanks a lot for the answer,
I did try some research and manage to find a way out for the query that I want, the query is as below:-
BEGIN
IF
$[$38.1.0]='Item Descriptions' or $[$38.1.0]='Item Descriptions 1' or $[$38.1.0]='Item Descriptions 2' or
$[$38.1.0]='Item Descriptions 3' or $[$38.1.0]='Item Descriptions 4'
SELECT T0.ItmsGrpNam FROM OITB T0 inner join OITM T1 ON T0.ItmsGrpCod=T1.ItmsGrpCod
Group By T0.ItmsGrpNam
ELSE
SELECT T0.ItmsGrpNam FROM OITB T0 inner join OITM T1
ON T0.ItmsGrpCod=T1.ItmsGrpCod where T1.ItemCode=$[$38.1.0]
END
regards,
Asyraf -
Hi All,
I have a line UDF called U_PO in the sales order documents that denotes our purchase order number that particular item is ordered on.
I have another line UDF called U_XMill which I want to populate with the corresponding PO document due date.
What would be my query for that?
Basically, it should be something like:
SELECT T0.DocDueDate FROM OPOR T0 WHERE T0.DocNum=$[$38.44.0] FOR BROWSE
However, I am sure that "38.44" is wrong.
It should denote my current document's UDF *.U_PO.
And I am not sure what would be the correct notation for it.
I was wondering if there was a help document I could refer to to figure out the corresponding field numbers for the cases like this.
Thank you for your help.Hello
use FMS on matrix (tables) as
[ItemUID.ColumnUID.Type] or [TableName.FieldName]
where itemUID is 38
ColumnUID is U_XMill
Type is 0 (general).
There is a now-to guide on service.sap.com/smb/sbo where you can find how to us FMS.
Regards
J -
I have a below table
student_id course startdate enddate amount
1 .net 12-05-2014 30-7-2014 5000
1 sql 1-06-2014 30-06-2014
3000
2 informtica 1-06-2014 31-07-2014 10000.
so on
output sholud be the amount has to split accross months
student_id course startdate enddate amount month split_amount
1 .net 12-05-2014 30-7-2014 5000
may 1250
1 .net 12-05-2014 30-7-2014
5000 june 1875
1 .net 12-05-2014 30-7-2014 5000
july 1875
1 sql 1-06-2014 30-06-2014
3000 june 3000
2 informtica 1-06-2014 31-07-2014 10000 june
4918
2 informatica 1-06-2014 31-07-2014 10000 july
5082
please suggest me any query..Hi,
i think this may help you,
first i created the temp table (you can replace it with your data table)
Declare @t Table (student_id Int,course Varchar(100),startdate DateTime,enddate DateTime,amount Decimal(12,0))
Insert Into @t
Select 1,'.net','2014-05-12','2014-07-30',5000
Union
Select 1,'sql','2014-06-01','2014-06-30',3000
Union
Select 2,'informtica','2014-06-01','2014-07-31',10000
;with cte As (
Select t.*,cd.LatinMonthTitle,t.amount/Count(cd.id) Over(Partition By student_id,course) As AmountPerDay,cd.LatinMonthId--*Count(cd.id)
From @t As t
Inner Join @DateIndex As cd On cd.LatinDate Between t.StartDate And t.EndDate)
Select student_id,course,startdate,enddate,amount,LatinMonthTitle,Cast(Count(1)*AmountPerDay As Decimal(12,0)) As AmountPerMonth
From cte
Group By student_id,course,startdate,enddate,amount,LatinMonthTitle,AmountPerDay,LatinMonthId
Order By 1,2,LatinMonthId
You need to know about my @DateIndex Table!
you should build this table and it's useful many time.
declare @dateindex table(Id Int Identity(1,1),LatinDate DateTime,LatinMonthId Int,LatinMonthTitle Varchar(100))
declare @i int=0
declare @FirstDate datetime='2014-01-01'
declare @CurrDate datetime=@FirstDate
while @i<1000
begin
Set @CurrDate=DATEADD(day,@i,@FirstDate)
insert into @dateindex
(LatinDate,LatinMonthId,LatinMonthTitle)
Select @CurrDate,DATEPART(MONTH,@CurrDate),DATENAME(MONTH,@CurrDate)
set @i+=1
end
Select * From @dateindex -
How do i deduct dates using formatted search with a query
Hi Experts,
I would like to know how to get the date difference using query and formatted search. Below are the details:
1. I have created 3 Header UDF's composed of 2 Date type fields and 1 Quantity field.
2. The first one is for the Original Date, the next one is for the Payment Date and the Last one is for the No. of Days Lapsed.
What I would like to do is automatically compute for the number of days from the original date to the payment date. What query syntax should i use to achieve this?
Thanks,
YvetteHi Yvette,
It should be something like;
DATEDIFF (day, T0.[createDate], T0.[closeDate] ) as 'Aging' This is just an example. You may add your udf's instead of dates.
Thanks,
Joseph
Edited by: Joseph Antony on Jul 2, 2010 1:53 PM -
Formatted Search Query for BatchNo
Dear All,
I am using the following query as formated search for Identifying the batches availble during the creation of Delivary document
in a user defined column at row level. When i click on this field it's showing the Batches for the Item with Zero Qty also.
I need to display only the batches where the QTY >0. This query displaying even the Zero Qty Batches also. Please help me to modify the below query for getting the above. Below is the query .
SELECT distinct T4.[BatchNum] FROM [dbo].[OIBT] T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode INNER JOIN DLN1 T2 ON T1.ItemCode = T2.ItemCode INNER JOIN ODLN T3 ON T2.DocEntry = T3.DocEntry INNER JOIN IBT1 T4 ON T0.BatchNum = T4.BatchNum AND T3.DocNum = T4.BaseNum INNER JOIN OWHS T5 ON T0.WhsCode = T5.WhsCode WHERE T0.[ItemCode] = $[$38.1] AND T4.[WhsCode] = $[$38.24] AND T0.[Quantity]>=$[$38.11]
Regards
Srinii removed that T5, But It's showing the Batches where the qty in the main warehouse for that batch is Zero.That batch was actually present in another warehouse. And also when i am working on other warehouses it's showing the batches in the main warehouse where the qty is present.
Regards
Srini
Edited by: Srini on May 11, 2010 10:24 PM -
Formatted search query for displaying invoice items details
hi all,
i need to display all the items in AP invoice.kindly suggest me a query for that.
in AP invoice
Ex. row items
code--descqtyprice--
total
I0001--XXXXXXX5--
100 -
500
query should display this row as
code--desc--
price
I0001--XXXXXXX--
100
I0001--XXXXXXX--
100
I0001--XXXXXXX--
100
I0001--XXXXXXX--
100
I0001--XXXXXXX--
100
=================================
the query should display as the qty is 5 so it will display the same item 5 times
kindly suggest me some query for formatted search
its very urgent
regards
sandipHi Sandip,
DoQuery("Select b.ItemCode from OINV a,INV1 b Where a.DocEntry=b.DocEntry")
Hope its help for you
Give me reward points,
Regards,
G.Suresh. -
Failed to find out the source table of query in the formated search
Dear All,
I am trying to find out how to know the table that it is the source of a formatted search query. In the query manager --> formatted search --> select one of query --> double click to see the query. I see the query but I can't find out what table it will be used if the query like this :
SELECT $[$13.87.NUMBER] - ($[$13.9.NUMBER] + $[$13.88.NUMBER])
If I go to receipt from production form, the column no relate to the above query are mixture of IGE1 and OWOR, so what actually the table must I choose if I redesign the above query from query generator. I need your help to solve this question. I appreciate your answer. TIA
Rgds,
SteveHi Steve,
Assuming the FS is currently assigned to a form field you could try the following:
- Look in OUQR for the query and get it's id (OUQR.IntrnalKey).
- Look for this id value in CSHS.QueryID and check the FormID value of any records listed. It's not the table name you're looking for but the FormID might help e.g. 139 = Sales Order = ORDR/RDR1 etc.
Hope this helps.
Regards,
Andrew. -
Formatted search query adding spaces
Hello,
I have created a table U_Items in SBO database.
I was trying to run this query using formatted search.
SELECT ItemDesc
FROM U_Items T0
WHERE T0.ItemCode = RTRIM(LTRIM('$[$38.1.0]'))
When the query gets executed '$[$38.1.0]' is repalced
by 'N'A00001 '' value.
I want the value to be 'A00001' so that it can match the record in the U_Items. How can I get rid of the trailing spaces?
Thanks,
SheetalHello Sheetal,
Your query,
SELECT ItemDesc
FROM U_Items T0
WHERE T0.ItemCode = RTRIM(LTRIM('$[$38.1.0]'))
I think must be
SELECT ItemDesc
FROM [@U_Items] T0
WHERE T0.ItemCode = RTRIM(LTRIM($[$38.1.0]))
if this is a user defined table.
I think your query seems ok. It doesn't work? -
Formatted search to auto generate Item No.
Hi,
Customer is using 2007A PL47. They had requirement to auto generate Item No based on UDF created in Item Master Data(OITM). The stock code structure is as follow:
Item No=EP(hardcode 2 char)+U_ProdRange U_ProdGroupU_ProdFamily+user defined text
The keystroke steps are:
1. Key in item description
2. Select drop down list for U_ProdRange in OITM
3. Select drop down list for U_ProdGroup in OITM
4. Select drop down list for U_ProdFamily in OITM
5. Formatted search to generate Item No based on 2,3, 4
6. User keys in user defined text in Item No
7. Fill in other relevant fields in Item Master Data
8. Add Item Master Data
May I know how to write the query in formatted search?
Regards
ThomasHi,
I had got solution.
Try this Select TOP 1 'EP' +$[OITM.U_ProdRange] +$[OITM.U_Prodgroup] +$[OITM.U_ProdFamily]
Regards
Thomas -
Using Second Column of Formatted Search
Hi All,
i have a query for formatted Search, which goes like This
"Select ItemName, ItemCode from oitm"
When i press Tab on the field 'Product No.' in 'Production order',
i get the CFL of ItemName and ItemCode.
when i select one row from this, i need to capture the ItemCode
in the field 'Product No.' (By Default it captures the first Column i.e ItemName)
Any suggestion are most welcome
Regards,
MahendraMahendra,
By default it will fetch the first column only. one workaround what you may not like to use is, to define a user defined field in production order form and give an FMS there. ther you show the itemname first as you have written, and give an Auto refresh FMS on production order field where you change it to itemcode when item name is selected.
HTH,
Regards,
Binita -
How to create a query for formatted search if my variable is in the matrix(some column and some row).
I would like the SAP user get a list of all Workorders for a Job, and Job is a cell in matrix.
Workorder value should be shown in another cell in the same row.
Thanks a lot,Hi Pavel,
The document 'How to Define and Use Formatted Search' on the Service Market Place goes through defining and using formatted searches with queries. It also explains how to use fields in an active form in a formatted search, look at the section called 'Search by Saved Query' in the document.
To find this document go to
www.service.sap.com -> Channel Partner Portal -> Solutions - SAP Business One -> Support -> Additional Information - Documentation Resource Centre -> SAP Business One 2005 A SP 01 -> How to guides -> 'How to Define and Use Formatted Search'
This document also gives some examples of the types of queries which are used in formatted searches.
Hope this helps
Noreen -
Formatted Search on Inventory Posting
Dear Experts,
I have a FMS on inventory posting distribution rule, its supposed to display the distribution rule automatically for the items, without human intervention. How can I set this to auto-refresh ? since when using this form virtually no column is normally touched apart from the reconcile button.
Edited by: Roc on Apr 8, 2010 4:27 PMHi Gordan,
we have upgraded SAP B1 2005 to 2007 - we are using old query for formatted search for items in marketing document - can in that cancelled items also reflecting - can you please correct that query where i dont want to reflect cancelled items.
SELECT T0.[ItemCode] AS 'Item No.', T0.[ItemName] AS 'Item Description', T0.[UserText] AS 'Item Details', T0.[OnHand] AS 'In Stock' ,T0.PrchseItem,T0.SellItem FROM [dbo].[OITM] T0 WHERE (T0.[UserText] Like N'%[%0]%' ) AND (T0.[UserText] Like N'%[%1]%' ) AND (T0.[UserText] Like N'%[%2]%' ) AND (T0.[UserText] Like N'%[%3]%' )
Thanks -
Query - Formatted Search in a User Defined Field
Hi,
I am having some problems with a very simple query but it doesn't seem to work. I insert this formatted search in to my UDF I made called Cost. The query I am using is:
SELECT $[$34.0.0] - (I had to use variable number because this Unit Price field in the Item master data does not have a field name associated)
It is supposed to grab the unit price from the screen, however it is always displaying zero when I query it, and when I put it in the UDF as a formatted search, it give me the internal error.
I would greatly appreciate your help.
ThanksQuestion 1: Where is this Cost UDF defined. Is it at the Marketing document Header or row level?
NOTE:
The field reference for the Unit Price column is incorrect. When you mouse over the Unit Price column you should see the values for Item=xx Colunm=xx
The syntax is $\[$Item.Column.Type]. Therefore for your case it should be $\[$38.14.Number]
The type prefix can be 0 if you are accessing a Alphanumeric column.
If you user field is at the Header level the Formatted Search Query might not work unless you highlight that whole row and then click on the header level UDF and press Shift+F2
How have you set the refresh options? -
UDF - formatted search help using query
I've created a UDF for 'activities' called U_BP_Link - it has a formatted search query which simply displays all data in the OCRD business partner database. I wanted to also fill in a UDF which would display the 'description' of the BP that was selected in the U_BP_Link field. I'm having trouble coming up with the correct syntax for the query associated with the UDF name field. This is giving me a syntax error near $[$U_BP_Link]................
SELECT T0.CardName FROM OCRD T0 INNER JOIN OCLG T1 ON T0.CardCode = T1.U_BP_Link Where T0.CardCode = $[$U_BP_LINK.1.0]Good Day,
I don't fully understand your situation.
I'm thinking you have 2 UDFs. One is OCLG.U_BP_Link and the second is the 'also fill in a UDF' and that is to be populated with OCRD.CardName based on data entry in OCLG.U_BP_Link
That being the case, I would create a FMS on OCLG.U_BP_Name field to:
1) Search in Saved Query - create query similiar to SELECT OCRD.CardName FROM OCRD, OCLG Where OCRD.CardCode = $[OCLG.U_BP_LINK] FOR BROWSE
Create and test the query and after results are generated as expected, substitue the $[OCLG.U_BP_LINK]. The query will error in SAP but is OK for use in FMS.
2) Auto refresh when Field Changes
3) Based on field OCLG.U_BP_Link - actually the description for this field.
4) Display saved values
It could work.
M
Maybe you are looking for
-
Airport connection problems after software update
I cannot connect to a Wi-Fi network I have been using for days. This happened after installing software updates for quicktime, itunes, airport extreme, safari and Security Update 2008-002. When i run network diagnostics, it tells me this network need
-
Open multiple images from the project bin
In Elements 9 I can only seem to open 1 image from the project bin at a time! What am I doing wrong? Bob Dunkerley.
-
Need help in this code snippet for split container
Hi, I am using the following code to display two tables in report output. using cl_salv_table. ============================================================================================= START-OF-SELECTION. DATA: lo_report TYPE REF TO lcl_test_clas
-
Ocrcheck shows "Logical corruption check failed"
Hi, I have a strange issue, that I am not sure how to recover from... In a random 'ocrcheck' we found the above 'logical corruption'. In the CRS_HOME/log/nodename/client/ I found the previous ocrcheck was done a month earlier and was successful. So,
-
Problem with system config "@^@^@^@^@"
Hello, newbie here (to the forums and to linux in general). I have been trying to install archlinux on my virtual machine for the past few days, following tutorials on youtube and on the archwiki, and I have hit a snag. After installing the packages,