Count no. of records for a particular customer in the query?
Hi,
1)Can anybody guide as to how do we count the number of records for a particular customer. E.g.
C1 has placed 2 orders
C2 has placed 4 orders
C3 has placed 5 orders
so in all the ODS has 11 records. Now while designing the query we need to ensure that we show only the Customers who have placed more than 3 orders. What could be logic to solve this kind of a problem?
2) Is there a way that we can access the structure and data of the ODS in ABAP code say one of the includes in a user exit?
The requirement says there could be N number of cases opened and closed in one month. Now we need to calculate the average number of days taken to close a case? Any ideas on the possible solution.
Thanks
RB
Hi Rajat,
Take a calculated key figure rename it as Count , go to the properties of that calculated key figure on the left hand side not at the columns side in the properties click on the button Enhance which is shown in the down left side, in the exception aggregation part select "count all values <>0" , take the reference character as customer Id . Now go to the Customer character which is in rows go to properties and select "Normalise to" combo box in that select "Query result" now u will get the exact result which ur looking for .
Similar Messages
-
To Get the earlier records in a table for a particular id neglecting the newer ones
Hi All,
I need to get the older records for a particular id rejecting the newer ones..My Scenarios is as follows..
ID Result Date
1 Pass 2015-01-01
1 Fail 2015-03-05
2 Pass 2014-06-07
2 Fail 2015-02-02
My Output will be
ID Result Date
1 Pass 2015-01-01
2 Pass 2014-06-07
How can i achieve this....Thanks in advancePlease follow the basic Netiquette of all SQL forums for the past 35+ years on the Internet. Post DDL that follows ISO-11179 rules for data element names. You have no idea; you do not even know that DATE is a reserved word in SQL! Use industry standard
encodings (ISBN, UPC, GTIN, etc) and avoid needless dialect. Give clear specifications. Give sample data. Web need to see the keys and constraints, the DRI, etc. 80-95% of the work in SQL is in the DDL.
If you do not know that rows are not records, fields are not columns and tables are not files, then you should not be posting. If your tables have no keys, you should not be posting. If you have not tried any DML yourself, you should not be posting.
>> I need to get the older records [sic] for a particular product_id, rejecting the newer ones..My Scenarios is as follows.. <<
Now we have to do all your typing because of your bad manners. Thanks a lot. Here is a repair job.
CREATE TABLE Inspections
(product_id CHAR(5) NOT NULL,
inspection_date DATE NOT NULL
PRIMARY KEY (product_id, inspection_date),
inspection_result CHAR(4) NOT NULL
CHECK (inspection_result IN ('pass', 'fail'))
INSERT INTO Inspections
VALUES
('prod1', '2015-01-01', 'pass'),
('prod1', '2015-03-05', 'fail'),
('prod2', '2014-06-07', 'pass')
('prod2', '2015-02-02', 'fail');
Here is one way to do this:
WITH X(product_id, inspection_date, inspection_result, first_inspection_date)
AS
(SELECT product_id, inspection_date, inspection_result,
MIN(inspection_date) OVER (PARTITION BY product_id)
FROM Inspections)
SELECT product_id, inspection_date, inspection_result
FROM X
WHERE first_inspection_date = inspection_date;
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
Visibility for a particular customized record.
We are facing an issue of visibility for a particular customized record.
As customized record costing is created automatically using web services, so by default it is picking the name of the Administrator.How can we remove admin by default and assign its real owner by default?
Thanks in Advance,
Manish.You should be able to assign this by using post default on the Opportunity Owner ID field to be the creator of the record. If you have hard coded a WS username to complete this perhaps look at using SSO
-
Techical field ( and Table ) for Promotion type for a particular Customer
Hi All,
Where can I find the promotion type for a particular Customer?
Thanks,
SanjeetHi Suman,
I think you are talking about Transaction VB33.
Table - KONA (Rebate Agreements)
Field - KNUMA (Agreement (various conditions grouped together))
Structure - RV13A (Input/Output Fields for Price Element Maintenance)
Field - KNUMA_PI (Promotion)
And if you want based on particular customer..
Table - KOTE003 (Customer)
Field - KNUMA (Agreement (various conditions grouped together))
Table - KOTE004 (Customer Hierarchy)
Field - KNUMA (Agreement (various conditions grouped together))
Best Regards,
Sayak -
Display list of sales orders for one particular customer using BAPI in WD
Friends,
i want to display list of sales orders for one particular customer, the materials ordered, quantity ordered, goods issue date of that particular order and contact information about that particular customer, using Webdynpro.
Please somebody send me related info,blogs,help links , to complete this task, this is very urgent.
Please help
PeterFind the WD tutorials here...
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/web%20dynpro%20sample%20applications%20and%20tutorials.htm">Tutorials</a> -
Retrieve the sales orders for a particular customer in selection screen
Hi
I want to retrieve the sales orders for a particular customer(entering customer number field in the selection screen and then clicking on f4 help on sales order field in the selection screen I should get only sales order numbers for that particular customer number).How can I achieve this through search helps?Are there any standard search helps that I can use.
<removed_by_moderator>
Edited by: Julius Bussche on Apr 9, 2009 12:55 PMHi,
try this:
at selection-screen on value-request for p_par.
select * from vbak
into itab
where kunnr = p_par.
then use the FM 'F4IF_TABLE_VALUE_REQUEST'.
with
retfield = 'VBELN'
dynprog = sy-repid
dynpnr = sy-dynnr
dynprofield = <name of parameter>
value_org = 'S'
tables = itab.
Regards,
Leo. -
Delivery for a particular customer
Is it possible to create delivery for a particular
customer on specific dates we want? How we will do it in SAP if possible? thanksHi
Further...if you wish to create deliveries on different future dates, one more alternative is to create a SCHEDULING AGREEMENT with delivery dates and quantities given in the schedule lines. Based on the delivery date, it automatically wil be added in the delivery due list.
Thanks,
Ravi -
Need single record for single period. Modify the select query.
Requirement
THere are 6 programs for each company for each billing period. If anyof the program for one billing period and period_balance>0 then display outstanding balance YES. if period_balance <=0 for all the programs for one period then outstanding balance=NO
Below is the query i have used but i have to modify the query to get single record for each period whether outstandignbalance yes or no. Please help to resolve this issue. OR modify the query.
select distinct B_Billing_key, B_COMPANY_ID company ,
to_char(to_date('01/'||trim(substr(B_REPORT_PERIOD,5,2))||'/'||
trim(substr(B_REPORT_PERIOD,1,4)),'DD/MM/YYYY'),'Month YYYY') Billing,
Max(to_char(P_RECEIVED_DATE,'MM/DD/YY')) lastPaymentdate,
SURCH_AMOUNT,ADJUST_AMOUNT,PI_AMOUNT,AMOUNT,
(nvl(SURCH_AMOUNT,0)+nvl(ADJUST_AMOUNT,0)+nvl(PI_AMOUNT,0))-(nvl(sum(AMOUNT),0))"Period_Balance",
decode(sign((nvl(SURCH_AMOUNT,0)+nvl(ADJUST_AMOUNT,0)+nvl(PI_AMOUNT,0))-(nvl(sum(AMOUNT),0))),1, 'Yes'
,'No'
) outstandingbalance
p.PROGRAM_NAME_ID programname
FROM tuff_balance_view,MV_PROG_SURCH S,MV_PAYMENT_HOLDING H,MV_PROGRAM_DICT P where
b_company_id = 'U-7052-C'
and B_Billing_key=s.BILLING_KEY
and S.PROGRAM_KEY = P.PROGRAM_KEY
and P.PROGRAM_KEY= H.PROGRAM_KEY
GROUP BY B_Billing_key,B_COMPANY_ID,B_REPORT_PERIOD,SURCH_AMOUNT,ADJUST_AMOUNT,PI_AMOUNT,PROG_SURCH_KEY,
S.PROGRAM_KEY,p.PROGRAM_NAME_ID,AMOUNT
order by B_Billing_key desc
B_Billing_key is the primary key. I am looking for the output only one record for each biling perid. there are 6 programs for each billing period. if any of the program has period balance >0 then outstanding balance should be yes. For sample i am giving 2 programs.
Actual output from the above
biling_key company billing period period_balance outstandingbalance programname
123 xyz January 2011 $4 Yes ABC
123 xyz January 2011 $-5 NO DEF
456 xyz February 2011 $-3 NO ABC
456 xyz February 2011 $- 2 NO DEF
Need the output as below from the above query. Can you please help to simplify query. If anyof theprogram having outstanding balance for that particular period show the outstandigbalance as yes. Else NO.
Expected output as below
company billing period outstandingbalance programname
xyz January 2011 Yes ABC
xyz February 2011 No DEF
Thanks,
viHi G,
With the same query i am gettting outs as NO for all months which is not true. can you pelase look at the following data.
SELECT DISTINCT B_BILLING_KEY,
to_char(to_date('01/'||trim(substr(B_REPORT_PERIOD,5,2))||'/'||
trim(substr(B_REPORT_PERIOD,1,4)),'DD/MM/YYYY'),'Month YYYY') Billing,
B_company_id company,
sum((nvl(T.B_ORG_SURCH_AMOUNT,0)+nvl(T.B_ORG_PI_AMOUNT,0))-(nvl(T.P_AMOUNT,0))) "PeriodBalance",
Max(to_char(P_RECEIVED_DATE,'MM/DD/YY')) LastPaymentDate,
decode(sign(
(nvl(T.B_ORG_SURCH_AMOUNT,0)+nvl(T.B_ORG_PI_AMOUNT,0))-(nvl(T.P_AMOUNT,0))), 1,'Yes','No') Outs
FROM mv_program_dict P, tuff_balance_view T WHERE
b_company_id = 'U-7052-C' group by B_REPORT_PERIOD,B_company_id,B_BILLING_KEY,B_ORG_SURCH_AMOUNT,
B_ORG_PI_AMOUNT,P_AMOUNT
order by B_BILLING_KEY desc
Actual
Billing key Billing company periodbalance lastpayment date outs
110631534073 November 2010 U-7052-C 270 Yes
110631534073 November 2010 U-7052-C 690 Yes
110631534073 November 2010 U-7052-C 66 Yes
110461533197 October 2010 U-7052-C 4740 Yes
110461533197 October 2010 U-7052-C 27000 Yes
110461533197 October 2010 U-7052-C 0 No
110251532527 September 2010 U-7052-C 0 09/13/10 No
110251532527 September 2010 U-7052-C 0 No
110251532527 September 2010 U-7052-C -18 09/13/10 No
110251532484 August 2010 U-7052-C 0 09/13/10 No
110251532484 August 2010 U-7052-C 2001 09/13/10 Yes
110251532484 August 2010 U-7052-C 0 No
Expectedoutput(need only following columns)
Billing key Billing company lastpayment date outs
110631534073 November 2010 U-7052-C Yes
110461533197 October 2010 U-7052-C Yes
110251532527 September 2010 U-7052-C 09/13/10 No
110251532484 August 2010 U-7052-C 09/13/10 YES
By using below query i am getting all output as NO. HOw to modify it.
SELECT company,
billing,LastPaymentDate,
CASE
WHEN SUM (DECODE (outs, 'YES', 1, 0)) > 0 THEN 'YES'
ELSE 'NO'
END Outstanding
FROM (
SELECT DISTINCT B_BILLING_KEY,
to_char(to_date('01/'||trim(substr(B_REPORT_PERIOD,5,2))||'/'||
trim(substr(B_REPORT_PERIOD,1,4)),'DD/MM/YYYY'),'Month YYYY') Billing,
B_company_id company,
sum((nvl(T.B_ORG_SURCH_AMOUNT,0)+nvl(T.B_ORG_PI_AMOUNT,0))-(nvl(T.P_AMOUNT,0))) "PeriodBalance",
Max(to_char(P_RECEIVED_DATE,'MM/DD/YY')) LastPaymentDate,
decode(sign(
(nvl(T.B_ORG_SURCH_AMOUNT,0)+nvl(T.B_ORG_PI_AMOUNT,0))-(nvl(T.P_AMOUNT,0))), 1,'Yes','No') Outs
FROM mv_program_dict P, tuff_balance_view T WHERE
b_company_id = 'U-7052-C' group by B_REPORT_PERIOD,B_company_id,B_BILLING_KEY,B_ORG_SURCH_AMOUNT,
B_ORG_PI_AMOUNT,P_AMOUNT
order by B_BILLING_KEY desc)
GROUP BY company, billing,LastPaymentDate;
Note:in the actual out put max(lastpayment date) is returing null values. if there is any date in one billing return that date only remove null example is september. in september it should return only 09/13/10 this date not null date. but if there is no other within one biling then consider that as null example november..
Thanks,
v -
Approval History (Workflow History) for a particular version of the PO
Hello Everyone,
We are using SRM 5.0 with ECS.
We need the Approval History (Workflow History) for a particular version of the Purchase Order.
Is there a way to get that?
Any FM or table which can give the Approval History for a PO?
Regards,
Khushbu.LOGIKNR is assigned to only currently installed devices (see entries in EGERH, you will understand). So if you are looking at a record in EGERH and if the field BIS is in future, that is the record that will have the LOGIKNR. All the older records will not have that link. A device is always an equipment and LOGIKNR is always assigned to only installed devices. All other devices do not get that number. Only when you install a device, you will have information like device install date, device location etc. So it is relevant in the other case where device location was also needed.
-
Maintaing a default value for a particular field in the selection screen
Hi all,
How to maintain a default value for a particular field in the Selection Screen of a Standard report
Regards
Ajay>
ajay babu wrote:
> Hi all,
>
> How to maintain a default value for a particular field in the Selection Screen of a Standard report
>
> Regards
> Ajay
Create a variant for your standard program and assign this variant to the field 'Start with variant' while creating transaction code for the standard program in the transaction 'SE93'.
Regards
Rajesh. -
Code for reading particular fields from the file placed in application
hi,
code for reading particular fields from the file placed in application server in to the internal table.Hi,
Use the GUI_UPLOAD FM to upload the File into ur Internal Table.
DATA : FILE_TABLE TYPE FILE_TABLE OCCURS 0,
fwa TYPE FILE_TABLE,
FILENAME TYPE STRING,
RC TYPE I.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
EXPORTING
WINDOW_TITLE = 'Open File'
DEFAULT_EXTENSION =
DEFAULT_FILENAME =
FILE_FILTER =
INITIAL_DIRECTORY =
MULTISELECTION =
WITH_ENCODING =
CHANGING
FILE_TABLE = FILE_TABLE
RC = RC
USER_ACTION =
FILE_ENCODING =
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
NOT_SUPPORTED_BY_GUI = 4
others = 5
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
READ TABLE FILE_TABLE INDEX 1 into fwa.
FILENAME = fwa-FILENAME.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = filename
FILETYPE = 'DAT'
IMPORTING
FILELENGTH =
TABLES
data_tab = itab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
OTHERS = 6 .
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Regards,
Balakumar.G
Reward Points if helpful. -
Display Excahnge rate for that particular day in the reports
Hello friends,
I have a requirement from the business users to display the exchange rate being used to convert USD to JPY for that particular day in the reports. Is this possible. Please give me the steps to make this solution.
Appreciate a lot
--Thanks
SimmiHi,
What will be the source of such exchange rates in your scenario? If you want to take it from the standard tables in SAP, you can load the data from such tables to the master and then can create the report on master.
On the other hand, if you want to take it from internet, you can get the data into BI from Internet using RDA (Real Time Data Acquisition) (which can be implemented in 2004s only).
I think first option would be simpler to implement.
Regards,
Yogesh -
How to count number of records for a field based on condition?
Hi guys,
I want to know how to find count of records coming from the database for a particular field based on some condition.
I need to use this count to suppress some headers. Because of this i am not able to use running totals. Is there any other way?
Ex scenario:
I have account number and currency fields, those are coming from database. And i need to count the number of accounts whose currency is not Euro.
Thanks in advance,
Vijay.A simple formula can do that:
//Formula begin
if {your account field}<>"Euro" then 1
//Formula end
This formula can be summarized. (by group or report)
Bryan Tsou@Taiwan -
Logic - Average value for a particular Customer + Period
Hello Experts,
Please help me in the Logic to find out Average for the below scenario:
This is the Output:
Customer
Period
Payment Timeliness
Cust-001
01/97
-4
Cust-001
01/97
2
Cust-001
01/97
3
Cust-001
04/97
3
Cust-001
04/97
5
Cust-001
06/97
-4
Cust-001
07/97
2
Cust-001
08/97
3
Cust-002
09/97
5
Cust-002
09/97
4
Cust-002
10/97
6
Cust-002
10/97
-2
Cust-002
12/97
-4
Requirement is:
Customer
Period
Payment Timeliness
Cust-001
01/97
0.333
Cust-001
04/97
4
Cust-001
06/97
-4
Cust-001
07/97
2
Cust-001
08/97
3
Cust-002
09/97
4.5
Cust-002
10/97
2
Cust-002
12/97
-4
Display the Average of all the Payment Timeliness for a particular Month as shown above.
My Code is:
*& Form fetch_data
FORM fetch_data .
SELECT bukrs
belnr
gjahr
blart
bldat
budat
monat
FROM bkpf
INTO TABLE g_t_bkpf
WHERE bukrs EQ '0470'
AND gjahr EQ p_year
AND ( blart EQ 'EZ'
OR blart EQ 'DZ' )
AND monat IN s_month.
IF sy-subrc EQ 0.
SELECT bukrs
belnr
gjahr
augdt
buzei
shkzg
kunnr
zfbdt
zbd1t
zbd2t
zbd3t
rebzg
FROM bseg
INTO TABLE g_t_bseg
FOR ALL ENTRIES IN g_t_bkpf
WHERE bukrs EQ g_t_bkpf-bukrs
AND belnr EQ g_t_bkpf-belnr
AND gjahr EQ g_t_bkpf-gjahr
AND kunnr IN s_kunnr.
IF sy-subrc EQ 0.
ELSE.
WRITE:/'No Data Found'.
ENDIF.
ENDIF.
ENDFORM. " fetch_data
FORM display_paystats .
DATA: l_due_date TYPE faedt_fpos,
l_timeliness TYPE p,
l_kunnr type kunnr,
l_counter type i,
l_period type char5,
l_tot_timeli type p.
IF g_t_bseg IS NOT INITIAL.
WRITE: /10 'Customer ', 24 'Period ', 35 'Payment Timeliness'.
WRITE: /10 sy-uline(44).
LOOP AT g_t_bseg INTO g_wa_bseg.
CLEAR l_due_date.
CALL FUNCTION 'NET_DUE_DATE_GET'
EXPORTING
i_zfbdt = g_wa_bseg-zfbdt
i_zbd1t = g_wa_bseg-zbd1t
i_zbd2t = g_wa_bseg-zbd2t
i_zbd3t = g_wa_bseg-zbd3t
i_shkzg = g_wa_bseg-shkzg
i_rebzg = g_wa_bseg-rebzg
IMPORTING
e_faedt = l_due_date.
READ TABLE g_t_bkpf INTO g_wa_bkpf WITH KEY
bukrs = g_wa_bseg-bukrs
belnr = g_wa_bseg-belnr
gjahr = g_wa_bseg-gjahr.
IF sy-subrc EQ 0.
l_timeliness = g_wa_bkpf-budat - l_due_date.
ENDIF.
CLEAR g_wa_paystat.
g_wa_paystat-kunnr = g_wa_bseg-kunnr.
CONCATENATE g_wa_bseg-augdt+4(2) '/' g_wa_bseg-augdt+2(2) INTO g_wa_paystat-period.
g_wa_paystat-timeli = l_timeliness.
APPEND g_wa_paystat TO g_t_paystat.
CLEAR : g_wa_bseg, g_wa_paystat.
ENDLOOP.
SORT g_t_paystat BY period.
LOOP AT g_t_paystat INTO g_wa_paystat.
WRITE:/10 g_wa_paystat-kunnr, 24 g_wa_paystat-period, 35 g_wa_paystat-timeli.
ENDLOOP.
ENDIF.
ENDFORM. " display_paystats
Where should I check the condition?
I thought of assigning the Period / KUNNR in a Variable; then compare from the second record.
But then how can I skip the check for 1st time inside a Loop?
Since this is BSEG/BKPF entries; it is slow. So, please suggest some logic that doesn't affect the performance.
Is it possible to write this logic within BSEG LOOP?
Appreciate your help.
Thank you!
Thanks & Regards,
SowmyaFound out by myself
Closing the thread.
SORT g_t_paystat BY kunnr period.
LOOP AT g_t_paystat INTO g_wa_paystat.
l_kunnr = g_wa_paystat-kunnr.
l_period = g_wa_paystat-period.
l_tot_timeli = g_wa_paystat-timeli.
IF sy-tabix NE 1.
READ TABLE g_t_paystat INTO g_wa_paystat1 WITH KEY kunnr = l_kunnr
period = l_period.
IF sy-subrc EQ 0.
l_counter = l_counter + 1.
l_tot_timeli = l_tot_timeli + 1.
ELSE.
g_wa_paystat-timeli = l_tot_timeli / l_counter.
MODIFY g_t_paystat FROM g_wa_paystat TRANSPORTING timeli WHERE kunnr = l_kunnr
AND period = l_period.
CLEAR:
l_counter,
l_tot_timeli.
ENDIF.
ENDIF.
ENDLOOP.
DELETE ADJACENT DUPLICATES FROM g_t_paystat COMPARING kunnr period.
LOOP AT g_t_paystat INTO g_wa_paystat.
WRITE:/10 g_wa_paystat-kunnr, 24 g_wa_paystat-period, 35 g_wa_paystat-timeli.
ENDLOOP. -
To automate outbound process for a particular customer
Hi All,
I have setup a edi 855 outbound process, I don't know how make the 855 happen automatically for received 850 for a particular new customer. can anyone help me... cos we are supposed to go-live anytime next week...Hi,
You should enhance the standard Data source 0customer_attr with that additional partner function (sales head) as per the proper logic and replicate the same . if it is 3.5 that same object( related to that field length and data type) same object can be added as attribute at info object level and do the transfer rules and activate that and try to the load.
Thanks & Regards,
Sathish
Maybe you are looking for
-
Problem with Left Click (mighty mouse) and flash content
Hi, first sorry for my bad english... Well I have an issue with the left click (i have mighty mouse) and flash content in Firefox: if i'm using Firefox and then change to any other app, when i get back to firefox i have no left click anymore... So i
-
Play count is out of wack!?
Ive been noticing lately that my play count on some songs are way too high, so i listened to a song on my ipod touch 1st gen and then went into its library via iTunes and it sayed 720 play count, but before sayed 325, i have no clue what is going on!
-
i clicked on a link to view the answers to questions on a PDF which opens a window which is continued in a 2nd window yet in version X of Adobe Reader the 2nd window doesn't show up It only works with the trial of version XI and I need to use Version
-
Adjustments window under Expert
I just installed PE 12 and I don't see an Adjustments window on the right under Elements under Expert. Is this not part of the Expert screen? Also, I don't see the little box with the green check next to the box with the crossed out circle to cance
-
Mc-nbt-edit: Command line editor for Minecraft's NBT files
Hello everyone! This is a little script I wrote for personal use but after all I decided to share it, after all someone might find it useful. So, mc-nbt-edit is a simple python script that edits nbt files using Thomas Woolford's NBT Library. I wrote