Using package functions in an update

Okay, I have a package function that returns a correct value when used in a SELECT, but when used in an UPDATE, it returns Null. Why can't I used its result in the UPDATE?
Package Spec
FUNCTION fpub_get_contract_attribute
     (     n_contract_id_in                    IN               CONTRACT.CONTRACT_ID%TYPE,
          s_attribute_in                         IN               VARCHAR2 )
RETURN VARCHAR2;
PRAGMA RESTRICT_REFERENCES(fpub_get_contract_attribute,TRUST,WNDS);
Source :
clear;
rollback;
select
     contract_functions.fpub_get_contract_attribute(CONTRACT_ID,'ORIGINAL_SALES_CHANNEL') "Before",
     original_sales_channel
from contract
where contract_id = 52549615;
update contract
set original_sales_channel = NVL(contract_functions.fpub_get_contract_attribute(CONTRACT_ID,'ORIGINAL_SALES_CHANNEL'),'Null')
where contract_id = 52549615;
select
     NVL(contract_functions.fpub_get_contract_attribute(52549615,'ORIGINAL_SALES_CHANNEL'),'Null') "After",
     original_sales_channel
from contract
where contract_id = 52549615;
rollback;
Result :
Rollback complete
Before                ORIGINAL_SALES_CHANNEL
RE                                                                              
1 row updated
After                 ORIGINAL_SALES_CHANNEL
Null                  Null
Rollback completeAny ideas?
Thanks,
Jason

Pragma restrict_references has not been required since 8i, so you can get rid of that. However, certain things will still be enforced, with or without the pragma. For example, you cannot perform DML from within a packaged function when that function is used in a select statement, although you can perform DML within a packaged function when it is used in an update statement. So, if you are performing some sort of DML in your function, it would not raise an error when used in the update statement, but would cause it to return whatever is specified in the exception block when used in a select statement, causing the different results.
Please see the demonstration below in which I have created a sample function that contains an insert statement. When I use the function from a select statement, it raises an error and does not insert a row. However, when I use the function in an update statement, it does not raise an error and inserts a row. I have then added an exception clause to the function and re-tested. When I used the function in a select statement, it now returns the value in the exception block, but still does not insert a row. When I used the function in an update statement, it returns a different value, not from the exception block, and inserts a row. Then I removed the insert statement from the function and re-tested. Now it returns the same value, whether used in a select statement or an update statement.
scott@ORA92> SELECT banner FROM v$version
  2  /
BANNER
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
PL/SQL Release 9.2.0.1.0 - Production
CORE     9.2.0.1.0     Production
TNS for 32-bit Windows: Version 9.2.0.1.0 - Production
NLSRTL Version 9.2.0.1.0 - Production
scott@ORA92> CREATE TABLE test
  2    (col1 VARCHAR2(30))
  3  /
Table created.
scott@ORA92> CREATE TABLE contract
  2    (contract_id            NUMBER,
  3       original_sales_channel VARCHAR2(30))
  4  /
Table created.
scott@ORA92> INSERT INTO contract (contract_id) VALUES (52549615)
  2  /
1 row created.
scott@ORA92> COMMIT
  2  /
Commit complete.
scott@ORA92> CREATE OR REPLACE PACKAGE contract_functions
  2  AS
  3    FUNCTION fpub_get_contract_attribute
  4        (n_contract_id_in IN CONTRACT.CONTRACT_ID%TYPE,
  5         s_attribute_in   IN VARCHAR2 )
  6        RETURN            VARCHAR2;
  7  END contract_functions;
  8  /
Package created.
scott@ORA92> SHOW ERRORS
No errors.
scott@ORA92> -- test with insert statement and no exception handling:
scott@ORA92> CREATE OR REPLACE PACKAGE BODY contract_functions
  2  AS
  3    FUNCTION fpub_get_contract_attribute
  4        (n_contract_id_in IN CONTRACT.CONTRACT_ID%TYPE,
  5         s_attribute_in   IN VARCHAR2 )
  6        RETURN            VARCHAR2
  7    IS
  8    BEGIN
  9        INSERT INTO test (col1) VALUES ('inserting');
10        RETURN 'Null';
11    END fpub_get_contract_attribute;
12  END contract_functions;
13  /
Package body created.
scott@ORA92> SHOW ERRORS
No errors.
scott@ORA92> SELECT * FROM contract
  2  /
CONTRACT_ID ORIGINAL_SALES_CHANNEL
   52549615
