Use ACCPAC.Advantage Browse Order's Detail Record?

SOLVED

Could someone please post a sample C# code for iterating the detail records ("OE0500") for a specific order?

Stephen Smith has instructions to "Set detail key into the detail view." - but not sure how to interpret this.

After composing my views, I tried this code:

oeHeader.Cancel();
oeHeader.Init();
oeHeader.Fields.FieldByName("ORDNUMBER").SetValue("ORD00000039", false);
oeHeader.Order = 1;
oeHeader.Read(false);


bool headerExists = oeHeader.Exists;  //Header Record Found


oeDetail.Fields.FieldByName("LINENUM").SetValue("1", false);  //LINENUM appears to be the primary key
oeDetail.Read(false); 

bool DetailExists = oeHeader.Exists;  //Detail Record Not Found??

  • 0

    Record a macro of the process and review it as your code above is missing the creation of the oeDetail record.  Likely a .RecordGenerate call.

    Also, always set your .Order back to 0 after reading for a record. Saving records in composed views doesn't work nicely when your order is set to something other than 0 and you often don't see explicit errors - you just are missing records.

  • 0 in reply to Django

    I'm not creating a new order. I'm trying to read an existing order header (which is working) and it's detail records (which is not working). 

    The VBA code that is generated looks like this:

    OEORD1headerFields("ORDNUMBER").Value = "ORD00000039" ' Order Number

    OEORD1header.Order = 1
    temp = OEORD1header.Exists
    OEORD1header.Read
    OEORD1header.Order = 0
    OEORD1detail1Fields("LINENUM").PutWithoutVerification ("-32767") ' Line Number
    OEORD1detail1.Browse "", 1

    OEORD1detail1Fields("LINENUM").PutWithoutVerification ("-32767") ' Line Number

    OEORD1detail1.Browse "", 1
    OEORD1detail1.Fetch

    But this is no translation of the 'PutWithoutVerification' in the Advantage API.  I have tried using this same -32767 value like this as well.

    oeDetail.Fields.FieldByName("LINENUM").SetValue("-32767", false);

  • +1 in reply to Pauli
    verified answer

    Usually you'll .browse/.fetch through detail lines.  But, if you want to .Read, make sure that you're passing a value that exists.  OEORDD saves the LINENUM values in increments of 32 (which can change on subsequent saves if you insert new detail lines in the middle).

  • 0 in reply to Django

    Thank you.  This really helps!!

  • +1 in reply to Pauli
    verified answer

    Hi Pauli, if the above suggested answer helped, please do mark it as verified for the benefit of others in this forum. Thank you!