Options

help with codeunit?

spiralspiral Member Posts: 12
edited 2003-03-04 in Navision Attain
i got a codeunit called formataddress


inside my report:

RecordNo := RecordNo + 1;
ColumnNo := ColumnNo + 1;
FormatAddr.Vendor(VendAddr[ColumnNo],Vendor);

inside my codeunit formataddress:


Vendor(VAR AddrArray : ARRAY [8] OF Text[50];VAR Vend : Record Vendor)
WITH Vend DO
FormatAddr(
AddrArray,Name,"Name 2",Contact,Address,"Address 2",
City,"Post Code",County,"Country Code");


how do i write the vendor procedure inside my report w/o using the
formataddress codeunit?
do i need to declare Name as text, Name2 as text...? i am new to navision
programming and i need help desperate. thanks!

Comments

  • Options
    Torben_R.Torben_R. Member Posts: 99
    Hi Spiral

    In your report you have to define Dimensions to 8 (a property) for the variable VendorAddr

    To call the function:
    FormatAddr.Vendor(VendorAddr,Vendor);

    Regards
    Torben
  • Options
    ShrekShrek Member Posts: 3
    Thi sis how they use to do it in an old copy of the Vendor Label report from version 1.10 Financials. This is before they had the FormatAddress Codeunit. The Data Item in the report is the Vendor table.

    OnAfterGetRecord()
    RecordNo := RecordNo + 1;
    ColumnNo := ColumnNo + 1;
    FormatAddress; // Call a local function to format address.
    IF RecordNo = NoOfRecords THEN BEGIN
    FOR i := ColumnNo + 1 TO NoOfColumns DO
    CLEAR(Addr);
    ColumnNo := 0;
    END ELSE BEGIN
    IF ColumnNo = NoOfColumns THEN
    ColumnNo := 0;
    END;

    NumOfBlanks := NumOfBlanksInput - 7;

    OnPostDataItem()

    FormatAddress() // This is the local function
    IF ColumnNo = 1 THEN CLEAR(Addr);
    Addr[ColumnNo][1] := Vendor.Contact; // For Example: if you don't want Vendor Contacts to show then you can comment out this line.
    Addr[ColumnNo][2] := Vendor.Name;
    Addr[ColumnNo][3] := Vendor."Name 2";
    Addr[ColumnNo][4] := Vendor.Address;
    Addr[ColumnNo][5] := Vendor."Address 2";
    IF STRLEN(Vendor.City + ', ' + Vendor.State + ' ' + Vendor."ZIP Code") > MAXSTRLEN(Addr[ColumnNo][6]) THEN BEGIN
    Addr[ColumnNo][6] := Vendor.City;
    Addr[ColumnNo][7] := Vendor.State + ' ' + Vendor."ZIP Code";
    END ELSE IF (Vendor.City <> '') AND (Vendor.State <> '') THEN
    Addr[ColumnNo][6] := Vendor.City + ', ' + Vendor.State + ' ' + Vendor."ZIP Code"
    ELSE
    Addr[ColumnNo][6] := DELCHR(Vendor.City + ' ' + Vendor.State + ' ' + Vendor."ZIP Code",'<>');
    COMPRESSARRAY(Addr[ColumnNo]); // The COMPRESSARRAY function removes all blank lines in the array.

    Hope this helps.
    There is a God!
Sign In or Register to comment.