Dynamic SELECT clause using lexical param

Aloha all.
I've been working with Report 6i for a while now, but was
wondering if anyone had success using lexical parameters in the
SELECT clause. I've done it in the WHERE clause many times.
Here's what I want to do:
select &column_list from &table_list where &cond_list
where &column_list will be a dynamic number of columns. I know
you can do this, but how do you display the dynamic columns back
to the report?
Thanks in advance.
Floyd Casem

You can pass each column as a parameter:
select
&p_column1 column1,
&p_column2 column2,
from &p_table table
&p_where
You will of course have to find a way of hiding the not needed
columns, but I think it can work with a little bit of work.

Similar Messages

  • Need to know the column names in my dynamic select clause

    Dear All,
    Please go through the following code. While executing the following code i am getting an error saying that dbms_sql.describe_columns overflow, col_name_len=35. Use describe_columns2.
    Please guide me how to proceed further. Or please help me, how can i get the column names when i issue a dynamic select clause.
    DECLARE
    CUR INTEGER;
    COL_CNT INTEGER ;
    A INTEGER;
    SEL_CLAUSE VARCHAR2(2000);
    DESC_T DBMS_SQL.DESC_TAB;
    REC DBMS_SQL.DESC_REC;
    b number;
    BEGIN
    SEL_CLAUSE := 'SELECT 1,2,DECODE(1,1,''ONE'',2,''TWO'',3,''THREE'') FROM DUAL';
    --'SELECT ROWID,PARA_SUB_CODE,DECODE('||''''||'ENG'||''''||','||''''||'ENG'||''''||',PARA_NAME,PARA_BL_NAME),NULL,NULL FROM PCOM_APP_PARAMETER';
    --'SELECT 1,2,DECODE(1,1,''ONE'',2,''TWO'') FROM DUAL';
    DBMS_OUTPUT.PUT_LINE( SEL_CLAUSE );
    CUR := DBMS_SQL.OPEN_CURSOR;
    DBMS_SQL.PARSE(CUR,SEL_CLAUSE,DBMS_SQL.NATIVE);
    DBMS_SQL.DESCRIBE_COLUMNS(CUR,COL_CNT,DESC_T);
    B := desc_t.first;
    FOR J IN 1..COL_CNT
    LOOP
    DBMS_OUTPUT.PUT_LINE('J := '||J || ' COL CNT ' || COL_CNT);
    END LOOP;
    BEGIN
    A := DBMS_SQL.EXECUTE(CUR);
    EXCEPTION
    WHEN OTHERS THEN
    NULL;
    END;
    END;
    Regards,
    Balaji

    Is there any way can i have it directly??It does not work with static SQL either. Dynamic SQL is no different.
    SQL> select 1 x from dual where x = 1 ;
    select 1 x from dual where x = 1
    ERROR at line 1:
    ORA-00904: "X": invalid identifier
    SQL>As suggested already, you will need to use alias if you want your select expression to be referred in the where clause.
    SQL> BEGIN
      2      FOR rec IN (SELECT *
      3                  FROM   (SELECT 1,
      4                                 2,
      5                                 DECODE(1, 1, 'ONE', 2, 'TWO', 3, 'THREE') "DECODE(1, 1, 'ONE', 2, 'TWO', "
      6                          FROM   DUAL)
      7                  WHERE  "DECODE(1, 1, 'ONE', 2, 'TWO', " = 'ONE')
      8      LOOP
      9          NULL;
    10      END LOOP;
    11  END;
    12  /
    PL/SQL procedure successfully completed.
    SQL>Message was edited by:
    Kamal Kishore

  • To create Dynamic Selection screen using Key Fields

    Hi All,
    We have a requirement where we want to create Dynamic selection screen using Key fileds of Z-table or any standard table.
    Please provide some solution if you have worked in this area.
    Thanks in Advance,
    Anand Raj Kuruba

    Hi,
    You can use the following statement.
    SELECTION-SCREEN DYNAMIC SELECTIONS FOR NODE|TABLE <node>.
    declares a node <node> of a logical database for dynamic selections in the selection include.
    To use the dynamic selections in the SELECT statements of the subroutine PUT_<node>, you must use the data object DYN_SEL. The data object DYN_SEL is automatically generated in the logical database program as follows:
    TYPE-POOLS RSDS.
    DATA DYN_SEL TYPE RSDS_TYPE.
    You do not have to program these lines yourself. The data object DYN_SEL is available in the database program but not in a connected executable program.
    The type RSDS_TYPE of the data object is defined in the type group RSDS as follows:
    TYPE-POOL RSDS.
    WHERE-clauses ------------------------------
    TYPES: RSDS_WHERE_TAB LIKE RSDSWHERE OCCURS 5.
    TYPES: BEGIN OF RSDS_WHERE,
    TABLENAME LIKE RSDSTABS-PRIM_TAB,
    WHERE_TAB TYPE RSDS_WHERE_TAB,
    END OF RSDS_WHERE.
    TYPES: RSDS_TWHERE TYPE RSDS_WHERE OCCURS 5.
    Expressions Polish notation ---------------
    TYPES: RSDS_EXPR_TAB LIKE RSDSEXPR OCCURS 10.
    TYPES: BEGIN OF RSDS_EXPR,
    TABLENAME LIKE RSDSTABS-PRIM_TAB,
    EXPR_TAB TYPE RSDS_EXPR_TAB,
    END OF RSDS_EXPR.
    TYPES: RSDS_TEXPR TYPE RSDS_EXPR OCCURS 10.
    Selections as RANGES-tables -----------------
    TYPES: RSDS_SELOPT_T LIKE RSDSSELOPT OCCURS 10.
    TYPES: BEGIN OF RSDS_FRANGE,
    FIELDNAME LIKE RSDSTABS-PRIM_FNAME,
    SELOPT_T TYPE RSDS_SELOPT_T,
    END OF RSDS_FRANGE.
    TYPES: RSDS_FRANGE_T TYPE RSDS_FRANGE OCCURS 10.
    TYPES: BEGIN OF RSDS_RANGE,
    TABLENAME LIKE RSDSTABS-PRIM_TAB,
    FRANGE_T TYPE RSDS_FRANGE_T,
    END OF RSDS_RANGE.
    TYPES: RSDS_TRANGE TYPE RSDS_RANGE OCCURS 10.
    Definition of RSDS_TYPE
    TYPES: BEGIN OF RSDS_TYPE,
    CLAUSES TYPE RSDS_TWHERE,
    TEXPR TYPE RSDS_TEXPR,
    TRANGE TYPE RSDS_TRANGE,
    END OF RSDS_TYPE.
    For more information, please check this link.
    http://help.sap.com/saphelp_nw04/helpdata/en/67/93b80914a911d2953c0000e8353423/content.htm
    Regards,
    Ferry Lianto

  • Dynamic select-options using parameter

    Hi experts,
    It the user selects one value from dropdown list, it should generate one select-option using that name. Is it possible?
    for example, (pls see my code).
    If user selects 'Malek' from parameter, <b>and press 'ENTER'</b>
    <b>select-option should display with that name</b> like
    Malek      malek-low  malek-high
    And if user selects some other like 'Amran'. It should generate(and append)
    Malek      malek-low  malek-high
    amran      amran-low amran-high
    and so on....
    report c.
    data: t_return like ddshretval occurs 0 with header line.
    data: begin of t_names occurs 0,
           name like usr01-bname,
          end of t_names.
    parameters : i_inspec like usr01-bname.
    at selection-screen on value-request for i_inspec.
      perform get_names.
    form get_names.
      t_names-name = 'Malek'.
      append t_names.
      t_names-name = 'Amran'.
      append t_names.
      t_names-name = 'Ow CC'.
      append t_names.
      t_names-name = 'titbit'.
      append t_names.
      call function 'F4IF_INT_TABLE_VALUE_REQUEST'
        exporting
          retfield    = 'T_NAMES-NAME'
          dynpprog    = sy-cprog
          dynpnr      = sy-dynnr
          dynprofield = 'I_INSPEC'
          value_org   = 'S'
        tables
          value_tab   = t_names.
      if sy-subrc <> 0.
        message id sy-msgid type sy-msgty number sy-msgno with
        sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
      read table t_return index   1.
    endform.                    "GET_NAMES
    Reward guaranteed,
    thanks
    kaki

    Use At selection-screen output,use screen internal table..
    User Dynamic Selection
    at selection-screen output.
      select single * from t000md.
      loop at screen.
        case screen-group1.
          when 'REL'.
            if not  p_old is initial.
              screen-input = '0'.
              screen-required = '0'.
              screen-invisible = '1'.
            endif.
            modify screen.
          when 'BEL'.
            if not p_new is initial.
              screen-input = '0'.
              screen-required = '0'.
              screen-invisible = '1'.
            endif.
            modify screen.
          when 'ARB'.
            if  p_new is initial.
              screen-input = '0'.
              screen-required = '0'.
              screen-invisible = '1'.
            endif.
            modify screen.
          when 'MTA'.
            if  p_new is initial.
              screen-input = '0'.
              screen-required = '0'.
              screen-invisible = '1'.
            endif.
            modify screen.
        endcase.
      endloop.

  • Dynamis where Condition using select-options

    Hi All,
    I am trying to form a dynamic where clause using values entered on a selection screen. I want that if a new entry is added in the selection screen the where clause can also be modified dynamically without any change in coding. The only change required should be addition of select-option statement in the selection screen declaration.
    Thanks in advance.
    Anju

    refer below example
    L_COND_SYNTAX = 'd2ext_status = l_status and d2ext_date ne c_intdate and '
    & 'd2~ext_uploaded = space'.
    SELECT D1TKNUM D1SHTYP D1TPLST D1ERNAM D1ERDAT D1BFART
    D1VSART D1ROUTE D1SIGNI D1EXTI1 D1~TPBEZ
    D1DATBG D1UATBG D1TDLNR D2VBELN D2~POSNR
    D2EXT_FAILED D2EXT_COUNT D2EXT_DATE D2EXT_TIME
    D2EXT_REP_DATE D2EXT_REP_TIME
    D2EXT_RES_DATE D2EXT_RES_TIME D2~EXT_ERR_TYPE
    INTO TABLE PA_GT_SHIP_HEADER
    FROM VTTK AS D1 INNER JOIN RIOZTM_DELSTAT AS D2
    ON D1TKNUM = D2TKNUM
    WHERE
    D1~TKNUM IN S_TKNUM AND
    D1~SHTYP IN S_SHTYP AND
    AND
    <b>(L_COND_SYNTAX).</b>
    Plz note the backet in L_COND_SYNTAX.
    Reward points if helpful

  • REPORT with dynamic WHERE CLAUSE (run RDF or REP) ?

    Hi:
    When running a REPORT (myreport.rep) with dynamic where clause using a lexical parameter, I got this error:
    REP-1439: Cannot compile .REP or .PLX file as it does not have source
    If i run the report specifiying RDF extension (myreport.rdf) the report run successfully! Is this normal ?
    If I specify RDF extension will Report Server COMPILE the report everytime I execute it ?
    When using dynamic WHERE CLAUSE I will have to run RDF files instead of REP ?
    I'm running Reports 9i under Linux, with IDS under Windows.
    Waiting Help
    Joao Oliveira

    It sounds like you are building the .rep files on one platform (windows) and running them on another (linux). The reason that the .rdf file continues to work is that Reports recompiles the PL/SQL within the report when you move from one platform to another or change schemas. .rep files can't be re-compiled in this way so you need to ensure they are compiled successfully when converting them.
    You need to convert from .rdf to .rep on the platform that you are intending to run on. Try running rwconverter on the linux platform with "compile_all=yes" to produce the .rep file and running that .rep file.

  • DYNAMIC SELECTION SCREEN uisng FREE_SELECTIONS_INIT

    Hi,
    I am facing a problem regarding the dynamic selection screen using FREE_SELECTIONS_INIT and FREE_SELECTIONS_DIALOG .After entering the values in Dynamic Selections on pressing Enter, the values are  getting distorted.For example if i gave the purchase order no as 0099994434 it is getting truncated to four digits no like 0099.
    Its a bit urgent .Can any body help me out in resolving this isuue.

    Hi,
    You may refer this http://help.sap.com/saphelp_47x200/helpdata/en/9f/db996135c111d1829f0000e829fbfe/frameset.htm
    Raja T
    Message was edited by:
            Raja T

  • Dynamic Selection screen in FDK43 transaction

    HI,
    The transaction FDK43 has a dynamic selection screen used from LDB DDF .It does not show all selections views in the dynamic selection but when I test the LDB from se36 its shows all the selections in dynamic selections.
    Any idea why it is not showind in the transaction FDK43 ??
    Regards,
    Shital

    Hi,
    LDB fields are nothing to do with Dynamic Selection. It is not necessary that all the field of LDB should be visible in Dynamic Selection. FDK43 is a standard screen and SAP has designed the dynamic selection with limited option. If you want additional fields, you need to do the enhancement with the help of ABAPer.
    Regards,
    Ravi

  • How to change the Dynamic Selection screen

    Dear Freinds,
                I have requirement where in on the selection of Dynamic Selections ( iam using PNP logical database) i want to add another fields , could  any one tell me how to change  Dynamic Selections as per my requirement.
    please let me know .
    regards
    divya

    Hi Prat,
               I have done similar way and saved the view ( i.e se80> ediobject>table>table name > given all the tables required for me and i try to saved it is not allowing to save and giving message as empty view cannot be saved. Therefore i have selected the tables which have been added and made one by table and selected them . some how it got saved. Now when i added this name of the view in the custom report caterogy and executed my custom report and selected the > dynamic selections i found as empty and in debugging i can see all the 4 tables which i have mentioed while createing view are there . But i dint understood why the custom View is empty.
    please correct me where i went wrong.
    regards
    divya'

  • How to make dynamic selection in case of innerjoin

    hi
    in run time i will get some table name into g_v_fubw
    if i write a select quiry like this its working
      SELECT * FROM (g_v_fubw)
        INTO TABLE g_it_fubw
        FOR ALL ENTRIES IN g_it_werks
        WHERE kostl IN s_kostl3    AND
              platznr IN s_platz3  AND
              werks = g_it_werks-werks   AND
              matnr IN s_matnr     AND
              prctr IN s_prctr.
    But if i am  using inner join  like bellow
        SELECT
        avalev ainvpe vastrd vtxjhr a~bukrs
        awerks amatnr
        aindei abwtar a~bklas
        v~adqty
        v~meins
        a~peinh
        INTO TABLE g_it_temp_display
                FROM (g_v_fuba) AS a INNER JOIN
                     (g_v_abcd) AS v ON
                       amatnr = vmatnr AND
                       ainvpe = vinvpe
              WHERE a~invpe EQ p_invw                 AND
                    a~valev EQ 'P'              AND
                    v~astrd IN g_r_astrd              AND
                    v~txjhr IN g_r_txjhr              AND
                    a~bukrs EQ p_bukrs                AND
    its not working
    how can i write dynamic select quiry using innerjoin

    Hi...
    Make sure the structure of g_it_temp_display is same as the selected fields.
    FROM (g_v_fuba AS a INNER JOIN
    g_v_abcd AS v ON
    amatnr = vmatnr AND
    ainvpe = vinvpe ).....>
    See the syntax...
    as below...
    SELECT a~knuma_ag          "SAP agreement number
           a~boart_ag              "SAP agreement type
           a~zzlegsum              "Legacy summary number
           b~datab                 "Begin date
           b~datbi                 "End date
      FROM ( /irm/ipbbasp AS a INNER JOIN  kona AS b ON
      aknuma_ag = bknuma )
      INTO TABLE i_irm_kona
      FOR ALL ENTRIES  IN i_kona_deal
      WHERE a~boart_ag IN r_agrmnt_typ  AND         "SAP agreement type
            a~zzlegsum IN r_summ_number AND         "Legacy summary number
            b~knuma = i_kona_deal-knuma AND         "SAP agreement No
            b~valdt    IN r_ppd.                "Prior price date

  • Join Table & Dynamic Selection

    Hi Gurus,
    I need to do a performance tuning on a bad response time program.
    Therefore i use inner join to improve the response time, it works.
    But my problem is the original program was using dynamic selection(with LDB), so i need to retain the same feature(i.e. dynamic selection) in new program.
    I use FM 'FREE_SELECTIONS_INIT' & FM 'FREE_SELECTIONS_DIALOG' to let user entering dynamic selections.
    How can the SELECT with JOIN be done with dynamic selection?
    Thanks in advance.
    Regards,
    Hikaruno

    Hai   ... here is the program for   using the dynamic  selection  FM  used .
    REPORT zmodtab NO STANDARD PAGE HEADING.
    TYPE-POOLS: rsds.
    DATA: is_x030l  TYPE x030l,
          it_dfies  TYPE TABLE OF dfies,
          is_dfies  TYPE dfies,
          it_fdiff  TYPE TABLE OF field_dif,
          is_fdiff  TYPE field_dif.
    DATA: w_selid   TYPE rsdynsel-selid,
          it_tables TYPE TABLE OF rsdstabs,
          is_tables TYPE rsdstabs,
          it_fields TYPE TABLE OF rsdsfields,
          it_expr   TYPE rsds_texpr,
          it_ranges TYPE rsds_trange,
          it_where  TYPE rsds_twhere,
          is_where  TYPE rsds_where,
          w_active  TYPE i.
    DATA: it_content TYPE REF TO data,
          it_modif   TYPE REF TO data,
          it_fcat    TYPE lvc_t_fcat.
    DATA: w_okcode   TYPE sy-ucomm.
    FIELD-SYMBOLS: <itab> TYPE STANDARD TABLE,
                   <ntab> TYPE STANDARD TABLE.
    * Macros
    DEFINE table_error.
      message e398(00) with 'Table' p_table &1.
    END-OF-DEFINITION.
    DEFINE fixed_val.
      is_fdiff-fieldname = is_dfies-fieldname.
      is_fdiff-fixed_val = &1.
      is_fdiff-no_input  = 'X'.
      append is_fdiff to it_fdiff.
    END-OF-DEFINITION.
    * Selection screen
    SELECTION-SCREEN: BEGIN OF BLOCK b01 WITH FRAME.
    PARAMETERS: p_table TYPE tabname OBLIGATORY                    "table
                                     MEMORY ID dtb
                                     MATCHCODE OBJECT dd_dbtb_16.
    SELECTION-SCREEN: BEGIN OF LINE,
                      PUSHBUTTON 33(20) selopt USER-COMMAND sel,
                      COMMENT    55(15) selcnt,
                      END OF LINE.
    SELECTION-SCREEN: SKIP.
    PARAMETERS: p_rows  TYPE i.                                    "rows
    SELECTION-SCREEN: END OF BLOCK b01,
                      SKIP,
                      BEGIN OF BLOCK b02 WITH FRAME.
    PARAMETERS: p_displ TYPE c AS CHECKBOX.                        "display
    SELECTION-SCREEN: END OF BLOCK b02.
    * Initialization
    INITIALIZATION.
      MOVE '@4G@ Filter records' TO selopt.
    * PBO
    AT SELECTION-SCREEN OUTPUT.
      IF w_active IS INITIAL.
        CLEAR: selcnt.
      ELSE.
        WRITE w_active TO selcnt LEFT-JUSTIFIED.
      ENDIF.
    * PAI
    AT SELECTION-SCREEN.
      IF p_table NE is_x030l-tabname.
        CALL FUNCTION 'DDIF_NAMETAB_GET'
             EXPORTING
                  tabname   = p_table
             IMPORTING
                  x030l_wa  = is_x030l
             TABLES
                  dfies_tab = it_dfies
             EXCEPTIONS
                  OTHERS    = 1.
        IF is_x030l IS INITIAL.
          table_error 'does not exist or is not active'.
        ELSEIF is_x030l-tabtype NE 'T'.
          table_error 'is not selectable'.
        ELSEIF is_x030l-align NE 0.
          table_error 'has alignment - cannot continue'.
        ENDIF.
    *   Default values for system fields
        REFRESH: it_fdiff.
        is_fdiff-tabname = p_table.
        LOOP AT it_dfies INTO is_dfies.
          IF is_dfies-datatype = 'CLNT'.
            fixed_val sy-mandt.
          ELSEIF is_dfies-rollname = 'ERDAT'
              OR is_dfies-rollname = 'ERSDA'
              OR is_dfies-rollname = 'AEDAT'
              OR is_dfies-rollname = 'LAEDA'.
            fixed_val sy-datum.
          ELSEIF is_dfies-rollname = 'ERTIM'
              OR is_dfies-rollname = 'AETIM'.
            fixed_val sy-uzeit.
          ELSEIF is_dfies-rollname = 'ERNAM'
              OR is_dfies-rollname = 'AENAM'.
            fixed_val sy-uname.
          ENDIF.
        ENDLOOP.
    *   Prepare free selection on table
        REFRESH it_tables.
        is_tables-prim_tab = p_table.
        APPEND is_tables TO it_tables.
        CLEAR: w_selid.
      ENDIF.
      IF sy-ucomm = 'SEL'.
        IF w_selid IS INITIAL.
    *     Init free selection dialog
          CALL FUNCTION 'FREE_SELECTIONS_INIT'
               EXPORTING
                    expressions  = it_expr
               IMPORTING
                    selection_id = w_selid
                    expressions  = it_expr
               TABLES
                    tables_tab   = it_tables
               EXCEPTIONS
                    OTHERS       = 1.
        ENDIF.
    *   Display free selection dialog
        CALL FUNCTION 'FREE_SELECTIONS_DIALOG'
             EXPORTING
                  selection_id            = w_selid
                  title                   = 'Selection'
                  status                  = 1
                  as_window               = 'X'
             IMPORTING
                  expressions             = it_expr
                  field_ranges            = it_ranges
                  number_of_active_fields = w_active
             TABLES
                  fields_tab              = it_fields
             EXCEPTIONS
                  OTHERS                  = 1.
      ENDIF.
    * Start of processing
    START-OF-SELECTION.
      PERFORM f_create_table USING p_table.
      PERFORM f_select_table.
      PERFORM f_display_table.
    *       FORM f_create_table                                           *
    FORM f_create_table USING in_tabname.
      FIELD-SYMBOLS: <fcat> TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
           EXPORTING
                i_structure_name = in_tabname
           CHANGING
                ct_fieldcat      = it_fcat
           EXCEPTIONS
                OTHERS           = 1.
      IF sy-subrc = 0.
    *   Complete field catalog
        LOOP AT it_fcat ASSIGNING <fcat>.
          <fcat>-tabname = in_tabname.
        ENDLOOP.
        CALL FUNCTION 'LVC_FIELDCAT_COMPLETE'
             CHANGING
                  ct_fieldcat = it_fcat
             EXCEPTIONS
                  OTHERS      = 1.
      ELSE.
        WRITE: 'Error building field catalog'.
        STOP.
      ENDIF.
    * Create dynamic table for data
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_fcat
        IMPORTING
          ep_table        = it_content.
      IF sy-subrc = 0.
        ASSIGN it_content->* TO <itab>.
      ELSE.
        WRITE: 'Error creating internal table'.
        STOP.
      ENDIF.
    * Create dynamic table for modif
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_fcat
        IMPORTING
          ep_table        = it_modif.
      IF sy-subrc = 0.
        ASSIGN it_modif->* TO <ntab>.
      ELSE.
        WRITE: 'Error creating internal table'.
        STOP.
      ENDIF.
    ENDFORM.
    *       FORM f_select_table                                           *
    FORM f_select_table.
      IF w_active = 0.
        SELECT * FROM (p_table)
                 INTO CORRESPONDING FIELDS OF TABLE <itab>
                UP TO p_rows ROWS.
      ELSE.
    *   Selection with parameters
        CALL FUNCTION 'FREE_SELECTIONS_RANGE_2_WHERE'
             EXPORTING
                  field_ranges  = it_ranges
             IMPORTING
                  where_clauses = it_where.
        READ TABLE it_where INTO is_where WITH KEY tablename = p_table.
        SELECT * FROM (p_table)
                 INTO CORRESPONDING FIELDS OF TABLE <itab>
                UP TO p_rows ROWS
                WHERE (is_where-where_tab).
      ENDIF.
      IF sy-dbcnt = 0.
        WRITE: 'No record selected'.
        STOP.
      ENDIF.
    ENDFORM.
    *       FORM f_display_table                                          *
    FORM f_display_table.
      DATA: l_answer TYPE c,
            l_eflag  TYPE c.
      CLEAR: w_okcode.
      REFRESH: <ntab>.
    * Display table contents
      CALL FUNCTION 'STC1_FULLSCREEN_TABLE_CONTROL'
           EXPORTING
                header       = p_table
                tabname      = p_table
                display_only = p_displ
                endless      = 'X'
                no_button    = space
           IMPORTING
                okcode       = w_okcode
           TABLES
                nametab      = it_dfies
                table        = <itab>
                fielddif     = it_fdiff
                modif_table  = <ntab>
           EXCEPTIONS
                OTHERS       = 1.
      IF sy-subrc = 0.
        IF p_displ IS INITIAL AND w_okcode = 'SAVE'.
    *     Confirm update
          CALL FUNCTION 'POPUP_TO_CONFIRM'
               EXPORTING
                    titlebar              = p_table
                    text_question         = 'Do you want to update table ?'
                    default_button        = '2'
                    display_cancel_button = ' '
               IMPORTING
                    answer                = l_answer
               EXCEPTIONS
                    OTHERS                = 1.
          IF l_answer = '1'.
    *       Apply modifications
            IF NOT <ntab>[] IS INITIAL.
              PERFORM f_add_system USING space.
              MODIFY (p_table) FROM TABLE <ntab>.
              IF sy-subrc NE 0.
                l_eflag = 'X'.
              ENDIF.
            ENDIF.
    *       Apply deletions
            IF l_eflag IS INITIAL.
              REFRESH: <ntab>.
              CALL FUNCTION 'STC1_GET_DATA'
                   TABLES
                        deleted_data = <ntab>
                   EXCEPTIONS
                        OTHERS       = 1.
              IF NOT <ntab>[] IS INITIAL.
                DELETE (p_table) FROM TABLE <ntab>.
                IF sy-subrc NE 0.
                  ROLLBACK WORK.
                  l_eflag = 'X'.
                ENDIF.
              ENDIF.
            ENDIF.
    *       Apply creations
            IF l_eflag IS INITIAL.
              REFRESH: <ntab>.
              CALL FUNCTION 'STC1_GET_DATA'
                   TABLES
                        new_data = <ntab>
                   EXCEPTIONS
                        OTHERS   = 1.
              IF NOT <ntab>[] IS INITIAL.
                PERFORM f_add_system USING 'X'.
                INSERT (p_table) FROM TABLE <ntab>.
                IF sy-subrc NE 0.
                  ROLLBACK WORK.
                  l_eflag = 'X'.
                ENDIF.
              ENDIF.
            ENDIF.
            IF l_eflag IS INITIAL.
              COMMIT WORK.
              MESSAGE s261(53).
            ELSE.
              MESSAGE s075(3i).
              PERFORM f_select_table.
            ENDIF.
          ENDIF.
    *     Display table again
          PERFORM f_display_table.
        ENDIF.
      ENDIF.
    ENDFORM.
    *       FORM f_add_system                                             *
    FORM f_add_system USING new TYPE c.
      FIELD-SYMBOLS: <irec> TYPE ANY,
                     <upd>  TYPE ANY.
      LOOP AT it_fdiff INTO is_fdiff.
        READ TABLE it_dfies INTO is_dfies
                        WITH KEY fieldname = is_fdiff-fieldname.
        LOOP AT <ntab> ASSIGNING <irec>.
          ASSIGN COMPONENT is_fdiff-fieldname OF STRUCTURE <irec> TO <upd>.
          IF is_dfies-datatype = 'CLNT'.
            <upd> = sy-mandt.
          ELSE.
            CASE is_dfies-rollname.
              WHEN 'AENAM'.
                <upd> = sy-uname.
              WHEN 'AEDAT' OR 'LAEDA'.
                <upd> = sy-datum.
              WHEN 'AETIM'.
                <upd> = sy-uzeit.
              WHEN OTHERS.
            ENDCASE.
          ENDIF.
        ENDLOOP.
      ENDLOOP.
    ENDFORM.
    reward  points if it is usefull......
    Girish

  • &param lexical variable in SELECT clause

    Is there a way to get Oracle*Reports to accept a lexical variable in the SELECT clause? The example is:
    SELECT
    table.column1,
    table.column2,
    &PARAM as column3
    FROM
    table
    I am already using lexical variables in the WHERE clause, but getting one to work in the SELECT clause has thus far failed.
    The SQL is accepted if :PARAM is used in place of &PARAM, but I am unable to actually vary the selected column this way.
    The bind variable PARAM has the following code behind it in a BeforeReport trigger:
    IF :ANOTHER_PARAM := 'ALL' THEN
    :PARAM = 'ALL'
    ELSE
    :PARAM = 'table.column3'
    When using :PARAM in the SELECT clause, the literals 'table.column3' are returned, not the contents of table.column3.

    Sorry for the wasted bandwidth. I found a solution. Here it is:
    SELECT
    table.column1,
    table.column2,
    CASE :P_USER
    WHEN 'ALL' THEN 'ALL'
    ELSE table.column3
    END as column3

  • Dynamic Where Clause in select using member attribute of class

    Hello,
    can anybody provide me some tips how to solve this problem:
              SELECT (lv_sql_select) INTO CORRESPONDING FIELDS OF TABLE lt_cntrl2
                         FROM (lv_db_name)
                     FOR ALL ENTRIES IN mt_guids
                 WHERE (lv_sql_where).
    works perfectly fine if I use a local table variable or a member of my class. But if I build my where clause using a member attribute of my class which comes from the interace- exactly the same type and data as before I get a dump.
    SELECT (lv_sql_select) INTO CORRESPONDING FIELDS OF TABLE lt_xyz
                         FROM (lv_db_name)
                     FOR ALL ENTRIES IN if_abc~mt_guids
    my where clause "guid = if_abc~mt_guids-guid.
    Dump:
    Error analysis
        An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_SY_DYNAMIC_OSQL_SEMANTICS', was
         not caught in
        procedure "....GET_DATA" "(METHOD)", nor was it propagated
         by a RAISING clause.
        Since the caller of the procedure could not have anticipated that the
        exception would occur, the current program is terminated.
        The reason for the exception is:
        Das laufende ABAP-Programm wollte eine Open SQL-Anweisung ausführen,
        die eine dynamische Angabe enthält. Der Parser lieferte jedoch den
        Fehler: "Wrong table name or table alias name table alias name
         table alias name "....". table alias name
         "...". table alias name "...". t"

    Hi Marco Freischlag,
      As per my understanding , if we give for all entries we want to use internal table ,  For where conditions you want to pass variable , not internal table one filed,because it will not have header line...
    so code like this...
    SELECT (lv_sql_select) INTO CORRESPONDING FIELDS OF TABLE lt_xyz
                         FROM (lv_db_name)
                     FOR ALL ENTRIES IN if_abc~mt_guids
              where guid = if_abc~mt_guids-guid. " Here pass some variable or work area in it and test.
    Thanks,
    Vijay SR

  • Dynamic WHERE clause in SELECT statement

    Hi,
    I need to extract (SELECT) all the products in different salesorganizations. Since a product can be available in more than 1 salesorg I have created several properties in the PRODUCT dimension - 1 for each salesorganization (naming: Sxxxx where xxxx is the salesorganization number).
    Since I need to prefix the salesorganization property with an "S" I have created a property on the SALESORG dimension called SALESORG.
    Therefore I need to create a dynamic WHERE clause in the SELECT statement. Currently my script is:
    *SELECT(%SORG%, "[SALESORG]",SALESORG, [ID]=%SALESORG_SET%)
    *SELECT(%PROD%, "[ID]",PRODUCT, [%SORG%]="X")
    My first SELECT find the Sxxx (equal to the property I need in the PRODUCT dimension). My second SELECT uses the variable in the first SELCT statement to use the correct property for the WHERE clause.
    Unfortunately the code is not validated - any suggestions?
    /Lars

    Hi Lars,
    If you run it from a DM package without validating it, does it still work? I would bet it does.
    If this is the case I would open a message with SAP (it would be an enhancement request). Until they fix the validation code, you would just have to live with the script not validating.
    Cheers,
    Ethan

  • Dynamic where clause in select query

    Hi
    I'm trying for a dynamic query and in the dynamic where clause i'm checking a field for constant.....for instance if i wanna to use WERKS EQ '0478' how to declare it in dync where clause. i tried for the following:
    SELECT  (TAB_FIELD) INTO TABLE DITAB UP TO 10 ROWS FROM (TAB_NAME) WHERE (CONDI).
    heree CONDI = 'werks eq 0287'   . in this case the query fails as the werks shud be equal to '0287' and not just 0287. How to handle this? i tried for the following
    CONDI = 'werks eq " '0287' " ' but no luck as it is not a valid stmt as i knew.

    hi prabhu,
    this is how u select dynamically...
    DATA: COND(72) TYPE C,
    ITAB LIKE TABLE OF COND.
    PARAMETERS: CITY1(10) TYPE C, CITY2(10) TYPE C.
    DATA WA TYPE SPFLI-CITYFROM.
    CONCATENATE 'CITYFROM = ''' CITY1 '''' INTO COND.
    APPEND COND TO ITAB.
    CONCATENATE 'OR CITYFROM = ''' CITY2 '''' INTO COND.
    APPEND COND TO ITAB.
    CONCATENATE 'OR CITYFROM = ''' 'BERLIN' '''' INTO COND.
    APPEND COND TO ITAB.
    LOOP AT ITAB INTO COND.
    WRITE COND.
    ENDLOOP.
    SKIP.
    SELECT CITYFROM
    INTO WA
    FROM SPFLI
    WHERE (ITAB).
    WRITE / WA.
    ENDSELECT.
    regards,
    sohi

Maybe you are looking for

  • New to FIOS, Can't Browse With Mobile Device

    I recently switched from DSL to FIOS.  I have the Actiontec mi424wr Rev. E router.  Everything has been working well with the exception of my wireless PDA.  It connects to the wireless network ok but I an not able to browse the internet with the devi

  • 10.4.8 and RAIDs. How are things working for MacPro people??

    So, pondering is things working well/at all for people with 10.4.8 and have RAID boot systems in MacPro? Anyone installed it with you having Raid 10, or 0 or 1 ? What kind of problems did you install? Intrested to install the 10.4.8 to my work comput

  • How i save Buzzword document in my computer?

    dear friedns have create buzzword document,now i wana save that doc in my computer. how to save that? help required? i dont know where it save when i save that doc.

  • Dynadock U3.0 freezes the display when connected

    I am using the dynadock u3.0 docking station. The display/laptop freezes every so often. It happens most often when I visit a website with flash video (CNN/Youtube) etc. I thought this has to do with Chrome/Flash so I uninstalled/reinstalled etc but

  • Zen V Plus - Track Playing Order Prob

    When? I rip a CD, put it on my Zen V Plus, then play the album, I can move through successi've tracks by moving the joystick to the right, so Track , Track 2, Track 3, etc..... However, I've just tried ripping the audio from a music DVD, which involv