Delimiting Costumized Table

Hi,
hope someone could help me not getting mad
I have created a table which holds parameters for our agencies to a specified date range (endda, agency is key).
Now I want to have the "delimit" button in SM31, so I could have these szenario:
agency - begda- endda- param
123 - 01.04.2009 - 31.12.9999 - 1
after delimitation:
123 - 01.04.2009 - 01.05.2009 - 1
123 - 01.05.2009 - 31.12.9999 - 2
I made it to get the button "delimit" in the transaction, I where asked for a delimitation date, but then I have only one entry:
123 - 01.05.2009 - 31.12.9999 - 2
But where is the history/delimited entry???

Hi,
Prerequisite is to set End Date as Key field. Begin Date does not need to be Key field.
When you create the table maintenance in SE11 (in 'Maintain Table' screen > Utilities > Table Maintenance Generator). In the 'Generate Table Maintenance Dialog' screen, click on Environment > Generate Time-Dep.
Then in SM30, you should see a Delimit button. Create your entry. Delimit that entry by specifying 01.05.2009 in your example. You should see the record being delimited. If you only see 1 record, try clicking the Expand <-> Collapse button. You should see 2 records.
No need for extra coding to have the delimit function. System will auto generate the required coding once you specify 'Generate Time-Dep'.
Hope it helps!

