Table of Content
HAL Forum
procedure AddCharsToString (
var string ModifiedString,string Char,integer Amount)
Description:
Modifies the input string by adding specified amount of specified character to the END of the string. No absolute string length check is performed. If that is needed, then use M4PadString.
Parameters:
ModifiedString The string to be modified
Char Character to add
Amount Amount of characters to add
external procedure AddCharsToString(var string,string,Integer);

global
function Boolean GetFirstItem(var string ItemCode,var record INVc INr)
begin
  Boolean res;
  string 255 tstr;
  record ItemSettingBlock ISb;
  record BarcodeVc Barcoder;

  BlockLoad(ISb);
  INr.Code = ItemCode;
  res = ReadFirstMain(INr,1,true);
  if (res==false) then begin
    if (nonblank(ItemCode)) then begin
      tstr = ItemCode;
      if (ISb.BarCodeLength>0) then begin
        if ( len(tstr) < ISb.BarCodeLength ) then begin
          AddCharsToString(tstr,'0',ISb.BarCodeLength-len(tstr));
        end;  
      end;
      ItemCode = tstr;
      INr.BarCode = ItemCode;
      res = ReadFirstKey("BarCode",INr,1,true);
      if (res) then begin ItemCode = INr.Code; end;
      if (res==false) then begin
//        ItemCode = tstr;
        INr.AlternativeCode = ItemCode;
        res = ReadFirstKey("AlternativeCode",INr,1,true);
        if (res) then begin ItemCode = INr.Code; end;
      end;
    end;
  end;
  if (res==false) then begin
/*
    Barcoder.Barcode = ItemCode;
    if (ReadFirstMain(Barcoder,1,true)) then begin
*/
    Barcoder.Barcode = ItemCode;
    if (ReadFirstKey("Barcode",Barcoder,1,true)) then begin
      ItemCode = Barcoder.Itemcode;
      if (ReadFirstItem2(Barcoder.Itemcode,INr)) then begin // Can't call ReadFirstItem, Risk for eternal loop
        INr.Code = Barcoder.Itemcode;
        INr.BarCode = Barcoder.Barcode;
        res = true;
      end;
    end;
  end;
  if res==false and nonblank(ItemCode) then begin
  	record PIVc PIr;

    PIr.VEItemCode = ItemCode;
  	if ReadFirstKey("VEItemCode",PIr,1,true) then begin
  		INr.Code = PIr.ItemCode;
  		res = ReadFirstMain(INr,1,true);
  	end;
  end;
  if (Importing==false) then begin//close item with some qty in stock, export-import and stock list is wrong  
    if (INr.Terminated!=0) then begin res = false; end;
  end;
  GetFirstItem = res;
  return;
end;  
Related topics:
««