How to alter Select Query while altering selectionscreen for same output?

Hi,
i have to change the selection screen fields with some new fields , but i dont know how to change the selection query accordingly, because i need the same output with the same fields but with a different set of fields in the selection screen.
The original code is
TYPES: BEGIN OF ty_output,
       mblnr TYPE mseg-mblnr,
       mjahr TYPE mseg-mjahr,
       zeile TYPE mseg-zeile,
       bwart TYPE mseg-bwart,
       werks TYPE mseg-werks,
       lgort TYPE mseg-lgort,
       ebeln TYPE mseg-ebeln,
       ebelp TYPE mseg-ebelp,
       lfbnr TYPE mseg-lfbnr,
       lfpos TYPE mseg-lfpos,
       sjahr TYPE mseg-sjahr,
       dmbtr TYPE mseg-dmbtr,
       menge TYPE mseg-menge,
       matnr TYPE mseg-matnr,
       mtart TYPE mara-mtart,
       matkl TYPE mara-matkl,
       bismt TYPE mara-bismt,
       meins TYPE mara-meins,
       bedat TYPE ekko-bedat,
       waers TYPE ekko-waers,
       wkurs TYPE ekko-wkurs,
       verkf TYPE ekko-verkf,
      EFFWR TYPE EKPO-EFFWR,
       tax TYPE ekpo-effwr,
       maktx TYPE makt-maktx,
       budat TYPE mkpf-budat,
       usnam TYPE mkpf-usnam,
       m_menge TYPE ekpo-menge,
       ablad TYPE mseg-ablad,
       wempf TYPE mseg-wempf,
       END OF ty_output.
TYPES: BEGIN OF ty_mseg_103,
       mblnr TYPE mseg-mblnr,
       mjahr TYPE mseg-mjahr,
       zeile TYPE mseg-zeile,
       bwart TYPE mseg-bwart,
       werks TYPE mseg-werks,
       lgort TYPE mseg-lgort,
       ebeln TYPE mseg-ebeln,
       ebelp TYPE mseg-ebelp,
       lfbnr TYPE mseg-lfbnr,
       lfpos TYPE mseg-lfpos,
       sjahr TYPE mseg-sjahr,
       dmbtr TYPE mseg-dmbtr,
       menge TYPE mseg-menge,
       matnr TYPE mseg-matnr,
       mtart TYPE mara-mtart,
       matkl TYPE mara-matkl,
       bismt TYPE mara-bismt,
       meins TYPE mara-meins,
       bedat TYPE ekko-bedat,
       waers TYPE ekko-waers,
       wkurs TYPE ekko-wkurs,
       verkf TYPE ekko-verkf,
      EFFWR TYPE EKPO-EFFWR,
       tax TYPE ekpo-effwr,
       maktx TYPE makt-maktx,
       budat TYPE mkpf-budat,
       usnam TYPE mkpf-usnam,
       m_menge TYPE ekpo-menge,
       ablad TYPE mseg-ablad,
       wempf TYPE mseg-wempf,
       END OF ty_mseg_103.
TYPES: BEGIN OF ty_mseg_105,
       mblnr TYPE mseg-mblnr,
       mjahr TYPE mseg-mjahr,
       zeile TYPE mseg-zeile,
       bwart TYPE mseg-bwart,
       werks TYPE mseg-werks,
       lgort TYPE mseg-lgort,
       ebeln TYPE mseg-ebeln,
       ebelp TYPE mseg-ebelp,
       lfbnr TYPE mseg-lfbnr,
       lfpos TYPE mseg-lfpos,
       sjahr TYPE mseg-sjahr,
       dmbtr TYPE mseg-dmbtr,
       menge TYPE mseg-menge,
       matnr TYPE mseg-matnr,
       mtart TYPE mara-mtart,
       matkl TYPE mara-matkl,
       bismt TYPE mara-bismt,
       meins TYPE mara-meins,
       bedat TYPE ekko-bedat,
       waers TYPE ekko-waers,
       wkurs TYPE ekko-wkurs,
       verkf TYPE ekko-verkf,
       effwr TYPE ekpo-effwr,
       tax TYPE ekpo-effwr,
       maktx TYPE makt-maktx,
       budat TYPE mkpf-budat,
       ablad TYPE mseg-ablad,
       wempf TYPE mseg-wempf,
       END OF ty_mseg_105.