Similar Messages

  • SPLIT data-record AT delimiter into table-fieldname

    Hi all,
    I have the following SPLIT statement. But unable to split into respective field in an internal table. I'm using the standard delimeter.
    Please help me how to create a file using the delimeter w_delimeter.
    When I create the file with separated by '#' even it is not spliting.
    w_delimeter TYPE c value cl_abap_char_utilities=>horizontal_tab.
    SPLIT data-record AT w_delimeter INTO i_0208-pernr
                                                                         i_0208-begda
                                                                        i_0208-endda
                                                                        i_0208-wtart
                                                                        i_p0208-allpc.
    Thanks,
    Prasad

    Hi Prasad,
    it should work try this bellow piece of code.
    REPORT  ZTEST_A.
    data: Begin of itab occurs 1,
            name(30),
            street(30),
            Apt(3),
            city(30),
            state(2),
            zipcode(5),
          end of itab,
          text1(250),
          text2(250).
    Text1 = 'Jacson  3 xyz dr  B4  abcd  DE  12345'.
    Text2 = 'Edward  3 Caaa dr  B4  pqr  DE  54623'.
    split text1  AT '  '  into   itab-name itab-street  itab-Apt
            itab-city itab-state itab-zipcode.
    append itab.
    split text2  AT '  '  into   itab-name itab-street  itab-Apt
            itab-city itab-state itab-zipcode.
    append itab.
    thanks,
    Venkat

  • Split String at delimiter into table.

    Hi Experts,
    I have a requirement wherein i need to split aaaa#bbbbbbbbbbbb#ccc#dddddddddddddddddddddd#e# into internal table as below:
    Header 1
    Header 2
    1
    aaaa
    2
    bbbbbbbbbbbb
    3
    ccc
    4
    dddddddddddddddddddddd
    5
    e
    how can this be done.
    Thanks & Regards,
    Anil

    Hi Ashok,
    split <string> at '#' into table it.  -Doesn't work
    split <string> at SPACE into table it. - Works
    But same statement with '#' is not working.
    Feeling strange.
    Thanks,
    Anil

  • Pflegedialog(Costumizingtabelle) or Costumizing Table SM30

    hi all
    i have some problem but i can't write it in english, because my english acknowledgment  is too bad. I try to explain in german, may be one or more people here understand german.
    hallo miteinadner
    ich habe eine frage zu pflegedialog(SM30). bei der pflegeview kann man den zeitpunkt bestimmen, wann seine eigene Routine durchlaufen soll. ich habe den Zeitpunkt
    "ZP 01: Vor dem Sichern der Daten in der Datenbank" gewählt.
    Alle daten, die schon in der Tabelle vorhanden oder die neu hinzugekommen sind, werden in der interne Tabelle total gespeichert.
    Hier meine Routine 
    loop at total.
        if <action> = 'N'.
          read table extract with key <vim_xtotal_key>.
          if sy-subrc eq 0.
            lf_index = sy-tabix.
          else.
            clear lf_index.
          endif.
          break-point.
          lf_len = strlen( total ).
          lf_len = lf_len - 1.
          lf_data = total(lf_len).
          split lf_data at '#' into: lf_mandt lf_kschl.
    *(gewünschte Manipulation der Zeile TOTAL durchführen)
          modify total.
          check lf_index = 0.
          extract = total.
          modify extract index lf_index.
        endif.
      endloop.
    das Problem ist, total zeigt mir nicht alle datenfelder an, anstatt 3 nur 2.
    die costumizingtabelle(pflegedialog) von mir besteht aus drei Feldern, das sind MANDT, REIHE, KSCHL.
    Beim debuggen zeigt mir die interne Tabelle "total" nur 295ÞYLP1N, das zweite Field(Reihe) fehlt und aber auch ab und zu mit komischen Zeichen
    wie zum Beispiel 295#ZRL1, 295#ZRL1, 295 ZRL1, 2958ZRL1.
    Was möchte ich aber überhaupt erreichen damit, beim sichern von Pflegedialog sollte die Routine überprüfen, ob die KSCHL Konditionschlüssel überhaupt vorhanden ist.

    Hallo,
    ich kann deutsch.
    Wenn Du in der SM30 bei der Tabellenpflege nur Konditionsschlüssel erlauben möchtest, die es auch gibt, dann ist der beste Weg eine Fremdschlüsselprüfung. Diese musst Du via SE11 in die Tabelle einbauen, die Du mit der SM30 pflegen möchtest. Dann noch den Pflegedialog komplett neu generieren und alles ist gut.
    Die Fremdschlüsselprüfung für das Feld KSCHL geht über die Tabelle T685. Die Felder KVEWE und KAPPL solltest Du in der Prüfung mit Festwerten belegen - die Anwendung für Deine Tabelle kennst Du ja, oder? z.B. KVEWE = A und KAPPL = V für Preisfindung im Vertrieb.
    Den Pflegedialog selbst zu manipulieren ist dann nicht mehr erforderlich.
    Gruß,
    Martin

  • Using a substitution variable to pull data from a table

    Hello,
    I am working with a simple program that asks the user to enter any info that will relate to a table in the db.
    Thus far I have read 1,000 ways to accomplish this, and none of them work.
    PROMPT
    ACCEPT var PROMPT 'Enter var'
    DECLARE
    BEGIN
    SELECT &var
    FROM &table
    WHERE var=tablevar;
    END;

    Thanks for the feedback. Though I understand your logic, it doesn't seem to properly apply here. This is a more detailed explanation of what I've done.
    First, I create the table
    CREATE TABLE starbright
    (planet_num VARCHAR2(3),
    planet VARCHAR2(20));
    INSERT INTO starbright VALUES
    (257, 'Neptune');
    INSERT INTO starbright VALUES
    (367, 'Venus');
    INSERT INTO starbright VALUES
    (586, 'Mars');
    INSERT INTO starbright VALUES
    (725, 'Earth');Now, with that table created, I want to be able to periodically use PL/SQL to call data from the table, such as below
    DECLARE
    p_no := '&planet_num';
    BEGIN
    INSERT p_no
    INTO starbright;
    SELECT planet_num
    INTO p_no
    FROM starbright
    WHERE planet_num := p_no;
    dbms_output.put_line( 'Result: ' || planet );
    END;This is my generic error
    Error report:
    ORA-06550: line 2, column 6:
    PLS-00103: Encountered the symbol "=" when expecting one of the following:
       constant exception <an identifier>
       <a double-quoted delimited-identifier> table LONG_ double ref
       char time timestamp interval date binary national character
       nchar
    The symbol "<an identifier>" was substituted for "=" to continue.
    ORA-06550: line 6, column 8:
    PLS-00103: Encountered the symbol "P_NO" when expecting one of the following:
       into <a SQL statement>
    ORA-06550: line 11, column 18:
    PLS-00103: Encountered the symbol "=" when expecting one of the following:
       . ( * @ % & = - + ; < / > at for in is mod remainder not rem
       <an exponent (**)> <> or != or ~= >= <= <> and or like LIKE2_
       LIKE4_ LIKEC_ between group h
    06550. 00000 -  "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:

  • Problem after creating a costumer view

    hi guys,
    i just created a new view from a costumer table.
    the problem is that when i access the view from sm30, i click on add new entries, and some fields have label and some has only the +, symbol, i dont now why!
    something like this:
    begda___________
    endda___________
    user ____________
    +_______________
    +_______________
    +_______________
    any ideas?
    tks in advance.

    Usually you see + symbol if you use a builtin datatype
    in the table instead of a data element.
    You can resolve the issue in two ways.
    1.You can go to SE54 enter the vie name and select generated objects and click on Change.
    After going inside select Environment--> Modification --> Maintainence screens.
    Select the screen and go to the layout and maintain the descriptions.
    2. Change the table and add data element to the fields for which you have maintained built  in data types.
    Delete the maintainance view and regerate from the transaction SE54. You will see the descriptions.
    Regards
    Sudhir Atluru

  • Function with for loop and parameter table/column names ... syntax help

    I'm trying to create a function that returns the distinct values and counts from a user defined schema/table/column.
    The code below defines an object type [stats_on_column_obj] and creates a single table of this type [stats_on_column_tab].
    The function is supposed to take three input variables: p_schema_name, p_table_name, p_column_name and return a table (above).
    I can hard code a SELECT statement into the () ... but once I try to convert it to parameters & exec immediate I am stuck. The red section is where the issue is (i think).
    Oracle 10g.
    CREATE TYPE stats_on_column_obj IS OBJECT(
      COL_VAL      VARCHAR2(500),
      COL_VAL_CNT  NUMBER    (7)
    CREATE TYPE stats_on_column_tab IS TABLE OF stats_on_column_obj;
    CREATE OR REPLACE FUNCTION get_STATS_ON_COLUMN
       p_schema_name IN varchar2,
       p_table_name IN varchar2,
       p_column_name IN  varchar2
       RETURN STATS_ON_COLUMN_tab
    IS
       l_STATS_ON_COLUMN_tab   STATS_ON_COLUMN_tab := STATS_ON_COLUMN_tab ();
       n                       INTEGER := 0;
       str_select_tbl          varchar2(5000);
    BEGIN
       str_select_tbl := 'SELECT '||p_column_name||' as col_val, count(*) as col_val_cnt FROM '||p_schema_name||'.'||p_table_name||' group by '||p_column_name;
       FOR r IN (str_select_tbl)
       LOOP
          l_STATS_ON_COLUMN_tab.EXTEND;
          n := n + 1;
          l_STATS_ON_COLUMN_tab (n) := STATS_ON_COLUMN_obj (r.col_val, r.col_val_cnt);
       END LOOP ;
       RETURN l_STATS_ON_COLUMN_tab;
    END;
    [Error] PLS-00103 (124: 4): PLS-00103: Encountered the symbol "LOOP" when expecting one of the following:   * & - + / at mod remainder rem .. <an exponent (**)> ||   multiset year DAY_
    [Error] PLS-00103 (126: 9): PLS-00103: Encountered the symbol "=" when expecting one of the following:   constant exception <an identifier>   <a double-quoted delimited-identifier> table LONG_ double ref   char time timestam
    [Error] PLS-00103 (127: 29): PLS-00103: Encountered the symbol "(" when expecting one of the following:   constant exception <an identifier>   <a double-quoted delimited-identifier> table LONG_ double ref   char time timestam
    [Error] PLS-00103 (128: 4): PLS-00103: Encountered the symbol "END" when expecting one of the following:   begin function package pragma procedure subtype type use   <an identifier> <a double-quoted delimited-identifier> form
    SELECT * FROM TABLE (get_STATS_ON_COLUMN('SCHEMAS_X','TABLE_X','COLUMN_X'));

    SCOTT@orcl > CREATE OR REPLACE
      2    FUNCTION get_STATS_ON_COLUMN(
      3                                 p_schema_name IN varchar2,
      4                                 p_table_name IN varchar2,
      5                                 p_column_name IN  varchar2
      6                                )
      7      RETURN STATS_ON_COLUMN_tab
      8      IS
      9          v_STATS_ON_COLUMN_tab STATS_ON_COLUMN_tab := STATS_ON_COLUMN_tab ();
    10          v_n                   INTEGER := 0;
    11          v_str_select_tbl      VARCHAR2(5000);
    12      BEGIN
    13          v_str_select_tbl := 'SELECT stats_on_column_obj(' || p_column_name || ',count(*)) FROM ' ||
    14                              p_schema_name || '.' || p_table_name || ' group by ' || p_column_name;
    15      EXECUTE IMMEDIATE v_str_select_tbl
    16        BULK COLLECT
    17        INTO v_STATS_ON_COLUMN_tab;
    18       RETURN v_STATS_ON_COLUMN_tab;
    19  END;
    20  /
    Function created.
    SCOTT@orcl > select  *
      2            from  table(
      3                        get_STATS_ON_COLUMN(
      4                                            'SCOTT',
      5                                            'EMP',
      6                                            'JOB'
      7                                           )
      8                       )
      9  /
    COL_VAL              COL_VAL_CNT
    CLERK                          4
    SALESMAN                       4
    PRESIDENT                      1
    MANAGER                        3
    ANALYST                        2
    SCOTT@orcl >
    Or better change it to pipelined function.
    SY.

  • WS14500015 is not working for Multilevel approval

    We are trying to Implement the Workflow Template Ws14500015. We have implemented the BADI BBP_WFL_APPROVE_BADI. The workflow works perfectly for 1st level approval. We have checked that the ApproverList Container element gets pouplated with 3 levels of approval when 1 st level approver has not approved it. But as soon as the first level approver approves it this container element is updated with one entry. Please review the code I am attaching. Any help will be highly appreciated.
    METHOD if_ex_bbp_wfl_approv_badi~get_remaing_approvers .
    Interface parameters:
    OBJECT_ID                  TYPE  CRMT_OBJECT_ID                "Import
    OBJECT_TYPE                TYPE  CRMT_SUBOBJECT_CATEGORY       "Import
    GUID                       TYPE  BBP_GUID_32                   "Import
    ACTUAL_APPROVAL_INDEX      TYPE  SWH_NUMC10                    "Import
    APPROVAL_HISTORY_TABLE     TYPE  BBP_WFL_APPROVAL_HISTORY_BADI "Import
    ITEM_APPROVAL_HISTORY_TABLE TYPE BBPT_WFL_ITEM_APPROVAL_BADI   "Import
    APPROVAL_TABLE             TYPE  BBPT_WFL_APPROVAL_TABLE_BADI  "Export
    ITEM_APPROVAL_TABLE        TYPE  BBPT_WFL_ITEM_APPROVAL_BADI   "Export
    NO_FURTHER_APPROVAL_NEEDED TYPE  BOOLEAN                       "Export
    ITEM_APPROVAL_OBJ          TYPE  BBPT_WFL_ITEM_APPROVAL_OBJ  "Changing
    This a default implementation that gives idea about of how line item
    approval should work as well to find the number of approval required
    and to find the approvers.
    Global data---------------------------------------------------------*
    TYPES---------------------------------------------------------------*
      TYPES : ty_item_info    TYPE STANDARD TABLE OF /fir/rmm0bgst001.
                  "to have the necessary values of custom table .
    DATA----------------------------------------------------------------*
      DATA : it_item_info TYPE ty_item_info,"to store the approval values.
             wa_item_info TYPE /fir/rmm0bgst001. " work area for item_info.
      DATA : v_value_per_cctr TYPE bbp_value, " contain value per account
                                              " type in line item of SC
             v_value_per      TYPE bbp_value. " value for v_value_per_cctr
                                              " in USD
      DATA : v_apprv_value    TYPE bbp_value. " amount of first level.
      DATA:  v_call_value1    TYPE bbp_wfl_app_property,"have cost_ctr,
                              "asset_no or order_no value.
             v_co_code        TYPE bbp_wfl_app_property," have company code
             v_plant_value    TYPE bbp_wfl_app_property," have plant value
             v_account_type   TYPE bbp_wfl_app_criterion ," Account type
                              " ie COST_CTR, ASSET_NO or ORDER_NO.
             v_comp_code      TYPE bbp_wfl_app_criterion ,"COMP_CODE
             v_plant          TYPE bbp_wfl_app_criterion ," PLANT
             v_acc_desc       TYPE bbp_step_description ." approval desc.
    WORKAREA------------------------------------------------------------*
      DATA:  wa_header         TYPE bbp_pds_sc_header_d, " header of line
                                                         " item
    tables and work area.
             it_item           TYPE TABLE OF bbp_pds_sc_item_d,
                                            " line item details
             wa_item           TYPE bbp_pds_sc_item_d,
                                            " have one line item detail.
    accounting structures
             it_account        TYPE TABLE OF bbp_pds_acc,
                                            " account details
             wa_account        TYPE bbp_pds_acc .
                                            " one account details.
      DATA: v_req TYPE bbp_wfl_app_criterion. " for creator.
    CONSTANTS-----------------------------------------------------------*
    Business objects
      CONSTANTS:
       c_po            TYPE crmt_subobject_category_db VALUE 'BUS2201',
       c_shop          TYPE crmt_subobject_category_db VALUE 'BUS2121',
       c_contract      TYPE crmt_subobject_category_db VALUE 'BUS2000113'.
    Approval Criteria and properties used
      CONSTANTS:
        c_cost_centre  TYPE bbp_wfl_app_criterion  VALUE 'COST_CTR',
        c_order_no     TYPE bbp_wfl_app_criterion  VALUE 'ORDER_NO',
        c_asset_no     TYPE bbp_wfl_app_criterion  VALUE 'ASSET_NO',
        c_comp_code    TYPE bbp_wfl_app_criterion  VALUE 'COMP_CODE',
        c_plant        TYPE bbp_wfl_app_criterion  VALUE 'PLANT',
        c_cc_desc      TYPE bbp_step_description   VALUE
                                                 'Cost center approval',
        c_io_desc      TYPE bbp_step_description   VALUE
                                                 'Order type approval',
        c_as_desc      TYPE bbp_step_description   VALUE
                                                 'Asset Num approval',
        c_usd          TYPE char3 VALUE 'USD',
        c_m            TYPE char1 VALUE 'M',
        c_x            TYPE char1 VALUE 'X',
        c_apprv_times  TYPE char1 VALUE 3,
        c_1            TYPE char2 VALUE '1',
        c_as           TYPE BBP_ACC_CAT VALUE 'AS',
        c_or           TYPE BBP_ACC_CAT VALUE 'OR',
        c_cc           TYPE BBP_ACC_CAT VALUE 'CC',
        c_us           TYPE char2       VALUE 'US'.
    Case when the object type bus212...---------------------------------*
      CASE object_type.
        WHEN c_shop.
    -----------   shopping cart --------------------------------------- *
          IF NOT approval_table[] IS INITIAL.
            approval_history_table[] = approval_table[].
            item_approval_history_table[] = item_approval_table[].
            REFRESH  : approval_table, item_approval_table,
                    item_approval_obj   .
          ENDIF.
          REFRESH : it_item,it_account.
        Get the details of the shopping cart
          CALL FUNCTION 'BBP_PD_SC_GETDETAIL'
            EXPORTING
              i_object_id = object_id
            IMPORTING
              e_header    = wa_header
            TABLES
              e_item      = it_item
              e_account   = it_account.
        Proceed if it_item is not initial.
          IF NOT it_item IS INITIAL AND NOT it_account IS INITIAL.
    *read the lt_item for plant
            READ TABLE it_item INTO wa_item INDEX 1.
    CHANGE FOR REQEUSTOR.
            CONCATENATE c_us wa_item-created_by INTO v_req.
          now read the table with wa_item-be_plant.
            SELECT *
              FROM /fir/rmm0bgst001
              INTO TABLE it_item_info
              WHERE zplant = wa_item-be_plant.
            SORT it_item BY guid .
            SORT it_account BY p_guid .
            IF actual_approval_index LE c_apprv_times AND
               actual_approval_index GE c_1.
          looping at it_item is done to fetch the approver for every
          line item
              CLEAR: wa_item, wa_account.
              LOOP AT it_item INTO wa_item WHERE del_ind IS INITIAL.
                LOOP AT it_account  INTO wa_account
                  WHERE p_guid = wa_item-guid.
    to calculate the amount before calling the funciton module for
    approval table.value respective to account type
                  v_value_per_cctr =
                  wa_account-distr_perc * wa_item-value / 100.
    read the table respective to account type and for level 1 approval
    such that if the value is less than zvalue then no approval required.
                  CLEAR: wa_item_info.
                  CASE wa_account-acc_cat .
                    WHEN c_or.
                       READ TABLE it_item_info INTO wa_item_info
                        WITH KEY zlevel = c_1   " 1
                       zorder_no = wa_account-order_no
                       zplant    = wa_item-be_plant.
                    WHEN c_as.
                       READ TABLE it_item_info INTO wa_item_info
                        WITH KEY zlevel = c_1   " 1
                       zasset_no = wa_account-asset_no
                       zplant    = wa_item-be_plant.
                    WHEN c_cc.
                       READ TABLE it_item_info INTO wa_item_info
                        WITH KEY zlevel = c_1     " 1
                       zcost_ctr = wa_account-cost_ctr
                       zplant    = wa_item-be_plant.
                  ENDCASE.
                  IF sy-subrc = 0.
                    v_apprv_value = wa_item_info-zvalue.
                  ENDIF.
                now convert the amount to local currency ie usd
                  CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
                    EXPORTING
                    CLIENT                  = SY-MANDT
                      date                    = sy-datum
                      foreign_amount          = v_value_per_cctr
                      foreign_currency        = wa_item-currency
                      local_currency          = c_usd
                     type_of_rate            = c_m
                     read_tcurr              = c_x
                   IMPORTING
                     local_amount            = v_value_per
                   EXCEPTIONS
                     no_rate_found           = 1
                     overflow                = 2
                     no_factors_found        = 3
                     no_spread_found         = 4
                     derived_2_times         = 5
                     OTHERS                  = 6
                  IF v_value_per GE v_apprv_value AND sy-subrc = 0.
    To Find out Account id of what type ie cost center/IO/Asset.
                    IF wa_account-acc_cat eq c_cc.
                      v_call_value1 = wa_account-cost_ctr.
                      v_account_type = c_cost_centre.
                      v_acc_desc  = c_cc_desc. "'Cost center approval'.
                    ELSEIF wa_account-acc_cat eq c_or.
                      v_call_value1 = wa_account-order_no.
                      v_account_type = c_order_no.
                      v_acc_desc  = c_io_desc. "'Internal Order approval'.
                    ELSE.
                   IF NOT wa_account-asset_no IS INITIAL.
                      v_call_value1 = wa_account-asset_no.
                      v_account_type = c_asset_no..
                      v_acc_desc  = c_as_desc. "'Asset Number approval'.
                   ENDIF.
                    ENDIF.
                  Defining the PLANT and plant value.
                    v_plant = c_plant.
                    v_plant_value = wa_item-be_plant.
                  defining the COMPNAY CODE and company value.
                    v_comp_code = c_comp_code.
                    v_co_code   = wa_item-be_co_code.
                  Calling the Custom function to find the approvers.
                    CALL FUNCTION '/FIR/RP2P0BGS_ITEM_APPRV_GET'
                      EXPORTING
                        sc_guid                    = wa_header-guid
                        item_guid                  = wa_item-guid
                        approval_description       = v_acc_desc
                        hide_items_not_responsible = c_x "'X'
    each cost center approver should see only items he is responsible
                        criterion1                 = v_account_type
                        criterion2                 = v_comp_code
                        criterion3                 = v_plant
                        value1                     = v_call_value1
                        value2                     = v_co_code
                        value3                     = v_plant_value
                        approval_index           = actual_approval_index
                      TABLES
                        it_item_info               = it_item_info
                      CHANGING
                        approval_table             = approval_table
                        item_approval_table        = item_approval_table
                        item_approval_obj          = item_approval_obj.
                  ENDIF." end if if value per cost center is more than
                  " level one price.
                  CLEAR wa_account.
                ENDLOOP. " end of loop of account.
                CLEAR:  wa_account,wa_item, wa_item_info.
              ENDLOOP. " end of loop at item
    CHANGE FOR REQUESTOR.----
              DELETE approval_table WHERE approval_agent = v_req.
              IF approval_table IS INITIAL.
                no_further_approval_needed = c_x. " 'X'.
              ENDIF.
            ELSE. " end of if actual_approval_index le 3.
            this BADI-implementation defines 3 steps
              no_further_approval_needed = c_x. "'X'.
            ENDIF.
          ENDIF. " end of if the it_item is not initial.
      ENDCASE. "end of case if bus type is 2121
    ENDMETHOD.
    Function Module
    FUNCTION /fir/rp2p0bgs_item_apprv_get .
    ""Local Interface:
    *"  IMPORTING
    *"     REFERENCE(SC_GUID) TYPE  BBP_GUID OPTIONAL
    *"     REFERENCE(ITEM_GUID) TYPE  BBP_GUID OPTIONAL
    *"     REFERENCE(APPROVAL_DESCRIPTION) TYPE  BBP_STEP_DESCRIPTION
    *"       OPTIONAL
    *"     REFERENCE(HIDE_ITEMS_NOT_RESPONSIBLE) TYPE  BOOLEAN OPTIONAL
    *"     REFERENCE(CRITERION1) TYPE  BBP_WFL_APP_CRITERION OPTIONAL
    *"     REFERENCE(CRITERION2) TYPE  BBP_WFL_APP_CRITERION DEFAULT ''
    *"     REFERENCE(CRITERION3) TYPE  BBP_WFL_APP_CRITERION DEFAULT ''
    *"     REFERENCE(VALUE1) TYPE  BBP_WFL_APP_PROPERTY DEFAULT ''
    *"     REFERENCE(VALUE2) TYPE  BBP_WFL_APP_PROPERTY DEFAULT ''
    *"     REFERENCE(VALUE3) TYPE  BBP_WFL_APP_PROPERTY DEFAULT ''
    *"     REFERENCE(APPROVAL_INDEX) TYPE  SWH_NUMC10 OPTIONAL
    *"  TABLES
    *"      IT_ITEM_INFO STRUCTURE  /FIR/RMM0BGST001
    *"  CHANGING
    *"     REFERENCE(APPROVAL_TABLE) TYPE  BBPT_WFL_APPROVAL_TABLE_BADI
    *"     REFERENCE(ITEM_APPROVAL_TABLE) TYPE  BBPT_WFL_ITEM_APPROVAL_BADI
    *"     REFERENCE(ITEM_APPROVAL_OBJ) TYPE  BBPT_WFL_ITEM_APPROVAL_OBJ
    *"       OPTIONAL
    Local data-----------------------------------------------------------*
      TYPES: ty_option TYPE STANDARD TABLE OF rfc_db_opt,
             ty_fields TYPE STANDARD TABLE OF rfc_db_fld,
             ty_data   TYPE STANDARD TABLE OF tab512.
      DATA:
        wa_approval_table      TYPE bbp_wfl_approval_table_badi,
        wa_item_approval_table TYPE bbps_wfl_item_approval,
        wa_approval_def        TYPE /fir/rmm0bgst001.
      DATA:
        v_app_obj_guid           TYPE bbp_guid_32,
        v_is_new_approval_object TYPE boolean.
      DATA : it_update_tab   TYPE STANDARD TABLE OF /fir/rmm0bgst001,
             it_approval_def TYPE STANDARD TABLE OF /fir/rmm0bgst001,
             wa_update_tab   TYPE /fir/rmm0bgst001.
      DATA : it_actor_tab    TYPE STANDARD TABLE OF swhactor,
             wa_actor_tab    TYPE swhactor,
             it_ac_container TYPE STANDARD TABLE OF swcont,
             wa_ac_container TYPE swcont.
      DATA : it_options TYPE ty_option,
             it_fields  TYPE ty_fields,
             it_data    TYPE ty_data.
      DATA : wa_options TYPE  rfc_db_opt,
             wa_fields  TYPE  rfc_db_fld,
             wa_data    TYPE  tab512.
      DATA : v_apprv_io TYPE aufuser2,
             v_apprv_cc TYPE verak.
      DATA : v_cost_ctr  TYPE  bbp_wfl_app_property ,
             v_order_no  TYPE  bbp_wfl_app_property ,
             v_asset_no  TYPE  bbp_wfl_app_property ,
             v_as_value  TYPE  bbp_wfl_app_property .
      DATA : v_query_table   TYPE dd02l-tabname.
      DATA : v_apprv_count   TYPE char1 VALUE '0'.
    to find the number of lines in the table it_update_tab.
      DATA : v_lines TYPE i.
      DATA : v_app_ind TYPE swh_numc10 VALUE '0'.
      DATA : v_destination   TYPE char10,
             v_system        TYPE sysysid,
             v_mandt         TYPE symandt.
    Constants-----------------------------------------------------------*
      CONSTANTS:
        c_clnt          TYPE char4 VALUE 'CLNT',
        c_agent_is_user TYPE otype VALUE 'US',
        c_x             TYPE char1 VALUE 'X',
        c_cost_centre   TYPE bbp_wfl_app_criterion  VALUE 'COST_CTR',
        c_order_no      TYPE bbp_wfl_app_criterion  VALUE 'ORDER_NO',
        c_asset_no      TYPE bbp_wfl_app_criterion  VALUE 'ASSET_NO',
        c_csks          TYPE char4 VALUE 'CSKS',
        c_anlz          TYPE char4 VALUE 'ANLZ',
        c_coas          TYPE char4 VALUE 'COAS',
        c_verak         TYPE char5 VALUE 'VERAK',
        c_user2         TYPE char5 VALUE 'USER2',
        c_kostl         TYPE char5 VALUE 'KOSTL',
        c_aufnr         TYPE char5 VALUE 'AUFNR',
        c_bukrs         TYPE char5 VALUE 'BUKRS',
        c_anln1         TYPE char5 VALUE 'ANLN1',
        c_c             TYPE char1 VALUE 'C',
        c_and           TYPE char3 VALUE 'AND',
        c_eq            TYPE char1 VALUE '=',
        c_org_object    TYPE swc_elem VALUE 'ORG_OBJECT',
        c_deli          TYPE char1 VALUE '|',
        c_l12           TYPE ddleng VALUE '000012',
        c_off0          TYPE doffset VALUE '000000',
        c_l10           TYPE ddleng VALUE '000010',
        c_l20           TYPE ddleng VALUE '000020',
        c_l04           TYPE ddleng VALUE '000004',
        c_ind01         TYPE swc_index VALUE '000001',
        c_el06          TYPE swc_length VALUE '006',
        c_tab_name      TYPE tabname  VALUE '/fir/rmm0bgst001',
        c_r10           TYPE sysysid VALUE 'R10',
        c_r15           TYPE sysysid VALUE 'R15',
        c_r20           TYPE sysysid VALUE 'R20',
        c_r40           TYPE sysysid VALUE 'R40',
        c_e10           TYPE sysysid VALUE 'E10',
        c_e15           TYPE sysysid VALUE 'E15',
        c_e20           TYPE sysysid VALUE 'E20',
        c_e40           TYPE sysysid VALUE 'E40',
        c_121           TYPE symandt VALUE '121',
        c_300           TYPE symandt VALUE '300',
        c_100           TYPE symandt VALUE '100',
        c_120           TYPE symandt VALUE '120',
    begin of change for generic entry 06-06-2007----
        c_cc            TYPE kostl   VALUE 'CC',
        c_as            TYPE anln1   VALUE 'AS',
        c_or            TYPE aufnr   VALUE 'OR'.
    end of change for generic entry 06-06-2007----
    -perpare the system and client for RFC----
      CASE sy-sysid .
        WHEN c_r10.                                             "' R10'.
          IF sy-mandt = c_120.                                  " '120'.
            CONCATENATE c_e10 c_clnt c_121 INTO v_destination.
          ENDIF.
        WHEN c_r15.                                             " 'R15'.
          IF sy-mandt = c_120.                                  " '120'.
            CONCATENATE c_e15 c_clnt c_300 INTO v_destination.
          ENDIF.
        WHEN c_r20.                                             " 'R20'.
          IF sy-mandt = c_300.                                  " '300'.
            CONCATENATE c_e20 c_clnt c_300 INTO v_destination.
          ENDIF.
        WHEN c_r40.                                             " 'R40'.
          IF sy-mandt = c_100.                                  " '100'.
            CONCATENATE c_e40 c_clnt c_100 INTO v_destination.
          ENDIF.
      ENDCASE.
    Comment on logic ---------------------------------------------------*
    First find the right approval object the item belongs to.
    All items of an approval object are approved together in
    this approval step, and therefore only one workitem is
    created for this items.
      CALL FUNCTION 'BBP_WFL_DIN_APP_OBJ_GET'
        EXPORTING
          sc_guid                 = sc_guid
          criterion1              = criterion1
          value1                  = value1
       IMPORTING
    If 2 items of the same shopping cart have the same
    values for the criterias, this function returns the
    same (!!!) approval object guid
         approval_obj_guid       = v_app_obj_guid
        TABLES
         item_app_obj            = item_approval_obj
    Check what type of account is ie Order no/Internal order/ASSET.
    if the account type is asset_no then responsible cost center is
    found.
      CLEAR: it_update_tab, wa_update_tab.
      CASE criterion1 .
        WHEN c_asset_no.    " 'ASSET_NO'.
          v_asset_no = value1.
          CONCATENATE c_anln1 c_eq value1 " 'ANLN1' '=' value1
            c_and c_bukrs c_eq value2 INTO wa_options-text
            SEPARATED BY space.
          APPEND wa_options TO it_options.
          wa_fields-fieldname = c_anln1.                        " 'ANLN1'.
          wa_fields-length    = c_l12.                          " '000012'.
          wa_fields-offset    = c_off0.                         " '000000'.
          wa_fields-type      = c_c.      " 'C'.
          APPEND wa_fields TO it_fields.
          wa_fields-fieldname = c_kostl.  " 'KOSTL'.
          wa_fields-length    = c_l10.                          " '000010'.
          wa_fields-offset    = c_off0.                         " '000000'.
          wa_fields-type      = c_c.      " 'C'.
          APPEND wa_fields TO it_fields.
          wa_fields-fieldname = c_bukrs.  " 'BUKRS'.
          wa_fields-length    = c_l04.                          " '000004'.
          wa_fields-offset    = c_off0.                         " '000000'.
          wa_fields-type      = c_c.      " 'C'.
          APPEND wa_fields TO it_fields.
          CALL FUNCTION 'RFC_READ_TABLE' DESTINATION v_destination
            EXPORTING
              query_table          = c_anlz  " 'ANLZ'
              delimiter            = c_deli  " '|'
            TABLES
              OPTIONS              = it_options
              fields               = it_fields
              data                 = it_data
            EXCEPTIONS
              table_not_available  = 1
              table_without_data   = 2
              option_not_valid     = 3
              field_not_valid      = 4
              not_authorized       = 5
              data_buffer_exceeded = 6
              OTHERS               = 7.
          IF sy-subrc = 0.
          as it_data table contains only one record
          so no sorting required.
            READ TABLE it_data INTO wa_data INDEX 1.
            v_as_value = wa_data-wa+13(10).
          ENDIF.
        at the end of this if asset is passed its responsible
        cost is obtained and is placed in value1 field.
          CLEAR : wa_data , wa_options , wa_fields .
          REFRESH: it_data , it_options , it_fields .
          v_cost_ctr = v_as_value.
          CONCATENATE c_kostl c_eq v_cost_ctr INTO wa_options-text
          SEPARATED BY space.
          APPEND wa_options TO it_options.
          CLEAR: wa_fields.
          wa_fields-fieldname = c_verak.   " 'VERAK'.
          wa_fields-length    = c_l20.                          " '000020'.
          wa_fields-offset    = c_off0.                         " '000000'.
          wa_fields-type      = c_c.        " 'C'.
          APPEND wa_fields TO it_fields.
          CLEAR: wa_fields.
          wa_fields-fieldname = c_kostl.    " 'KOSTL'.
          wa_fields-length    = c_l10.                          " '000010'.
          wa_fields-offset    = c_off0.                         " '000000'.
          wa_fields-type      = c_c.        " 'C'.
          APPEND wa_fields TO it_fields.
          v_query_table = c_csks. " 'CSKS'.
        set the initial value of v_asset_no by value1.
          CLEAR: v_cost_ctr .
          v_asset_no = value1.
        WHEN c_cost_centre . " 'COST_CTR' or 'ASSET_NO'.
          v_cost_ctr = value1.
          CONCATENATE c_kostl c_eq v_cost_ctr INTO wa_options-text
          SEPARATED BY space.
          APPEND wa_options TO it_options.
          CLEAR: wa_fields.
          wa_fields-fieldname = c_verak.   " 'VERAK'.
          wa_fields-length    = c_l20.                          " '000020'.
          wa_fields-offset    = c_off0.                         " '000000'.
          wa_fields-type      = c_c.        " 'C'.
          APPEND wa_fields TO it_fields.
          CLEAR: wa_fields.
          wa_fields-fieldname = c_kostl.    " 'KOSTL'.
          wa_fields-length    = c_l10.                          " '000010'.
          wa_fields-offset    = c_off0.                         " '000000'.
          wa_fields-type      = c_c.        " 'C'.
          APPEND wa_fields TO it_fields.
          v_query_table = c_csks. " 'CSKS'.
        WHEN c_order_no.    " 'ORDER_NO'.
          v_order_no = value1.
          CONCATENATE c_aufnr c_eq value1 INTO wa_options-text
          SEPARATED BY space.
          APPEND wa_options TO it_options.
          CLEAR: wa_fields.
          wa_fields-fieldname = c_user2.                        " 'USER2'.
          wa_fields-length    = c_l20.                          " '000020'.
          wa_fields-offset    = c_off0.                         " '000000'.
          wa_fields-type      = c_c.      " 'C'.
          APPEND wa_fields TO it_fields.
          CLEAR: wa_fields.
          wa_fields-fieldname = c_aufnr.   " 'AUFNR'.
          wa_fields-length    = c_l12.                          " '000012'.
          wa_fields-offset    = c_off0.                         " '000000'.
          wa_fields-type      = c_c.        " 'C'.
          APPEND wa_fields TO it_fields.
          v_query_table = c_coas. " 'COAS'.
      ENDCASE.
      LOOP AT it_item_info INTO wa_update_tab
        WHERE
              zplant    = value3       AND
              zcost_ctr = v_cost_ctr AND
              zorder_no = v_order_no AND
              zasset_no = v_asset_no.
        APPEND wa_update_tab TO it_update_tab .
      ENDLOOP.
    -begin of change for generic entry 06-06-2007----
    it_update_tab may or may not contain the value as the per the data
    maintainted. if initial then only generic value is maintained and the
    the record need to be appended.
    so the record which need to be appended shud be appended to
    it_update_tab appropiatly with the amt of generic entry.
      CLEAR : wa_update_tab.
      CASE criterion1 .
        WHEN c_asset_no.
          READ TABLE it_item_info INTO wa_update_tab WITH KEY
          zplant = value3
          zasset_no = c_as."'AS'
          IF sy-subrc = 0.
            wa_update_tab-zasset_no = v_asset_no .
            wa_update_tab-zlevel    = 1.
            APPEND wa_update_tab TO it_update_tab.
          ENDIF.
        WHEN c_cost_centre.
          READ TABLE it_item_info INTO wa_update_tab WITH KEY
          zplant = value3
          zcost_ctr = c_cc."'CC'
          IF sy-subrc = 0.
            wa_update_tab-zcost_ctr = v_cost_ctr .
            wa_update_tab-zlevel    = 1.
            APPEND wa_update_tab TO it_update_tab.
          ENDIF.
        WHEN c_order_no.
          READ TABLE it_item_info INTO wa_update_tab WITH KEY
          zplant = value3
          zorder_no = c_or."'OR'
          IF sy-subrc = 0.
            wa_update_tab-zorder_no = v_order_no .
            wa_update_tab-zlevel    = 1.
            APPEND wa_update_tab TO it_update_tab.
          ENDIF.
      ENDCASE.
    end of change for generic entry 06-06-2007----
    RFC to read table for finding the person responsible for the
    cost center / order ie approver.
      CALL FUNCTION 'RFC_READ_TABLE' DESTINATION v_destination
        EXPORTING
          query_table          = v_query_table
          delimiter            = c_deli   "'|'
        TABLES
          OPTIONS              = it_options
          fields               = it_fields
          data                 = it_data
        EXCEPTIONS
          table_not_available  = 1
          table_without_data   = 2
          option_not_valid     = 3
          field_not_valid      = 4
          not_authorized       = 5
          data_buffer_exceeded = 6
          OTHERS               = 7.
      IF sy-subrc = 0.
        CLEAR :wa_approval_def.
        READ TABLE it_data INTO wa_data INDEX 1.
        IF v_query_table = c_csks.    " 'CSKS'.
          v_apprv_cc = wa_data-wa+0(20).
          wa_approval_def-zapprover = v_apprv_cc.
        ELSE.
          v_apprv_io = wa_data-wa+0(20).
          wa_approval_def-zapprover = v_apprv_io.
        ENDIF.
      ENDIF.
      find the number of record in the update table.
      DESCRIBE TABLE it_update_tab LINES v_lines.
      The updation of table runs only for the number of records
      avaiable in the  update table ie v_lines.
      DO v_lines TIMES.        " begin of do to approval index times.
         CLEAR: it_approval_def.
        v_apprv_count = v_apprv_count + 1.
        wa_approval_def-zlevel    = v_apprv_count .
      if the count is more than one then next level of approver
      is found using the rfc call swx_get_manager and stored as per.
        IF v_apprv_count > 1.
          v_apprv_count = v_apprv_count - 1.
          READ TABLE it_update_tab INTO wa_update_tab
               WITH KEY zlevel = v_apprv_count .
          IF sy-subrc = 0 .
    NOW FOR FINDING THE SECOND LEVEL OF APPROVER
    1ST LEVEL OF APPROVER IS FOUND USING ABOVE READ.
    THE FIRST LEVEL OF APPROVER IS USED TO FIND THE SECOND
    LEVEL OF APPROVER USING THE SWX_GET_MANAGER.
    PREPARE THE TABLES FOR SWX_GET_MANAGER
            REFRESH : it_ac_container.
            wa_ac_container-element = c_org_object. " 'ORG_OBJECT'.
            wa_ac_container-tab_index = c_ind01.                " '000001'.
            wa_ac_container-elemlength = c_el06.                " '006'.
            wa_ac_container-type       = c_c.   " 'C'.
            CONCATENATE c_agent_is_user wa_update_tab-zapprover
            INTO wa_ac_container-value .
            APPEND wa_ac_container TO it_ac_container.
            CALL FUNCTION 'SWX_GET_MANAGER' DESTINATION v_destination
              TABLES
                actor_tab    = it_actor_tab
                ac_container = it_ac_container
              EXCEPTIONS
                nobody_found = 1
                OTHERS       = 2.
            IF sy-subrc = 0.
              READ TABLE it_actor_tab INTO wa_actor_tab WITH KEY
                   otype = c_agent_is_user.
              wa_approval_def-zapprover = wa_actor_tab-objid.
            ENDIF.
          ENDIF.
          v_apprv_count = v_apprv_count + 1.
        ENDIF.
      before updating populate the table it_approval_def
      it_update_tab is read based on next v_apprv_count and
      updates the approver and its value.
        READ TABLE it_update_tab INTO wa_update_tab
               WITH KEY zlevel = v_apprv_count .
        IF sy-subrc = 0.
          wa_approval_def-zplant = wa_update_tab-zplant.
          wa_approval_def-zcost_ctr = wa_update_tab-zcost_ctr.
          wa_approval_def-zorder_no = wa_update_tab-zorder_no.
          wa_approval_def-zasset_no = wa_update_tab-zasset_no.
          wa_approval_def-zvalue = wa_update_tab-zvalue.
          APPEND wa_approval_def TO it_approval_def.
    modify the table it_update_tab so that along with the custom
    database table the table in use in this function module ie
    it_update_tab also remain updated.
    benefit is that if the modify to dtab fails. the process works fine.
          MODIFY it_update_tab FROM wa_approval_def
                   TRANSPORTING zapprover
                   WHERE zlevel = wa_approval_def-zlevel AND
                         zvalue = wa_approval_def-zvalue.
      now enqueue the table for modification.
          CALL FUNCTION 'ENQUEUE_E_TABLE'
            EXPORTING
              tabname        = c_tab_name       " '/fir/rmm0bgst001'
            EXCEPTIONS
              foreign_lock   = 1
              system_failure = 2
              OTHERS         = 3.
          now modify the table, for updation of approver.
          IF sy-subrc = 0.
            MODIFY /fir/rmm0bgst001 FROM wa_approval_def.
            if sy-subrc goes 0 commit work is called.
            also the it_update_tab need to be updated.
            IF sy-subrc = 0.
              COMMIT WORK.
            ENDIF.
          ENDIF.
      now dequeue the table after the updation.
          CALL FUNCTION 'DEQUEUE_E_TABLE'
            EXPORTING
              tabname = c_tab_name.     " '/fir/rmm0bgst001'.
        ENDIF.
        once all done clear the work areas.
        CLEAR : wa_approval_def-zlevel , wa_approval_def-zapprover.
      ENDDO.                               " END OF DO STATEMENT.
      SORT it_approval_def BY zlevel ASCENDING.
    as per the logic for the different level of approval.
    for second level of approval only records above 2 should be
    present in the apprval table.
    so for approval index = 2 delete the first record ie for zlevel  = 1.
    and for approval index = 3 delete first two records ie zlevel = 1 and
    zlevel = 2. thus only one approval of zlevel 3 is left in the table
    which is used to update the approval table.
      IF approval_index = 2 .
        DELETE it_approval_def INDEX 1.
      ELSEIF approval_index = 3.
        DELETE it_approval_def INDEX 1.
        DELETE it_approval_def INDEX 1.
      ELSEIF approval_index GT 3.
        REFRESH : it_approval_def .
      ENDIF.
    for above 3 as approval index there shud be no enteries in the table.
    so the table is refreshed and thus the approval table will not
    contain anything.
    approval_index is assigned to a varaiable
      v_app_ind = approval_index.
    v_app_ind is incremented for every next record so that approver is
    assigned to next approval index.
    beign of change 28th may 2007----
    clear : v_app_ind .
    v_app_ind = v_app_ind + 1.
      LOOP AT it_approval_def INTO wa_approval_def.
        wa_approval_table-approval_index       = v_app_ind.
        CONCATENATE c_agent_is_user wa_approval_def-zapprover
        INTO wa_approval_table-approval_agent.
        wa_approval_table-approval_description = approval_description.
        wa_approval_table-approval_object_guid = v_app_obj_guid.
        wa_approval_table-hide_items_not_responsible =
                                hide_items_not_responsible.
        APPEND wa_approval_table TO approval_table.
        v_app_ind = v_app_ind + 1 .
        CLEAR: wa_approval_def.
      ENDLOOP.
      sort the approval table so that approvers come in sequence.
      SORT approval_table BY approval_index.
    ENDIF.
    fill item table (which items belongs to which approval object)
      wa_item_approval_table-approval_object_guid = v_app_obj_guid.
      wa_item_approval_table-approval_item_guid   = item_guid.
      APPEND wa_item_approval_table TO item_approval_table.
      CLEAR :wa_item_approval_table,wa_approval_table,it_update_tab.
    ENDFUNCTION.
    Thanks
    Arghadip
    [email protected]

    Hi,
    You have to debug the entire system behaviour , the approval process using the second approver.
    As first step , please check the security level of the second approver. Restart of workflow is based on the security level of the approver.
    you can find the parameter for security level in the personalization tab of the user .
    there is one function module  which determines wether the workflow should be restarted (or) not.
    i do not remember the exact name of the function module.
    1)start transaction se37
    2)enter bbpwflrestart*.
    3) system will return a number of function modules , of them one function module determines wether to restart the workflow (or) not.
    Please check what does the above function module return for the user and the shopping cart , there will be one parameter 'restart' which triggers the start

  • How to pass a col of pl/sql tab to a parametrized cursor?

    Hi,
    I'm getting this error constantly:
    Error on line 1
    declare
    j number :=1;
    cursor f
    ORA-06550: line 9, column 20:
    PLS-00103: Encountered the symbol "TABLE" when expecting one of the following:
    constant exception <an identifier>
    <a double-quoted delimited-identifier> table LONG_ double ref
    char time timestamp interval date binary national character
    nchar
    Code Snippet:
    declare
    j number :=1;
    cursor firstquery (c_item in varchar2) is
    SELECT SEARCH, NAME, ID FROM tablename
    WHERE name LIKE c_item;
    first_rec_tbl_type is table of firstquery%rowtype index by binary_integer;
    first_rec_tbl first_rec_tbl_type;
    type act_str_tbl_type is table of varchar2(50) index by binary_integer;
    act_put_str_tbl act_str_tbl_type;
    begin
    this is executing fine as i have executed it as a standalone script also
    act_put_str_tbl table has values here.passing these to below:
    ----------------------------------- i guess the problem lies here------------------------
         begin
              dbms_output.put_line('reached second begin');
    For i in act_put_str_tbl.first..act_put_str_tbl.last
         loop
         dbms_output.put_line('inside loop of second begin');
         open firstquery(act_put_str_tbl(i));
              loop
              fetch firstquery into first_rec_tbl(j);
              j:=j+1;
              exit when firstquery%notfound or firstquery is null;
              end loop;
         close firstquery;
         end loop;
    How to use parametrized cursor with PL/SQL table, any help is appreciated in the above snippet.
    Thanks

    Satyaki_De wrote:
    first_rec_tbl_type is table of firstquery%rowtype index by binary_integer;Create this type in side any package like ->
    create or replace package patch_array
    is
    first_rec_tbl_type is table of firstquery%rowtype index by pls_integer;
    end;But, you have to use explicit record type instead of firstquery%rowtype here.
    And, then refer this type inside your parametrized cursor to use that properly, that might solve your current problem - i guess.
    So, you cursor should look something like this ->
    cursor firstquery (c_item in patch_array.first_rec_tbl_type)
    is
    SELECT SEARCH, NAME, ID
    FROM tablename
    WHERE name LIKE c_item; N.B.:Not Tested...
    Regards.
    Satyaki De.
    Edited by: Satyaki_De on Dec 28, 2008 1:32 AM??? No package is needed:
    SQL> declare
      2      j number := 1;
      3      cursor firstquery(
      4                        c_item in varchar2
      5                       )
      6        is
      7          SELECT  ename,
      8                  sal
      9            FROM  emp
    10            WHERE ename LIKE c_item;
    11      type first_rec_tbl_type is table of firstquery%rowtype index by binary_integer;
    12      first_rec_tbl first_rec_tbl_type;
    13      type act_str_tbl_type is table of varchar2(50) index by binary_integer;
    14      act_put_str_tbl act_str_tbl_type;
    15  begin
    16      act_put_str_tbl(1) := 'S%';
    17      act_put_str_tbl(2) := '%L%';
    18      act_put_str_tbl(3) := 'KING';
    19      begin
    20          dbms_output.put_line('reached second begin');
    21          For i in 1..nvl(act_put_str_tbl.count,0) loop
    22            dbms_output.put_line('inside loop of second begin');
    23            dbms_output.put_line('act_put_str_tbl(' || i || ') = ' || act_put_str_tbl(i));
    24            open firstquery(act_put_str_tbl(i));
    25            loop
    26              fetch firstquery into first_rec_tbl(j);
    27              exit when firstquery%notfound;
    28              dbms_output.put_line('first_rec_tbl(' || j || ').ename = ' || first_rec_tbl(j).enam
    e);
    29              dbms_output.put_line('first_rec_tbl(' || j || ').sal = ' || first_rec_tbl(j).sal);
    30              j:=j+1;
    31            end loop;
    32            close firstquery;
    33          end loop;
    34      end;
    35  end;
    36  /
    reached second begin
    inside loop of second begin
    act_put_str_tbl(1) = S%
    first_rec_tbl(1).ename = SMITH
    first_rec_tbl(1).sal = 800
    first_rec_tbl(2).ename = SCOTT
    first_rec_tbl(2).sal = 3000
    inside loop of second begin
    act_put_str_tbl(2) = %L%
    first_rec_tbl(3).ename = ALLEN
    first_rec_tbl(3).sal = 1600
    first_rec_tbl(4).ename = BLAKE
    first_rec_tbl(4).sal = 2850
    first_rec_tbl(5).ename = CLARK
    first_rec_tbl(5).sal = 2450
    first_rec_tbl(6).ename = MILLER
    first_rec_tbl(6).sal = 1300
    inside loop of second begin
    act_put_str_tbl(3) = KING
    first_rec_tbl(7).ename = KING
    first_rec_tbl(7).sal = 5000
    PL/SQL procedure successfully completed.
    SQL> To OP. It is better to use BULK COLLECT:
    SQL> declare
      2      cursor firstquery(
      3                        c_item in varchar2
      4                       )
      5        is
      6          SELECT  ename,
      7                  sal
      8            FROM  emp
      9            WHERE ename LIKE c_item;
    10      type first_rec_tbl_type is table of firstquery%rowtype index by binary_integer;
    11      first_rec_tbl first_rec_tbl_type;
    12      type act_str_tbl_type is table of varchar2(50) index by binary_integer;
    13      act_put_str_tbl act_str_tbl_type;
    14  begin
    15      act_put_str_tbl(1) := 'S%';
    16      act_put_str_tbl(2) := '%L%';
    17      act_put_str_tbl(3) := 'KING';
    18      begin
    19          dbms_output.put_line('reached second begin');
    20          For i in 1..nvl(act_put_str_tbl.count,0) loop
    21            dbms_output.put_line('inside loop of second begin');
    22            dbms_output.put_line('act_put_str_tbl(' || i || ') = ' || act_put_str_tbl(i));
    23            open firstquery(act_put_str_tbl(i));
    24            fetch firstquery bulk collect into first_rec_tbl;
    25            for j in 1..nvl(first_rec_tbl.count,0) loop
    26              dbms_output.put_line('first_rec_tbl(' || j || ').ename = ' || first_rec_tbl(j).enam
    e);
    27              dbms_output.put_line('first_rec_tbl(' || j || ').sal = ' || first_rec_tbl(j).sal);
    28            end loop;
    29            close firstquery;
    30          end loop;
    31      end;
    32  end;
    33  /
    reached second begin
    inside loop of second begin
    act_put_str_tbl(1) = S%
    first_rec_tbl(1).ename = SMITH
    first_rec_tbl(1).sal = 800
    first_rec_tbl(2).ename = SCOTT
    first_rec_tbl(2).sal = 3000
    inside loop of second begin
    act_put_str_tbl(2) = %L%
    first_rec_tbl(1).ename = ALLEN
    first_rec_tbl(1).sal = 1600
    first_rec_tbl(2).ename = BLAKE
    first_rec_tbl(2).sal = 2850
    first_rec_tbl(3).ename = CLARK
    first_rec_tbl(3).sal = 2450
    first_rec_tbl(4).ename = MILLER
    first_rec_tbl(4).sal = 1300
    inside loop of second begin
    act_put_str_tbl(3) = KING
    first_rec_tbl(1).ename = KING
    first_rec_tbl(1).sal = 5000
    PL/SQL procedure successfully completed.
    SQL> SY.
    Edited by: Solomon Yakobson on Dec 27, 2008 12:32 PM

  • PL/SQL procedure to kill inactive session

    Hi all ,
    Please i am trying to write a procedure to kill inactive sessions of the shema 'TESTSCHEMA' .This is my first procedure , am not use to pl/sql but i went through many turtorial but have some errors at compliation .when i try to compile the procedure the errors are as below :
    15:50:28 Start Find Objects [TESTSCHEMA@TESTDB_UNIX(2)] ...
    15:50:28 End Find Objects [TESTSCHEMA@ TESTDB_UNIX(2)]
    15:50:32 Start Compiling 1 object(s) ...
    15:50:32 Executing ALTER PROCEDURE fib_dead_cnx_cleanup COMPILE ...
    15:50:32 [13:2] PL/SQL: ORA-00933: SQL command not properly ended
    15:50:32 [9:3] PL/SQL: SQL Statement ignored
    15:50:32 [18:12] PLS-00103: Encountered the symbol "(" when expecting one of the following:
    15:50:32 constant exception <an identifier>
    15:50:32 <a double-quoted delimited-identifier> table LONG_ double ref
    15:50:32 char time timestamp interval date binary national character
    15:50:32 nchar
    15:50:32 The symbol "<an identifier>" was substituted for "(" to continue.
    15:50:32 [18:21] PLS-00103: Encountered the symbol "LOOP" when expecting one of the following:
    15:50:32 := ; not null default character
    15:50:32 The symbol "; was inserted before "LOOP" to continue.
    15:50:32 [27:8] PLS-00103: Encountered the symbol "ALTER" when expecting one of the following:
    15:50:32 begin case declare exit for goto if loop mod null pragma
    15:50:32 raise return select update while with <an identifier>
    15:50:32 <a double-quoted delimited-identifier> <a bind variable> <<
    15:50:32 close current delete fetch lock insert open rollback
    15:50:32 savepoint set sql execute commit forall merge pipe
    15:50:32 Compilation complete - 5 error(s) found
    15:50:32 End Compiling 1 object(s)
    below is the procedure code :
    CREATE OR REPLACE
    PROCEDURE fib_dead_cnx_cleanup
    AS
    l_serial     CHAR(100);
    l_sid CHAR (100);
    l_sid_serial CHAR(100);
    l_count      NUMBER(10,0);
    CURSOR session_cur IS
              SELECT sid,serial#,sid||','||serial# as sid_serial
         FROM v$session
         WHERE username='EBBFCAT' and schemaname='TESTSCHEMA'
         and status='INACTIVE'
    BEGIN
         BEGIN
         l_count := 0;
                   OPEN session_cur;
                        WHILE ( 1 = 1) LOOP
                             BEGIN
                                  FETCH session_cur INTO l_sid ,l_serial,l_sid_serial ;
                                       EXIT WHEN session_cur%NOTFOUND ;
                                  BEGIN
                                       alter system kill session 'l_sid_serial' ;
                                  END;     
                             END;
                        END;
                   CLOSE session_cur;
         END;
    END FIB_DEAD_CNX_CLEANUP;
    Thanks

    Hi,
    Never write, let alone post, unformatted code.
    When posting any formatted text on this site, type these 6 characters:
    &#123;code&#125;
    (small letters only, inside curly brackets) before and after sections of formatted text, to preserve spacing.
    Among the benefits of formatting: you can indent to show the extent of blocks, such as BEGIN-END.
    Different types of blocks need modifiers after the end, such as "END *IF* " and " END *LOOP* ". If each opening statement (BEGIN, IF, LOOP) is directly above its corresponding END, then it's easy to check if you got the right modifier.
    Here's what you code looks like with some formatting, and a couple of corrections added. Look for -- comments.
    CREATE OR REPLACE
    PROCEDURE fib_dead_cnx_cleanup
    AS
         l_serial     CHAR(100);
         l_sid          CHAR (100);
         l_sid_serial     CHAR(100);
         l_count          NUMBER(10,0);
         CURSOR session_cur IS
                SELECT  sid
                ,       serial#
                ,       sid     || ','
                                      || serial#     as sid_serial
                FROM     v$session
                WHERE      username     = 'EBBFCAT'
                and     schemaname     = 'TESTSCHEMA'
                and     status          = 'INACTIVE';          -- need semicolon here
    BEGIN
         BEGIN                                   -- Why?
              l_count := 0;
              OPEN session_cur;
              WHILE ( 1 = 1)
              LOOP
                    BEGIN                         -- Why?
                         FETCH  session_cur
                         INTO   l_sid
                         ,          l_serial
                         ,          l_sid_serial ;
                               EXIT WHEN session_cur%NOTFOUND ;
                         BEGIN                    -- Why?
                             alter system kill session 'l_sid_serial' ;    -- Not a PL/SQL command
                               END;
                          END;
                END LOOP;                         -- LOOP ends with END LOOP
                CLOSE session_cur;
            END;
    END      FIB_DEAD_CNX_CLEANUP;Take baby steps.
    I've been wrtiing PL/SQL for 20 years, and I would never write that much code at once. If you're a beginner, all the more reason to start small. Write as little as possible, test, debug and test again (if necessary). When you have someting working, add 2 or 3 more lines and test again.
    It looks like you have three BEGIN statements that don't serve any purpose. You should get rid of them (and their corresponding END statements, of course).
    One error I did not fix: ALTER SYSTEM is not a PL/SQL statement. It's a SQL statement. You can run a SQL statement inside PL/SQL by using dynamic SQL, where you construct a string containing the SQL statement, and then use dbms_sql or EXECUTE IMMEDIATE to run it.
    Edited by: Frank Kulash on Aug 18, 2009 12:37 PM

  • How to read the content of a blob col along with other cols as pipe delimit

    Hi,
    I would like to read the blob content along with the other columns . Assume table TAB1 has columns Response_log, Empcode and Ename. Here Response_log col is a blob data type, and the content of the blob is an xml file.Now i would like to read the content of the xml file of response_log column along with Empcode and Ename as pipe delimited . or else the best option would be to write to a text file with name extract.txt with the data being pipe delimited .
    create  table tab1(
    response_log blob,
    empcode  number,
    ename  varchar2(50 byte)
    )Sample code goes something like the one below .
    select xmltype( response_log, nls_charset_id( 'char_cs' ) ).getclobval() || '|' || empcode || '|' || ename
    from tab1 Can I have any other alternate way for this.
    Please advice

    Just Now one example is given in HOW TO WRITE ,SAVE A FILE IN BLOB COLUMN

  • Whats this error while creating a trigger

    HI ,
    I was creating a trigger and getting the following Error . What is this
    1 CREATE OR REPLACE TRIGGER TRG_AUDIT_LOGON AFTER
    2 LOGON ON DATABASE
    3 Declare
    4 v_sid v$session.sid%type ;
    5 v_serial v$session.serial# %type;
    6 v_username v$session.username%type;
    7 v_osuserid v$session.osuser%type;
    8 v_machinename v$session.machine%type;
    9 v_PROGRAM v$session.program%type;
    10 v_TERMINAL v$session.terminal%type;
    11 v_hostname v$instance.host_name%type;
    12 v_instance_name v$instance.instance_name%type;
    13 v_application_id v$database.dbid%type;
    14 v_logon_time date;
    15 v_Audit_tab_check varchar2(30);
    16 v_system_users_tab_check varchar2(30);
    17 v_sql_Audit_upload varchar2(1000) := 'INSERT INTO dbaoper.T_AUDIT (HOST_NAME, APPLICATION_ID, INSTANCE_NAME, SID, SERIAL#, USERNAME, OSUSERID, MACHINENAME, PROGRAM, TERMINAL, LOGON_TIME) VALUES (:v_hostname,:v_application_id,:v_instance_name, :v_sid, :v_serial, :v_username ,:v_osuserid,: v_machinename, :v_program,:v_TERMINAL,:v_logon_time ) ';
    18 type c_audit_cur_typ is ref cursor;
    19 C_Audit c_audit_cur_typ ;
    20 V_system_users_tab := 'T_SYSTEM_USERS';
    21 No_Audit_records Exception;
    22 Begin
    23 Select table_name into v_Audit_tab_check from dba_tables where owner='DBAOPER' and table_name='T_AUDIT';
    24 Select table_name into v_system_users_tab_check from dba_tables where owner='DBAOPER' and table_name='T_SYSTEM_USERS';
    25 Open c_Audit for ' SELECT sid, serial#, username, osuser, machine, program, terminal FROM v$session WHERE audsid = userenv (''''sessionid'''') and program not like ''''oracle@%J0%'''' and username not in (select * from dbaoper.' || V_system_users_tab||' ) and type!=''''BACKGROUND'''' ' ;
    26 Fetch c_Audit into v_sid, v_serial, v_username, v_osuserid, v_machinename,v_program,v_TERMINAL ;
    27 If c_Audit%Notfound then
    28 Raise No_Audit_records ;
    29 Else
    30 Select host_name, instance_name into v_hostname, v_instance_name from v$instance;
    31 select dbid into v_application_id from v$database;
    32 select sysdate into v_logon_time from dual;
    33 execute immediate v_sql_Audit_upload using v_hostname,v_application_id,v_instance_name,v_sid,v_serial,v_username,v_osuserid,v_machinename,v_program,v_TERMINAL,v_logon_time;
    34 end if;
    35 close C_Audit;
    36 exception
    37 when no_data_found then
    38 dbms_system.ksdwrt(2, ' ORA-20001 Audit tables T_AUDIT or T_SYSTEM_USERS not found Audit information is not being captured'
    39 );
    40 When No_Audit_records then
    41 dbms_output.put_line ('No Audit records to insert ');
    42* end;
    SQL> /
    Warning: Trigger created with compilation errors.
    SQL> sho err
    Errors for TRIGGER TRG_AUDIT_LOGON:
    LINE/COL ERROR
    18/20 PLS-00103: Encountered the symbol "=" when expecting one of the
    following:
    constant exception <an identifier>
    <a double-quoted delimited-identifier> table LONG_ double ref
    char time timestamp interval date binary national character
    nchar
    The symbol "<an identifier>" was substituted for "=" to
    continue.
    Thanks
    Pramod

    Hi
    I am sorry...i am getting the following error once trigger is created and one of the user is trying to connect....what might be the reason ?
    Enter user-name: test
    Enter password:
    ERROR:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-00907: missing right parenthesis
    ORA-06512: at line 23
    Thanks
    Prmaod

  • PLS-00103: Received error on creation of procedure

    Dear All,
    I have created view when this procedure i got error.
    1. PLS-00103: Encountered the symbol "=" when expecting one of the following:
    constant exception <an identifier>
    <a double-quoted delimited-identifier> table LONG_ double ref
    char time timestam
    2. PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
    ( - + case mod new not null others <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> avg
    3. PLS-00103: Encountered the symbol ")" when expecting one of the following:
    . ( * @ % & - + ; / at for mod remainder rem
    <an exponent (**)> and or group having intersect minus order
    start uni
    create or replace PROCEDURE PO_ITEM_BRANCH_PROC (ITEM_ID1 IN NUMBER, BRANCH_CODE1 IN VARCHAR2 , RESULT1 OUT NUMBER,ERR_MSG OUT NVARCHAR2 )
    as
    RESULT1 := 0 ;
    BEGIN
    SELECT
    count(a.asset_number) into RESULT1
    FROM
    FA_ADDITIONS A
    ,FA_CATEGORIES_VL C
    ,FA_BOOKS B
    ,FA_LOCATIONS FL
    ,FA_DISTRIBUTION_HISTORY DH
    ,FA_TRANSACTION_HEADERS TH
    WHERE
    A.ASSET_CATEGORY_ID=C.CATEGORY_ID
    AND A.ASSET_ID=B.ASSET_ID
    AND A.ASSET_ID=TH.ASSET_ID
    AND TH.TRANSACTION_TYPE_CODE='ADDITION'
    AND B.TRANSACTION_HEADER_ID_IN=TH.TRANSACTION_HEADER_ID
    AND B.ASSET_ID=TH.ASSET_ID
    AND A.ASSET_ID=DH.ASSET_ID
    AND DH.LOCATION_ID=FL.LOCATION_ID
    AND TH.TRANSACTION_TYPE_CODE='ADDITION'
    --AND  FL.SEGMENT4 = 'Shalimar Campus Lahore'
    AND TH.TRANSACTION_TYPE_CODE <> 'FULL RETIREMENT'
    -- AND FL.SEGMENT4 = (SELECT flex_value FROM fnd_flex_values WHERE ATTRIBUTE1 = '04010303')
    AND A.ASSET_CATEGORY_ID IN (
    SELECT
    msi.asset_category_id
    FROM
    po_requisition_lines_all b,
    mtl_system_items_b msi
    WHERE
    b.ITEM_ID = msi.INVENTORY_ITEM_ID
    AND msi.inventory_item_id(+) = B.item_id
    AND msi.organization_id(+) = B.destination_organization_id
    AND b.item_id = ITEM_ID
    AND FL.SEGMENT4 = (
    SELECT
    (SELECT FLEX_VALUE FROM fnd_flex_values WHERE ATTRIBUTE1 = B.ATTRIBUTE2) BRANCH
    FROM
    po_requisition_lines_all b,
    mtl_system_items_b msi
    WHERE
    b.ITEM_ID = msi.INVENTORY_ITEM_ID
    AND msi.inventory_item_id(+) = B.item_id
    AND msi.organization_id(+) = B.destination_organization_id
    AND b.ATTRIBUTE2 = BRANCH_CODE
    exception when others then
    mesg := 'select failed in BILLTER' ;
    err_msg :=mesg;
    END ;

    create or replace PROCEDURE PO_ITEM_BRANCH_PROC(ITEM_ID1 IN NUMBER,
                                                    BRANCH_CODE1 IN VARCHAR2,
                                                    RESULT1 OUT NUMBER,
                                                    ERR_MSG OUT NVARCHAR2
                                                   ) as
    BEGIN
      RESULT1 := 0 ;
      SELECT count(a.asset_number)
        into RESULT1
        FROM FA_ADDITIONS A,
             FA_CATEGORIES_VL C,
             FA_BOOKS B,
             FA_LOCATIONS FL,
             FA_DISTRIBUTION_HISTORY DH,
             FA_TRANSACTION_HEADERS TH
       WHERE A.ASSET_CATEGORY_ID = C.CATEGORY_ID
         AND A.ASSET_ID = B.ASSET_ID
         AND A.ASSET_ID = TH.ASSET_ID
         AND TH.TRANSACTION_TYPE_CODE = 'ADDITION'
         AND B.TRANSACTION_HEADER_ID_IN = TH.TRANSACTION_HEADER_ID
         AND B.ASSET_ID = TH.ASSET_ID
         AND A.ASSET_ID = DH.ASSET_ID
         AND DH.LOCATION_ID = FL.LOCATION_ID
         AND TH.TRANSACTION_TYPE_CODE = 'ADDITION'
    --   AND FL.SEGMENT4 = 'Shalimar Campus Lahore'
         AND TH.TRANSACTION_TYPE_CODE != 'FULL RETIREMENT'
    --   AND FL.SEGMENT4 = (SELECT flex_value FROM fnd_flex_values WHERE ATTRIBUTE1 = '04010303')
         AND A.ASSET_CATEGORY_ID IN (SELECT msi.asset_category_id
                                       FROM po_requisition_lines_all b,
                                            mtl_system_items_b msi
                                      WHERE b.ITEM_ID = msi.INVENTORY_ITEM_ID
                                        AND msi.inventory_item_id(+) = B.item_id
                                        AND msi.organization_id(+) = B.destination_organization_id
                                        AND b.item_id = ITEM_ID
         AND FL.SEGMENT4 = (SELECT (SELECT FLEX_VALUE
                                      FROM fnd_flex_values
                                     WHERE ATTRIBUTE1 = B.ATTRIBUTE2
                                   ) BRANCH
                              FROM po_requisition_lines_all b,
                                   mtl_system_items_b msi
                             WHERE b.ITEM_ID = msi.INVENTORY_ITEM_ID
                               AND msi.inventory_item_id(+) = B.item_id
                               AND msi.organization_id(+) = B.destination_organization_id
                               AND b.ATTRIBUTE2 = BRANCH_CODE
    exception
      when others
      then err_msg := 'select failed in BILLTER';
    END ;Regards
    Etbin
    Edited by: Etbin on 21.4.2012 11:26
    sorry
    Edited by: Etbin on 21.4.2012 12:02
    reposted

  • Dynamic FROM clause

    Hi, I am needing to use a dynamic "<font color="blue">FROM (insert table name here)</font>" as well. From reading several posts, it seems like I need to do this using dynamic SQL. I can pass the name of the table into the stored procedure, but I am getting confused as to how to turn the SELECT statement part of this function into dynamic SQL since the SELECT statement is already inside a cursor itself. Thank you -
    <br><br><b>FUNCTION getDni4wImmStartInterface(p_board_group_id NUMBER)   RETURN interface_cnt_tbl PIPELINED
    IS
    --fill the cursor with available interfaces for the board_group_id passed in
    CURSOR gc_intf IS
       SELECT interface
       FROM TABLE(ipfinterfaces.getinterfaceslist(p_board_group_id))
       WHERE interface NOT IN (SELECT interface FROM physical_interface WHERE board_group_id = p_board_group_id);
    l_count NUMBER(10);
    l_max   NUMBER(10);
    BEGIN
    --fetch the max # of interfaces allowed for the board group type
    --passed in
    SELECT bgt.max_interfaces
    INTO l_max
    FROM board_group_type bgt, board_groups bg
    WHERE bg.board_group_id = p_board_group_id
    AND bg.board_group_type_id = bgt.board_group_type_id;
    --for interface in the cursor, check to see if there is an interface
    --with the same C-S-G in the database that is 1 greater than the one in the cursor
    FOR gc_rec IN gc_intf LOOP
    SELECT count(*)
    INTO l_count
    "<font color="blue">FROM INT_DNI_4W_IMM c</font>
      , VIRTUAL_INTERFACE vi
      , BOARD_GROUPS bg
      , PHYSICAL_INTERFACE  pi
      , BOARD b
      WHERE b.BOARD_ID = bg.BOARD_ID
      AND b.SYSTEM_ID = vi.SYSTEM_ID
      AND vi.PHYSICAL_INTERFACE_ID = pi.PHYSICAL_INTERFACE_ID
      AND pi.SYSTEM_ID =  vi. SYSTEM_ID
      AND pi.BOARD_GROUP_ID = bg.BOARD_GROUP_ID
      AND vi.SYSTEM_ID =  bg.SYSTEM_ID
      AND c.VIRTUAL_INTERFACE_ID = vi.VIRTUAL_INTERFACE_ID
      AND bg.BOARD_GROUP_ID = p_board_group_id
      AND pi.Interface = TO_NUMBER(gc_rec.Interface) + 1;
    --if there is not interface 1 greater than the one passed in, and if
    --the interface passed in is not the max interface, pipe the row back.
         IF l_count = 0 AND (TO_NUMBER(gc_rec.interface) != l_max)
           THEN PIPE ROW (interface_cnt_obj (TO_NUMBER(gc_rec.interface), TO_NUMBER(l_count)));
         END IF;
    END LOOP;
    RETURN;
    END getDni4wImmStartInterface;
    </b>

    Hi Vikas,
    Sorry, I didn't think I could assign p_table_name to l_table_name like that. When I try to implement your suggestion, I get these errors (Is my DECLARE out of place?):<br><br>
    Line # = 469 Column # = 1 Error Text = PLS-00103: Encountered the symbol "DECLARE" when expecting one of the following: begin function package pragma procedure subtype type use <an identifier> <a double-quoted delimited-identifier> form current cursor The symbol "begin" was substituted for "DECLARE" to continue. <br><br>
    Line # = 474 Column # = 14 Error Text = PLS-00103: Encountered the symbol "=" when expecting one of the following: constant exception <an identifier> <a double-quoted delimited-identifier> table LONG_ double ref char time timestamp interval date binary national character nchar The symbol "<an identifier>" was substituted for "=" to continue.
    <br><br>
    Line # = 491 Column # = 51 Error Text = PLS-00103: Encountered the symbol "C" when expecting one of the following: * & = - + ; < / > at in is mod remainder not rem <an exponent (**)> <> or != or ~= >= <= <> and or like LIKE2_ LIKE4_ LIKEC_ between || multiset member SUBMULTISET_
    <br><br>
    Line # = 496 Column # = 3 Error Text = PLS-00103: Encountered the symbol "WHERE" when expecting one of the following: , from into bulk
    <br><br>
    Line # = 503 Column # = 27 Error Text = PLS-00049: bad bind variable 'B1'
    <br><br>
    Line # = 506 Column # = 3 Error Text = PLS-00103: Encountered the symbol "EXECUTE"
    <br><br>
    Here's my current code:<br><br><b>FUNCTION getDni4wImmStartInterface(p_board_group_id NUMBER, p_table_name VARCHAR2)   RETURN interface_cnt_tbl PIPELINED
    IS
    --fill the cursor with available interfaces for the board_group_id passed in
    CURSOR gc_intf IS
       SELECT interface
       FROM TABLE(ipfinterfaces.getinterfaceslist(p_board_group_id))
       WHERE interface NOT IN (SELECT interface FROM physical_interface WHERE board_group_id = p_board_group_id);
    DECLARE
    l_count NUMBER(10);
    l_max   NUMBER(10);
    l_sql   LONG;
    l_count NUMBER;
    l_table_name := p_table_name;
    BEGIN
    --fetch the max # of interfaces allowed for the board group type
    --passed in
    SELECT bgt.max_interfaces
    INTO l_max
    FROM board_group_type bgt, board_groups bg
    WHERE bg.board_group_id = p_board_group_id
    AND bg.board_group_type_id = bgt.board_group_type_id;
    --for interface in the cursor, check to see if there is an interface
    --with the same C-S-G in the database that is 1 greater than the one in the cursor
    FOR gc_rec IN gc_intf LOOP
    l_sql := 'SELECT count(*) FROM ||l_table_name||' c
      , VIRTUAL_INTERFACE vi
      , BOARD_GROUPS bg
      , PHYSICAL_INTERFACE  pi
      , BOARD b
      WHERE b.BOARD_ID = bg.BOARD_ID
      AND b.SYSTEM_ID = vi.SYSTEM_ID
      AND vi.PHYSICAL_INTERFACE_ID = pi.PHYSICAL_INTERFACE_ID
      AND pi.SYSTEM_ID =  vi. SYSTEM_ID
      AND pi.BOARD_GROUP_ID = bg.BOARD_GROUP_ID
      AND vi.SYSTEM_ID =  bg.SYSTEM_ID
      AND c.VIRTUAL_INTERFACE_ID = vi.VIRTUAL_INTERFACE_ID
      AND bg.BOARD_GROUP_ID = :b1
      AND pi.Interface = TO_NUMBER(gc_rec.Interface) + 1;
      EXECUTE IMMEDIATE l_sql INTO l_count USING p_board_group_id;
    <br><br></b>Message was edited by:
    The Fabulous LB

  • Securing file download links

    As per the File upload/download How-to at http://download-west.oracle.com/docs/cd/B19306_01/appdev.102/b14377/up_dn_files.htm#sthref153
    downloading a file involves writing a stored procedure and invoking it directly using the DAD and mod_plsql. For example, /pls/htmldb/owner.procedure?p_file_id=1234
    This link bypasses the Apex show engine so even if I have all the security in the world in Apex using authentication schemes, authorization schemes, etc, a authenticated user in Apex can just right click on the Download link, shoot it off to someone else who can download the file without even logging in to my application!
    How can these "download links" be secured so that only authenticated users can access them only from an Apex session?
    Thanks

    Thank you Vikas.
    The reason I ask is I get a compilation error in my procedure.
    I am no PL/SQL expert so I am sure my syntax or logic is wrong.
    I am using APEX version 2.0
    Error(7,19): PLS-00103: Encountered the symbol "." when expecting one of the following: constant exception <an identifier> <a double-quoted delimited-identifier> table LONG_ double ref char time timestamp interval date binary national character nchar The symbol "<an identifier>" was substituted for "." to continue.
    CREATE OR REPLACE PROCEDURE download_my_file(p_file in number) AS
            v_mime  VARCHAR2(48);
            v_length  NUMBER;
            v_file_name VARCHAR2(2000);
            Lob_loc  BLOB;
            APEX_APPLICATION.G_FLOW_ID := 100;
    BEGIN
    --testing security
    IF NOT wwv_flow_custom_auth_std.is_session_valid then
        -- display this message or a custom message.
    htp.p('Unauthorized access - file will not be retrieved.');
        -- You can do whatever else you need to here to log the
        --     unauthorized access attempt, get the requestor's
        --     IP address, send email, etc.
        RETURN;
    END IF;
            SELECT MIME_TYPE, BLOB_CONTENT, name,DBMS_LOB.GETLENGTH(blob_content)
                    INTO v_mime,lob_loc,v_file_name,v_length
                    FROM file_subjects
                    WHERE id = p_file;
                  -- set up HTTP header
                        -- use an NVL around the mime type and
                        -- if it is a null set it to application/octect
                        -- application/octect may launch a download window from windows
                        owa_util.mime_header( nvl(v_mime,'application/octet'), FALSE );
                    -- set the size so the browser knows how much to download
                    htp.p('Content-length: ' || v_length);
                    -- the filename will be used by the browser if the users does a save as
                    htp.p('Content-Disposition:  attachment; filename="'||replace(replace(substr(v_file_name,instr(v_file_name,'/')+1),chr(10),null),chr(13),null)|| '"');
                    -- close the headers           
                    owa_util.http_header_close;
                    -- download the BLOB
                    wpg_docload.download_file( Lob_loc );
    end download_my_file;
    /Thanks
    VC

Maybe you are looking for