Decode (function) VERY URGENT ! ! !

Hi Folks,
Does any one know how can i use some thing like
if a < 25 then
else
end if;
using decode function.
Thanks in advance
D'Silva

Yep use Decode in conjunction with
the sign() function.
Goes something like this...
Decode( Sign( a - 25 ),0, 'EQUAL',
1, 'GREATER',
-1, 'LESS' )
Hope this helps
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by D'Silva:
Hi Folks,
Does any one know how can i use some thing like
if a < 25 then
else
end if;
using decode function.
Thanks in advance
D'Silva<HR></BLOCKQUOTE>
null

Similar Messages

  • Not a single-group group function very urgent

    HI,
    select sum(avg(wait_to))+sum(avg(idle))+sum(avg(users))+sum(avg(system)) from system_cpu
    where hostid='DSCP02469' group by cpuid
    this query is working
    but i want cpuid group to be displayed
    so i wrote query like this.
    select cpuid,sum(avg(wait_to))+sum(avg(idle))+sum(avg(users))+sum(avg(system)) from system_cpu
    where hOstid=' ' group by cpuid it is throwing a error
    not a single-group group function.
    how can get sum of avg of colums,column based on some coloum
    group by column
    id,sum(avg( )) i have to get
    please give me solution.
    send me mail to [email protected]

    hi,
    thanku for immediate reply but
    if i do that
    select cpuid, a+b+c+d total_value from (select cpuid,
    sum(avg(wait_to)) a, sum(avg(idle)) b,sum(avg(users)) c,sum(avg(system)) d
    from system_cpu where hostid='DSCP02469' group by cpuid)
    SQL> /
    select cpuid, a+b+c+d total_value from (select cpuid,
    ERROR at line 1:
    ORA-00937: not a single-group group functionelse
    select cpuid, a+b+c+d total_value from (select
    sum(avg(wait_to)) a, sum(avg(idle)) b,sum(avg(users)) c,sum(avg(system)) d
    from system_cpu where hostid='DSCP02469' group by cpuid)
    SQL> /
    select cpuid, a+b+c+d total_value from (select
    ERROR at line 1:
    ORA-00904: "CPUID": invalid identifier2)
    can we use select in select case
    can we use select sal, case when sal then select * from emp like this
    with regards
    shannu sarma

  • Very urgent help needed in activating a function module

    Hello experts.
    I had a standard report and i copied into an z report. i need to change some field output , and that field is there in a standard function module.so i copied that fun module  into z fun module and stored in a new fun group. Now it is showing the error in the z fun module. include in the fun module is giving the error stating that it is not existing. please help me in coping the standard fun module correctly . please its very urgent.

    Hi,
    You should not copy a Function module alone, as it will have some dependant INLCUDES and global data in TOP include of the function group.
    SO if you want the function module copy the entire Function Group into Z function group.
    Regards,
    Sesh

  • Very urgent - Usage of IsError function in HFR

    Hi All,
    Its very urgent requirement for us.
    How can we use the is error function in HFR.bcoz if the both values in formula ex: a/b ; a=0,b=0; then it shows some garbage value.i came to know we can achieve that
    by using iserror function.but i dnt know how use it.
    Thanks,
    Ravi

    Hi
    It can be done in this way using IfThen condition
    IfThen(IsErr((reference row/column),0,(reference row/column))
    where IfThen checks the condition
    Condition is IsErr, it returns true when reference formula row/column,has #error value, so you many assign 0 (or whatever value you want) else returns actual calulated value from formula row/column,.
    PS: Only formula rows and columns can result in #error.
    Cheers
    Vikas Naidu

  • Update Equipment BOM using Function module (very urgent)

    Hi All,
    I am an ABAPER and trying to update equipemnt BOM.
    I want to update equipment BOM using a function module. I am currently using 'CSAI_BOM_MAINTAIN' function module. But i am not able to update the Equipment BOM. After function call the sy-subrc value is 0, even though the BOM is not updated.
    Please help its very urgent.
    Kind Regards,
    Sharat.

    Hi Sharat,
    I am facing the same problem. Could you please let me know what might be the reason.
    Plz mail me at [email protected]
    Plz update this section once u have mailed the answer.
    Thanks a lot in advance.
    Regards,
    Himanshu

  • Decode function--urgent

    hai all,
    this is the query from robinson .....
    I am trying to use decode function as below in PL/SQl..
    DECODE(column1,a1,1,a2,2,a3,3,......a150,150,null)
    i got a error as
    ---unhandled exception---
    If this decode function is restricted to 120 values i get the
    answer.
    so i would like to know whether there is any restriction for the
    number of arguments to be passed to the decode function.
    I will be glad and grateful to receive a answer...for this query.
    thanks in advance...
    robinson

    I'm not sure what is the limit for the decode function
    arguments, but it certainly seems that you've reached it.
    So, I'd recommend that you write a stored function that you will
    call in your select. It should be like the following:
    create
    function f_decode (p in your_data_type) return your_ret_type
    is
    begin
    if p=expr1 then
    return value1;
    elsif p=expr2 then
    return value2;
    elsif p=exprn then
    return exprn;
    else
    return def_value;
    end if;
    Or, another way to handle it, even more graciously when the
    number of possible values will vary pretty often may be to have
    a table that you would join.
    That's what I do when a have to deal with more than 10-20 values.
    end;

  • Decode function involving 2 fields (urgent)

    Hi .. I am trying to use the decode function involving 2 fields.
    The query runs but does not produce the correct results. If
    anyone knows, please reply .. Usually decode function involves
    one column only but I have more
    than one. The situation is : If ins_code = 2 or special_code =
    MMI, put a 'Y', otherwise, it's a 'N'. Does anyone know how to
    put this in a decode statement? Thanks

    Thanks, Suresh ... but I have to put this condition using the
    decode statement because that's how the rest of the program is
    written. It's part of the script that I have to change. The
    current statement is this: decode(ins_code, '2', 'Y', 'N'). I
    have to change it to ins_code =2 or special_feature = MMI.
    Please reply ... thanks a lot....

  • DECODE Function In Reports 3.0

    Hi,
    When I use the decode function in a query (Reports 3.0.5.8.0) I receive an error message "Bind Variable Does Not Exist" (ORA-1006). When I remove the decode function from the query, the query compiles fine. All table and column references are existing.
    Also, the same query runs perfectly fine from SQL*Plus. The OS is Win 2000, SP2
    Any idea if this is a bug? Is there any way out? Do get back as this is very urgent.
    The database is Oracle 8i Ent, 8.1.7 on AIX 4.3
    The query is as follows:
    SELECT NAM_CMP , COD_CMP , COD_CMP_REG ,
    DECODE(FLG_CMP_SHP,'Y','S/',' /') || DECODE(FLG_CMP_AGT,'Y','A/',' /') || DECODE(FLG_CMP_CNE,'Y','C',' ') TYPE ,
    DES_ADD_STT , DES_ADD_PLC , DES_ADD_STA , DES_ADD_POS , COD_CTY , COD_cou_iso ,
    DAT_LST_AST , DAT_LST_UPD,
    cod_dcl_box_num, decode(cod_imp_chg_way,'C','CASH','CREDIT') cod_imp_chg_way,
    decode(cod_imp_cre_way,'W','WEEKLY','F','FIFTEEN DAYS','M','MONTHLY', NULL) cod_imp_cre_way,
    decode(flg_imp_prn_inv, 'N', null, flg_imp_prn_inv) flg_imp_prn_inv,
    cod_bro_box_num, decode(cod_exp_chg_way,'C','CASH','CREDIT') cod_exp_chg_way,
    decode(cod_exp_cre_way,'W','WEEKLY','F','FIFTEEN DAYS','M','MONTHLY', NULL) cod_exp_cre_way,
    decode(flg_exp_prn_inv, 'N', null, flg_exp_prn_inv) flg_exp_prn_inv
    FROM CMP
    where dat_can is null

    Try TO_CHAR(NULL) instead of NULL in all DECODE functions.
    For example:
    decode(cod_imp_cre_way,'W','WEEKLY','F','FIFTEEN DAYS','M','MONTHLY', TO_CHAR(NULL))
    instead of:
    decode(cod_imp_cre_way,'W','WEEKLY','F','FIFTEEN DAYS','M','MONTHLY', NULL).

  • Problem using DECODE() function with a Query of Queries

    I
    posted
    on my blog about an issue I was having trying to use the PL/SQL
    DECODE() function with a Coldfusion Query of Queries. This function
    works fine when you query a database for information. However, when
    you query another query, it seems that CF doesn't recognize it. I
    got errors stating that it found a left parenthesis where it
    expected a FROM key word. Here is a simplified version of what I am
    trying to do:
    quote:
    <!--- Simulated query; similar to what I was calling from
    my database --->
    <cfscript>
    qOriginal = queryNew("Name,Email,CountryCode",
    "VarChar,VarChar,VarChar");
    newRow = queryAddRow(qOriginal, 5);
    querySetCell(qOriginal, "Name", "Joe", 1);
    querySetCell(qOriginal, "Email", "[email protected]", 1);
    querySetCell(qOriginal, "CountryCode", "AMER", 1);
    querySetCell(qOriginal, "Name", "Sally", 2);
    querySetCell(qOriginal, "Email", "[email protected]", 2);
    querySetCell(qOriginal, "CountryCode", "AMER", 2);
    querySetCell(qOriginal, "Name", "Bob", 3);
    querySetCell(qOriginal, "Email", "[email protected]", 3);
    querySetCell(qOriginal, "CountryCode", "ASIA", 3);
    querySetCell(qOriginal, "Name", "Mary", 4);
    querySetCell(qOriginal, "Email", "[email protected]", 4);
    querySetCell(qOriginal, "CountryCode", "EURO", 4);
    querySetCell(qOriginal, "Name", "John", 5);
    querySetCell(qOriginal, "Email", "[email protected]", 5);
    querySetCell(qOriginal, "CountryCode", "EURO", 5);
    </cfscript>
    <cfquery name="qCountries" dbtype="query">
    SELECT DISTINCT(CountryCode) AS CountryCode,
    DECODE(states, "AMER", "North America &amp; Canada",
    "EURO", "Europe &amp; Africa", "ASIA", "Japan &amp;
    Asia","") CountryName
    FROM qOriginal
    ORDER BY CountryCode
    </cfquery>
    <cfdump var="#qCountries#">
    <!--- ========== END OF CODE ========== --->
    So running this returned the following error:
    Query Of Queries syntax error.
    Encountered "(. Incorrect Select Statement, Expecting a
    'FROM', but encountered '(' instead, A select statement should have
    a 'FROM' construct.
    Does anybody know why this doesn't work? Is it just not
    supported? Please note that I have also tried to use the CASE()
    function instead of DECODE() and that resulted in basically the
    same error. For now I an looping over my distinct query with a
    switch statement and manually loading a new query with the data how
    I want it. But it would be a lot cleaner and less code to have the
    DECODE() to work. Thx!

    DECODE() is an Oracle function, not generic SQL. Q-of-Q is a
    very limited subset of SQL and lacks many functions and clauses
    available in standard SQL, especially what you may be used to using
    in your particular RDBMS.
    See
    Query
    of Queries user guide
    Phil

  • DECODE function to validate date value and sort the records

    Hi Friends,
    I am looking for some query which can give me the required output,
    I need to do this using SQL query only and I have tried using the MIN() and MAX() functions it was working fine with limited data, now after inserting the last record(in the below table) which has date for start_range and end_range in(mm/dd/yyyy hh24:mi:ss) format.
    Because the data type is VARCHAR2 if I am using the MIN() function it is sorting as a string value, hence the min date is incorrect. I tried using validating the value to date or non date and tried to using MIN() and MAX() functions using the DECODE function, I am getting this error "ORA-01840: input value not long enough for date format".
    select table_name,
    DECODE(substr(START_RANGE,3,1)||substr(START_RANGE,6,1)||substr(START_RANGE,11,1)||substr(START_RANGE,14,1)||substr(START_RANGE,17,1),'// ::',
    to_char(min(to_date(start_range,'mm/dd/yyyy hh24:mi:ss')),'MM/DD/YYYY HH24:MI:SS'),min(start_range)) MIN_RUNS_START_RANGE,
    DECODE(substr(END_RANGE,3,1)||substr(A.END_RANGE,6,1)||substr(END_RANGE,11,1)||substr(END_RANGE,14,1)||substr(END_RANGE,17,1),'// ::',
    to_char(max(to_date(END_RANGE,'mm/dd/yyyy hh24:mi:ss')),'MM/DD/YYYY HH24:MI:SS'),max(END_RANGE)) MAX_RUNS_END_RANGE
    from MY_TABLE
    GROUP BY table_name,
    (substr(START_RANGE,3,1)||substr(START_RANGE,6,1)||substr(START_RANGE,11,1)||substr(START_RANGE,14,1)||substr(START_RANGE,17,1)),
    (substr(END_RANGE,3,1)||substr(END_RANGE,6,1)||substr(END_RANGE,11,1)||substr(END_RANGE,14,1)||substr(END_RANGE,17,1))
    Can sombody please advise what is the best way I can query this data with the required output.
    The following are the source table and records and the out put records using the sql query.
    MY_TABLE
    TABLE_NAME(VARCHAR2),START_RANGE(VARCHAR2),END_RANGE(VARCHAR2)
    TABLE1,1000,10000
    TABLE2,ABCD,EEEE
    TABLE3,01/12/2010 00:00:00,12/31/2010 23:59:59
    TABLE1,10001,20000
    TABLE2,EEEF,GGGG
    TABLE3,01/01/2011 00:00:00,01/31/2011 23:59:59
    OUTPUT :
    TABLE_NAME,MIN(START_RANGE),MAX(END_RANGE)
    TABLE1,1000,20000
    TABLE2,ABCD,GGGG
    TABLE3,01/12/2010 00:00:00,01/31/2011 23:59:59
    Thanks
    Kalycs

    i also think this is a very bad table design ...
    but if you are not able to change it, you could split the select (date and non-date data) and combine the result with UNION like this:
    with t as
    SELECT 'TABLE1' table_name,'1000' start_range,'10000' end_range FROM dual UNION
    SELECT 'TABLE2','ABCD','EEEE' FROM dual UNION
    SELECT 'TABLE3','01/12/2010 00:00:00','12/31/2010 23:59:59' FROM dual UNION
    SELECT 'TABLE1','10001','20000' FROM dual UNION
    SELECT 'TABLE2','EEEF','GGGG' FROM dual UNION
    SELECT 'TABLE3','01/01/2011 00:00:00','01/31/2011 23:59:59' FROM dual
    SELECT table_name,
           TO_CHAR(MIN(TO_DATE(start_range, 'MM/DD/YYYY HH24:MI:SS')), 'MM/DD/YYYY HH24:MI:SS'),
           TO_CHAR(MAX(TO_DATE(end_range, 'MM/DD/YYYY HH24:MI:SS')), 'MM/DD/YYYY HH24:MI:SS')
    FROM t
    WHERE start_range LIKE '%/%/%:%:%'
    GROUP BY table_name
    UNION
    SELECT table_name,
           MIN(start_range),
           MAX(end_range)
    FROM t
    WHERE start_range NOT LIKE '%/%/%:%:%'
    GROUP BY
        table_name;
    TABLE_ MIN_VALUE           MAX_VALUE
    TABLE1 1000                20000
    TABLE2 ABCD                GGGG
    TABLE3 01/12/2010 00:00:00 01/31/2011 23:59:59

  • Decode function in Update statement

    Hello everyone,
    I'm trying to write a query where I can update a pastdue_fees column in a book_trans table based on a difference between return_dte and due_dte columns.
    I am using Oracle SQL. This is what I have so far for my decode function:
    SQL> SELECT
    2 DECODE(SIGN((return_dte - due_dte)*2),
    3 '-1', '0',
    4 '1', '12', 'Null')
    5 FROM book_trans;
    DECO
    Null
    12
    Null
    0
    So the logic is that if the sign is -1, the value in return_dte column should be 0; if it's +1 then it's 12 and everything else is Null.
    So now, I need to enter my decode function into the update statement to update the columns. However, I get error messages.
    The logic should be:
    UPDATE book_trans SET PastDue_fees = decode(expression)
    I've given it a couple of different tries with the following results:
    SQL> UPDATE book_trans
    2 SET pastdue_fees = SELECT
    3 DECODE(SIGN((return_dte - due_dte)*2),
    4 '-1', '0',
    5 '1', '12', 'Null')
    6 FROM book_trans;
    SET pastdue_fees = SELECT
    ERROR at line 2:
    ORA-00936: missing expression
    SQL> UPDATE book_trans
    2 SET pastdue_fees =
    3 DECODE(SIGN((return_dte - due_dte)*2),
    4 '-1', '0',
    5 '1', '12', 'Null')
    6 FROM book_trans;
    FROM book_trans
    ERROR at line 6:
    ORA-00933: SQL command not properly ended
    Any help or tips would be greatly appreciated as I've been taking SQL for about six weeks and not very proficient!
    Thanks!

    882300 wrote:
    Hello everyone,
    I'm trying to write a query where I can update a pastdue_fees column in a book_trans table based on a difference between return_dte and due_dte columns.
    I am using Oracle SQL. This is what I have so far for my decode function:
    SQL> SELECT
    2 DECODE(SIGN((return_dte - due_dte)*2),
    3 '-1', '0',
    4 '1', '12', 'Null')
    5 FROM book_trans;
    DECO
    Null
    12
    Null
    0
    So the logic is that if the sign is -1, the value in return_dte column should be 0; if it's +1 then it's 12 and everything else is Null.
    So now, I need to enter my decode function into the update statement to update the columns. However, I get error messages.
    The logic should be:
    UPDATE book_trans SET PastDue_fees = decode(expression)
    I've given it a couple of different tries with the following results:
    SQL> UPDATE book_trans
    2 SET pastdue_fees = SELECT
    3 DECODE(SIGN((return_dte - due_dte)*2),
    4 '-1', '0',
    5 '1', '12', 'Null')
    6 FROM book_trans;
    SET pastdue_fees = SELECT
    ERROR at line 2:
    ORA-00936: missing expression
    SQL> UPDATE book_trans
    2 SET pastdue_fees =
    3 DECODE(SIGN((return_dte - due_dte)*2),
    4 '-1', '0',
    5 '1', '12', 'Null')
    6 FROM book_trans;
    FROM book_trans
    ERROR at line 6:
    ORA-00933: SQL command not properly ended
    Any help or tips would be greatly appreciated as I've been taking SQL for about six weeks and not very proficient!
    Thanks!If you really really really want to update the entire table, the syntax would be...
    UPDATE book_trans
       SET
          pastdue_fees  = DECODE(SIGN((return_dte - due_dte)*2), -1, 0, 1, 12, Null);I took out all the single quotes. If you actually have a string column and you're storing entirely numbers in it then it should be declared as a NUMBER column and not a character (varchar2) column.
    ALWAYS use the proper data type, it'll save you a ton of headaches in the future.
    Also, since you're new to the forum, please read the FAQ so you learn the etiquette and what not.
    http://wikis.sun.com/display/Forums/Forums+FAQ

  • How to write code for this logic in a routine, very urgent --help me

    hi all,
    i want to apply this logic into one subroutin ZABC.
    here i m giving my logic ,can any body help me in coding for this, this is very urgent, i hv to submit on wednesday.
    4.1 Read the company code number BSEG-BUKRS from document line item.
    4.2 Fetch PRDHA from MARA into GV_PRDHA where MATNR = BSEG-MATNR.
    4.3 Fetch Business area (GSBER) from ZFIBU into GV_GSBER where (PRDHA = GV_PRDHA and BUKRS = BSEG-BUKRS) OR (PRDHA = GV_PRDHA and BUKRS = SPACE).
    4.4 If business area match is found, go to step 3.9. Else continue.
    4.5 If BKPF-BLART IN set “ZVS_POSDT” OR BKPF-XBLNR starts with “I0*”, execute steps below. Else, go to Step 3.6.
    i. MOVE: BSEG-BKURS TO work area field WA_ZFIBUE-BUKRS,
    BSEG-MATNR TO work area field WA_ZFIBUE-MATNR,
    GV_PRDHA TO work area field WA_ZFIBUE-PRDHA,
    BSEG-HKONT TO work area field WA_ZFIBUE-HKONT,
    BSEG-GSBER TO work area field WA_ZFIBUE-GSBER,
    BSEG-PSWBT TO work area field WA_ZFIBUE-PSWBT,
    BKPF-BUDAT TO work area field WA_ZFIBUE-BUDAT,
    SY-DATUM TO work area field WA_ZFIBUE-CREDATE,
    SY-UZEIT TO work area field WA_ZFIBUE-CRETIME,
    Fetch running serial number (WA_ZFIBUE-SERIALNO) from ZFICO. This number will be stored in ZFICO with PARAMTYPE = "BPM030307", SUBTYPE = "ZFIBUE" and KEY1 = "SERIALNO". The actual serial number will be stored in the field VALUE1.
    i. Insert WA_ZFIBUE INTO ZFIBUE.
    ii. Send email notification to the user (if it is not already sent to user on the same posting date).
    Use function module ‘SO_NEW_DOCUMENT_ATT_SEND_API1’ to send mail.
    Fetch email address and date of last email from ZFICO. These values will be stored in ZFICO with PARAMTYPE = "BPM030307", SUBTYPE = "EMAIL" and KEY1 = "<USERNAME>". The email address will be stored in the field VALUE1 and posting date in VALUE2. Once mail is sent, VALUE2 is updated with latest posting date (BKPF-BUDAT).
    iii. Increment the running serial number and update ZFICO with new serial number.
    a. GV_ SERIALNO = WA_ZFIBUE-SERIALNO + 1
    b. Update ZFICO Set value1 = GV_SERIALNO
    Where PARAMTYPE = "BPM030307" AND
    SUBTYPE = "ZFIBUE" AND
    KEY1 = "SERIALNO".
    iv Move “VDFT” to BSEG-GSBER.
    v. Exit routine.
    4.6 Fetch MTART into GV_MTART from MARA where MATNR = BSEG-MATNR.
    4.7 If SY-BATCH = INITIAL AND GV_MTART <> ‘ROH’, issue the error message - “Maintain the mapping of product hierarchy <PRDHA> from article <MATNR> for <BUKRS>”. Else, go to step 3.8.
    4.8 If SY-BATCH <> INITIAL AND GV_MTART <> ‘ROH’, issue the error message - “Maintain product hierarchy on article master”. Go to step 3.10.
    4.9 Move GV_GSBER TO BSEG-GSBER.
    4.10 Exit Routine
    plz give me reply asap --this is very urgent
    thanks in advance
    swathi

    Hi Swathi,
    If it's very very urgent then you better get on with it, don't waste time on the web. Chop chop.

  • Update Routine ... Help me Please--VERY URGENT

    Hi All ,
    I Moving data from Cube to ODS . Let me explain abt the records in the cube .
    There are 6 key figures in the cube as well as dimensions, UNIQKEY TRANSACTION is One Dimension and ARTICLE is another dimension which is having an Navigational attribute called CORE ELEMENT.
    I am showing the data with those two dimension and the key figures which are to be used in the routine.
    Charc----
    Key Figures
    UNIQKEY-ARTICLE-Coreelement--
    billqty     
    in base unit
    A00N----1006330--1--
    10.5
    A00M -
    1006320----2--
    2.5
    A00P-----1006330--1--
    10.5  
    A00P-----1006320--2--
    2.5
    A00Q-----1006320--2--
    2.5
    A00Q-----1006340--3--
    10.5
    Now Lets see what the core element numbers mean,
    core element 1 means -- fuel .
    Core elemnet other 1 -- food .   
    I need to move these data into ODS Which will have an extra field called No of items in the transaction --ITEMS.For this i need to write  a routine .
    The Logic is ...
    1.if Materail is of type 1(Means if the core element - 1)
    I need to Populate the No of items in tnx = 1 .--ITEMS.
    2.If Material is of type(Means if the core element)2or 3 I need to populate the billing quantity to the no of transcations.--ITEMS
    3. If the Uniqkey tanscation contains two line items as  suppose that you have 20 litres of fuel and 2 cans of coke, then No of Items in the transaction should be 3 and Billing Quantity in BUoM 22
    billing quantity in BUoM = 20 litres for the first line item and 2 for the second line item...
    then as the first line item is fuel, field No OF Items in the Transcation should be 1 (replacing the 20) + 2 = 3
    so the final result in the ODS should be billing quantity in BUoM = 22 and The Items in the Transcation= 3
    So the ODS Data should look like this.
    UNIQKEY--billqty--
    ITEMS
    in base unit 
    A00N--10.5--
    1
    A00M--2.5--
    2.5
    A00P--13--
    3.5
    A00Q--13--
    12.5  
    NOTE : IN the ODS only the UNIQKEY IS THE KEY FIELD and the rest are DATA FIELDS.
    I Posted this one before also. But didnt get proper responses.
    I am Pasting the piece of code which I have written . This code will work for the first two records in the cube , But it is failing for the UNIQKEY Transcation having Line items.
    PROGRAM UPDATE_ROUTINE.
    $$ begin of global - insert your declaration only below this line  -
    TABLES: /BI0/PMATERIAL.
    DATA: TITEMS LIKE /BIC/AZPOCODS00-/BIC/ZTITEMS,
           CORE_ELEMENT like /BI0/PMATERIAL-RPA_WGH1.
    $$ end of global - insert your declaration only before this line   -
    FORM compute_data_field
      TABLES   MONITOR STRUCTURE RSMONITOR "user defined monitoring
      USING    COMM_STRUCTURE LIKE /BIC/CS8ZPOCTUS04
               RECORD_NO LIKE SY-TABIX
               RECORD_ALL LIKE SY-TABIX
               SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS
      CHANGING RESULT LIKE /BIC/AZPOCODS00-/BIC/ZTITEMS
               RETURNCODE LIKE SY-SUBRC "Do not use!
               ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update
    $$ begin of routine - insert your code only below this line        -
    fill the internal table "MONITOR", to make monitor entries
    check not COMM_STRUCTURE-material is initial.
      select SINGLE RPA_WGH1
            INTO CORE_ELEMENT
            from /BI0/PMATERIAL
            where
            material = COMM_STRUCTURE-material
            and  OBJVERS <>'D'.
       IF CORE_ELEMENT EQ '1'.
       TITEMS = '1'.
         CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
           EXPORTING
             input         = titems
          IMPORTING
            OUTPUT        = titems
       ELSE.
       TITEMS = COMM_STRUCTURE-BILL_QTY.
       ENDIF.
    result value of the routine
      RESULT = TITEMS..
    if abort is not equal zero, the update process will be canceled
      ABORT = 0.
    $$ end of routine - insert your code only before this line         -
    PLease give me ideas on how to acheive this . As I am not Aware of ABAP very well.. PLease try to give me the code. I hope one of you may got the same requirement before.
    Its very urgent and I need to deliver it today itself.
    Thanks in advance , you can mail me to [email protected]. If anybody intersted to discuss this Issue they can reach at +91 9845922955.

    Hi ,
    While I am moving the data from cube to ods . I need to create the update rules with cube -- 8cube . WHen i am doing this the billqty is a key figure in cube so that is not a problem but the ITEMS is not there in the cube ,SO for that I need to write a routine to populate that one.
    Its strange but the user what to analyse with the UNIQKEY transaction. And these objects will be added as navigational attributes to the Characteristic. as it acts as another dimension.
    He wants to laod these from ODS to Master data -Characteristic.
    to say for each transcation hpw many items are getting sold.
    Message was edited by: Nagarjuna Reddy
    ONce again thanks for the qucik replies
    Message was edited by: Nagarjuna Reddy

  • UPDATE ROUTINE --- CUBE --- ODS Very Very URGENT

    Hi Collegues/Friends ,
    First I need to thank for the intiators of this site , as I came to know that for many
    problems we will get different best solutions ... Hoping the same I am posting a question
    which is very very very urgent as the client is running after me for this .
    My Requirement is as Follows. ..
    I Moving the data from Cube to ODS . While i need to write a routine for an extra field in
    ODS based on Billing Quantity in Base Unit of Measure . The Key Field in the ODS Is UNIQKEY
    Transaction and It is a Characterstic in the Cube and we have MAterial as another
    Characteristic  and core element as navigational attribute .
    In the Cube for every UNIQKEY transaction- there are more than One line items. 
    My data fields in the ODS are Billing Quantity in Base Unit of MEasure and and EXTRA FIELD
    : No of Items in Transaction . But the thing is that I have only Billing Quantity in Base
    Unit of Measure in cube as a key figure
    BAsing on the UNIQKEY transcation and Billing Quantity In Base Unit Of Measure I need to
    populate the No of Items in Transaction... For this i need to write a routine .
    Let suppose say that for the Materials the core elements are as follows
    Material  Core element
    10         1 -- fuel -- In liters
    20         2 -- Cigar - in PAck
    30         3 -- Coke - in Cans
    Now Lets see how the records are there in InfoCUbe
    Uniqkey  /  Material  / Core element /Billin Quantiy
    A          /   10      /     1        /    22
    B          /   30      /     3        /    2
    C          /   10      /    1         /  15
    C          /   30      /     3        /     2
    D          /   20      /     2        /    10
    D          /   30      /     3        /    2
    And IN the ODS -- I need to Populate the No OF items in Transaction.
    the Logic behind this as follows .
    1.if Materail is of type  1(Mean if the core element - 1)
    I need to Populate the No of items in tnx = 1
    2.If Material id of type 2 or 3 I need to populate the billing quantity to the no of
    transcations.
    3. If the Uniqkey tanscation contains two line items as  suppose that you have 20 litres of
    fuel and 2 cans of coke, then No of Items in the transaction should be 3 and Billing
    Quantity in BUoM 22
    billing quantity in BUoM = 20 litres for the first line item and 2 for the second line
    item...
    then as the first line item is fuel, field No OF Items in the Transcation should be 1
    (replacing the 20) + 2 = 3
    so the final result in the ODS should be billing quantity in BUoM = 22 and The Items in the
    Transcation = 3
    For this I have Written a Rouinte like this for that field
    PROGRAM UPDATE_ROUTINE.
    $$ begin of global - insert your declaration only below this line  -
    TABLES: /BI0/PMATERIAL.
    DATA: TITEMS LIKE /BIC/AZPOCODS00-/BIC/ZTITEMS,
           CORE_ELEMENT like /BI0/PMATERIAL-RPA_WGH1.
    $$ end of global - insert your declaration only before this line   -
    FORM compute_data_field
      TABLES   MONITOR STRUCTURE RSMONITOR "user defined monitoring
      USING    COMM_STRUCTURE LIKE /BIC/CS8ZPOCTUS04
               RECORD_NO LIKE SY-TABIX
               RECORD_ALL LIKE SY-TABIX
               SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS
      CHANGING RESULT LIKE /BIC/AZPOCODS00-/BIC/ZTITEMS
               RETURNCODE LIKE SY-SUBRC "Do not use!
               ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update
    $$ begin of routine - insert your code only below this line        -
    fill the internal table "MONITOR", to make monitor entries
    check not COMM_STRUCTURE-material is initial.
      select SINGLE RPA_WGH1
            INTO CORE_ELEMENT
            from /BI0/PMATERIAL
            where
            material = COMM_STRUCTURE-material
            and  OBJVERS <>'D'.
       IF CORE_ELEMENT EQ '1'.
       TITEMS = '1'.
         CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
           EXPORTING
             input         = titems
          IMPORTING
            OUTPUT        = titems
       ELSE.
       TITEMS = COMM_STRUCTURE-BILL_QTY.
       ENDIF.
    result value of the routine
      RESULT = TITEMS..
    if abort is not equal zero, the update process will be canceled
      ABORT = 0.
    $$ end of routine - insert your code only before this line         -
    Does it satisfy all the conditions ?? mentioned above if . As far As i know as the only key
    field in the transcation it will satisfy the first two conditions .
    I want to know or If possioble anybody pls take some pain for me to send the code or any
    Ideas for satisfying all the conditions.
    Hope I will get immediate replies....
    Mail me to [email protected]

    Reddy,
    Please do not post in all sections ... makes it hard to follow up on posts..
    Arun

  • Open items for purchase order its very urgent

    hi
    my requirement is to write extract program for purchase order(me21) to extract only open items.
    please provide sample code its very urgent.
    thanks in advance.
    points will be rewarded.
    thanks
    hari prasad reddy

    check the below report :
    REPORT ZMM_OPEN_PO_REPORT no standard page heading
                              line-size 255
                              message-id zwave.
    ======================================================================
    Program Name : ZMM_OPEN_PO_REPORT                                    *
    Description  : This report displays all Open PO Items and output     *
                   would be PO Number,Material number and so on          *
    Author       : Seshu                                                 *
    Date         : 01/24/2007                                            *
    MODIFICATION HISTORY                                                 *
    DATE    | AUTHOR   | CHANGE #   | DESCRIPTION OF MODIFICATION        *
    --|||--
    01/24/07| Seshu    | DEVK921979 | Initial                            *
    D A T A  D E C L A R A T I O N   P A R T                         ***
    type-pools
    type-pools : slis.
    Tables
    tables : ekko, " Purchase order Header
             ekpo, " Purchase order Item
             marc. " Material with Plant data
    Internal table for output.
    data : begin of i_output occurs 0,
           ebeln like ekko-ebeln,
           matnr like ekpo-matnr,
           end of i_output.
    ALV Data declaration.
    data : v_repid like sy-repid.
      ALV Function Module Variables
    DATA: gs_layout type slis_layout_alv,
          g_exit_caused_by_caller,
          gs_exit_caused_by_user type slis_exit_by_user.
    DATA: gt_fieldcat    type slis_t_fieldcat_alv,
          gs_print       type slis_print_alv,
          gt_events      type slis_t_event,
          gt_list_top_of_page type slis_t_listheader,
          g_status_set   type slis_formname value 'PF_STATUS_SET',
          g_user_command type slis_formname value 'USER_COMMAND',
          g_top_of_page  type slis_formname value 'TOP_OF_PAGE',
          g_top_of_list  type slis_formname value 'TOP_OF_LIST',
          g_end_of_list  type slis_formname value 'END_OF_LIST',
          g_variant LIKE disvariant,
          g_save(1) TYPE c,
          g_tabname_header TYPE slis_tabname,
          g_tabname_item   TYPE slis_tabname,
          g_exit(1) TYPE c,
          gx_variant LIKE disvariant.
    data : gr_layout_bck type slis_layout_alv.
    Ranges
    ranges r_eindt for eket-eindt.
    initialization.
    v_repid = sy-repid.
    start-of-selection.
    Get the data from EKKO ,EKPO and MARC Table
    perform get_data_tables.
    end-of-selection.
    display the data in the form of ALV
    perform display_data.
    *&      Form  get_data_tables
          Get the data from EKKO,EKPO and MARC Table
    FORM get_data_tables.
    clear : i_output.
    refresh : i_output.
    fill the dates in ranges
    r_eindt-low = sy-datum - 7.
    r_eindt-high = sy-datum + 14.
    r_eindt-option = 'BT'.
    r_eindt-sign = 'I'.
    append r_eindt.
    Get the data from EKKO,EKPO and EKET Tables
    select aebeln bmatnr into table i_output
                           from ekko as a inner join
                                ekpo as b on aebeln = bebeln
                                inner join marc as c on cmatnr = bmatnr
                                inner join mara as d on dmatnr = bmatnr
                                inner join eket as e on eebeln = aebeln
                                               and   eebelp = bebelp
                                where c~beskz = 'E'
                                and   c~werks = '1000'
                                and   d~mtart = 'FERT'
                                and   b~loekz = space
                                and   b~elikz = space
                                and   e~eindt in r_eindt.
    if sy-subrc ne 0.
    message e000(zwave) with 'No open purchase order found'.
    endif.
    ENDFORM.                    " get_data_tables
    *&      Form  display_data
          text
    FORM display_data.
    Fill the Fiedlcat
      PERFORM fieldcat_init  using gt_fieldcat[].
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
       I_INTERFACE_CHECK                 = ' '
       I_BYPASSING_BUFFER                =
       I_BUFFER_ACTIVE                   = ' '
         I_CALLBACK_PROGRAM                = v_repid
       I_CALLBACK_PF_STATUS_SET          = ' '
        I_CALLBACK_USER_COMMAND           = g_user_command
       I_CALLBACK_TOP_OF_PAGE            = ' '
       I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
       I_CALLBACK_HTML_END_OF_LIST       = ' '
       I_STRUCTURE_NAME                  =
       I_BACKGROUND_ID                   = ' '
       I_GRID_TITLE                      =
       I_GRID_SETTINGS                   =
       IS_LAYOUT                         = gr_layout_bck
          IT_FIELDCAT                       = gt_fieldcat[]
       IT_EXCLUDING                      =
       IT_SPECIAL_GROUPS                 =
       IT_SORT                           =
       IT_FILTER                         =
       IS_SEL_HIDE                       =
       I_DEFAULT                         = 'X'
        I_SAVE                            = g_save
        IS_VARIANT                        =
       IT_EVENTS                         =
       IT_EVENT_EXIT                     =
       IS_PRINT                          =
       IS_REPREP_ID                      =
       I_SCREEN_START_COLUMN             = 0
       I_SCREEN_START_LINE               = 0
       I_SCREEN_END_COLUMN               = 0
       I_SCREEN_END_LINE                 = 0
       IT_ALV_GRAPHICS                   =
       IT_ADD_FIELDCAT                   =
       IT_HYPERLINK                      =
       I_HTML_HEIGHT_TOP                 =
       I_HTML_HEIGHT_END                 =
       IT_EXCEPT_QINFO                   =
    IMPORTING
       E_EXIT_CAUSED_BY_CALLER           =
       ES_EXIT_CAUSED_BY_USER            =
        TABLES
          T_OUTTAB                          = i_output
       EXCEPTIONS
         PROGRAM_ERROR                     = 1
         OTHERS                            = 2
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " display_data
    *&      Form  fieldcat_init
          text
         -->P_GT_FIELDCAT[]  text
    FORM fieldcat_init USING  e01_lt_fieldcat type slis_t_fieldcat_alv.
      DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    Purchase order number
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-FIELDNAME    = 'EBELN'.
      LS_FIELDCAT-ref_fieldname = 'EBELN'.
      LS_FIELDCAT-ref_tabname = 'EKKO'.
      LS_FIELDCAT-TABNAME    = 'I_OUTPUT'.
      ls_fieldcat-seltext_L = 'Purchase Order'.
      ls_fieldcat-seltext_M = 'Purchase Order'.
      ls_fieldcat-seltext_S = 'Purchase Order'.
      APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
    Material #
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-FIELDNAME    = 'MATNR'.
      LS_FIELDCAT-ref_fieldname = 'MATNR'.
      LS_FIELDCAT-ref_tabname = 'EKPO'.
      LS_FIELDCAT-TABNAME    = 'I_OUTPUT'.
      ls_fieldcat-seltext_L = 'Material'.
      ls_fieldcat-seltext_M = 'Material'.
      ls_fieldcat-seltext_S = 'Material'.
      APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
    ENDFORM.                    " fieldcat_init

Maybe you are looking for