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

Similar Messages

  • Adding new table dynamic selection screen of transaction FBL5N (LDB DDF).

    Hi,
    I have a requirement to add SEGMENT (CEPC-SEGMENT) field on the dynamic selection screen of transaction FBL5N (LDB DDF).
    Please let me know how can I meet this requirement
    Thanks

    I did not find any screen exits for this Tcode, may be you need to use enhancement spots.

  • Inner Join for Dynamic Select statement

    Hi All,
      Can some one please help me in rewriting the below select statement where i have to remove the existing table1 by putting a dynamic table name which has the same table structure.
      select a~zfield1
               a~zfield2
          from ztab1 as a
           inner join ztab2 as b
               on b~ztab1-zfield3 = a~ztab2-zfield3
         where a~zfield4 = 'A'.
    I am looking something as below. But encountering an error when using the below statement
      select a~zfield1
               a~zfield2
          from (v_ztab1) as a
           inner join ztab2 as b
               on b~ztab1-zfield3 = a~ztab2-zfield3
         where a~zfield4 = 'A'.
      No Separate selects please. Please help me in rewriting the same select statement itself.
    Regards,
    PSK

    hi,
    What error you are getting ?
    Also INTO is missing from the statement.
    SELECT  pcarrid pconnid ffldate bbookid
      INTO  TABLE itab
      FROM  ( spfli AS p
                INNER JOIN sflight AS f ON pcarrid = fcarrid AND
                                           pconnid = fconnid    )
      WHERE p~cityfrom = 'FRANKFURT' AND
            p~cityto   = 'NEW YORK' .
    thanks

  • Absolute dynamic select query with dynamic join and where

    Has anyone ever tried creating an absolutely dynamic SELECT query with dynamic Join and Where conditions.
    I have a requirement of creating such a query in an Utility Class, and i have written the code. But its throwing my sysntax errors.
    Please let me know where am I going wrong OR is it really possible to create such a dynamic Query??
        SELECT (FIELDS) INTO TABLE IT_TABLES
          FROM ( (ME->TABLE1)  inner join ( me->table2 )
          on ( on_condition ) )
          WHERE (me->where_fields).
    Ags.

    It worked for me in a following way:
    select * into corresponding fields of table <result_table>
            from (join_string)
            where (l_where).
    Where the contents of join_string were dynamically build using concatenation. So it will be something like
    concatenate ME->TABLE1 'as a INNER JOIN' me->table2 'as b ON (' into join_string separated by space.
    <...>
    add here matching/reference colums, something like
    concatenate 'a~' me->TABLE1_JOIN_COL into temp1.
    concatenate 'b~' me->TABLE2_JOIN_COL into temp2.
    concatenate join_string temp1 '=' temp2 into join_string separated by space.
    <...>
    concatenate join_string ')' into join_string separated by space.
    And then use similar approach for l_where variable.

  • Dynamic select list with display,return val & join condition issue.

    hello,
    I am having a dynamic select list with display, return value
    say for example my select statement is
    select distinct dname d, deptno r
    from dept dt
    right join emp e on (e.deptno=dt.deptno)
    where (condition)
    when i tried this query for my select list, it is not working. It saying that
    " LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query. "
    I am not able to understand the problem. Can anyone help me out with this issue?
    thanks.

    Shouldn't your join have dept as the driving table?
    select distinct dname d, deptno r
    from dept dt
    right join emp e on (dt.deptno = e.deptno)
    where (condition)
    Or using older Oracle standard join
    select distinct dname d, deptno r
    from dept dt, emp e
    where (dt.deptno (+) = e.deptno) AND (OTHER WHERE condition)
    OR
    (Since a right join is just getting the values from the driving table that are NOT in the associated table)
    select distinct dname d, deptno r
    from dept dt
    WHERE dt deptno NOT IN (SELECT deptno FROM emp) AND (OTHER where condition)
    Thank you,
    Tony Miller
    Webster, TX

  • Dynamic Select statements (Joins)

    Hi friends the following is the Source code in my FUNCTION MODULE and this i have few parameters in my report
    MARKET
    MEMBER
    EFFECTIVE DATE
    STATUS
    COUNTRY
    ADMISSION TYPE
    I need the output from Different Select options (PARAMETER OPTIONS) from the User point of view..this is Just one market's (XETRA) selections .. I have 13 markets... Kindly anyone help me with the similar output I need a dynamic selection ...
    SAMPLE or EXAMPLE CODE appreciated...
    CASE iv_market.
    WHEN lc_xtra_market.                                  
          lv_table = 'ZTGP_MEMBER_XTRA'.
    IF iv_member_id IS INITIAL AND iv_country IS INITIAL AND iv_adm_type IS INITIAL.
    SELECT ztgp_member_xtra~xetra_id
                   ztgp_member_xtra~admission
                   ztgp_member_xtra~partner
                   ztgp_member_xtra~status
                   ztgp_member_xtra~adm_type
                   ztgp_member_xtra~object_id
                   ztgp_member_xtra~addrnumber
                   ztgp_member_xtra~beg_dat
                   adrc~country
    INTO (lt_member-member_id, lt_member-admission, lt_member-partner, lt_member-status, lt_member-adm_type,
    lt_member-object_id, lt_member-addrnumber, lt_member-beg_dat,lt_member-country)
    FROM ztgp_member_xtra JOIN adrc ON ztgp_member_xtraaddrnumber = adrcaddrnumber WHERE ztgp_member_xtrastatus EQ iv_status AND                ztgp_member_xtrabeg_dat LE iv_date_effective AND
    ztgp_member_xtra~end_dat GE iv_date_effective.
    APPEND lt_member.
    ENDSELECT.
    ELSEIF NOT iv_member_id IS INITIAL AND iv_country IS INITIAL AND iv_adm_type IS INITIAL.
    SELECT  ztgp_member_xtra~xetra_id
            ztgp_member_xtra~admission
            ztgp_member_xtra~partner
            ztgp_member_xtra~status
            ztgp_member_xtra~adm_type
            ztgp_member_xtra~object_id
            ztgp_member_xtra~addrnumber
            ztgp_member_xtra~beg_dat
            adrc~country
    INTO (lt_member-member_id, lt_member-admission, lt_member-partner, lt_member-status, lt_member-adm_type,
    lt_member-object_id, lt_member-addrnumber, lt_member-beg_dat,lt_member-country)
    FROM ztgp_member_xtra JOIN adrc ON ztgp_member_xtraaddrnumber = adrcaddrnumber
    WHERE ztgp_member_xtra~xetra_id EQ iv_member_id AND
          ztgp_member_xtra~status EQ iv_status AND
          ztgp_member_xtra~beg_dat LE iv_date_effective AND
          ztgp_member_xtra~end_dat GE iv_date_effective.
         APPEND lt_member.
         ENDSELECT.
    ELSEIF NOT iv_member_id IS INITIAL AND NOT iv_country IS INITIAL AND iv_adm_type IS INITIAL.
    SELECT  ztgp_member_xtra~xetra_id
            ztgp_member_xtra~admission
            ztgp_member_xtra~partner
            ztgp_member_xtra~status
            ztgp_member_xtra~adm_type
            ztgp_member_xtra~object_id
            ztgp_member_xtra~addrnumber
            ztgp_member_xtra~beg_dat
            adrc~country
    INTO (lt_member-member_id, lt_member-admission, lt_member-partner, lt_member-status, lt_member-adm_type,
    lt_member-object_id, lt_member-addrnumber, lt_member-beg_dat,lt_member-country)
    FROM ztgp_member_xtra JOIN adrc ON ztgp_member_xtraaddrnumber = adrcaddrnumber
    WHERE ztgp_member_xtra~xetra_id EQ iv_member_id AND
    adrc~country EQ iv_country AND
    ztgp_member_xtra~status EQ iv_status AND
    ztgp_member_xtra~beg_dat LE iv_date_effective AND
    ztgp_member_xtra~end_dat GE iv_date_effective.
    APPEND lt_member.
    ENDSELECT.
    ELSEIF iv_member_id IS INITIAL AND NOT iv_country IS INITIAL AND iv_adm_type IS INITIAL.
    SELECT  ztgp_member_xtra~xetra_id
           ztgp_member_xtra~admission
           ztgp_member_xtra~partner
           ztgp_member_xtra~status
           ztgp_member_xtra~adm_type
           ztgp_member_xtra~object_id
          ztgp_member_xtra~addrnumber
          ztgp_member_xtra~beg_dat
    adrc~country
    INTO (lt_member-member_id, lt_member-admission, lt_member-partner, lt_member-status, lt_member-adm_type,
    lt_member-object_id, lt_member-addrnumber, lt_member-beg_dat,lt_member-country)
    FROM ztgp_member_xtra JOIN adrc ON ztgp_member_xtraaddrnumber = adrcaddrnumber
    WHERE adrc~country EQ iv_country AND
    ztgp_member_xtra~status EQ iv_status AND
    ztgp_member_xtra~beg_dat LE iv_date_effective AND
    ztgp_member_xtra~end_dat GE iv_date_effective.
    APPEND lt_member.
    ENDSELECT.
    ELSEIF iv_member_id IS INITIAL AND iv_country IS INITIAL AND NOT iv_adm_type IS INITIAL.
    SELECT  ztgp_member_xtra~xetra_id
            ztgp_member_xtra~admission
           ztgp_member_xtra~partner
           ztgp_member_xtra~status
        ztgp_member_xtra~adm_type
                    ztgp_member_xtra~object_id
                    ztgp_member_xtra~addrnumber
                    ztgp_member_xtra~beg_dat
                    adrc~country
    INTO (lt_member-member_id, lt_member-admission, lt_member-partner, lt_member-status, lt_member-adm_type,
    lt_member-object_id, lt_member-addrnumber, lt_member-beg_dat,lt_member-country)
    FROM ztgp_member_xtra JOIN adrc ON ztgp_member_xtraaddrnumber = adrcaddrnumber
    WHERE ztgp_member_xtra~adm_type EQ iv_adm_type AND
    ztgp_member_xtra~status EQ iv_status AND
    ztgp_member_xtra~beg_dat LE iv_date_effective AND
    ztgp_member_xtra~end_dat GE iv_date_effective.
    APPEND lt_member.
    ENDSELECT.
    ENDIF.
    WHEN lc_repo_market.
    WHEN lc_eurex_market.
    When lc_fwb_market.
    and so on... 13 markets..
          ENDIF.
    IF sy-subrc NE 0.
          ENDIF.
        WHEN OTHERS.
          EXIT.
      ENDCASE.

    In your case your internal tables seems to have constant and same structure so it can be defined statically.
    lv_table &  lv_where_cond are variables.
    SELECT F1 F2 FROM (lv_table)
                 INTO CORRESPONDING FIELDS OF TABLE  itab
                WHERE (lv_where_cond).

  • Dynamic Select query is failing with error "Invalid Table Name"

    OPEN rc FOR 'SELECT count(*) from :s' USING tab_name;
    fetch rc into rec_count;
    CLOSE rc;
    my requirement is to build dynamic select query to retrieve the total count of rows in each table ( variable tab_name contains the table_name )
    But I am getting stuck by this errror, not sure if there is any alternative !
    ORA-00903: invalid table name
    ORA-06512: at line 43

    OPEN rc FOR 'SELECT count(*) from '||tab_name;
    fetch rc into rec_count;
    CLOSE rc;
    -- This will work
    1. Create a sql statement.
    2. Open ref cursor for that statement.

  • Dynamic select conditions within a Join sql_cond - (cond_syntax)

    Hello,
    I have many programs where I use sql_cond - (cond_syntax) syntax ( http://help.sap.com/abapdocu_70/en/ABENWHERE_LOGEXP_DYNAMIC.htm )
    Example
                    TRY.
                        SELECT ebeln ebelp sakto
                         FROM ekkn
                         INTO TABLE i_ekkn
                         WHERE (cond_syntax).
                      CATCH cx_sy_dynamic_osql_error.
                        MESSAGE `Wrong WHERE condition!` TYPE 'I'.
                    ENDTRY.
    My problem now is that I am trying to do the same in a select join:
      TRY.
          SELECT bsbukrs bsmonat bsgjahr bsgsber  bshkont sktxt50 bssegment bkusnam
                 bsblart bsbelnr bkbktxt bsbuzei bsmwskz bswrbtr bsbuzid bsbudat bsxblnr bsbschl
                 bkwaers bsaugbl bszuonr bsshkzg bsdmbtr bktcode bk~stblg
            INTO TABLE i_bsis
            FROM  bsis AS bs
                INNER JOIN bkpf AS bk ON bsbelnr = bkbelnr AND
                                         bsbukrs = bkbukrs AND
                                         bsgjahr = bkgjahr AND
                                         bsblart = bkblart AND
                                         bk~stblg = ''
                INNER JOIN skat AS sk ON sk~spras = 'S'AND
                                         bshkont = sksaknr
                WHERE
                  bs~bukrs IN s_bukrs AND   "
                  bk~bukrs IN s_bukrs AND   "
                  bs~hkont IN s_racct AND    "
                  bs~zuonr IN s_lifnr AND    "
                  bs~zuonr IN s_kunnr AND  "
                  bs~belnr IN s_belnr AND  "
              ( bs~budat BETWEEN date1 AND p_date2 )
                  (cond_syntax)       AND
                  bk~waers IN s_waers AND
                  bk~xblnr IN s_xblnr AND    "
                  bs~gsber IN s_div AND      "
                  bk~usnam IN s_usnam.  "
        CATCH cx_sy_dynamic_osql_error.                        
          MESSAGE `Wrong WHERE condition!` TYPE 'I'.         
      ENDTRY.
    But it is not working at all, it only returns sy-subrc = 4 and if I change for 'bs~budat >= date1' it return all records from table
    does anybody have use this in an inner join?
    Thanks for your help.

    hI,
    TAKE THIS CODE... HOPE IT WORKS FOR YOU....
    clear: itwa_where_cond[], itwa_where_cond.
      move `BZOBJ  = '0'` to wa_where_cond.
      append wa_where_cond to itwa_where_cond.
      clear wa_where_cond.
      concatenate `AND KADKY >= '` l_date_start `'`  into wa_where_cond.
      append wa_where_cond to itwa_where_cond.
      clear wa_where_cond.
      concatenate `AND KADKY <= '` l_date_end `'` into wa_where_cond.
      append wa_where_cond to itwa_where_cond.
      clear wa_where_cond.
      concatenate `AND MATNR = '` wa_matwrk-matnr `'` into wa_where_cond.
      append wa_where_cond to itwa_where_cond.
      clear wa_where_cond.
      concatenate `AND WERKS = '` wa_matwrk-werks `'` into wa_where_cond.
      append wa_where_cond to itwa_where_cond.
      clear wa_where_cond.
      concatenate `AND KOKRS  = '` pi_kokrs `'` into wa_where_cond.
      append wa_where_cond to itwa_where_cond.
      if not pi_freig is initial.
        clear wa_where_cond.
        concatenate  `AND FREIG = '` pi_freig `'` into wa_where_cond.
        append wa_where_cond to itwa_where_cond.
      endif.
      if not pi_tvers is initial.
        clear wa_where_cond.
        concatenate  `AND TVERS = '` pi_tvers `'` into wa_where_cond.
        append wa_where_cond to itwa_where_cond.
      endif.
      if not pi_klvar is initial.
        clear wa_where_cond.
        concatenate  `AND KLVAR = '` pi_klvar `'` into wa_where_cond.
        append wa_where_cond to itwa_where_cond.
      endif.
      if not pi_feh_sta is initial.
        clear wa_where_cond.
        concatenate  `AND FEH_STA = '` pi_feh_sta `'` into wa_where_cond.
        append wa_where_cond to itwa_where_cond.
      endif.
      if not pi_kkzma is initial.
        clear wa_where_cond.
        concatenate  `AND KKZMA = '` pi_kkzma `'` into wa_where_cond.
        append wa_where_cond to itwa_where_cond.
      endif.
      SELECT * FROM  KEKO into corresponding fields of table it_keko
                                             WHERE  (itwa_where_cond).
    REGARDS
    SIDDARTH

  • DB connectivi​ty toolkit: syntax error in a SELECT data from joined tables

    Hello everyone
    I'm trying to put in labview an SQL query on joined tables.
    As example I take a DB for storing the data of 2on2 basketball games, whose tables are
    matches(matchId,teamA,teamB)
    teams(teamId,PlayerAname,PlayerBname,Nationality)
    nationalities(NatId,natName)
    To get a result table with the match number and the player names along with their nationality I use this query on MySQL (which works on the command line interface)
    SELECT MatchID,
                     t1.PlayerAName, t1.PlayerBName, n1.natName,
                     t2.PlayerAName, t2.PlayerBName, n2.natName
    FROM matches m
    INNER JOIN teams t1 ON t1.teamID = m.teamA
    INNER JOIN teams t2 ON t2.teamID = m.teamB
    INNER JOIN nationalities n1 ON n1.natID = t1.nationality
    INNER JOIN nationalities n2 ON n2.natID = t2.nationality
    When I put it in labview, using the "select data" block, I get a syntax error as shown in the attached screenshot.
    Am I mistanking something in using the JOIN statements, or the aliases?
    Thanks in advance!
    Solved!
    Go to Solution.
    Attachments:
    select2dabone.vi ‏12 KB

    Giovasa wrote:
    I do't like very much the chain of blocks execute query+n*(fetch element)+free object, so I try to avoid that as much that I can...
    Sounds like a prime candidate for a subVI. You don't have to use it every time, but it probably would help for cases where you do want to put the SQL query directly in code.
    Incidentally, if you're doing joins, you might consider using views, as that allows you to hide the details of the interactions of the tables in the DB itself.
    Try to take over the world!

  • Select distinct problem with muliple join tables, help needed

    Hi,
    I have two main tables. Each has its of sub joined tables.
    guest_id_for_reservation connects two major tables. This has
    to be that way
    because my guest may change the room status from single to
    double (and the
    similar exceptional requests).
    guests reservation
    guest_id_for_reservation
    countrytable hoteltable
    delegationtable roomtype
    I form a query. I want to select distinct those results. But
    it does not
    work.
    If I do not include any table related to reservation table
    and its sub
    joined tables (disregarding guest_id_for_reservation), it
    works.
    Is there a specific syntax for select distinct of this type
    or any
    workaround.?
    Thank you
    Hakan

    Hi I'm still battling with this - have connected the AX to my Imac via ethernet and it shows up fine in Airport Utility. Status light is green and it says its set up to connect to my existing wireless network using wireless connection. Security in Network Preferences is the same for both: WPA2 Personal.
    So I don't think there's a problem with the AX, and my current wireless network (BT Home Hub) is working fine.
    And when I restore factory settings Airport Utility can see the AX before updating settings so the wireless side of AX must work too.
    I'm figuring it must be something about the settings that mean AU can't see it anymore. But I can't work out what, since security is the same.
    Any ideas would be great!

  • Dynamic selection of tables

    Hi
    Is it possible to create a dynamic selection of tables in the 'from' clause.
    Thanks in advance

    Hi,
    Thanks for the reply.
    I have two tables. Currently in our existing production system we have two different procedures for example say, P1 and P2. These procedures have the same logic except that the data is retrieved from two different tables.
    I felt that if there is a possibility to select data from the tables dynamically then i could just use one common procedure and pass the tables as parameters to that.
    To make it more clear, please see the following.
    I have two tables , say T1, T2.
    I have two procedures P1, P2 in one package.
    P1 procedure
    Procedure P1 is
    cnt number := 0;
    Begin
    select count(*) into cnt from T1;
    if cnt = 0 then
       IF GVAR.T1_RecordNbr <= '1'  -- GVAR  is Global Variable package
                THEN
                   IF NAME_IN('T1.col_name') IS NULL
                   THEN
                      display_msg('Error');
                   END IF;
      end if;
    end if;
    end;
    [\pre]
    P2 procedure
    [pre]
    Procedure P2 is
    cnt number  := 0;
    Begin
    select count(*) into cnt from T2;
    if cnt = 0 then
       IF GVAR.T2_RecordNbr <= '1'
                THEN
                   IF NAME_IN('T2.col_name') IS NULL
                   THEN
                      display_msg('Error');
                   END IF;
       end if;
    end if;
    end;
    [\pre]
    Now I want to write only one procedure and just change the table names dynamically. Could you please suggest.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Dynamic selection screen fetching the value from table fields

    hi gurus,
    i have one table say ztable...and i should create a dynamic selection screen which should populate the selection screen by the table field names.
    example..if i have 3 fields im my table..my selection screen should have three selection option fields..and in future if i add one more field in my table it should automatically create another slection-option in selection screen..
    thanks
    Sudheer

    Do you mean like SE16 works. If so, you should notice that if you  amend the selection fields, the screen program is actually re-generated.
    That is what is happening. A program is being created and re-generated.
    To create a dynamic selection screen in a single program is not possible ( I may be wrong ). If it is possible, then you would have problems in defining selection screen field names and using them.

  • Which table the dynamic selection view will be stored

    Dear Freinds,
                      I  have created a dynamic selections view form Se80 > Editobject>Selection view > Created by adding the required tables pa0002,pa006,pa0009 . But the transport request we have saved it locally
    now i want to create a transport request for the dynamic view . Could any please let me know how to create transport reqest for the Dynamic selection
    View which has been created.
    regards
    divya

    HiDivya,
    yo have saved the changes into local object and now you want to generate the TRN and for the save you have to change the attribute > GOTO > Other object Entry and  changed the package and TRN will generate .
    Regards
    Sheetal

  • Extend dynamic selection for a field added on PRPS table

    Hi Gurus,
    I want to see the field that I've added in PRPS table as part of dynamic selection on the reports like S_ALR_87013542/ S_ALR_87013532. The LDB for project systems is PSJ. How do I make it appear as a dynamic selection on the selection-screen criteria for these reports?
    Thanks...

    Hi,
    We have done this a lot on my project.  Follow these steps:
    (1) Transaction SE36 for logical database PSJ
    (2) Choose menu path Extras -> Selection views (Ctrl+F7)
    (3) Change the "Origin of view" to SAP
    (4) Find the PRPS_R node in the top, right "Tables/nodes" view.
    (5) Double-click PRPS_R.
    (6) Find your custom field that you added in PRPS (in the bottom "Table fields/node fields" view.
    (7) Choose and enter a 2-character Function Group ID (see the top, left view) next to the new field.
    (8) Save and transport...
    Best Regards,
    James Gaddis

  • Urgent......  how to select few fields, from database table, (dynamic ita.)

    Dear all experts,
    I am able to populate all fields data from database table, using dynamic table creation.
    eg,
    SELECT *    FROM (w_tabname)    INTO    TABLE <t_itab>.
    where w_tabname is the table name given by the user, and t_itab is field symbol.
    but some requirement is like that i need to pick up only few fields, <b>which user will give at the runtime.</b>
    <b>I can</b> take those fields from file into any internal table,
    but the problem is that instead of <b>select *</b>, i need to put selected the fields given by user.
    i have tried with field symbol, it is not working (as per my knowledge.)
    do i need to create any structures dynamically ?
    Can anybody please help in this regards ?
    Your help will be surely rewarded with points.
    Waiting for reply..
    Regards
    Vinay

    Hi Vinay ,
    Adding to the below code , you can use some more fields in the select stmt as below:-
    REPORT ychatest.
    PARAMETERS : p_field1 LIKE dd03l-fieldname,
                             P_field2 LIKE dd03l-fieldname,
                             p_table LIKE dd03l-tabname.
    FIELD-SYMBOLS : <fs> TYPE STANDARD TABLE.
    SELECT (p_field1) (p_field2) ( FROM (p_table) INTO TABLE <fs>.
    Now p_field1 & p_field2  belong to the same table since you have give the user to enter only one table name.
    This should work fine.
    please try & let me know .
    Thanks & Regards,
    Daniel

Maybe you are looking for

  • Processamento de extrato bancario externo-(v9.0 Pl.11)

    Olá a todos! Estou precisando gerar pagamento das tarifas a partir da tela de "Processar extrato bancário externo". A Importação do extrato foi feita pelo BankSync. Não estou com a opção de "Instalar processamento de extrato bancário" ativo, quando s

  • Problem with date format when ask prompt web-intelligence

    Bo XIR2 with 5 SP. Instaled on Windows 2003 with support Russian. Inside BO every labels, buttons - use russian. But when invoke web-report and Prompt appear there is problem with date format. Looks like korean format of date 'jj.nn.aaa H:mm:ss'.  I

  • Query is not picking the data from multiprovider

    Hi All, i have defined a query on a multiprovider which is made up of three ods one from sales orders, delivery, and billing but when i run the query ...its not picking up order quantity for some sales orders and also its not picking all the items av

  • How to copy a value of interface counter to a variable

    Hi Folks, I'm new in EEM and I'm trying to read a interface counter and save the value in a new variable. I will use the new variable to manipulate the value. Should I use SNMP (event snmp oid ...) to get the value? Regards Padula

  • T400 faint image problems and dark, leds off inverter

    I have a 6475-BC1 t400 the problem is: does not show image on screen, the front leds off, connect an external display and the picture is normal, they proceeded to change according HMM systemboard iverter and the problem persists, the screen proved on