Simplel complex report query

hi guru's
i had prepared two complex reports seperately having the same Selection-screen , internal tables and declerations...now i have to combine both the reports into one single report....based upon <b>one field (i.e, filed PROCESS_TYPE)</b> of Selection-criteria(i.e, S_PR_TYP ) i have to display 2 outputs..One for SHC and another for CONF.....But the Logic  and Header display for the 2 output's is different   ........please let me know where should i write the logic ....and how the logic should be build....
the code is as follows :
<u><b>The code which is common for both the reports:</b></u>
$$********************************************************************
$$    TABLES DECLERATION
$$********************************************************************
TABLES: crmd_orderadm_h,
        crmd_orderadm_i,
        bbp_pdigp.
$$********************************************************************
$$  TYPE-POOLS
$$********************************************************************
TYPE-POOLS: slis, list.
$$********************************************************************
$$    GLOBAL TYPES
$$********************************************************************
TYPES: BEGIN OF y_str1,
       CLIENT         TYPE CRMD_ORDERADM_H-CLIENT,
       guid           TYPE crmd_orderadm_h-guid,
       object_id      TYPE crmd_orderadm_h-object_id,
       object_type    TYPE crmd_orderadm_h-object_type,
       process_type   TYPE crmd_orderadm_h-process_type,
       created_at     TYPE crmd_orderadm_h-created_at,
       changed_at     TYPE crmd_orderadm_h-changed_at,
       archiving_flag TYPE crmd_orderadm_h-archiving_flag,
       deliv_date     TYPE bbp_pdigp-deliv_date,
       final_entry    TYPE bbp_pdigp-final_entry,
       del_ind        TYPE bbp_pdigp-del_ind,
       END OF y_str1.
TYPES: BEGIN OF y_str2,
       guid1          TYPE crmd_orderadm_h-guid,
       object_id      TYPE crmd_orderadm_h-object_id,
       object_type    TYPE crmd_orderadm_h-object_type,
       process_type   TYPE crmd_orderadm_h-process_type,
       created_at     TYPE crmd_orderadm_h-created_at,
       changed_at     TYPE crmd_orderadm_h-changed_at,
       archiving_flag TYPE crmd_orderadm_h-archiving_flag,
       guid2          TYPE crmd_orderadm_i-guid,
       header         TYPE crmd_orderadm_i-header,
       guid3          TYPE bbp_pdigp-guid,
       deliv_date     TYPE bbp_pdigp-deliv_date,
       final_entry    TYPE bbp_pdigp-final_entry,
       del_ind        TYPE bbp_pdigp-del_ind,
       END OF y_str2.
$$********************************************************************
$$    GLOBAL CONSTANTS
$$********************************************************************
CONSTANTS: C_BLANK_F(1)           TYPE C VALUE 'X',
           C_DEL_IND_F(1)         TYPE C VALUE 'X',
           C_ARCHIVING_FLAG(1)    TYPE C VALUE 'X',
           C_FINAL_ENTRY_F(1)     TYPE C VALUE 'X',
           C_FINAL_ENTRY_SPACE(1) TYPE C VALUE ' ',
           C_CBA_SPACE(1)         TYPE C VALUE ' ',
           C_DEL_SPACE(1)         TYPE C VALUE ' '.
$$********************************************************************
$$    Global Elementary Variables
$$********************************************************************
DATA: w_ld_lines                 TYPE i,
      w_ld_linesc(10)            TYPE c,
      w_del_ind                  TYPE c,
      w_final_entry              TYPE c,
      w_COUNT_cba                TYPE I VALUE 0,
      w_count_f                  TYPE I VALUE 0,
      W_BLANK_F                  TYPE C,
      W_FINAL_ENTRY_F            TYPE C,
      W_DEL_COUNT                TYPE I VALUE 0,
      W_PER_CBA1                 TYPE P decimals 3,
      W_PER_CBA                  TYPE P decimals 2,
      W_PER_E_LINE               TYPE I,
      W_N                        TYPE I.
$$********************************************************************
$$    GLOBAL INTERNAL TABLES (custom structure)
$$********************************************************************
DATA:   t_str_sc1 TYPE STANDARD TABLE OF y_str1 INITIAL SIZE 1.
DATA:   t_str_sc2 TYPE STANDARD TABLE OF y_str2 INITIAL SIZE 1.
DATA:   t_header      TYPE   slis_t_listheader,
        w_header      TYPE   slis_listheader,
        e_line        LIKE   w_header-info.
DATA:   v_index       LIKE SY-TABIX.
        v_index = '1'.
$$********************************************************************
$$    GLOBAL FIELD-SYMBOLS
$$********************************************************************
FIELD-SYMBOLS: <FS_STR1> TYPE Y_STR1,
               <FS_STR2> TYPE Y_STR2.
$$********************************************************************
$$    PARAMETERS & SELECT-OPTIONS
$$********************************************************************
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_scno   FOR crmd_orderadm_h-object_id,
                s_pr_typ FOR crmd_orderadm_h-process_type NO INTERVALS NO DATABASE SELECTION NO-EXTENSION DEFAULT 'SHC',
                s_change FOR crmd_orderadm_h-changed_at.
SELECTION-SCREEN END OF BLOCK b1.
$$********************************************************************
$$    START-OF-SELECTION
$$********************************************************************
START-OF-SELECTION.
  REFRESH t_str_sc1.
  SELECT client
         guid
         object_id
         object_type
         process_type
         created_at
         changed_at
         archiving_flag
         FROM crmd_orderadm_h INTO TABLE t_str_sc1
         WHERE object_id IN s_scno AND  changed_at IN s_change AND process_type IN s_pr_typ.
  IF sy-subrc <> 0.
    MESSAGE I002.
  ENDIF.
  LOOP AT t_str_sc1 ASSIGNING <FS_STR1>.
    REFRESH t_str_sc2.
    SELECT a~guid
           a~object_id
           a~object_type
           a~process_type
           a~created_at
           a~changed_at
           a~archiving_flag
           b~guid
           b~header
           c~guid
           c~deliv_date
           c~final_entry
           c~del_ind
      INTO TABLE t_str_sc2
      FROM crmd_orderadm_h AS a INNER JOIN crmd_orderadm_i AS b
        ON aguid eq bheader INNER JOIN bbp_pdigp AS c
        ON bguid eq cguid
     WHERE a~guid eq <FS_STR1>-guid.
<u><b>THE LOGIC FOR FIRST REPORT:</b></u>
*"logic for displaying Delivery date at Header level
      SORT T_STR_SC2 BY DELIV_DATE.
      DESCRIBE TABLE T_STR_SC2 LINES W_N.
     READ TABLE T_STR_SC2 WITH KEY DELIV_DATE = T_STR_SC2-DELIV_DATE INTO <FS_STR2>-deliv_date.
      READ TABLE T_STR_SC2 INDEX v_index ASSIGNING <FS_STR2>.
      IF SY-SUBRC = 0.
        <FS_STR1>-deliv_date = <FS_STR2>-deliv_date.
        MODIFY  T_STR_SC1 FROM <FS_STR1> TRANSPORTING DELIV_DATE.
      ENDIF.
