Dynamic field in select statment.

Hello,
I created a report in which i have two checkboxes in the selection screen. The first checkbox is for the option to bring or not, initial purchase requisitions (BANFN) from EKPO and the second is to bring initial or not, RFQs
(ANFNR). I want the select statment to have this form:
select ...
from ekpo
into g_table
where ..
and dynamic field = " ".
Can this be done ?
i tried to put it as a string but it didnt work. (data: dynamic field type string value "EKPO-BANFN")
P.S i know that it can be by writing the same select code twice.
I just wonder if this can be done by this way
\Regards.

Hey Nick,
I have more conditions than the one i said before , should all be in the lv_where_clause ?
check my code.
DATA: G_CHBFLD type STRING.
G_CHBFLD = 'P~BANFN = '' " '.
FORM SELECT_DATA_EKPO_EKKO.
  SELECT  .....
      FROM EKPO AS P INNER JOIN EKKO AS K
        ON PEBELN = KEBELN
          INTO CORRESPONDING FIELDS OF TABLE GT_EKPOEKKO
            WHERE K~EBELN IN S_EBELN
            AND K~AEDAT IN S_AEDAT
            AND K~BSTYP IN S_BSTYP
            and ( G_CHBFLD ) .   -
> //DEBUGER ")" is not a valid comparison operator. comparison operator.

