Friday, January 28, 2022

Using Instream & Outstream set as Source and Run XMLPort - Export and Import Data

Hello Friends,

By using Instream & Outstream set as Source and Run XMLPort - Export and Import Data

codeunit 90000 "VTK High Radius Int Unit Test"

{
    Subtype = Test;
    TestPermissions = Disabled;

    [Test]
    [TransactionModel(TransactionModel::AutoRollback)]

    procedure "1A. HighRadius AR Export"()
    var
        HighRadARExport: xmlport "HighRadius AR Export";
        VarOutstream: OutStream;
        VarInStream: InStream;
        ExpFileName: Text;
        DataExport: Text;
        TempBlob: Codeunit "Temp Blob";
    begin
        Clear(TempBlob);
        TempBlob.CreateInStream(VarInStream);
        TempBlob.CreateOutStream(VarOutstream);
        Clear(HighRadARExport);
        HighRadARExport.SetDestination(VarOutstream);
        HighRadARExport.Export();
        VarInStream.ReadText(DataExport);
        IF StrLen(DataExport) = 0 then
            Error('There is no data export');
    end;

    [Test]
    [TransactionModel(TransactionModel::AutoRollback)]

    procedure "1A. HighRadius Customer Export"()
    var
        HighRadCustExport: XmlPort "HighRadius Customer Export";
        VarOutstream: OutStream;
        VarInStream: InStream;
        DataExport: Text;
        TempBlob: Codeunit "Temp Blob";
    begin
        Clear(TempBlob);
        TempBlob.CreateInStream(VarInStream);
        TempBlob.CreateOutStream(VarOutstream);
        Clear(HighRadCustExport);
        HighRadCustExport.SetDestination(VarOutstream);
        HighRadCustExport.Export();
        VarInStream.ReadText(DataExport);
        IF StrLen(DataExport) = 0 then
            Error('There is no data export');
    end;

    [Test]
    [TransactionModel(TransactionModel::AutoRollback)]

    procedure "1A. HighRadius DMS Extract Import"()
    var
        HighRadDMSEXtrImport: xmlport "HighRadius DMS Extract Import";
        VarOutstream: OutStream;
        VarInStream: InStream;

        TempBlob: Codeunit "Temp Blob";
        VarFileData: Text;
        LFChar: Text[1];
        DocInsertCount: Integer;
    begin
        Clear(TempBlob);

        TempBlob.CreateOutStream(VarOutstream);

        LFChar[1] := 10;  //LF

        VarFileData := 'DEDUCTION_ID|DEDUCTION_TYPE';
        VarFileData += LFChar;
        VarFileData += '13976|Pre-Deduction';
        VarFileData += LFChar;
        VarFileData += '13977|Pre-Deduction';

        VarOutstream.WriteText(VarFileData);
        TempBlob.CreateInStream(VarInStream);

        HighRadDMSEXtrImport.SETSOURCE(varInstream);
        HighRadDMSEXtrImport.SetRunFromTestCodeunit();
        HighRadDMSEXtrImport.IMPORT();
        DocInsertCount := HighRadDMSEXtrImport.GetOrderInsertCount();

        IF DocInsertCount = 0 then
            Error('There is nothing to import');




    end;

    [Test]
    [TransactionModel(TransactionModel::AutoRollback)]

    procedure "1A. HighRadius Payment Import"()
    var
        HighRadPaymentImport: XmlPort "HighRadius Payment Import";
        VarOutstream: OutStream;
        VarInStream: InStream;
        CRLFChar: Text[2];
        VarFileData: Text;
        TempBlob: Codeunit "Temp Blob";
        DocInsertCount: Integer;
    begin
        Clear(TempBlob);

        TempBlob.CreateOutStream(VarOutstream);

        CRLFChar[1] := 13; // CR - Carriage Return
        CRLFChar[2] := 10; // LF - Line Feed

        VarFileData := 'Bank Account Number,Currency,Payment Type';
        VarFileData += CRLFChar;
        VarFileData += '306262556,AUD,Wire';

        VarOutstream.WriteText(VarFileData);
        TempBlob.CreateInStream(VarInStream);

        HighRadPaymentImport.SETSOURCE(varInstream);
        HighRadPaymentImport.SetRunFromTestCodeunit();
        HighRadPaymentImport.IMPORT();
        DocInsertCount := HighRadPaymentImport.GetGenLineInsertCount();

        IF DocInsertCount = 0 then
            Error('There is nothing to import');



    end;


}

Very useful for create Import & Export XMLPort Test Codeunit creation

Thank you.

No comments:

Post a Comment