DATA: Begin with W_                                                 *
DATA : it_fcat TYPE slis_t_fieldcat_alv. " alv field catalog
DATA  : listhead TYPE slis_t_listheader WITH HEADER LINE.
DATA: event TYPE slis_t_event WITH HEADER LINE.
INTERNAL TABLES: Begin with IT_                                     *
DATA : it_output TYPE STANDARD TABLE OF ty_output WITH KEY mblnr mjahr,
       it_mseg_103 TYPE STANDARD TABLE OF ty_mseg_103,
       it_mseg_105 TYPE STANDARD TABLE OF ty_mseg_103,
       it_mseg_106 TYPE STANDARD TABLE OF ty_mseg_103,          " LNTDEV1 ADDED
       it_mara TYPE STANDARD TABLE OF ty_mara,
       it_ekko TYPE STANDARD TABLE OF ty_ekko,
       it_ekpo TYPE STANDARD TABLE OF ty_ekpo,
       it_makt TYPE STANDARD TABLE OF ty_makt,
       it_mkpf TYPE STANDARD TABLE OF ty_mkpf WITH KEY mblnr.
WORKAREAS: Begin with WA_                                           *
DATA : wa_fcat LIKE LINE OF it_fcat.
DATA : wa_output LIKE LINE OF it_output,
       wa_mara LIKE LINE OF it_mara,
       wa_ekko LIKE LINE OF it_ekko,
       wa_ekpo LIKE LINE OF it_ekpo,
       wa_makt LIKE LINE OF it_makt,
       wa_mkpf LIKE LINE OF it_mkpf,
       wa_mseg_103 LIKE LINE OF it_mseg_103,
       wa_mseg_105 LIKE LINE OF it_mseg_105,
       wa_mseg_106 LIKE LINE OF it_mseg_106.                        " LNTDEV1 ADDED
DATA : w_menge LIKE ekpo-menge.
FIELD-SYMBOLS: Begin with FS_                                       *
PARAMETERS: Begin with PR_                                          *
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS  : pr_werks LIKE mseg-werks OBLIGATORY.
SELECT-OPTIONS : so_budat FOR mkpf-budat.
SELECTION-SCREEN END OF BLOCK b1.
SELECT-OPTIONS: Begin with SO_                                      *
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME.
SELECT-OPTIONS : so_mtart FOR mara-mtart.
SELECT-OPTIONS : so_matkl FOR mara-matkl.
SELECT-OPTIONS : so_matnr FOR mara-matnr.
SELECT-OPTIONS : so_bismt FOR mara-bismt.
SELECT-OPTIONS : so_ebeln FOR mseg-ebeln.
SELECT-OPTIONS : so_verkf FOR ekko-verkf.
SELECT-OPTIONS : so_bedat FOR ekko-bedat.
SELECT-OPTIONS : so_mblnr FOR mseg-mblnr.
SELECTION-SCREEN END OF BLOCK b2.
*AT SELECTION-SCREEN.
*SO_BUDAT-HIGH = SO_BUDAT-HIGH + 1.
Query for getting all the Document Segment: Material data from MSEG *
Table which having Movement Types 103 and put into it_mseg table,   *
Filtering by reference document and material document number        *
Filtering by selection criteria (Material Docu No, Purchase order   *
and Plant)                                                          *
START-OF-SELECTION.
  SELECT pmblnr smblnr p~mjahr zeile bwart lfbnr werks lgort ebeln
         ebelp lfpos sjahr dmbtr usnam menge sbudat pmatnr q~mtart
         pablad pwempf
         FROM mseg AS p INNER JOIN mara AS q
           ON pmatnr = qmatnr
           JOIN mkpf AS s ON smblnr EQ pmblnr
           INTO CORRESPONDING FIELDS OF
         TABLE it_mseg_103
         WHERE bwart EQ 103
         AND p~matnr IN so_matnr
         AND werks EQ pr_werks
         AND ebeln IN so_ebeln
         AND q~mtart IN so_mtart
         AND p~mblnr IN so_mblnr
         AND s~budat IN so_budat.
  IF sy-subrc = 0.
  ENDIF.
  SELECT pmblnr smblnr p~mjahr zeile bwart lfbnr werks lgort ebeln
         ebelp lfpos sjahr dmbtr usnam menge sbudat pmatnr q~mtart
         pablad pwempf
         FROM mseg AS p INNER JOIN mara AS q
           ON pmatnr = qmatnr
           JOIN mkpf AS s ON smblnr EQ pmblnr
           INTO CORRESPONDING FIELDS OF
         TABLE it_mseg_105
      WHERE bwart EQ 105 OR bwart EQ 104 OR bwart EQ 124 OR bwart EQ 124
         AND p~matnr IN so_matnr
         AND werks EQ pr_werks
         AND ebeln IN so_ebeln
         AND q~mtart IN so_mtart
         AND p~mblnr IN so_mblnr
         AND s~budat IN so_budat.
  IF sy-subrc = 0.
  ENDIF.
  LOOP AT IT_MSEG_103 INTO WA_MSEG_103.
    READ TABLE IT_MSEG_105 INTO WA_MSEG_105 WITH KEY LFBNR =
                                           WA_MSEG_103-MBLNR.
      IF SY-SUBRC <> 0.
        APPEND WA_MSEG_103 TO IT_OUTPUT.
      ENDIF.
   ENDLOOP.
  SELECT pmblnr smblnr p~mjahr zeile bwart lfbnr werks lgort ebeln  
         ebelp lfpos sjahr dmbtr usnam menge sbudat pmatnr q~mtart
         pablad pwempf
         FROM mseg AS p INNER JOIN mara AS q
           ON pmatnr = qmatnr
           JOIN mkpf AS s ON smblnr EQ pmblnr
           INTO CORRESPONDING FIELDS OF
         TABLE it_mseg_106
         WHERE bwart EQ 106
         AND p~matnr IN so_matnr
         AND werks EQ pr_werks
         AND ebeln IN so_ebeln
         AND q~mtart IN so_mtart
         AND p~mblnr IN so_mblnr
         AND s~budat IN so_budat.
  LOOP AT it_mseg_103 INTO wa_mseg_103.
    READ TABLE it_mseg_106 INTO wa_mseg_106 WITH KEY
                                       lfbnr = wa_mseg_103-mblnr.
    IF sy-subrc = 0.
      APPEND wa_mseg_106 TO it_output.
      clear wa_mseg_106.
    ENDIF.
  ENDLOOP.                        
