erpjdedwards

Can you use the JD Edwards Update command to change a field that is also part of the WHERE clause?


In JD Edward's One World (E1) package, is it possible to use the built in Update table function to update a particular field that is also used in the where clause?

The use case is that I am executing a batch process that loops through a series of "unprocessed" records and after processing them, updates the table to show a "processed" status. There are three statuses (Processed, Unprocessed, and Ignored). During my update, I can't simply update all flags to "Processed" without accidentally updating the ones labeled "Ignored".

 If PO cProcessedFlag is equal to "U"
    Table1.Select
    Table1.Fetch Next
    While SV File_IO_Status is equal to CO SUCCESS
    ...
    Table1.Fetch Next
    End While
 End If
 Table1.Update 

I need to be able to update the processed field here (Table1.Update) while also being able to specify where the field is not "I".


Solution

  • You can select and update records at the same time. No problem doing this (Assuming that DOCO is the primary key of Table1):

    Table1.Select
        PO cProcessedFlag = BC cProcessedFlag
    Table1.Fetch Next
        VA mnOrderNumber[DOCO] <- BC mnOrderNumber[DOCO]
    
    While SV File_IO_Status is equal to CO SUCCESS
        ...
        Table1.Update
            VA mnOrderNumber[DOCO] = VA mnOrderNumber[DOCO]
            ā€œPā€ -> BC cProcessedFlag
    
        Table1.Fetch Next
            VA mnOrderNumber[DOCO] <- BC mnOrderNumber[DOCO]
    End While
    

    When you write code in ER, the middleware will actually perform an open, select, close etc. for each tableIO. So the handle for the second Table1.FetchNext is very different to the open, select, update, close generated for the Table1.Update