Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pageextension 50000 "CSV Sales Invoice List" extends "Sales Invoice List"
- { actions { addlast(processing) { action("CSV ImportFromCSV") {
- ApplicationArea = All;
- Caption = 'Import From CSV';
- Image = Import;
- ToolTip = 'Import Sales Invoice';
- trigger OnAction()
- var
- SH: Record "Sales Header";
- SL: Record "Sales Line";
- CSVB: Record "CSV Buffer";
- InS: InStream;
- i, LineNo: Integer;
- DateVal: Date;
- DecVal: Decimal;
- begin
- if not UploadIntoStream('Select CSV File', InS) then exit;
- CSVB.LoadDataFromStream(InS, ',');
- for i := 2 to CSVB.GetNumberOfLines() do begin // Skip header
- if CSVB.GetValue(i, 2) <> SH."External Document No." then begin
- SH.Init();
- SH.Validate("Document Type", SH."Document Type"::Invoice);
- SH.Insert(true);
- SH.Validate("Sell-to Customer No.", CSVB.GetValue(i, 1)); // Customer
- SH.Validate("External Document No.", CSVB.GetValue(i, 2)); // InvoiceNo
- Evaluate(DateVal, CSVB.GetValue(i, 3)); // Date
- SH.Validate("Document Date", DateVal);
- SH.Modify(true);
- LineNo := 0;
- end;
- LineNo += 10000;
- SL.Init();
- SL.Validate("Document Type", SH."Document Type");
- SL.Validate("Document No.", SH."No.");
- SL.Validate("Line No.", LineNo);
- SL.Insert(true);
- SL.Validate(Type, SL.Type::Item);
- SL.Validate("No.", CSVB.GetValue(i, 4)); // Item
- Evaluate(DecVal, CSVB.GetValue(i, 5)); // Qty
- SL.Validate("Quantity", DecVal);
- Evaluate(DecVal, CSVB.GetValue(i, 6)); // Unit Price
- SL.Validate("Unit Price", DecVal);
- SL.Modify(true);
- end;
- end; } } addlast(Category_Process) { actionref("CSV ImportFromCSV_Promoted"; "CSV ImportFromCSV") { } } } }
Advertisement
Add Comment
Please, Sign In to add comment