Can not get record from "Ship-to Address"

nikolai
Member Posts: 44
Hello, i want to get address from "Ship-to Address" table in invoice report. I defined global variable ShiptoAddress AS "Ship-to Address".
PrintDocHeader."Ship-to Address 2" :=
ShiptoAddress.Address +' '+ShiptoAddress."Address 2" + ', ' + ShiptoAddress.City;
is this wrong?
is any solution?
TransHeader - OnPreDataItem() IF (TransHeader.GETFILTER("Transaction No.") = '') THEN CurrReport.QUIT; TransHeader - OnAfterGetRecord() FillPrintDoc(); PrintReports(); TransHeader - OnPostDataItem() FillPrintDoc() {IF (ExternalDocNo = '') OR (ShipmentDate = 0D) OR (ShippingAgentCode = '') OR (ShippingAgentServicesCode = '') THEN ERROR('Please fill all fields'); } PrintDocHeader.INIT; PrintDocLine.INIT; //Get Retail Setup IF (CurrStore.GET(TransHeader."Store No.")) THEN; Customer.INIT; IF (Customer.GET(TransHeader."Customer No.")) THEN; BEGIN PrintDocHeader."Ship-to Address" := Customer.Address; [b] PrintDocHeader."Ship-to Address 2" := ShiptoAddress.Address +' '+ShiptoAddress."Address 2" + ', ' + ShiptoAddress.City;[/b] PrintDocHeader."Ship-to Name" := Customer.Name; PrintDocHeader."Ship-to Phone" := ShiptoAddress."Phone No."; END;
PrintDocHeader."Ship-to Address 2" :=
ShiptoAddress.Address +' '+ShiptoAddress."Address 2" + ', ' + ShiptoAddress.City;
is this wrong?
is any solution?
0
Comments
-
Did you try
FormatAddr.SalesInvShipTo(ShipToAddr,"Sales Invoice Header");
Just check report 206 for more information0 -
you havn't specified a reference of PrintDocHeader table and ShipToAddress table.
Use either setrange or Get function to create a refernce b/w two tables.0 -
I saw report 206, but i do not need to change it. i want to get "ShiptoAddress.Address" record for customer.
Do i need to add something in my code for this?0 -
abhinav0408 wrote:you havn't specified a reference of PrintDocHeader table and ShipToAddress table.
Use either setrange or Get function to create a refernce b/w two tables.
How can i do this?0 -
nikolai wrote:I saw report 206, but i do not need to change it. i want to get "ShiptoAddress.Address" record for customer.
Do i need to add something in my code for this?
I didnt tell you to change report 206
Copy the above code to your report and
show ShipToAddr[1]..ShipToAddr[6] in your sections0 -
ok thank you i'll try and i'll post result0
-
Does it exists more easy way to do that? example to use get function?
i can get customer address but shiptoadress not. how can i search ship to address
if i know cutomer No?0 -
nikolai wrote:Does it exists more easy way to do that? example to use get function?
i can get customer address but shiptoadress not. how can i search ship to address
if i know cutomer No?
ShiptoAddress.Get("Customer No.",InvHeader."Ship-to Address");0 -
I got error: "Unknown variable"
here is code:Documentation() Report - OnInitReport() Report - OnPreReport() Report - OnPostReport() Report - OnCreateHyperlink(VAR URL : Text[1024]) Report - OnHyperlink(URL : Text[1024]) FillPrintDoc() {IF (ExternalDocNo = '') OR (ShipmentDate = 0D) OR (ShippingAgentCode = '') OR (ShippingAgentServicesCode = '') THEN ERROR('Please fill all fields'); } PrintDocHeader.INIT; PrintDocLine.INIT; //Get Retail Setup IF (CurrStore.GET(TransHeader."Store No.")) THEN; Customer.INIT; IF (Customer.GET(TransHeader."Customer No.")) THEN; //IF (ShiptoAddress.GET(TransHeader."Customer No.", TransHeader."Ship-to Code")) THEN; BEGIN PrintDocHeader."Ship-to Address" := Customer.Address; PrintDocHeader."Ship-to Address 2" := ShiptoAddress.Address +' '+ShiptoAddress."Address 2" + ', ' + ShiptoAddress.City; PrintDocHeader."Ship-to Name" := Customer.Name; PrintDocHeader."Ship-to Phone" := ShiptoAddress."Phone No."; END; //ELSE {BEGIN PrintDocHeader."Ship-to Address" := Customer.Address; PrintDocHeader."Ship-to Address 2" := Customer.Address +' '+ Customer."Address 2" + ', ' + ShiptoAddress.City; PrintDocHeader."Ship-to Name" := Customer.Name; PrintDocHeader."Ship-to Phone" := ShiptoAddress."Phone No."; END;} //EE IF ShiptoAddress.Address = '' THEN PrintDocHeader."Ship-to Address 2" := Customer.Address +' '+ Customer."Address 2" + ', ' + ShiptoAddress.City; PrintDocHeader."Ship-to Address 2" := ShiptoAddress.Address +' '+ShiptoAddress."Address 2" + ', ' + ShiptoAddress.City; ShiptoAddress.Get("Customer No.",InvHeader."Ship-to Address"); CompanyInfo.FIND('-'); Counter := 1; PrintDocHeader."External Document No." := TransHeader."External Document No."; PrintDocHeader."Shipment Date" := TransHeader.Date; PrintDocHeader."Sell-to Customer No." := TransHeader."Customer No."; //PrintDocHeader."Shipping Agent Code" := TransHeader."Shipping Agent Code"; PrintDocHeader."Stock Address" := CurrStore.Address + ', ' + CurrStore.City; PrintDocHeader."Shipping Agent Services Code" := ''; //TransHeader."Shipping Agent Service Code"; PrintDocHeader."Zedd No." := TransHeader."Receipt No."; PrintDocHeader.Transfer := FALSE; PrintDocHeader."Stock Phone No." := CurrStore."Phone No."; PrintDocHeader."Ship-to VAT" := Customer."VAT Registration No."; PrintDocHeader.INSERT(TRUE); TransLine.RESET; TransLine.SETRANGE("Store No.", TransHeader."Store No."); TransLine.SETRANGE("POS Terminal No.", TransHeader."POS Terminal No."); TransLine.SETRANGE("Transaction No.", TransHeader."Transaction No."); IF (TransLine.FIND('-')) THEN REPEAT // IF (TransLine.Type=TransLine.Type::Item) THEN BEGIN SalesInvLine.RESET; SalesInvLine.SETRANGE("Document No.", SalesInvHeader."No."); SalesInvLine.SETRANGE("Line No.", TransLine."Line No."); PrintDocLine.INIT; PrintDocLine.Price := -(TransLine."Total Rounded Amt." - TransLine."VAT Amount"); IF (TransLine.Quantity <> 0) THEN PrintDocLine."Unit Price" := -PrintDocLine.Price/TransLine.Quantity; PrintDocLine.VALIDATE("VAT Amount", -TransLine."VAT Amount"); PrintDocLine."Line Amount" := -TransLine."Total Rounded Amt."; PrintDocLine."No." := FORMAT(Counter); PrintDocLine."Header No." := PrintDocHeader."No."; PrintDocLine.VALIDATE("Item No.", TransLine."Item No."); PrintDocLine.Quantity := -TransLine.Quantity; PrintDocLine."VAT Identifier" := '1'; PrintDocLine."VAT Calculation Type" := PrintDocLine."VAT Calculation Type"::"Normal VAT"; PrintDocLine."Tax Group Code" := '1'; PrintDocLine."Amount Including VAT" := PrintDocLine."Line Amount"; PrintDocLine."Inv. Discount Amount" := TransLine."Discount Amount"; PrintDocLine."Allow Invoice Disc." := (TransLine."Discount Amount" <> 0); IF (PrintDocLine.Quantity <> 0) THEN PrintDocLine.INSERT; Counter := Counter + 1; END; UNTIL (TransLine.NEXT = 0); PrintReports() COMMIT; IF (Counter <> 1) THEN BEGIN PrintDocHeader.SETRANGE("No.", PrintDocHeader."No."); REPORT.RUNMODAL(50050,FALSE,FALSE,PrintDocHeader); // UGT END; IF (PrintDocHeader.GET(PrintDocHeader."No.")) THEN PrintDocHeader.DELETE(TRUE);
0 -
Tell us exactly what is your requirement?
TryShiptoAddress.Get("Customer No.",InvHeader."Ship-to Address"); IF ShiptoAddress.Address = '' THEN PrintDocHeader."Ship-to Address 2" := Customer.Address +' '+ Customer."Address 2" + ', ' + ShiptoAddress.City ELSE PrintDocHeader."Ship-to Address 2" := ShiptoAddress.Address +' '+ShiptoAddress."Address 2" + ', ' + ShiptoAddress.City;
0 -
My target is to display ship-to address on report, but if it does not exist display customer address. customer address displays but ship to address not.
after printing report "ship-to address".address is empty, but it exists for this custemer in ship-to address table.
when i tried your code i got followning errors:
Unknown varaiables Invheader And Customer No.
Global variables: to view image click on it
Uploaded with ImageShack.us
Local variables:
Uploaded with ImageShack.us
code:Documentation() TransHeader - OnPreDataItem() IF (TransHeader.GETFILTER("Transaction No.") = '') THEN CurrReport.QUIT; TransHeader - OnAfterGetRecord() FillPrintDoc(); PrintReports(); TransHeader - OnPostDataItem() FillPrintDoc() {IF (ExternalDocNo = '') OR (ShipmentDate = 0D) OR (ShippingAgentCode = '') OR (ShippingAgentServicesCode = '') THEN ERROR('Please fill all fields'); } PrintDocHeader.INIT; PrintDocLine.INIT; //Get Retail Setup IF (CurrStore.GET(TransHeader."Store No.")) THEN; Customer.INIT; IF (Customer.GET(TransHeader."Customer No.")) THEN; //IF (ShiptoAddress.GET(TransHeader."Customer No.", TransHeader."Ship-to Code")) THEN; BEGIN PrintDocHeader."Ship-to Address" := Customer.Address; PrintDocHeader."Ship-to Address 2" := ShiptoAddress.Address +' '+ShiptoAddress."Address 2" + ', ' + ShiptoAddress.City; PrintDocHeader."Ship-to Name" := Customer.Name; PrintDocHeader."Ship-to Phone" := ShiptoAddress."Phone No."; END; //ELSE {BEGIN PrintDocHeader."Ship-to Address" := Customer.Address; PrintDocHeader."Ship-to Address 2" := Customer.Address +' '+ Customer."Address 2" + ', ' + ShiptoAddress.City; PrintDocHeader."Ship-to Name" := Customer.Name; PrintDocHeader."Ship-to Phone" := ShiptoAddress."Phone No."; END;} //EE IF ShiptoAddress.Address = '' THEN PrintDocHeader."Ship-to Address 2" := Customer.Address +' '+ Customer."Address 2" + ', ' + ShiptoAddress.City; CompanyInfo.FIND('-'); Counter := 1; PrintDocHeader."External Document No." := TransHeader."External Document No."; PrintDocHeader."Shipment Date" := TransHeader.Date; PrintDocHeader."Sell-to Customer No." := TransHeader."Customer No."; //PrintDocHeader."Shipping Agent Code" := TransHeader."Shipping Agent Code"; PrintDocHeader."Stock Address" := CurrStore.Address + ', ' + CurrStore.City; PrintDocHeader."Shipping Agent Services Code" := ''; //TransHeader."Shipping Agent Service Code"; PrintDocHeader."Zedd No." := TransHeader."Receipt No."; PrintDocHeader.Transfer := FALSE; PrintDocHeader."Stock Phone No." := CurrStore."Phone No."; PrintDocHeader."Ship-to VAT" := Customer."VAT Registration No."; PrintDocHeader.INSERT(TRUE); TransLine.RESET; TransLine.SETRANGE("Store No.", TransHeader."Store No."); TransLine.SETRANGE("POS Terminal No.", TransHeader."POS Terminal No."); TransLine.SETRANGE("Transaction No.", TransHeader."Transaction No."); IF (TransLine.FIND('-')) THEN REPEAT // IF (TransLine.Type=TransLine.Type::Item) THEN BEGIN SalesInvLine.RESET; SalesInvLine.SETRANGE("Document No.", SalesInvHeader."No."); SalesInvLine.SETRANGE("Line No.", TransLine."Line No."); PrintDocLine.INIT; PrintDocLine.Price := -(TransLine."Total Rounded Amt." - TransLine."VAT Amount"); IF (TransLine.Quantity <> 0) THEN PrintDocLine."Unit Price" := -PrintDocLine.Price/TransLine.Quantity; PrintDocLine.VALIDATE("VAT Amount", -TransLine."VAT Amount"); PrintDocLine."Line Amount" := -TransLine."Total Rounded Amt."; PrintDocLine."No." := FORMAT(Counter); PrintDocLine."Header No." := PrintDocHeader."No."; PrintDocLine.VALIDATE("Item No.", TransLine."Item No."); PrintDocLine.Quantity := -TransLine.Quantity; PrintDocLine."VAT Identifier" := '1'; PrintDocLine."VAT Calculation Type" := PrintDocLine."VAT Calculation Type"::"Normal VAT"; PrintDocLine."Tax Group Code" := '1'; PrintDocLine."Amount Including VAT" := PrintDocLine."Line Amount"; PrintDocLine."Inv. Discount Amount" := TransLine."Discount Amount"; PrintDocLine."Allow Invoice Disc." := (TransLine."Discount Amount" <> 0); IF (PrintDocLine.Quantity <> 0) THEN PrintDocLine.INSERT; Counter := Counter + 1; END; UNTIL (TransLine.NEXT = 0); PrintReports() COMMIT; IF (Counter <> 1) THEN BEGIN PrintDocHeader.SETRANGE("No.", PrintDocHeader."No."); REPORT.RUNMODAL(50050,FALSE,FALSE,PrintDocHeader); // UGT END; IF (PrintDocHeader.GET(PrintDocHeader."No.")) THEN PrintDocHeader.DELETE(TRUE);
0 -
replace
IF ShiptoAddress.Address = '' THEN PrintDocHeader."Ship-to Address 2" := Customer.Address +' '+ Customer."Address 2" + ', ' + ShiptoAddress.City;
withIF ShiptoAddress.GET(TransHeader."Customer No.", TransHeader."Ship-to Code") THEN BEGIN IF ShiptoAddress.Address = '' THEN PrintDocHeader."Ship-to Address 2" := Customer.Address +' '+ Customer."Address 2" + ', ' + ShiptoAddress.City ELSE PrintDocHeader."Ship-to Address 2" := ShiptoAddress.Address +' '+ShiptoAddress."Address 2" + ', ' + ShiptoAddress.City; END;
0 -
got error:
"you have specified an inknown variable.
Ship-to Code
Define the variable under 'Global C/AL symbols'.
"0 -
nikolai wrote:got error:
"you have specified an inknown variable.
Ship-to Code
Define the variable under 'Global C/AL symbols'.
"
Which table is TransHeader?
BTW, Are you technical consultant? :-k0 -
mohana_cse06 wrote:nikolai wrote:got error:
"you have specified an inknown variable.
Ship-to Code
Define the variable under 'Global C/AL symbols'.
"
Which table is TransHeader?
BTW, Are you technical consultant? :-k
"Transaction Header ", yes i am begginer0 -
In Sales Header, we have Ship-to Code to give Shipment address
In Transfer Header, we dont have any field with Ship-to Code..
Then from where you want to get the Ship-to Code?0 -
mohana_cse06 wrote:In Sales Header, we have Ship-to Code to give Shipment address
In Transfer Header, we dont have any field with Ship-to Code..
Then from where you want to get the Ship-to Code?
I whant to get address from "ship-to address" table, not ship to code.
address is in "Ship-to Address" table.0 -
nikolai wrote:I whant to get address from "ship-to address" table, not ship to code.
address is in "Ship-to Address" table.
we will have 100 records in "ship-to address" table
out of 100, which record you want?0 -
mohana_cse06 wrote:nikolai wrote:I whant to get address from "ship-to address" table, not ship to code.
address is in "Ship-to Address" table.
we will have 100 records in "ship-to address" table
out of 100, which record you want?
Where TransHeader."Customer No."="Ship-to Address"."Customer No."0 -
nikolai wrote:mohana_cse06 wrote:nikolai wrote:I whant to get address from "ship-to address" table, not ship to code.
address is in "Ship-to Address" table.
we will have 100 records in "ship-to address" table
out of 100, which record you want?
Where TransHeader."Customer No."="Ship-to Address"."Customer No."
Again you may have 100 records with (TransHeader."Customer No."="Ship-to Address"."Customer No.") this combination.
as primary key is Customer No.,Code
Now???0 -
ok i understand. "Transaction header"."Ship-to Address" is code in my case
Where TransHeader."Customer No."="Ship-to Address"."Customer No." AND
TransHeader."Ship-to Adress"="Ship-to Address".code
it seems that in "Ship-to Address" table there is no two same customer's address.0 -
nikolai wrote:ok i understand. "Transaction header"."Ship-to Address" is code in my case
Where TransHeader."Customer No."="Ship-to Address"."Customer No." AND
TransHeader."Ship-to Adress"="Ship-to Address".code
Is "Transaction header"."Ship-to Address" customized field?
If yes,
replaceIF ShiptoAddress.GET(TransHeader."Customer No.", TransHeader."Ship-to Code") THEN BEGIN
withIF ShiptoAddress.GET(TransHeader."Customer No.", TransHeader."Ship-to Address") THEN BEGIN
in my above code0 -
you need to create a field "ship to code" in transaction header and then assign it to a code for a perticular customer exist in transaction header as working in sales header.
because without adding or linking "ship to code" from ship-to-address table you can't get all detail.
based on this field check how's rest of the fields populating in sales header.0 -
ok then use ship-to-address field to as a ship-to-code.0
-
Thank you it works now0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions