Convert E9 ABL Updateable BAQ Directive Code to C# for Kinetic

In the process of an upgrade from E9 to Kinetic. There is a screen that utilizes an Updateable BAQ Directive that has ABL code. I have converted several BPM’s that have ABL code to C# but this has a different look to it.
Code:

//&if defined(UD13_ds_I) = 0 &then
//    &global-define UD13_ds_I
//    {bo/UD13/UD13_ds.i}
//&endif
//{Bpm/InfoPromptAction.i}
//{bo/DynamicQuery/BAQConstants.i}
//{core/BOUpdateExt/zeroize_buf.i}
//{core/BOUpdateExt/BOUpdError_ds.i}
//
//
///* Update procedure */
//
//def var hProc as handle no-undo.
//def var errorsOccured as logical no-undo.
//run createConstants.
//run bo/UD13/UD13.p persistent set hProc.
//do on error undo, leave:
//for each ttResults where ttResults.RowMod <> '' on error undo, next:
//    dataset UD13DataSet:empty-dataset().
//
//
//    create ttUD13.
//    run ZeroizeBuf(temp-table ttUD13:default-buffer-handle).
//    ttUD13.RowIdent = '#' + ttResults.RowIdent.
//    ttUD13.Character01 = ttResults.UD13_Character01.
//    ttUD13.Character02 = ttResults.UD13_Character02.
//    ttUD13.CheckBox01 = ttResults.UD13_CheckBox01.
//    ttUD13.CheckBox02 = ttResults.UD13_CheckBox02.
//    ttUD13.CheckBox03 = ttResults.UD13_CheckBox03.
//    ttUD13.CheckBox04 = ttResults.UD13_CheckBox04.
//    ttUD13.Company = Constants.CurrentCompany.
//    ttUD13.Date01 = ttResults.UD13_Date01.
//    ttUD13.Date02 = ttResults.UD13_Date02.
//    ttUD13.Date03 = ttResults.UD13_Date03.
//    ttUD13.Date04 = ttResults.UD13_Date04.
//    ttUD13.Key1 = ttResults.UD13_Key1.
//    ttUD13.Key2 = ttResults.UD13_Key2.
//    ttUD13.Key3 = ttResults.UD13_Key3.
//    ttUD13.Key4 = ttResults.UD13_Key4.
//    ttUD13.Key5 = ttResults.UD13_Key5.
//    ttUD13.Number01 = ttResults.UD13_Number01.
//    ttUD13.Number03 = ttResults.UD13_Number03.
//    ttUD13.ShortChar01 = ttResults.UD13_ShortChar01.
//    ttUD13.ShortChar02 = ttResults.UD13_ShortChar02.
//    ttUD13.ShortChar03 = ttResults.UD13_ShortChar03.
//    ttUD13.ShortChar04 = ttResults.UD13_ShortChar04.
//
//    run UpdateExt in hProc(input-output dataset UD13DataSet, true, true, output dataset BOUpdErrorDataset, output errorsOccured).
//    if IsInfoPromptHandlerInvoked() then return.
//    ttResults.RowMod = ''.
//
//        find first ttUD13 where ttUD13.RowIdent = '#' + ttResults.RowIdent no-error.
//        if available ttUD13 then do:
//	ttResults.UD13_Character01 = ttUD13.Character01.
//	ttResults.UD13_Character02 = ttUD13.Character02.
//	ttResults.UD13_CheckBox01 = ttUD13.CheckBox01.
//	ttResults.UD13_CheckBox02 = ttUD13.CheckBox02.
//	ttResults.UD13_CheckBox03 = ttUD13.CheckBox03.
//	ttResults.UD13_CheckBox04 = ttUD13.CheckBox04.
//	ttResults.UD13_Date01 = ttUD13.Date01.
//	ttResults.UD13_Date02 = ttUD13.Date02.
//	ttResults.UD13_Date03 = ttUD13.Date03.
//	ttResults.UD13_Date04 = ttUD13.Date04.
//	ttResults.UD13_Key1 = ttUD13.Key1.
//	ttResults.UD13_Key2 = ttUD13.Key2.
//	ttResults.UD13_Key3 = ttUD13.Key3.
//	ttResults.UD13_Key4 = ttUD13.Key4.
//	ttResults.UD13_Key5 = ttUD13.Key5.
//	ttResults.UD13_Number01 = ttUD13.Number01.
//	ttResults.UD13_Number03 = ttUD13.Number03.
//	ttResults.UD13_ShortChar01 = ttUD13.ShortChar01.
//	ttResults.UD13_ShortChar02 = ttUD13.ShortChar02.
//	ttResults.UD13_ShortChar03 = ttUD13.ShortChar03.
//	ttResults.UD13_ShortChar04 = ttUD13.ShortChar04.
//    end.
//
//    if errorsOccured then temp-table ttErrors:copy-temp-table(temp-table ttBOUpdError:handle, true, ?, true).
//end.
//finally:
//    delete object hProc.
//    for each ttErrors where ttErrors.ErrorRowIdent begins '#':
//        ttErrors.ErrorRowIdent = substring(ttErrors.ErrorRowIdent, 2).
//    end.
//end finally.
//end.

