ABAP-Logic/Command: Execute An Expression Stored In A Variable

Consider the following code - <b>Is it possible to execute the statement/expression stored in variables expression1, expression2 and expression3?</b> The result should be:
sum = 5 , subname = 'First' & i_output should be sorted by lifnr and ebeln.
*---DATA DECLARATIONS
DATA: sum         TYPE i,
      op1         TYPE i,
      op2         TYPE i,
      name        TYPE string,
      subname     TYPE string,
      offset      TYPE i,
      expression1 TYPE string,
      expression2 TYPE string,
      expression3 TYPE string.
DATA: BEGIN OF i_output OCCURS 0,
      lifnr TYPE lfa1-lifnr,
      ebeln TYPE ekko-ebeln,
      ebelp TYPE ekpo-ebelp,
      END OF i_output.
*---BUILD EXPRESSION 1
op1 = 2.
op2 = 3.
expression1 = 'sum = op1 + op2'.
*---BUILD EXPRESSION 2
name   = ' First Name'.
offset = 5.
expression2 = 'subname = name+1(offset)'.
*---POPULATE ITAB I_OUTPUT
MOVE: '111111' TO i_output-lifnr,
      'PO1'    TO i_output-ebeln,
      '010'    TO i_output-ebelp.
APPEND i_output.
MOVE: '111511' TO i_output-lifnr,
      'PO1'    TO i_output-ebeln,
      '020'    TO i_output-ebelp.
APPEND i_output.
MOVE: '111111' TO i_output-lifnr,
      'PO3'    TO i_output-ebeln,
      '010'    TO i_output-ebelp.
APPEND i_output.
MOVE: '114111' TO i_output-lifnr,
      'PO2'    TO i_output-ebeln,
      '010'    TO i_output-ebelp.
APPEND i_output.
MOVE: '111121' TO i_output-lifnr,
      'PO2'    TO i_output-ebeln,
      '020'    TO i_output-ebelp.
APPEND i_output.
CLEAR i_output.
*---BUILD EXPRESSION 3
expression3 = 'sort i_output by lifnr ebeln'.
Thanks in advance!

> You can achieve this by generating a subroutine pool
> dynamically, passing the code lines (expressions) as
> an internal table. Here is the syntax:
>
> GENERATE SUBROUTINE POOL itab NAME name.
>
> Hope this helps,
> Bhanu
Hey Banu, thanks!
Message was edited by: Sam

