?
Solved

powerscript question

Posted on 2006-05-03
6
Medium Priority
?
1,120 Views
Last Modified: 2013-12-26
Below is my code. I am getting three C0031: syntax errors on lines 86,86 and 88. I am unable to figure out why. Please help.



integer      row_count, li_downtime, i, ll_cnt
date            ldt_begin_date, ldt_end_date, temp_date
string      machine_num, setting

st_date_machine      st_date_machine

open( w_calendar_range_response_mach )

st_date_machine = message.powerobjectparm

If IsValid(Message.PowerObjectParm) and Not IsNull(Message.PowerObjectParm) Then
     If ClassName(Message.PowerObjectParm) = 'st_date_machine' Then
          st_date_machine = message.powerobjectparm
     Else
          MessageBox("Error","Returned object is not valid")
          Return -1
     End If
Else
     MessageBox("Error","Nothing Returned")
     Return -1
End If

ldt_begin_date = st_date_machine.st_begin_date
ldt_end_date = st_date_machine.st_end_date
machine_num = st_date_machine.st_machine_id
if machine_num <> '-1' then
      if ldt_begin_date > 1949-01-01 and ldt_end_date > 1949-01-01 then
      temp_date = ldt_begin_date
      do while temp_date <= ldt_end_date
      select sum(downtime_minutes)  
    into :li_downtime  
    from machine_downtime  
   where ( machine_id = :machine_num ) and  
         ( capture_date = :temp_date );
                  
                  if li_downtime > 1 then
                        row_count++
                  end if

            temp_date =relativedate(temp_date,1)      
      loop      
      tab_1.tabpage_1.dw_1.settransobject( sqlca )
      tab_1.tabpage_1.dw_1.retrieve( ldt_begin_date, ldt_end_date, machine_num, row_count )
      tab_1.tabpage_2.dw_2.settransobject( sqlca )
      tab_1.tabpage_2.dw_2.retrieve( ldt_begin_date, ldt_end_date, machine_num, row_count )
      
      
else
      
end if
end if

Datastore ds_all
ds_all = Create Datastore
ds_all.DataObject = 'dw_all_machine'  //the SQL for this DW is 'Select distinct machine_id from machine_downtime'
ds_all.SetTransObject(SQLCA)

if machine_num = '%' then
      ll_Cnt  = ds_all.Retrieve()
For i = 1 to ll_Cnt
machine_num = ds_all.Object.machine_id[i]
if ldt_begin_date > 1949-01-01 and ldt_end_date > 1949-01-01 then
     temp_date = ldt_begin_date
     do while temp_date <= ldt_end_date
     select sum(downtime_minutes)  
    into :li_downtime  
    from machine_downtime  
   where ( machine_id = :machine_num ) and  
         ( capture_date = :temp_date );
               
               if li_downtime > 10 then
                    row_count++
               end if

          temp_date =relativedate(temp_date,1)    
     loop
      tab_1.tabpage_1.dw_1.settransobject( sqlca )
      tab_1.tabpage_1.dw_1.retrieve( ldt_begin_date, ldt_end_date, machine_num, row_count )
      tab_1.tabpage_2.dw_2.settransobject( sqlca )
      tab_1.tabpage_2.dw_2.retrieve( ldt_begin_date, ldt_end_date, machine_num, row_count )
      
      
else
      
end if
end if
0
Comment
Question by:sushmasriram
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
diasroshan earned 1000 total points
ID: 16596463
Hi,


 u missed to Close ur For Loop... the keyword Next is missing...
please find below the changed code...


integer     row_count, li_downtime, i, ll_cnt
date          ldt_begin_date, ldt_end_date, temp_date
string     machine_num, setting

st_date_machine     st_date_machine

open( w_calendar_range_response_mach )

st_date_machine = message.powerobjectparm