*"Setting up the flags for the entire items in CRMD_ORDERADM_H as per the scenario
    LOOP AT T_STR_SC2 ASSIGNING <FS_STR2> WHERE HEADER EQ <FS_STR1>-GUID.
      IF <FS_STR2>-DEL_IND NE 'X'.
        IF <FS_STR2>-FINAL_ENTRY NE 'X'.
          W_BLANK_f = C_BLANK_F.
        ELSE.
          W_FINAL_ENTRY_F = C_FINAL_ENTRY_F.
        ENDIF.
      ENDIF.
    ENDLOOP.
*"Logic started at item level
    LOOP AT T_STR_SC2 ASSIGNING <FS_STR2> WHERE HEADER EQ <FS_STR1>-GUID.
      IF W_BLANK_F NE 'X'.
        IF W_FINAL_ENTRY_F NE 'X'.
*" Displaying the status for Del 'X' , Final_entry ' ', Archive_flag 'X'.
          <FS_STR1>-DEL_IND = C_DEL_IND_F.
         W_DEL_COUNT = W_DEL_COUNT + 1.
          <FS_STR1>-FINAL_ENTRY = C_FINAL_ENTRY_SPACE.
          <FS_STR1>-ARCHIVING_FLAG = C_ARCHIVING_FLAG.
         w_COUNT_cba = w_COUNT_cba + 1.
          MODIFY  T_STR_SC1 FROM <FS_STR1> TRANSPORTING DEL_IND FINAL_ENTRY ARCHIVING_FLAG.
        ELSE.
*" Displaying the status for Del ' ' , Final_entry 'X', Archive_flag 'X'.
          <FS_STR1>-FINAL_ENTRY = C_FINAL_ENTRY_F.
         w_count_f  = w_count_f  + 1.
          <FS_STR1>-DEL_IND = C_DEL_SPACE.
          <FS_STR1>-ARCHIVING_FLAG = C_ARCHIVING_FLAG.
         w_COUNT_cba = w_COUNT_cba + 1.
          MODIFY  T_STR_SC1 FROM <FS_STR1> TRANSPORTING FINAL_ENTRY DEL_IND ARCHIVING_FLAG.
        ENDIF.
      ELSE.
*" Displaying the status for Del ' ' , Final_entry ' ', Archive_flag ' '.
        <FS_STR1>-DEL_IND = C_DEL_SPACE.
        <FS_STR1>-FINAL_ENTRY = C_FINAL_ENTRY_SPACE.
        <FS_STR1>-ARCHIVING_FLAG = C_CBA_SPACE.
        MODIFY  T_STR_SC1 FROM <FS_STR1> TRANSPORTING DEL_IND FINAL_ENTRY ARCHIVING_FLAG .
      ENDIF.
    ENDLOOP.    "end of t_str_sc2
    if  <FS_STR1>-DEL_IND eq C_DEL_IND_F.
         W_DEL_COUNT = W_DEL_COUNT + 1.
    endif.
   if <FS_STR1>-FINAL_ENTRY eq C_FINAL_ENTRY_F.
            w_count_f  = w_count_f  + 1.
   endif.
  if  <FS_STR1>-ARCHIVING_FLAG eq C_ARCHIVING_FLAG.
           w_COUNT_cba = w_COUNT_cba + 1.
    endif.
    CLEAR: W_BLANK_F , W_FINAL_ENTRY_F.
*"Logic ended at item level
  ENDLOOP.    "end of t_str_sc1
*" when Transaction type is SHC
IF <FS_STR1>-process_type EQ 'SHC'.
DESCRIBE TABLE t_str_sc1 LINES w_ld_lines.
  w_ld_linesc = w_ld_lines.
  CONCATENATE ' TOTAL NO OF RECORDS SELECTED:' w_ld_linesc INTO e_line SEPARATED BY space.
*" Percentage of Archived SC's
  W_PER_E_LINE = w_ld_lines.
  W_PER_CBA1 = W_COUNT_CBA / W_PER_E_LINE.
  W_PER_CBA = W_PER_CBA1 * 100.
*" Displaying the total no of records fetched for DB
  FORMAT COLOR 7.
  WRITE:/9 e_line .
  WRITE:/10 'TOTAL NO OF FINAL ENTRIES SELECTED:',        w_count_f.
  WRITE:/10 'TOTAL NO OF DELETE ENTRIES SELECTED:',       W_DEL_COUNT.
  WRITE:/10 'TOTAL NO OF ENTRIES SELECTED FOR ARCHIVING:',w_COUNT_cba.
  SKIP.
  WRITE:/10 'PERCENTAGE OF CAN BE ARCHIVED:',W_PER_CBA,'%'.
  FORMAT COLOR 3.
  SKIP.
  WRITE:/30 '#### SC HAVING FINAL ENTRY INDICATOR FOR ALL ITEM IN SRM #####'.
  FORMAT COLOR OFF.
  WRITE:/30(63) SY-ULINE.
  ULINE.
*" Displaying Headings for the Report
NEW-LINE SCROLLING.
  WRITE:/3        'Transaction No',                          18  sy-vline,
         19       'Transaction Type',                        36  sy-vline,
         37       'Business Trans.Cat',                      56  sy-vline,
         57       'Created On',                              68  sy-vline,
         69(10)   'Changed On',                              84  sy-vline,
         85       'Delivery date',                           99  sy-vline,
        100       'Final Entry Ind',                        115  sy-vline,
        116       'Deletion Ind',                           129  sy-vline,
        130       'Can be Archived',                        146  sy-vline.
SET LEFT SCROLL-BOUNDARY COLUMN 19.
  ULINE.
$$********************************************************************
$$    DISPLAY DATA AT HEADER LEVEL FOR SHC
$$********************************************************************
*" Sort the SC in Sequence
  SORT t_str_sc1 BY object_id.
  IF SY-SUBRC = 0.
*" Displaying the Report at Header level
    LOOP AT t_str_sc1 ASSIGNING <FS_STR1>.
      IF NOT <FS_STR1>-archiving_flag IS INITIAL.
        FORMAT COLOR 7.
      ELSE.
        FORMAT COLOR 3.
      ENDIF.
  WRITE:/3        <FS_STR1>-object_id,                       18  sy-vline,
         19       <FS_STR1>-process_type,                    36  sy-vline,
         37       <FS_STR1>-object_type,                     56  sy-vline,
         57       <FS_STR1>-created_at,                      68  sy-vline,
         69(10)   <FS_STR1>-changed_at,                      84  sy-vline,
         85       <FS_STR1>-deliv_date,                      99  sy-vline,
        100       <FS_STR1>-final_entry,                    115  sy-vline,
        116       <FS_STR1>-del_ind,                        129  sy-vline,
        130       <FS_STR1>-archiving_flag,                 146  sy-vline.
    ENDLOOP.   "end of t_str_sc1 displaying at header level
  ENDIF.    "End of SY-SUBRC
*ENDCASE.
ENDIF.   "End of displaying Transaction type as SHC
*" when Transaction type is CONF
IF <FS_STR1>-process_type EQ 'CONF'.
  DESCRIBE TABLE t_str_sc1 LINES w_ld_lines.
  w_ld_linesc = w_ld_lines.
  CONCATENATE ' TOTAL NO OF RECORDS SELECTED:' w_ld_linesc INTO e_line SEPARATED BY space.
*" Percentage of Archived SC's
  W_PER_E_LINE = w_ld_lines.
  W_PER_CBA1 = W_COUNT_CBA / W_PER_E_LINE.
  W_PER_CBA = W_PER_CBA1 * 100.
