Advertisement
Guest User

Untitled

a guest
Feb 14th, 2020
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.61 KB | None | 0 0
  1.  var WSClient = new WSReference.zws_sd_pedidos_mbusiness2Client();
  2.                     WSClient.ClientCredentials.UserName.UserName = WSUser;
  3.                     WSClient.ClientCredentials.UserName.Password = WSPassword;
  4.  
  5.  
  6.                     List<WSReference.ZsdRfcHeader> headers = new List<WSReference.ZsdRfcHeader>();
  7.                     var header = new WSReference.ZsdRfcHeader()
  8.                     {
  9.                         Mandt = drVenta["Mandante"].ToString(),
  10.                         Idpedidomdsoft = SecuenciaPedidoERP, // "BM4000"                    
  11.                         Clase = drVenta["Clase"].ToString(), //'"N"                    
  12.                         Solicitante = drVenta["CliCodigo"].ToString(), //'"400000"                    
  13.                         Destinatario = "",
  14.                         Vendedor = drVenta["RepVendedor"].ToString(),  //' "5"                    
  15.                         Transportista = "",
  16.                         Condpago = "",
  17.                         Fpedido = DateTime.Parse(drVenta["VenFecha"].ToString()).Date.ToString("yyyy -MM-dd"),  // '  "2018-02-14"                    
  18.                         Importe = decimal.Parse(drVenta["VenMontoTotal"].ToString()),
  19.                         Obs = "",
  20.                         Vpago = "",
  21.                         Flete = 0,
  22.                         Fagrup = "",
  23.                         Vbeln = "",
  24.                         Status = "",
  25.                         Tipo = "",
  26.                         Agrup = "",
  27.                         Div = "",
  28.                         Uname = ""
  29.  
  30.                     };
  31.                     headers.Add(header);
  32.  
  33.  
  34.                     WriteLog("Cargando el detalle");
  35.                     var details = new List<WSReference.ZsdRfcDetail>();
  36.                     var DTDetalle = Ventas.ObtenerDetalleVenta(RepCodigo, VenSecuencia);
  37.                     foreach (DataRow row in DTDetalle.Rows)
  38.                     {
  39.                         // 'Writelog("Producto: " & "'" & drDetalle!ProCodigo & "'")
  40.                         var detail = new WSReference.ZsdRfcDetail()
  41.                         {
  42.                             Mandt = drVenta["Mandante"].ToString(), // '"620"
  43.                             Idpedidomdsoft = SecuenciaPedidoERP, //' PedSecuencia  '"BM4000"
  44.                             Idlinea = row["VenPosicion"].ToString(), //' "1"
  45.                             Posicion = "",//' drDetalle!PedPosicion '"1"
  46.                             Material = row["ProCodigo"].ToString(),// ' "50000050000017"
  47.                             Cantidad = decimal.Parse(row["VenCantidad"].ToString()) // '34
  48.                         };
  49.  
  50.                         details.Add(detail);
  51.                     }
  52.                     if (details.Count() == 0)
  53.                     {
  54.                         strMsg = $"Error al Carga Venta a SAP: { RepCodigo + "-" + VenSecuencia } este Venta no tiene detalle";
  55.                         WriteLog(strMsg);
  56.                         Funciones.CrearTransaccionesErrores(4, RepCodigo, VenSecuencia, strMsg);
  57.                     }
  58.  
  59.  
  60.  
  61.  
  62.                     WriteLog("Enviando pedido a SAP");
  63.                     //'FALTA OBTENER EL NUMERO ERP
  64.  
  65.  
  66.                     var sale = new WSReference.ZsdRfcPedidos();
  67.                     sale.Header = headers.ToArray();
  68.                     sale.Detalle = details.ToArray();
  69.                     var rafaga = new WSReference.ZmfSdPedidosMbRafaga()
  70.                     {
  71.                         Opcion = "1",
  72.                         Pedidos = sale,
  73.  
  74.                     };
  75.                     var respond = WSClient.ZmfSdPedidosMbRafaga(rafaga);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement