How to add catch block in the for each and when the error is encountered i want to move to the next record

i have tried this
DO ON ERROR UNDO , THROW:

FOR EACH ttFileData NO-LOCK:

CREATE ttCustomerDetails.
ASSIGN
ttCustomerDetails.ttcustmId = INTEGER (ENTRY(2 , ttFileData.ttLine))
ttCustomerDetails.ttfirstName = ENTRY(3 , ttFileData.ttLine)
ttCustomerDetails.ttgender = ENTRY(6 , ttFileData.ttLine)
ttCustomerDetails.ttsalary = DECIMAL (ENTRY( 13 , ttFileData.ttLine))
ttCustomerDetails.ttcountry = ENTRY(5 , ttFileData.ttLine)
ttCustomerDetails.ttage = INTEGER ( ENTRY (7 , ttFileData.ttLine))
ttCustomerDetails.ttTenure = INTEGER (ENTRY (8 , ttFileData.ttLine))
ttCustomerDetails.ttDOB = obj1custmomerDetail:calculateDOB(INPUT ttCustomerDetails.ttcustmId ,
INPUT TABLE ttCustomerDetails)
ttCustomerDetails.ttemail = obj1custmomerDetail:createEMAIL(INPUT ttCustomerDetails.ttcustmId ,
INPUT TABLE ttCustomerDetails).

CATCH e AS Progress.Lang.Error:

MESSAGE "error:" e:GetMessage(1)
VIEW-AS ALERT-BOX.
FIND NEXT ttFileData.
END CATCH.
END.
But I'm getting this error
FIND cannot be processed for a FOR EACH mode record.
I'm a fresher so if it is small problem also i feel difficult so someone help me
 

Stefan

Well-Known Member
1. please put code inside [ code ] tags to make it legible
2. when you have a problem and would like others to help you with it, it helps if you reduce the problem to the smallest version of the problem. Showing how you assign NINE fields with all sorts of crap does not help.

What you need is an undo, next:

Code:
define temp-table tt no-undo
    field ii as int
    .
create tt. tt.ii = 1.
create tt. tt.ii = 2.

_foreach:
for each tt:

    message tt.ii.
      if tt.ii = 1 then tt.ii = int( 'one' ). // force an error

    catch e as Progress.Lang.Error:
        message 'caught:' e:GetMessage(1).
        undo, next _foreach.
    end catch.

end.

 
Top