*" Displaying Headings for the Report
*" Displaying the total no of records fetched for DB
  FORMAT COLOR 7.
  WRITE:/9 e_line .
WRITE:/10 'TOTAL NO OF FINAL ENTRIES SELECTED:',        w_count_f.
  WRITE:/10 'TOTAL NO OF DELETE ENTRIES SELECTED:',       W_DEL_COUNT.
  WRITE:/10 'TOTAL NO OF ENTRIES SELECTED FOR ARCHIVING:',w_COUNT_cba.
  SKIP.
  WRITE:/10 'PERCENTAGE OF CAN BE ARCHIVED:',W_PER_CBA,'%'.
  FORMAT COLOR 3.
  SKIP.
  WRITE:/30 '#### SC HAVING FINAL ENTRY INDICATOR FOR ALL ITEM IN SRM #####'.
  FORMAT COLOR OFF.
  WRITE:/30(63) SY-ULINE.
  ULINE.
NEW-LINE SCROLLING.
  WRITE:/3        'Transaction No',                          18  sy-vline,
         19       'Transaction Type',                        36  sy-vline,
         37       'Business Trans.Cat',                      56  sy-vline,
         57       'Created On',                              68  sy-vline,
         69(10)   'Changed On',                              84  sy-vline,
         85       'Delivery date',                           99  sy-vline,
       100       'Final Entry Ind',                        115  sy-vline,
        100       'Deletion Ind',                           112  sy-vline,
        113       'Can be Archived',                        129  sy-vline.
SET LEFT SCROLL-BOUNDARY COLUMN 19.
  ULINE.
*$$********************************************************************
*$$    DISPLAY DATA AT HEADER LEVEL
*$$********************************************************************
*" Sort the SC in Sequence
  SORT t_str_sc1 BY object_id.
  IF SY-SUBRC = 0.
*" Displaying the Report at Header level
    LOOP AT t_str_sc1 ASSIGNING <FS_STR1>.
      IF NOT <FS_STR1>-archiving_flag IS INITIAL.
        FORMAT COLOR 7.
      ELSE.
        FORMAT COLOR 3.
      ENDIF.
  WRITE:/3        <FS_STR1>-object_id,                       18  sy-vline,
         19       <FS_STR1>-process_type,                    36  sy-vline,
         37       <FS_STR1>-object_type,                     56  sy-vline,
         57       <FS_STR1>-created_at,                      68  sy-vline,
         69(10)   <FS_STR1>-changed_at,                      84  sy-vline,
         85       <FS_STR1>-deliv_date,                      99  sy-vline,
       100       <FS_STR1>-final_entry,                    115  sy-vline,
        100       <FS_STR1>-del_ind,                        112  sy-vline,
        113       <FS_STR1>-archiving_flag,                 129  sy-vline.
    ENDLOOP.   "end of t_str_sc1 displaying
  ENDIF.  "End of SY-SUBRC
ENDIF.  "End of displaying Transaction type as CONF
<b><u>
THE LOGIC FOR THE SECOND REPORT</u></b>
LOOP AT t_str_sc1 ASSIGNING <FS_STR1>.
      REFRESH t_str_sc2.
      SELECT a~guid
             a~object_id
             a~object_type
             a~process_type
             a~created_at
             a~changed_at
             a~archiving_flag
             b~guid
             b~header
             c~guid
             c~deliv_date
             c~final_entry
             c~del_ind
        INTO TABLE t_str_sc2
        FROM crmd_orderadm_h AS a INNER JOIN crmd_orderadm_i AS b
          ON aguid eq bheader INNER JOIN bbp_pdigp AS c
          ON bguid eq cguid
       WHERE a~guid eq <FS_STR1>-guid.
       IF NOT t_str_sc2[] is INITIAL.
      LOOP AT T_STR_SC2 ASSIGNING <FS_STR2>.
       IF <FS_STR2>-DEL_IND NE C_DEL_SPACE.        " if x
          <FS_STR2>-DEL_IND = C_DEL_IND_F.
          <FS_STR2>-ARCHIVING_FLAG = C_ARCHIVING_FLAG.
          MODIFY T_STR_SC2 FROM <FS_STR2> .
        ELSE.         "if ' '
          EXIT.
        ENDIF.
      ENDLOOP.    "End loop of t_str_sc2
      MOVE <FS_STR2>-DEL_IND TO <FS_STR1>-DEL_IND.
      MOVE <FS_STR2>-ARCHIVING_FLAG TO <FS_STR1>-ARCHIVING_FLAG.
      MODIFY T_STR_SC1 FROM <FS_STR1>.
    ELSE.   " For sy-subrc
      <FS_STR1>-REMARKS = c_itnf.
      MODIFY T_STR_SC1 FROM <FS_STR1>.
    ENDIF.    " End of sy-subrc
  IF <FS_STR1>-DEL_IND eq C_DEL_IND_F.
         W_DEL_COUNT = W_DEL_COUNT + 1.
  ENDIF.
  IF  <FS_STR1>-ARCHIVING_FLAG eq C_ARCHIVING_FLAG.
        w_COUNT_cba = w_COUNT_cba + 1.
  ENDIF.
  ENDLOOP.  "End loop of t_str_sc1
********************************" when Transaction type is CONF
*******************************IF <FS_STR1>-process_type EQ 'CONF'.
  DESCRIBE TABLE t_str_sc1 LINES w_ld_lines.
  w_ld_linesc = w_ld_lines.
  CONCATENATE ' TOTAL NO OF RECORDS SELECTED:' w_ld_linesc INTO e_line SEPARATED BY space.
*" Percentage of Archived SC's
  W_PER_E_LINE = w_ld_lines.
  W_PER_CBA1 = W_COUNT_CBA / W_PER_E_LINE.
  W_PER_CBA = W_PER_CBA1 * 100.
*" Displaying Headings for the Report
*" Displaying the total no of records fetched for DB
  FORMAT COLOR 7.
  WRITE:/9 e_line .
WRITE:/10 'TOTAL NO OF FINAL ENTRIES SELECTED:',        w_count_f.
  WRITE:/10 'TOTAL NO OF DELETE ENTRIES SELECTED:',       W_DEL_COUNT.
  WRITE:/10 'TOTAL NO OF ENTRIES SELECTED FOR ARCHIVING:',w_COUNT_cba.
  SKIP.
  WRITE:/10 'PERCENTAGE OF CAN BE ARCHIVED:',W_PER_CBA,'%'.
  FORMAT COLOR 3.
  SKIP.
  WRITE:/30 '#### SC HAVING FINAL ENTRY INDICATOR FOR ALL ITEM IN SRM #####'.
  FORMAT COLOR OFF.
  WRITE:/30(63) SY-ULINE.
  ULINE.
  NEW-LINE SCROLLING.
  WRITE:/3        'Transaction No',                          18  sy-vline,
         19       'Transaction Type',                        36  sy-vline,
         37       'Business Trans.Cat',                      56  sy-vline,
         57       'Created On',                              68  sy-vline,
         69(10)   'Changed On',                              84  sy-vline,
        100       'Deletion Ind',                           112  sy-vline,
        113       'Can be Archived',                        129  sy-vline,
        130       'Remarks',                                 150  sy-vline.
  SET LEFT SCROLL-BOUNDARY COLUMN 19.
  ULINE.
