For loop across all available companies?

Mr. Dynamic picture Mr. Dynamic · Aug 9, 2012 · Viewed 8.9k times · Source

I need to create a job with a for loop (I think) that goes through all available companies and checks for a specific value. I'm just not familiar with how I would get it to select each individual company.

Does anyone know the syntax for that?

Answer

Jan B. Kjeldsen picture Jan B. Kjeldsen · Aug 10, 2012

I use the following technique in a job:

static void CountIt(Args _args)
{
    DataArea  DataArea;

    void doIt()
    {;
        info(int2str((select Count(RecId) from CustTable).RecId));
    }

    setPrefix("Counting");
    while select DataArea where !DataArea.isVirtual
    {
        print(DataArea.Id);
        setPrefix(DataArea.Id);
        changecompany (DataArea.Id)
        {
            doIt();
        }
    }
}