Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

Ayuda CreateInventoryTransfer

(0) ShareShare
ReportReport
Posted on by 30

Buen Día, Equipo de Microsoft Dynamics GP

Soy Christian López, de Automatica Technologies, Nuevo León, México http://www.automaticatech.com, me comunico por este medio para solicitarles ayuda, con respecto a una interfaz/enlace que estamos realizando con uno de nuestros clientes, el cual utiliza el ERP Microsoft Dynamics GP. Dicha interfaz la estamos realizando por medio de los WebServices que se ofrece dentro del DVD de Instalación de Dynamics GP 2010 (Web Services for Microsoft Dynamics GP).

Hemos estado estudiando la lista métodos preparados que se ofrecen dentro de este paquete, hemos seleccionado alguno de ellos para realizar tareas especificas msdn.microsoft.com/.../cc508424.aspx

El problema lo encontramos con el método "CreateInventoryTransfer", pongo el link a continuación:

Metodo: CreateInventoryTransfer

msdn.microsoft.com/.../cc508616.aspx

El ejemplo nos presenta el Link funciona correctamente, pero cuando se trata de Artículos que llevan control por Lotes (Lots), el presente ejemplo ya no funciona.

Artículo: 128 SDRAM, no lleva control lote, funciona.

Artículo: CAP100, si lleva control lote, no funciona.

Sin embargo, hemos estado investigando el uso de este método, para llevar a cabo el TransferInventory con artículos que llevan control de Lote (Lots) el cual no hemos tenido éxito. Les presento siguiente código que estamos utilizando, está totalmente documentado:

private void Transfer()

{

try

{

CompanyKey companyKey;

Context context;

BatchKey batchKey;

ItemKey itemKey;

Quantity itemQuantity;

WarehouseKey fromWarehouseKey;

WarehouseKey toWarehouseKey;

InventoryKey inventoryKey;

InventoryLineKey inventoryLineKey;

InventoryTransfer inventoryTransfer;

InventoryTransferLine inventoryTransferLine;

Policy inventoryTransferCreatePolicy;

// Create an instance of the service

DynamicsGP wsDynamicsGP = new DynamicsGP();

// Be sure the default credentials are used

wsDynamicsGP.UseDefaultCredentials = true;

// Create a context with which to call the service

context = new Context();

// Specify which company to use (sample company)

companyKey = new CompanyKey();

companyKey.Id = (-1);

// Set up the context object

context.OrganizationKey = (OrganizationKey)companyKey;

// Create an inventory key to identify the inventory transfer object

inventoryKey = new InventoryKey();

inventoryKey.Id = "WSINVTRFR00000015";

// Create a batch key object to specify a batch for the inventory transfer

batchKey = new BatchKey();

batchKey.Id = "TRANSFER 5";

// Create an inventory transfer object

inventoryTransfer = new InventoryTransfer();

// Populate the inventory transfer object's required properties

inventoryTransfer.Key = inventoryKey;

inventoryTransfer.BatchKey = batchKey;

inventoryTransfer.Date = DateTime.Today;

// Create an inventory transfer line object to detail the inventory transfer

inventoryTransferLine = new InventoryTransferLine();

// Create an inventory line key to identify the inventory transfer line object

inventoryLineKey = new InventoryLineKey();

inventoryLineKey.InventoryKey = inventoryKey;

// Create an item key object to specify the item

itemKey = new ItemKey();

//itemKey.Id = "128 SDRAM";

itemKey.Id = "CAP100";

// Create a quantity object to specify the amount of the transfer

itemQuantity = new Quantity();

itemQuantity.Value = 2m;            //<---------- COMO OBTENER ESTA INFORMACION

// Create a warehouse key to specify the location originating the transfer

fromWarehouseKey = new WarehouseKey();

//fromWarehouseKey.Id = "NORTH";

fromWarehouseKey.Id = "WAREHOUSE";  //<---------- COMO OBTENER ESTA INFORMACION

// Create a warehouse key to specify the location receiving the transfer

toWarehouseKey = new WarehouseKey();

//toWarehouseKey.Id = "WAREHOUSE";

toWarehouseKey.Id = "SOUTH";        //<---------- COMO OBTENER ESTA INFORMACION

/////////////////////// CONTROL LOTS //////////////////////////////////

Quantity itemQuantityLot = new Quantity();

itemQuantityLot.Value = 1m;        

itemQuantityLot.DecimalDigits = 0;  //<-----------SE HA PROBADO CON Y SIN EL DATO

//Desconosco si este es obligatorio o no, se ha probado ambos casos

InventoryLotKey inventoryLotKey = new InventoryLotKey();

inventoryLotKey.CompanyKey = companyKey;

inventoryLotKey.InventoryLineKey = inventoryLineKey;

//Desconosco el dato que va, en un foro se comentaba que se colocaba

//este numero 16384 y si hay partidas se le ponen el multiplo de 16384

//no se si sea obligatorio, pero he probado colocando 0 y/o quitando esta linea

inventoryLotKey.SequenceNumber = 16384; //<---------PORQUE ESTE DATO

InventoryTransferLot inventoryTransferLot = new InventoryTransferLot();

inventoryTransferLot.Key = inventoryLotKey;

//Este es el lote al que le corresponde el articulo, dato obtenido del GP

//sin embargo hay ningun webmethod de donde obtener esta informacion

//y me pregunto, como llenar esta informacion automaticamente si no forma de obtenerla

inventoryTransferLot.LotNumber = "LOT A";

inventoryTransferLot.Quantity = itemQuantityLot;

//Los siguientes datos se ha probado con y sin ellos, no se si sea obligatorio

//las fechas corresponde a la creacion del lote, dato obtenido del GP

inventoryTransferLot.ReceivedDate = Convert.ToDateTime("06/15/2015");

inventoryTransferLot.ManufacturedDate = Convert.ToDateTime("01/01/1900");

inventoryTransferLot.ExpirationDate = Convert.ToDateTime("01/01/1900");

//Desconosco el dato que se coloca en esta propiedad, se ha probado colocando

//diversos datos como el Almacen, lotes, blancos, y datos indiferentes.

//Se ha probado con y sin ellos

inventoryTransferLot.BinFrom = "";

inventoryTransferLot.BinTo = "";

//Aqui se adiciona una unica partida del lote del articulo con los datos especificado arriba,

//sin embargo, sabemos que se agregan tantas partidas como se sea necesario

//segun la transferencia que se requiera y sobre todo la cantidad que se quiera transferir

//El cual no hay información y relacion de datos Articulo/Almacen/Lote/Cantidad para poder llenar

//la información de forma automatica

InventoryTransferLot[] Lots = { inventoryTransferLot };

////////////////////////// FIN CONTROL LOTS ///////////////////////////////

// Populate the required properties of the inventory transfer line object

inventoryTransferLine.Key = inventoryLineKey;

inventoryTransferLine.ItemKey = itemKey;

inventoryTransferLine.Quantity = itemQuantity;

inventoryTransferLine.WarehouseFromKey = fromWarehouseKey;

inventoryTransferLine.WarehouseToKey = toWarehouseKey;

inventoryTransferLine.Lots = Lots;  //<---------------------AQUI VA TODO EL LOTE

// Create an array to hold the inventory transfer line object

InventoryTransferLine[] lines = { inventoryTransferLine };

// Add the array of inventory transfer lines to the inventory transfer object

inventoryTransfer.Lines = lines;

// Get the create policy for an inventory transfer

inventoryTransferCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateInventoryTransfer", context);

// Create the inventory transfer

wsDynamicsGP.CreateInventoryTransfer(inventoryTransfer,

context, inventoryTransferCreatePolicy);

}

catch (Exception ex)

{

MessageBox.Show(ex.Message);

}

}