Similar Messages

  • Dynamic field in select query

    Hi Team,
    I have to select dynamic fields from database table GLT0.
    This depends on period value given on screen.
    If period is 01 then fields will be hsl01.
    If period is 02 then fields will be hsl01 and hsl02.
    If period is 03 then fields will be hsl01,hsl02 and hsl03 .
    so on...till 12..
    My code is throwing exception at select query.
    "Error in module RSQL of the database interface."
    My code :
    *"      Type declaration to store field name as per given period
    TYPES : BEGIN OF y_fieldname        ,
               fieldname(10)  TYPE c    ,
             END OF y_fieldname         .
    data  t_fieldname  TYPE  STANDARD TABLE OF y_fieldname   .
      DO p_monat TIMES.
         clear w_count .
          MOVE sy-index TO w_count
          IF sy-index LE c_9.
            CONCATENATE c_hsl
                        c_0
                        w_count
            INTO      e_fieldname-fieldname.
            APPEND e_fieldname TO t_fieldname.
          ELSE.
            CONCATENATE c_hsl
                        w_count
            INTO     e_fieldname-fieldname.
            APPEND e_fieldname TO t_fieldname.
          ENDIF.
        ENDDO.
      Get Local Currency Amounts
      from table glt0 depending on period
        SELECT (t_fieldname)
          FROM glt0
          INTO TABLE t_glto_with_saknr
          FOR ALL ENTRIES IN t_bukrs
         WHERE rldnr EQ c_00
           AND rrcty EQ c_0
           AND rvers EQ c_001
           AND bukrs EQ t_bukrs-bukrs
           AND ryear EQ p_gjahr
           AND racct IN r_saknr.
    Please guide me.
    Thanking u in advance.
    Sangeeta Verma

    Hi Asik,
    I m selecting all fields now as suggestd by u so in one record i have hsl01 to hsl12.
    I have to calculate balance into e_glt0_bal-bal .This balance is summation of e_glt0_bal-hsl01 till  e_glt0_bal-hsl12 (depending on monat).
    I m using logic in process then
    my code now :
    data:    w_monat_bal type string  .
              DO p_monat TIMES.
                MOVE c_01 TO w_count .
                CONCATENATE 'e_glt0_bal-hsl'
                             w_count
                       INTO w_monat_bal.
                ASSIGN w_monat_bal TO <fs_monat_bal>.
                e_glt0_bal-bal = e_glt0_bal-bal + <fs_monat_bal>.
                w_count = w_count + c_01.
              ENDDO.
    But <fs_monat_bal> can not be added.
    Giving exception :
    Unable to interpret "e_glt0_bal-hsl01" as a number.
    If I do <fs_monat_bal> type GLT0-hslvt instead to type any
    Then assigning from w_monat_bal  is not possible.

  • Dynamic field in Select Statement

    I am able to create a dynamic statement to insert into the where clause of my sql, but I am unable to dynamically create a select statement. Oracle Reports produces the following error:
    REP-0499: Column " selected by the query is incompatible with report definition.
    Here is an example of my select:
    Select
    &dynamic_field
    from
    any_table
    Any help is appreciated.

    I figured it out. Thanks

  • Dynamic fields in select statement

    Hi all,
       In selection screen we are having period as select option.The values for period are 01 to 16. Based on 
          the values entered in selection screen for period we need to select HSLXX from FAGLFLEXT.
       For example if we enter 01 to 03 in selection screen then we need to select HSL01 HSL02 HSL03  
           from FAGLFLEXT.
      Like this we need to select fields dynamically in select statement. Can any one tell me how to restrict fields dynamically.
    Regards,
    Swetha

    hi Swetha,
    the  third select statemnet will work for  you..
    try this..
    _Dynamic where clause in select query.._
    * With a variable, result: AND rbusa = '5145'
    concatenate 'AND rbusa = '  ''''  i_tab-zgsber  ''''
    append where_clause to where_tab.                                  
    * Select
    select * from zcostfreq                                           
         where (where_tab).                                              
    endselect.
    _Using a dynamic table name_
    parameters:
    p_tab type tabname.
    start-of-selection.
      select count(*) from (p_tab) into l_count.
    _Dynamic retrieval and writing of data_
    FIELD-SYMBOLS:
      <row>         TYPE ANY,
      <component>   TYPE ANY.
    PARAMETERS:
    p_tab TYPE tabname.
    CREATE DATA dataref TYPE (p_tab).
    * The variable dataref cannot be accessed directly, so a field symbol is
    * used
      ASSIGN dataref->* TO <row>.
      SELECT *
        FROM (p_tab) UP TO 10 ROWS
        INTO <row>.
        NEW-LINE.
        DO.
    *     Write all the fields in the record   
          ASSIGN COMPONENT sy-index
            OF STRUCTURE <row>
            TO <component>.
          IF sy-subrc <> 0.
            EXIT.
          ENDIF.
          WRITE <component>.
        ENDDO.
      ENDSELECT.
    Regards,
    Prabhduas

  • Specify database field's name dynamically in a select statement

    Hi to all!!
    I have the following problem:
    I got a paraneters statement where the user is to choose the month of the year,once i have the month, i need to make a query on a database(select field_name) of a field whose name deppend on the month that the user chose before, is it possible?
    What I need? I think i can do it using field simbols but I've never worked with field simbols and I have no time to learn it now.
    Thanks everybody

    Hi,
    <b>Below code is the Simple one:</b>
    <b>DATA: DYN_FIELD(15)
    SELECT single (DYN_FIELD)
    into corresponding fields of <IT_TABLE>
    from <TABLE> where XXX = YYY.</b>
    This is the complex program, have a look at it ...
    REPORT zdany_dynamic_select.
    * We use some parameters to dynamically control the select, this is not very
    * clever but this is just a test program !!
    PARAMETER : p_tabnam TYPE tabname DEFAULT 'SFLIGHT',
                p_selfl1 TYPE edpline DEFAULT 'CARRID',
                p_selfl2 TYPE edpline DEFAULT 'CONNID',
                p_selfl3 TYPE edpline DEFAULT 'FLDATE',
                p_selfl4 TYPE edpline DEFAULT 'PRICE',
                p_selfl5 TYPE edpline DEFAULT 'CURRENCY',
                p_where1 TYPE edpline DEFAULT 'PRICE > 300',
                p_where2 TYPE edpline DEFAULT 'AND CURRENCY = ''EUR'''.
    FIELD-SYMBOLS : <lt_outtab> TYPE ANY TABLE,
                    <ls_outtab> TYPE ANY,
                    <l_fld> TYPE ANY.
    DATA: lt_where    TYPE TABLE OF edpline,
          lt_sel_list TYPE TABLE OF edpline,
          lt_group    TYPE TABLE OF edpline,
          l_having    TYPE string,
          l_wa_name   TYPE string,
          l_sel_list  TYPE edpline,
          dref        TYPE REF TO data,
          itab_type   TYPE REF TO cl_abap_tabledescr,
          struct_type TYPE REF TO cl_abap_structdescr,
          elem_type   TYPE REF TO cl_abap_elemdescr,
          comp_tab    TYPE cl_abap_structdescr=>component_table,
          comp_fld    TYPE cl_abap_structdescr=>component.
    TYPES: f_count TYPE i.
    * Creation of the output table including a non standard field, f_count
    * see ABAP FAQ #14 for more information on this topic
    struct_type ?= cl_abap_typedescr=>describe_by_name( p_tabnam ).
    elem_type   ?= cl_abap_elemdescr=>describe_by_name( 'F_COUNT' ).
    comp_tab = struct_type->get_components( ).
    * We remove the unnecessary fields
    LOOP AT comp_tab INTO comp_fld.
       IF comp_fld-name <> p_selfl1 AND
          comp_fld-name <> p_selfl2 AND
          comp_fld-name <> p_selfl3 AND
          comp_fld-name <> p_selfl4 AND
          comp_fld-name <> p_selfl5.
             DELETE TABLE comp_tab WITH TABLE KEY name = comp_fld-name.
       ENDIF.
    ENDLOOP.
    comp_fld-name = 'F_COUNT'.
    comp_fld-type = elem_type.
    APPEND comp_fld TO comp_tab.
    struct_type = cl_abap_structdescr=>create( comp_tab ).
    itab_type   = cl_abap_tabledescr=>create( struct_type ).
    l_wa_name = 'l_WA'.
    CREATE DATA dref TYPE HANDLE itab_type.
    ASSIGN dref->* TO <lt_outtab>.
    CREATE DATA dref TYPE HANDLE struct_type.
    ASSIGN dref->* TO <ls_outtab>.
    * Creation of the selection fields and the "group by" clause
    APPEND p_selfl1 TO lt_sel_list.
    APPEND p_selfl1 TO lt_group.
    APPEND p_selfl2 TO lt_sel_list.
    APPEND p_selfl2 TO lt_group.
    APPEND p_selfl3 TO lt_sel_list.
    APPEND p_selfl3 TO lt_group.
    APPEND p_selfl4 TO lt_sel_list.
    APPEND p_selfl4 TO lt_group.
    APPEND p_selfl5 TO lt_sel_list.
    APPEND p_selfl5 TO lt_group.
    APPEND 'COUNT(*) AS F_COUNT' TO lt_sel_list.
    * creation of the "where" clause
    APPEND p_where1 TO lt_where.
    APPEND p_where2 TO lt_where.
    * Creation of the "having" clause
    l_having = 'count(*) >= 1'.
    * THE dynamic select
    SELECT          (lt_sel_list)
           FROM     (p_tabnam)
           INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>
           WHERE    (lt_where)
           GROUP BY (lt_group)
           HAVING   (l_having)
           ORDER BY (lt_group).
    * display of the results
    LOOP AT <lt_outtab> ASSIGNING <ls_outtab>.
       LOOP AT comp_tab INTO comp_fld.
          ASSIGN COMPONENT comp_fld-name OF STRUCTURE <ls_outtab> TO <l_fld>.
          WRITE: <l_fld>.
       ENDLOOP.
       SKIP.
    ENDLOOP.
    Have a look at the link, this link will have lot of examples :-
    http://www.susanto.id.au/papers/DynOpenSQL.asp
    Regards
    Sudheer

  • How to pass selection screen value to LDB dynamic field.

    Hello everybody,
    In my program, I am using standard LDB(PSJ) for getting data. And there is a requirement that I have to display some dynamic fields on my selection screen like plant , person responsible ( which are mandatory also ) etc. and inside the program I have to fill those dynamic fields for which the user has entered the value in selection screen.
    Could you please tell me how to pass some of selection screen values to ldb dynamic fields before GET statement.
    Thanks !!!
    Regards,
    Mitra

    >
    Pavan Bhamidipati wrote:
    > Hi,
    >
    >
    I have to fill those dynamic fields for which the user has entered the value in selection screen.
    >
    >
    > This means that the user is going to enter the values in the selection screen for the dynamic field values so
    >
    > SET PARAMETERID 'XYZ' FIELD p_field.
    >
    > where p_field is a parameter on the selection screen
    >
    > Regards
    > Pavan
    You can capture the values selected through the dynamic selections using some of the functions modules below, just search the forum for the below FM's, perhaps you can find some sample code
    FREE_SELECTIONS_EX_2_RANGE
    FREE_SELECTIONS_EX_2_WHERE
    FREE_SELECTIONS_RANGE_2_EX
    FREE_SELECTIONS_RANGE_2_WHERE
    FREE_SELECTIONS_WHERE_2_EX
    FREE_SELECTIONS_WHERE_2_RANGE

  • Adding fields on selection screen dynamically

    Hi all,
    Can we add some fields to selection screen dynamically on pushbutton click?
    Regards,
    Dnyanesh

    just have look below code
    REPORT zrsdvsr1
           LINE-SIZE 220
           LINE-COUNT 65(5).
    TYPE-POOLS : slis.
    TABLES
    TABLES: vbak.
    DATA DECLARATIONS
    Ranges
    RANGES: r_posnr FOR vbap-posnr.
    DATA: BEGIN OF t_veramt OCCURS 0,
            vbeln TYPE vbap-vbeln,
            posnr TYPE vbap-posnr,
            matnr TYPE vbap-matnr,
            netwr TYPE vbap-netwr,
            mwsbp TYPE vbap-mwsbp,
          END OF t_veramt.
    DATA: BEGIN OF t_disamt OCCURS 0,
            vbeln TYPE vbap-vbeln,
            posnr TYPE vbap-posnr,
            matnr TYPE vbap-matnr,
            netwr TYPE vbap-netwr,
            mwsbp TYPE vbap-mwsbp,
            netwr_v TYPE vbap-netwr,
            mwsbp_v TYPE vbap-mwsbp,
            disc_val TYPE vbap-mwsbp,
          END OF t_disamt.
    *&   ALV FIELDS
    DATA : alv_fcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
           alv_layout TYPE slis_layout_alv.
    SELECTION SCREEN
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS:  p_ver RADIOBUTTON GROUP g1 USER-COMMAND rad DEFAULT 'X',
                 p_sab RADIOBUTTON GROUP g1 .
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
    SELECT-OPTIONS: s_vbeln FOR vbak-vbeln NO INTERVALS MODIF ID gr1.
    PARAMETERS:    p_dwfile TYPE  rlgrap-filename
                   DEFAULT 'C:\test1.txt' MODIF ID gr2,         "#EC NOTEXT
                   p_upfile TYPE  rlgrap-filename
                   DEFAULT 'C:\test.txt' MODIF ID gr3.          "#EC NOTEXT
    SELECTION-SCREEN END OF BLOCK b2.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_upfile.
    **************F4 Help For Input File Name****************************
      CALL FUNCTION 'F4_FILENAME'
           EXPORTING
                program_name  = syst-cprog
                dynpro_number = syst-dynnr
                field_name    = 'C:\'
           IMPORTING
                file_name     = p_upfile.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_dwfile.
    **************F4 Help For Input File Name****************************
      CALL FUNCTION 'F4_FILENAME'
           EXPORTING
                program_name  = syst-cprog
                dynpro_number = syst-dynnr
                field_name    = 'C:\'
           IMPORTING
                file_name     = p_dwfile.
    AT SELECTION-SCREEN OUTPUT.
      LOOP AT SCREEN.
        IF  p_sab = 'X'.
          IF screen-group1 = 'GR1' OR screen-group1 = 'GR2'.
            screen-active = '0'.
            screen-invisible = '1'.
          ELSE.
            screen-active = '1'.
            screen-invisible = '0'.
          ENDIF.
          MODIFY SCREEN.
        ELSE.
          IF screen-group1 = 'GR3'.
            screen-active = '0'.
            screen-invisible = '1'.
          ELSE.
            screen-active = '1'.
            screen-invisible = '0'.
          ENDIF.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
    START-OF-SELECTION
    START-OF-SELECTION.
    Check Radio Button
      IF p_ver = 'X'.
        PERFORM get_details_open_so_vertex.
      ELSE.
        PERFORM get_details_open_so.
      ENDIF.
    Display the output.
      PERFORM diplay_report .
    regards
    vinod

  • Performace problem in a select statment how to imporve the performance

    fist select statment
    SELECT    a~extno
              a~guid_lclic       " for next select
              e~ctsim
              e~ctsex
    *revised spec 3rd
              f~guid_pobj
              f~amnt_flt
              f~amcur
              f~guid_mobj
              e~srvll     "pk
              e~ctsty     "PK
              e~lgreg  "PK
      INTO TABLE gt_sagmeld
      FROM /SAPSLL/LCLIC  as a
      INNER JOIN /sapsll/tlegsv as e on elgreg = algreg
    * revised spec 3rd
      inner join /sapsll/legcon as f on fguid_lclic = aguid_lclic   " for ccngn1 selection
      inner join /sapsll/corcts as g on gguid_pobj = fguid_pobj
                               where   a~extno in s_extno.
      sort gt_sagmeld by guid_lclic guid_pobj.
    lgreg ctsty srvll
      delete adjacent duplicates from gt_sagmeld comparing guid_lclic guid_pobj.
    it selects about 20 lakh records
    belos select statment whichs is taking time as it is based on the entreis of gt_sagmeld
    select /sapsll/corpar~guid_mobj
                /sapsll/corpar~PAFCT
                but000~bpext
                but000~partner
                /sapsll/corpar~parno
                into table gt_but001
        from    /sapsll/corpar
        INNER join but000  on  but000partner = /sapsll/corparparno
        for all entries in gt_sagmeld
        where  /sapsll/corpar~guid_mobj = gt_sagmeld-guid_mobj
        and    /sapsll/corpar~PAFCT = 'SH'.
       SELECT /sapsll/cuit~guid_cuit         " PK
              /sapsll/cuit~QUANT_FLT         " to be displayed
              /sapsll/cuit~QUAUM             " to be displayed
              /sapsll/cuit~RPTDT             " to be displayed
             /sapsll/cuhd~guid_cuhd         " next select
              /sapsll/cuit~guid_pr           " next select
      INTO table gt_sapsllcuit
      FROM  /sapsll/cuit
    inner join /sapsll/cuhd on /sapsll/cuitguid_cuhd = /sapsll/cuhdguid_cuhd
      FOR all entries in gt_sagmeld
      WHERE /sapsll/cuit~guid_cuit = gt_sagmeld-guid_pobj.
      Delete adjacent duplicates from gt_sapsllcuit[].
           if not gt_sapsllcuit[] is initial.

    hi navenet
    that didnt worked
    we need to try ur range options
    but not sure what you told in the last mail as not clear with range can u pls eloboragte more i am pasting the full code here
    SELECT     a~extno
               a~guid_lclic       " for next select but000
               e~ctsim
               e~ctsex
               e~srvll
               e~ctsty
               e~lgreg
      INTO TABLE gt_sagmeld
      FROM /SAPSLL/LCLIC  as a
      INNER JOIN /sapsll/tlegsv as e on elgreg = algreg
                               where   a~extno in s_extno.
    sort gt_sagmeld by guid_lclic.
    delete adjacent duplicates from gt_sagmeld comparing all fields.
      IF not gt_sagmeld[] is initial.
      SELECT  /sapsll/legcon~guid_lclic
              /sapsll/legcon~guid_pobj
              /sapsll/legcon~amnt_flt
              /sapsll/legcon~amcur
               but000~bpext
               *revised spec
               /sapsll/corpar~PAFCT
              /sapsll/legcon~guid_mobj
             /sapsll/cuit~guid_cuit
      INTO TABLE gt_but000
      FROM /SAPSLL/LEGCON
      for all entries in gt_sagmeld
      where /SAPSLL/legcon~guid_lclic = gt_sagmeld-guid_lclic.
            IF NOT GT_BUT000[] IS INITIAL.
           sort gt_but000 by guid_mobj.
           delete adjacent duplicates from gt_but000 comparing guid_mobj.
         select /sapsll/corpar~guid_mobj
                /sapsll/corpar~PAFCT
                /sapsll/corpar~parno
                into table gt_but001
        from    /sapsll/corpar
        for all entries in gt_but000
        where  /sapsll/corpar~guid_mobj = gt_but000-guid_mobj.
       and    /sapsll/corpar~PAFCT = 'SH'.
    DELETE gt_but001 where PAFCT <> 'SH'.
    *sort gt_corpar by parno.
    *delete adjacent duplicates from gt_corpar comparing parno.
    *select gd000~partner
          gd000~bpext
         from gd000 into table gt_but001
    for all entries in gt_corpar
    where  gd000~partner = gt_corpar-parno.
    my ultimat aim is to select bpext from gd000
    can u please explain how to use ranges here and what is the singnificance and how ill i read the data from the final  table if we use ranges
    regards
    Nishant

  • Create a dynamic form where selected text boxes appears, based on options chosen in a drop-down box

    HELP!!! Can anyone please provide some guidance on how to create a dynamic form where selected text boxes appears, based on options chosen in a drop-down box.
    I have a form which – based on the department that's selected from a drop-down box – will have different form fields/text boxes, etc, made available.
    Is this possible in LiveCycle, if so, can you please provide the script/info - as needed.
    Thanks,

    In the preOpen event of the second dropdown list you put something like (in formCalc):
    if (dropdown1 == 1) then
    $.clearItems()
    $.setItems("Year, 2 Year,  3 Year")
    elseif (dropdown1 == 2) then
    $.clearItems()
    $.setItems("3 Year,  4 Year")
    endif

  • How to get around Ampersand in text field in Select statement

    I have an SQL statement I am trying to run in SQL*Plus. In one of my subqueries, I have a select statment in which some of the fields I am trying to pull have an "&" within the text. So, when I try and run the query it returns "Enter value for 35:". I've even tried wildcard characters and it is still not working. If anyone could help me with this, I would appreciate it. Here is a sample of my statement (the subquery is at the bottom of the statement):
    select real_case.file_dt, real_case.dscr, pty_cd, first_name, last_name, addr_line1, addr_line2, city, st_cd, zip_cd
    from real_case, pty, idnt, ptyaddr s1, addr
    where real_case.case_id = pty.case_id
    AND pty.idnt_id = idnt.idnt_id
    AND pty.case_id = s1.case_id
    and pty.seq = s1.seq
    and s1.addr_id = addr.addr_id
    and (real_case.file_dt >= '01-NOV-06'
    and real_case.file_dt <= current_date)
    and (real_case.dscr like '79D01-%'
    or real_case.dscr like '79C01-%'
    or real_case.dscr like '79D02-%')
    and (pty.pty_cd like 'DFNDT')
    and (s1.ins_dttm in
    (select max(s2.ins_dttm) from ptyaddr s2
    where s2.case_id = s1.case_id
    and s2.seq = s1.seq))
    and (real_case.case_id in
    (select case_id from ptychrg
    where ptychrg.actn_cd IN ('35-41-5-1&35-48-4-1')));Thanks,
    Shannon

    this?
    SQL> set define off
    SQL> ed
    Wrote file afiedt.buf
      1  with t as
      2    (select 'a&b' col from dual
      3      union all
      4      select 'abc' from dual)
      5   select    * from t
      6*  where col like '%\&%'
      7  /
    COL
    a&b
    or this
    SQL> ed
    Wrote file afiedt.buf
      1  with t as
      2    (select 'a&b' col from dual
      3      union all
      4      select 'abc' from dual)
      5   select    * from t
      6*  where col like '%'||chr(38)||'%'
    SQL> /
    COL
    a&bjust '%'||chr(38)||'%' will not work.
    You nedd either set scan off or set define off
    correction
    Message was edited by:
    devmiral

  • Query in select statment

    Hi ,
        what is the difference between,select single and
    select upto one row .
    In a select statment .
    Thanks ,
    shankar.

    According to SAP Performance course the SELECT UP TO 1 ROWS is faster than SELECT SINGLE because you are not
    using all the primary key fields.
    select single is a construct designed to read database records with primary key. In the absence of the primary key,
    it might end up doing a sequential search, whereas the select up to 1 rows may assume that there is no primary key
    supplied and will try to find most suitable index.
    The best way to find out is through sql trace or runtime analysis.
    Use "select up to 1 rows" only if you are sure that all the records returned will have the same value for the field(s)
    you are interested in. If not, you will be reading only the first record which matches the criteria, but may be the
    second or the third record has the value you are looking for.
    The System test result showed that the variant Single * takes less time than Up to 1 rows as there is an additional
    level for COUNT STOP KEY for SELECT ENDSELECT UP TO 1 ROWS.
    The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause
    If this results in multiple records then only the first one will be returned and therefore may not be unique.
    Mainly: to read data from
    The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that
    are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns
    the first record of the result set.
    Mainly: to check if entries exist.
    You can refer to the below link..
    http://www.sap-img.com/abap/difference-between-select-single-and-select-upto-one-rows.htm

  • Reg: Dynamic Field catalog in ALV

    Hi ,
    Can any one guide me to build a dynamic field catalog in ALV report?
    Below is the format which i expect..........
    Material    |     Plant1    |    Plant2    |    Plant3    | ....................|    Plant 20      |
    Qty
    Val
    Qty
    Val
    Qty
    Val
    Qty
    Val
    The plant 1 to 20 has to be brought dynamically as headings from T001W table. (Horizontally populate)
    Below each plant i need sub-headings "QTY" and "VAL".                                  (Horizontally populate)
    List of Materials should be brought vertically from MARA table.                          (Vertically populate)
    Can anyone suggest how to bring out this format for populating data accordingly into the o/p format?
    Ur help will be appreciated.
    Thanks,
    K.S.Kannan

    your part of the code is present in routine
    perform dynamic_table.
    *& Report ZCS_NAC_MAT_CHARACTERISTICS
    2/ Description ...: Business requirement is to get all materials
    without any characteristic values maintained in SAP
    which are given in the selection screen.
    REPORT znac_material_char.
    TYPE-POOLS : abap,
    slis.
    TABLES : kssk,
    klah,
    mara,
    makt,
    cabn,
    t134,
    t023.
    DATA : i_fieldcat TYPE slis_t_fieldcat_alv ,
    wa_fieldcat TYPE slis_fieldcat_alv.
    DATA : w_layout TYPE slis_layout_alv.
    DATA : st_layout TYPE slis_layout_alv.
    DATA : t_header TYPE slis_t_listheader,
    w_header TYPE slis_listheader.
    TYPES : BEGIN OF ty_cabn,
    atinn TYPE cabn-atinn,
    atnam TYPE cabn-atnam,
    END OF ty_cabn.
    DATA : i_cabn TYPE STANDARD TABLE OF ty_cabn WITH HEADER LINE.
    DATA : w_cabn LIKE i_cabn.
    TYPES : BEGIN OF ty_ausp,
    objek TYPE ausp-objek,
    atinn TYPE ausp-atinn,
    klart TYPE ausp-klart,
    END OF ty_ausp.
    DATA : i_ausp TYPE STANDARD TABLE OF ty_ausp WITH HEADER LINE.
    DATA : w_ausp LIKE i_ausp.
    TYPES : BEGIN OF ty_mara,
    matnr TYPE mara-matnr,
    mtart TYPE mara-mtart,
    matkl TYPE mara-matkl,
    prdha TYPE mara-prdha,
    mstae TYPE mara-mstae,
    mstde TYPE mara-mstde,
    END OF ty_mara.
    DATA : i_mara TYPE STANDARD TABLE OF ty_mara WITH HEADER LINE.
    DATA : w_mara LIKE i_mara.
    DATA : i_mara_temp TYPE STANDARD TABLE OF ty_mara WITH HEADER LINE.
    DATA : w_mara_temp LIKE i_mara_temp.
    TYPES :BEGIN OF ty_data,
    atnam TYPE cabn-atnam,
    atinn TYPE cabn-atinn,
    objek TYPE ausp-objek,
    klart TYPE ausp-klart,
    matnr TYPE mara-matnr,
    maktx TYPE makt-maktx,
    mtart TYPE mara-mtart,
    matkl TYPE mara-matkl,
    prdha TYPE mara-prdha,
    mstae TYPE mara-mstae,
    mstde TYPE mara-mstde,
    END OF ty_data.
    DATA : i_data TYPE STANDARD TABLE OF ty_data WITH HEADER LINE.
    DATA : w_data LIKE i_data.
    DATA : i_class TYPE STANDARD TABLE OF sclass WITH HEADER LINE.
    DATA : w_class LIKE i_class.
    DATA : i_class_temp TYPE STANDARD TABLE OF sclass WITH HEADER LINE.
    DATA : w_class_temp LIKE i_class_temp.
    DATA : i_objdata TYPE STANDARD TABLE OF clobjdat WITH HEADER LINE.
    DATA : w_objdata LIKE i_objdata.
    TYPES : BEGIN OF ty_objdata_temp.
    TYPES: matnr TYPE mara-matnr.
    TYPES: maktx TYPE makt-maktx.
    INCLUDE STRUCTURE clobjdat.
    TYPES : prdha TYPE mara-prdha.
    TYPES : mstde TYPE mara-mstde.
    TYPES : END OF ty_objdata_temp.
    DATA : i_objdata_temp TYPE STANDARD TABLE OF ty_objdata_temp WITH HEADER LINE.
    DATA : w_objdata_temp LIKE i_objdata_temp.
    FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE,
    <fs_dyntable>,
    <fs_fldval> TYPE ANY.
    DATA: t_newtable TYPE REF TO data,
    t_newline TYPE REF TO data,
    fs_fldcat TYPE slis_t_fieldcat_alv,
    t_fldcat1 TYPE lvc_t_fcat,
    wa_it_fldcat TYPE lvc_s_fcat,
    wa_colno(2) TYPE n,
    wa_flname(30) TYPE c.
    DATA: fieldname(20) TYPE c.
    DATA: fieldvalue(40) TYPE c.
    DATA: index(3) TYPE c,
    v_time(60) TYPE c.
    DATA: wa_cat LIKE LINE OF fs_fldcat.
    CONSTANTS : c_nac TYPE klah-class VALUE 'NAC',
    c_klart TYPE ausp-klart VALUE '001',
    c_check TYPE c VALUE 'X' .
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-000.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT (28) text-001 .
    SELECT-OPTIONS: s_atnam FOR cabn-atnam NO INTERVALS OBLIGATORY. " Characteristic name
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK b1 .
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
    SELECT-OPTIONS: s_matnr FOR mara-matnr. " material Number
    SELECT-OPTIONS: s_mtart FOR mara-mtart. " material type
    SELECT-OPTIONS: s_matkl FOR mara-matkl. " material type
    SELECT-OPTIONS: s_mstae FOR mara-mstae. " X-Plant material status
    PARAMETERS : s_date LIKE sy-datum OBLIGATORY DEFAULT sy-datum . " date
    SELECTION-SCREEN END OF BLOCK b2 .
    AT SELECTION-SCREEN ON s_atnam.
    SELECT SINGLE * FROM cabn WHERE atnam IN s_atnam.
    IF sy-subrc 0.
    MESSAGE text-003 TYPE 'E'.
    ENDIF.
    AT SELECTION-SCREEN ON s_matnr.
    SELECT SINGLE * FROM mara WHERE matnr IN s_matnr.
    IF sy-subrc 0.
    MESSAGE text-004 TYPE 'E'.
    ENDIF.
    AT SELECTION-SCREEN ON s_mtart.
    SELECT SINGLE * FROM t134 WHERE mtart IN s_mtart.
    IF sy-subrc 0.
    MESSAGE text-005 TYPE 'E'.
    ENDIF.
    AT SELECTION-SCREEN ON s_matkl.
    SELECT SINGLE * FROM t023 WHERE matkl IN s_matkl.
    IF sy-subrc 0.
    MESSAGE text-006 TYPE 'E'.
    ENDIF.
    START-OF-SELECTION.
    PERFORM get_data.
    PERFORM get_data_keydate.
    PERFORM material_all_charname.
    PERFORM get_classification.
    PERFORM dynamic_table.
    *& Form dynamic_table
    text
    --> p1 text
    <-- p2 text
    FORM dynamic_table.
    PERFORM fieldcatalog.
    PERFORM dynamic_table_create.
    PERFORM final_data.
    PERFORM final_fieldcatalog.
    PERFORM layout_build.
    PERFORM grid_display.
    ENDFORM. " fieldcat
    *& Form layout_build
    text
    FORM layout_build .
    st_layout-zebra = c_check.
    st_layout-no_vline = ''.
    st_layout-colwidth_optimize = c_check.
    st_layout-detail_popup = c_check.
    st_layout-detail_initial_lines = c_check.
    st_layout-detail_titlebar = text-021.
    ENDFORM. " layout_build
    *& Form alv_top_of_page
    text
    FORM alv_top_of_page.
    REFRESH t_header.
    CLEAR t_header.
    w_header-typ = 'H'. "H=Header, S=Selection, A=Action
    w_header-key = ' '.
    w_header-info = text-019.
    APPEND w_header TO t_header.
    CONCATENATE sy-datum4(2) '-' sy-datum6(2) '-' sy-datum0(4) ' / ' sy-uzeit0(2) ':' sy-uzeit2(2) ':' sy-uzeit4(2) INTO v_time.
    w_header-typ = 'S'. "H=Header, S=Selection, A=Action
    w_header-key = text-020.
    w_header-info = v_time.
    APPEND w_header TO t_header.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    it_list_commentary = t_header.
    ENDFORM. "alv_top_of_page
    *& Form grid_display
    text
    --> p1 text
    <-- p2 text
    FORM grid_display .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = sy-repid
    i_callback_top_of_page = 'ALV_TOP_OF_PAGE'
    it_fieldcat = fs_fldcat
    is_layout = st_layout
    i_default = c_check
    i_save = 'A'
    it_events = v_events[]
    TABLES
    t_outtab = <t_dyntable>.
    ENDFORM. " grid_display
    *& Form FINAL_FIELDCATALOG
    text
    --> p1 text
    <-- p2 text
    FORM final_fieldcatalog .
    wa_cat-fieldname = text-009.
    wa_cat-seltext_m = text-015.
    wa_cat-outputlen = 18.
    APPEND wa_cat TO fs_fldcat.
    wa_cat-fieldname = text-011.
    wa_cat-seltext_m = text-016.
    wa_cat-outputlen = 40.
    APPEND wa_cat TO fs_fldcat.
    LOOP AT s_atnam.
    CLEAR wa_cat.
    wa_cat-fieldname = s_atnam-low.
    wa_cat-seltext_m = s_atnam-low.
    wa_cat-outputlen = '15'.
    APPEND wa_cat TO fs_fldcat.
    ENDLOOP.
    wa_cat-fieldname = text-012.
    wa_cat-seltext_m = text-017.
    wa_cat-outputlen = 18.
    APPEND wa_cat TO fs_fldcat.
    wa_cat-fieldname = text-013.
    wa_cat-seltext_m = text-018.
    wa_cat-outputlen = 8.
    APPEND wa_cat TO fs_fldcat.
    ENDFORM. " FINAL_FIELDCATALOG
    *& Form FIELDCATALOG
    text
    --> p1 text
    <-- p2 text
    FORM fieldcatalog .
    wa_it_fldcat-fieldname = text-009.
    wa_it_fldcat-datatype = text-010.
    wa_it_fldcat-intlen = 18.
    APPEND wa_it_fldcat TO t_fldcat1.
    wa_it_fldcat-fieldname = text-011.
    wa_it_fldcat-datatype = text-010.
    wa_it_fldcat-intlen = 40.
    APPEND wa_it_fldcat TO t_fldcat1.
    LOOP AT s_atnam.
    CLEAR wa_it_fldcat.
    wa_it_fldcat-fieldname = s_atnam-low.
    wa_it_fldcat-datatype = text-010.
    wa_it_fldcat-intlen = 30.
    APPEND wa_it_fldcat TO t_fldcat1.
    ENDLOOP.
    wa_it_fldcat-fieldname = text-012.
    wa_it_fldcat-datatype = text-010.
    wa_it_fldcat-intlen = 18.
    APPEND wa_it_fldcat TO t_fldcat1.
    wa_it_fldcat-fieldname = text-013.
    wa_it_fldcat-datatype = text-014.
    wa_it_fldcat-intlen = 8.
    APPEND wa_it_fldcat TO t_fldcat1.
    ENDFORM. " FIELDCATALOG
    *& Form DYNAMIC_TABLE_CREATE
    text
    --> p1 text
    <-- p2 text
    FORM dynamic_table_create .
    Create dynamic internal table and assign to FS
    CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
    it_fieldcatalog = t_fldcat1
    IMPORTING
    ep_table = t_newtable.
    ASSIGN t_newtable->* TO <t_dyntable>.
    Create dynamic work area and assign to FS
    CREATE DATA t_newline LIKE LINE OF <t_dyntable>.
    ASSIGN t_newline->* TO <fs_dyntable>.
    ENDFORM. " DYNAMIC_TABLE_CREATE
    *& Form FINAL_DATA
    text
    --> p1 text
    <-- p2 text
    FORM final_data .
    LOOP AT i_objdata_temp INTO w_objdata_temp.
    *assign w_objdata_temp-matnr to <fs_dyntable>.
    AT NEW matnr.
    wa_flname = text-009.
    fieldvalue = w_objdata_temp-matnr.
    CONDENSE fieldvalue NO-GAPS.
    ASSIGN COMPONENT wa_flname
    OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
    <fs_fldval> = fieldvalue.
    ENDAT.
    wa_flname = text-011.
    fieldvalue = w_objdata_temp-maktx.
    CONDENSE fieldvalue NO-GAPS.
    ASSIGN COMPONENT wa_flname
    OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
    <fs_fldval> = fieldvalue.
    wa_flname = w_objdata_temp-atnam.
    fieldvalue = w_objdata_temp-ausp1.
    CONDENSE fieldvalue NO-GAPS.
    ASSIGN COMPONENT wa_flname
    OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
    <fs_fldval> = fieldvalue.
    wa_flname = text-012.
    fieldvalue = w_objdata_temp-prdha.
    CONDENSE fieldvalue NO-GAPS.
    ASSIGN COMPONENT wa_flname
    OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
    <fs_fldval> = fieldvalue.
    wa_flname = text-013.
    fieldvalue = w_objdata_temp-mstde.
    CONDENSE fieldvalue NO-GAPS.
    ASSIGN COMPONENT wa_flname
    OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
    <fs_fldval> = fieldvalue.
    AT END OF matnr.
    APPEND <fs_dyntable> TO <t_dyntable>.
    ENDAT.
    ENDLOOP.
    ENDFORM. " FINAL_DATA
    *& Form GET_CLASSIFICATION
    text
    --> p1 text
    <-- p2 text
    FORM get_classification .
    LOOP AT i_data INTO w_data.
    SELECT SINGLE * FROM klah WHERE class = c_nac.
    IF sy-subrc = 0.
    IF w_data-mstde >= klah-vondt.
    CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
    EXPORTING
    class = c_nac
    classtext = c_check
    classtype = c_klart
    clint = 0
    features = c_check
    language = sy-langu
    object = w_data-objek
    TABLES
    t_class = i_class
    t_objectdata = i_objdata
    EXCEPTIONS
    no_classification = 1
    no_classtypes = 2
    invalid_class_type = 3
    OTHERS = 4.
    LOOP AT i_class INTO w_class.
    MOVE w_class TO w_class_temp.
    APPEND w_class_temp TO i_class_temp.
    ENDLOOP .
    LOOP AT s_atnam.
    READ TABLE i_objdata INTO w_objdata WITH KEY atnam = s_atnam-low.
    IF sy-subrc = 0.
    MOVE w_data-matnr TO w_objdata_temp-matnr.
    MOVE w_data-maktx TO w_objdata_temp-maktx.
    MOVE-CORRESPONDING w_objdata TO w_objdata_temp.
    MOVE w_data-prdha TO w_objdata_temp-prdha.
    MOVE w_data-mstde TO w_objdata_temp-mstde.
    APPEND w_objdata_temp TO i_objdata_temp.
    ENDIF.
    ENDLOOP.
    ENDIF.
    ENDIF.
    ENDLOOP.
    ENDFORM. " GET_CLASSIFICATION

  • Dynamic fields in PDF form

    Hello Experts,
                           I have a requirement to design all fields in a form dynamically..!
    It means if the user selects speific fields in a custom config, the form should be genarated with only those fields.
    I know it can be done placing fields at design time and then hiding it later.. but I am looking for dynamic fields creation and position and setting its properties dynamically.
    Thanx for Ur time.. !

    hi,
    Did you try creating a composite form ?? The sap.help link to creating Dynamic forms is give below
    [link|http://help.sap.com/saphelp_nwce10/helpdata/en/44/bca11fc60b7006e10000000a155369/content.htm]
    Hope this helps
    Regards
    Manthan.

  • Dynamic sql for select statement

    Hi,
    Please help me with the below code:
    It is updating null if the select statment returns one values. If it fetches multiple values then it throughs the below error msg when running the program.
    Please let me know how to modify the below code. Or let me know is there anyother way to write this code.
    Logic for development:
    * View name should be passed as dynamic.
    CREATE OR REPLACE
    PROCEDURE "PKEP_LOAD_SO_EU" (p_var1 IN VARCHAR2)
    IS
    lv_sql VARCHAR2 (4000);
    lv_name VARCHAR2 (20);
    BEGIN
    lv_sql :=
    ' SELECT DISTINCT LEVEL2
    FROM BIIO_SALES_OB_IMPORT_'|| p_var1;
    EXECUTE IMMEDIATE lv_sql
    INTO lv_name;
    BEGIN
    UPDATE BIIO_SALES_OB_IMPORT_NA2 --table name for updation
    SET SOB_1 = NULL,
    SOB_DATE_1 = NULL
    WHERE level2 = lv_name; -- validation ( eg. Select distinct level2 from biio_sales_ob_import_'||p_var1)
    COMMIT;
    EXCEPTION
    WHEN OTHERS
    THEN
    DBMS_OUTPUT.put_line (SQLERRM);
    NULL;
    END;
    END;
    BEGIN
    PKEP_LOAD_SO_EU ('NA1');
    end;
    Error report:
    ORA-01422: exact fetch returns more than requested number of rows
    ORA-06512: at "DEMANTRA.PKEP_LOAD_SO_EU", line 11
    ORA-06512: at line 2
    01422. 00000 - "exact fetch returns more than requested number of rows"
    *Cause:    The number specified in exact fetch is less than the rows returned.
    *Action:   Rewrite the query or change number of rows requested
    Thanks.
    Padma

    Padu wrote:
    Please let me know whether is anyother way to write this code as im a beginner for SQl.You dont need to have a seperate SELECT statement. Just a single UPDATE will do the job for you.
    create or replace procedure pkep_load_so_eu
       p_var1 in varchar2
    as
    begin
       lSql := ' update biio_sales_ob_import_na2               ' ||
               '    set sob_1      = null                    ' ||
            '      , sob_date_1 = null                    ' ||
            '  where level2 in (                         ' ||
            '                    select level2               ' ||
            '                      from biio_sales_ob_import_'       || p_var1 ||
       execute immediate lSql;
    end;

  • Dynamic field in master page header?

    Is it possible to put a dynamic field in a master page header that will either pull from a hidden text field added to each subform (e.g., appID) or pull in the title of the subform itself?  I have a number of variable-sized subforms that need the same header and footer, with the only distinct element being a different number at the top.
    I've been looking for a standard variable or wildcard that can be used to dynamically reference an object at the same level in multiple subforms, but so far have not been able to find what I need.
    Hierarchy:
    form1
         masterpage
         subformApp1
         subformApp2

    Hi Sankar,
    Create on eattribute of type String and bind to title property of page header,
    and your WDDOINIT or any event write code to set title for PG header,
    You are using different buttons, use this code in your buttons and change text.
    DATA lo_el_context TYPE REF TO if_wd_context_element.
      DATA ls_context TYPE wd_this->Element_context.
      DATA lv_pg TYPE wd_this->Element_context-pg.
    * get element via lead selection
      lo_el_context = wd_context->get_element( ).
      data pg1 type string.
      pg1 = 'selected the record'.
      lv_pg = Pg1.
    * set single attribute
      lo_el_context->set_attribute(
        name =  `PG`
        value = lv_pg ).
    In button 1..
    lv_pg = 'Enter the entries'.
    * set single attribute
      lo_el_context->set_attribute(
        name =  `PG`
        value = lv_pg ).
    Cheers,
    Kris.

Maybe you are looking for