scott@ORA92> COLUMN "Before" FORMAT A30
scott@ORA92> select contract_functions.fpub_get_contract_attribute (CONTRACT_ID, 'ORIGINAL_SALES_CHANNEL') "Before",
  2           original_sales_channel
  3  from   contract
  4  where  contract_id = 52549615
  5  /
select contract_functions.fpub_get_contract_attribute (CONTRACT_ID, 'ORIGINAL_SALES_CHANNEL') "Before",
ERROR at line 1:
ORA-14551: cannot perform a DML operation inside a query
ORA-06512: at "SCOTT.CONTRACT_FUNCTIONS", line 9
scott@ORA92> SELECT * FROM test
  2  /
no rows selected
scott@ORA92> update contract
  2  set    original_sales_channel = NVL (contract_functions.fpub_get_contract_attribute (CONTRACT_ID, 'ORIGINAL_SALES_CHANNEL'), 'Null')
  3  where  contract_id = 52549615
  4  /
1 row updated.
scott@ORA92> SELECT * FROM test
  2  /
COL1
inserting
scott@ORA92> COLUMN "After" FORMAT A30
scott@ORA92> select contract_functions.fpub_get_contract_attribute (CONTRACT_ID, 'ORIGINAL_SALES_CHANNEL') "After",
  2           original_sales_channel
  3  from   contract
  4  where  contract_id = 52549615
  5  /
select contract_functions.fpub_get_contract_attribute (CONTRACT_ID, 'ORIGINAL_SALES_CHANNEL') "After",
ERROR at line 1:
ORA-14551: cannot perform a DML operation inside a query
ORA-06512: at "SCOTT.CONTRACT_FUNCTIONS", line 9
scott@ORA92> SELECT * FROM test
  2  /
COL1
inserting
scott@ORA92> --
scott@ORA92> -- repeat test with insert statement and exception handling:
scott@ORA92> ROLLBACK
  2  /
Rollback complete.
scott@ORA92> CREATE OR REPLACE PACKAGE BODY contract_functions
  2  AS
  3    FUNCTION fpub_get_contract_attribute
  4        (n_contract_id_in IN CONTRACT.CONTRACT_ID%TYPE,
  5         s_attribute_in   IN VARCHAR2 )
  6        RETURN            VARCHAR2
  7    IS
  8    BEGIN
  9        INSERT INTO test (col1) VALUES ('inserting');
10        RETURN 'Null';
11    EXCEPTION
12        WHEN OTHERS THEN RETURN 'RE';
13    END fpub_get_contract_attribute;
14  END contract_functions;
15  /
Package body created.
scott@ORA92> SHOW ERRORS
No errors.
scott@ORA92> select contract_functions.fpub_get_contract_attribute (CONTRACT_ID, 'ORIGINAL_SALES_CHANNEL') "Before",
  2           original_sales_channel
  3  from   contract
  4  where  contract_id = 52549615
  5  /
Before                         ORIGINAL_SALES_CHANNEL
RE
scott@ORA92> SELECT * FROM test
  2  /
no rows selected
scott@ORA92> update contract
  2  set    original_sales_channel = NVL (contract_functions.fpub_get_contract_attribute (CONTRACT_ID, 'ORIGINAL_SALES_CHANNEL'), 'Null')
  3  where  contract_id = 52549615
  4  /
1 row updated.
scott@ORA92> SELECT * FROM test
  2  /
COL1
inserting
scott@ORA92> select contract_functions.fpub_get_contract_attribute (CONTRACT_ID, 'ORIGINAL_SALES_CHANNEL') "After",
  2           original_sales_channel
  3  from   contract
  4  where  contract_id = 52549615
  5  /
After                          ORIGINAL_SALES_CHANNEL
RE                             Null
scott@ORA92> SELECT * FROM test
  2  /
COL1
inserting
scott@ORA92> --
scott@ORA92> -- repeat test with no insert statement and no exception handling:
scott@ORA92> ROLLBACK
  2  /
Rollback complete.
scott@ORA92> CREATE OR REPLACE PACKAGE BODY contract_functions
  2  AS
  3    FUNCTION fpub_get_contract_attribute
  4        (n_contract_id_in IN CONTRACT.CONTRACT_ID%TYPE,
  5         s_attribute_in   IN VARCHAR2 )
  6        RETURN            VARCHAR2
  7    IS
  8    BEGIN
  9        RETURN 'Null';