Present selection criteria is
1. Plant
2. Posting Date
3. Material Type
4. Material Group
5. Material No.
6. Old Material No.
7. PO Order No.
8. Old PO No.
9. PO Date
10. Material Document No.
New selection criteria is
1. PO no.
2. PO date
3. PO value (Ex: >=10000 <=50000)
4. Purch org
5. Doc type
6. Vendor
7. Material
8. Account assignment category
9. Order

Hi,
i have to change the selection screen fields with some new fields , but i dont know how to change the selection query accordingly, because i need the same output with the same fields but with a different set of fields in the selection screen.
The original code is
TYPES: BEGIN OF ty_output, mblnr TYPE mseg-mblnr, mjahr TYPE mseg-mjahr, zeile TYPE mseg-zeile, bwart TYPE mseg-bwart, werks TYPE mseg-werks, lgort TYPE mseg-lgort, ebeln TYPE mseg-ebeln, ebelp TYPE mseg-ebelp, lfbnr TYPE mseg-lfbnr, lfpos TYPE mseg-lfpos, sjahr TYPE mseg-sjahr, dmbtr TYPE mseg-dmbtr, menge TYPE mseg-menge, matnr TYPE mseg-matnr, mtart TYPE mara-mtart, matkl TYPE mara-matkl, bismt TYPE mara-bismt, meins TYPE mara-meins, bedat TYPE ekko-bedat, waers TYPE ekko-waers, wkurs TYPE ekko-wkurs, verkf TYPE ekko-verkf, * EFFWR TYPE EKPO-EFFWR, tax TYPE ekpo-effwr, maktx TYPE makt-maktx, budat TYPE mkpf-budat, usnam TYPE mkpf-usnam, m_menge TYPE ekpo-menge, ablad TYPE mseg-ablad, wempf TYPE mseg-wempf, END OF ty_output. TYPES: BEGIN OF ty_mseg_103, mblnr TYPE mseg-mblnr, mjahr TYPE mseg-mjahr, zeile TYPE mseg-zeile, bwart TYPE mseg-bwart, werks TYPE mseg-werks, lgort TYPE mseg-lgort, ebeln TYPE mseg-ebeln, ebelp TYPE mseg-ebelp, lfbnr TYPE mseg-lfbnr, lfpos TYPE mseg-lfpos, sjahr TYPE mseg-sjahr, dmbtr TYPE mseg-dmbtr, menge TYPE mseg-menge, matnr TYPE mseg-matnr, mtart TYPE mara-mtart, matkl TYPE mara-matkl, bismt TYPE mara-bismt, meins TYPE mara-meins, bedat TYPE ekko-bedat, waers TYPE ekko-waers, wkurs TYPE ekko-wkurs, verkf TYPE ekko-verkf, * EFFWR TYPE EKPO-EFFWR, tax TYPE ekpo-effwr, maktx TYPE makt-maktx, budat TYPE mkpf-budat, usnam TYPE mkpf-usnam, m_menge TYPE ekpo-menge, ablad TYPE mseg-ablad, wempf TYPE mseg-wempf, END OF ty_mseg_103. TYPES: BEGIN OF ty_mseg_105, mblnr TYPE mseg-mblnr, mjahr TYPE mseg-mjahr, zeile TYPE mseg-zeile, bwart TYPE mseg-bwart, werks TYPE mseg-werks, lgort TYPE mseg-lgort, ebeln TYPE mseg-ebeln, ebelp TYPE mseg-ebelp, lfbnr TYPE mseg-lfbnr, lfpos TYPE mseg-lfpos, sjahr TYPE mseg-sjahr, dmbtr TYPE mseg-dmbtr, menge TYPE mseg-menge, matnr TYPE mseg-matnr, mtart TYPE mara-mtart, matkl TYPE mara-matkl, bismt TYPE mara-bismt, meins TYPE mara-meins, bedat TYPE ekko-bedat, waers TYPE ekko-waers, wkurs TYPE ekko-wkurs, verkf TYPE ekko-verkf, effwr TYPE ekpo-effwr, tax TYPE ekpo-effwr, maktx TYPE makt-maktx, budat TYPE mkpf-budat, ablad TYPE mseg-ablad, wempf TYPE mseg-wempf, END OF ty_mseg_105. *----------------------------------------------------------------------* * DATA: Begin with W_ * *----------------------------------------------------------------------* DATA : it_fcat TYPE slis_t_fieldcat_alv. " alv field catalog DATA : listhead TYPE slis_t_listheader WITH HEADER LINE. DATA: event TYPE slis_t_event WITH HEADER LINE. *----------------------------------------------------------------------* * INTERNAL TABLES: Begin with IT_ * *----------------------------------------------------------------------* DATA : it_output TYPE STANDARD TABLE OF ty_output WITH KEY mblnr mjahr, it_mseg_103 TYPE STANDARD TABLE OF ty_mseg_103, it_mseg_105 TYPE STANDARD TABLE OF ty_mseg_103, it_mseg_106 TYPE STANDARD TABLE OF ty_mseg_103, " LNTDEV1 ADDED it_mara TYPE STANDARD TABLE OF ty_mara, it_ekko TYPE STANDARD TABLE OF ty_ekko, it_ekpo TYPE STANDARD TABLE OF ty_ekpo, it_makt TYPE STANDARD TABLE OF ty_makt, it_mkpf TYPE STANDARD TABLE OF ty_mkpf WITH KEY mblnr. *----------------------------------------------------------------------* * WORKAREAS: Begin with WA_ * *----------------------------------------------------------------------* DATA : wa_fcat LIKE LINE OF it_fcat. DATA : wa_output LIKE LINE OF it_output, wa_mara LIKE LINE OF it_mara, wa_ekko LIKE LINE OF it_ekko, wa_ekpo LIKE LINE OF it_ekpo, wa_makt LIKE LINE OF it_makt, wa_mkpf LIKE LINE OF it_mkpf, wa_mseg_103 LIKE LINE OF it_mseg_103, wa_mseg_105 LIKE LINE OF it_mseg_105, wa_mseg_106 LIKE LINE OF it_mseg_106. " LNTDEV1 ADDED DATA : w_menge LIKE ekpo-menge. *----------------------------------------------------------------------* * FIELD-SYMBOLS: Begin with FS_ * *----------------------------------------------------------------------* *----------------------------------------------------------------------* * PARAMETERS: Begin with PR_ * *----------------------------------------------------------------------* SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME. PARAMETERS : pr_werks LIKE mseg-werks OBLIGATORY. SELECT-OPTIONS : so_budat FOR mkpf-budat. SELECTION-SCREEN END OF BLOCK b1. *----------------------------------------------------------------------* * SELECT-OPTIONS: Begin with SO_ * *----------------------------------------------------------------------* SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME. SELECT-OPTIONS : so_mtart FOR mara-mtart. SELECT-OPTIONS : so_matkl FOR mara-matkl. SELECT-OPTIONS : so_matnr FOR mara-matnr. SELECT-OPTIONS : so_bismt FOR mara-bismt. SELECT-OPTIONS : so_ebeln FOR mseg-ebeln. SELECT-OPTIONS : so_verkf FOR ekko-verkf. SELECT-OPTIONS : so_bedat FOR ekko-bedat. SELECT-OPTIONS : so_mblnr FOR mseg-mblnr. SELECTION-SCREEN END OF BLOCK b2. *AT SELECTION-SCREEN. * *SO_BUDAT-HIGH = SO_BUDAT-HIGH + 1. *---------------------------------------------------------------------* * Query for getting all the Document Segment: Material data from MSEG * * Table which having Movement Types 103 and put into it_mseg table, * * Filtering by reference document and material document number * * Filtering by selection criteria (Material Docu No, Purchase order * * and Plant) * *---------------------------------------------------------------------* *---------------------------------------------------------------------* START-OF-SELECTION. *---------------------------------------------------------------------* SELECT p~mblnr s~mblnr p~mjahr zeile bwart lfbnr werks lgort ebeln ebelp lfpos sjahr dmbtr usnam menge s~budat p~matnr q~mtart p~ablad p~wempf FROM mseg AS p INNER JOIN mara AS q ON p~matnr = q~matnr JOIN mkpf AS s ON s~mblnr EQ p~mblnr INTO CORRESPONDING FIELDS OF TABLE it_mseg_103 WHERE bwart EQ 103 AND p~matnr IN so_matnr AND werks EQ pr_werks AND ebeln IN so_ebeln AND q~mtart IN so_mtart AND p~mblnr IN so_mblnr AND s~budat IN so_budat. ** IF sy-subrc = 0. ENDIF. SELECT p~mblnr s~mblnr p~mjahr zeile bwart lfbnr werks lgort ebeln ebelp lfpos sjahr dmbtr usnam menge s~budat p~matnr q~mtart p~ablad p~wempf FROM mseg AS p INNER JOIN mara AS q ON p~matnr = q~matnr JOIN mkpf AS s ON s~mblnr EQ p~mblnr INTO CORRESPONDING FIELDS OF TABLE it_mseg_105 WHERE bwart EQ 105 OR bwart EQ 104 OR bwart EQ 124 OR bwart EQ 124 AND p~matnr IN so_matnr AND werks EQ pr_werks AND ebeln IN so_ebeln AND q~mtart IN so_mtart AND p~mblnr IN so_mblnr AND s~budat IN so_budat. IF sy-subrc = 0. ENDIF. LOOP AT IT_MSEG_103 INTO WA_MSEG_103. READ TABLE IT_MSEG_105 INTO WA_MSEG_105 WITH KEY LFBNR = WA_MSEG_103-MBLNR. IF SY-SUBRC 0. APPEND WA_MSEG_103 TO IT_OUTPUT. ENDIF. ENDLOOP. SELECT p~mblnr s~mblnr p~mjahr zeile bwart lfbnr werks lgort ebeln ebelp lfpos sjahr dmbtr usnam menge s~budat p~matnr q~mtart p~ablad p~wempf FROM mseg AS p INNER JOIN mara AS q ON p~matnr = q~matnr JOIN mkpf AS s ON s~mblnr EQ p~mblnr INTO CORRESPONDING FIELDS OF TABLE it_mseg_106 WHERE bwart EQ 106 AND p~matnr IN so_matnr AND werks EQ pr_werks AND ebeln IN so_ebeln AND q~mtart IN so_mtart AND p~mblnr IN so_mblnr AND s~budat IN so_budat. LOOP AT it_mseg_103 INTO wa_mseg_103. READ TABLE it_mseg_106 INTO wa_mseg_106 WITH KEY lfbnr = wa_mseg_103-mblnr. IF sy-subrc = 0. APPEND wa_mseg_106 TO it_output. clear wa_mseg_106. ENDIF. ENDLOOP.
Present selection criteria is 1. Plant 2. Posting Date 3. Material Type 4. Material Group 5. Material No. 6. Old Material No. 7. PO Order No. 8. Old PO No. 9. PO Date 10. Material Document No. New selection criteria is 1. PO no. 2. PO date 3. PO value (Ex: >=10000 <=50000) 4. Purch org 5. Doc type 6. Vendor 7. Material 8. Account assignment category 9. Order
I hope the code is readable now.
Thanks in advance.