All this code does is create a temporary dataset (tableset) filled with values from your ttResults of your BAQ, then runs an UpdateExt call against them. After running the update, it checks if errors were output, then processes those rows into another error temp table to be copied to the BOUpdError letting the UI know these rows didn’t make it.

In Kinetic, you would likely use the UD13 tableset and the UD13Svc.

I’m not a uBAQ expert and it’s been a looong time since I played with ABL code, but this should get you started:

bool errorsOccurred = false;

CallService<UD13SvcContract>( svc => {

    var ttUD13 = new UD13Tableset();

    foreach ( var res in ttResults.Where(x => !x.Unchanged()) )
    {
        var updRow = new UD13Row();

        //ud13row.RowIdent = "#" + res.RowIdent;
        ud13row.Character01 = res.UD13_Character01;
        ud13row.Character02 = res.UD13_Character02;
        ud13row.CheckBox01 = res.UD13_CheckBox01;
        ud13row.CheckBox02 = res.UD13_CheckBox02;
        ud13row.CheckBox03 = res.UD13_CheckBox03;
        ud13row.CheckBox04 = res.UD13_CheckBox04;
        ud13row.Company = Constants.CurrentCompany;
        ud13row.Date01 = res.UD13_Date01;
        ud13row.Date02 = res.UD13_Date02;
        ud13row.Date03 = res.UD13_Date03;
        ud13row.Date04 = res.UD13_Date04;
        ud13row.Key1 = res.UD13_Key1;
        ud13row.Key2 = res.UD13_Key2;
        ud13row.Key3 = res.UD13_Key3;
        ud13row.Key4 = res.UD13_Key4;
        ud13row.Key5 = res.UD13_Key5;
        ud13row.Number01 = res.UD13_Number01;
        ud13row.Number03 = res.UD13_Number03;
        ud13row.ShortChar01 = res.UD13_ShortChar01;
        ud13row.ShortChar02 = res.UD13_ShortChar02;
        ud13row.ShortChar03 = res.UD13_ShortChar03;
        ud13row.ShortChar04 = res.UD13_ShortChar04;

        ud13row.RowMod = "U";

        tsUpdInvoice.UD13.Add( updRow );
        var ttErrors = svc.UpdateExt( ref ttUD13, true, true, boUpdErrorDataSet, errorsOccurred );
    }

});
4 Likes

Thank you this is a great start. When I replaced the code with this I received the following errors:

System.Drawing.Bitmap CS0246 The type or namespace name ‘UD13SvcContract’ could not be found (are you missing a using directive or an assembly reference?)
System.Drawing.Bitmap CS0246 The type or namespace name ‘UD13Tableset’ could not be found (are you missing a using directive or an assembly reference?)
System.Drawing.Bitmap CS0103 The name ‘ttResults’ does not exist in the current context
System.Drawing.Bitmap CS0246 The type or namespace name ‘UD13Row’ could not be found (are you missing a using directive or an assembly reference?)
System.Drawing.Bitmap CS0103 The name ‘ud13row’ does not exist in the current context
System.Drawing.Bitmap CS0103 The name ‘tsUpdInvoice’ does not exist in the current context
System.Drawing.Bitmap CS0103 The name ‘boUpdErrorDataSet’ does not exist in the current context

I did try to change the ud13row to UD13Row didn’t seem to make a difference.

The first few errors seem to be because you’re missing a using clause. If you’re doing this in uBAQ Directives Maintenance, there’s a option in the custom code editor to add usings & references.

The one about ttResults is based on the BAQ Results table it’s using. That’s what was used in the original script you posted, so that’s what I used. If you right click in the code editor there should be a table name in the parameters menu.

The rest are because I changed some of the variables to make it easier to read, but didn’t change them everywhere. That’s my bad.

bool errorsOccurred = false;

CallService<UD13SvcContract>( svc => {

    var ttUD13 = new UD13Tableset();

    foreach ( var res in ttResults.Where(x => !x.Unchanged()) )
    {
        var ud13Row = new UD13Row();

        //ud13row.RowIdent = "#" + res.RowIdent;
        ud13row.Character01 = res.UD13_Character01;
        ud13row.Character02 = res.UD13_Character02;
        ud13row.CheckBox01 = res.UD13_CheckBox01;
        ud13row.CheckBox02 = res.UD13_CheckBox02;
        ud13row.CheckBox03 = res.UD13_CheckBox03;
        ud13row.CheckBox04 = res.UD13_CheckBox04;
        ud13row.Company = Constants.CurrentCompany;
        ud13row.Date01 = res.UD13_Date01;
        ud13row.Date02 = res.UD13_Date02;
        ud13row.Date03 = res.UD13_Date03;
        ud13row.Date04 = res.UD13_Date04;
        ud13row.Key1 = res.UD13_Key1;
        ud13row.Key2 = res.UD13_Key2;
        ud13row.Key3 = res.UD13_Key3;
        ud13row.Key4 = res.UD13_Key4;
        ud13row.Key5 = res.UD13_Key5;
        ud13row.Number01 = res.UD13_Number01;
        ud13row.Number03 = res.UD13_Number03;
        ud13row.ShortChar01 = res.UD13_ShortChar01;
        ud13row.ShortChar02 = res.UD13_ShortChar02;
        ud13row.ShortChar03 = res.UD13_ShortChar03;
        ud13row.ShortChar04 = res.UD13_ShortChar04;

        ud13row.RowMod = "U";

        ttUD13.UD13.Add( updRow );
        var ud13UpdErrors = svc.UpdateExt( ref ttUD13, true, true, out errorsOccurred );
    }

});
2 Likes

