Trouble looping thru SR to mark as completed with powershell
Not sure this is actually a SCSM question, but I only seem to have trouble doing this in SCSM PowerShell.
PS D:\ps1\Management Scripts> gc D:\ps1\SRs2Close_6.23.2014.txt
SR6172
SR6411
SR6159
SR6284
SR6280
SR6298
SR6226
SR6262
SR6307
SR6223
SR6264
SR6285
SR6334
SR6255
SR6251
SR6247
SR6238
SR6234
SR6231
SR6200
SR6165
$SRs = gc D:\ps1\SRs2Close_6.23.2014.txt
Errors:
ERRORS:
PS D:\ps1\Management Scripts> $SRs | foreach-object {"D:\PS1\Management Scripts\Set-SRStatus.ps1" $_ "Completed"}
Unexpected token '_' in expression or statement.
At line:1 char:71
+ $SRs | foreach-object {"D:\PS1\Management Scripts\Set-SRStatus.ps1" $_ <<<< "Completed"}
+ CategoryInfo : ParserError: (_:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
PS D:\ps1\Management Scripts> $SRs | foreach-object {"D:\PS1\Management Scripts\Set-SRStatus.ps1" $_.name.tostring() "Completed"}
Unexpected token '_' in expression or statement.
At line:1 char:71
+ $SRs | foreach-object {"D:\PS1\Management Scripts\Set-SRStatus.ps1" $_ <<<< .name.tostring() "Completed"}
+ CategoryInfo : ParserError: (_:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
PS D:\ps1\Management Scripts> foreach ($SR in $SRs) {"D:\PS1\Management Scripts\Set-SRStatus.ps1" $SR.tostring() "Completed"}
Unexpected token 'SR' in expression or statement.
At line:1 char:72
+ foreach ($SR in $SRs) {"D:\PS1\Management Scripts\Set-SRStatus.ps1" $SR <<<< .tostring() "Completed"}
+ CategoryInfo : ParserError: (SR:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
Script:
param([string]$SRID,[string]$Status)
$a = (get-module|%{$_.name}) -join " "
if(!$a.Contains("SMLets")){Import-Module 'smlets' -ErrorVariable err -Force}
$SRobj = Get-SCSMObject -Class (Get-SCSMClass -name System.WorkItem.ServiceRequest$) -Filter "ID -eq $SRID"
Set-SCSMObject -SMObject $SRobj -Property Status -Value $Status
PS D:\ps1\Management Scripts> Get-SCSMObject -Class $SRClass -Filter "ID -eq SR6172" | select status
Status
In Progress
PS D:\ps1\Management Scripts> $SRobj = Get-SCSMObject -Class $SRClass -Filter "ID -eq SR6172"
PS D:\ps1\Management Scripts> Set-SCSMObject -SMObject $SRobj -Property status -Value Completed
PS D:\ps1\Management Scripts> Get-SCSMObject -Class $SRClass -Filter "ID -eq SR6172" | select status
Status
Completed
PS D:\ps1\Management Scripts> $SRs = gc D:\ps1\SRs2Close_6.23.2014.txt
PS D:\ps1\Management Scripts> $SRs | ForEach-Object {& 'D:\ps1\Management Scripts\Set-SRStatus.ps1' "$_" "Completed"}
Get-SCSMObject : Id='SR6411' -- Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
At D:\ps1\Management Scripts\Set-SRStatus.ps1:6 char:24
+ $SRobj = Get-SCSMObject <<<< -Class (Get-SCSMClass -name System.WorkItem.ServiceRequest$) -Filter "ID -eq $SRID"
+ CategoryInfo : NotSpecified: (:) [Get-SCSMObject], UnknownDatabaseException
+ FullyQualifiedErrorId : Microsoft.EnterpriseManagement.Common.UnknownDatabaseException,SMLets.GetSMObjectCommand
Get-SCSMObject : Id='SR6159' -- Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
At D:\ps1\Management Scripts\Set-SRStatus.ps1:6 char:24
+ $SRobj = Get-SCSMObject <<<< -Class (Get-SCSMClass -name System.WorkItem.ServiceRequest$) -Filter "ID -eq $SRID"
+ CategoryInfo : NotSpecified: (:) [Get-SCSMObject], UnknownDatabaseException
+ FullyQualifiedErrorId : Microsoft.EnterpriseManagement.Common.UnknownDatabaseException,SMLets.GetSMObjectCommand
Get-SCSMObject : Id='SR6284' -- Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
At D:\ps1\Management Scripts\Set-SRStatus.ps1:6 char:24
+ $SRobj = Get-SCSMObject <<<< -Class (Get-SCSMClass -name System.WorkItem.ServiceRequest$) -Filter "ID -eq $SRID"
+ CategoryInfo : NotSpecified: (:) [Get-SCSMObject], UnknownDatabaseException
+ FullyQualifiedErrorId : Microsoft.EnterpriseManagement.Common.UnknownDatabaseException,SMLets.GetSMObjectCommand
Get-SCSMObject : Id='SR6280' -- Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
At D:\ps1\Management Scripts\Set-SRStatus.ps1:6 char:24
+ $SRobj = Get-SCSMObject <<<< -Class (Get-SCSMClass -name System.WorkItem.ServiceRequest$) -Filter "ID -eq $SRID"
+ CategoryInfo : NotSpecified: (:) [Get-SCSMObject], UnknownDatabaseException
+ FullyQualifiedErrorId : Microsoft.EnterpriseManagement.Common.UnknownDatabaseException,SMLets.GetSMObjectCommand
Get-SCSMObject : Id='SR6298' -- Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
At D:\ps1\Management Scripts\Set-SRStatus.ps1:6 char:24
+ $SRobj = Get-SCSMObject <<<< -Class (Get-SCSMClass -name System.WorkItem.ServiceRequest$) -Filter "ID -eq $SRID"
+ CategoryInfo : NotSpecified: (:) [Get-SCSMObject], UnknownDatabaseException
+ FullyQualifiedErrorId : Microsoft.EnterpriseManagement.Common.UnknownDatabaseException,SMLets.GetSMObjectCommand
PS D:\ps1\Management Scripts>
I got this to work previously, I just can't remember how...?
Joshua Fuente
That's whats driving me "batty".
It works from the console.
PS D:\ps1\Management Scripts> Get-SCSMObject -Class $SRClass -Filter "ID -eq SR6172" | select status
Status
Completed
I tried changing the script to a function, but didn't have any luck.
I will try with the name param and see if that helps.
Like I said, I have done this before, it just seems like it different every time.
So I changed the script to this,
param([string]$SRID,[string]$Status)
$a = (get-module|%{$_.name}) -join " "
if(!$a.Contains("SMLets")){Import-Module 'smlets' -ErrorVariable err -Force}
Get-SCSMObject -Class (Get-SCSMClass -name System.WorkItem.ServiceRequest$) -Filter "Id -eq $SRID" | Select ID, Name, Status
And it works fine
PS D:\ps1\Management Scripts> $SRs | ForEach-Object {.\Set-SRStatus.ps1 $_}
Id Name Status
SR6172 SR6172 Completed
SR6411 SR6411 In Progress
SR6159 SR6159 In Progress
SR6284 SR6284 In Progress
SR6280 SR6280 In Progress
SR6298 SR6298 In Progress
SR6226 SR6226 In Progress
SR6262 SR6262 In Progress
SR6307 SR6307 In Progress
SR6223 SR6223 In Progress
SR6264 SR6264 In Progress
SR6285 SR6285 In Progress
SR6334 SR6334 In Progress
SR6255 SR6255 In Progress
SR6251 SR6251 In Progress
SR6247 SR6247 In Progress
PS D:\ps1\Management Scripts>
And add on the Set-SCSMobj
param([string]$SRID,[string]$Status)
$a = (get-module|%{$_.name}) -join " "
if(!$a.Contains("SMLets")){Import-Module 'smlets' -ErrorVariable err -Force}
Get-SCSMObject -Class (Get-SCSMClass -name System.WorkItem.ServiceRequest$) -Filter "Id -eq $SRID" | Set-SCSMObject -Property Status -Value $Status
And now it works...
PS D:\ps1\Management Scripts> $SRs | ForEach-Object {.\Set-SRStatus.ps1 $_ completed}
No errors, and all SRs show completed.
Similar Messages
-
DAC - Mark as completed - From Command Line?
I have a exec plan which has around 50 tasks... This exec plan starts when a source file is posted in source file folder. We have a .bat file which checks for source file, once it find the file, it starts exec plan. .bat runs in loop, so once file is loaded it will again check for source file..
Now my question is if 3rd task (out of 50) does not load any records/does not meet required conditions, I would like to skip the remaining part of exec plan, as they dont have meaning without any records loaded in 3rd task. How can I go this in command line? daccmdline helps me to stop the exec plan, but no mark it as complete..
Would like to do this, so next file can be started quick and we dont have wait for all 50 tasks to complete.
Can we mark is as complete only from UI? Or can I update status in some of DAC tables to achieve this (not sure if this is supported!!)??
Please let me know.
Thanks.
AshHi,
There is no option to mark as completed from the command line.
Create a task group for the remaining sessions and set the order of execution for those tasks and before doing this step you can create one session at informatica level which will check whether the file has been generated or not.
If the file has not been generated then you are not going to execute the remaining tasks.
Thanks & Regards,
Navin Kumar Bolla -
PL/SQL how to loop thru SQL statement?
Hey guys. I have this bit of a complicated problem.
I have a cursor that selects a DISTINCT field called Term and a StudentID.
I am looping thru that cursor.
Inside that loop I have another SQL statement that is pulling all rows from the DB where the Term = the Term and the StudentID= the StudentID from the crusor loop.
My problem is how do I get all the information/rows returned from that SQL statement? I need to loop thru it somehow, but I am not sure how to do it.
If there is a better way to get this done feel free to chime in.
Here is my code.
/* CURSOR*/
CURSOR c_GPAPerTerm IS
SELECT DISTINCT Term, Student_ID FROM course_grades
WHERE STUDENT_ID = p_StudentID;
/* OPEN AND LOOP THRU CURSOR*/
OPEN c_GPAPerTerm;
LOOP
FETCH c_GPAPerTerm INTO v_Terms,v_StudentID;
/* SQL STATEMENT NEED TO LOOP THRU AND GET VALUES FOR EACH ROW*/
SELECT Score
INTO v_Scores
FROM course_grades
WHERE Term = v_Terms and StudentID = v_StudentID;
EXIT WHEN c_GPAPerTerm%NOTFOUND;
END LOOP;
CLOSE c_GPAPerTerm;Ok here's my complete code....it's pretty big though...hope it's not too confusing.
It compiles fine if I take the new cursor out, so the error is somewhere in that cursor.
CREATE OR REPLACE PROCEDURE get_Student_GPA(p_StudentID IN NUMBER) AS
/*VARIABLES*/
v_Terms VARCHAR2(6);
v_Courses VARCHAR2(6);
v_Scores NUMBER;
v_Grade CHAR;
v_GPA NUMBER;
v_ScoresTotal NUMBER :=0;
v_StudentID NUMBER;
/*CURSORS*/
CURSOR c_GetTerms IS
SELECT Term
FROM course_grades
WHERE STUDENT_ID = p_StudentID;
CURSOR c_GetCourseAndGrade IS
SELECT Course_ID, Score FROM course_grades
WHERE STUDENT_ID = p_StudentID;
CURSOR c_GPAPerTerm IS
SELECT DISTINCT Term, Student_ID
FROM course_grades
WHERE STUDENT_ID = p_StudentID;
CURSOR c_GetScores (p_Term VARCHAR2, p_StudentID NUMBER) IS
SELECT Score
FROM course_grades
WHERE Term = p_Term AND StudentID = p_StudentID;
/*FUNCTIONS*/
FUNCTION convert_grade(p_GradeNumber IN NUMBER)
RETURN CHAR IS
BEGIN
/* GET NUMERIC GRADE AND CONVERT TO LETTER */
CASE
WHEN p_GradeNumber < 60 THEN RETURN 'F';
WHEN (p_GradeNumber > 59 AND p_GradeNumber < 70) THEN RETURN 'D';
WHEN (p_GradeNumber > 69 AND p_GradeNumber < 80) THEN RETURN 'C';
WHEN (p_GradeNumber > 79 AND p_GradeNumber < 90) THEN RETURN 'B';
WHEN (p_GradeNumber > 89 AND p_GradeNumber < 101) THEN RETURN 'A';
ELSE RETURN 'Z';
END CASE;
END convert_grade;
FUNCTION calculate_gpa(p_TotalHourPoints IN NUMBER, p_TotalHours IN NUMBER)
RETURN NUMBER IS
/*CREATE VARIABLE TO HOLD GPA*/
v_GPA NUMBER;
BEGIN
/*CALCULATE AND OUTPUT GPA*/
v_GPA := p_TotalHourPoints/p_TotalHours;
RETURN v_GPA;
END calculate_gpa;
FUNCTION calculate_point (p_Grade IN CHAR)
RETURN NUMBER IS
BEGIN
/* GET LETTER GRADE AND CONVERT TO NUMBER */
CASE
WHEN p_Grade = 'A' THEN RETURN 4;
WHEN p_Grade = 'B' THEN RETURN 3;
WHEN p_Grade = 'C' THEN RETURN 2;
WHEN p_Grade = 'D' THEN RETURN 1;
WHEN p_Grade = 'F' THEN RETURN 0;
ELSE RETURN 0;
END CASE;
END calculate_point ;
/****BEGIN MAIN BLOCK********/
BEGIN
DBMS_OUTPUT.PUT_LINE('**********TERMS**********');
OPEN c_GetTerms;
LOOP
FETCH c_GetTerms INTO v_Terms;
DBMS_OUTPUT.PUT_LINE('Term: ' || v_Terms);
EXIT WHEN c_GetTerms%NOTFOUND;
END LOOP;
CLOSE c_GetTerms;
DBMS_OUTPUT.PUT_LINE('**********COURSES AND GRADES**********');
OPEN c_GetCourseAndGrade;
LOOP
FETCH c_GetCourseAndGrade INTO v_Courses, v_Scores;
v_Grade := convert_grade(v_Scores);
DBMS_OUTPUT.PUT_LINE('Course: ' || v_Courses || ' Grade: ' || v_Grade);
EXIT WHEN c_GetCourseAndGrade%NOTFOUND;
END LOOP;
CLOSE c_GetCourseAndGrade;
DBMS_OUTPUT.PUT_LINE('**********GPA PER TERM**********');
OPEN c_GPAPerTerm;
LOOP
FETCH c_GPAPerTerm INTO v_Terms,v_StudentID;
/*NEW CURSOR LOOP WILL GO HERE*/
v_ScoresTotal := v_ScoresTotal + v_Scores;
v_GPA := calculate_gpa(v_ScoresTotal, 3);
v_ScoresTotal :=0;
DBMS_OUTPUT.PUT_LINE('Term: ' || v_Terms || ' GPA: ' || v_GPA);
EXIT WHEN c_GPAPerTerm%NOTFOUND;
END LOOP;
CLOSE c_GPAPerTerm;
END get_Student_GPA;
/ -
TS3367 face time has the camera icon with a line thru it and will not complete a call?
on my iphone, when trying a face time call, the camera has a line thru it and will not complete the call. it just rings tothe person, but there phone does not ring.
I have the same problem. I can't figure it out. I have followed their
trouble-shooting guide with no luck/\. -
everytime i try to it keeps looping thru to verify my account, so i do and then try to download and it loops me right back thru again to verify my account. HELP ME PLEASE
Contact iTunes. Select the appropriate topic of:
Apple - Support - iTunes -
Having trouble register my account to paypal to complete setup of webforms. Please help?
Is it this: http://www.adobe.com/products/acrobat/create-pdf-web-forms-builder.html ? Which means Acrobat.
Contact Customer Care - click on the Still need help? button to chat with an agent. -
Looping thru column names based on a variable value
I have an ArrayCollection with a series of columns named
price1, price2... thru to price10
I'm trying to loop thru these columns based on a variable
value, but can't figure the syntax:
for (var column:int = 1; column < 11; column++){
testPrice = myGrid.selectedItem.price(column); <-- this
doesn't work
}Try testPrice = myGrid.selectedItem["price" + column];
Remember to test that selectedItem isn't null before you try
to assign the values.
TS -
I have a number of courses that have branching slides in them. Because of the branching the user may not go to all of the slides. When the user completes the course, the course says that it is in progress and the user gets the blue in progress icon on their "My Training" page. When the course is playing you can see that the Table of Contents also does not show the module as complete as well. I am wondering what can be done to resolve this issue.
Your issue is likely to be that since users do not visit all slides then the slide completion falls below a percentage that is required.
If you're not worried about exporting to HTML5, then the TickTOC widget might provide the answer.
http://www.infosemantics.com.au/adobe-captivate-widgets/ticktoc
You specify slides in the widget that will be marked as complete even if they were never visited. This means those slides will be marked off as visited in the TOC and will also be credited to the user at the end of the project. In your case I would suggest you place the TickTOC widget on the second last slide of the project (not the last slide) and set it to mark off all previous slides in the project.
Trial versions of all widgets available here:
http://www.infosemantics.com.au/adobe-captivate-widgets/download-free-trial-widgets -
Workflow to close Parent Task if all Children Tasks are Marked as Complete
Hi All,
I am struggling in creating a workflow which would mark my parent task as complete once all children tasks(I have subgrid in parent task where I add children tasks) have been marked as complete. I would assume it would be on a wait condition but
I could have many children tasks and I guess I am little unsure how to create this wait condition to check whether all children tasks are complete and then complete parent task...
Any help would be much appreciated!
Thanks so much!You can't do this out of the box. There's no easy way to check all child records on a parent record and then close the parent record. You'll either have to find another approach, or do some custom development to create a workflow that can do
what you want.
I'd start looking here: https://msdn.microsoft.com/en-us/library/gg309745.aspx?f=255&MSPPError=-2147217396
The postings on this site are solely my own and do not represent or constitute Hitachi Solutions' positions, views, strategies or opinions. -
Video Not Marking as Complete Until Exit Button is Clicked?
I recieved the following feedback from one of our clients. They are using an AICC based LMS.
"We noticed that in order for the video to mark as completed, we need to have all of the chapters checked off, quiz must be taken, and the user has to press the small Exit button."
Do users actually have to press the exit button before a video will send "completed" to an LMS? Is there a work around?
Thanks!What Captivate version are you using?
This is happening based upon the Quiz Preferences - Reporting Settings that you have configured.
Yes, you can customize the settings to mark completeing on basis of user access, slide view, Quiz attempts and many more criteria.
Please choose and customize based upon your requirement--
Instead of making the user hit the close button, you can yourself set Captivate to Close the course once it reaches the end.
You can do that fron Start and End Settings under Preferences.
I hope this helps.
Thanks,
Anjaneai -
Looping thru tif images using OCR
I have this code below in powershell where I OCR a tif image and save it to a table in sql server. OCR is only working on the first page and not looping thru the tif image pages.
Can someone help me with the code to make it loop on my tif image pages ?
#Functions
#OCR Function
#param - imagepath(path the image to ocr)
Function OCR($imagepath) {
#create a new modi object
$modidoc = new-object -comobject modi.document
$modidoc.create($imagepath)
try{
#call the ocr method
$modidoc.ocr()
#single page document so I only need the item(0).layout text
$modidoc.images.item(0).layout.text
catch{
#catch the error and go on
return "Error"
Finally
#clean up the object
$modidoc = ""
} # end OCR function
#Function to update the fulltext field in imageskeyvalues table
#param ID(ID of table)
function SaveImagesKeyValues($ID, $fulltext)
$cmd = new-object system.data.sqlclient.sqlcommand
$cmd.connection = $sqlconnection
$s = "update dbo.Images_Local set fulltext = '" + ($fulltext.tostring()).replace('''','') + "' where ID = " + $ID.tostring()
$cmd.commandtext = $s
$a = $cmd.executenonquery()
} #end SaveImagesKeyValues
#Function to get the list of records to OCR
function GetImagesKeyValues()
$sqlda = new-object system.data.sqlclient.sqldataadapter
$datatable = new-object system.data.dataset
$sqlcommandselect = new-object system.data.sqlclient.sqlcommand
$sqlcommandselect.commandtext =
"select ID, FullImagePath, fulltext from images_Local
where (fulltext is null or fulltext like 'error%') order by ID "
#and (fulltext is null or fulltext like 'error%')
#"select b.batch_number, b.sequence_number,a.claimnumber, a.potentialamount,a.buyer, b.[document type],b.fulltext, c.imagelastmodified, c.image_path
#from cip.dbo.cip_mastertable a
#inner join imageskeyvalues b on a.claimnumber = substring(b.[claim number],2,6)
#inner join images c on b.batch_number = c.batch_number and b.sequence_number = c.sequence_number
#where (a.buyer = '006' or (a.buyer = '007' and a.potentialamount > 500000))
#and c.imagelastmodified >= '1/1/13'
#and b.[document type] = '2'
#order by c.imagelastmodified"
$sqlcommandselect.connection = $sqlconnection
$sqlda.selectcommand = $sqlcommandselect
#Fill the datatable and store the output in variable otherwise it shows in the output.
$trap = $sqlda.fill($datatable)
$datatable.tables[0]
#end GetImagesKeyValues
#End Functions
#Main
clear
#set the parent path to the working directory
$parentpath = "C:\Data\Portugal PRG\Images\Contratos SONAE 08-11\Imdex\"
#Create new sql connection
$sqlconnection = new-object system.data.sqlclient.sqlconnection
#Assign the connectionstring
$sqlconnection.connectionstring = "Server=ATL01L20969\SQLEXPRESS;Database=Sonae;integrated security=True"
#Open the connection
$sqlconnection.open()
#get the list of records that need ocr'd
$imageskeyvalues = getimageskeyvalues
#iterate through the list
foreach ($t in $imageskeyvalues){
#$completepath = $parentpath + $t.image_path
$completepath = $t.FullImagePath
#call the ocr function and put the results in the fulltext property
$t.fulltext = OCR $completepath
#give some bread crumbs to monitor the script
write-host "Saving " $t.ID
#update the database fulltext filed
Saveimageskeyvalues $t.ID $t.fulltext
}#end MainHi Abenitez,
Since the OCR is only working on the first page, as a workaround, please try to spilt the tiff files to multople single files:Tiff Splitter, and then you can use foreach to loop every files.
Refer to:
How to split a multipage TIFF file on Windows?
If there is anything else regarding this issue, please feel free to post back.
Best Regards,
Anna Wang -
This is my first pl/sql program, I've written psudocode on paper, but not sure what to do for two parts.
What I'm trying to do is write pl/sql that will check a row based on an employee id #.
declare
cursor cur is
select *
from employee
where employee_id = foo;What we are checking are the results the employee answered. They have answered 180 questions and I want to find when the answer a 0, 7, and 9.
Basically the pl/sql has to loop thru the 180 questions
loop
v_count := vcount + 1
select *
from employee
where q1 thru q180 in (0, 7, 9);
end loop;
dbms_output.put_line ('Employee ID' || employee_id);
dbms_output.put_line ('Q1 - Q180' || q1 - q180); I'm not sure how to write the pl/sql to loop thur all 180 questions.
I'm not sure how to display the output to show what question they scored a 0, 7, and/or a 9 on.
thanks
Message was edited by:
cmmiller536 columns in one table? Yowsa. Without a normalized table, you are going to need dynamic pl/sql and a messy solution.
I would rethink your design, and come up with something more like so:
employee
questions
employee_responses
So that would you could easily do something like this:
declare
cursor c1 is
select ers.question_id,
que.question_name,
ers.rating
from employee emp,
questions que,
employee_responses ers
where emp.employee_id = ers.employee_id and
que.question_id = ers.question_id and
emp.employee_id = v_employee_id and
ers.rating in (0, 7, 9) and
que.enabled_flag = 'Y';
begin
for r1 in c1 loop
dbms_output.put_line('Question: '||r1.question_name);
dbms_output.put_line('Employee Rated this: '||r1.rating);
end loop;
end;Thats how I would do it - I think you are going down the wrong path. What happens if you need to create a new question or delete one? You constantly have to modify the table. Hope this helps -
How to Loop thru a Queue?
I have a Queue that I can add and remove items from, but I need to display all the contents currently in the Queue.
How would I loop thru the Queue and do this?
Any simple example will do.
Thanks!Thanks for the link. It showed me which methods an Iterator has, but not practical way to use it. So I did some googling and found this example.
import java.util.Iterator;
import java.util.NoSuchElementException;
for ( Iterator iter = myList.iterator(); iter.hasNext(); )
String key = (String) iter.next();
System.out.println( key );
}Which makes perfect sense. However, where it says Iterator iter = myList.iterator(); I am not sure what to put in the myList.iterator(); part.
I would assume that my Queue object would be used there, however, my Queue object has no .iterator() method.
Like I said, I am new to Java so this is not as easy to me as it seems it should be.
But there is all of my code if it helps.....I'll leave out the unimportant parts.
Queenode class........................................
public class QueueNode {
//fields
Object info;
QueueNode link;
public QueueNode() {
public QueueNode(Object item) {
info=item;
link=null;
public QueueNode(Object item, QueueNode qn) {
info=item;
link=qn;
}//end classQueue class..............................................
public class Queue {
//create a front and back node
private QueueNode front;
private QueueNode rear;
private int size;
//methods
public void insert(Object item){
//if queue is empty front and rear are same
if(isEmpty()){
rear=new QueueNode(item);
front = rear;
}//end if
//otherwise queue not empty add top end
else{
rear.link= new QueueNode(item);
rear=rear.link;
}//end else
///either case incriment size
size++;
}//end insert
public Object remove(){
//create a temp node referencing the front
QueueNode oldFront=front;
//peek at front item
Object item = peek();
//make front to link with the next node
front=front.link;
//remove temp node
oldFront=null;
//decrement size
size--;
//return the item that was removed
return item;
}//remove
public Object peek(){
if(isEmpty()){
throw new NullPointerException();
}//end if
else{
return front.info;
}//and else
}//end peek
public boolean isEmpty(){
return(size==0);
}//end isEmpty
public int getSize(){
return size;
}//end getsize
}//end classAnd finaly my class to test that the Queue is working....................
import javax.swing.*;
import javax.swing.border.BevelBorder;
import java.awt.*;
import java.awt.event.*;
import java.util.Iterator;
import java.util.NoSuchElementException;
public class QueueTest extends JFrame implements ActionListener{
//Create Queue object
Queue q = new Queue();
public QueueTest(){
//Add title to window
super("Testing Queue's");
}//end constructor
public void actionPerformed(ActionEvent event){
if (event.getSource()==btnAddQueueItem){
q.insert(txtAddQueueItem.getText());
for(Iterator iter = q.?????; iter.hasNext();){
///Output each queue item here........
}//end for
}//end if
if (event.getSource()==btnRemoveQueueItem){
q.remove();
}//end if
}//end actionPerformed
public static void main(String[] args) {
QueueTest testQueue = new QueueTest();
}//end main
}//end class -
how to Loop thru the RFC model
for(int i=0;i<wdContext.nodeEx_Org_Units().size();i++){
//how to get the attribute each and every columns
//mgr.reportSuccess("id" +nodeEx_Org_Units().getId());
Message was edited by:
yzme yzmeHi,
When there is a RFC Model with table ouptut....every row in the table can be correlated to elements in the model node...
your model node : <i>nodeEx_Org_Units</i>
Now if you have 5 rows as output after executing the model...there will be 5 elements created under the node. Loop through all the elements and use the get methods as given below:
// assuming tht u have two columns(attributes) <i>col1 & col2</i>
// access the node
IPrivate<view>.IEx_Org_UnitsNode tableNode = wdContext.nodeEx_Org_Units();
// access the element under the node, do not initalize this element
IPrivate<view>.IwdContext.nodeEx_Org_UnitsElement tableElem;
//loop thrugh the elements
for(int i=0; i<tableNode.size(); i++)
tableElem = tableNode.getEx_Org_UnitsElementAt(i);
// access the attributes col1 & col2
tableElem.getCol1();
tableElem.getCol2();
Regards
Srikanth -
Help!
We are having problems with our Development and QA environments. One of the ETL workflows failed, so the whole execution plan failed. We would like to abandon that execution plan and just run a full load to start with a clean DB. However we can't get the first execution plan to complete. We've tried restarting it, requeueing everything, and the obvious 'Mark as Complete'. But nothing is working. The 'Mark as Complete' does nothing... no popup, no error message, nada.
I know there is SQL floating around to reset the table, but I was hoping someone could tell me why I can't 'Mark as Complete'. Is this a security setting?
Brenda
Edited by: user10736039 on Oct 13, 2009 3:22 PMCheck the repository schema DAC (or whatever schema has been assigned to DAC to store it metadata and data) on the database and see if it has run out of tablespace. People sometimes forget to monitor these schemas (DAC and ETL metadata schemas). If DAC cannot update the tables where this information is stored it starts behaving erratically and sometimes doesn't build, assemble or nothing works.
Check that add space if required and re-bounce DAC services.
Maybe you are looking for
-
Logical path and syntax groups
WE know that we may define ligical file & logical file path. It is said that if we link a logical path to a logical file the logical file is valid for all syntax groups thgat have been maintained for that logical path? Could some one explain how
-
Sale quantity is not updated in COPA report
Dear All I am using Account based COPA. In the report COGS and the revenue is captured correctly, but the quantity is not coming. While seeing the line items I found that at the time of PGI one line item with +ve quantity is generated and at invoicin
-
Some albums are missing on my PC after latest iTunes upgrade.
This morning I was listening to music on my iPhone on my way to work. Sat down at my PC and opened iTunes, the album I wanted showed up without artwork and I could see the name of the songs, but it would not play. I then downloaded the latest iTune
-
Transfer data from R/3 to APO
Dear all, How to transfer datas from R/3 to APO and get back from APO to R/3. Pls provide valuable inputs. Regards, S.Suresh.
-
Early schedule start date, early schedule finish date
I want early schedule start date, early schedule finish date and project cost plan in my report. This is a PS requirement. In the standard cube (0PS_C02) I can find actual start date and actual finish date. Has anybody used early schedule start date