SQLBindParameters Output RowType

I'm programming in MSVC++ with VS6.0 (of course)
I have to call a Stored Procedure in Oracle and I have a problem
This is the SP declaration:
PROCEDURE SDB_TIC_HIS (
pi_ticket_id IN NUMBER DEFAULT 1,
po_ticket_id OUT NUMBER,
po_ticket_type OUT NUMBER,
po_remain_trips_nr OUT NUMBER,
po_rec_cnt OUT NUMBER,
po_history_records OUT SDB.SDB_TIC_HIS_TYPE_TAB%ROWTYPE
I prepare the call like this:
SQLPrepare(myHstmtHis, (SQLCHAR*) "{call sdb_tic.sdb_tic_his(?,?,?,?,?,?)}", SQL_NTS);
Then I bind the paraters like this:
SQLBindParameter(myHstmtHis,     1,     SQL_PARAM_INPUT, SQL_C_CHAR,          SQL_NUMERIC,                    0,0, (void*)tic_id, 100,NULL);
SQLBindParameter(myHstmtHis,     2,     SQL_PARAM_OUTPUT, SQL_C_CHAR,          SQL_NUMERIC,                    0,0, (void*)ret_tic_id, 100,NULL);
and so on....
How can I bind the last output parameter that is a RECORD defined in ORACLE??
Please tell me if other infos are needed or if it is not possible to pass a RECORD type through ODBC
Thank You
Edited by: Rankor on Aug 26, 2008 2:17 PM

%ROWTYPE is a PLSQL type, not exposed to OCI. So, you cant pass it via any client side apps (odbc, oledb, odp.net, jdbc, etc).
Hope it helps,
Greg

Similar Messages

  • ORABPEL-11811 on creation of DB adapter returning record

    Hi,
    I have been getting some really frustrating results from using the database adapter with some PL/SQL function calls which have input or output %ROWTYPE paramerters.
    On creation of the DB adapter, I get notification that a wrapper package is to be created. I confirm this, deploy the process and everything runs fine.
    The next day, I start the dev server, only to find the same process generate the following error:
    <bindingFault xmlns="http://schemas.oracle.com/bpel/extension"><part name="code"><code>4063</code>
    </part><part name="summary"><summary>file:/C:/soa_suite/bpel/domains/default/tmp/.bpel_fetchMedAssess_1.0_5e8d9ed419a39e6c3b8583856366f207.tmp/fetchMedicalAssess.wsdl [ fetchMedicalAssess_ptt::fetchMedicalAssess(InputParameters,OutputParameters) ] - WSIF JCA Execute of operation 'fetchMedicalAssess' failed due to: Error while trying to prepare and execute an API.
    An error occurred while preparing and executing the NHSSOA.BPEL_FETCHMEDICALASSESS.TOPLEVEL$NHSSOA_GET_MED_ASSES API. Cause: java.sql.SQLException: ORA-04063: package body "NHSSOA.BPEL_FETCHMEDICALASSESS" has errors
    ORA-06508: PL/SQL: could not find program unit being called: "NHSSOA.BPEL_FETCHMEDICALASSESS"
    ORA-06512: at line 1
    [Caused by: ORA-04063: package body "NHSSOA.BPEL_FETCHMEDICALASSESS" has errors
    ORA-06508: PL/SQL: could not find program unit being called: "NHSSOA.BPEL_FETCHMEDICALASSESS"
    ORA-06512: at line 1
    ; nested exception is:
         ORABPEL-11811
    Error while trying to prepare and execute an API.
    An error occurred while preparing and executing the NHSSOA.BPEL_FETCHMEDICALASSESS.TOPLEVEL$NHSSOA_GET_MED_ASSES API. Cause: java.sql.SQLException: ORA-04063: package body "NHSSOA.BPEL_FETCHMEDICALASSESS" has errors
    ORA-06508: PL/SQL: could not find program unit being called: "NHSSOA.BPEL_FETCHMEDICALASSESS"
    ORA-06512: at line 1
    [Caused by: ORA-04063: package body "NHSSOA.BPEL_FETCHMEDICALASSESS" has errors
    ORA-06508: PL/SQL: could not find program unit being called: "NHSSOA.BPEL_FETCHMEDICALASSESS"
    ORA-06512: at line 1
    Check to ensure that the API is defined in the database and that the parameters match the signature of the API. Contact oracle support if error is not fixable.
    </summary>
    </part><part name="detail"><detail>
    Internal Exception: java.sql.SQLException: ORA-04063: package body "NHSSOA.BPEL_FETCHMEDICALASSESS" has errors
    ORA-06508: PL/SQL: could not find program unit being called: "NHSSOA.BPEL_FETCHMEDICALASSESS"
    ORA-06512: at line 1
    Error Code: 4063</detail>
    </part></bindingFault>
    It looks like the wrapper package is erring somehow, although I have no idea what could be causing it. Could it be something to do with the %ROWTYPE parameters? No DDL has been changed between yesterday (working) and today (not working).
    Im running JDev / SOA Suite 10.1.3.3
    Edited by: Steve_Macleod on Sep 13, 2008 3:02 PM
    Edited by: Steve_Macleod on Sep 13, 2008 6:32 PM
    Edited by: Steve_Macleod on Sep 13, 2008 6:55 PM

    Ok, Im replying to myself now... clearly loosing the plot!
    I have noticed that the BPEL_GETPERSHISTDAT2.sql file (which is added when the DB adapter is created) looks like this:
    -- Declare the SQL type for the PL/SQL type ROWTYPE_PL0
    CREATE OR REPLACE TYPE ROWTYPE_SQL2 AS OBJECT (
    ASSESS_FORM_ID NUMBER,
    ASSESS_ID NUMBER,
    PERS_HIST_DETS VARCHAR2(4000),
    FORM_OWNER NUMBER,
    ASSESS_UPDATED DATE,
    ASSESS_ADDED DATE
    show errors
    -- Declare package containing conversion functions between SQL and PL/SQL types
    CREATE OR REPLACE PACKAGE BPEL_GETPERSHISTDAT2 AS
         -- Redefine a PL/SQL RECORD type originally defined via CURSOR%ROWTYPE
         TYPE ROWTYPE_PL0 IS RECORD (
              ASSESS_FORM_ID NUMBER,
              ASSESS_ID NUMBER,
              PERS_HIST_DETS VARCHAR2(4000),
              FORM_OWNER NUMBER,
              ASSESS_UPDATED DATE,
              ASSESS_ADDED DATE);
         -- Declare the conversion functions the PL/SQL type ROWTYPE_PL0
         FUNCTION PL_TO_SQL5(aPlsqlItem ROWTYPE_PL0)
         RETURN ROWTYPE_SQL2;
         FUNCTION SQL_TO_PL5(aSqlItem ROWTYPE_SQL2)
         RETURN ROWTYPE_PL0;
    FUNCTION TOPLEVEL$NHSSOA_GET_PERS_HIST (P_ASSESS_FORM_ID NUMBER) RETURN ROWTYPE_SQL2;
    END BPEL_GETPERSHISTDAT2;
    show errors
    CREATE OR REPLACE PACKAGE BODY BPEL_GETPERSHISTDAT2 IS
         FUNCTION PL_TO_SQL5(aPlsqlItem ROWTYPE_PL0)
         RETURN ROWTYPE_SQL2 IS
         aSqlItem ROWTYPE_SQL2;
         BEGIN
              -- initialize the object
              aSqlItem := ROWTYPE_SQL2(NULL, NULL, NULL, NULL, NULL, NULL);
              aSqlItem.ASSESS_FORM_ID := aPlsqlItem.ASSESS_FORM_ID;
              aSqlItem.ASSESS_ID := aPlsqlItem.ASSESS_ID;
              aSqlItem.PERS_HIST_DETS := aPlsqlItem.PERS_HIST_DETS;
              aSqlItem.FORM_OWNER := aPlsqlItem.FORM_OWNER;
              aSqlItem.ASSESS_UPDATED := aPlsqlItem.ASSESS_UPDATED;
              aSqlItem.ASSESS_ADDED := aPlsqlItem.ASSESS_ADDED;
              RETURN aSqlItem;
         END PL_TO_SQL5;
         FUNCTION SQL_TO_PL5(aSqlItem ROWTYPE_SQL2)
         RETURN ROWTYPE_PL0 IS
         aPlsqlItem ROWTYPE_PL0;
         BEGIN
              aPlsqlItem.ASSESS_FORM_ID := aSqlItem.ASSESS_FORM_ID;
              aPlsqlItem.ASSESS_ID := aSqlItem.ASSESS_ID;
              aPlsqlItem.PERS_HIST_DETS := aSqlItem.PERS_HIST_DETS;
              aPlsqlItem.FORM_OWNER := aSqlItem.FORM_OWNER;
              aPlsqlItem.ASSESS_UPDATED := aSqlItem.ASSESS_UPDATED;
              aPlsqlItem.ASSESS_ADDED := aSqlItem.ASSESS_ADDED;
              RETURN aPlsqlItem;
         END SQL_TO_PL5;
    FUNCTION TOPLEVEL$NHSSOA_GET_PERS_HIST (P_ASSESS_FORM_ID NUMBER) RETURN ROWTYPE_SQL2 IS
    RETURN_ ROWTYPE_SQL2;
    BEGIN
    RETURN_ := BPEL_GETPERSHISTDAT2.PL_TO_SQL5(NHSSOA_GET_PERS_HIST(P_ASSESS_FORM_ID));
    return RETURN_;
    END TOPLEVEL$NHSSOA_GET_PERS_HIST;
    END BPEL_GETPERSHISTDAT2;
    show errors
    exit
    The procedure that I am running from the DB adapter looks like this (I initially had this in a package, but simplified it into a stand-alone function):
    create or replace FUNCTION NHSSOA_GET_PERS_HIST (p_assess_form_id NUMBER) RETURN nhssoa_a_types.pers_hist AS
    CURSOR c_get_assess_dets IS
    SELECT *
    FROM nhscont_ass_pers_hist
    WHERE assess_form_id = p_assess_form_id;
    r_c_get_assess_dets c_get_assess_dets%ROWTYPE;
    BEGIN
    OPEN c_get_assess_dets;
    FETCH c_get_assess_dets INTO r_c_get_assess_dets;
    CLOSE c_get_assess_dets;
    RETURN r_c_get_assess_dets;
    END NHSSOA_GET_PERS_HIST;
    The nhssoa_a_types.pers_hist type looks like this
    TYPE pers_hist IS RECORD (
    ASSESS_FORM_ID     NUMBER,
    ASSESS_ID     NUMBER,
    PERS_HIST_DETS     VARCHAR2(4000 BYTE),
    FORM_OWNER     NUMBER,
    ASSESS_UPDATED     DATE,
    ASSESS_ADDED     DATE
    I should add that the NHSSOA_GET_PERS_HIST function has been tested outside BPEL and works OK.

  • Output parameter rowtype problem

    Hi,
    I have this type from Oracle:
    TYPE typ_vec_com_acces_doss IS TABLE
    OF COM_ACCES_DOSS%ROWTYPE
    INDEX BY binary_integer;
    And this Stored proc
    PROCEDURE LireAccesDossier (p_cod_ret OUT NOCOPY NUMBER,
    p_msg_ret OUT NOCOPY VARCHAR2,
    p_vec_com_acces_doss OUT NOCOPY
    typ_vec_com_acces_doss, ********************This is my problem!!!!!!
    p_app_cod IN
    COM_ACCES_DOSS.APP_COD%TYPE,
    p_ado_nom_tbl IN
    COM_ACCES_DOSS.ADO_NOM_TBL%TYPE DEFAULT NULL,
    p_ado_id_doss IN
    COM_ACCES_DOSS.ADO_ID_DOSS%TYPE DEFAULT NULL,
    p_ado_no_util_acces IN
    COM_ACCES_DOSS.ADO_NO_UTIL_ACCES%TYPE DEFAULT NULL,
    p_ado_dc IN
    COM_ACCES_DOSS.ADO_DC%TYPE DEFAULT NULL,
    p_ado_des_id_doss IN
    COM_ACCES_DOSS.ADO_DES_ID_DOSS%TYPE DEFAULT NULL);
    I need to call this procedure and attempting to
    catch p_vec_com_acces_doss on output.
    How can I do this in C# or VB.NET?

    Arnold,
    I subscribe to this forum because I searched for 2 days on the Internet to see anything about the subject and didn't find anything.
    This is my last attempt to find a solution to my problem.
    I can use a SQL string in my VB.NET code to retrieve what I want but this is a simple easy way and not very a good OOP design.
    I'm a bit frustrated because I canno't find answer to this question.
    But tks to have replied

  • ABAP Dump while Changing the Layout fields in Report output - RCOPCA02

    Hi,
    I Copied the Standard Program RCOPCA02 to ZRCOPCA02. I added two new fields(AUART, AUGRU) in the report output. It is executing correctly with default layout, While Changing the layout for displaying new fields it is dumping.
    I am not understanding, What should i do...
    Here is the Code.
    report ZRCOPCA02 no standard page heading message-id km
                    line-count (2) line-size 81.
    type-pools: slis, ecarc.
    DDIC-Tabellen *******************************************************
    tables: glpca,                         "Einzelposten / Ist
            glu1,                          "Übergabestruktur FI-SL-Anzeige
            t000,
            tka01,
            sscrfields,
            vbak.
    Variablen und int. Tabellen *****************************************
    data: l_vbeln like vbak-vbeln,
    l_auart like vbak-auart,
    l_augru like vbak-augru.
    data: afield type slis_fieldcat_alv,
    sp_group type slis_sp_group_alv,
    t_listheader type slis_t_listheader with header line,
    t_layout type slis_layout_alv,
    t_fieldcat type slis_t_fieldcat_alv,
    t_spec_groups type slis_t_sp_group_alv,
    event type slis_alv_event,
    t_events type slis_t_event,
    g_variant like disvariant,
    gx_variant like disvariant,
    g_exit(1) type c,
    g_save(1) type c,
    g_repid like sy-repid,
    msgtyp like sy-msgty,
    lt_dynpread like dynpread occurs 1 with header line,
    ls_rpcak like rpcak, "note 0310592
    packsize type i value 1000,
    text1(60) type c,
    text2(60) type c,
    oldkokrs like glpca-kokrs,
    oldracct like glpca-racct.
    data: whr_size type i value 50,"Maximum of single values per MIC 46a
    "charact. in the where-clause of the select-statement
    lines type i, "number of lines of range table MIC 46a
    cnt_rldnr type i, "Zähler Anzahl selektierter Ledger
    cnt_kokrs type i, "Zähler Anzahl selektierter KoReKreise
    cnt_poper type i, "Zähler Anzahl selektierter Perioden
    cnt_ryear type i, "Zähler Anzahl selektierter GeschJahre
    cnt_rvers type i, "Zähler Anzahl selektierter Versionen
    cnt_bukrs type i, "Zähler Anzahl selektierter BuKreise
    empge like dkobr-empge,
    ksl_curr like tka01-pcacur,
    hsl_curr like t001-waers,
    a_rec like rstirec.
    data: begin of dim_data.
    include structure rgcdi. "data for dimensions
    data: end of dim_data.
    data: begin of tab_fields occurs 80,
    name like dntab-fieldname, "fields in table i_glpca
    end of tab_fields.
    data: begin of i_glpca occurs 0.
    include structure rpca2.
    data: racct_ktext like rpcak-ktext,
    psppp like prps-posid,
    v_auart like vbak-auart,
    v_augru like vbak-augru,
          end of i_glpca.
    data: rw_subrc   like sy-subrc,      "Flag: Report-Writer-Schnittstelle
          re_subrc   like sy-subrc,        "Flag: Recherche-Schnittstelle
          subrc      like sy-subrc.
    data: set_id    like sethier-setid,    "Set-ID        "RDI_SETS_4.0
          set_class like sethier-setclass, "Setklasse     "RDI_SETS_4.0
          set_sname like sethier-shortname."Setname (24)  "RDI_SETS_4.0
    data: authorised(1),
          s_message(1),
          auth_dbcount like sy-tabix,
        Hex-Konstanten für Minimum/Maximum-Werte
          begin of hex00,
            x1(12) type c,
            x2(12) type c,
          end of hex00,
          begin of hexff,
            x1(12) type c,
            x2(12) type c,
          end of hexff.
    ranges rclnt for glpca-rclnt.
    field-symbols:  type ecarc_glpca_curr.
    Selektionsoptionen *************************************************
    select-options:
      rldnr    for glpca-rldnr   default '8A' no-display,
      rassc    for glpca-rassc                no-display,
    rrcty    for glpca-rrcty   default 0,
      rrcty    for glpca-rrcty,
      rvers    for glpca-rvers   default '000',
      kokrs    for glpca-kokrs   memory id cac,
      bukrs    for glpca-rbukrs  memory id buk,
    poper    for glpca-poper   default sy-datlo+4(2),
    ryear    for glpca-ryear   default sy-datlo,
      poper    for glpca-poper,
      ryear    for glpca-ryear,
      prctr    for glpca-rprctr  matchcode object prct,
      pprctr   for glpca-sprctr  matchcode object prct,
    RACCT    FOR GLPCA-RACCT   MATCHCODE OBJECT KART,      "RD_P30K128304
      racct    for glpca-racct,            "RD_P30K128304
      drcrk    for glpca-drcrk,
      activ    for glpca-activ,
      rhoart   for glpca-rhoart,
      rfarea   for glpca-rfarea,
      stagr    for glpca-stagr,
      rtcur    for glpca-rtcur,
      runit    for glpca-runit,
      versa    for glpca-versa  no-display,
      eprctr   for glpca-eprctr no-display,
      afabe    for glpca-afabe  no-display,
      rmvct    for glpca-rmvct  no-display,
      hrkft    for glpca-hrkft  no-display,  "note 550972
      sbukrs   for glpca-sbukrs no-display,  "note 550972
      shoart   for glpca-shoart no-display,  "note 550972
      sfarea   for glpca-sfarea no-display,  "note 550972
      docct    for glpca-docct,
      docnr    for glpca-docnr,
      refdocct for glpca-refdocct,
      refdocnr for glpca-refdocnr,
      werks    for glpca-werks,
      repmatnr for glpca-rep_matnr matchcode object pca_shlp_rep_matnr,
      rscope   for glpca-rscope.
    parameters: no_rrint no-display default ' '." skip       "MICP40K066037
    " report-report-interface
    display variant                                       ">>MICP40K039857
    selection-screen begin of block 0 with frame title text-e01.
    parameters: p_vari like disvariant-variant.
    selection-screen comment 47(40) varname for field p_vari.
    selection-screen end of block 0.
    parameters log_grp(4) type c no-display default 'KE5Z'.
    "<<MICP40K039857
    ranges: v_racct  for glpca-racct,
            v_prctr  for glpca-rprctr,
            v_pprctr for glpca-sprctr.
    Tabelle mit Werten aus den Berichts-Set vom Report-Writer           *
    data  begin of val_tab occurs 50.
            include structure rgciv.
    data  end of val_tab.
           MICP30K166368
    feldkatalog und interface für bb-schnittstelle rw        MICP30K166368
           MICP30K166368
    "MICP30K166368
    data  begin of bbs_fieldtab occurs 20. "MICP30K166368
            include structure rstifields.  "MICP30K166368
    data  end of bbs_fieldtab.             "MICP30K166368
    archiv
    type-pools: rsds.
    types:      begin of ty_archive_objects,
                   object       like arch_obj-object,
                end   of ty_archive_objects,
                ty_t_archive_objects type ty_archive_objects occurs 2.
    constants:  lc_set          type  c           value 'X',
                lc_report       type  progname    value 'KE5Z',
                lc_reporttype   type  reporttype  value 'TR'.
    tables:     admi_files.
    select-options lr_files for admi_files-archiv_key no-display.
    parameter:  read_db       type c            default 'X' no-display,
                read_ar       type c                        no-display,
                arc_obj       like arch_obj-object          no-display,
                read_as       type c            default 'X' no-display.
    data  :     lt_arch_obj     type ty_t_archive_objects with header line,
                ls_selections   type rsds_frange,
                lt_selections   type rsds_frange_t,
                ls_selopt type rsdsselopt,
                lt_glpca_archiv type ecarc_t_glpca_curr.
    *********************************************************>>MICP40K039857
    INITIALIZATION
    initialization.
    Diverse Initialisierungen
      perform init_vars.
      g_repid = sy-repid.
    Set default values for record type
      rrcty-sign = 'I'.
      rrcty-option = 'EQ'.
      rrcty-low    = '0'.
      append rrcty.
      rrcty-low = '2'.
      append rrcty.
    Set default values for period and year (if kokrs or bukrs is known)
      get parameter id 'BUK' field bukrs-low.
      get parameter id 'CAC' field kokrs-low.
      if     kokrs-low is initial       "get contr. area from company code
         and not bukrs-low is initial.
        call function 'KOKRS_GET_FROM_BUKRS'
          exporting
            i_bukrs        = bukrs-low
          importing
            e_kokrs        = kokrs-low
          exceptions
            no_kokrs_found = 1
            others         = 2.
        if sy-subrc <> 0.
          clear kokrs-low.
        endif.
      endif.
      if not kokrs-low is initial.
        call function 'K_KOKRS_READ'       "get fiscal year variant
             exporting
                  kokrs           = kokrs-low
              importing
                  e_tka01         = tka01
            exceptions
                  not_found       = 1
                  not_found_gjahr = 2
                  others          = 3.
        if sy-subrc = 0.
          call function 'G_PERIOD_GET'
            exporting
              date                           = sy-datlo
              variant                        = tka01-lmona
            importing
              period                         = poper-low
              year                           = ryear-low
            exceptions
              ledger_not_assigned_to_company = 1
              period_not_defined             = 2
              variant_not_defined            = 3
              others                         = 4.
          if sy-subrc = 0.
            poper-sign = 'I'.
            poper-option = 'EQ'.
            append poper.
            ryear-sign = 'I'.
            ryear-option = 'EQ'.
            append ryear.
          endif.
        endif.
      endif.
    Settings for display variants
      g_save = 'A'.  "Schalter Varianten benutz./allg. speichern
      clear g_variant.
      g_variant-report = g_repid.
      g_variant-log_group = log_grp.
      g_variant-username = sy-uname.
    Get default variant
      gx_variant = g_variant.
      call function 'REUSE_ALV_VARIANT_DEFAULT_GET'
        exporting
          i_save     = g_save
        changing
          cs_variant = gx_variant
        exceptions
          not_found  = 2.
      if sy-subrc = 0.
        p_vari = gx_variant-variant.
      endif.
    Set variant
      if p_vari is initial.
        p_vari = '1SAP'.
        move p_vari to gx_variant-variant.
        call function 'REUSE_ALV_VARIANT_EXISTENCE'
          exporting
            i_save     = g_save
          changing
            cs_variant = gx_variant
          exceptions
            not_found  = 1.
        if sy-subrc ne 0.
          clear p_vari.
          clear gx_variant-variant.
        endif.
      endif.
      varname = gx_variant-text.
      "<<MICP40K039857
    archiv
      call function 'KARL_DATA_INPUT_INIT'
        exporting
          i_report     = lc_report
          i_reporttype = lc_reporttype
        importing
          e_xusedb     = read_db
          e_xusear     = read_ar
          e_archobj    = arc_obj
          e_infosys    = read_as
        tables
          t_arch_sel   = lr_files.
      data: lt_excluding like sy-ucomm occurs 0 with header line.
      call function 'RS_SET_SELSCREEN_STATUS'
        exporting
          p_status  = 'SELSCREEN'
          p_program = 'RCOPCA02'
        tables
          p_exclude = lt_excluding.
    Initialisieren der Bericht/Bericht-Schnittstellen                   *
      data: ld_no_rrint type boole_d.      "note 490484 begin
      import rri = ld_no_rrint from memory id 'RCOPCA02_NO_RRI'.
      if ld_no_rrint = 'X'.
        free memory id 'RCOPCA02_NO_RRI'.
      else.                                "note 490484 end
        call function 'G_REPORT_INTERFACE_INIT'   "Report-Writer?
            exporting                      "MICP30K166368
                 table = 'GLPCT'           "MICP30K166368
             importing
                 subrc = rw_subrc          "MICP30K166368
            tables                         "MICP30K166368
                 it_fieldr = bbs_fieldtab. "MICP30K166368
        call function 'RSTI_APPL_STACK_POP'"oder Recherche?
             importing
                  i_rec                      = a_rec
             exceptions
                  appl_stack_not_initialized = 1.
        re_subrc = sy-subrc.
        if re_subrc = 0.
       check Receiver is this report
          if not ( ( a_rec-rtool = 'RT' and a_rec-ronam = 'RCOPCA02' )
                   or ( a_rec-rtool = 'TR' and a_rec-ronam = 'KE5Z' ) ) .
            re_subrc = 2.
          endif.
        endif.
      endif.
    AT SELCTION-SCREEN on value request**********************************
    *at selection-screen on value-request for racct-low.          "RD "4.6a
                                                                "RD "4.6a
    call function 'K_RACCT_VALUE_REQUEST'                       "RD "4.6a
         importing                                              "RD "4.6a
              e_racct      = racct-low.                         "RD "4.6a
                                                                "RD "4.6a
                                                                "RD "4.6a
    *at selection-screen on value-request for racct-high.         "RD "4.6a
                                                                "RD "4.6a
    call function 'K_RACCT_VALUE_REQUEST'                       "RD "4.6a
         importing                                              "RD "4.6a
              e_racct      = racct-high.                        "RD "4.6a
    at selection-screen on value-request for p_vari.         "MICP40K039857
      perform f4_for_variant.              "MICP40K039857
    at selection-screen on value-request for poper-low.         "RD "4.6a
    begin of insertion note 522715
      call function 'K_KOKRS_READ'
        exporting
          kokrs           = kokrs-low
        exceptions
          not_found       = 1
          not_found_gjahr = 2
          others          = 3.
      if sy-subrc = 0.
    end of insertion note 522715
        call function 'ECPCA_RPMAX_VALUE_REQUEST'               "RD "4.6a
             exporting                                          "RD "4.6a
                  i_kokrs     = kokrs-low                       "RD "4.6a
                  i_ryear     = ryear-low                       "RD "4.6a
             importing                                          "RD "4.6a
                  e_rpmax     = poper-low                       "RD "4.6a
    begin of insertion note 522715
             exceptions
                  table_empty = 1.
      endif.
    end of insertion note 522715
    at selection-screen on value-request for poper-high.        "RD "4.6a
    begin of insertion note 522715
      call function 'K_KOKRS_READ'
        exporting
          kokrs           = kokrs-low
        exceptions
          not_found       = 1
          not_found_gjahr = 2
          others          = 3.
      if sy-subrc = 0.
    end of insertion note 522715
        call function 'ECPCA_RPMAX_VALUE_REQUEST'               "RD "4.6a
             exporting                                          "RD "4.6a
                  i_kokrs     = kokrs-low                       "RD "4.6a
                  i_ryear     = ryear-low                       "RD "4.6a
             importing                                          "RD "4.6a
                  e_rpmax     = poper-high                      "RD "4.6a
    begin of insertion note 522715
             exceptions
                  table_empty = 1.
      endif.
    end of insertion note 522715
    AT SELCTION-SCREEN ***************************************************
    at selection-screen.
      perform pai_of_selection_screen.
    begin of insertion note 522715
      if not kokrs-low is initial.
        call function 'K_KOKRS_READ'
          exporting
            kokrs           = kokrs-low
          exceptions
            not_found       = 1
            not_found_gjahr = 2
            others          = 3.
        if sy-subrc <> 0.
          message e101(ki) with kokrs-low.
        endif.
      endif.
    end of insertion note 522715
    archiv
      if sy-ucomm = 'FC01' or sy-ucomm = 'UCDS'
        or sy-ucomm = 'ONLI' and read_ar = 'X'
        and read_as is initial and lr_files[] is initial.
        if lt_arch_obj[] is initial.
          lt_arch_obj-object = 'PCA_OBJECT'. append lt_arch_obj.
          lt_arch_obj-object = 'EC_PCA_ITM'. append lt_arch_obj.
        endif.
        call function 'KARL_DATA_INPUT_SELECT'
          exporting
            i_db_and_arc       = lc_set
            i_infosys_possible = lc_set
            i_object_fixed     = 'V'
            i_documentation    = 'KARL_DATA_INPUT_SEL_KE5YZ'
            i_report           = lc_report
            i_reporttype       = lc_reporttype
          tables
            t_objects          = lt_arch_obj
            t_arch_sel         = lr_files
          changing
            c_xusedb           = read_db
            c_xusear           = read_ar
            c_archobj          = arc_obj
            c_infosys          = read_as.
      endif.
    START-OF-SELECTION **************************************************
    start-of-selection.
      Default-Werte löschen, falls Aufruf über Recherche
      oder Report-Writer erfolgt ist
      if no_rrint is initial and ld_no_rrint is initial.        "note 490484
        if rw_subrc eq 0 or re_subrc eq 0.
          refresh: rldnr, rrcty, rvers,  kokrs, bukrs, poper,  ryear,
                   racct, prctr, pprctr, drcrk, activ, rhoart, rfarea,
                   versa, afabe, eprctr,
                   v_racct, v_prctr, v_pprctr.
          clear:   rldnr, rrcty, rvers,  kokrs, bukrs, poper,  ryear,
                   racct, prctr, pprctr, drcrk, activ, rhoart, rfarea,
                   versa, afabe, eprctr,
                   v_racct, v_prctr, v_pprctr.
        endif.
    Parameter einlesen über Report-Writer-Schnittstelle                 *
        if rw_subrc eq 0.
          perform rw_get_parameters.
    oder Parameter einlesen über Recherche-Schnittstelle                *
        elseif re_subrc eq 0.
          perform re_get_parameters.
        endif.
      endif.
      if read_db = 'X'.                     " read from DB (archiv)
    Bewegungsdaten einlesen und puffern...................................
        call function 'SAPGUI_PROGRESS_INDICATOR'
          exporting
            text = 'Einzelposten selektieren'(p10).
    Use dirty trick to mislead DB-optimizer
        call function 'DB_DO_NOT_USE_CLIENT_INDEX'
          exporting
            value    = sy-mandt
          tables
            mandttab = rclnt.
        select (tab_fields) from glpca
           client specified
           package size packsize
          APPENDING CORRESPONDING FIELDS OF TABLE i_glpcaO
            into corresponding fields of table i_glpca
           where rldnr     in rldnr
             and rrcty     in rrcty
             and rvers     in rvers
             and kokrs     in kokrs
             and rbukrs    in bukrs
             and ryear     in ryear
             and rassc     in rassc
             and hrkft     in hrkft   "note 550972
             and sbukrs    in sbukrs  "note 550972
             and shoart    in shoart  "note 550972
             and sfarea    in sfarea  "note 550972
             and racct     in racct
             and rprctr    in prctr
             and sprctr    in pprctr
             and poper     in poper
             and drcrk     in drcrk
             and activ     in activ
             and rhoart    in rhoart
             and rfarea    in rfarea
             and versa     in versa
             and eprctr    in eprctr
             and afabe     in afabe
             and rmvct     in rmvct
             and docct     in docct
             and docnr     in docnr
             and stagr     in stagr
             and rtcur     in rtcur
             and runit     in runit
             and refdocct  in refdocct
             and refdocnr  in refdocnr
             and werks     in werks
             and rep_matnr in repmatnr       "RDIP40K020663
             and rscope    in rscope         "RDIP40K020663
          and rclnt     in rclnt.       "dirty trick to mislead DB-optimizer
          if sy-dbcnt > 1.
            text1 = sy-dbcnt.
            condense text1.
            concatenate text1 text-m01 into text2 separated by space.
            call function 'SAPGUI_PROGRESS_INDICATOR'
              exporting
                text = text2.          " ... Datensätze gelesen
          endif.
        endselect.
    Entfernt nicht zugehörige Einträge....................................
        loop at i_glpca where ( not rprctr in v_prctr  )
                           or ( not sprctr in v_pprctr )
                           or ( not racct  in v_racct  ).
          delete i_glpca.
        endloop.
      endif.
    *archiv
      if read_ar = 'X' and not
        ( read_as is initial and lr_files[] is initial ).
        call function 'SAPGUI_PROGRESS_INDICATOR'
          exporting
            text = 'Lesen im Archiv'(p12).
        define fill_lt_selections.
          if not &2[] is initial.
            clear ls_selections.
            move &1 to ls_selections-fieldname.
            loop at &2.
              clear ls_selopt.
              move-corresponding &2 to ls_selopt.
              append ls_selopt to ls_selections-selopt_t.
            endloop.
            append ls_selections to lt_selections.
          endif.
        end-of-definition.
        fill_lt_selections 'RLDNR'  rldnr.
        fill_lt_selections 'RRCTY'  rrcty.
        fill_lt_selections 'RVERS'  rvers.
        fill_lt_selections 'KOKRS'  kokrs.
        fill_lt_selections 'RBUKRS' bukrs.
        fill_lt_selections 'POPER'  poper.
        fill_lt_selections 'RYEAR'  ryear.
        fill_lt_selections 'RPRCTR' prctr.
        fill_lt_selections 'SPRCTR' pprctr.
        fill_lt_selections 'RACCT'  racct.
        fill_lt_selections 'DRCRK'  drcrk.
        fill_lt_selections 'ACTIV'  activ.
        fill_lt_selections 'RHOART' rhoart.
        fill_lt_selections 'RFAREA' rfarea.    "note 401961
        fill_lt_selections 'STAGR'  stagr.
        fill_lt_selections 'RTCUR'  rtcur.
        fill_lt_selections 'RUNIT'  runit.
        fill_lt_selections 'VERSA'  versa.
        fill_lt_selections 'EPRCTR' eprctr.
        fill_lt_selections 'AFABE'  afabe.
        fill_lt_selections 'RMVCT'  rmvct.
        fill_lt_selections 'DOCCT'  docct.
        fill_lt_selections 'DOCNR'  docnr.
        fill_lt_selections 'REFDOCCT' refdocct.
        fill_lt_selections 'REFDOCNR' refdocnr.
        fill_lt_selections 'WERKS'  werks.
        fill_lt_selections 'REP_MATNR' repmatnr.
        fill_lt_selections 'RSCOPE' rscope.
        fill_lt_selections 'HRKFT'  hrkft.   "note 550972
        fill_lt_selections 'SBUKRS' sbukrs.  "note 550972
        fill_lt_selections 'SHOART' shoart.  "note 550972
        fill_lt_selections 'SFAREA' sfarea.  "note 550972
        call function 'EC_PCA_SELECT_FROM_ARCHIVE'
          exporting
            i_selections            = lt_selections[]
            i_files_sequential_read = lr_files[]
          importing
            e_glpca                 = lt_glpca_archiv[]
          exceptions
            no_infostruc_found      = 1.
        if sy-subrc = 1.
          message id sy-msgid type 'I' number sy-msgno
                  with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        endif.
        clear i_glpca.
        loop at lt_glpca_archiv assigning  to i_glpca.
          append i_glpca.
        endloop.
      endif.
      if i_glpca[] is initial.         "Info,nichts gefunden
        message s000.
        exit.
      endif.
    get texts for accounts ...............................................
      sort i_glpca by kokrs racct.
      loop at i_glpca assigning -racct_ktext = ls_rpcak-ktext.
      endloop.
    Liste mit Einzelposten geeignet sortieren.............................
      call function 'SAPGUI_PROGRESS_INDICATOR'
        exporting
          text = 'Einzelposten sortieren'(p30).
    if show_ref is initial.
       sort i_glpca by rldnr ryear rbukrs rrcty rvers
                       docct docnr docln.
    else.
      sort i_glpca by rldnr kokrs ryear rbukrs rrcty rvers poper
                      refdocct refdocnr refdocln.
    endif.
    Berechtigungsprüfung und gemerkte Belege aufbereiten .................
      call function 'SAPGUI_PROGRESS_INDICATOR'
        exporting
          text = 'Berechtigungsprüfungen'(p40).
      clear: cnt_rldnr, cnt_kokrs, cnt_ryear, cnt_rvers, cnt_bukrs.
      loop at i_glpca assigning .
      Berechtigungscheck
        perform check_repo_authority changing authorised.
        if authorised is initial.
          delete i_glpca.
          s_message = 'X'.
        zählen der Sätze ohne Berechtigung
          auth_dbcount = auth_dbcount + 1.
        else. "Weitere Bearbeitung nur für berechtigte Belege...
        Zusätzlich merken der Anzahl der Ausprägungen
        bestimmter Dimensionen
          on change of -rbukrs
                ct       = '10'
              importing
                currency = hsl_curr.
          endon.
        externe Immobilienbezeichnung                     "ww/kb
        on change of i_glpca-imkey.
          if ( not -dabrz
                    I_length   = 20
                 importing
                      e_empge    = -konty.
            endif.
          CONCATENATE I_GLPCA-KONTY I_GLPCA-EMPGE INTO I_GLPCA-IMBEZ.
          endif.
        endon.
        on change of i_glpca-dabrz.
           call function 'REMD_IMKEY_TO_EMPGE'
                exporting
                     i_imkey    = i_glpca-imkey
                     i_dabrz    = i_glpca-dabrz
                    i_length   = 20
                importing
                     e_empge    = i_glpca-empge
                     e_konty    = i_glpca-konty.
          CONCATENATE I_GLPCA-KONTY I_GLPCA-EMPGE INTO I_GLPCA-IMBEZ.
         endon.
        Konvertierungsproblem mit PSP-Nummer bereinigen
          if not -psppp.
            endif.
          endif.
        Währungen in Hilfsfeldern speichern
          if -ksl_curr = ksl_curr.
          endif.
        modify i_glpca.
        endif.
      endloop.
    Nachricht, wenn nicht alle Einzelposten angezeigt werden.
      if not s_message is initial.
        message s407(km) with auth_dbcount.
      endif.
    EP ausgeben...........................................................
      call function 'SAPGUI_PROGRESS_INDICATOR'
        exporting
          text = 'Einzelposten ausgeben'(p50).
      t_layout-detail_initial_lines = 'X'.
      t_layout-detail_popup         = 'X'.
      t_layout-f2code               = 'PIC1'.                "MICP40K039857
      t_layout-get_selinfos         = 'X'.
      t_layout-group_change_edit    = 'X'.                   "note 576149
      perform fill_listheader.
      perform fieldcat_fill.
      perform spec_groups_fill.
      perform events_fill.                 "MICP40K039857
      ">>MICP40K039857
    call function 'K_KKB_LIST_DISPLAY'
          exporting
               i_callback_program       = 'RCOPCA02'
               i_callback_user_command  = 'USR_CMD'
               i_callback_top_of_page   = 'TOP_OF_PAGE'
              I_CALLBACK_END_OF_PAGE   =
              I_CALLBACK_END_OF_LIST   =
               i_callback_pf_status_set = 'SET_PF_STATUS'
              I_CALLBACK_LAYOUT_SAVE   =
              I_CALLBACK_FIELDCAT_SAVE =
               i_tabname                = 'I_GLPCA'
               is_layout                = t_layout
               it_fieldcat              = t_fieldcat
              I_FCTYPE                 = 'R'
              IT_EXCLUDING             =
               it_special_groups        = t_spec_groups
              IT_SORT                  =
              IS_SEL_HIDE              =
              I_SCREEN_START_COLUMN    = 0
              I_SCREEN_START_LINE      = 0
              I_SCREEN_END_COLUMN      = 0
              I_SCREEN_END_LINE        = 0
          tables
               t_outtab                 = i_glpca
          exceptions
               others                   = 1.
    loop at i_glpca.
    select single vbeln auart augru
    into (l_vbeln, l_auart, l_augru)
    from vbak where vbeln = i_glpca-aubel.
    if sy-subrc = 0.
    move l_auart to i_glpca-v_auart.
    move l_augru to i_glpca-v_augru.
    modify i_glpca.
    endif.
    endloop.
      call function 'REUSE_ALV_GRID_DISPLAY'
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
         exporting
            I_INTERFACE_CHECK        = ' '
               i_callback_program       = 'ZRCOPCA02'
               i_callback_pf_status_set = 'SET_PF_STATUS'
               i_callback_user_command  = 'USR_CMD'
               i_structure_name         = 'I_GLPCA'
               is_layout                = t_layout
               it_fieldcat              = t_fieldcat
            IT_EXCLUDING             =
               it_special_groups        = t_spec_groups
            IT_SORT                  =
            IT_FILTER                =
            IS_SEL_HIDE              =
               i_default                = 'X'
               i_save                   = g_save
               is_variant               = g_variant
               it_events                = t_events
            IT_EVENT_EXIT            =
            IS_PRINT                 =
            I_SCREEN_START_COLUMN    = 0
            I_SCREEN_START_LINE      = 0
            I_SCREEN_END_COLUMN      = 0
            I_SCREEN_END_LINE        = 0
       IMPORTING
            E_EXIT_CAUSED_BY_CALLER  =
            ES_EXIT_CAUSED_BY_USER   =
          tables
               t_outtab                 = i_glpca
        exceptions
             program_error            = 1
             others                   = 2.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
      "<<MICP40K039857
      clear i_glpca.
    *&      Form  CHECK_REPO_AUTHORITY
    Check only new auth-object K_PCA                                    *
    -->  p1        text
    <--  p2        text
    form check_repo_authority changing authorized like authorised.
    fill structure for userexit in K_PCA_RESP_AUTHORITY_CHECK
      data: auth like pca_i_auth.          "46a MIC check K_PCA and G_GLTP
      auth-bukrs = -rrcty.
      clear authorized.
    check PrCtr/account/activity
      call function 'K_PCA_RESP_AUTHORITY_CHECK'
        exporting
          i_kokrs             = -racct
          i_vorgn             = 'REPP'
          i_actvt             = '28'
          i_auth              = auth
          i_no_dialog_message = 'X'
        exceptions
          no_authority        = 1
          data_missing        = 2
          others              = 3.
      if sy-subrc = 0.                                          "ok
    check ledger/version/record type
        call function 'PCA_G_GLTP_AUTH_CHECK'
          exporting
            rldnr            = -rrcty
          exceptions
            no_authorisation = 1
            others           = 2.
        if sy-subrc = 0.                   "ok, User is authorized
          authorized = 'X'.
        endif.
      endif.
    endform.                               " CHECK_REPO_AUTHORITY
    *&      Form  INIT_VARS
          Initialisieren diverser Hilfsvariablen und -tabellen           *
    form init_vars.
      data begin of nametab occurs 80. "Tabelle mit Feldern aus der RPCA2
              include structure dntab.
      data end of nametab.
      select single * from t000
                      client specified
                      where mandt = sy-mandt.
      refresh nametab.
      call function 'NAMETAB_GET'
        exporting
          only    = 'T'
          tabname = 'RPCA2'
        tables
          nametab = nametab.
    Übernehmen der Feldnamen, die auch in der GLPCA
    vorkommen.
      loop at nametab where fieldname ne 'KSL_CURR'
                        and fieldname ne 'HSL_CURR'
                        and fieldname ne 'EMPGE'               "ww/kb
                        and fieldname ne 'KONTY'.              "ww/kb
        move nametab-fieldname to tab_fields-name.
        append tab_fields.
      endloop.
    fill Fields of receiver for BBS                          "MIC46C
      call function 'RSTI_REPORT_FIELDS_FIND'
        exporting
          e_repid   = 'RCOPCA02'
          e_type    = 'R'
        tables
          it_fields = bbs_fieldtab.
    correct fieldnames
      read table bbs_fieldtab with key rfield = 'PRCTR'.
      if sy-subrc = 0.
        bbs_fieldtab-rfield = 'RPRCTR'.
        modify bbs_fieldtab index sy-tabix.
      endif.
      read table bbs_fieldtab with key rfield = 'PPRCTR'.
      if sy-subrc = 0.
        bbs_fieldtab-rfield = 'SPRCTR'.
        modify bbs_fieldtab index sy-tabix.
      endif.
      read table bbs_fieldtab with key rfield = 'BUKRS'.
      if sy-subrc = 0.
        bbs_fieldtab-rfield = 'RBUKRS'.
        modify bbs_fieldtab index sy-tabix.
      endif.
    Unicode
      class cl_abap_char_utilities definition load.
      clear hex00 with cl_abap_char_utilities=>minchar.
      clear hexff with cl_abap_char_utilities=>maxchar.
    endform.                               " INIT_VARS
          FORM FILL_LISTHEADER                                          *
          List-Header in Abhängigkeit der selektierten Daten            *
    form fill_listheader.
      read table i_glpca index 1.
      if sy-subrc ne 0.
        exit.
      endif.
      t_listheader-typ  = 'S'.
      t_listheader-key  = 'Ledger              '(h01).
      if cnt_rldnr <= 1.
        t_listheader-info = i_glpca-rldnr.
      else.
        t_listheader-info = '*'.
      endif.
      append t_listheader.
      t_listheader-typ  = 'S'.
      t_listheader-key  = 'Kostenrechnungskreis'(h02).
      if  cnt_kokrs <= 1.
        t_listheader-info = i_glpca-kokrs.
      else.
        t_listheader-info = '*'.
      endif.
      append t_listheader.
      t_listheader-typ  = 'S'.
      t_listheader-key  = 'Buchungskreis       '(h03).
      if cnt_bukrs <= 1.
        t_listheader-info = i_glpca-rbukrs.
      else.
        t_listheader-info = '*'.
      endif.
      append t_listheader.
      t_listheader-typ  = 'S'.
      t_listheader-key  = 'Buchungsperiode     '(h04).
      if cnt_poper <= 1.
        t_listheader-info = i_glpca-poper.
      else.
        t_listheader-info = '*'.
      endif.
      append t_listheader.
      if cnt_ryear <= 1.
        t_listheader-typ  = 'S'.
        t_listheader-key  = 'Geschäftsjahr       '(h05).
        t_listheader-info = i_glpca-ryear.
        append t_listheader.
      endif.
      t_listheader-typ  = 'S'.
      t_listheader-key  = 'Version             '(h06).
      if cnt_rvers <= 1.
        t_listheader-info = i_glpca-rvers.
      else.
        t_listheader-info = '*'.
      endif.
      append t_listheader.
    endform.                    "fill_listheader
    *&      Form  FIELDCAT_FILL
    *&      Aufbau des Feldkataloges für den K_KKB_LIST_DISPLAY,           *
    *&      bzw REUSE_ALV_LIST_DISPLAY,                                    *
    *&      weitere Infos enthält die FktBaustein-Doku                     *
    form fieldcat_fill.
      data: i type i value 0.
      refresh t_fieldcat.
    Ledger
    if cnt_rldnr > 1.
      add 1 to i.
      clear afield.
      afield-col_pos     = i.
      afield-fieldname   = 'RLDNR'.
      afield-no_sum      = 'X'.
      afield-no_out      = 'X'.
      afield-key         = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-sp_group    = '1'.
      append afield to t_fieldcat.
    endif.
    Satzart
      add 1 to i.
      clear afield.
      afield-col_pos     = i.
      afield-fieldname   = 'RRCTY'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-no_out      = 'X'.
      afield-sp_group    = '1'.
      append afield to t_fieldcat.
    Version
    if cnt_rvers > 1.
      add 1 to i.
      clear afield.
      afield-col_pos     = i.
      afield-fieldname   = 'RVERS'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-no_out      = 'X'.
      afield-sp_group    = '1'.
      append afield to t_fieldcat.
    endif.
    Periode
    if cnt_poper > 1.
      add 1 to i.
      clear afield.
      afield-col_pos     = i.
      afield-fieldname   = 'POPER'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-no_out      = 'X'.
      afield-sp_group    = '1'.
      append afield to t_fieldcat.
    endif.
    Geschäftsjahr
    if cnt_ryear > 1.
      add 1 to i.
      clear afield.
      afield-col_pos     = i.
      afield-fieldname   = 'RYEAR'.
      afield-no_sum      = 'X'.
      afield-ref_tabname = 'GLPCA'.
      afield-no_out      = 'X'.
      afield-sp_group    = '1'.
      append afield to t_fieldcat.
    endif.
    Referenzbelegtyp
      add 1 to i.
      clear afield.
      afield-col_pos     = i.
      afield-fieldname   = 'REFDOCCT'.
      afield-ref_tabname = 'GLPCA'.
      afield-key_sel     = 'X'.
      afield-no_sum      = 'X'.
      afield-sp_group    = '2'.
      afield-seltext_s   = 'Typ'(t01).
      afield-seltext_m   = 'Belegtyp'(t02).
      afield-seltext_l   = 'Ref.Belegtyp'(t03).
      afield-outputlen   = 3. "Platz für die Sterne der Zwischensummen
    if not show_ref is initial.
      afield-key = 'X'.
    else.
       afield-no_out = 'X'.
    endif.
      append afield to t_fieldcat.
    Referenzbelegnummer
      add 1 to i.
      clear afield.
      afield-col_pos     = i.
      afield-fieldname   = 'REFDOCNR'.
      afield-ref_tabname = 'GLPCA'.
      afield-key_sel     = 'X'.
      afield-no_sum      = 'X'.
      afield-sp_group    = '2'.
      afield-seltext_s  = 'Refbeleg'(t04).
      afield-seltext_m  = 'Refbelegnr'(t05).
      afield-seltext_l  = 'Ref.Belegnummer'(t06).
    if not show_ref is initial.
      afield-key = 'X'.
    else.
       afield-no_out = 'X'.
    endif.
      append

    Hi Prabhu,
    You are right, problem is with Field Catalog...
    When I use  FM 'REUSE_ALV_GRID_DISPLAY'  it is dumping...
    When i tried with FM 'REUSE_ALV_LIST_DISPLAY'  it is working perfectly....
    how can i use FM 'REUSE_ALV_GRID_DISPLAY' without dumping????
    do i need to pass any thing in FM????
    Here is the dump:
    Runtime Errors         MESSAGE_TYPE_X                                
           Occurred on     12/21/2006 at 01:03:24                                                                               
    The current application triggered a termination with a short dump.   
                                                             What happened?                                                       
    The current application program detected a situation which really    
    should not occur. Therefore, a termination with a short dump was     
    triggered on purpose by the key word MESSAGE (type X).               
                                                         Error analysis                                                       
    Short text of error message:                                                                               
    Technical information about the message:                             
    Message classe...... "0K "                                           
    Number.............. 000 
    User, transaction...                                                                               
    Language key........ "E"                                                    
    Transaction......... "SE38 "                                                
    Program............. "SAPLSLVC "                                            
    Screen.............. "SAPLSLVC_FULLSCREEN 0500"                             
    Screen line......... 3                                                                               
    Information on where termination occurred                                                                               
    The termination occurred in the ABAP program "SAPLSLVC " in "LINE_OUT_NEW_2".
    The main program was "ZRCOPCA02 ".                                          
    The termination occurred in line 918 of the source code of the (Include)    
    program "LSLVCF01 "                                                        
    of the source code of program "LSLVCF01 " (when calling the editor 9180).   
                                                             Source code extract                                                                               
    008880         gs_roid-row_id = rs_row-index * -1.                          
    008890       endif.                                                         
    008900       gs_roid-sub_row_id = rs_row-rowtype+7(10).                     
    008910       gs_poid-row_id = gs_roid-row_id.                               
    008920       gs_poid-sub_row_id = gs_roid-sub_row_id.                       
    008930       gs_poid-rowtype    = rs_row-rowtype.                           
    008940       gs_poid-index      = rs_row-index.                             
    008950       insert gs_poid into table rt_poid.  
    008960     endif.                                                               
    008970     append gs_roid to rt_roid.                                           
    008980                                                                          
    008990     loop at rt_fieldcat assigning <ls_fieldcat> where tech ne 'X' and    
    009000                                                       no_out ne 'X'.     
    009010                                                                          
    009020       if gflg_invisible = 'X'.                                           
    009030         if <ls_fieldcat>-do_sum is initial.                              
    009040           clear gflg_invisible.                                          
    009050           continue.                                                      
    009060         else.                                                            
    009070           clear g_col_counter.                                           
    009080           clear gflg_invisible.                                          
    009090         endif.                                                           
    009100       endif.                                                             
    009110                                                                          
    009120       clear gs_lvc_data.                                                 
    009130       clear g_style.                                                     
    009140                                                                          
    009150       assign component                                                   
    009160              <ls_fieldcat>-fieldname of structure rt_data to <g_field>.  
    009170       if sy-subrc ne 0.                                                  
         >         message x000(0k).                                                
    009190       endif.                                                             
    009200                                                                          
    009210       g_col_counter = g_col_counter + 1.                                 
    009220                                                                          
    009230       gs_lvc_data-row_pos = r_row_counter.                               
    009240       gs_lvc_data-col_pos = g_col_counter.                               
    009250       gs_lvc_data-row_id  = gs_roid-row_id.                              
    009260       gs_lvc_data-sub_row_id = gs_roid-sub_row_id.                       
    009270                                                                          
    009280   *   Endtotal and average                                               
    009290       if rs_row-rowtype(1) ca 'T' and <ls_fieldcat>-do_sum = 'C'.        
    009300   *     save the actual grouplevel information                    
    009310         gs_grouplevels = rs_grouplevels.                          
    009320         clear g_lines.                                            
    009330                                                                   
    009340   *     get number of lines of the collect table                  
    009350         describe table rt_data lines g_lines.                     
    009360   *     if there is only one line or the field has no references so
    009370   *     that only the first line has to be considered                                                                               
    Thanks,
    fractal
    null

  • Outputting data to a flat file

    Hi. Sorry if this is really a simple question, but I am new to PL/SQL and SQL.
    I need to select all the fields from a table and output it to a flat file. Can you tell me how to do this, ie give me a sample code.
    Thanks.

    Hey CD,
    Theres Nothing more simple than outputting values in to a flat file from PL/SQL.
    1-Open a cursor containing your field values.
    2- Use the UTL_FILE package from Oracle to output the results....
    Like so:
    PROCEDURE PROC_PROCEDURE()
    IS
    -- declare variables!
    var_FileHandle UTL_FILE.FILE_TYPE; -- file handle
    var_Values VARCHAR2(4000); -- record layout
    -- declare cursors
    CURSOR cur_cursor IS
    SELECT *
    FROM table
    WHERE {conditions}
    -- declare cursor variables
    varcur_cursor cur_cursor%ROWTYPE;
    BEGIN
    -- Open File to write...
    var_FileHandle := UTL_FILE.FOPEN(ExportFilePath, FileName, 'w', 8191);
    -- Select records...
    FOR varcur_cursor IN cur_cursor LOOP
    -- Build INSERT statements...
    var_Values := varcur_cursor.FIELDNAME1
    &#0124; &#0124;varcur_cursor.FIELDNAME2
    &#0124; &#0124; ...more fields....
    -- Insert Values into flat file...
    UTL_FILE.PUT_LINE(var_FileHandle, var_Values);
    END LOOP;
    -- Close text file...
    UTL_FILE.FCLOSE(var_FileHandle);
    END PROC_PROCEDURE;
    Hope this helps!
    Mg.

  • How to call a Stored Function with OUT parameter of %rowType from Java

    Hi everyone,
    I'm getting crazy trying to make this work.
    I have a function (not developed by me) in Oracle 10g declared in this way:
    type tab_RLSSP is table of TB_RLSSP_STOSTPRPAR_CL%ROWTYPE index by binary_integer;
    FUNCTION DBF_PERL_LISTA_PRATICHE (
    p_id_va IN NUMBER,
    p_seq_partita IN NUMBER,
    p_trattamento IN CHAR,
    lrec_RLSSP OUT tab_RLSSP ) RETURN NUMBER;
    And here is the code snipplet of my java method:
    sql="{? = call "+SCHEMA+PACKAGE+"."+FUNCTION_LIST+"(?,?,?,?)}";
    cs=connection.prepareCall(sql);
    cs.registerOutParameter(1, OracleTypes.NUMBER);
    cs.setLong(2,idVATitolare);
    cs.setLong(3,seqPartita);
    cs.setString(4,trattamento);// Caso Decesso
    cs.registerOutParameter(5, OracleTypes.OTHER);
    cs.executeQuery();
    result = (ResultSet) cs.getObject(5);
    if (result.next())
    listaPratiche.add(readPraticaPartita(result));
    The result (exception thrown at executeQuery with statement generated as
    SQL : {? = call PEDBA.DBK_PERL_RATEI_SUPPLETIVI.DBF_PERL_LISTA_PRATICHE(?,?,?,?)}:
    java.sql.SQLException: ORA-06550: line 1, column 13:
    PLS-00306: wrong number or types of arguments in call to 'DBF_PERL_LISTA_PRATICHE'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Changing to :
    sql="{call ? := "+SCHEMA+PACKAGE+"."+FUNCTION_LISTA+"(?,?,?,?)}";
    leading to
    SQL : {call ? := call PEDBA.DBK_PERL_RATEI_SUPPLETIVI.DBF_PERL_LISTA_PRATICHE(?,?,?,?)}
    don't change anything.
    What's wrong? Any suggestion?
    Edited by: 957158 on 5-set-2012 9.06

    >
    Taking for granted that it works, I wonder what's different, probably the output is defined as Cursor...
    >
    You mean because of this line?
    cs.registerOutParameter(5,OracleTypes.CURSOR);You can either use a cursor or use a function that returns a SQL type instead of the PL/SQL type.
    Here is sample code using a cursor
    CREATE OR REPLACE TYPE SCOTT.local_type IS OBJECT (
        empno   NUMBER(4),
        ename   VARCHAR2(10));
    CREATE OR REPLACE TYPE SCOTT.local_tab_type IS TABLE OF local_type;
    CREATE OR REPLACE PACKAGE SCOTT.test_refcursor_pkg
    AS
        TYPE my_ref_cursor IS REF CURSOR;
         -- add more cursors as OUT parameters
         PROCEDURE   test_proc(p_ref_cur_out OUT test_refcursor_pkg.my_ref_cursor);
    END test_refcursor_pkg;
    CREATE OR REPLACE PACKAGE BODY SCOTT.test_refcursor_pkg
    AS
         PROCEDURE  test_proc(p_ref_cur_out OUT test_refcursor_pkg.my_ref_cursor)
         AS
            l_recs local_tab_type;
         BEGIN
             -- Get the records to modify individually.
             SELECT local_type(empno, ename) BULK COLLECT INTO l_recs
             FROM EMP;
             -- Perform some complex calculation for each row.
             FOR i IN l_recs.FIRST .. l_recs.LAST
             LOOP
                 DBMS_OUTPUT.PUT_LINE(l_recs(i).ename);
             END LOOP;
             -- Put the modified records back into the ref cursor for output.  
             OPEN p_ref_cur_out FOR
             SELECT * from TABLE(l_recs);      
             -- open more ref cursors here before returning
         END test_proc;
    END;
    SET SERVEROUTPUT ON SIZE 1000000
    DECLARE
      l_cursor  test_refcursor_pkg.my_ref_cursor;
      l_ename   emp.ename%TYPE;
      l_empno   emp.empno%TYPE;
    BEGIN
      test_refcursor_pkg.test_proc (l_cursor);
      LOOP
        FETCH l_cursor
        INTO  l_empno, l_ename;
        EXIT WHEN l_cursor%NOTFOUND;
        DBMS_OUTPUT.PUT_LINE(l_ename || ' | ' || l_empno);
      END LOOP;
      CLOSE l_cursor;
    END;
    /

  • Associative Array with more than one field - retrieving as output parameter

    Hello,
    I'm developing an C# Application that is showing a datagrid with results from a PL/SQL procedure inside a Package.
    The .net project is in .net 4 and the DB is an oracle 10g.
    I have read the odp.net sample about the associative array. I could successfully pass as an input parameter a string[] and dealing with it inside my PL/SQL procedure.
    Now it become more complex to me because I would like to return an associative array defined like this :
    TYPE r_FinalExtract IS RECORD
    RecordmyTable myTable%ROWTYPE,
    Tel1 varchar2(25),
    Tel1Libelle varchar2(50),
    Tel2 varchar2(25),
    Tel2Libelle varchar2(50),
    Tel3 varchar2(25),
    Tel3Libelle varchar2(50),
    Tel4 varchar2(25),
    Tel4Libelle varchar2(50),
    Tel5 varchar2(25),
    Tel5Libelle varchar2(50),
    Email1 varchar2(50),
    Email1Libelle varchar2(50),
    Email2 varchar2(50),
    Email2Libelle varchar2(50)
    TYPE t_FinalExtract IS TABLE OF r_FinalExtract INDEX BY BINARY_INTEGER;
    You can guess my PL/SQL stored procedure is filling this collection.
    The spec of my procedure :
    PROCEDURE P_SELECTDATA( ptab_ListRef IN t_AssocArrayVarchar2, ptab_Result OUT t_FinalExtract );
    Unfortunately, in my .net project, I don't know how to deal with that.
    I tryed to add p_Result as an output parameter but you have to define the OracleCollectionType for that parameter and the array type is not the good one because my t_FinalExtract is not a simple array...
    I searched over the internet and the only one thread I could find is someone who was doing like me... and finally reply to his own thread 3 months later and said that he had to create CSV lines and return a table of varchar2...
    This is what I will do because I'm loosing time for finding the way to do it with my associative array, but if someone has the solution I would be glad to read it.
    Thanks in advance.

    For PL/SQL records, I would recommend using User-Defined Types (UDTs), rather than associative arrays.
    You can read more on how to use ODP.NET UDTs here:
    http://docs.oracle.com/cd/E20434_01/doc/win.112/e23174/featUDTs.htm#CJAGCAID
    Strictly speaking, ODP.NET doesn't support PL/SQL Records per se. Instead, ODP.NET supports building any generic UDT in the Oracle DB, which covers the effective functionality of a Record.
    If you want to walk through the process of taking a sample DB UDT, generating a .NET custom class, then passing an instance between DB and application, here's a tutorial that shows you how to do that:
    http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/dotnet/userdefinedtypes/userDefinedTypes.htm

  • Assigning a format to an output type while printing Hu label;s

    Hi Everyone,
    I am trying to see if there is a way to attach a format type to a output type which we are using to print HU barcoded labels...
    we have about 6 different formats one for a customer... so when we ar desigining an output type we need to figure how to append this format type to the custom Output type we are developing....
    I have looked at the handling units... there is a method to a assign bar code profile and formk to an output type... i dont have anything that allows me to embed a format type into an output type.... please help

    Variable "elist" is a collection of record, so you access an individual field of a given collection element by specifying the field name, not its position :
    DECLARE
      SUBTYPE t_rec IS TEST_TABLE%ROWTYPE;
      TYPE records_table IS TABLE OF t_rec;
      elist RECORDS_TABLE;
      CURSOR table_cursor IS SELECT * FROM TEST_TABLE WHERE rownum <= 20;
    BEGIN
      OPEN table_cursor;
      FETCH table_cursor BULK COLLECT INTO elist;
        FOR j IN 1..elist.COUNT
        LOOP
          elist(j).value1 := elist(j).value1 + 1;
        END LOOP;
      CLOSE table_cursor;
    END;Your second example is different as you're dealing with a collection of collections.

  • Merge Statement output

    Hi all,
    I am working on oracle9i
    I am using the Merge Statement to INS/UPD rows
    I am using loops to
    I am updating 29 rows as insert and 1 row a update
    Values are inserting and updating correctly in table
    But in Sql prompt
    I am getting the output as
    below
    12:03:54 SQL> execute Pr_Bdms_Cont_Insupd;
    1 rows merged.
    1 rows inserted.
    1 rows updated.
    PL/SQL procedure successfully completed.
    But i take out the loop i am getting exact result
    12:03:54 SQL> execute Pr_Bdms_Cont_Insupd;
    30 rows merged.
    29 rows inserted.
    1 rows updated.
    PL/SQL procedure successfully completed.
    Any help
    Below is my procedure
    and
    CREATE OR REPLACE PROCEDURE Pr_EMP_Insupd IS
    empID VARCHAR2(7);
    CURSOR C_empno IS SELECT empno FROM TEMP WHERE ROWNUM < 30;
    REC_BIN C_empid%ROWTYPE;
    BEGIN
    FOR REC_BIN IN C_empid LOOP
    empID := fn_emp_Id(REC_BIN.Bin);-- Calling function
    Merge INTO EMP E
    BGC
    USING (SELECT A.EMP_ID,B.SALARY,B.BONUS
    FROM EMP_IN A, TEMP B
    WHERE A.EMPNO = B.EMPNO
    AND A.EMP_ID = EMPID)NP
    ON(E.EMP_ID = NP.EMP_ID)
    WHEN MATCHED THEN UPDATE SET E.SALARY = NP.SALARY,
    E.BONUS = NP.BONUS
    WHEN NOT MATCHED THEN INSERT (E.EMP_ID,E.SALARY,E.BONUS,E.CREATED_DATE)
    VALUES (CASE Check_Upd_Ins.merge_counter(Check_Upd_Ins.c_inserting)
    WHEN 0 THEN E.EMP_ID
    END,
    E.SALARY,E.BONUS,SYSDATE);
    END LOOP;
    /* Use insert count... using ETL Package*/
    dbms_output.put_line(Check_Upd_Ins.get_merge_update_count(SQL%rowcount) || ' rows updated.');
    dbms_output.put_line(Check_Upd_Ins.get_merge_insert_count || ' rows inserted.');
    Check_Upd_Ins.reset_counters;
    COMMIT;
    EXCEPTION
    WHEN OTHERS THEN
    RAISE_APPLICATION_ERROR(-20000, SQLERRM(SQLCODE));
    END Pr_EMP_Insupd;

    Perhaps I can help you with this piece of code and this link :
    MERGE INTO bonuses D
    USING (SELECT employee_id, salary, department_id FROM employees
    WHERE department_id = 80) S
    ON (D.employee_id = S.employee_id)
    WHEN MATCHED THEN UPDATE SET D.bonus = D.bonus + S.salary*.01
    WHEN NOT MATCHED THEN INSERT (D.employee_id, D.bonus)
    VALUES (S.employee_id, S.salary*0.1);
    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/13_elems30.htm#37586
    Joel P�rez

  • DBMS_METADATA.GET_DDL - output trucating

    Hi,
    I am generating Database Package Scripts using the following.
    =====================================================
    set pagesize 0
    set long 90000
    set feedback off;
    column DDL format a80 WORD_WRAPPED
    spool FMONTUSER_PACKAGE.sql
    select dbms_metadata.get_ddl(object_type,object_name,owner) DDL from dba_objects
    where owner='FMONTUSER' and
    object_type in('PACKAGE');
    spool off;
    ============================================
    This is the last PROCEDURE of Last PAKCGE in FMONTUSER_PACKAGE.sql
    =============================================
    PROCEDURE insert_loan_year_end_data(argloan_id IN LOAN.LOAN_ID%TYPE,
    arg_temp_prio_end_row IN TEMP_PRIOR_YEAR_END%ROWTYPE)
    IS
    v_as_of_dt LOAN_YEAR_END_DATA.ASOFDATE%TYPE;
    BEGIN
    -- Insert the record into original loan table
    DBMS_OUTPUT.put_line ('before insert LOAN_YEAR_END_DATA');
    v_as_of_dt := arg_temp_prio_end_row.AS_OF_DATE;
    INSERT INTO LOAN_YEAR_END_DATA     VALUES(LOAN_YEAR_END_DATA_SEQ.NEXTVAL,argloan_id,
    arg_temp_
    prio_end_row.BEGINNING_PRINCIPAL_BAL,arg_temp_prio_end_row.YTD_PRINCIPAL_PAID,
    =============================================
    I am getting trucated some lines in this procedure.
    I increased 'set long 90000' to 'set long 100000'
    Still I am getting truncated output.
    Please help me to solve this.
    regards,
    Mathew

    Hi,
    This script I am using.
    =======================================
    set pagesize 0
    --set long 90000
    set long 2000000000
    set feedback off;
    column DDL format a80 WORD_WRAPPED
    EXECUTE dbms_metadata.set_transform_param(DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',true);
    EXECUTE dbms_metadata.set_transform_param(DBMS_METADATA.SESSION_TRANSFORM,'PRETTY',true);
    EXECUTE dbms_metadata.set_transform_param(DBMS_METADATA.SESSION_TRANSFORM,'CONSTRAINTS',true);
    EXECUTE dbms_metadata.set_transform_param(DBMS_METADATA.SESSION_TRANSFORM,'REF_CONSTRAINTS',false);
    EXECUTE dbms_metadata.set_transform_param( DBMS_METADATA.SESSION_TRANSFORM, 'CONSTRAINTS_AS_ALTER', false);
    EXECUTE dbms_metadata.set_transform_param( DBMS_METADATA.SESSION_TRANSFORM, 'STORAGE', false );
    EXECUTE dbms_metadata.set_transform_param( DBMS_METADATA.SESSION_TRANSFORM, 'SEGMENT_ATTRIBUTES', false );
    EXECUTE dbms_metadata.set_transform_param( DBMS_METADATA.SESSION_TRANSFORM, 'TABLESPACE', false );
    spool FMONTUSER_PACKAGE.sql
    REM -------------------------------------------------------------------------------------------------------
    REM FMONTUSER_PACKAGE.sql
    REM PACKAGE.sql
    select dbms_metadata.get_ddl(object_type,object_name,owner) DDL from dba_objects
    where owner='FMONTUSER' and
    object_type in('PACKAGE');
    spool off;
    regards
    Mathew

  • Printing the Package output from Anonymous block

    Hi,
    I need to call the below package from anonymous block and get the output.
    Could you let me know.
    I tried using this, but i don't get data.
    ===========Anonymous Block=====================================================================
    declare
    var              xxdc.xxdc_sr_log_his_pkg.sr_tbl_type;
    l_sr_idx_bi  BINARY_INTEGER := 0;
    BEGIN
    xxdc.xxdc_sr_log_his_pkg.service_record('14040',var);
    dbms_output.put_line('CLAIM_CREDIT_OFFERS  :'||var(l_sr_idx_bi).qa_credit_offers(l_sr_idx_bi).character1 );
    end;
    =============================================================================================
    ============================================================================================
    Package Spec
    TYPE cr_offer_type IS TABLE OF apps.qa_results_v%ROWTYPE  
    INDEX BY BINARY_INTEGER;
    TYPE sr_rec_type IS RECORD
    (task_status                      apps.jtf_task_statuses_tl.name%TYPE
    ,task_type                        apps.jtf_task_types_tl.name%TYPE
    ,qa_credit_offers                 cr_offer_type
    TYPE sr_tbl_type IS TABLE OF sr_rec_type
    INDEX BY BINARY_INTEGER;
    PROCEDURE  service_record(p_service_req_num IN  VARCHAR2
                                               ,p_service_req_tbl OUT sr_tbl_type
    Package Body
           FOR emp_row_rec IN cur_credit_off
           LOOP
             l_sr_tbl(l_sr_idx_bi).qa_credit_offers(l_sr_idx_bi).character1 := emp_row_rec.character1;
             --dbms_output.put_line( l_sr_tbl(l_sr_idx_bi).qa_credit_offers(l_sr_idx_bi).character1);   --commenting for testing
              l_sr_idx_bi := l_sr_idx_bi + 1;
           END LOOP;
          p_service_req_tbl := l_sr_tbl;
    =============================================================================================
    Thank

    Hi,
    Did you issue the SQL*Plus command
    SET  SERVEROUTPUT  ON
    or, if you're using some other front end, its equivalent?
    Can you ever see output from dbms_output?  For example, what happens when you run this?
    SET  SERVEROUTPUT  ON
    BEGIN
        dbms_output.put_line ('Hello, world!');
    END;
    Since I don't have your tables, I can't actually run your code.  If you'd post CREATE TABLE and INSERT statements, or re-write the package to reference commonly available tables, such as those in the scott schema, then I could test it.

  • CSV file output!!

    Hello, i have a working select statment, and i have try to adapt an old CSV output file i have used before, but i am gettin the following error:
    SQL> @$ORBEXE/sup.sql
    TYPE wk_tab IS TABLE OF read_input%ROWTYPE
    ERROR at line 98:
    ORA-06550: line 98, column 4:
    PL/SQL: ORA-00933: SQL command not properly ended
    ORA-06550: line 8, column 1:
    PL/SQL: SQL Statement ignored
    There is probably a few more mistakes, but il start with this one.
    Thanks CP
    DECLARE
         v_count NUMBER(10) := 0;
         EXEC_file UTL_FILE.FILE_TYPE;
       CURSOR read_input
       IS
    SELECT COALESCE(ilv1.btr_pla_refno,ilv2.pla_refno,ilv3.PLP_PLA_REFNO) refno,  ilv1.par_per_surname, ilv1.adr_line_all, ilv1.description, ilv1.SCHEME_NO, ilv1.btr_cpa_cla_refno, ilv1.susp
    ,ilv2.pla_par_refno,  ilv3.PLP_BAK_ACCOUNT_NUMBER
    FROM (
    select distinct benefit_transactions.btr_cpa_cla_refno
                         ,parties.par_per_surname
                   ,addresses.adr_line_all
                   ,rbx151_schemes_data.description
                      ,rbx151_schemes_data.SCHEME_NO
                   ,btr_pla_refno
                      ,nvl2 (claim_parts.cpa_suspended_date, 'Y', 'N')        AS SUSP
      from fsc.address_usages
          ,fsc.address_elements
          ,fsc.addresses
          ,fsc.parties
          ,fsc.properties
          ,claim_periods
          ,benefit_transactions
          ,rbx151_schemes_cl
          ,rbx151_schemes_data
          ,claim_roles
          ,claim_property_occupancies
            ,claim_hb_payment_schemes
            ,claims
              ,claim_parts
    where address_elements.ael_street_index_code = addresses.adr_ael_street_index_code
       and addresses.adr_refno = address_usages.aus_adr_refno
       and properties.pro_refno = address_usages.aus_pro_refno
       and properties.pro_refno = claim_property_occupancies.cpo_pro_refno
       and rbx151_schemes_cl.scheme_no = rbx151_schemes_data.scheme_no
       and claim_roles.cro_crt_code = 'CL'
       and claim_roles.cro_end_date is null
       and claim_periods.cpe_cpa_cla_refno = claim_roles.cro_cla_refno
       and parties.par_refno = claim_roles.cro_par_refno
       and claim_property_occupancies.cpo_cla_refno = claim_periods.cpe_cpa_cla_refno
       and claim_property_occupancies.cpo_cla_refno = benefit_transactions.btr_cpa_cla_refno
       and claim_periods.cpe_cpa_cla_refno = benefit_transactions.btr_cpa_cla_refno
       and benefit_transactions.btr_cpa_cla_refno = rbx151_schemes_cl.claim_no
       and claim_roles.cro_cla_refno = claim_property_occupancies.cpo_cla_refno
       and claim_periods.cpe_cpo_pro_refno = rbx151_schemes_cl.pro_refno
       and claim_periods.cpe_cpa_cpy_code = 'HB'
       and claim_periods.cpe_cps_code = 'A'
       and claim_periods.cpe_cpa_cpy_code = benefit_transactions.btr_cpa_cpy_code
       and rbx151_schemes_cl.claim_no like '406%'
      -- and benefit_transactions.btr_cpa_cla_refno = '307801231'
    --   and parties.par_per_surname is not null
       and claim_property_occupancies.cpo_pro_refno = rbx151_schemes_cl.pro_refno
       and claim_periods.cpe_cpa_cla_refno = claim_parts.cpa_cla_refno   --MORE ADDED CODE!!
       and claims.cla_refno = claim_hb_payment_schemes.chp_cla_refno  --ADDED CODE!!!
       AND claims.cla_refno = claim_roles.cro_cla_refno  --ADDED CODE!!!
       and (claim_hb_payment_schemes.chp_pty_code ='CL' or claim_hb_payment_schemes.chp_pty_code ='LL') --ADDED CODE
       and claim_periods.cpe_created_date =
              (select max(c2.cpe_created_date)
                 from claim_periods c2
                where c2.cpe_cpa_cla_refno = claim_periods.cpe_cpa_cla_refno
                  and claim_periods.cpe_cpa_cpy_code = c2.cpe_cpa_cpy_code )
       and claim_property_occupancies.cpo_created_date =
              (select max(cp2.cpo_created_date)
                 from claim_property_occupancies cp2
                where cp2.cpo_cla_refno = claim_property_occupancies.cpo_cla_refno)
       and benefit_transactions.btr_created_date =
              (select max(b2.btr_created_date)
                 from benefit_transactions b2
               where b2.btr_cpa_cla_refno = benefit_transactions.btr_cpa_cla_refno)
      and claim_parts.CPA_CREATED_DATE =
              (select max(c1.CPA_CREATED_DATE)
                 from claim_parts c1
               where c1.CPA_CREATED_DATE = claim_parts.CPA_CREATED_DATE)) ilv1
    full outer join
    (select            private_ll_accounts.pla_refno,
                 private_ll_accounts.pla_par_refno
       from        private_ll_accounts
      where  private_ll_accounts.pla_created_date =
              (select max(p2.pla_created_date)
                from private_ll_accounts p2
              where p2.pla_refno = private_ll_accounts.pla_refno
                 and private_ll_accounts.pla_refno = p2.pla_refno (+))) ilv2
                ON (ilv1.btr_pla_refno = ilv2.pla_refno)
    full outer JOIN
    (select distinct private_ll_pay_schemes.PLP_PLA_REFNO, private_ll_pay_schemes.PLP_BAK_ACCOUNT_NUMBER
    from   private_ll_pay_schemes
    where  private_ll_pay_schemes.PLP_START_DATE =
             (select max(p1.PLP_START_DATE)
                from private_ll_pay_schemes p1
               where p1.PLP_PLA_REFNO = private_ll_pay_schemes.PLP_PLA_REFNO
                 and private_ll_pay_schemes.PLP_PLA_REFNO = p1.PLP_PLA_REFNO (+))) ilv3
    ON (ilv2.pla_refno =ilv3.PLP_PLA_REFNO)
    WHERE (ilv1.par_per_surname IS not NULL)
    --or ilv1.btr_pla_refno IS NULL and ilv3.PLP_PLA_REFNO IS NOT NULL)
    --and ( -- OR ilv2.pla_refno IS NOT NULL OR ilv3.PLP_PLA_REFNO IS NOT NULL);
       TYPE wk_tab IS TABLE OF read_input%ROWTYPE
          INDEX BY PLS_INTEGER;
       wk   wk_tab;
    BEGIN
       exec_file := utl_file.fopen('/spp/spool/RBlive/rr_output', 'sup.txt', 'W');
       OPEN read_input;
       LOOP
          EXIT WHEN read_input%NOTFOUND;
          FETCH read_input
          BULK COLLECT INTO wk LIMIT 100;
          FOR i IN 1 .. wk.count
          LOOP
         v_count :=0;
             utl_file.put_line(exec_file, wk(i).refno||','||wk(i).par_per_surname||','||wk(i).adr_line_all||','||wk(i).description||','||wk(i).SCHEME_NO||','||wk(i).btr_cpa_cla_refno||','||wk(i).susp||','||wk(i).PLA_PAR_REFNO||','||wk(i).PLP_BAK_ACCOUNT_NUMBER);
          END LOOP;
       END LOOP;
       CLOSE read_input;
       utl_file.fclose(exec_file);
    END;
    /

    Hello, first off, you need to change:
    WHERE (ilv1.par_per_surname IS not NULL)
    --or ilv1.btr_pla_refno IS NULL and ilv3.PLP_PLA_REFNO IS NOT NULL)
    --and ( -- OR ilv2.pla_refno IS NOT NULL OR ilv3.PLP_PLA_REFNO IS NOT NULL);To:
    WHERE (ilv1.par_per_surname IS not NULL);
    --or ilv1.btr_pla_refno IS NULL and ilv3.PLP_PLA_REFNO IS NOT NULL)
    --and ( -- OR ilv2.pla_refno IS NOT NULL OR ilv3.PLP_PLA_REFNO IS NOT NULL);(You were missing a semi-colon since it was commented out)

  • PLS-801 internal error when returnig rowtype in select clause

    Hi,
    looks like the following case is not handled in version 11.1.0.6.
    I created a function which returns a ROWTYPE
    and when calling this function from a simple sql statement an internal error occurs.
    create table testing as select 1 id, 'A' val from dual;
    create or replace function ret_row return testing%rowtype is
    cursor cur_t is
    select * from testing;
    r testing%rowtype;
    begin
    open cur_t;
    fetch cur_t into r;
    close cur_t;
    return r;
    end;
    select ret_row from dual; when executing this select statement the following error occurs:
    SQL> select ret_row from dual
    ERROR at line 1:
    ORA-06553: PLS-801: internal error [55018]Didn't find any notes from the metalink about this error.
    Ants

    Perhaps in this specific case you can view your output as ->
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    5 rows selected.
    Elapsed: 00:00:01.48
    satyaki>
    satyaki>
    satyaki>create table testing as select 1 id, 'A' val from dual;
    Table created.
    Elapsed: 00:00:03.16
    satyaki>
    satyaki>set lin 80
    satyaki>
    satyaki>desc testing;
    Name                                      Null?    Type
    ID                                                 NUMBER
    VAL                                                CHAR(1)
    satyaki>
    satyaki>
    satyaki>set lin 310
    satyaki>
    satyaki>create or replace function ret_row return testing%rowtype is
      2  cursor cur_t is
      3   select * from testing;
      4   r testing%rowtype;
      5  begin
      6   open cur_t;
      7   fetch cur_t into r;
      8   close cur_t;
      9   return r;
    10  end;
    11  /
    Function created.
    Elapsed: 00:00:03.06
    satyaki>
    satyaki>
    satyaki>select ret_row from dual;
    select ret_row from dual
    ERROR at line 1:
    ORA-00902: invalid datatype
    Elapsed: 00:00:00.25
    satyaki>
    satyaki>declare
      2       y testing%rowtype;
      3  begin
      4       y := ret_row;
      5       for i in 1..y.ID
      6       loop
      7         dbms_output.put_line(y.ID);
      8         dbms_output.put_line(y.VAL);
      9       end loop;
    10  end;
    11  /
    1
    A
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.16
    satyaki>
    satyaki>Regards.
    Satyaki De.

  • Procedure output like a query in SQL developer?

    Hi!
    How can a PL procedure create output like a query in SQL developer?
    This block
    begin
    for record in (
    select * from my_db
    loop
    dbms_output.put_line(record.name ' ' || record.address)
    end loop;
    end;
    would print a of names and adresses in my_db. However, output sent to a query result window which would be the result of
    select name,address from my_db;
    How could I make the PL block behave the same way as the SQL query, i.e. present its output in a query result window?

    Welcome to the forum!
    Please provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION) wheneve you ask a question.
    Do you mean query a procedure as if it were a table?
    You can do that with a pipelined function. Here is sample code you can test using the SCOTT schema
    -- type to match emp record
    create or replace type emp_scalar_type as object
      (EMPNO NUMBER(4) ,
       ENAME VARCHAR2(10),
       JOB VARCHAR2(9),
       MGR NUMBER(4),
       HIREDATE DATE,
       SAL NUMBER(7, 2),
       COMM NUMBER(7, 2),
       DEPTNO NUMBER(2)
    -- table of emp records
    create or replace type emp_table_type as table of emp_scalar_type
    -- pipelined function
    create or replace function get_emp( p_deptno in number )
      return emp_table_type
      PIPELINED
      as
       TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE;
        emp_cv EmpCurTyp;
        l_rec  emp%rowtype;
      begin
        open emp_cv for select * from emp where deptno = p_deptno;
        loop
          fetch emp_cv into l_rec;
          exit when (emp_cv%notfound);
          pipe row( emp_scalar_type( l_rec.empno, LOWER(l_rec.ename),
              l_rec.job, l_rec.mgr, l_rec.hiredate, l_rec.sal, l_rec.comm, l_rec.deptno ) );
        end loop;
        return;
      end;
      /Then you can query the function as if it were a table
    select * from table(get_emp(20))Is that what you were looking for?

  • Split Output from Select into 2 different Cols

    Hi,
    I am new to oracle dev. Env Oracle 10g R2
    I need a help with the following.
    I have a select query that returns comma separated values.
    Column LIST1 in table svp_1.
    This needs to hold that data returned by the select query.
    Datatype of Column LIST1 varchar2(4000)
    I get the follwing error.
    ORA-19011: Character string buffer too small
    CREATE OR REPLACE PROCEDURE
    sale_temp( pType in Char,lDate in date) as
    cnt number;
    v_error_code NUMBER;
    v_error_msg VARCHAR2(2000);
    cursor c1 is select svp
    from sale
    where type = pType
    var1 c1%ROWTYPE;
    BEGIN
    UPDATE svp_1
    SET LIST1 = ( SELECT LTRIM( xmlagg (xmlelement (c, RTRIM(RELATED_SVP) || ',')).extract ('//text()'), ',' ) AS RELATED_SVP from (
    SELECT rtrim(BASE_SVP) BASE_SVP,
    rtrim(RELATED_SVP) RELATED_SVP
    from
    svp_enc se
    where
    se.effective date<= pDate
    and (se.expiration_date is null or se.expiration_date > plDate )
    and se.base_svp in
    ( var1.svp
    and se.RELATION_TYPE = '4'
    )group by base_svp)
    WHERE type = pType
    commit;
    dbms_output.put_line('UPDATE done' );
    end;
    end loop;
    close c1;
    END ;
    My requirement :
    In need to capture the data from the select query and update the column.
    The data needs to be returned as comma separated values.
    This data can also be split into 2 columns.....ie data split and updated into 2 cols ie LIST1 AND LIST2 ( can be added to existing table).
    What is the best way to do this?
    Is the below approach possilble?
    LOOP through cursor ...check the length of data....for the select query ....check length .if > 3990 byte.....then write into 2 plsql variables.....and update 2 cols....
    Is this apporach right, if so how to do that in the procedure ? Please give an example...
    Are there any other approaches...?
    All I need is to Split Output from Select into 2 different columns and avoid the ORA-19011: Character string buffer too small error.
    Thanks in advance.

    Re: ORA-19011: Character string buffer too small

Maybe you are looking for