10    END fpub_get_contract_attribute;
11  END contract_functions;
12  /
Package body created.
scott@ORA92> SHOW ERRORS
No errors.
scott@ORA92> select contract_functions.fpub_get_contract_attribute (CONTRACT_ID, 'ORIGINAL_SALES_CHANNEL') "Before",
  2           original_sales_channel
  3  from   contract
  4  where  contract_id = 52549615
  5  /
Before                         ORIGINAL_SALES_CHANNEL
Null
scott@ORA92> SELECT * FROM test
  2  /
no rows selected
scott@ORA92> update contract
  2  set    original_sales_channel = NVL (contract_functions.fpub_get_contract_attribute (CONTRACT_ID, 'ORIGINAL_SALES_CHANNEL'), 'Null')
  3  where  contract_id = 52549615
  4  /
1 row updated.
scott@ORA92> SELECT * FROM test
  2  /
no rows selected
scott@ORA92> select contract_functions.fpub_get_contract_attribute (CONTRACT_ID, 'ORIGINAL_SALES_CHANNEL') "After",
  2           original_sales_channel
  3  from   contract
  4  where  contract_id = 52549615
  5  /
After                          ORIGINAL_SALES_CHANNEL
Null                           Null
scott@ORA92> SELECT * FROM test
  2  /
no rows selected
scott@ORA92>