Este ejemplo, no nos funciona, se va al catch exception y no realize la tarea. Mensaje del Error:

An exception occurred that the exception subsystem was unable to log, Consult your System Administrator.

Otro punto a mencionar, es ¿Cómo puedo obtener la relación de datos e información precisa de artículos con su correspondiente lote, almacén y cantidad? No existe ningún método o web method que me proporcione esta información, es decir los datos por ejemplo “LOT A”, “LOT B” su existencia y almacén (WAREHOUSE, SOUTH) de donde se pueden obtener, para así poder llenar esta información de forma automática dentro del Código correspondiente.

Otro punto más a mencionar, al correr el ejemplo presentado tanto el del link así como el propio, la ejecución lleva bastante tiempo (Aproximadamente 30 a 40 segundos en el mejor de los casos).

Espero y me puedan ayudar con esto, por lo que no es el único proceso que se requiere utilizar con este restricción.

*This post is locked for comments

  • Community Member Profile Picture
    on at
    RE: Ayuda CreateInventoryTransfer

    English Translation:

    This example does not work we are going to catch Realize exception and not the task. Error message:

    An exception occurred That the exception subsystem was unable to log, Consult your System Administrator.

    Another point to mention, is how do I obtain the list of required data and information items with their corresponding lot, warehouse and quantity? There is no method or web method to provide me this information, ie data such as "LOT A", "Lot B" its existence and warehouse (WAREHOUSE, SOUTH) from where you can get, in order to fill this information automatically within the applicable Code.

    Another point to mention, to run the example presented both the link and the proper, implementation takes time (approximately 30-40 seconds in the best case).

    And I hope you can help me with this, so it is not the only process that is required for use with this restriction.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >

Featured topics

Product updates

Dynamics 365 release plans