Iterating/Executing TSQL-Scripts in Subfolders throws an error

Hi Forum,
the idea: I have several subfolders containing tsql-scripts. I want to change into a folder and execute every script - sorted by name (important because of dependencies).
I have an array with Subfolder names, I build on fly an array wiht script names inside of every subfolder, I'm reading the content of a tsql-file (sentence by sentence), I'm paying attention for a "go" statement and then execute the command.
When the first script doesn't end with a "go" statement, I'll get an error executing the first line of the second script.
I don't know where to set my command-variable to $null or to blank (" ").
For example the first script is:
DECLARE @CMD varchar(500)
SET @CMD = 'EXEC sp_configure ''show advanced option'', ''1'';
reconfigure with override
EXEC sp_configure ''xp_cmdshell'',''1''
reconfigure with override'
print @CMD
EXEC (@CMD)
..and the second begins with:
sp_configure 'allow updates','1'
go
reconfigure with override
GO
then I get an error:
DECLARE @CMD varchar(500)
SET @CMD = 'EXEC sp_configure ''show advanced option'', ''1'';
       reconfigure with override
            EXEC sp_configure ''xp_cmdshell'',''1''
            reconfigure with override'
print @CMD
EXEC (@CMD)
sp_configure 'allow updates','1'
Exception calling "ExecuteScalar" with "0" argument(s): "Incorrect syntax near 'allow updates'."
At L:\SQL-INSTALL\Install_AdminDB.ps1:42 char:50
+                         $SQLCommand.ExecuteScalar <<<< ()
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException
My PSScript looks like that:
param(
#$ServerName
[parameter(Mandatory=$true,
HelpMessage="SQLServer-Name?",Position=0)]
[String]
[ValidateNotNullOrEmpty()]
$ServerName = $(throw "sqlserver parameter is required.")
$Paths = "DEV_1", "DEV_2", "DEV_3"
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null
$objSQLConnection = New-Object System.Data.SqlClient.SqlConnection
$objSQLConnection.ConnectionString = "Server=$ServerName;Integrated Security=SSPI;"
$objSQLConnection.Open() #| Out-Null
foreach($path in $Paths)
$sqlSkripts = Join-Path ($PWD.Path) $path | dir -Filter "*.sql" | sort-object name
"sqlSkripts: " + $sqlSkripts
foreach($sqlSkript in $sqlSkripts)
$SQLCommandText = @(Get-Content -Path $sqlSkript.FullName)
"#" * $sqlSkript.FullName.Length | Out-File -FilePath ($PWD.Path + "\SQLProtokoll.txt") -Append
$sqlSkript.FullName | Out-File -FilePath ($PWD.Path + "\SQLProtokoll.txt") -Append
"#" * $sqlSkript.FullName.Length | Out-File -FilePath ($PWD.Path + "\SQLProtokoll.txt") -Append
Try
foreach($SQLString in $SQLCommandText)
if($SQLString -ne "go")
$SQLPacket += $SQLString + "`n"
else
$IsSQLErr = $false
try
$SQLCommand = New-Object System.Data.SqlClient.SqlCommand($SQLPacket, $objSQLConnection)
$SQLCommand.ExecuteScalar()
catch
Write-Host "Error..."
$IsSQLErr = $true
"SQLPaket: " + $SQLPacket
$SQLPacket | Out-File -FilePath ($PWD.Path + "\SQLProtokoll.txt") -Append
$Error[0] | Out-File -FilePath ($PWD.Path + "\SQLProtokoll.txt") -Append
$SQLPacket = $null
$SQLString = ""
Catch
$errText = $Error[0].ToString()
"Error: " + $errText | Out-File -FilePath ($PWD.Path + "\SQLProtokoll.txt") -Append
continue
$SQLCommandText = ""
$objSQLConnection.Close()
Write-Host "Done!..." -NoNewline
Thanks for your help
Purclot

Hi Purclot,
How about using a parameter with the cmdlet $SqlCmdQueryPlanGet.Parameters.Add()?
I found a thread which has the similar issue may be helpful for you to modify the script:
Handling plan_handle with varbinary data type in PowerShell
I hope this helps.

Similar Messages

  • Can you get the file name of the current executing TSQL script?

    Can you get the file name of the current executing TSQL script? I wrote entries to a generic log file and would like to include the script name.

    Okay, So What you can do is
    1. Read get the version from your  database and redirect it to a text file(SQLCMD outout can be directed to text file using -o option or windows redirection operator >)
    2. Now you can read this value from the text file either inside a batch file or a powershell script and decide what operations you can do. 
    Satheesh
    My Blog |
    How to ask questions in technical forum

  • Update Link function throws an error in cs4!

    Hi,
    Iam using the update() function in the Link class to update a dataLink in the document. But when I execute the update command, Indesign throws an
    error "Error String : update" . Can any one tell me why this doesnt work?
    Example:
    function UpdateAllOutdatedLinks(){
       var myLinks = myDocument.links;
       for(var myCounter = myDocument.links.length-1; myCounter >= 0; myCounter--){
          var myLink = myDocument.links[myCounter];
          if (myLink.status == LinkStatus.linkOutOfDate){
             myLink.update();

    I use something like :myLink.relink(File(xxx));
    myLink.update();
    and yet, I have to update manually the links in the UI.
    I saw similar posts all around but none of the tricks I used from them produced any improvements.
    Any ideas ?
    next bug ?
    the same problem is in VB6 - sometimes link is updated - sometimes not ... I'm not sure but running .Update after few seconds update link ...
    robin
    www.adobescripts.co.uk

  • Smo.Server.ExecuteNonQuery throw an error executing a script with IF statement

    I am trying to executed this script (see below) using Smo libraries with powershell (this script works in SSMS)
    use master;
    GO
    use master;
    if (not exists(select * from sys.databases where name = 'dbname'))
        alter database [dbname] set offline with rollback immediate;
    GO
    however, I always got an
    Exception calling "ExecuteNonQuery" with "1" argument(s): "An exception occurred while executing a Transact-SQL statement or batch."
    if I delete the if statement, the script execute without erros... is there any problem to use if statements?  I would really appreciate any help
    regards.!

    Olaf
    Helper answer does make sense and you won't be able to modify database which doesn't exists. However, your syntax's are correct.
    However, if you are executing it via Powershell as mentioned by HoroChan then
    I recommend you to increase the statementTimeout to appropriate value. 
    There may be chances that alerting database got hanged and exceeded the timeout.  So instead of IMMEDIATE ROLLBACK you can use
    WITH NO WAIT
    From MSDN:
    Specifies that if the requested database state or option change cannot complete immediately without waiting for transactions to commit or roll back on their own, the request will fail.
    So your overall code will look like 
    USE MASTER;
    IF EXISTS(select * from sys.databases where name = 'dbname')
    ALTER DATABASE [dbname] SET OFFLINE WITH NO_WAIT
    GO
    Hope this will help.

  • Dump while executing SAP Script

    Hello,
    My program is throwing a dump while executing this script. Request you all to please help me in removing this.
    /E   MAIN_DATA
    /:    BOX FRAME 10 TW
    PA To,  ,,Invoice No. & Date,,  &JVBRK-VBELN&  &JVBRK-FKDAT&
    PA M/s  &JKNA1-NAME1(35)&,,Your P.O. No.,,  &JVBAK-BSTNK&
    /*           &JKNA1-NAME2(35)&,,Truck No.,,  &JLIKP-TRAID&
    PA         &JKNA1-NAME2(35)&,,Truck No.,,  &WRK_VEHNO&
    PA         &JKNA1-ORT01(20)&,,LR No.& Date,,  &WRK_LRNO&   &JJ_1IEXCDTL-EXDAT& 
    /*           &JKNA1-REGIO(20)&,,Net Qty.in kgs.,,  &JLIPS-NTGEW(10.3L)&
    PA         &JKNA1-REGIO(20)&,,Net Qty.in kgs.,,  &W_NETWT(12.3L)& KG
    PA         ,,Material,,  &JVBRP-ARKTX(30)&
    My Report has the following code:
    FORM write_to_layout_set.
      PERFORM write_layout_set USING 'MAIN' 'SET' 'BODY' 'MAIN'.
      PERFORM write_layout_set USING '' 'SET' 'BODY' 'LOGO'.
      PERFORM write_layout_set USING '' 'SET' 'BODY' 'HEADER2'.
      PERFORM write_layout_set USING 'HEADER' 'SET' 'BODY' 'TEST2'.
      PERFORM write_layout_set USING 'FOOTER' 'SET' 'BODY' 'FOOTER2'.
      PERFORM write_layout_set USING '' 'SET' 'BODY' 'SIGN'.
    ENDFORM.                               " WRITE_TO_LAYOUT_SET
    FORM write_layout_set USING wrk_element
                                wrk_function
                                wrk_type
                                wrk_window.
      CALL FUNCTION 'WRITE_FORM'
         EXPORTING
               element       =  wrk_element
               function      =  wrk_function
               type          =  wrk_type
              window         =  wrk_window
       IMPORTING
            PENDING_LINES =
           EXCEPTIONS
                element       = 1
                function      = 2
                type          = 3
                unopened      = 4
                unstarted     = 5
                window        = 6
                OTHERS        = 7.
    +
      IF sy-subrc NE 0.
        PERFORM protocol_update.
      ENDIF.
    +
    ENDFORM.                               " WRITE_LAYOUT_SET

    As per my first reply you have to change the perform
    PERFORM write_layout_set USING 'MAIN' 'SET' 'BODY' 'MAIN'.
    to
    PERFORM write_layout_set USING 'MAIN_DATA' 'SET' 'BODY' 'MAIN'.
    and now check and one more thing whether this main_data element is in main window or not just check.
    if it does not work then just change &W_NETWT(12.3L)&  to
    &W_NETWT& and check

  • TSQL Script to monitor SQL Server transactional and snapshot replication

    Hi Team,
    Could you please let me know do you have any TSQL script to monitor replication(Transactional, Snapshot) with current status ? I have tried below script but it giving error. could you please have a look at the below script or do you have any other new TSQL
    script to monitor the replication status ?
    "Msg 8164, Level 16, State 1, Procedure sp_MSload_tmp_replication_status, Line 80
    An INSERT EXEC statement cannot be nested."
    DECLARE @srvname VARCHAR(100)
    DECLARE @pub_db VARCHAR(100)
    DECLARE @pubname VARCHAR(100)
    CREATE TABLE #replmonitor(status    INT NULL,warning    INT NULL,subscriber    sysname NULL,subscriber_db    sysname NULL,publisher_db    sysname NULL,
    publication    sysname NULL,publication_type    INT NULL,subtype    INT NULL,latency    INT NULL,latencythreshold    INT NULL,agentnotrunning    INT NULL,
    agentnotrunningthreshold    INT NULL,timetoexpiration    INT NULL,expirationthreshold    INT NULL,last_distsync    DATETIME,
    distribution_agentname    sysname NULL,mergeagentname    sysname NULL,mergesubscriptionfriendlyname    sysname NULL,mergeagentlocation    sysname NULL,
    mergeconnectiontype    INT NULL,mergePerformance    INT NULL,mergerunspeed    FLOAT,mergerunduration    INT NULL,monitorranking    INT NULL,
    distributionagentjobid    BINARY(16),mergeagentjobid    BINARY(16),distributionagentid    INT NULL,distributionagentprofileid    INT NULL,
    mergeagentid    INT NULL,mergeagentprofileid    INT NULL,logreaderagentname VARCHAR(100),publisher varchar(100))
    DECLARE replmonitor CURSOR FOR
    SELECT b.srvname,a.publisher_db,a.publication
    FROM distribution.dbo.MSpublications a,  master.dbo.sysservers b
    WHERE a.publisher_id=b.srvid
    OPEN replmonitor 
    FETCH NEXT FROM replmonitor INTO @srvname,@pub_db,@pubname
    WHILE @@FETCH_STATUS = 0
    BEGIN
    INSERT INTO #replmonitor
    EXEC distribution.dbo.sp_replmonitorhelpsubscription  @publisher = @srvname
         , @publisher_db = @pub_db
         ,  @publication = @pubname
         , @publication_type = 0
    FETCH NEXT FROM replmonitor INTO @srvname,@pub_db,@pubname
    END
    CLOSE replmonitor
    DEALLOCATE replmonitor
    SELECT publication,publisher_db,subscriber,subscriber_db,
            CASE publication_type WHEN 0 THEN 'Transactional publication'
                WHEN 1 THEN 'Snapshot publication'
                WHEN 2 THEN 'Merge publication'
                ELSE 'Not Known' END,
            CASE subtype WHEN 0 THEN 'Push'
                WHEN 1 THEN 'Pull'
                WHEN 2 THEN 'Anonymous'
                ELSE 'Not Known' END,
            CASE status WHEN 1 THEN 'Started'
                WHEN 2 THEN 'Succeeded'
                WHEN 3 THEN 'In progress'
                WHEN 4 THEN 'Idle'
                WHEN 5 THEN 'Retrying'
                WHEN 6 THEN 'Failed'
                ELSE 'Not Known' END,
            CASE warning WHEN 0 THEN 'No Issues in Replication' ELSE 'Check Replication' END,
            latency, latencythreshold, 
            'LatencyStatus'= CASE WHEN (latency > latencythreshold) THEN 'High Latency'
            ELSE 'No Latency' END,
            distribution_agentname,'DistributorStatus'= CASE WHEN (DATEDIFF(hh,last_distsync,GETDATE())>1) THEN 'Distributor has not executed more than n hour'
            ELSE 'Distributor running fine' END
            FROM #replmonitor
    --DROP TABLE #replmonitor
    Rajeev R

    INSERT INTO #replmonitor
    Hi Rajeev,
    Could you please use the following query and check if it is successful?
    INSERT INTO #replmonitor
    SELECT a.*
    FROM OPENROWSET
    ('SQLNCLI', 'Server=DBServer;Trusted_Connection=yes;',
    'SET FMTONLY OFF; exec distribution..sp_replmonitorhelpsubscription
    @publisher = DBServer,
    @publication_type = 0,
    @publication=MyPublication') AS a;
    There is a similar thread for your reference.
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/634090bf-915e-4d97-b71a-58cf47d62a8a/msg-8164-level-16-state-1-procedure-spmsloadtmpreplicationstatus-line-80?forum=sqlreplication
    Thanks,
    Lydia Zhang
    Lydia Zhang
    TechNet Community Support

  • R Functions in Execute R Script

    Hello, much appreciated if the learned ones can help me here.
    I followed the excellent quick start by Blackmist.
    My R script uses the function graph.data.frame from igraph to turn the data frame into a graph object and it throws an error 0063  Error: Mapped variable must be of class type data.frame at this time.
    Does this mean the my data frame in ML is not the same type of data frame as in R? 
    In R
    sample1<-read.csv("File Location")
    graph1<-graph.data.frame(sample1)
    In ML
    sample1<-maml.mapInputPort(1)
    graph1<-graph.data.frame(sample1)

    Hi,
    The problem is that you can only return objects where "is.data.frame" is true and graph data frames from the igraph library do not have this property.
    Here are a couple of work arounds:
    2. To return arbitrary R objects as data.frames, you can serialize
    them into a byte array using:
    as.data.frame(as.integer(serialize(g,con=NULL))); <o:p></o:p>
    3. Alternatively, igraph provides a function, get.data.frame to
    get the edge and vertex information as data frames. So you can do something
    like this:<o:p></o:p>
    vertices <- get.data.frame(g, what="vertices")
    or
    edges <- get.data.frame(g, what="edges")
    Each of these are a data.frame you can return them individually from the Execute R Script module.
    Does this help?
    Margaret

  • How to execute sql scripts from Powershell across multiple databases

    Re: How to execute sql scripts from Powershell across multiple databases
    I have an tsql script that I want to run across a list of databases. How is the best way to do this in Powershell? Thanks.

    My example below, using just the SMO and not breaking up the batches, the ExecuteWithResults give the following error when the .sql file contains a GO. My script files are as simple as a DECLARE and then a GO.
    WARNING: SQL Script Failed
    The object of type "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not valid or not in the correct sequence. This is likely caused by a user-specified "format-list" comm
    and which is conflicting with the default formatting.
        + CategoryInfo          : InvalidData: (:) [out-lineoutput], InvalidOperationException
        + FullyQualifiedErrorId : ConsoleLineOutputOutOfSequencePacket,Microsoft.PowerShell.Commands.OutLineOutputCommand
    Also, when executing from the ISE, is there a way to force the ISE to release the files. I am having to close the ISE and reopen my script every time I want to make a testing change to the .sql file.
    [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")
    $scriptspath = "C:\temp\psExecuteSQLScripts\scripts"
    $SQLServer = "fidevc10"
    $SQLDB = "Bank03"
    # Create SMO Server Object
    $Server = New-Object ('Microsoft.SQLServer.Management.Smo.Server') $SQLServer
    # Get SMO DB Object
    $db = $Server.Databases[$SQLDB]
    # Load All SQL Scripts in Directory
    $scripts = Get-ChildItem -Path (Join-Path $scriptspath "*") -Include "*.sql" -Recurse
    # Loop through each script and execute
    foreach ($SQLScript in $scripts)
    $fullpath = $SQLScript.FullName
    # Read the Script File into Powershell Memory
    $reader = New-Object System.IO.StreamReader($fullpath)
    $script = $reader.ReadToEnd()
    # Execute SQL
    Write-Host "Executing $SQLScript on $SQLDB...."
    try
    $ds = $db.ExecuteWithResults($script)
    Foreach ($t in $ds.Tables)
    Foreach ($r in $t.Rows)
    Foreach ($c in $t.Columns)
    Write-Host $c.ColumnName "=" $r.Item($c)
    Write-Host "Complete"
    catch [Exception]
    Write-Warning "SQL Script Failed"
    echo $_.Exception|format-list -force
    Write-Host " " -BackgroundColor DarkCyan

  • Error while executing the script adgetlnxver.sh

    Error while executing the script adgetlnxver.sh on apps&db tier during upgrade from 11.5.9 to 11.5.10.2
    -bash: [: -lt: unary operator expected
    [aptinst@dba5 TINST_dba5]$ sh adapcctl.sh restart
    adapcctl.sh version 115.55
    /u01/app/tinst/tinstappl/ad/11.5.0/bin/adgetlnxver.sh: line 123: [: -lt: unary operator expected
    Apache Web Server Listener :httpd ( pid 8645 ) is running.
    Restarting the Apache Web Server Dedicated HTTP Listener..
    Apache Web Server Listener (PLSQL) :httpd ( pid 8673 ) is running.
    Restarting the Apache Web Server Dedicated PLSQL Listener..
    adapcctl.sh: exiting with status 0
    In adgetlnxver.sh: line 123 says
    if [ ${setflag}x = "x" -a $os = "RH" ]; then
    redhatver=`grep -oP "Enterprise Linux [a-z A-Z 0-9]* release [0-9]+" /etc/redhat-release | sed 's/Enterprise Linux [a-z A-Z 0-9]* release //g'`
    if [ $redhatver -lt 5 ]; then
    LD_ASSUME_KERNEL="2.4.19"
    export LD_ASSUME_KERNEL
    fi
    fi
    Thanks,
    Vamsi

    Hi Vamsi.
    The exactly erro refers to a problems when you try upgrade from these version to 11.5.10.
    Can you read this note and apply solution? The note refers a patch, but the problem is the same.
    After Patch 4334965, adstrtal.sh & adstpall.sh is failing with errors [ID 360046.1]
    BR Rafael Ceolim

  • Afraid of executing a script on server

    I have to make a script which deletes all the folders and files in the following directories on Windows Server 2008:
    D:\frotxy\out\backup\
    D:\frotxy\in\backup\
    Yesterday I tried executing the script from my Desktop to delete the files in a test folder but unfortunately I had mistaken the path to this folder. What happened was my Desktop files were deleted - ARGHH! 
    So my question is is there a safer way to do the script and check it before executing it on the server as it is important not to delete some other directory or file from the server :)
    This is the script:
    set folder="D:\frotxy\out\backup"
    cd /d %folder%
    for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q)
    set folder="D:\frotxy\in\backup"
    cd /d %folder%
    for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q)
    And where should I place the file containing the script?
    I am not into scripts at all so please help!

    If the folder doesn't exist, you have no error checking there to handle the failure of the cd command, and you continue on with the "delete everything" part.  You can either check for the existence of the folder first, check for an error after
    the CD command, or not use relative paths at all and just pass folder in to the dir command (which would be my preference.)  Here's my example (note the quotation marks have been removed from the set folder line; they're hard-coded later on):
    set folder=D:\frotxy\in\backup
    for /F "delims=" %%i in ('dir /b "%folder%\*"') do (rmdir "%folder%\%%i" /s/q || del "%folder%\%%i" /s/q)
    Note:  I'm not sure what's going on with that (rmdir || del) bit.  To my knowledge, there's no "||" operator in batch files, and "|" doesn't make any sense here, but I've left the original code alone and only changed the bits related
    to where things will be deleted, not how they are deleted.
    Edit:  On a side note, this would be much safer and easier in PowerShell, which is Microsoft's current command-line interface and scripting language.  For example:
    $folder = 'D:\frotxy\in\backup'
    Get-ChildItem -Path "$folder\*" -Recurse -Force | Remove-Item -Force -WhatIf
    That -WhatIf switch on the end of the Remove-Item command is a common parameter in PowerShell.  It shows you what the command would have done, allowing you to make sure you like the results first.  Then you run it again without -WhatIf, and it deletes
    things for you.

  • How to execute vb script with out using Remote manager in oim 11g r2

    Hi Currently,
    i have a requirement to execute  vb script (present on a remote machine in which connector server is installed) from oim machine while using Exchange connector (11.1.1.6).
    This can be achieved by using remote manager,but i dont want to use remote manager.
    Hence decided to use Action scripts.
    As per connector configuration,
    i have configured Action scripts in Lookup.Exchange.UM.Configuration lookup definition, by means of three entries
    After Create Action Language      Shell
    After Create Action Target           Resource
    After Create Action File              /home/scripts/Disable.bat
    Disable.bat has the following ,
    Powershell.exe -File C:\scripts\Setup.vbs
    -%Log on Name%
      Exit
    As Setup.vbs is expecting a parameter of log on name, i was providing the same.
    But while creating the user,as this script gets called, getting the following error and hence 'create User' is getting failed.
    Problem while PowerShell execution System.Management.Automation.RemoteException: This task does not support recipients of this type. The specified recipient XXXXXXXXXXX...XXXXX is of type UserMailbox. Please make sure that this recipient matches the required recipient type for this task.
    While provisioning the user to Exchange , i have selected 'Recepient type' as 'User Mail box' explicitly, but still getting the error.
    Please provide any pointers to resolve the issue.
    Thanks in advance
    Kumar

    As far as I know Oracle and MySQL are two different products.
    Why do you clutter an Oracle forum with MySQL questions?
    If MySQL is such a tremendous RDBMS, like many people state (as 'free' means per definition better),
    why don't you visit a MySQL forum where fellow MySQL aficionados can answer you MySQL questions?
    In short, why don't you stop abusing Oracle forums?
    Sybrand Bakker
    Senior Oracle DBA

  • Error to execute the script through command prompt

    I tried to execute the script through command prompt. I got some following error. Could you please advice me how to rectify this.
    cscript D:\JS\Test.js
    Microsoft (R) Windows Script Host Version 5.6
    Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
    D:\JS\Test.js(1, 1) Microsoft JScript runtime error: 'app' is undefined.
    Thanks,
    Prabudass

    I haven't use CS for quite some time and file associations may not work with the command prompt.
    You can try using Windows Explorer to browse to a .js file then right click on that file. From the popup menu choose Open With. Even if you see Photoshop in the file list choose Browse at the bottom. Browse to Photoshop and make sure to check 'Always use selected program...'
    If that doesn't work you will need to create an action that runs your script and make a droplet from that action. You can then use the droplet in the command prompt. You may also need to create a 'dummy' image file to launch the droplet with if you script doesn't require an open document at startup. See http://www.ps-scripts.com/bb/viewtopic.php?t=967

  • ABAP program to execute shell script !

    Hi Friends,
    I have created some shell scripts and need to be executed through ABAP prog in order to automate some process. can any one tell me how to execute these scripts through ABAP program? i know that we have to setup those scripts through SM69 but i dont have clear idea about this.can some one tell me step by step how to do this. ur help will be awarded in terms of points.
    Thanks

    Define the scripts as commands in SM69. Test them in SM69/SM49 to see if they work.
    Next, go to SE37, run FM SXPG_COMMAND_EXECUTE, and specify your command there. Does it work?
    If yes, you can just code a 'CALL FUNCTION' to this FM in your ABAP program, and you are ready to invoke your script from your ABAP.
    For  a list of functions that work with commands (defined in SM69), do a drop-down on SXPG_COMMAND* in SE37.
    A sample code may look like this
    concatenate zsys_id z_infile z_extfile into parm
        separated by space.
    *C_FTP_COMMAND is a script defined in SM49
        CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
          EXPORTING
            COMMANDNAME                   = C_FTP_COMMAND
            ADDITIONAL_PARAMETERS         = parm
            OPERATINGSYSTEM               = SY-OPSYS
          TABLES
            EXEC_PROTOCOL                 = PROT
          EXCEPTIONS
            NO_PERMISSION                 = 1
            COMMAND_NOT_FOUND             = 2
            PARAMETERS_TOO_LONG           = 3
            SECURITY_RISK                 = 4
            WRONG_CHECK_CALL_INTERFACE    = 5
            PROGRAM_START_ERROR           = 6
            PROGRAM_TERMINATION_ERROR     = 7
            X_ERROR                       = 8
            PARAMETER_EXPECTED            = 9
            TOO_MANY_PARAMETERS           = 10
            ILLEGAL_COMMAND               = 11
            WRONG_ASYNCHRONOUS_PARAMETERS = 12
            CANT_ENQ_TBTCO_ENTRY          = 13
            JOBCOUNT_GENERATION_ERROR     = 14
            OTHERS                        = 15.
        IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        else.
          write: /, 'FTP Function module executed with no errors.'.
        ENDIF.

  • How can I execute a script before connection?.

    Hi ,
    I want to execute a script before retrieving the data.How can I do this?.
    Thanks...

    When you say create a command line, what exactly are you referring to? I assume you have a logical schema mapped to the ebs instance you want to run the fnd_global function in (the same one you will have reverse engineered the models from etc), just set that as the schema on the step parameters and ODI will connect through for you as a SQL session.
    Technology set to Oracle ?
    What does the error actually say in the operator log?
    ETA : might be worth checking a few of these links as the refer to EBS with ODI : Oracle EBS and ODI
    Some of the pre-shipped KM's must do something similar to what you are trying to achieve for the apps security.

  • Some tags are not showing in SQL when executing the script as per Date

    A) When i am executing below script
    Select ToP 10000 [T_idx],[T_Tag], [T_date], [T_counter] from dbo.[total] ORDER BY T_DATE desc
    i am able to see all tags with respect to date except some tags prefix with ----PO, this 'PO' tags also present in the same table, with same time and date like other tags
    B) When executing below script
    Select top 10000 * FROM dbo.[total] where T_Tag like '%PO%' ORDER BY T_DATE DESC
    i am able to see all tags related to  PO
    How i can all tags including 'PO' with one script. can any one help me ??
    acmi

    Venkat,
    Select ToP 10000 [T_idx],[T_Tag], [T_date], [T_counter] from dbo.[total] ORDER BY T_DATE desc
    The above query MAY or MAY NOT give the records with taag ---PO as they might belong to a later data which might not fit into the top 10,000 dates of the table. This shud be the problem.
    If you want to see all the data irrespective of the number of rows, then below shud help:
    Select
    [T_idx],[T_Tag], [T_date], [T_counter]
    from dbo.[total]
    ORDER BY T_DATE desc
    If you need the rows that CONTAIN --PO then folowing shud do it:
    SELECT
    [T_idx],[T_Tag], [T_date], [T_counter]
    FROM dbo.[total]
    WHERE T_Tag like '%PO%'
    ORDER BY T_DATE desc
    If you need just the top 10,000 rows of the above result, then just add a TOP clause as below:
    SELECT
    TOP 10000
    [T_idx],[T_Tag], [T_date], [T_counter]
    FROM dbo.[total]
    WHERE T_Tag like '%PO%'
    ORDER BY T_DATE desc
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

Maybe you are looking for

  • Error while transporting objects:Internal error during pvc call: Parameter

    Dear all, We are facing the following error while transporting the individual configuration objects from our PI development system. Export failed: Internal error during pvc call: Parameter versionSpecifier or version has the invalid value null . Howe

  • A newbie in need of help and advice

    I was wondering if someone could help and advise me... I got my macbook at the beginning of the year.. I love it, so far. BUT as its my first mac, I know nothing about them or how to proceed. I understand there is a thing called 'bootcamp', where I c

  • XMP folder location on MAC

    I am trying to add Custom Panel within Adobe Bridge CC on Mac OS 10.9.2.  does any one know the location of the XMP folder. 

  • Outbound JMS adapter with fx example

    When I wire outbound jms adapter as a listener for the spreaderOut <wlevs:stream id="spreaderOut" manageable="true"> <wlevs:listener ref="outboundJmsAdapter" /> </wlevs:stream> I get a error in instantiation of the outbound jms adapter using the fact

  • How to get iPhoto back in order after recall? Is rebuilding your photo-library dangerous?

    I recently had my iMac recalled, and when I got it back, about a quarter of my 62,000 photos only show the thumbnail vies. When I try to enter them to edit them, I get a black exclamtion point within a white circle and no access. I called support and