How to use reference parameters (BAPI Import Parameters) in SQL statements

Dear SAP gurus
I have a question on using parameters passed in a custom BAPI in SQL statements.
I am sending 2 parameters  TABLENAME, COLUMNNAME into a custom bapi.
In the BAPI I need to give an sql command some thing like
select * from TABLENAME where COLUMNNAME = '100'.
Where TABLENAME and COLUMNAME may vary depend on what parameters are sent while calling this BAPI.
Even defining an internal table that has the structure of TABLENAME is not working.
I used the following statement 'data: ls_TABLENAME type TABLENAME', which generates error message saying TABLENAME is unknons.
Any feedback will be highly appreciated.
Thanks
Ram

As far as I know you can not give parameter to a select query like that. You should describe the tablename and the columnname as string type.  Then assign the values to them you want to use in query.
data: str_table type string.
data: str_column type string.
select * from  (str_table)  into  <g_t_table>  where (str_column)  = '100'.
If the table name is not determined until runtime, you must specify an output area with INTO .

Similar Messages

  • How to use "Reference Structure" setting in analysis grid item

    Hello expert,
            in Bex analyzer, how to use "Reference Structure" setting in analysis grid item by example?
    Many thanks,

    The variable needs assigned a value, that's why you're getting prompted. When you execute the statement, it's not executing the variable and exec lines.
    Having script output available in a grid would be an enhancement request.

  • How to use Reference type of Data Element

    Hi guys, is there anyone could give me a trace how to use reference type of data element.
    More details i'm going to reach is:
    I create 2 tables:
    eq.
    1. table ZFIRST has field X with data element ZFX (Data element i declared).
    2. table ZSECOND has field Y.
    Here at field Y (second table) I'm going to declare a new data element say it ZFY, but in ZFY I'm going to use the data element as i declared before (ZFX). Is it possible if I do it using reference type data element (SE11)?
    I already did this way, but I got error :
    Field Y: Reference ZFX to class w/o interface cannot be used in DB table ZSECOND
    What does it mean?. Did I miss something about using reference data element type?.
    This error occurs when I activate ZSECOND table. However in creating ZFY (reference) to data element ZFX, there is no error occur.
    The point is I need to RE-declared existing data element and ot put existing data element(ZFX) to my current table (ZSECOND).
    Any helpful will be highly appreciated.
    Thanks.
    Edited by: dinivian dondi on Nov 4, 2010 8:30 AM

    Field Y: Reference ZFX to class w/o interface cannot be used in DB table ZSECOND
    What does it mean?. Did I miss something about using reference data element type?.
    Apparently system doesn't allow you to type a transparent table field with deep type. This refers to references and tables types as components. The RDBMS (Relational DB Management System) cannot interpret this componenets correclty and mapp them to TABLEs in DB.
    So I am affraid you won't be able to type table component with reference to other data element.
    The point is I need to RE-declared existing data element and ot put existing data element(ZFX) to my current table (ZSECOND).
    Sorry but I don't get it, could you please explain this more clearly. Maybe then we can think of some workaround for you.
    Regards
    Marcin

  • Need a quick step by step how to use home share to import 500 songs in my Libruary into my little girls libruary

    need a quick step by step how to use home share to import 500 songs in my Libruary into my little girls libruary; her birthday is today - my five min action item has had me up since 2am - help me not be a failure today

    Hi there,
    So, is your daughter's library on a separate computer and running on the same Wifi as yours? Just need to establish the scenario.
    Cheers,
    GB

  • How to use getAncestor(n),getdescendant(child,child) in sql why they are use please give me example

    how to use getAncestor(n),getdescendant(child,child) in sql why they are use please give me example
    jitendra

    Below are a few examples that demonstrate these hierarchyid data type methods.  See the hierarchyid reference in the SQL Server Books Online for more examples of these and other methods (http://technet.microsoft.com/en-us/library/bb677193.aspx).
    --return a child of this node ('/1/')
    SELECT CAST('/' AS hierarchyid).GetDescendant(NULL, NULL).ToString();
    --returns a child of this node greater than child node '/1/' ('/2/')
    SELECT CAST('/' AS hierarchyid).GetDescendant(CAST('/1/' AS hierarchyid), NULL).ToString();
    --returns a child of this node less than chold node '/1/' ('/0/')
    SELECT CAST('/' AS hierarchyid).GetDescendant(NULL, CAST('/1/' AS hierarchyid)).ToString();
    --returns a child of this node greater than child node '/1/' and less than child node '/2/' ('/1.1/')
    SELECT CAST('/' AS hierarchyid).GetDescendant(CAST('/1/' AS hierarchyid), CAST('/2/' AS hierarchyid)).ToString();
    --return ancestor of node 1 level up from this node ('/1/2/')
    SELECT CAST('/1/2/3/' AS hierarchyid).GetAncestor(1).ToString();
    --return ancestor of node 2 levels up from this node ('/1/')
    SELECT CAST('/1/2/3/' AS hierarchyid).GetAncestor(2).ToString();
    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

  • How to use open cursor and iner join in one statement

    Hello All,
    Could any one post the code for the below question?
    How to use open cursor and iner join in one statement
    Regards,
    Lisa

    OPEN CURSOR c FOR SELECT     carrid connid fldate bookid smoker
                        FROM     sbook innerjoin shook
                        ORDER BY carrid connid fldate smoker bookid.
    Pls reward if helpful.

  • How to use PrSDKTransmitInvocationSuite in a importer ?

    But other types of plug-ins can use the Transmit Invocation Suite to push frames to transmitters. For example, an effect or titler with a modal setup dialog could push frames to the output.
    This is good idea for a title importer ! But, how to use "PrSDKTransmitInvocationSuite" in our title importer ? Sorry, we did not find any samples or codes in Examples of SDK.
    Is there some guys from Adobe could write some example code in here ?
    for example, where and how to call PrSDKTransmitInvocationSuite::CreateInstance(...) ?  how to fill the field of "ioInstance" parameters for this API ?
    how to implement PrSDKTransmitChangedProc functions ?
    It seems that there is no documents about this suite in SDK manual.

    Hi Zac,
    Thanks for your reply, please see my comment, am I right ?
    typedef struct
    csSDK_int32 inInstanceID;     // How to fill this ID ?
    PrTimelineID inTimelineID;  //  set it to 0 ?
    PrPlayID inPlayID;                 // set it to 0 ?
    prBool inHasAudio;               //  set it to FALSE, because Title did not need audio.
    csSDK_uint32 inNumChannels; // set it to 0
    PrAudioChannelLabel inChannelLabels[16];
    PrAudioSampleType inAudioSampleType;
    float inAudioSampleRate;
    prBool inHasVideo;                         // set to TRUE ?
    csSDK_int32 inVideoWidth;          //  Title project video resolution ?
    csSDK_int32 inVideoHeight;
    csSDK_int32 inVideoPARNum;
    csSDK_int32 inVideoPARDen;
    PrTime inVideoFrameRate;
    prFieldType inVideoFieldType;
    void* ioPrivateInstanceData; // may be written by plugin in CreateInstance, need not be serializable by the host
    } tmInstance;
    Regards.
    Jack

  • How to use this two bapi:BAPI_ACC_DOCUMENT_POST and   BAPI_ACC_GL_POSTING_POST

    As far as I know this two bapi used to create accounting document. But how do we use them ? and what's the different between them?
    The most important thing is in what condition we use which bapi to post accounting doc?
    Such as there is one requirement to post accounting doc though t-code F-02 in BDC, but how do I know whether I can use this two bapi to replace the BDC?
    BAPI_ACC_DOCUMENT_POST
    BAPI_ACC_GL_POSTING_POST

    Hello,
    how we use BAPI_ACC_DOCUMENT_POST:
       gs_documentheader-ref_doc_no = .... your document number (from number range)
       gs_documentheader-bus_act = 'RFBU'.
       gs_documentheader-username = sy-uname.
       gs_documentheader-header_txt = .... your header text
       gs_documentheader-comp_code = '0001'.
       gs_documentheader-doc_date = ..... date
       gs_documentheader-pstng_date = .... date
       gs_documentheader-fisc_year =.... year
       gs_documentheader-fis_period = .... period
       gs_documentheader-doc_type = 'BS'.
       loop at ... items ... assigning <belpos_line>.
         gs_accountgl-itemno_acc = <belpos_line>-posnr. "10 digits !
         gs_accountgl-bus_area = ... your business area
         gs_accountgl-tax_code = <belpos_line>-tax_code.
         gs_accountgl-gl_account = <belpos_line>-gl_account.
         gs_accountgl-comp_code = ... your company code.
         gs_accountgl-alloc_nmbr = ... some identity number
         gs_accountgl-item_text = .... item text
         gs_accountgl-costcenter = <belpos_line>-kostl.
         gs_accountgl-plant = .... werks
         append gs_accountgl to gt_accountgl.
         gs_currencyamount-itemno_acc = <belpos_line>-posnr.
         gs_currencyamount-currency = ... waers
         gs_currencyamount-amt_doccur = .... waers
         append gs_currencyamount to gt_currencyamount.
       endloop.
       call function 'BAPI_ACC_DOCUMENT_POST'
         exporting
           documentheader = gs_documentheader
         importing
           obj_type       = gd_obj_type
           obj_key        = gd_obj_key
           obj_sys        = gd_obj_sys
         tables
           accountgl      = gt_accountgl
           currencyamount = gt_currencyamount
           return         = gt_return.
    Regards

  • How to use lodercli for export import

    Hello,
    I want to migrate my content server data  , that is on SAPDB version 7.3 (32 bit)  to new server with MAX DB 7.6. (64 bit) .
    I wanted to know:
    1)  how to do export an d import using lodercli. i wanted to use loder of my new server i.e. MAXDB loder to do the export immport. Can any one tell me the steps and the command to do this ?
    2) I have refered SAP note 962019, but need some more help on the steps that is given in this note for hetrageneous copy.
    Note : i dont have any SAP system on the server i have only content server and hence i dont have user SAPR3 on database.
    Regards,
    Bhavesh

    > Please check the following (point 7) in note 962019:
    Ok...
    > 7. The procedure described in this note supports the following migrations:
    > and I am dealing with the same situation hence choose the export import rather than normal backup recovery.
    Well. it says: the procedure supports these migrations, which is true.
    It does not say: "please do use the export/import migration in these situations".
    Please do read the note point 1 where it says;
    "Homogeneous system copies (backup/recovery) can be executed only in
    systems that fulfill  the following conditions:
    a) The database versions in the source system and the target system
        do not differ.
    b) The processor uses the same byte sorting sequence (Little Endian
        -> Little Endian; Big Endian -> Big Endian).
    *If the specified operating system prerequisites are met in the
    source and target system, you MUST use the homogeneous system copy
    and not the heterogeneous system copy.*"
    So in your case export import is not even supported!
    > 2) I know the Cs 6.10 is out of support and it need to upgrade to new CS version that is 6.4 , but if i am already installing the new server for content server with CS 6.4 and MAXDB 7.6 why then why cant i use the export import from older server to new server??
    > Other wise i need to upgrade the MAXDB then upgrade CS and then take the backup and restore, isnt it more logivcal to do export import using loder as we have all prerequisites available??
    1. you don't meet the prerquesites (see above) - you can use backup/restore, so you have to !
    2. export/import is a terribly slow and clumsy procedure
    3. backup/restore is a easy, safe and fast method to perform the system copy
    If you still really, really want to stick with export/import, feel free to try it out.
    The note contain all required steps and the documentation for MaxDB even includes tutorials for the loader.
    regards,
    Lars

  • How to Use Sequence created in Oracle Database in SQL Ldr Control file

    Hi,
    I created a sequence in oracle database. How will use the sequence in SQL loader Control file.
    Thanks in advance

    Hi,
    You might get a good response to your post in the forum dedicated to data movement , including SQL*Loader . You can find it here Export/Import/SQL Loader & External Tables
    Regards,

  • How to use the updated value in the same update statement

    Hello,
    I just wonder how to use the updated new value of other column in the same udpate statement. I am using Oracle 11.2, and want to update the two columns with one update statement as following:
    create table tb_test (id number(5), tot number(5), mon_tot number(5));
    update tb_test set (tot = 15, mon_tot = tot *15) where id = 1;
    ...I would like to update both tot and mon_tot column, the value of mon_tot shall be determinted by the new value of tot.
    Thanks,
    Edited by: 939569 on 1-Feb-2013 7:00 AM

    Edit: example added
    SQL> create table tb_test
      2  ( id number(5)
      3  , tot number(5)
      4  , mon_tot number generated always as (tot*15) virtual
      5  );
    Table created.
    SQL> insert into tb_test (id, tot) values (1, 5);
    1 row created.
    SQL> select * from tb_test;
            ID        TOT    MON_TOT
             1          5         75
    1 row selected.
    SQL> update tb_test
      2  set    tot = 15
      3  where  id = 1;
    1 row updated.
    SQL> select * from tb_test;
            ID        TOT    MON_TOT
             1         15        225
    1 row selected.

  • How To Use a Hidden Page Item within an SQL Report Query without Submitting

    Hi,
    Using: Oracle ApEx 3.0.1
    I have an sql report region that contains a hidden page item as part of the "where clause". My problem is, based on a value entered by the user, I need to assign this value enetered to my hidden item, so that it can be used within the where condition of my sql but this would need to be done without actually submitting the form.
    At the moment, I can set the value via an on-demand process but my SQL is still not returing any values as the hidden page item within the query is not set (as page has not been submitted).
    Can anybody please assist as I am not sure how to do this and whether in actual fact, this is possible to do, without having submitted the page.
    Thanks.
    Tony.
    Edited by: Tony F. on Nov 12, 2011 1:39 AM

    You can set a session value using a dummy ajax call e.g:
    Add the following to the 'Function and Global Variable Declaration' region
    function f_set_item(pThis){
      var get = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=dummy',1);
      get.add('P1_ID',pThis.value)
      gReturn = get.get();
      get = null;
    }Where P1_ID is the session value to be set. Then call the function in the usual way e.g.
    javascript:f_set_item(this);
    I hope that helps
    Shunt

  • MAP Toolkit - How to use this MAP tool kit for all SQL Server inventory in new work enviornment

    Hi Every one
     Just joined to new job and planning to do Inventory for whole environment so I can get list of all SQL Server installed . I downloaded MAP tool kit just now. So looking for step by step information to use this for SQL Inventory. If anyone have documentation
    or screen shot and can share would be great.
    Also like to run It will be good to run this tool anytime or should run in night time when is less activity? 
    Hoe long generally takes for medium size environment where server count is about 30 ( Dev/Staging/Prod)
    Also any scripts that will give detailed information would be great too..
    Thank you 
    Please Mark As Answer if it is helpful. \\Aim To Inspire Rather to Teach A.Shah

    Hi Logicinisde,
    According to your description, since the issue regards Microsoft Assessment and Planning Solution Accelerator. I suggestion you post the question in the Solution Accelerators forums at
    http://social.technet.microsoft.com/Forums/en-US/map/threads/ . It is appropriate and more experts will assist you.
    The Microsoft Assessment and Planning (MAP) Toolkit is an agentless inventory, assessment, and reporting tool that can securely assess IT environments for various platform migrations. You can use MAP as part of a comprehensive process for planning and migrating
    legacy database to SQL Server instances.
    There is more information about how to use MAP Tool–Microsoft Assessment and Planning toolkit, you can review the following articles.
    http://blogs.technet.com/b/meamcs/archive/2012/09/24/how-to-use-map-tool-microsoft-assessment-and-planning-toolkit.aspx
    Microsoft Assessment and Planning Toolkit - Technical FAQ:
    http://ochoco.blogspot.in/2009/02/microsoft-assessment-and-planning.html
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • How to pass the bind variable value to the sql statement of the LOV

    Hi,
    I am using Forms 10g builder.
    I have a text item which will be populated by a LOV when i press a button, but i have a bind variable in the SQL statement of the LOV. That bind variable should be replaced by a value which is derived from a radio group in the same data block.
    For Ex: ( )radio1 ( )radio2
    before i click on the push button, I'll select one of the radio button above,so my question is how to assign this radio group value to the bind variable in the sql statement in the LOV?
    Pl any hint is appreciated!
    Thanks
    Reddy

    The variable can be taken into account in the SELECT order contained in the Record Group used by the LOV.
    e.g. Select ... From ... Where column = :block.radio_group ...Francois

  • Using a string variable as a query SQL statement

    I want to construct a custom SQL statement in a string var, then use that var in the cfquery statement.  What is the proper syntax?  Here is my feeble attempt:
      <cffunction ...>
      <cfset var sql_txt="">
            <cfquery name="qSBJs" datasource="cfBAA_odbc">
                "#sql_txt#"
            </cfquery>
        <cfreturn qSBJs>
    I've tried using no " or # or just # or just " but nothing works.
    what about:
            <cfquery name="qSBJs" datasource="cfBAA_odbc" sql="#sql_txt#">
            </cfquery>
    nope.  I wish there was a sql property I could fill *before* the execution of the query.  Any suggestions?

    Hi Adam, and/or anyone who may have a few minutes to check this... I got the following code to work.  It calls the getSBJs function from Flash Builder 4.  I get the correct result set back.  Long table names are replaced with short abreviations.  Note that some local vars are declared but not used in the following example. I will use them in the future versions of this same code.  Since I will in the future, like a donkey, mindlessly use this same method for all my queries, it would be much appreciated if I could get a guru to check this code for:
    -Pure idiocy
    -Mild insanity
    -SQL injection vulnerability
    -Memory leakage
    -Scope dangers
    (ignore emoticons, see the underlying text)
        <cffunction name="AbrvTblNms" output="false" returntype="string" >
            <cfargument name="txt" type="string" required="true" />
            <cfset var qAbrvs="">
            <cfset var output_str="#ARGUMENTS.txt#">
            <cfquery name="qAbrvs" datasource="cfBAA_odbc" result="rsltAbrvs">
                SELECT TBL_NM, ABRV FROM BAA_TBL_ABRV ORDER BY 1
            </cfquery>
        <cfloop query="qAbrvs">
                <cfset output_str = Replace(output_str, '[' & qAbrvs.TBL_NM & ']', qAbrvs.ABRV, "ALL")>
        </cfloop>
            <cfreturn output_str>
        </cffunction>
        <!--- Fetch a list photo subjects whose records contain the given search word(s) --->
        <cffunction name="getSBJs" output="false" access="remote" returntype="any" >
            <cfargument name="srch_val" type="string" required="true" />
            <cfset var qSBJs="">
            <cfset var sql_txt="">
            <cfset var whr=""> 
            <cfset var b=False>
            <cfset var in_txt="">
            <cfset var fm_dt="">
            <cfset var to_dt="">
            <cfset var on_dt="">
            <cfset var pht="">
            <cfset var srch_str="">
            <cfset var srch_trm="">
            <!--- Transfer the srch_val to a local variable for further manipulation --->
            <cfset srch_str = "#ARGUMENTS.srch_val#">
            <!---
                An empty search term argument is handled by the BAA FlashBuilder front end.  We test for it again here,
                and substitute a dummy value, in case this function is called by something other than the intended
                FlashBuilder front end, and that front end doesn't protect us from an empty search term argument.
                Remember that we must still "hand back" a valid query structure to avoid causing a data type error
                in the calling function, so we search for a dummy value that will allow the query to proceed but is
                guaranteed to return an empty result set.  If the srch_val argument is not empty, transfer the value of
                the srch_str local variable to the srch_trm local variable.
            --->
            <cfif Not (Len(srch_str))>
                <cfset srch_str = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX">
            </cfif>
            <cfset srch_trm = "#srch_str#">
            <cfset sql_txt =
                "SELECT DISTINCT
                  [BAA_SBJ].SRC_SYS_NM, [BAA_SBJ].SRC_SYS_GUID, [BAA_SBJ].OBJ_GUID, [BAA_SBJ].SBJ_NM, [BAA_SBJ].SBJ_DOB, [BAA_SBJ].SBJ_ID, [BAA_SBJ].NOTE, [BAA_SBJ].CDT, [BAA_SBJ].CTM, [BAA_SBJ].CBY, [BAA_SBJ].MDT, [BAA_SBJ].MTM, [BAA_SBJ].MBY
                FROM
                  BAA_SBJ [BAA_SBJ]
                  LEFT JOIN BAA_SES [BAA_SES] ON [BAA_SES].PAR_GUID = [BAA_SBJ].OBJ_GUID
                  LEFT JOIN BAA_IMG [BAA_IMG] ON [BAA_IMG].PAR_GUID = [BAA_SES].OBJ_GUID
                WHERE [WHERE_CLAUSE] ORDER BY [BAA_SBJ].SBJ_NM">
            <cfset whr = "([BAA_SBJ].SBJ_NM CONTAINING TRIM( rm_srch_trm1 ) OR " &
                    "[BAA_SBJ].NOTE CONTAINING TRIM(:prm_srch_trm2 ) OR " &
                    "[BAA_SBJ].SBJ_DOB CONTAINING TRIM(:prm_srch_trm3 ) OR " &
                    "[BAA_SES].SES_TYP CONTAINING TRIM(:prm_srch_trm4 ) OR " &
                    "[BAA_SES].NOTE CONTAINING TRIM(:prm_srch_trm5 ) OR " &
                    "[BAA_IMG].NOTE CONTAINING TRIM(:prm_srch_trm6 ))">
            <cfset sql_txt = Replace(sql_txt,"[WHERE_CLAUSE]", "#whr#", "ALL")>
            <cfset sql_txt = AbrvTblNms(sql_txt)>
        <!--- Through experimentation, I learned that each occurance of a param must be uniquely named.
                  It would be very handy, if the param value was applied to *all* occurances of the param.
                        That way, I could get away with using one .addParam line instead of 6 --->
            <cfscript>
            queryService = new query();
            queryService.setDatasource("cfBAA_odbc");
            queryService.setName("qSBJs");
            queryService.setAttributes(sql="#sql_txt#");
            queryService.addParam(name="prm_srch_trm1", value="#srch_trm#", cfsqltype="VARCHAR");
            queryService.addParam(name="prm_srch_trm2", value="#srch_trm#", cfsqltype="VARCHAR");
            queryService.addParam(name="prm_srch_trm3", value="#srch_trm#", cfsqltype="VARCHAR");
            queryService.addParam(name="prm_srch_trm4", value="#srch_trm#", cfsqltype="VARCHAR");
            queryService.addParam(name="prm_srch_trm5", value="#srch_trm#", cfsqltype="VARCHAR");
            queryService.addParam(name="prm_srch_trm6", value="#srch_trm#", cfsqltype="VARCHAR");
            result = queryService.execute();
            qSBJs = result.getResult();
            </cfscript>       
            <!--- <cfquery name="qSBJs" datasource="cfBAA_odbc">
            </cffunction>
            </cfquery> --->
            <cfreturn qSBJs>
        </cffunction>
    THANKS TO ADAM AND DAN FOR HELPIMG ME GET THIS FAR!  Now, don't let me embarass you by doing something dum and giving you "credit", if you see me doing something dum above.  Thanks!

Maybe you are looking for