Tipo de Valor de Datos: Codeunit
Con el Tipo: Codeunit se puede definir un valor de una tabla de manera individual. Para esto se pueden utilizar funciones programadas, filtros y otras cosas.
Ejemplo
Cuando el cliente utiliza un codeunit para fusionar líneas o un codeunit para otras lógicas para una factura de ventas publicada, entonces también necesita un codeunit para eDocuments. De lo contrario, hay una alta probabilidad de que se cree un archivo XML no válido para los formatos XInvoice y ZUGFeRD.
En el codeunit de ejemplo, el método GETFUNCTION devuelve la lista de parámetros para la configuración del valor de datos.
Info
Este codeunit debe ser implementado dentro de una extensión personalizada.
| 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('El registro no existe.');
if not LocalRecordSIMXSDLinkedData.Get('CATEGORY') then
Error('Los datos vinculados no existen.');
if LocalRecordRef.Number <> 113 then
Error('Tabla incorrecta');
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('El registro no existe.');
if not LocalRecordSIMXSDLinkedData.Get('CATEGORY') then
Error('Los datos vinculados no existen.');
if LocalRecordRef.Number <> 123 then
Error('Tabla incorrecta');
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;
}
|
Ver también