*$$********************************************************************
*$$    DISPLAY DATA AT HEADER LEVEL
*$$********************************************************************
*" Sort the SC in Sequence
  SORT t_str_sc1 BY object_id.
  IF SY-SUBRC = 0.
*" Displaying the Report at Header level
    LOOP AT t_str_sc1 ASSIGNING <FS_STR1>.
      IF NOT <FS_STR1>-archiving_flag IS INITIAL.
        FORMAT COLOR 7.
      ELSE.
        FORMAT COLOR 3.
      ENDIF.
      WRITE:/3        <FS_STR1>-object_id,                       18  sy-vline,
             19       <FS_STR1>-process_type,                    36  sy-vline,
             37       <FS_STR1>-object_type,                     56  sy-vline,
             57       <FS_STR1>-created_at,                      68  sy-vline,
             69(10)   <FS_STR1>-changed_at,                      84  sy-vline,
            100       <FS_STR1>-del_ind,                        112  sy-vline,
            113       <FS_STR1>-archiving_flag,                 129  sy-vline,
            130       <FS_STR1>-REMARKS,                        150  sy-vline.
    ENDLOOP.   "end of t_str_sc1 displaying
  ENDIF.  "End of SY-SUBRC
**********************ENDIF.  "End of displaying Transaction type as CONF