If IsValid(Message.PowerObjectParm) and Not IsNull(Message.PowerObjectParm) Then
     If ClassName(Message.PowerObjectParm) = 'st_date_machine' Then
          st_date_machine = message.powerobjectparm
     Else
          MessageBox("Error","Returned object is not valid")
          Return -1
     End If
Else
     MessageBox("Error","Nothing Returned")
     Return -1
End If

ldt_begin_date = st_date_machine.st_begin_date
ldt_end_date = st_date_machine.st_end_date
machine_num = st_date_machine.st_machine_id
if machine_num <> '-1' then
     if ldt_begin_date > 1949-01-01 and ldt_end_date > 1949-01-01 then
     temp_date = ldt_begin_date
     do while temp_date <= ldt_end_date
     select sum(downtime_minutes)  
    into :li_downtime  
    from machine_downtime  
   where ( machine_id = :machine_num ) and  
         ( capture_date = :temp_date );
               
               if li_downtime > 1 then
                    row_count++
               end if

          temp_date =relativedate(temp_date,1)    
     loop    
     tab_1.tabpage_1.dw_1.settransobject( sqlca )
     tab_1.tabpage_1.dw_1.retrieve( ldt_begin_date, ldt_end_date, machine_num, row_count )
     tab_1.tabpage_2.dw_2.settransobject( sqlca )
     tab_1.tabpage_2.dw_2.retrieve( ldt_begin_date, ldt_end_date, machine_num, row_count )
     
     
else
     
end if
end if

Datastore ds_all
ds_all = Create Datastore
ds_all.DataObject = 'dw_all_machine'  //the SQL for this DW is 'Select distinct machine_id from machine_downtime'
ds_all.SetTransObject(SQLCA)

if machine_num = '%' then
     ll_Cnt  = ds_all.Retrieve()
For i = 1 to ll_Cnt
machine_num = ds_all.Object.machine_id[i]
if ldt_begin_date > 1949-01-01 and ldt_end_date > 1949-01-01 then
     temp_date = ldt_begin_date
     do while temp_date <= ldt_end_date
     select sum(downtime_minutes)  
    into :li_downtime  
    from machine_downtime  
   where ( machine_id = :machine_num ) and  
         ( capture_date = :temp_date );
               
               if li_downtime > 10 then
                    row_count++
               end if

          temp_date =relativedate(temp_date,1)    
     loop          
end if
//the below four lines have been changed and NEXT added - Rosh
Next
     tab_1.tabpage_1.dw_1.settransobject( sqlca )
     tab_1.tabpage_1.dw_1.retrieve( ldt_begin_date, ldt_end_date, machine_num, row_count )
     tab_1.tabpage_2.dw_2.settransobject( sqlca )
     tab_1.tabpage_2.dw_2.retrieve( ldt_begin_date, ldt_end_date, machine_num, row_count )

end if


Hope u dont get an error now...

Cheers,
Rosh
0
 

Author Comment

by:sushmasriram
ID: 16613933
I am not getting any errors now. But when I choose all option, the row_count value is not getting retrieved. I m getting 0 as the value. row count is to calculate the number of production days. To calculate this, we used the logic that if the downtime registered is more than 10 minutes, count the day as a production day. we use this row count value in our report to calculate the scheduled production hours. Now with the logic above, it is retrieving good values for individual machines but for ALL, it is giving a 0 value. Please help.
0
 
LVL 18

Expert Comment

by:diasroshan
ID: 16621483
Hi,

the code looks alrite to me...
do me a favour... can u debug thru the code and check if the code is entering the For loop and then the Do While Loop...

Also tell the value of  ll_Cnt  = ds_all.Retrieve()


Cheers,
Rosh
0
 
LVL 14

Assisted Solution

by:sandeep_patel
sandeep_patel earned 1000 total points
ID: 16630546
Hi,

I think problem is at ll_cnt = ds_all.Retrieve()

it is retrieving more rows and you have declared ll_cnt as integer

change declaration of  ll_cnt as long or double.

Regards,
Sandeep
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question