Anlaytical Func
hi
select 1 slno, 1000 Amount , 0.12 Int_Rate, 1000*0.12 IntAmt from dual
union
select 2 slno, 1000 Amount , 0.13 Int_Rate ,1120 * 0.13 from dual
SLNO AMOUNT INT_RATE INTAMT
1 1000 0.12 120
2 1000 0.13 145.6
Column 120 is the product of amount*int_rate(1000*0.12)
Column 145.6 is the product of amount*int_rate(1000*0.12)*int_rate(1000*0.13)
Can i get the help from somebody to compute using an analytical function to get the result
Thanks in Advance
user639304 wrote:
Hi,
That's great Sven W. In SQL, we have something to sum the values of rows, but we have nothing for the product of values of rows (or, at least, if something exist to express directly the product of numbers, we don't often use it) . So I was thinking to how use the existing functionalities of SQL in order to have the product of values in a given column, and I was thinking to the ln and exp functions. But I didn't arrive to the point where Sven W. has arrived. Sven W. has used the formula:
x1 * x2 * ... * xn = exp(ln(x1) + ln (x2) + ... + ln(xn)), in other terms, roughly speaking,
Product of values = exp(Sum of the ln of these values).Thanks for the explaination. I didn't had a proper idea how to write one myself. ;)
A minor issue with this solution is that it might be a little CPU intensive. For example I had to add rounding, because the floating point math involved led to rounding issues.
So if we need this often, it could be better to build our own aggregate_multiplication function. This is less complicated then one often thinks.
Oh and here is the solution using a recursive with clause. I build it upon nicosas version, but changed the math to be consistent with my previous examples.
Op wasn't very clear about the math behind and I think that led to much confusion.
with t as (
select 1 slno, 1000 Amount , 0.12 Int_Rate from dual
union all
select 2 slno, 0 Amount , 0.13 Int_Rate from dual
union all
select 3 slno, 0 Amount , 0.14 Int_Rate from dual
order by slno -- this is important
------ end of sample data ------
------ This removes the gap-problem, by introducing a sequential row number
, t2 as (select rownum rn, slno, Amount, Int_Rate
from t)
------ trec below is a recursive with clause (AKA recursive subquery factoring) ------
trec(rn, slno,amount,int_rate) as
select rn,slno,amount*(1+int_rate),int_rate
from t2 base
where rn=1
union all
select t3.rn,t3.slno,trec.amount*(1+t3.int_rate),t3.int_rate
from t2 t3
join trec on t3.rn=trec.rn+1
------ just query the recursive with clause ------
select * from trec
RN SLNO AMOUNT INT_RATE
1 1 1120 0,12
2 2 1265,6 0,13
3 3 1442,784 0,14 This is the important line
trec.amount*(1+t3.int_rate)
Essentially this puts the amount from the previous row up for multiplication with interest from the current row. And sets it a the new amount.
Edited by: Sven W. on Aug 17, 2012 3:07 PM - added with clause solution
Edited by: Sven W. on Aug 17, 2012 3:10 PM - Typo correction
Similar Messages
-
To get the values from func. module
c i have used a func. module to calculate the values of date , i wrote a subroutine i want the values of this to be dispalyed on the list...
now how do i get them to the list output, i mean how do i assign to the fieldcatalog?????
thanks,
CAPCHi CAPC,
Plese find below a sample program which will solve u r broblem.
report abc.
TYPE-POOLS : slis.
Data
DATA : BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE t001.
DATA : flag tyPE c,
END OF itab.
DATA : alvfc TYPE slis_t_fieldcat_alv.
DATA : alvly TYPE slis_layout_alv.
Select Data
SELECT * FROM t001 INTO TABLE itab.
*------- Field Catalogue
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ITAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
Display
alvly-box_fieldname = 'FLAG'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = alvfc
i_callback_program = sy-repid "<-------Important
i_callback_user_command = 'ITAB_USER_COMMAND' "<------ Important
is_layout = alvly
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
CALL BACK FORM
FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE
slis_selfield.
data : msg(100) type c.
LOOP AT itab.
if itab-flag = 'X'.
msg = sy-tabix.
condense msg.
concatenate 'Row Number ' msg ' ' into msg
separated by space.
message msg type 'I'.
endif.
ENDLOOP.
ENDFORM. "ITAB_user_command
Regards,
Sunil -
How can I use non-static func in a static func?
Hello guys,
I have a func processFiles which is static, i wanna use a func from another class FileData in processFile func and i dnt wanna make processFile non-static, what should i do?
my code:
public class Library {
private FileData file = new FileData();
public static void main(String[] args){
try{
Library lib = new Library();
lib.processFiles(args);
catch(IOException e)
System.err.println("IOException occurred in main.");
System.exit(0);
@SuppressWarnings("unchecked")
public static void processFiles(String[] fileNames) throws IOException {
file.getMaterial();// I get error here;
class FileData{
getMaterila() {}
}1) it's not "func", it's "method".
2) Create a FileData instance and call the method on that
3) Read the basic tutorials about what "static" means, and put the error message into Google. -
Hi,
if I run the report "RALM_ME_FUNCLOC_LIST" with SE38 and selection parameter func. loc. typs "S" I don't receive a newly created func. loc.
If I do the same using transaction IH06 with the same parameter, I receive the newly created func. loc.
The same happens I I start the initial replication for func. locs. The newly created isn't transfered.
Any idea?
Thank you and regards,
FlorianHello Florian,
Unfortunatly, if you look at the code a note is reffered: 772443 . There it says you cannot select from the FLTYP field (even if it is available for data entry).
Sorry,
Julien. -
Func module to convert list to pdf without using memory id
hi Experts,
Is there any funct module to convert list to pdf without using memory, as I am using Convert_to_PDF func module which outputs last page only when its running in Background.
But my req is to output all the Pages in the PDF format.
Sample code also appreciable,
Reward Points are guranteed..
Cheers
SantoshCheck the below postings :
Re: Convert spool to pdf
Convert a spooljob to a writeprotected PDF
Hope this will helpful -
Dear all,
i have a concern,i have to implement a user exit in tcode j1iin in the FM J_1I7_USEREXIT_CALC_EXC_BASE .now when i try to bring in change mode it says
Carry out modification comparison for FUNC J_1I7_USEREXIT_CALC_EXC_BASE first. No changes possible
...how do i do the modification comparision. i have checked with SPAU and SE95 tcodes but iam unable to compare.please can anyone provide brief explanation and help?
Thanks in advance,
Naren>
naren wrote:
> Dear all,
> i have a concern,i have to implement a user exit in tcode j1iin in the FM J_1I7_USEREXIT_CALC_EXC_BASE .now when i try to bring in change mode it says
>
> Carry out modification comparison for FUNC J_1I7_USEREXIT_CALC_EXC_BASE first. No changes possible
> ...how do i do the modification comparision. i have checked with SPAU and SE95 tcodes but iam unable to compare.please can anyone provide brief explanation and help?
>
> Thanks in advance,
> Naren
Hi ,.
Once You go to SE95 Give the package name as - J1I2 and Execute .
If some Note has been applied for the package (Whcih Contains your FM) then it will show following nodes
Note Corrections
With Modification Assistant
Without Modification Assistant
Appends
So you need to find under whcih node Your update for FM exits .It must be Visible in red .
Now goto Menubar >>Goto >>Modification Adjustment .
once you adjust ,the FM should become Editable .
Regards,
Rajesh -
CALL FUNCTION func STARTING NEW TASK task
hi,
i developed rfc to extract data and send to xi
as my interface is Async
as per soem documents it was mentioned the syntax
CALL FUNCTION func STARTING NEW TASK task
wat is the task ? in the syntax
and how do i use it
jeffHi suresh,
this is the code of RFC. if i execute without RFCDESTINATION it executes successfully. when i use RFC DESTINATION it shows error
call to messaging system failed: com.sap.aii.af.ra.ms.api.DeliveryException
i created RFC destination using TCP/IP and registered program. same parameters i am mentioning in XI.
FUNCTION z_bank_reconciliation.
""Local interface:
*" IMPORTING
*" VALUE(COMP_CODE) TYPE BUKRS
*" VALUE(HOUSE_BANK) TYPE HBKID
*" VALUE(ACCOUNT_ID) TYPE HKTID
*" TABLES
*" CHQDETAILS STRUCTURE ZPAYR
DATA: itab LIKE payr OCCURS 0 WITH HEADER LINE.
DATA: jtab LIKE payr OCCURS 0 WITH HEADER LINE.
DATA: it_bank LIKE zbankrecon OCCURS 0 WITH HEADER LINE.
DATA: it_bank1 LIKE zpayr OCCURS 0 WITH HEADER LINE.
TYPES : BEGIN OF ty_bseg ,
bukrs LIKE bseg-bukrs,
hbkid LIKE bseg-hbkid,
belnr LIKE bseg-belnr,
zlsch LIKE bseg-zlsch,
kostl LIKE bseg-kostl,
hkont LIKE bseg-hkont,
bzdat LIKE bseg-bzdat,
END OF ty_bseg.
TYPES : BEGIN OF ty_t012 ,
bukrs LIKE t012-bukrs,
bankl LIKE t012-bankl,
bankn LIKE t012k-bankn,
END OF ty_t012.
TABLES : payr, t012, t012k, bseg.
DATA : itpayr LIKE zpayr OCCURS 0 WITH HEADER LINE,
itt012 TYPE STANDARD TABLE OF ty_t012,
itbseg TYPE STANDARD TABLE OF ty_bseg,
wa_itt012 TYPE ty_t012,
wa_itbseg TYPE ty_bseg,
total TYPE n.
SELECT * FROM zbankrecon INTO TABLE it_bank
FOR ALL ENTRIES IN itab
WHERE chequeno EQ itab-chect.
SELECT abukrs abankl b~bankn
INTO CORRESPONDING FIELDS OF TABLE
itt012 FROM t012 AS a
INNER JOIN t012k AS b ON bbukrs = abukrs AND b~hbkid =
house_bank AND b~hktid = account_id
WHERE abukrs = comp_code AND ahbkid = house_bank.
DELETE ADJACENT DUPLICATES FROM itt012.
SELECT zbukr hbkid hktid vblnr gjahr zaldt checf chect znme1 rwbtr
waers zaldt zbnkl FROM payr INTO CORRESPONDING FIELDS OF TABLE itpayr
WHERE ( zbukr = comp_code AND hbkid = house_bank ) AND hktid =
account_id.
SELECT bukrs hbkid belnr zlsch kostl hkont bzdat FROM bseg INTO TABLE
itbseg
WHERE bukrs = comp_code AND hbkid = house_bank.
SORT itt012 BY bankl.
SORT itbseg BY belnr.
READ TABLE itt012 INTO wa_itt012 INDEX 1.
LOOP AT itpayr.
read table itbseg into wa_itbseg with key bukrs = itpayr-zbukr
hbkid = itpayr-hbkid.
if sy-subrc = 0.
itpayr-kostl = wa_itbseg-kostl.
itpayr-hkont = wa_itbseg-hkont.
itpayr-bldat = wa_itbseg-bzdat.
itpayr-zlsch = wa_itbseg-zlsch.
endif.
itpayr-zbnkl = wa_itt012-bankl.
itpayr-zbnkn = wa_itt012-bankn.
MODIFY itpayr.
APPEND itpayr TO chqdetails.
ENDLOOP.
LOOP AT chqdetails.
READ TABLE it_bank WITH KEY chequeno = chqdetails-chect.
IF sy-subrc NE 0.
MOVE chqdetails TO it_bank1.
APPEND it_bank1.
CLEAR it_bank1.
ENDIF.
ENDLOOP.
REFRESH chqdetails.
chqdetails[] = it_bank1[].
LOOP AT it_bank1.
MOVE : it_bank1-chect TO zbankrecon-chequeno,
sy-datum TO zbankrecon-check_date,
sy-uzeit TO zbankrecon-check_time.
INSERT zbankrecon.
CLEAR zbankrecon.
ENDLOOP.
ENDFUNCTION. -
Comp characteristics extraction - Func Modules
All,
There are 2 function modules to get characteristics info:
1. CUAB_DISPLAY_CD_CONFIGURATION
2. CUD0_GET_VAL_FROM_INSTANCE
Both work off the CUOBJ value that is derived either from the RESB table for the Prod Order (component config information extraction) or from the Purchase Order table EKPO.
Question is what is the diff b/w the 2 function modules in terms of the output they generate.
My interest is to find a function module that will extract all the component characteristics (chars of class 300)
Pls let me know
ThanksThanks,
Then there are these 2 func modules, how do these differ from the earlier ones?:
VC_I_GET_CONFIGURATION_IBASE
CLAF_CLASSIFICATION_OF_OBJECTS
I'm trying to be sure I use the right one that does not give me incorrect data. I'm plng to extract data for the char's & pass them to my MES system for further use.
Thanks -
To find the processing Func. module
hi,
can anyone tell me how to find the processing Func. module(outbound) if i know the message type, basic type and extension.
i tried with we57 but coudnt find the one(outbound) needed.Hi Pawan,
From the link
http://www.intelligententerprise.com/channels/applications/feature/archive/kasturi.jhtml
For more inf. you can check this link.
From WEDI got to Control -> Inbound process codes -> Inbound with ALE service -> Processing by function module (transaction WE42), or from WEDI go to Control -> Outbound process codes -> Outbound with ALE service -> With function module (transaction WE41). There will be function modules associated with the process codes. For inbound, the function modules usually follow this pattern: IDOC_INPUT_messagetype: for example, IDOC_INPUT_CHRMAS for inbound characteristics master.
*Use transaction WE57 or from WEDI go to Development -> Message/Application Object. The entries list the function module, Business Object, message type, and IDOC type that are used for inbound ALE/EDI interfaces.
Hope you will clear now, if yes please close this thread with rewarding appropriate points to the helpful answers.
Cheers
Sunny -
Example of calling PL/SQL func in JavaScript
I need to validate a form element based on existing database value and give an alert. Does anyone know how to capture the value returned by a PL/SQL func in JavaScript variable? Thanks.
hi,
in the PL/SQL block 'before form displayed'
insert the code:-
htp.p('{script}var myVar = "' | | myPLSQLfunc | | '";{script}');
(I have replaced the less-than and greater-than symbols with {} so that they will show in the browser)
The variable myVar will now be available to JavaScript in the page and will have the value returned by myPLSQLfunc.
Regards Michael. -
Lock inheritance with "CALL FUNCTION func IN BACKGROUND TASK"
I see that the "SAP Lock concept" documentation states that for locks obtained with _scope = '3', all UPDATE tasks (spawned via "CALL FUNCTION func IN UPDATE TASK" inherit the lock (which is released only once all such update tasks and the calling process have requested a DEQUEUE).
What should happen when instead, I use "CALL FUNCTION func IN BACKGROUND TASK" (for doing the update in a queue)? Are the locks inherited here as well?
Cheers!Hopefully not, as a background task may be executed late. While update tasks are to be executed quickly (if not, administrators should review the system configuration, like increasing the number of UPD workprocesses).
Solution: In the background task, redo the locks, as if it was a background job. -
Func. Mod's, BAPI's, IDoc's Related to Customer Master
Hi,
I need Func. Mod's, BAPI's, IDoc's Related to Customer Master. For creation, modification, Deletion, Updation of master data records.
Regards,
SudheerHi,
Bapi to create customer master
BAPI_CUSTOMER_CREATEFROMDATA
BAPI_CUSTOMER_CREATEFROMDATA1
Or you can use FM SD_CUSTOMER_MAINTAIN_ALL
customer master idoc is DEBMAS05
Hope this helps
Please reward points if useful.
Regards
Rose -
Hi,
Which one to go ABAP-HR or func HR???
which has good future????
Thnx in adv
Regards,
Praveen.To be honest you can't get this document outside legally.
This is SAP own document for training which can't sent out.
If you have any friends you can get it from them.
It might be available with your company
Please check
Regards -
User defined funcs in a Servlet
I am invoking a servlet from a java program. Some data is being sent to the servlet. I want to manipulate that data in servlet. The data sent from java program is received in doGet(). Now to manipulate the data can I write member functions inside a class within the servlet, create an object of that class and invoke the mem Funcs ?
I am invoking a servlet from a java program. Some
data is being sent to the servlet. I want to
manipulate that data in servlet. The data sent from
java program is received in doGet(). Now to
manipulate the data can I write member functions
inside a class within the servlet, create an object
of that class and invoke the mem Funcs ?Have that class outside the servlet. You can also store the object by binding it to a scope and reuse it within a jsp.
ram. -
Need Tables and Func Modules related to Project Systems
Hi
I am working on a custom program that Creates Project ( CJ01) using standard Project Def.
All WBS elements of Standard Project Template should be copied to the newly created Project
I am not able to get any Standard Func Module which creates new WBS elements from Standard WBS elements.
It will be of great help for me, if any one has info on this.
thanks in advance.Hi
See the Tables
PRPS -WBS element
PROJ - Project Definition
other tables are
PRTE,PRTX,PSTX,PSTT -Scheduling data for items
PRHIS
see the fun modules
CJPN_GET_WBS_ELEMENT
CJPS_GET_WBS_ELEMENT
PSBW_GET_TEXT_WBS_ELEMENT
PSBW_GET_WBS_ELEMENT
K_PROJECT_WBS_PLANVALUES
AIPR_GET_HIERARCHY_TO_WBSELEM
CJDW_GET_NEW_WBS_ELEMENTS
Reward points if useful
Regards
Anji
Message was edited by:
Anji Reddy Vangala
Maybe you are looking for
-
Problem Sending attachments with JavaMail API
Hi, I am able to succesfully able to send the attachment but the body message is not going with it. If i dont send the attachment then the email body goes properly. i can't understand what the problem is . please help. import java.util.*; import java
-
The files are no longer available. How can I open these files again?
The files are no longer available, how can i open this files again?
-
Webcenter ribbon disappears in Office applications
Hi, I am wondering if you guys have experienced that the Webcenter ribbon in Office applications are being disabled during startup of eg. MS Word and if you have a good solution on how to prevent this? We are using DIS 11.1.6.97 and sometimes the Web
-
DW CS3 performance and mixed up logins
Hi, Forum Folks, Running DW 9.0 on two different Intel-based Macs with the same difficulties on each, and I don't see an English updater. I'm experiencing three annoying things: 1) sluggish performance ... picking an item on any menu means up to a se
-
Address Book opens up ramdomly
Hey guys, after 2.5 years on a Mac I have the first problem I couldn't solve myself. I'm on 10.7.3 with all of my contacts on iCloud syncing with my iPhone. For a few weeks now Address Book opens up unintentionally with hidden window. Console log say