Similar Messages

  • Using a xpath expression stored in a variable

    Hi All,
    I have an xpath expression which is stored in the database which I need to use against the request XML. I am able to retrieve this Xpath expression from the database, but not able to use it against the request XML.
    Xpath expression got from the database is: /request/param//name.
    I have tried $body/$XpathVariable, this does not work. I can not hard code this expression during my design time, so the details of the expression has to be fetched at run time.
    Any ideas to get the value would helpful.
    Thanks

    try to assign this value to a temp variable and then in the XqueryExpression try to retrieve it starting with "//"

  • How to execute sql query stored in  a variable

    Hi
    define query = 'select * from abc;'
    then how to execute this defined variable query.
    Thanks,
    Shyam

    EXECUTE IMMEDIATE mmy_sql --(variable
    INTO     mmy_default_bill_type;
    by kumar.

  • Logical command in ABAP.....Urgent

    Hi,
      i am pretty new using ABAP program so i neeed help urgently. i am trying to move a file on the application server from one directory to the other and i was using the open dataset function to do that. but the file i am trying to move is pretty big and because i am using internal table to store, it is causing problems with the space.
      i have consulted the basis guys and they have managed to create a logical file for copying from one directory to the other on the application server. to help you furthter. i am enclosing the mail sent to me.
    I have created a logical command which should copy the file from one location to the other but you need to pass it the source dir and file name and the destination dir and file name.
    The logical command is ZCOPY and uses cmd /c copy
    Copies one or more files to another location.
    COPY [/V] [/N] [/Y | /-Y] [/Z] [/A | /B ] source [/A | /B]
         [+ source [/A | /B] [+ ...]] [destination [/A | /B]]
      source       Specifies the file or files to be copied.
      /A           Indicates an ASCII text file.
      /B           Indicates a binary file.
      destination  Specifies the directory and/or filename for the new file(s).
      /V           Verifies that new files are written correctly.
      /N           Uses short filename, if available, when copying a file with a
                   non-8dot3 name.
      /Y           Suppresses prompting to confirm you want to overwrite an
                   existing destination file.
      /-Y          Causes prompting to confirm you want to overwrite an
                   existing destination file.
      /Z           Copies networked files in restartable mode.
    The switch /Y may be preset in the COPYCMD environment variable.
    This may be overridden with /-Y on the command line.  Default is
    to prompt on overwrites unless COPY command is being executed from
    within a batch script.
    the problem now is i have no idea about how to use the logical command. can any one help me.
    Thank you,
    Ravi.

    If memory is not an issue, then there should be no reason why this should not work.
    report zrich_0001.
    parameters: d1 type localfile default '/usr/sap/TST/SYS/Data1.txt',
                d2 type localfile default '/usr/sap/TST/SYS/Data2.txt'.
    data: itab type table of string with header line.
    start-of-selection.
    * Read old file
      open dataset d1 for input in text mode.
      if sy-subrc = 0.
        do.
          read dataset d1 into itab.
          if sy-subrc <> 0.
            exit.
          endif.
          append itab.
        enddo.
      endif.
      close dataset d1.
    * Write to new file
      open dataset d2 for output in text mode.
      loop at itab.
        transfer itab to d2.
      endloop.
      close dataset d2.
    * Delete the old file
      delete dataset d1.
    Regards,
    Rich Heilman

  • How to improve ABAP logics

    Hi
    How to Improve ABAP logics(Programming) in all areas.
    I need guidence from you all. How to start to improve them.
    Regards,
    Maruti

    Hi,
    Following are the performance standards need to be following in writing ABAP programs:
    1.      Unused/Dead code
    Avoid leaving unused code in the program. Either comment out or delete the unused situation. Use program --> check --> extended program to check for the variables, which are not used statically. 
    2.      Subroutine Usage
    For good modularization, the decision of whether or not to execute a subroutine should be made before the subroutine is called. For example:  
    This is better:
    IF f1 NE 0.
      PERFORM sub1.
    ENDIF. 
    FORM sub1.
    ENDFORM.  
    Than this:
    PERFORM sub1.
    FORM sub1.
      IF f1 NE 0.
      ENDIF.
    ENDFORM. 
    3.      Usage of IF statements
    When coding IF tests, nest the testing conditions so that the outer conditions are those which are most likely to fail. For logical expressions with AND , place the mostly likely false first and for the OR, place the mostly likely true first. 
    Example - nested IF's:
      IF (least likely to be true).
        IF (less likely to be true).
         IF (most likely to be true).
         ENDIF.
        ENDIF.
       ENDIF. 
    Example - IF...ELSEIF...ENDIF :
      IF (most likely to be true).
      ELSEIF (less likely to be true).
      ELSEIF (least likely to be true).
      ENDIF. 
    Example - AND:
       IF (least likely to be true) AND
          (most likely to be true).
       ENDIF.
    Example - OR:
            IF (most likely to be true) OR
          (least likely to be true). 
    4.      CASE vs. nested Ifs
    When testing fields "equal to" something, one can use either the nested IF or the CASE statement. The CASE is better for two reasons. It is easier to read and after about five nested IFs the performance of the CASE is more efficient. 
    5.      MOVE statements
    When records a and b have the exact same structure, it is more efficient to MOVE a TO b than to  MOVE-CORRESPONDING a TO b.
    MOVE BSEG TO *BSEG.
    is better than
    MOVE-CORRESPONDING BSEG TO *BSEG. 
    6.      SELECT and SELECT SINGLE
    When using the SELECT statement, study the key and always provide as much of the left-most part of the key as possible. If the entire key can be qualified, code a SELECT SINGLE not just a SELECT.   If you are only interested in the first row or there is only one row to be returned, using SELECT SINGLE can increase performance by up to three times. 
    7.      Small internal tables vs. complete internal tables
    In general it is better to minimize the number of fields declared in an internal table.  While it may be convenient to declare an internal table using the LIKE command, in most cases, programs will not use all fields in the SAP standard table.
    For example:
    Instead of this:
    data:  t_mara like mara occurs 0 with header line.
    Use this:
    data: begin of t_mara occurs 0,
            matnr like mara-matnr,
            end of t_mara. 
    8.      Row-level processing and SELECT SINGLE
    Similar to the processing of a SELECT-ENDSELECT loop, when calling multiple SELECT-SINGLE commands on a non-buffered table (check Data Dictionary -> Technical Info), you should do the following to improve performance:
    o       Use the SELECT into <itab> to buffer the necessary rows in an internal table, then
    o       sort the rows by the key fields, then
    o       use a READ TABLE WITH KEY ... BINARY SEARCH in place of the SELECT SINGLE command. Note that this only make sense when the table you are buffering is not too large (this decision must be made on a case by case basis).
    9.      READing single records of internal tables
    When reading a single record in an internal table, the READ TABLE WITH KEY is not a direct READ.  This means that if the data is not sorted according to the key, the system must sequentially read the table.   Therefore, you should:
    o       SORT the table
    o       use READ TABLE WITH KEY BINARY SEARCH for better performance. 
    10.  SORTing internal tables
    When SORTing internal tables, specify the fields to SORTed.
    SORT ITAB BY FLD1 FLD2.
    is more efficient than
    SORT ITAB.  
    11.  Number of entries in an internal table
    To find out how many entries are in an internal table use DESCRIBE.
    DESCRIBE TABLE ITAB LINES CNTLNS.
    is more efficient than
    LOOP AT ITAB.
      CNTLNS = CNTLNS + 1.
    ENDLOOP. 
    12.  Performance diagnosis
    To diagnose performance problems, it is recommended to use the SAP transaction SE30, ABAP/4 Runtime Analysis. The utility allows statistical analysis of transactions and programs. 
    13.  Nested SELECTs versus table views
    Since releASE 4.0, OPEN SQL allows both inner and outer table joins.  A nested SELECT loop may be used to accomplish the same concept.  However, the performance of nested SELECT loops is very poor in comparison to a join.  Hence, to improve performance by a factor of 25x and reduce network load, you should either create a view in the data dictionary then use this view to select data, or code the select using a join. 
    14.  If nested SELECTs must be used
    As mentioned previously, performance can be dramatically improved by using views instead of nested SELECTs, however, if this is not possible, then the following example of using an internal table in a nested SELECT can also improve performance by a factor of 5x:
    Use this:
    form select_good.
      data: t_vbak like vbak occurs 0 with header line.
      data: t_vbap like vbap occurs 0 with header line.
      select * from vbak into table t_vbak up to 200 rows.
      select * from vbap
              for all entries in t_vbak
              where vbeln = t_vbak-vbeln.
      endselect.
    endform.
    Instead of this:
    form select_bad.
    select * from vbak up to 200 rows.
      select * from vbap where vbeln = vbak-vbeln.
      endselect.
    endselect.
    endform.
    Although using "SELECT...FOR ALL ENTRIES IN..." is generally very fast, you should be aware of the three pitfalls of using it:
    Firstly, SAP automatically removes any duplicates from the rest of the retrieved records.  Therefore, if you wish to ensure that no qualifying records are discarded, the field list of the inner SELECT must be designed to ensure the retrieved records will contain no duplicates (normally, this would mean including in the list of retrieved fields all of those fields that comprise that table's primary key).
    Secondly,  if you were able to code "SELECT ... FROM <database table> FOR ALL ENTRIES IN TABLE <itab>" and the internal table <itab> is empty, then all rows from <database table> will be retrieved.
    Thirdly, if the internal table supplying the selection criteria (i.e. internal table <itab> in the example "...FOR ALL ENTRIES IN TABLE <itab> ") contains a large number of entries, performance degradation may occur.
    15.  SELECT * versus SELECTing individual fields
    In general, use a SELECT statement specifying a list of fields instead of a SELECT * to reduce network traffic and improve performance.  For tables with only a few fields the improvements may be minor, but many SAP tables contain more than 50 fields when the program needs only a few.  In the latter case, the performace gains can be substantial.  For example:
    Use:
    select vbeln auart vbtyp from table vbak
      into (vbak-vbeln, vbak-auart, vbak-vbtyp)
      where ...
    Instead of using:
    select * from vbak where ... 
    16.  Avoid unnecessary statements
    There are a few cases where one command is better than two.  For example:
    Use:
    append <tab_wa> to <tab>.
    Instead of:
    <tab> = <tab_wa>.
    append <tab> (modify <tab>).
    And also, use:
    if not <tab>[] is initial.
    Instead of:
    describe table <tab> lines <line_counter>.
    if <line_counter> > 0. 
    17.  Copying or appending internal tables
    Use this:
    <tab2>[] = <tab1>[].  (if <tab2> is empty)
    Instead of this:
    loop at <tab1>.
      append <tab1> to <tab2>.
    endloop.
    However, if <tab2> is not empty and should not be overwritten, then use:
    append lines of <tab1> [from index1] [to index2] to <tab2>.

  • CALCULATE_DIFFERENCE  Logic command purpose and usage

    Experts,
    Recently we are facing the issue of send governor hanging issue and it's causing one of the appserver goes down automatically when users send data using input schedules ,to fix this kind of issues one of the experts suggeted us we should use CALCULATE_DIFFERENCE logic command in the default logic, this is not a permanent fix though but if we use this command the send governor will be active until it reaches the certain no.of sends, for example 20 to 30 , after that we need to manually restart the send governer service.
    But as far as I know the purpose of this  CALCULATE_DIFFERENCE is at what time delta value should calculated i.e either execution of the logic or posting of the values.
    In general when do we use this CALCULATE_DIFFERENCE command? is this command mandatory to include in the logic?
    what are the impacts of this command if we include in the logic as currently we are not using command in any of the logic?
    How does CALCULATE_DIFFERENCE  command affect the send governor service ?
    Is there any relation ship between CALCULATE_DIFFERENCE   command and send governor service ?
    Any help will be apprecited greatly! Thanks

    Hi Krishna,
    The CALCULATE_DIFFERENCE option allows you to turn off or on the write back by difference.
    Here is some further info:
    When posting values, BPC needs to write in the database just the difference between what is already stored and the new value. The calculation of the difference takes time. If such calculation is performed directly by the Logic Module at the time of executing the logic, it is possible that the subsequent posting time will be reduced. This is what the logic module does by default. To override the default, the following instruction can be entered in a logic file:
    *CALCULATE_DIFFERENCE = 0  (default is 1)
    When the calculation of the difference is turned off, the write engine is instructed of the change in behavior and takes over the job of calculating (and posting) the difference, so that the final values will be correct. The main reason for using this instruction is that the debug file will show the values exactly as the user expects them to look like in the fact tables.
    Thanks,
    John

  • Logical command...

    Hello,
    Please help me on how to use the logical command.
    Here is the details of my problem.
    In program, a flat file is created and put on the file system. Right after storing the flat file on the file system, an additional logical command needs to be called that starts an FTP script.
    logical command: Z_POSTING_PUT
    The problem is, I don't know how to use the said logical command. Can any body help me please....
    Thanks a lot.
    massive

    it is used to connect the various external system..
    the commond varies according to the system you are using
    it can be seen in SM49 transaction and according you need to chose that
    * connect to the FTP server and send the files.
    * Calculate password length
    u201C password used for connection
      v_slen = strlen( ppwd ).
    * Encrypt password
      call function 'HTTP_SCRAMBLE'
        exporting
          source      = ppwd
          sourcelen   = v_slen
          key         = v_key
        importing
          destination = v_encrypted_pwd.
    * Connect to destination server
      call function 'FTP_CONNECT'
        exporting
          user            = puser
          password        = v_encrypted_pwd
          host            = phost     u201CHost address
          rfc_destination = c_rfc_destination u201Cit is a constant   c_rfc_destination type rfcdes-rfcdest value 'SAPFTPA'.
        importing
          handle          = v_handle
        exceptions
          not_connected.
      if sy-subrc <> 0.
        message e002 with phost sy-subrc.
      endif.
      refresh it_result.
      refresh it_commands.
    Commands will depend on which OS is being used on server side and client side.
    This code is for unix machines
    * change the directory on the destination machine
      concatenate 'cd' prpath into wa_command-line separated by space.
      append wa_command to it_commands.
    * Change the local directory on the sap server
      concatenate 'lcd' plpath into wa_command-line separated by space.
      append wa_command to it_commands.
    * Set Ascii mode
      clear wa_command-line.
      if pbin eq 'X'.
        move 'bin' to wa_command-line.
      else.
        move 'asc' to wa_command-line.
      endif.
      append wa_command to it_commands.
    * files to be transferred
      loop at it_list into wa_list.
    * Put the file from the sap server to the destination machine
        concatenate 'put' wa_list-name wa_list-name
                             into wa_command-line separated by space.
        append wa_command to it_commands.
      endloop.
    * Send FTP commands to server
      call function 'FTP_COMMAND_LIST'
        exporting
          handle        = v_handle
        importing
          command_index = v_command_index
        tables
          data          = it_result
          commands      = it_commands
        exceptions
          command_error = 1
          tcpip_error   = 2.
      v_subrc = sy-subrc.
      if v_subrc ne 0.
    * if there is an error disconnect from the server
    * and display an appropriate message
        perform ftp_disconnect using v_handle c_rfc_destination.
        message e004.
      endif.
    form ftp_disconnect using
      in_handle
      in_rfc_destination.
    * Disconnect from destination server
      call function 'FTP_DISCONNECT'
        exporting
          handle = in_handle.
    * Close RFC connection
      call function 'RFC_CONNECTION_CLOSE'
        exporting
          destination = in_rfc_destination
        exceptions
          others      = 1.
    endform.                    "ftp_disconnect

  • Execute the expression in select statement

    CREATE TABLE TEST1
      OFFICE_PRODUCTS     NUMBER,
      OFFICE_ELECTRONICS  NUMBER
    Insert into TEST1 (OFFICE_PRODUCTS, OFFICE_ELECTRONICS) Values(1, 0);
    COMMIT;
    CREATE TABLE TEST2
      EXPORT_FIELD_NAME         VARCHAR2(100 BYTE),
      EXPORT_COLUMN_EXPRESSION  VARCHAR2(100 BYTE)
    Insert into TEST2
       (EXPORT_FIELD_NAME, EXPORT_COLUMN_EXPRESSION)
    Values ('A1', 'least(OFFICE_PRODUCTS, OFFICE_ELECTRONICS)');
    COMMIT; I want to be execute the expression should run in select statement how to do?
    and tried as like below,it's not working.
    select (select EXPORT_COLUMN_EXPRESSION from test2 where EXPORT_FIELD_NAME='A1') FROM TEST1;

    968892 wrote:
    CREATE TABLE TEST1
    OFFICE_PRODUCTS     NUMBER,
    OFFICE_ELECTRONICS  NUMBER
    Insert into TEST1 (OFFICE_PRODUCTS, OFFICE_ELECTRONICS) Values(1, 0);
    COMMIT;
    CREATE TABLE TEST2
    EXPORT_FIELD_NAME         VARCHAR2(100 BYTE),
    EXPORT_COLUMN_EXPRESSION  VARCHAR2(100 BYTE)
    Insert into TEST2
    (EXPORT_FIELD_NAME, EXPORT_COLUMN_EXPRESSION)
    Values ('A1', 'least(OFFICE_PRODUCTS, OFFICE_ELECTRONICS)');
    COMMIT; I want to be execute the expression should run in select statement how to do?
    and tried as like below,it's not working.
    select (select EXPORT_COLUMN_EXPRESSION from test2 where EXPORT_FIELD_NAME='A1') FROM TEST1;
    Your problems are many...
    a) it's very poor design to be storing expressions or sql statements or any 'executable' style code as data in the database.
    b) what you're storing is a string of characters. Oracle isn't going to miraculously know that that is some expression that has to be evaluated, so why should it decide to treat it as such?
    c) this poor design can lead to security issues especially around SQL injection.
    d) to actually perform what you want would require you to build a dynamic SQL statement and then execute that using EXECUTE IMMEDIATE or DBMS_SQL (or for a 3rd party client, a Ref Cursor), but then there are numerous issues around doing dynamic SQL, aside from SQL injection, in that you are producing code that is not validated at compile time and can thus lead to bugs showing only at run-time and sometime only under certain conditions; the code is harder to maintain; the code can potentially be avoiding the use of bind variables, impacting on resources and performance on the database; the final query can be difficult to know just from reading the code, making further development or debugging a pain in the posterior. Essentially, dynamic SQL is considered very poor design and is 99.9% of the time used for the wrong reasons.
    So, why are you trying to do this? What is the business requirement you are trying to solve?

  • What are the steps necessary to allow a single user login the ability to execute a single stored procedure and nothing else.

    Hello,
    I have a request to create a user login and restrict that user to only be able to execute a single stored procedure.
    Is this possible using only TSQL commands? 
    Am i on the right track here?
    USE MyDatabase
    GO
    CREATE LOGIN [mylogin] DEFAULT_DATABASE = [MyDatabase], CHECK_POLICY = OFF, CHECK_EXPIRATION = OFF
    GO
    CREATE ROLE exec_single_proc_role
    GO
    exec sp_addrolemember 'exec_single_proc_role', 'mylogin'
    GO
    CREATE SCHEMA [restricted] AUTHORIZATION mylogin
    GO
    GRANT EXECUTE ON SCHEMA::restricted TO exec_single_proc_role
    GO

    Thanks for the reply.
    This particular user should need to be able to Alter, Execute, and View the stored procedure as well.
    Here is what i ended up with:  Any improvement are appreciated.  Thanks
    USE MyDatabase
    GO
    --DROP SCHEMA
    IF EXISTS (SELECT * FROM sys.schemas WHERE name = N'restricted')
    DROP SCHEMA [restricted]
    GO
    --DROP SERVER WIDE LOGIN
    IF EXISTS (SELECT * FROM sys.server_principals WHERE name = N'MyUserLogin')
    DROP LOGIN [MyUserLogin]
    GO
    --CREATE SERVER WIDE LOGIN
    CREATE LOGIN [MyUserLogin] WITH PASSWORD = 0x0100F1CF6792E602EF40DFF55983FDE81A9 HASHED, SID = 0xC33B04EECE59DC4C95BE66ED9B15D13D, DEFAULT_DATABASE = [MyDatabase], CHECK_POLICY = OFF, CHECK_EXPIRATION = OFF
    GO
    --DROP ROLE
    DECLARE @RoleName sysname
    set @RoleName = N'exec_single_proc_role'
    IF EXISTS (SELECT * FROM sys.database_principals WHERE name = @RoleName AND type = 'R')
    Begin
    DECLARE @RoleMemberName sysname
    DECLARE Member_Cursor CURSOR FOR
    select [name]
    from sys.database_principals
    where principal_id in (
    select member_principal_id
    from sys.database_role_members
    where role_principal_id in (
    select principal_id
    FROM sys.database_principals where [name] = @RoleName AND type = 'R' ))
    OPEN Member_Cursor;
    FETCH NEXT FROM Member_Cursor
    into @RoleMemberName
    WHILE @@FETCH_STATUS = 0
    BEGIN
    exec sp_droprolemember @rolename=@RoleName, @membername= @RoleMemberName
    FETCH NEXT FROM Member_Cursor
    into @RoleMemberName
    END;
    CLOSE Member_Cursor;
    DEALLOCATE Member_Cursor;
    End
    IF EXISTS (SELECT * FROM sys.database_principals WHERE name = N'exec_single_proc_role' AND type = 'R')
    DROP ROLE [exec_single_proc_role]
    GO
    --DROP USER
    IF EXISTS (SELECT * FROM sys.database_principals WHERE name = N'MyUserLogin')
    DROP USER [MyUserLogin]
    GO
    --CREATE USER AND ASSIGN DEFAULT SCHEMA
    CREATE USER [MyUserLogin] FOR LOGIN [MyUserLogin] WITH DEFAULT_SCHEMA=[restricted]
    GO
    --CREATE SCHEMA
    CREATE SCHEMA [restricted] AUTHORIZATION [MyUserLogin]
    GO
    --CREATE ROLE
    CREATE ROLE [exec_single_proc_role] AUTHORIZATION [MyUserLogin]
    GO
    --ADD ROLE
    EXEC sp_addrolemember 'exec_single_proc_role', [MyUserLogin]
    GO
    GRANT EXECUTE ON SCHEMA::[restricted] TO [exec_single_proc_role]
    GO
    GRANT EXECUTE ON OBJECT::[dbo].[MyStoredProcedure] TO [MyUserLogin]
    GO

  • Executing an oracle stored procedure in xMII 11.5

    Dear all,
          I am facing problem executing an oracle stored procedure using sql query in MII. The SP does not have any input or output parameters & consists of only 2 insert statements. I tried to use Command Mode, FixedQuery & FixedQuery With output mode, but the SP doesn't run.
    This is the error i get when i use :
    execute InsertTest or exec InsertTest -  A SQL Error has occurred on query, ORA-00900: invalid SQL statement
    I read in one of the posts to use 'CALL' instead of 'exec' or 'execute'. Even with this i get error which states:
    A SQL Error has occurred on query, ORA-06576: not a valid function or procedure name
    The syntax i used is CALL InsertTest  -  'InsertTest' is the SP name.
    I also checked Sam's comment in one of the posts about jdbc driver. We are using oracle 9i, so i guess there is no problem with the version of DB.
    The stored procedure is working fine in SQL Developer, How else can i invoke the SP in MII?
    Any help would be greatly appreciated.
    Thanks,
    Sushma.

    Hi all,
    for insert create procedure
    CREATE PROCEDURE MII_TEST_INSUPD
    (ID_IN IN NUMBER,
    NAME_IN IN VARCHAR2)
    IS
    BEGIN
      -- UPDATE ROW
      UPDATE TEST SET
              NAME = NAME_IN
      WHERE
              ID = ID_IN;
      -- NOT RETURN INSERT NEW LINE IN TABLE
      IF SQL%ROWCOUNT = 0 THEN
         INSERT INTO TEST (ID, NAME) VALUES (ID_IN, NAME_IN);                        
      END IF; 
    END;
    In MII you create a query template
    Mode - Command
    FixedQuery - insert the code below
    CALL MII_TEST_INSUPD ([Param.1],'[Param.2]')
    for returns the grid using procedures in oracle you need create a package on oracle server
    CREATE PACKAGE PKG_test IS
      TYPE cursortype is ref cursor;
      PROCEDURE test (mycursor in out cursortype);
    END PKG_test;
    CREATE PACKAGE BODY PKG_test IS
      PROCEDURE test (mycursor in out cursortype) AS
      BEGIN
         open mycursor for select * from test;
      END;
    END PKG_test;
    In MII you create a query template
    Mode -  FixedQueryWithOutput
    FixedQuery - insert the code below
    CALL PKG_TEST.TEST(?)
    Danilo

  • ABAP dump while executing transaction *PC00_M99_CIPE*

    Hi,
    Getting ABAP dump while executing transaction PC00_M99_CIPE  ,hence cannot do payroll posting .
        Information on where terminated
        Termination occurred in the ABAP program "CL_HRFPM_CD_CLOSING_HANDLER===CP" -
         in "GET_FM_POS_CHECK_DATA".
        The main program was "RPCIPE00 ".
        In the source code you have the termination point in line 13
        of the (Include) program "CL_HRFPM_CD_CLOSING_HANDLER===CM00E".
    We have recently upgraded our patch level.
    SAP_OCS(SPAM/SAINT)          SAPKD70026            SAPKD70033
    SAP_ABA                                SAPKA70012            SAPKA70018
    SAP_BASIS                              SAPKB70012           SAPKB70018
    PI_BASIS                                 SAPKIPYJ7B            SAPKIPYJ7I
    SAP_BW                                  SAPKW70012           SAPKW70020
    SAP_AP                                   SAPKNA7008           SAPKNA7015
    SAP_APPL                                SAPKH60009           SAPKH60015
    SAP_HR                                  SAPKE60028            SAPKE60039
    EA-HR                                     SAPKGPHD07          SAPKGPHD26
    Kindly guide me.
    Regards,
    Rachel

    thanks for the quick response.
    By applying  note 1137655,problem got resoved.
    FORM CHECK_CMTNT_UPDATE_CLOSED
    Delta001
    Context Block
    FORM check_cmtnt_update_closed
               USING
                  u_key_date TYPE begda
               CHANGING
                  c_flg_cmtnt_closed.
    Delete Block
      DATA ls_encumb_iv TYPE t77hrfpm_encumb.
      DATA l_gsval TYPE t77s0-gsval.
      DATA ls_fm_pos_key TYPE hrfpm_fm_doc_pos-key_pos.
      DATA lx TYPE REF TO cx_hrfpm.
      STATICS so_closing_handler TYPE REF TO cl_hrfpm_cd_closing_handler.
      CLEAR c_flg_cmtnt_closed .
    *--- old switch from note??? active?
    *--- if so: use the old logic
      cl_hr_t77s0=>read_gsval(
        EXPORTING
          grpid       = 'HRFPM'
          semid       = 'CHKAC'
        IMPORTING
          returnvalue = l_gsval ).
      TRY.
          IF NOT l_gsval IS INITIAL .
            TRY.
                c_flg_cmtnt_closed = 'X'.
    Insert Block
      DATA: ls_encumb_iv TYPE t77hrfpm_encumb.
      STATICS:
          s_gsval TYPE t77s0-gsval,
          s_gsval_read TYPE flag.
      IF s_gsval_read IS INITIAL .
        SELECT SINGLE gsval
           FROM t77s0
          INTO s_gsval
          WHERE grpid = 'HRFPM'
            AND semid = 'CHKAC' .
        s_gsval_read = 'X'.
      ENDIF.
      CLEAR c_flg_cmtnt_closed .
      TRY.
          c_flg_cmtnt_closed = 'X'.
    Delta002
    Context Block
        CATCH
            cx_hrfpm_db_operation
            cx_hrfpm_ad_customizing .
    Delete Block
            ENDTRY.
          ELSE.
    *--- using closed period functionality of PBC
            IF so_closing_handler IS INITIAL .
              CREATE OBJECT so_closing_handler.
            ENDIF.
            IF so_closing_handler->consumption_in_closed_period(
                       i_key_date = u_key_date
                       is_fm_pos_key = ls_fm_pos_key )
                 IS INITIAL.
              c_flg_cmtnt_closed = 'X'.
            ENDIF.
          ENDIF.
        CATCH cx_hrfpm INTO lx.
        lx->raise_sy_message( ).
      ENDTRY.
    ENDFORM.                    "check_cmtnt_update_closed
    Insert Block
      ENDTRY.
    ENDFORM.                    "check_cmtnt_update_closed

  • Pl. provide ABAP logic

    Can any body help me in providing the logic (ABAP logic-infopackage) for extracting data for 6th month considering sydatum.
    Logic should be on Caday.
    Example: If I am executing I/P today i.e. 13.01.2012, I should get the data of 01.06.2011 to 30.06.2011.
    Please help. 
    Thanks in Advance.
    Maddali VSKP

    Hi,
    As I am not core ABAPER, I tried below logic in the development. Logic is working fine. I am getting expected results.
    DATA: l_cur_month(2) type n,
    l_pre_month(2) type n,
    l_cur_year(4) type n,
    z_ppredat type DATS,
    z_ppredat1 type INT1,
    z_ppredat2(8) type n,
    z_ppredat3(2) type n,
    l_pre_year(4) type n.
    data: l_idx like sy-tabix.
      read table l_t_range with key
           fieldname = 'CALDAY'.
      l_idx = sy-tabix.
      l_cur_month = sy-datum+4(2).
      l_cur_year = sy-datum(4).
      l_pre_year = sy-datum(4).
      if l_cur_month >= 7.
        l_pre_month = l_cur_month - 7.
      endif.
      if l_cur_month <= 6.
        l_pre_year = l_cur_year - 1.
        l_pre_month = 12 - ( 7 - l_cur_month ).
      endif.
      break-point.
      concatenate l_pre_year  l_pre_month  '01'
      into z_ppredat.
      CALL FUNCTION '/OSP/GET_DAYS_IN_MONTH'
        EXPORTING
          IV_DATE       = z_ppredat
        IMPORTING
          EV_DAYS       = z_ppredat1 .
          z_ppredat3 = z_ppredat1.
      concatenate l_pre_year  l_pre_month z_ppredat3
      into z_ppredat2.
    concatenate  "l_pre_year  l_pre_month  z_ppredat1" into z_ppredat2
      l_t_range-sign = 'I'.
      l_t_range-option = 'BT'.
      l_t_range-low = z_ppredat.
      l_t_range-high = z_ppredat2.
      modify l_t_range index l_idx.
      p_subrc = 0.
    Request you to help me to validate the logic.
    Thanks in Advance,
    Maddali VSKP

  • How can I use JTA in my business logic and execute process with PAPI?

    HI All,
    How can I use JTA in my business logic and execute process with PAPI?
    When my business logic has exception, the process will rollback.
    or the process has some exceptions, my business logic also will rollback.
    I don't know how to do it.
    Does anyone know how to do it?

    Thank you for your reply, Daniel.
    But I think I did not express my mind clearly.
    There is a scene that I have 2 Application Server.
    My business code is deployed in one Server.
    The BPM is deployed in another Server.
    I want to execute Task use PAPI.(ProcessServiceSession.runActivity)
    In my business code, I will do something before execute Task.
    I need my business logic and Task in same transaction.
    To ensure them "all-or-nothing" .
    As you say, if The transactions are managed by Oracle BPM.
    then can I retrieve OBPM transcaction in my business code?

  • Evaluating an expression stored as varchar

    Hi,
    I've declared a varchar variable and the data stored in that variable is an expression.
    I need to evaluate the expression.
    Is there any option to do so.
    For example
    v_s_expression:='10+5';
    i need to evaluate and get the value into another variable.
    i should get the result 15 in the variable v_n_result.
    any methods?
    Thanks in advance
    Prasanth

    first of all why?....
    execute immediate 'select '||v_s_expression||' from dual' into res;like in
    SQL> declare
      2     v_s_expression varchar2(10);
      3     res number;
      4  begin
      5     v_s_expression:='10+5';
      6     execute immediate 'select '||v_s_expression||' from dual' into res;
      7     dbms_output.put_line(res);
      8  end;
      9  /
    15
    PL/SQL procedure successfully completed.

  • Executing a query stored ina file

    Hello all,
    I need to execute a query stored in a file through pl/sql program
    for eg: i have a query "select sysdate from dual;" stored in a file date.sql. this file is kept under default location oracle/bin directory. this has to be done through a plsql program . How can i achieve this
    Regards,
    Kiran

    we cannot execute a query stored in a file through pl/sql program. Instead use UTL package to read the script (in which seprate the script using ';' as delimiter or new line) and assign it to a variable in pl/sql program, then use the execute immediate command to execute the SQL.
    or store the required script in a procedure, call the SP in plsql program.
    Twinkle

Maybe you are looking for