Very difficult to give you a solution without having access to the actual data and tables and some basic relationship model to explain the entities of the tables.
But one thing I found that makes dealing complex queries a lot easier - easier to code and to read and to maintain - is to use the WITH clause. This allows the type of modularisation of code that we're using in other languages.
The basic syntax is:WITH <alias1> AS(
  SELECT ...
<alias2> AS(
  SELECT ...
<aliasn> AS(
  SELECT ...
SELECT
FROM alias1, .. aliasnThis allows you to create distinct query sets once - and then re-use these again in joins, selects, and even other sub-sets.
The resulting SQL is a lot les stressful on the eye and makes the whole "processing logic" of getting to the results much easier to analyse, follow and understand.

Similar Messages

  • &column in report query

    Hi Friends,
    I opened some of the complex reports in Oracle Applications and I see &column_name in the query.
    Where does this variable column ask an input value for substitution?
    I thought the input parameter is like this one > :P_INPUT
    Thanks a lot

    Hi again,
    Please see before report or after trigger form.
    Its a lexical parameter called in queryI tried to open an Oracle Apps report to study it (FAS400.rdf)
    I found 3 queries:
    Q_1
    select count (*) from fa_system_controlsQ_2
    SELECT
         &ACCT_FLEX_BAL_SEG     COMP_CODE,
         decode(TRANSACTION_TYPE,'B',RSV.RESERVE_ACCT, &ACCT_FLEX_ACCT_SEG )     GL_ACCOUNT,
         RSV.DEPRN_RESERVE_ACCT     RSV_ACCOUNT,
         &ACCT_FLEX_COST_SEG     COST_CENTER,
         AD.ASSET_NUMBER || '-' || AD.DESCRIPTION          
              ASSET_NUMBER,
         DATE_PLACED_IN_SERVICE          START_DATE,
         METHOD_CODE               METHOD,
         RSV.LIFE                    LIFE,
         RSV.RATE               ADJ_RATE,
         DS.BONUS_RATE               BONUS_RATE,
         RSV.CAPACITY               PROD,
         SUM(decode(transaction_type,'B',NULL,COST))               COST,
         SUM(RSV.DEPRN_AMOUNT)         DEPRN_AMOUNT,
         SUM(RSV.YTD_DEPRN)          YTD_DEPRN,
         SUM(RSV.DEPRN_RESERVE)          DEPRN_RESERVE,
         sum(decode(transaction_type,'B',NULL,nvl(PERCENT,0)))          PERCENT,
         TRANSACTION_TYPE          T_TYPE
    FROM
         FA_RESERVE_LEDGER_GT     RSV,
         FA_ADDITIONS          AD,
         GL_CODE_COMBINATIONS     CC,
         &lp_fa_deprn_summary     DS
    WHERE
         RSV.ASSET_ID          = AD.ASSET_ID
    AND
         RSV.DH_CCID          = CC.CODE_COMBINATION_ID
    AND
         DS.PERIOD_COUNTER (+)     = RSV.PERIOD_COUNTER     AND
         DS.BOOK_TYPE_CODE (+)     = :P_Book               AND
         DS.ASSET_ID (+)          = RSV.ASSET_ID
    GROUP BY
         &ACCT_FLEX_BAL_SEG,
         decode(transaction_type,'B', RSV.RESERVE_ACCT,&ACCT_FLEX_ACCT_SEG),
         RSV.DEPRN_RESERVE_ACCT,
         &ACCT_FLEX_COST_SEG,
         AD.ASSET_NUMBER,
         AD.DESCRIPTION,
         DATE_PLACED_IN_SERVICE,
         METHOD_CODE,
         RSV.LIFE,
         RSV.RATE,
         RSV.CAPACITY,
         DS.BONUS_RATE,
         TRANSACTION_TYPE
    ORDER BY
         1, 2, 3, 4, 5Q_3
    SELECT Company_Name,
                 Category_Flex_Structure,
                 Location_Flex_Structure,
                 Asset_Key_Flex_Structure,
                 'P' a_partial_retirement,
                 'F' a_full_retirement,
                 'T' a_transfer_out,
                 'N' a_non_depreciate,
                 'R' a_reclass,
                 'B' a_bonus
    FROM   FA_SYSTEM_CONTROLSTriggers:
    function AfterPForm return boolean is
    begin
    IF :p_ca_set_of_books_id <> -1999
    THEN
      BEGIN
       select mrc_sob_type_code, currency_code
       into :p_mrcsobtype, :lp_currency_code
       from gl_sets_of_books
       where set_of_books_id = :p_ca_set_of_books_id;
      EXCEPTION
        WHEN OTHERS THEN
         :p_mrcsobtype := 'P';
      END;
    ELSE
       :p_mrcsobtype := 'P';
    END IF;
    IF upper(:p_mrcsobtype) = 'R'
    THEN
      :lp_fa_deprn_summary := 'FA_DEPRN_SUMMARY_MRC_V';
    ELSE
      :lp_fa_deprn_summary := 'FA_DEPRN_SUMMARY';
    END IF;
      return (TRUE);
    end;
    function BeforeReport return boolean is
    begin
    SRW.USER_EXIT('FND SRWINIT');
    IF upper(:p_mrcsobtype) = 'R'
    THEN
      fnd_client_info.set_currency_context(:p_ca_set_of_books_id);
    END IF;
    return (TRUE);
    end;LEXICALS:
    &ACCT_FLEX_BAL_SEG
    &ACCT_FLEX_ACCT_SEG
    &ACCT_FLEX_COST_SEG
    &lp_fa_deprn_summaryReport Output Columns:
    sset Number -  Date Placed Date                               Net Book     Proceeds of                                      Trans
    Description     in Service  Retired        Cost Retired   Value Retired            Sale    Removal Cost       Gain/Loss     Number
    --------------- ----------- ----------- --------------- --------------- --------------- --------------- --------------- ----------May question is ...instead of outputting it to the above....How can I create/make a "view" from the 3 queries?
    Why is that I do not see any relation of the "lexicals" to the "afterform" and "beforereport" triggers?
    Please help :(
    Thanks a lot

  • Recurring problem - need to touch report query to make page to work again

    Hello
    In my APEX 3.0 (Oracle 10.2.0.3.0) application I have a main menu which is a very simple page with one report that selects from a local table (no dblink) what pages the logged user has access to.
    The problem is that now and then (around once a week) users get "page not found" after they log in to the application but before the main menu is displayed. After some testing I found out that, to fix it, I need to touch the report query (let's say, adding an extra space somewhere) and apply changes. After that, the page works fine...
    I have other much more complex pages in the application that don't have such problem.
    Any advice? Where should I start investigating to fix this?
    Thanks
    Luis
    PS: From the error_log file:
    [Mon Aug 20 10:12:54 2007] [error] [client 10.0.10.87] [ecid: 11877561:10.0.24.16:14092:0:37471,0] mod_plsql: /pls/apex/f HTTP-404 ORA-03113: end-of-file o
    n communication channel\n
    [Mon Aug 20 10:12:54 2007] [alert] [client 10.0.10.87] [ecid: 11877561:10.0.24.16:14092:0:37471,0] mod_plsql: Unable to reset state for mode 0: Err 3114 url=>/pls/apex/f

    i have this exact same problem in our production environment
    i really need help to fix it or we'll lose our major client
    they're fed up with it
    anyone?

  • Post upgrade to 3.1 issues : Unable to open report query

    Hi,
    We have upgraded our APEX version from 3.0 to 3.1. We have some wierd problems now
    1. I tried to add a new column link to an existing report region and I get an error.
    failed to parse SQL query:
    ORA-00911: invalid character
    2. I have to make some changes to an existing report query and I am unable to open it. I Get the following error:
    ORA-01461: can bind a LONG value only for insert into a LONG column
    Can anybody let me know the reason for these errors.
    Thanks
    Knut

    Hi Scott,
    We created a test case on apex.oracle.com in my workspace (DGIELIS_31)
    It's Application 54025, the query is called "Test Big Query".
    Currently it works, but edit the query and copy one of the comment lines and paste it in to take it over 4k. You should get the same error.
    Just for the record:
    - in APEX 3.0 in a non UTF-8 (WE8ISO8859P15) database this query was working
    - When migrating to UTF-8 database with APEX 3.1.1 we can't open the queries.
    - We can't use a view in this case, it's a pretty complex query which already uses MV's and the tables in questions are pretty huge. The query we had to come up with is pretty big to get optimal performance.
    If you want I can email you my login details or create you a user.
    Regards,
    Dimitri
    -- http://dgielis.blogspot.com/
    -- http://www.apex-evangelists.com/
    -- http://www.apexblogs.info/

  • Complex reporting szenario

    Hello experts!
    I have a very complex reporting problem and can not find a solution at the moment.
    I want to calculate the following:
    stock quantity x volume (m^3) = stock volume
    Now, the problem is that volume is a attribute of 0MATERIAL. Because our people are not very consistent in maintaining this values in the material master, we are not able to calculate this in our data flow of the infocube.
    Therefore we use it as a formula variable in the report fetching volume with replacement path.
    So far this works and is no problem. What we want to do is to show this also aggregated for a plant or so. Therefore I should calculate it before aggregation.
    How you can see here:
    http://help.sap.com/saphelp_nw70/helpdata/en/5b/30d43b0527a17be10000000a114084/frameset.htm
    to calculate a formula variable is not possible.
    So are there any alternative ways to make this szenario?
    Best regards,
    Peter

    Hi Peter,
    well at the moment I would think about a virtual keyfigure. May be someone else has a better idea. In case your report has to be very quick and you have lots of data in your datatargets the virtual keyfigure might not be a good idea, because such a query does not use any aggregate.
    regards
    Siggi

  • Complex reporting

    Hi,
    I have requirement to develop a complex reporting in such way:
                    Pervious Year(PY) | Current Year(CY) | % PY/CY
       KF1      
         KF1a
       KF2
         KF2a
    How can I make query for this layout?
    Thanks,
    Helen

    Hi Helen,
    You can do it like this. Keep all the required KFs in rows. In columns add a new structure. Make a new selection for Previous year (PY). Add the year characteristic here and include the variable for the year here (Either SAP exit for current year or user entry). Give an offset of -1. Similarly create another new selection for Current year. Use the same variable here without any offset. Create a new formula for %PY/CY. In this way you can achieve this layout. Do post back incase of further clarification.
    Thanks.
    Sumit

  • Need to create report query to get latest open and last closed period for given application

    Hi All,
    I need to create a report query to get below result displayed in report output.
    1)   -   Application name
    2)   -    Ledger name
    -o/  -Operating Unit
    3)   -  Last Closed Period
    4)   -  Current Open Period
    5)   -  Date Closed – Last Closed Period
    6)   -  Date Open – Current Open Period
    I tr I tried to create the query below is the same. Please let me know if it looks fine.
    SELECT *
      FROM (SELECT fav.application_name ,
                   hou.name Operating_Unit_Name,
                   gl.name Ledger_name,
                   gl.latest_opened_period_name,
                   gps.period_name Period_Name,
                   DECODE(gps.closing_status, 'O', 'Open', 'C', 'Closed') status,
                   gps.last_update_date Last_status_modified_date
              FROM gl_period_statuses gps,
                   gl_sets_of_books   gsob,
                   fnd_application_vl fav,
                   hr_operating_units hou,
                   gl_ledgers         gl
             WHERE gps.period_name = gps.period_name
               AND gps.closing_status ='C'
               AND fav.application_short_name =
                   NVL('&p_application_short_name', fav.application_short_name)
               AND gps.application_id = fav.application_id
               AND gsob.set_of_books_id = gps.set_of_books_id
               AND hou.set_of_books_id = gps.set_of_books_id
               AND gl.ledger_id = gsob.set_of_books_id
               AND hou.organization_id=NVL('&p_operating_unit',hou.organization_id)
               AND gl.ledger_id=NVL('&p_ledger_id',gl.ledger_id) 
             ORDER BY gps.last_update_date desc )WHERE ROWNUM = 1 
    UNION ALL
    SELECT *
      FROM (SELECT fav.application_name Application_Name,
                   hou.name Operating_Unit_Name,
                   gl.name Ledger_name,
                   gl.latest_opened_period_name,
                   gps.period_name Period_Name,
                   DECODE(gps.closing_status, 'O', 'Open', 'C', 'Closed') status,
                   gps.last_update_date Last_status_modified_date
              FROM gl_period_statuses gps,
                   gl_sets_of_books   gsob,
                   fnd_application_vl fav,
                   hr_operating_units hou,
                   gl_ledgers         gl
             WHERE gps.period_name = gps.period_name
               AND gps.closing_status = 'O'
               AND fav.application_short_name =
                   NVL('&p_application_short_name', fav.application_short_name)
               AND gps.application_id = fav.application_id
               AND gsob.set_of_books_id = gps.set_of_books_id
               AND hou.set_of_books_id = gps.set_of_books_id
               AND gl.ledger_id = gsob.set_of_books_id
               AND hou.organization_id=NVL('&p_operating_unit',hou.organization_id)
               AND gl.ledger_id=NVL('&p_ledger_id',gl.ledger_id) 
             ORDER BY gps.last_update_date desc)
             WHERE ROWNUM = 1

    It is within the table I believe (I'm not a DBA or a developer) since I created a BLOB column and then used the file browse feature to allow users to attach a resume to the table in order to be able to perform a search of the attached documents.
    I'm just having a hard time pointing the link in the search results report to the document in the blob column.
    The information on that page is great if you're trying to create a link to the document on the initial report.
    But I created a query using Oracle Text to run a report that does a boolean search of the attached word documents in the table.
    When it displays the search results, it doesn't create a link to the document and I can't figure out how to do it.
    Here's a link the the instructions I used to create the initial search report with Oracle Text, mind you I only created the index and query, I didn't add in all the link data since they're using documents on websites and I'm using documents in a table.
    http://www.oracle.com/technology/products/database/application_express/pdf/apex_text_application_v1.6.pdf
    If you can help me with this I'd really appreciate it.
    Thanks again.
    Greg
    Edited by: gjones77 on Dec 2, 2008 8:14 AM

  • Report-Query Value

    Hi Experts,
    Currently we are using one BW report in 3.5version(report query against multi provider).
    Current issue:
    Cube Fields:
    PO Number: 123
    Order value 100.
    Confirmation value 50
    Final Delivery Indicator: X (YES-No more confirmation is expected)
    Calculation on the Query:
    Outstanding Confirmed Value= Order Value - Net Confirmed Value
    Here Outstanding Confirmed Value = 100-50=50.So in the reports, Outstanding Confirmed Value shows 50.
    But the PO's Final Delivery Indicator is marked. So No more confirmation is expected
    Question:
    I am not able to create any formula against the filed Final Delivery Indicator. But i want to show in the report that if the PO's Final Delivery Indicator marked, then Outstanding Confirmed Value has to be 0(ZERO).
    Please help me achieve this result. Thanks.
    Advance Thanks.
    RR.

    Hi ,
    This can be achived in the following way.
    1. Create your formula
        "Outstanding Confirmed Value= Order Value - Net Confirmed Value" and hide it using the property.
    2. Create one more forumala which will check the condition. i.e. if the Final Delivery Indicator is marked then it will set the outstanding confirmed value as zero else it will show the value which we are getting by using above mentioned formula.
    put the following condition in the formula.
    [Final Delivery Indicator = = 0 ] * 0 + [Final Delivery Indicator <> 0]*Outstanding Confirmed Value
    This will work as follow.
    For example : Outstanding Confrimed Value is 50 and Final Delivery Indicator is marked.
    = [ 0 == 0 ] * 0 + [ 0 <> 0 ] * 50
    = 1* 0 + 0 * 50              " When the condition is satisfied its result is 1. here 0 == 0 condtion is satisfied so its return value is 1.
    = 0
    Hope this will help.
    - Jaimin

  • Performance issues when creating a Report / Query in Discoverer

    Hi forum,
    Hope you are can help, it involves a performance issues when creating a Report / Query.
    I have a Discoverer Report that currently takes less than 5 seconds to run. After I add a condition to bring back Batch Status that = ‘Posted’ we cancelled the query after reaching 20 minutes as this is way too long. If I remove the condition the query time goes back to less than 5 seconds.
    Please see attached the SQL Inspector Plan:
    Before Condition
    SELECT STATEMENT
    SORT GROUP BY
    VIEW SYS
    SORT GROUP BY
    NESTED LOOPS OUTER
    NESTED LOOPS OUTER
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS OUTER
    NESTED LOOPS OUTER
    NESTED LOOPS
    NESTED LOOPS OUTER
    NESTED LOOPS OUTER
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    TABLE ACCESS BY INDEX ROWID GL.GL_CODE_COMBINATIONS
    AND-EQUAL
    INDEX RANGE SCAN GL.GL_CODE_COMBINATIONS_N2
    INDEX RANGE SCAN GL.GL_CODE_COMBINATIONS_N1
    TABLE ACCESS BY INDEX ROWID APPLSYS.FND_FLEX_VALUES
    INDEX RANGE SCAN APPLSYS.FND_FLEX_VALUES_N1
    TABLE ACCESS BY INDEX ROWID APPLSYS.FND_FLEX_VALUE_SETS
    INDEX UNIQUE SCAN APPLSYS.FND_FLEX_VALUE_SETS_U1
    TABLE ACCESS BY INDEX ROWID APPLSYS.FND_FLEX_VALUES_TL
    INDEX UNIQUE SCAN APPLSYS.FND_FLEX_VALUES_TL_U1
    INDEX RANGE SCAN APPLSYS.FND_FLEX_VALUE_NORM_HIER_U1
    TABLE ACCESS BY INDEX ROWID GL.GL_JE_LINES
    INDEX RANGE SCAN GL.GL_JE_LINES_N1
    INDEX UNIQUE SCAN GL.GL_JE_HEADERS_U1
    INDEX UNIQUE SCAN GL.GL_SETS_OF_BOOKS_U2
    TABLE ACCESS BY INDEX ROWID GL.GL_JE_HEADERS
    INDEX UNIQUE SCAN GL.GL_JE_HEADERS_U1
    INDEX UNIQUE SCAN GL.GL_DAILY_CONVERSION_TYPES_U1
    TABLE ACCESS BY INDEX ROWID GL.GL_JE_SOURCES_TL
    INDEX UNIQUE SCAN GL.GL_JE_SOURCES_TL_U1
    INDEX UNIQUE SCAN GL.GL_JE_CATEGORIES_TL_U1
    INDEX UNIQUE SCAN GL.GL_JE_HEADERS_U1
    INDEX UNIQUE SCAN GL.GL_JE_HEADERS_U1
    INDEX UNIQUE SCAN GL.GL_JE_BATCHES_U1
    INDEX UNIQUE SCAN GL.GL_BUDGET_VERSIONS_U1
    INDEX UNIQUE SCAN GL.GL_ENCUMBRANCE_TYPES_U1
    INDEX UNIQUE SCAN GL.GL_SETS_OF_BOOKS_U2
    TABLE ACCESS BY INDEX ROWID GL.GL_JE_BATCHES
    INDEX UNIQUE SCAN GL.GL_JE_BATCHES_U1
    INDEX UNIQUE SCAN GL.GL_SETS_OF_BOOKS_U2
    INDEX UNIQUE SCAN GL.GL_JE_BATCHES_U1
    TABLE ACCESS BY INDEX ROWID GL.GL_PERIODS
    INDEX RANGE SCAN GL.GL_PERIODS_U1
    After Condition
    SELECT STATEMENT
    SORT GROUP BY
    VIEW SYS
    SORT GROUP BY
    NESTED LOOPS
    NESTED LOOPS OUTER
    NESTED LOOPS OUTER
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS OUTER
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS OUTER
    NESTED LOOPS
    NESTED LOOPS OUTER
    NESTED LOOPS
    NESTED LOOPS
    NESTED LOOPS OUTER
    NESTED LOOPS
    TABLE ACCESS FULL GL.GL_JE_BATCHES
    INDEX UNIQUE SCAN GL.GL_SETS_OF_BOOKS_U2
    INDEX UNIQUE SCAN GL.GL_JE_BATCHES_U1
    TABLE ACCESS BY INDEX ROWID GL.GL_JE_HEADERS
    INDEX RANGE SCAN GL.GL_JE_HEADERS_N1
    INDEX UNIQUE SCAN GL.GL_SETS_OF_BOOKS_U2
    INDEX UNIQUE SCAN GL.GL_ENCUMBRANCE_TYPES_U1
    INDEX UNIQUE SCAN GL.GL_DAILY_CONVERSION_TYPES_U1
    INDEX UNIQUE SCAN GL.GL_BUDGET_VERSIONS_U1
    TABLE ACCESS BY INDEX ROWID GL.GL_JE_SOURCES_TL
    INDEX UNIQUE SCAN GL.GL_JE_SOURCES_TL_U1
    INDEX UNIQUE SCAN GL.GL_JE_CATEGORIES_TL_U1
    INDEX UNIQUE SCAN GL.GL_JE_BATCHES_U1
    TABLE ACCESS BY INDEX ROWID GL.GL_JE_LINES
    INDEX RANGE SCAN GL.GL_JE_LINES_U1
    INDEX UNIQUE SCAN GL.GL_SETS_OF_BOOKS_U2
    TABLE ACCESS BY INDEX ROWID GL.GL_CODE_COMBINATIONS
    INDEX UNIQUE SCAN GL.GL_CODE_COMBINATIONS_U1
    TABLE ACCESS BY INDEX ROWID GL.GL_PERIODS
    INDEX RANGE SCAN GL.GL_PERIODS_U1
    TABLE ACCESS BY INDEX ROWID APPLSYS.FND_FLEX_VALUES
    INDEX RANGE SCAN APPLSYS.FND_FLEX_VALUES_N1
    INDEX RANGE SCAN APPLSYS.FND_FLEX_VALUE_NORM_HIER_U1
    TABLE ACCESS BY INDEX ROWID APPLSYS.FND_FLEX_VALUES_TL
    INDEX UNIQUE SCAN APPLSYS.FND_FLEX_VALUES_TL_U1
    TABLE ACCESS BY INDEX ROWID APPLSYS.FND_FLEX_VALUE_SETS
    INDEX UNIQUE SCAN APPLSYS.FND_FLEX_VALUE_SETS_U1
    INDEX UNIQUE SCAN GL.GL_JE_HEADERS_U1
    INDEX UNIQUE SCAN GL.GL_JE_HEADERS_U1
    INDEX UNIQUE SCAN GL.GL_JE_HEADERS_U1
    Is there anything i can do in Discoverer Desktop / Administration to avoid this problem.
    Many thanks,
    Lance

    Hi Rod,
    I've tried the condition (Batch Status||'' = 'Posted') as you suggested, but the qeury time is still over 20 mins. To test i changed it to (Batch Status||'' = 'Unposted') and the query was returned within seconds again.
    I’ve been doing some more digging and have found the database view that is linked to the Journal Batches folder. See below.
    I think the problem is with the column using DECODE. When querying the column in TOAD the value of ‘P’ is returned. But in discoverer the condition is done on the value ‘Posted’. I’m not too sure how DECODE works, but think this could be the causing some sort of issue with Full Table Scans. How do we get around this?
    Lance
    DECODE( JOURNAL_BATCH1.STATUS,
    '+', 'Unable to validate or create CTA',
    '+*', 'Was unable to validate or create CTA',
    '-','Invalid or inactive rounding differences account in journal entry',
    '-*', 'Modified invalid or inactive rounding differences account in journal entry',
    '<', 'Showing sequence assignment failure',
    '<*', 'Was showing sequence assignment failure',
    '>', 'Showing cutoff rule violation',
    '>*', 'Was showing cutoff rule violation',
    'A', 'Journal batch failed funds reservation',
    'A*', 'Journal batch previously failed funds reservation',
    'AU', 'Showing batch with unopened period',
    'B', 'Showing batch control total violation',
    'B*', 'Was showing batch control total violation',
    'BF', 'Showing batch with frozen or inactive budget',
    'BU', 'Showing batch with unopened budget year',
    'C', 'Showing unopened reporting period',
    'C*', 'Was showing unopened reporting period',
    'D', 'Selected for posting to an unopened period',
    'D*', 'Was selected for posting to an unopened period',
    'E', 'Showing no journal entries for this batch',
    'E*', 'Was showing no journal entries for this batch',
    'EU', 'Showing batch with unopened encumbrance year',
    'F', 'Showing unopened reporting encumbrance year',
    'F*', 'Was showing unopened reporting encumbrance year',
    'G', 'Showing journal entry with invalid or inactive suspense account',
    'G*', 'Was showing journal entry with invalid or inactive suspense account',
    'H', 'Showing encumbrance journal entry with invalid or inactive reserve account',
    'H*', 'Was showing encumbrance journal entry with invalid or inactive reserve account',
    'I', 'In the process of being posted',
    'J', 'Showing journal control total violation',
    'J*', 'Was showing journal control total violation',
    'K', 'Showing unbalanced intercompany journal entry',
    'K*', 'Was showing unbalanced intercompany journal entry',
    'L', 'Showing unbalanced journal entry by account category',
    'L*', 'Was showing unbalanced journal entry by account category',
    'M', 'Showing multiple problems preventing posting of batch',
    'M*', 'Was showing multiple problems preventing posting of batch',
    'N', 'Journal produced error during intercompany balance processing',
    'N*', 'Journal produced error during intercompany balance processing',
    'O', 'Unable to convert amounts into reporting currency',
    'O*', 'Was unable to convert amounts into reporting currency',
    'P', 'Posted',
    'Q', 'Showing untaxed journal entry',
    'Q*', 'Was showing untaxed journal entry',
    'R', 'Showing unbalanced encumbrance entry without reserve account',
    'R*', 'Was showing unbalanced encumbrance entry without reserve account',
    'S', 'Already selected for posting',
    'T', 'Showing invalid period and conversion information for this batch',
    'T*', 'Was showing invalid period and conversion information for this batch',
    'U', 'Unposted',
    'V', 'Journal batch is unapproved',
    'V*', 'Journal batch was unapproved',
    'W', 'Showing an encumbrance journal entry with no encumbrance type',
    'W*', 'Was showing an encumbrance journal entry with no encumbrance type',
    'X', 'Showing an unbalanced journal entry but suspense not allowed',
    'X*', 'Was showing an unbalanced journal entry but suspense not allowed',
    'Z', 'Showing invalid journal entry lines or no journal entry lines',
    'Z*', 'Was showing invalid journal entry lines or no journal entry lines', NULL ),

  • Report query with bind variable

    Trying to create a report query for xsl-fo print. For output format I pick "derive from item" then pick the item name from the list, on the next screen, I paste the query with the bind variable. on the next step test query, I always get "data not found" regardless what value I type in. This is the same query that I ran under sql commands without any issues.
    Does anyone run into the same issue as I have when attempted to create a query with bind var ? There is no problem creating a query without bind varibles. . thanks.
    Munshar

    Hi, please did you get any solution to this issue? I am having similar challenge right now.
    select     EMP.DEPTNO as DEPTNO,
         DEPT.DNAME as DNAME,
         EMP.EMPNO as EMPNO,
         EMP.ENAME as ENAME,
         EMP.JOB as JOB,
         EMP.MGR as MGR,
         EMP.HIREDATE as HIREDATE,
         EMP.SAL as SAL
    from     SCOTT.DEPT DEPT,
         SCOTT.EMP EMP
    where EMP.DEPTNO=DEPT.DEPTNO
    and      DEPT.DNAME =upper(:dname)
    This run perfectly in sql developer, toad, and even inside publisher if I login directly to publisher to create report.
    Generating this same query in shared component query builder and testing it returns no data found. If I remove the last line, it works. but with the last line, it return no data found. It seems no one has been able to provide solution to this issue

  • Performance problem with report query

    Hi,
    I am encountering a performance issue with a page returning a report.
    I have a page that has a region which joins 2 tables. One table has about 220,00 rows, while the other contains roughly 60,000 rows. In the region source of the report region, the query includes join condition with local variables. For example, the page is page 70, and some join conditions are:
    and a.id=:P70_ID
    and a.name like :P70_NAME
    I run the query that returns a large number of rows from sqlplus, and it takes less than 30 sec to complete.
    When I run the page, the report took about 3 minutes to return.
    In this case, :P70_NAME is initialized to '%' on the page.
    I then tried to substitute variable value directly in the query:
    and a.id=1000
    and a.name like '%'
    this time the report returned in about 30 sec.
    I then tried another thing which specified the region as "PL/SQL Function returning sql query", and modified the region as follows:
    l_sql := '.......';
    l_sql := l_sql || 'and a.id=' || v('P70_ID')
    and similar substituting :P70_NAME to v('P70_NAME') and append its value to the l_sql string.
    The report query page also returned in 30 sec.
    Is there any known performance issue with using the bind variable (:PXX_XXX) in the report region?

    If you are able.. flush the shared_pool, run your
    report then query the v$sql_area or v$sql_text tables.
    Or do a google query and look up Cary Milsap's piece on enabling extended trace .. there is your sure fire way of finding the problem sql. I am still learning htmldb but is there a way to alter session enable trace in some pre-query block?

  • Creating a print button to call a Report Query and pass filters

    If i use the REPORT QUERY option in APEX 4 to create an statement that is the same one used in an interactive report, can I create a link or button to the REPORT QUERY and pass all the session and filter information from the interactive report to the report query?
    This way I can have the interactive report screen where the user can do all sorts of modifications and such and then pass those to the REPORT QUERY so I can call that from a custom link or button.
    You may ask "why does he need another print button?"
    Answer: I am using a view that has some embedded HTML tags to format the output really nicely. The HTML download version created by the interactive reports works beautifully. The customer also wants a PDF version (meh) which does not render the HTML tags and actually echos them as part of the text. I found that I can create another view that uses the CHR function to create all the breaks and such I was doing with HTML and these do render properly in PDF. So, I figured just have 2 reports: 1 Interactive and 1 using a REPORT QUERY. I just want to call the REPORT QUERY version but use the Interactive Search form to set all the parameters.
    Or, am I over thinking this and there is an easier method?
    I made a previous post where I showed how I got the APEX printing to work and i hoped that helped someone out - fixing this issue would put the whole thing to rest.
    Thanks

    Is BI Publisher desktop (MS Word add-in) a possibility? This would allow you to use MS Word to create your output template (RTF) that would result in a properly formatted PDF. Of course, you'd have to right an updated version of the query without HTML embedded. Just thinking outside of the box.

  • Bind Variables and Shared Component Report Query

    I have a query in a region report which I have replicated to a shared component report query.
    Both queries reference page items as bind variables in the where clause.
    The report region on screen shows the correct results but the report query shows "no data". This is the case when running "Test Query" and "Download XML data" from the shared component report query definition. If I hardcode the variable names I get rows returned, If I use bind variables - and specify the values for these variables I get no data. THe XML file contains the tags for each bind variable I have specified but has no data between the tags. I have Ticked the box to include application and session state but it appears that the bind variables are not being used.
    When I use my report query in the application (URL tied to a button) I get the same problem, the binds are not being passed to the report query.
    Can someone please clarify if this is a bug or not? And if not, how can I get it to work.
    I am using Apex 4.0.2
    Thanks
    Kathryn

    Hi
    To confirm, yes I selected the bind variables. I used these in the report layout, but the xml file has them as empty i.e.
    <P0_START_DATE><P0_START_DATE/> with nothing in between.
    IN the Test Query section, if I put real values in the boxes for the bind variables, I get no data found. If I hardcode the values into the query, I get the data.
    I've repeated the create report query many times and have created a report layout in RTF. I can use the layout with my region - in the print attributes and the layout works with the query but I need to create a PDF using 2 queries - ROWSET1 and ROWSET2. I can generate the XML but the values in the rows are all empty. When I use the layout with a report query instead of the region, I get no data even though I have used the same sql and have selected the bind variables. I was using variables from page items on page zero but have also tried using page items on the current page, the result is the same.
    I need to use a report query and a report layout as I need data from 2 queries in the PDF.
    I looked at your demo - what happens if you add a second sql query to the report query - is there any chance I can look at the back end (developer access?)
    Thanks for your input
    Kathryn

  • Ora-06502 pl/sql numeric or value error in Report Query in oracle apex

    Hello all,
    I need your help...
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    I am using bi publisher to generate PDF reports in oracle apex.
    We were using APEX 4.0 and migrated to 4.2 just a week ago.
    Now we have apex 4.2.
    When I try to Create report query,
    Shared Components >> Report Queries then create.
    and test a report in a create wizard I am getting a error "ORA-06502: PL/SQL: numeric or value error: character string buffer too small".
    I have also applied a patch "16760897".
    This issue is because of number of columns in a query is more then 26.
    If I run a report with 26 or less number of columns then the is working fine, otherwise getting this error.
    My before migration report queries working perfectly even now, but not new queries.
    This issue is also in apex.oracle.com.
    You can see
    Not working  - http://apex.oracle.com/pls/apex/f?p=619:4
    Working - http://apex.oracle.com/pls/apex/f?p=619:2:
    Please give a solution.
    Thanks you.

    check the DB version compatibility with apex 4 or your DB version to apex 4.0 support for upgrade!
    Oracle Application Express Installation Requirements for 4.0

  • Report Query returning "No Data Found" with bind variables

    I put a simple query into Report Query:
    Select "bluefish". "name" as "name",
    "bluefish"."primary_flag" as "primary_flag",
    "bluefish"."status" as "status",
    "bluefish"."ID" as "ID" from "bluefish" "bluefish" where "bluefish"."ID" = :P3_XPRINTID
    When I test the query, data is returned; however, when I try to run the query using "Test Report" button, I get an error 01403 No Data Found. If I replace the bind variable with an explicit value, the report works.
    Anyone have any ideas as to what is causing this problem? I am using the Generic Report Layout, with various output types. I AM editting the query and defining the bind variable before I test the report (otherwise, the query wouldn't run).
    Charles

    Sometimes if you create a form/report/whatever using the wizards, it will create an After Submit process called something like Reset Page - basically you want to make sure you don't have any After Submit processes that call a Clear Session state (it may say something like Clear Cache for Page).
    In your branch, there is also a box that says Clear Cache - you want to make sure that does not have page Number 8 in it or it will clear your session state.
    Put the page in Debug mode and read through it - check to make sure your value is getting saved and maybe you can see what is going wrong.

Maybe you are looking for