• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1140
  • Last Modified:

powerscript question

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
sushmasriram
Asked:
sushmasriram
  • 2
2 Solutions
 
diasroshanCommented:
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
 
sushmasriramAuthor Commented:
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
 
diasroshanCommented:
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
 
sandeep_patelCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now