Similar Messages

  • Using packaged functions in Apex

    Hi,
    I'm fairly new to apex and I am about to write an app which needs to access a SQL server database. My local dba has set up the transparent gateway and I can select from and update the SQLServer database no problem via a db link. What I need to decide is whether to code the sql for reports etc directly into the apex page or to call a pl/sql function returning a select statement. I would like to have all the code in packages as a lot of it will be used by multiple apps in future but is there any extra overhead in doing this:
    declare
    l_sql varchar2(4000);
    begin
    select package.function into l_sql from dual;
    return l_sql;
    end;
    rather than coding the SQL directly in the page? Also is there a more efficient way of using packaged functions to select data rather that just have it returning sql statements.
    Thanks in advance.
    Dave

    Hi
    I only use function returning select when I have a strong reason to do so, because it is so much more difficult to test and maintain. Not sure about performance, but I think it is not that much worse.
    If you simply want to reuse SELECT statements, you could use views instead.
    Anyway, if you decide to use the package solution, at least you can make it much simpler -- just code like this in the page:
    return package.function;
    I hope this helps.
    Luis

  • Use of function module to update Realignment data: Demand Planning

    Hi,
    Can anyone explain how the function module /SAPAPO/TS_RLG_STEP_CREATE works? I need to use it to update Realignment table(of CVC creation in Demand Planning).
    Thanks !

    I also need information about this bapi /SAPAPO/TS_RLG_STEP_CREATE
    Thanks

  • DBMS_JOB using Packaged Functions but Package goes invalid

    Is there any way to check a package while running a PL/SQL procedure to see if it's state is valid and then catch the exception?
    In my case usually just calling any function in the package 1x clears it up but the procedure in question runs as a DBMS_JOB it just keeps failing. This procedure could run often enough that Oracle will mark it as broken but I want to give it every shot at execution on time instead of having to make it wait till the next cycle.
    What I would like to do is to catch the exception for the package state being invalid and basically have it go back to the beginning of the procedure and give it another try before failing in case it is just a failure because the package has been altered.
    Is there any way to do this?

    Firstly, I'll copy/paste my standard response regarding package state going invalid as it usually helps to have an understanding of these things...
    Packages tend to fail because of their "package state". A package has a "state" when it contains package level variables/constants etc. and the package is called. Upon first calling the package, the "state" is created in memory to hold the values of those variables etc. If an object that the package depends upon e.g. a table is altered in some way e.g. dropped and recreated, then because of the database dependencies, the package takes on an INVALID status. When you next make a call to the package, Oracle looks at the status and sees that it is invalid, then determines that the package has a "state". Because something has altered that the package depended upon, the state is taken as being out of date and is discarded, thus causing the "Package state has been discarded" error message.
    If a package does not have package level variables etc. i.e. the "state" then, taking the same example above, the package takes on an INVALID status, but when you next make a call to the package, Oracle sees it as Invalid, but knows that there is no "state" attached to it, and so is able to recompile the package automatically and then carry on execution without causing any error messages. The only exception here is if the thing that the package was dependant on has changes in such a way that the package cannot compile, in which case you'll get an Invalid package type of error.
    And if you want to know how to prevent discarded package states....
    Move all constants and variables into a stand-alone package spec and reference those from your initial package. Thus when the status of your original package is invlidated for whatever reason, it has no package state and can be recompiled automatically, however the package containing the vars/const will not become invalidated as it has no dependencies, so the state that is in memory for that package will remain and can continue to be used.
    As for having package level cursors, you'll need to make these local to the procedures/functions using them as you won't be able to reference cursors across packages like that (not sure about using REF CURSORS though.... there's one for me to investigate!)
    This first example shows the package state being invalided by the addition of a new column on the table, and causing it to give a "Package state discarded" error...
    SQL> set serveroutput on
    SQL>
    SQL> create table dependonme (x number)
      2  /
    Table created.
    SQL>
    SQL> insert into dependonme values (5)
      2  /
    1 row created.
    SQL>
    SQL> create or replace package mypkg is
      2    procedure myproc;
      3  end mypkg;
      4  /
    Package created.
    SQL>
    SQL> create or replace package body mypkg is
      2    v_statevar number := 5; -- this means my package has a state
      3
      4    procedure myproc is
      5      myval number;
      6    begin
      7      select x
      8      into myval
      9      from dependonme;
    10
    11      myval := myval * v_statevar;
    12      DBMS_OUTPUT.PUT_LINE('My Result is: '||myval);
    13    end;
    14  end mypkg;
    15  /
    Package body created.
    SQL>
    SQL> exec mypkg.myproc
    My Result is: 25
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
      2  /
    OBJECT_NAME
    OBJECT_TYPE         STATUS
    MYPKG
    PACKAGE             VALID
    MYPKG
    PACKAGE BODY        VALID
    SQL>
    SQL>
    SQL> alter table dependonme add (y number)
      2  /
    Table altered.
    SQL>
    SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
      2  /
    OBJECT_NAME
    OBJECT_TYPE         STATUS
    MYPKG
    PACKAGE             VALID
    MYPKG
    PACKAGE BODY        INVALID
    SQL>
    SQL> exec mypkg.myproc
    BEGIN mypkg.myproc; END;
    ERROR at line 1:
    ORA-04068: existing state of packages has been discarded
    ORA-04061: existing state of package body "SCOTT.MYPKG" has been invalidated
    ORA-06508: PL/SQL: could not find program unit being called: "SCOTT.MYPKG"
    ORA-06512: at line 1
    SQL>
    SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
      2  /
    OBJECT_NAME
    OBJECT_TYPE         STATUS
    MYPKG
    PACKAGE             VALID
    MYPKG
    PACKAGE BODY        INVALID
    SQL>
    SQL> exec mypkg.myproc
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
      2  /
    OBJECT_NAME
    OBJECT_TYPE         STATUS
    MYPKG
    PACKAGE             VALID
    MYPKG
    PACKAGE BODY        VALIDAnd this next example shows how having the package variables in their own package spec, allows the package to automatically recompile when it is called even though it became invalidated by the action of adding a column to the table.
    SQL> drop table dependonme
      2  /
    Table dropped.
    SQL>
    SQL> drop package mypkg
      2  /
    Package dropped.
    SQL>
    SQL> set serveroutput on
    SQL>
    SQL> create table dependonme (x number)
      2  /
    Table created.
    SQL>
    SQL> insert into dependonme values (5)
      2  /
    1 row created.
    SQL>
    SQL> create or replace package mypkg is
      2    procedure myproc;
      3  end mypkg;
      4  /
    Package created.
    SQL>
    SQL> create or replace package mypkg_state is
      2    v_statevar number := 5; -- package state in seperate package spec
      3  end mypkg_state;
      4  /
    Package created.
    SQL>
    SQL> create or replace package body mypkg is
      2    -- this package has no state area
      3
      4    procedure myproc is
      5      myval number;
      6    begin
      7      select x
      8      into myval
      9      from dependonme;
    10
    11      myval := myval * mypkg_state.v_statevar;  -- note: references the mypkg_state package
    12      DBMS_OUTPUT.PUT_LINE('My Result is: '||myval);
    13    end;
    14  end mypkg;
    15  /
    Package body created.
    SQL>
    SQL> exec mypkg.myproc
    My Result is: 25
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
      2  /
    OBJECT_NAME
    OBJECT_TYPE         STATUS
    MYPKG
    PACKAGE             VALID
    MYPKG
    PACKAGE BODY        VALID
    SQL>
    SQL> alter table dependonme add (y number)
      2  /
    Table altered.
    SQL>
    SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
      2  /
    OBJECT_NAME
    OBJECT_TYPE         STATUS
    MYPKG
    PACKAGE             VALID
    MYPKG
    PACKAGE BODY        INVALID
    SQL>
    SQL> exec mypkg.myproc
    My Result is: 25
    PL/SQL procedure successfully completed.---------------------------------------------------------------------------------------------
    Secondly, from this above standard response, you can see how to check for package state if you want to determine it programatically.
    ;)

  • How to use function module to update data

    Hello ,
    Can any body have idea how we can use function module SAVE_TEXT to update the master recipe header and operation long text.
    I want to use this functional module to update the master recipe long text
    step by step procedure is highly appreciated
    thanks & regards
    siddhasrth

    Hi
    SAVE_TEXT
    SAVE_TEXT writes a text module back to the text file or the text memory, depending on the storage mode of the corresponding text object.
    You can use this module either to change existing texts or to create new texts. If you know for sure that the text is new, use the parameter INSERT to indicate this. The system then does not have to read the text first, which improves the performance of the function module.
    If the lines table passed with the function module is empty, the system deletes the text from the text file.
    Function call:
    CALL FUNCTION 'SAVE_TEXT'
    EXPORTING CLIENT = SY-MANDT
    HEADER = ?...
    INSERT = SPACE
    SAVEMODE_DIRECT = SPACE
    OWNER_SPECIFIED = SPACE
    IMPORTING FUNCTION =
    NEWHEADER =
    TABLES LINES = ?...
    EXCEPTIONS ID =
    LANGUAGE =
    NAME =
    check thi sample code
    CALL FUNCTION 'SAVE_TEXT'
    EXPORTING
    CLIENT = SY-MANDT
    HEADER = t_header
    SAVEMODE_DIRECT = 'X'
    * OWNER_SPECIFIED = ' '
    * LOCAL_CAT = ' '
    * IMPORTING
    * FUNCTION =
    * NEWHEADER =
    TABLES
    LINES = t_long
    EXCEPTIONS
    ID = 1
    LANGUAGE = 2
    NAME = 3
    OBJECT = 4
    OTHERS = 5
    Reward all helpfull answers
    Regards
    Pavan

  • How can i use multiple row subquery in update statement

    Hai All
    I using group function in my update statement.. and i need to update more rows so i need to use multiple row
    subquery pls tell me how to use multiple row subquery in update statement
    For example
    while i am using this like this i got an error
    update dail_att set outtime in (select max(r2.ptime) from temp_att where empcode=r2.enpno and
    barcode=r2.cardn and attend_date=r2.pdate group by enpno,pdate,cardn);
    Pls tell me how to use with example
    Thanks & regards
    Srikkanth.M

    Hai Man
    Thanks for ur response Let me clear what i need
    First step Fetch the records as text file and stores into table T1
    and the next step is i have seperated the text using substring and stores in different columns of a table
    There are two shifts 0815 to 1645 and 1200 and 2000
    Here I rep IN and O rep OUT
    Empno date time inout
    001 01-01-10 0815 I
    002 01-01-10 0815 I
    003 01-01-10 0818 I
    001 01-01-10 1100 0
    001 01-01-10 1130 I
    002 01-01-10 1145 0
    002 01-01-10 1215 I
    004 01-01-10 1200 I
    005 01-01-10 1215 I
    004 01-01-10 1315 O
    004 01-01-10 1345 I
    001 01-01-10 1645 0
    002 01-01-10 1715 0
    003 01-01-10 1718 0
    004 01-01-10 2010 0
    005 01-01-10 2015 0
    This is my T1 table i have taken data from text file and stored in this table from this table i need to move data to another table T2
    T2 contains like this
    Empno Intime Intrin Introut Outtime Date
    001 0815 1100 1130 1645 01-01-10
    002 0815 1145 1215 1715 01-01-10
    003 0818 1718 01-01-10
    004 1200 1315 1345 2010 01-01-10
    005 1215 2015 01-01-10
    This what i am trying to do man but i have little bit problems Pls give some solution with good example
    And my coding is
    declare
         emp_code varchar2(25);
    in_time varchar2(25);
    out_time varchar2(25);
    Cursor P1 is
    Select REASON,ECODE,READMODE,EMPD,ENPNO,FILL,PDATE,PTIME,INOUT,CARDN,READERN
    From temp_att
    group by REASON,ECODE,READMODE,EMPD,ENPNO,FILL,PDATE,PTIME,INOUT,CARDN,READERN
    ORDER BY enpno,pdate,ptime;
    begin
         for r2 in p1 loop
    declare
    bar_code varchar2(25);
    begin
    select barcode into bar_code from dail_att where empcode=r2.enpno and attend_date=r2.pdate;
    For r3 in (select empcode,empname,barcode,intime,intrin,introut,addin,addout,outtime,attend_date from dail_att)loop
    if r2.inout ='O' then
    update dail_att set outtime =(select max(r2.ptime) from temp_att where empcode=r2.enpno and barcode=r2.cardn and attend_date=r2.pdate group by r2.cardn,r2.enpno,r2.pdate );
    end if;
    end loop;     
    exception
         when no_data_found then
         if r2.inout ='I' then
                   insert into dail_att(barcode,empcode,intime,attend_date)(select r2.cardn,r2.enpno,min(r2.ptime),r2.pdate from temp_att group by r2.cardn,r2.enpno,r2.pdate );
         end if;
    end;
    end loop;
    commit;     
         end;
    Pls tell me what correction i need to do i the update statement i have used a subquery with group function but when i used it will return only one row but my need is to return many rows and i need to use multiple row subquery
    and how can i use it in the update statement
    Thanks In Advance
    Srikkanth.M

  • How to use these function modules

    Hi all,
    can anyone help that how to use these Function modules to update the status of a task, what are all the inputs i required to proceed
    1. FC_USER_AUTHORITY_CHECK
    <b>2. FC_USER_STATUS_CHECK
    3. FC_USER_STATUS_UPDATE</b>
    4. FC_USER_GET_CACTI
    5. FC_USER_CHECK_FOR_OUTPUT
    Thanks in Advance
    Ganesh

    Hi Rob,
    thanks for ur reply,
    but they are not clear what they are meant to be, I understood there are some flags needed to run the Function Modules 2 & 3 which are in bold...
    but how do i populate them.. i am not getting that..
    thanks
    ganesh

  • CALL FUNCTION update_function IN UPDATE TASK

    hi
    please give me an <b>example  for implementation</b> of  CALL FUNCTION update_function IN UPDATE TASK
    plz help.. its urgent
    useful solutions will be rewarded
    <b>note</b>: dont give me link. i need simple straight forward example
    thanks
    ravish

    Hi,
       When u want to call function which has to be executed in the Update work process.
    1. You have to set the "Processing Type"  to  "Update Module" and select "Immediate Start" which makes the function to be processed using V1 update process(for critical updates)
    function module parameters must be passed by using Pass by Value only.
    Export parameters are not supported.
    In the source code of the function
    to perform a ROLLBACK in case of any error
    Generate a message using type A(Abend)
    2. Call the function from the program using
       CALL FUNCTION 'Z_FM' in update task
       EXPORTING
      TABLES
      COMMIT WORK .  
    hope this will help.
    Reward if so.
    Regards,
    Varma

  • BOM Update using a function module - 'CSAP_MAT_BOM_MAINTAIN'

    Hi,
    I have problem in updating the item status for a BOM using a function module - 'CSAP_MAT_BOM_MAINTAIN'.
    My goal is reset the Checkbox for 'Indicator: item relevant to production'. When i pass the value ' '[Space] to the structure field 'T_STPO-REL_PROD' it doen't work.
    Do let me know if you come across such problem & what needs to passed as input to reste the checkbox in the BOM.
    Thanks & Regards,
    Bhargava

    PLM wants to manipulate the Indicators u2013 u201CBulk Materialu201D & u201CCost Relevancyu201D in BOM.
    Note: The 2 indicators [u201CBulk Materialu201D & u201CCost Relevancyu201D] are interlinked with each other for a business functionlity given by SAP. So, if we try to set both indicators we get the below SAP standard error.
    E 29127 Bulk material not allowed for items relevant to costing
    SAP Field Name                             RFC Tag       SAP values    PLM values  Meaning for SAP field
    Indicator: bulk material                   BULK_MAT   Space             !                   No
    Indicator: bulk material                   BULK_MAT    X                   X                  Yes
    Indicator: item relevant to costing  REL_COST    Space            !                    Not relevant to costing
    Indicator: item relevant to costing  REL_COST     1                   1                   Not relevant to costing
    Indicator: item relevant to costing  REL_COST     2                   2                   Packaging operation
    Indicator: item relevant to costing  REL_COST     3                   3                   Packaging material
    Indicator: item relevant to costing  REL_COST     X                   X                  Relevant to costing
    To achieve the clear/reset/set value for 2 indicators [u201CBulk Materialu201D & u201CCost Relevancyu201D] from PLM, only eitheir of indicators status needs to sent [i.e 1 indicator status @ a time].

  • Function Module to update Bill of Lading & No. of packages in a Delivery

    Hi,
    Can any one suggest me a function module to update Bill of Lading & No. of packages in a Delivery ?
    Thanks in Advance.

    Hi:
    I am also trying to update components of PM. I used the function CO2M_COMPONENT_CHANGE_WITH_REF, but I am not sure if I am passing the correct parameters. If possible  can you please send a sample code Or you can take a look at my code and tell me where I am doing wrong.. Thanks.
    Here is what I am passing into the the function:
    DATA: in_resbd_new LIKE resbd,
    in_rsnum_source    LIKE     resb-rsnum,
    in_rspos_source    LIKE     resb-rspos,
    in_rsart_source    LIKE     resb-rsart,
    out_INDEX_BT       LIKE     SY-TABIX.
    When I created the component, Requirement quantity of the component
    was set to initial. I am trying to change that to 1.
    in_resbd_new-MANDT = '200'.
    in_resbd_new-RSNUM = '0000000708'.  " from RESB-RSNUM
    in_resbd_new-RSPOS = '0001'.             " from RESB-RSPOS
    in_resbd_new-MATNR = '000000000000000072'. " RESB-MATNR
    in_resbd_new-WERKS = '0010'.             " from RESB-WERKS
    in_resbd_new-LGORT = '0010'.              "" from RESB-lgort
    in_resbd_new-MENGE = '1'.
    in_rsnum_source = '0000000708'.
    in_rspos_source = '0001'.
    CALL FUNCTION 'CO2M_COMPONENT_CHANGE_WITH_REF'
      EXPORTING
        i_resbd_new          = in_resbd_new
        i_rsnum_source       = in_rsnum_source
        i_rspos_source       = in_rspos_source
        i_rsart_source       = in_rsart_source
    IMPORTING
       E_INDEX_BT           = out_INDEX_BT
    EXCEPTIONS
       ERROR_OCCURED        = 1
       OTHERS               = 2
    The return value in out_index_bt is '1'.
    Thanks for your help.

  • How can I use 3D function in Photoshop CS6 (student package)?

    Please let me know how can I use 3D function in Photoshop CS6 (student package)?
    Thanks,

    Thanks so much for your helpful reply.
    Now I' ve already installed Adobe Creative Suite 6 Production Premium (Student Package), Extended included. But when I open Photoshop CS6, there' s still no 3D function in menu bar.
    Would you please tell me how to activate this function?
    Thanks,

  • How to use group function in insert or update

    Hai All
    How can we use group function in insert or update statement
    I am generating an attendance so i have different set of timing for example
    0800,1200,1230, 1700 and i need to insert into these data into table with min value to intime and max value to
    outtime and othere to inertval time in or out
    Pls tell me with some example
    For example
    For INSERT
    insert into T2 (barcode,empcode,intime,attend_date)
                   values(r2.cardn,r2.enpno,MIN(r2.ptime),r2.pdate);
    For UPDATE
    update dail_att set outtime= MAX(r2.ptime) where empcode=r2.enpno and barcode=r2.cardn and
    attend_date=r2.pdate;
    Here instead of where i need to use having so pls tell how to use
    Thanks & Regards
    Srikkanth.M

    Hai Man
    R2 is not a table name its a record
    Let me explain clearly
    I have to generate daily attendance for lot of employees So i have two table t1 and t2
    T1 consist of three column empno,date,time
    T2 consist of empno,name,date,intime,outtime,intrin,introut
    So now i need to give the T1 Min value Of time to T2 Intime and T1 Max value of Time to T2 Outtime fields so there so many records while i am using
    max(time) it gives the max value of all so i seperated by group function so now i have an error in subquery ie it is an single row subquery so i need to use multiple row subquery how i can use multiple row subquery in update statement
    Thanks In Advance
    Srikkanth.M

  • How to use type, packages, functions, and procedures in another schema ?

    I have two target schema in one OWB project, such as A and B. In a mapping of A, I would like to use some types, packages, functions, and procedures from B. I have tried the method of synonym as suggested, but I could not find the metadata of these when importing ... The only type of synonym I can import is the synonym for table. Is there a bug for synonym?
    If I cannot use synonym for this issue, is there another way to solve the problem?

    Now, in some instances you will absolutely need to create the second module as Carsten describes, however it should also be noted that you can reference objects in things like Expressions even if you have not loaded up the metadata. It is only when you need strong binding that it becomes neccessary to import objects. For everything else, as long as the reference will resolve at compile-time then you are good to go.
    For example, I have a function in one target schema (S1) and a private synonym to it in another(s2). A mapping in the S2 schema has an expression object that uses the synonym to the function in the expression property for a couple of the output attirbutes. The synonym has not been loaded into metadata - indeed OWB has no knowledge of its existance. But it resolves at compile time so the mapping validates and generates successfully.
    Mike

  • Using a packaged function in a query

    Hi ,
    I have read the following statement (correct option for the question)in 1z0-147 questions.
    The question is :: WHEN USING A PACKAGED FUNCTION IN A QUERY which of the following is true ::
    The packaged function cannot execute DML statements against the table that is being queriedI tried the following to understand the above statement
    create or replace package test_pk is
    function fn_test(i number) return number ;
    end;
    create or replace package body test_pk is
    function fn_test (i number) return number is
      j number:=1;
    begin
        insert into a values(200,300);
        commit;
       return j;
       end;
    end test_pk;  Upon executing the above function in the select statement
    select TEST_PK.FN_TEST(1) from dualI got the error saying that Can't perform DML Inside SElect
    Is this example for the above statement is TRUE ????
    Could you please explain me if my example is wrong
    Thanks
    Edited by: Smile on Nov 22, 2012 9:47 AM

    No, it is not true. Any function used in SQL is not allowed to perform a DML operation other than SELECT regardless if it is against the table that is being queried or not. Select is allowed against any table. And function in your example does INSERT which is not allowed. Also, Any function used in SQL is not allowed to perform commit/rollback/savepoint.
    SY.
    Edit: unless function is autonomous transaction.
    Edited by: Solomon Yakobson on Nov 22, 2012 10:22 AM

  • I want single update query without use the function.

    I want to update sells_table selling_code field with max date product_code from product table.
    In product table there is multiple product_code date wise.
    I have been done it with below quey with the use of function but can we do it in only one update query
    without use the function.
    UPDATE sells_table
    SET selling_code = MAXDATEPRODUCT(ctd_vpk_product_code)
    WHERE NVL(update_product_flag,0) = 0 ;
    CREATE OR REPLACE FUNCTION HVL.maxdateproduct (p_product IN VARCHAR2) RETURN NUMBER
    IS
    max_date_product VARCHAR2 (100);
    BEGIN
    BEGIN
    SELECT NVL (TRIM (product_code), 0)
    INTO max_date_product
    FROM (SELECT product_code, xref_end_dt
    FROM product
    WHERE TO_NUMBER (p_product) = pr.item_id
    ORDER BY xref_end_dt DESC)
    WHERE ROWNUM = 1; -- It will return only one row - max date product code
    EXCEPTION
    WHEN OTHERS
    THEN
    RETURN 0;
    END;
    RETURN max_date_product;
    END maxdateproduct;
    Thanks in Advance.

    Hi,
    Something like this.
    update setlls_table st
            set selling_code =(select nvl(trim(product_code)) from 
                                  (select product_code
                                          , rank() over (partition by item_id order by xref_end_dt DESC) rn
                                       from product
                                   ) pr
                                   where rn =1
                                         and pr.item_id = st.ctd_vpk_product_code
                               ) where NVL(update_product_flag,0) = 0 ;As such not tested due to lack of input sample.
    Regards
    Anurag Tibrewal.

Maybe you are looking for

  • Value mapping in the adapter module

    Hi all... There was been alot of writing about value mapping in many different ways. But I have not been able to find help about doing the lookup in the adapter module. Has anyone tried this? Regards Peter

  • IPhone 5 activation without SIM - and absolutely need to set the phone before acquiring SIM

    I bought the phone from the Apple Store a few days ago and I'm leaving for Europe in a few days for 4 months. I do not intend to change my existing "simple" phone service with Telus (Samsung Rugged II) right now before leaving, I intend to buy the se

  • Why Mozilla site doesn't accept OpenID ?

    Why Mozilla Support site does not use OpenID authentication ? Stand-alone authentication is an lithic age of web !

  • Unable to view newly added data to fact table

    Hi, I have load some data into my fact table and dimensions to test my cube and make sure everything is OK, works fine so far. Now I have loaded data for another year 2013 into my fact table, all OK I have re-process the cube , all OK here too. When

  • Po deletion for import

    hi while i delete import purchase order that has been posted in 31.3.2005, it shows the error  'invoice pending for delivery costs ' help me out