Advertisement
Zavaski

Untitled

Oct 5th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. /*
  2. Add your SAP Business ByDesign scripting language implementation for:
  3. Business Object: Opportunity
  4. Node: Root
  5. Action: checkIfClientIsOn_Boletagem
  6.  
  7. Note:
  8. - To access the elements of the business object node,
  9. use path expressions, for example, this.<element name>.
  10. - To use code completion, press CTRL+J.
  11.  
  12. */
  13.  
  14. import ABSL;
  15. import AP.FO.BusinessPartner.Global;
  16.  
  17. var request : Library::ClientGET_WSDL.SI_BUSCA_CLIENTE_SYNC_OUT.Request;
  18. var response : Library::ClientGET_WSDL.SI_BUSCA_CLIENTE_SYNC_OUT.Response;
  19. var scenario = "ClientGET_Scenario";
  20.  
  21. if(this.ProspectParty.IsSet()) { //If there is a client associated to the opportunity
  22. var customer = Customer.Retrieve(this.ProspectParty.PartyUUID); //Get the client
  23. if(customer.IsSet()) {
  24. request.MT_BUSCA_CLIENTE_OUT.ID = customer.InternalID.RemoveLeadingZeros();
  25. response = Library::ClientGET_WSDL.SI_BUSCA_CLIENTE_SYNC_OUT(request, "", scenario);
  26. // error handling
  27. if (response.IsInitial()) {
  28. raise GenericMessage.Create("E", "Erro ao enviar o verificar Cliente no Boletagem");
  29. customer.CurrentCommon.wasSentToBoletagem = false;
  30. return;
  31. } else {
  32. // fault messages
  33. var faultItems = response.CommunicationFault.Item;
  34. var severity;
  35. if (faultItems.Count() > 0) {
  36. // do not send the complete error stack to the user. Assumption: last message is the most important on.
  37. raise GenericMessage.Create("E", "Erro: " + faultItems.GetLast().Note);
  38. customer.CurrentCommon.wasSentToBoletagem = false;
  39. return;
  40. }
  41. }
  42. if(response.MT_BUSCA_CLIENTE_OUT_RESPONSE.IsInitial()) {
  43. raise GenericMessage.Create("E", "Reposta vazia do Boletagem");
  44. customer.CurrentCommon.wasSentToBoletagem = false;
  45. return;
  46. }
  47. if(response.MT_BUSCA_CLIENTE_OUT_RESPONSE.LOG.IsInitial()) { //If find a client on the Boletagem, does not generate log.
  48. customer.CurrentCommon.wasSentToBoletagem = true;
  49. } else {
  50. customer.CurrentCommon.wasSentToBoletagem = false;
  51. }
  52. }
  53. else {
  54. raise GenericMessage.Create("E", "Oportunidade sem cliente válido");
  55. customer.CurrentCommon.wasSentToBoletagem = false;
  56. }
  57. }
  58. else {
  59. raise GenericMessage.Create("E", "Oportunidade sem cliente");
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement