Data Value Type: Codeunit
With the Type: Codeunit a value from a table can be defined individually. Programmed functions, filters and other things can be used for this.
Example
When the customer uses a code unit for merging lines or a codeunit for other logics for a posted sales invoice, then you also need a codeunit for eDocuments. Otherwise, there is a very high chance that an invalid XML file will be created for XInvoice and ZUGFeRD formats.
In the sample codeunit, the GETFUNCTION method returns the parameter list for the data value configuration.
Info
This codeunit must be implemented within a custom extension.
| AL |
|---|
| codeunit 50000 "SIM_XSD Custom Data Value"
{
TableNo = "SIM_XSD Data Value";
trigger OnRun()
var
LocalRecordSalesInvoiceLine: Record "Sales Invoice Line";
LocalRecordPurchInvLine: Record "Purch. Inv. Line";
LocalRecordSIMXSDLinkedData: Record "SIM_XSD Linked Data";
LocalRecordSIMXSDLinkedDataLine: Record "SIM_XSD Linked Data Line";
LocalRecordRef: RecordRef;
LocalParamText: Text;
begin
if Rec."Codeunit Function" = '' then
LocalParamText := 'GETFUNCTIONS'
else
LocalParamText := Rec."Codeunit Function";
case LocalParamText of
'GETFUNCTIONS':
Rec."Function List" := 'SalesInvoiceLine_CAT,PurchInvLine_CAT';
'SalesInvoiceLine_CAT':
begin
if not LocalRecordRef.Get(Rec."Codeunit Record ID") then
Error('Datensatz existiert nicht.');
if not LocalRecordSIMXSDLinkedData.Get('CATEGORY') then
Error('Verknüpfte Daten existieren nicht.');
if LocalRecordRef.Number <> 113 then
Error('Falsche Tabelle');
LocalRecordRef.SetTable(LocalRecordSalesInvoiceLine);
if LocalRecordSalesInvoiceLine."VAT Bus. Posting Group" = 'NICHTSTB' then begin
Rec."Function Return Value" := 'E';
exit;
end;
if LocalRecordSIMXSDLinkedDataLine.Get(LocalRecordSIMXSDLinkedData.Code, LocalRecordSalesInvoiceLine."VAT Prod. Posting Group") then begin
Rec."Function Return Value" := LocalRecordSIMXSDLinkedDataLine."New Value";
exit;
end;
Rec."Function Return Value" := '';
end;
'PurchInvLine_CAT':
begin
if not LocalRecordRef.Get(Rec."Codeunit Record ID") then
Error('Datensatz existiert nicht.');
if not LocalRecordSIMXSDLinkedData.Get('CATEGORY') then
Error('Verknüpfte Daten existieren nicht.');
if LocalRecordRef.Number <> 123 then
Error('Falsche Tabelle');
LocalRecordRef.SetTable(LocalRecordPurchInvLine);
if LocalRecordPurchInvLine."VAT Bus. Posting Group" = 'NICHTSTB' then begin
Rec."Function Return Value" := 'E';
exit;
end;
if LocalRecordSIMXSDLinkedDataLine.Get(LocalRecordSIMXSDLinkedData.Code, LocalRecordPurchInvLine."VAT Prod. Posting Group") then begin
Rec."Function Return Value" := LocalRecordSIMXSDLinkedDataLine."New Value";
exit;
end;
Rec."Function Return Value" := '';
end;
end;
end;
}
|
See also