Similar Messages

  • Sinlge select query in different schemas for same table(Indentical Structu)

    Scenario :
    Table XYZ is created in Schema A
    After an year, the old data from the previous year would be moved to different schema. However in the other schema the same table name would be used.
    For eg
    Schema A contains table XYZ with data of 2012 yr
    Schema B contains table XYZ with data of 2011 yr
    Table XYZ in both the schemas have identical structure.
    So can we fire a single select query to read the data from both the tables in effective way.
    Eg select * from XYZ where date range between 15-Oct-2011 to 15-Mar-2012.
    However the data resides in 2 different schema altogether.

    Thanks for the reply
    Creating an view is an option.
    But my problem, there is ORM layer(either Hibernate or Eclipse Top Link) between the application and the database.
    So the queries would be formed by the ORM layer and are not hand generated.
    So i cannot use view.
    So is there any option that would allow me to use single query on different schema's ?

  • Sinlge select query in diff schemas for same table(Indentical Structure)

    Scenario :
    Table XYZ is created in Schema A
    After an year, the old data from the previous year would be moved to different schema. However in the other schema the same table name would be used.
    For eg
    Schema A contains table XYZ with data of 2012 yr
    Schema B contains table XYZ with data of 2011 yr
    Table XYZ in both the schemas have identical structure.
    So can we fire a single select query to read the data from both the tables in effective way.
    Eg select * from XYZ where date range between 15-Oct-2011 to 15-Mar-2012.
    However the data resides in 2 different schema altogether.
    Creating an view is an option.
    But my problem, there is ORM layer(either Hibernate or Eclipse Top Link) between the application and the database.
    So the queries would be formed by the ORM layer and are not hand generated.
    So i cannot use view.
    So is there any option that would allow me to use single query on different schema's ?

    Hi,
    970773 wrote:
    Scenario :
    Table XYZ is created in Schema A
    After an year, the old data from the previous year would be moved to different schema. However in the other schema the same table name would be used.
    For eg
    Schema A contains table XYZ with data of 2012 yr
    Schema B contains table XYZ with data of 2011 yr
    Table XYZ in both the schemas have identical structure.
    So can we fire a single select query to read the data from both the tables in effective way.That depends on what you mean by "effective".
    Eg select * from XYZ where date range between 15-Oct-2011 to 15-Mar-2012.
    However the data resides in 2 different schema altogether.You can do a UNION, so the data from the two years appears together. The number of actual tables may make the query slower, but it won;t change the results.
    Given that you have 2 tables, the fact that they are in different schemas doesn't matter. Just make sure the user running the query has SELECT privileges on both of them.
    Creating an view is an option.Is it? You seem to say it is not, below.
    But my problem, there is ORM layer(either Hibernate or Eclipse Top Link) between the application and the database.
    So the queries would be formed by the ORM layer and are not hand generated.
    So i cannot use view.So creating a view is not an option. Or is it?
    So is there any option that would allow me to use single query on different schema's ?Anything that you can do with a view, you can do with sub-queries. A view is merely a convenience; it just saves a sub-query, so you don't have to re-code it every time you use it. Assuming you have privilges to query the base tables, you can always avoid using a view by repeating the query that defines the view in your own query. It will not be any slower

  • How to turn off 3G while open 2G for iphone 4s?

    How to turn off 3G while open 2G for iphone 4s?

    Apple removed the ability to disable 3G on the iPhone 4S. iOS 5.1 beta has added the switch back. Whether we'll see it in the final release is unknown. We'll just have to wait & see.

  • In  RSA1 transaction, I written SELECT QUERY while compile It shows error

    Hi All,
                   While compile my SELECT query in RSA1 trans, ENDROUTINE, It show error...
                Select single MAX( date )
                         from dbtable
                         into W_DATE
                        where DOC_NUMBER = w_itab-DOC_NUMBER
                          and S_ORD_ITEM = w_itab-S_ORD_ITEM
                          and Plant     = 'number'.
    ERROR
    E:Unknown column name " date ". not determined until runtime, you
    cannot specify a field list.
    help me please
    reward

    Hi,
    make sure the column 'date' exists in your dbtable. If that is the case, you may be need to take out the spaces in ( date ).
    regards
    Siggi

  • How to run select query from one SID to fetch record from another SID?

    I have two SID, one is AAA and another is BBB and the connection name is A1 and B1 respectively. I want to run one select query from A1 connection to fetch record B1. Can anyone help me how I can connect from one SID to another SID?

    Hi 869357,
    You can also use the copy command. (Works with limited types)
    try:
    help copyRegards,
    Turloch

  • How to write selection Query for the following requirment.

    Hi All,
    I am new to ABAP, I need a help ,
    I need to select all plants(WERKS) from MARC at Plant/Material level,
    then I need to take all sales organozation(VKORG) from T001w,
    then I need the company code(BUKRS) from TVKO based on VKORG,
    then I need the currency key(WAERS) from T001 based on BUKRS,
    Can any one help me in writing selection Query for the same?
    Thanks All,
    Debrup.

    Hi,
    Its easy for you if you learn SELECT with JOIN to complete your task. So SEARCH the forum with SELECT statement and you will get a lot of examples using which you can write your own.
    If you struck up anywhere revert back.
    Regards
    Karthik D

  • How to store select query output in arrays.

    i created a varray type variables and now want to assign some data though select query output in pl/sql code as well as in reports 6i.

    You're in the wrong forum (this one is for issues with the SQL Developer tool). You were in the right one where you posted first, but don't reuse unrelated threads as you did.
    Regards,
    K.

  • Select query in driver program for sapscript

    Hi All,
    I want to select buzei, zuonr,sgtxt,meins from bseg ,temp (a temporary variable of type p deciamls 2), tmp (another temporary variable) and dmbtr from HBSEG (a structure of type bseg) . under the cond
    koart ne 's' or
    xauto ne 'x' or
    buzid ne 't'.
    I have to write this select query usinf a WORKAREA . After this select query i give WRITE_FORM as i call there vairables in script.Its very urgent.
    thanks much

    Hi,
    You can use inner join. Consider this simple example.
    data : a type zvijirank occurs 10 with header line,
              b type zvijirank1 occurs 10 with header line.
    data : name like zvijirank-name,
           total like zvijirank1-total,
           reg_no like zvijirank.
    *       regno type i.
    data : begin of wa,
           name type zvijirank-name,
           total type zvijirank1-total,
           branch type zvijirank1-branch,
           reg_no type zvijirank-reg_no,
    *       FNAME TYPE ZVIJIRANK2-F_NAME,
    *       MNAME TYPE ZVIJIRANK2-M_NAME,
    *       CITY TYPE ZVIJIRANK2-CITY,
    *       TEL_NO TYPE ZVIJIRANK2-TEL_NO,
           end of wa.
    data : it like standard table of wa with header line,
             it1 like standard table of wa with header line.
    call selection-screen 9010.
    select a~name b~total b~branch a~reg_no into table it from zvijirank as a inner join zvijirank1 as b on a~reg_no = b~reg_no .
    loop at it.
    if it-reg_no eq regno.
    write : 'NAME   :', it-name,
            'REG_NO :', it-reg_no,
             'TOTAL :', it-total.
    ENDIF.
    endloop.
    Thanks,
    Reward If Helpful.

  • Select query in not working for Count(*)

    Hi,
    Our batch team running one query that is selecting one table TSFHEAD and this query is hanging. Below are diffrent shenario in which the select query is running on this table.
    select * from tsfhead where create_id = 'BATCH' and create_date = '26-OCT-12';
    --not returning any rows and hanging
    select * from tsfhead where create_id = 'BATCH' ---returning rows
    select * from tsfhead where create_date = '26-OCT-12'; --- returning rows
    select count(*) from tsfhead ----not returning rows and hanging
    This table TSFHEAD has 59000 rows.
    SQL> explain plan for select * from tsfhead where create_id = 'BATCH' and create_date = '26-OCT-12';
    Explained.
    SQL> SELECT * FROM TABLE(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 415503093
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 67 | 215 (1)| 00:00:03 |
    |* 1 | TABLE ACCESS FULL| TSFHEAD | 1 | 67 | 215 (1)| 00:00:03 |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
    1 - filter("CREATE_ID"='BATCH' AND "CREATE_DATE"='26-OCT-12')
    I don't know why this query behaving in this manner.Please help.

    RanVijai_dba wrote:
    Thanks for your reply. But +"select count(*) from tsfhead"+ is hanging and +"select * from tsfhead where create_date = '26-OCT-12' "+ is showing records.It might be showing records, but not necessarily the correct records.
    As sb points out, you are treating dates as strings rather than the DATE datatype. That means you could be querying the wrong data, and your query is also not safe in different environments. It could also effect the query execution plan. Also, as pointed out, you should be ideally using 4 digit years. There were many headaches caused by the use of 2 digit years that most companies corrected as part of the millenium bug fixes prior to the year 2000... well over a decade ago, and most good designs now ensure that 4 digit years are used as standard.
    So your query would be better written as:
    select * from tsfhead where create_date = TO_DATE('26-OCT-2012','DD-MON-YYYY')When you say:
    select count(*) from tsfhead... is hanging, you say the table has around 59000 rows in it, and in reality that's a small amount of records, so a count(*) shouldn't take long at all, even doing a full table scan.
    Post the explain plan for that simple count(*) query for us. (and ensure you use {noformat}{noformat} tags to keep the formatting on the forum, as described in {message:id=9360002})                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to make linkage query In Data Model for search

    I want to make an linkage query as a condition for my  report in BI Publisher. how to make the linkage in Date Model ?

    This is the forum for SQL Developer, not for general SQL or PL/SQL questions.
    Please repost this in the SQL and PL/SQL forum.

  • Simple SELECT query to generate  INSERT for a table

    Hi,
    I am looking for a SELECT query which generates INSERT statements for a table.Please guide.
    Thanks
    PG.

    Like this?
    SQL> SELECT * from kons;
         COL1      COL2
            1         1
            2         2
    SQL> SELECT 'INSERT INTO kons VALUES('||col1||','||col2||');' statement FROM kons;
    STATEMENT
    INSERT INTO kons VALUES(1,1);
    INSERT INTO kons VALUES(2,2);
    SQL> If you have character and / or date columns you will have to change my example,
    but you might get the idea from it.
    You can spool the result to a file.
    Regards,
    Guido
    Edit: ';' added to end of statement...

  • How to pass multiple query string values using the same parameter in Query String (URL) Filter Web Part

    Hi,
    I want to pass multiple query string values using the same parameter in Query String (URL) Filter Web Part like mentioned below:
    http://server/pages/Default.aspx?Title=Arup&Title=Ratan
    But it always return those items whose "Title" value is "Arup". It is not returned any items whose "Title" is "Ratan".
    I have followed the
    http://office.microsoft.com/en-us/sharepointserver/HA102509991033.aspx#1
    Please suggest me.
    Thanks | Arup
    THanks! Arup R(MCTS)
    SucCeSS DoEs NOT MatTer.

    Hi DH, sorry for not being clear.
    It works when I create the connection from that web part that you want to be connected with the Query String Filter Web part. So let's say you created a web part page. Then you could connect a parameterized Excel Workbook to an Excel Web Access Web Part
    (or a Performance Point Dashboard etc.) and you insert it into your page and add
    a Query String Filter Web Part . Then you can connect them by editing the Query String Filter Web Part but also by editing the Excel Web Access Web Part. And only when I created from the latter it worked
    with multiple values for one parameter. If you have any more questions let me know. See you, Ingo

  • How to improve select stmt performance without going for secondary index

    Hi friends,
    I have a select statement which does not contains key fields(Primary index) in where condition. And I have to improve that select stmt performance without going for the secondary indexes.
    Can you plese suggest the alternative way for this?.
    Thanks in advance,
    Ramesh.

    Hi,
    If , possible create a secondary index opf your own But if you have restriction on this, try to arrange the fields in where clause in the same order as they appear in the very table.
    This will help the performance a bit.
    Another issue, If your table doesn't contain any critical data or data in them are not updated frequently, you may go for Bufferring . it is a good alternate of Indexing with above limitations.
    For details in bufferring , check, and all the sublinks.
    [concept of buffering|http://help.sap.com/saphelp_nw04/helpdata/en/cf/21f244446011d189700000e8322d00/content.htm]
    Regards,
    Anirban

  • How to LOOP SELECT Query in Oracle?

    Hello
    I have a query which use a variable (:enddate) and returns a set of data. Lets assume it gives sales totals by account for a given month (specified using the variable :enddate). So the query would look something like :
    SELECT ACCOUNT_NO, SUM(SALE_AMT) TOTAL_SALES FROM SCHEMA1.SALES_LINES, :ENDDATE as END_DATE WHERE SALE_DATE BETWEEN addmonths(:ENDDATE,-1) and :ENDDATE
    GROUP BY ACCOUNT_NO
    Now, currently, I have to run this query each time I need results for a particular date, and thats OK but the problem arises when I need to run this query for an entire year. Then I have to run the query 12 times, passing the date variable each time and re-running the query.
    What I would like to do, is to create a loop which covers a time period entered by the user (e.g. user enters 12 months as the total time and 1 month as the period, and the query automatically runs for the previous 12 months, passing :enddate 1 month at a time and then presents the combined results) OR takes a bunch of dates entered in an array, (e.g. :enddate in (JAN-31-2009, Feb-28-2009, MAR-31-2009, APR-30,2009 etc) and runs the query for each of them and presents the results together in one set.
    How can I do this using a simple PLSQL loop? I would like to avoid creating a procedure if possible. Sample code will be much appreciated.
    BTW, I am using Oracle XE 10g.
    Thanks

    Hi,
    It will be more efficient to get all the results at once, rather than running 12 separate queries.
    You can do that without loops or PL/SQL, something like this:
    SELECT    account_no
    ,       TRUNC (sale_date, 'MONTH')     AS mnth
    ,        SUM (sale_amt)          AS total_sales
    FROM        schema1.sales_lines
    WHERE       sale_date     >  ADD_MONTHS (:enddate, -12)
    AND       sale_date     <= :enddate
    GROUP BY  account_no
    ,            TRUNC (sale_date, 'MONTH')
    ;Of course, you can do a query like this within PL/SQL if you need to.
    If you'd care to post some sample data (CREATE TABLE and INSERT statements) and the results you want from that data, then I could test it.
    Simplify as much as possible. For example, instead of 12 sepaarte months, you can post just 2 or 3. Adapting the solution for 12 months should be easy.
    In pure SQL, bind varibales can't be DATEs, but you could define the bind variable as a string and use TO_DATE to convert it to a DATE, OR use a substitution variable instead of a bind variable.
    The solution above works in all versions Oracle. The way you're using :enddate in the FROM clause, and a function called addmonths (rather than ADD_MONTHS) makes me wonder if you're using Oracle at all.

Maybe you are looking for