Okay I was able to fix a lot of those error doing what you suggested. The only parameter that I can use when I right click is “queryResultDataset” and it doesn’t like that one with the where clause. Thank you again! Down to these three errors:

System.Drawing.Bitmap CS1061 ‘QueryResultDataSetUbaqTableset’ does not contain a definition for ‘Where’ and no accessible extension method ‘Where’ accepting a first argument of type ‘QueryResultDataSetUbaqTableset’ could be found (are you missing a using directive or an assembly reference?)
System.Drawing.Bitmap CS0103 The name ‘tsUpdInvoice’ does not exist in the current context
System.Drawing.Bitmap CS0103 The name ‘boUpdErrorDataSet’ does not exist in the current context

The script I posted a few minutes ago has the corrections for those last two.

For the first one, you don’t have the ttResults option in the Parameters like below?
image

1 Like

I see, they changed it in Kinetic. Use queryResultDataset.Results instead of ttResults. The script below should clear the errors. Can’t promise it will work, but it should clear the errors.

bool errorsOccurred = false;

CallService<UD13SvcContract>( svc => {

    var ttUD13 = new UD13Tableset();

    foreach ( var res in queryResultDataset.Results.Where(x => !x.Unchanged()) )
    {
        var ud13Row = new UD13Row();

        //ud13row.RowIdent = "#" + res.RowIdent;
        ud13row.Character01 = res.UD13_Character01;
        ud13row.Character02 = res.UD13_Character02;
        ud13row.CheckBox01 = res.UD13_CheckBox01;
        ud13row.CheckBox02 = res.UD13_CheckBox02;
        ud13row.CheckBox03 = res.UD13_CheckBox03;
        ud13row.CheckBox04 = res.UD13_CheckBox04;
        ud13row.Company = Constants.CurrentCompany;
        ud13row.Date01 = res.UD13_Date01;
        ud13row.Date02 = res.UD13_Date02;
        ud13row.Date03 = res.UD13_Date03;
        ud13row.Date04 = res.UD13_Date04;
        ud13row.Key1 = res.UD13_Key1;
        ud13row.Key2 = res.UD13_Key2;
        ud13row.Key3 = res.UD13_Key3;
        ud13row.Key4 = res.UD13_Key4;
        ud13row.Key5 = res.UD13_Key5;
        ud13row.Number01 = res.UD13_Number01;
        ud13row.Number03 = res.UD13_Number03;
        ud13row.ShortChar01 = res.UD13_ShortChar01;
        ud13row.ShortChar02 = res.UD13_ShortChar02;
        ud13row.ShortChar03 = res.UD13_ShortChar03;
        ud13row.ShortChar04 = res.UD13_ShortChar04;

        ud13row.RowMod = "U";

        ttUD13.UD13.Add( updRow );
        var ud13UpdErrors = svc.UpdateExt( ref ttUD13, true, true, out errorsOccurred );
    }

});
1 Like

That did fix the results issue! I had read so many things about using the ttResults and never knew or saw that is how to do it in Kinetic!

Down to one more error from the part catching the errors and adding it to the ttUD13.

System.Drawing.Bitmap CS1503 Argument 1: cannot convert from ‘ref Ice.Tablesets.UD13Tableset’ to ‘ref Ice.Tablesets.UpdExtUD13Tableset’

I totally fixed that, I must have pasted over it or something. You just need to change this line:

    var ttUD13 = new UD13Tableset();

to this:

    var ttUD13 = new UpdExtUD13Tableset();

Edited: I did it wrong again.

3 Likes

No problem! You’ve been a life saver on this! I just have to find the Using & References for the UpdExtUD13Tableset now and hopefully it works! Thank You!

If you have any ides on which Assembly is needed let me know.

Should be Ice.BO.UD13

I had already added Ice.Contracts.BO.UD13 which solved the errors from earlier but not for the last section you corrected. I’m still scrolling through looking for one that would make sense to use.

UD13 should be the only assembly you need. Did you change line 5 to var ttUD13 = new UpdExtUD13Tableset();?

1 Like

Yes I changed that line to that then the error came up: System.Drawing.Bitmap CS0246 The type or namespace name ‘UD13UpdExtTableset’ could not be found (are you missing a using directive or an assembly reference?)
So I started to look for an assembly that would work for it.

UpdExtUD13Tableset instead of UD13UpdExtTableset

2 Likes

Oh wow my bad! Thank you! Thats what rushing and quickly doing things does I guess.

1 Like