8
n8n 中文网amn8n.com

SAP汇率设置发布

高级

这是一个AI, IT Ops领域的自动化工作流,包含 22 个节点。主要使用 Set, Limit, Switch, Webhook, SplitOut 等节点,结合人工智能技术实现智能自动化。 支持AI验证和多数据源的SAP B1灵活汇率上传

前置要求
  • HTTP Webhook 端点(n8n 会自动生成)
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "orfFmTSduPuXzA9M",
  "meta": {
    "instanceId": "06b3271522ae4bedcb94de9dac3219d19e1a4e5fcd0a448a4abc68198b391077",
    "templateCredsSetupCompleted": true
  },
  "name": "SAP SetCurrencyRate 发布",
  "tags": [],
  "nodes": [
    {
      "id": "3995b39d-8f9e-4ed8-9919-cfb8b7df4555",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -400,
        200
      ],
      "webhookId": "b81a1fa5-2138-4b70-80ee-945fa44e69ce",
      "parameters": {
        "path": "b81a1fa5-2138-4b70-80ee-945fa44e69ce",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 1
    },
    {
      "id": "c0fca1fe-e89f-448f-914a-986609e349ab",
      "name": "条件分支",
      "type": "n8n-nodes-base.switch",
      "position": [
        120,
        160
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "JSON",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "92e037df-a8ef-402e-ba21-7ae482659d64",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Webhook').item.json.body.origen }}",
                    "rightValue": "JSON"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "SQL",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "cc611430-1094-4ff3-a7ff-a33839f95da3",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Webhook').item.json.body.origen }}",
                    "rightValue": "SQL"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "SHEETS",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "50e8b710-12d1-4bf1-8293-bdf84f77bb06",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Webhook').item.json.body.origen }}",
                    "rightValue": "GoogleSheets"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "MANUAL",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "5e5bc8db-919f-4040-9663-9b2f0742017f",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Webhook').item.json.body.origen }}",
                    "rightValue": "Manual"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2,
      "alwaysOutputData": false
    },
    {
      "id": "f47c38b0-67fa-4f0d-98c6-b088253fe06f",
      "name": "发送 SAP (JSON)",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        1140,
        -180
      ],
      "parameters": {
        "url": "={{ $vars.url_sap }}SBOBobService_SetCurrencyRate",
        "body": "={\n    \"Currency\": \"{{ $json.Currency }}\",\n    \"Rate\": \"{{ $json.Rate }}\",\n    \"RateDate\": \"{{ $json.RateDate }}\"\n}\n",
        "method": "POST",
        "options": {
          "allowUnauthorizedCerts": true
        },
        "sendBody": true,
        "contentType": "raw",
        "sendHeaders": true,
        "rawContentType": "application/json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Cookie",
              "value": "=B1SESSION={{ $('Conectar SAP').item.json.SessionId }}"
            }
          ]
        }
      },
      "typeVersion": 4.2,
      "alwaysOutputData": false
    },
    {
      "id": "51aa4842-0177-40d4-9931-cdf90b09f9d8",
      "name": "连接 SAP",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -160,
        200
      ],
      "parameters": {
        "url": "={{ $vars.url_sap }}Login",
        "method": "POST",
        "options": {
          "allowUnauthorizedCerts": true
        },
        "jsonBody": "={\n       \"UserName\": \"{{ $vars.user_sap }}\",\n       \"Password\": \"{{ $vars.password_sap }}\",\n       \"CompanyDB\": \"{{ $vars.company_db }}\"\n}",
        "sendBody": true,
        "specifyBody": "json"
      },
      "typeVersion": 4.2,
      "alwaysOutputData": false
    },
    {
      "id": "b5fb4c29-f1ca-4dca-b830-975ed1a5d76e",
      "name": "Microsoft SQL",
      "type": "n8n-nodes-base.microsoftSql",
      "position": [
        660,
        40
      ],
      "parameters": {
        "query": "{{ $json.select_sql }}",
        "operation": "executeQuery"
      },
      "credentials": {
        "microsoftSql": {
          "id": "m9hMdVOqOAfRvsja",
          "name": "Microsoft SQL account"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "591a6fab-dfc2-4c23-889a-dc82701cbe8b",
      "name": "提取查询",
      "type": "n8n-nodes-base.set",
      "position": [
        420,
        40
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ffd45f1e-2e64-43cd-b885-1954cf490d41",
              "name": "select_sql",
              "type": "string",
              "value": "={{ $('Webhook').item.json.body.sql }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "293eaf33-7cb3-4b0e-a37e-513607fdca83",
      "name": "发送 SAP (SQL)",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        1600,
        40
      ],
      "parameters": {
        "url": "={{ $vars.url_sap }}SBOBobService_SetCurrencyRate",
        "body": "={\n    \"Currency\": \"{{ $json.message.content.Currency }}\",\n    \"Rate\": \"{{ $json.message.content.Rate }}\",\n    \"RateDate\": \"{{ $json.message.content.RateDate }}\"\n}",
        "method": "POST",
        "options": {
          "allowUnauthorizedCerts": true
        },
        "sendBody": true,
        "contentType": "raw",
        "sendHeaders": true,
        "rawContentType": "application/json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Cookie",
              "value": "=B1SESSION={{ $('Conectar SAP').item.json.SessionId }}"
            }
          ]
        }
      },
      "typeVersion": 4.2,
      "alwaysOutputData": false
    },
    {
      "id": "99a4e171-2b5a-447c-bbf6-a6d29c82084c",
      "name": "限制",
      "type": "n8n-nodes-base.limit",
      "position": [
        880,
        40
      ],
      "parameters": {
        "maxItems": 10
      },
      "typeVersion": 1
    },
    {
      "id": "08588a10-01f2-4e3d-86f6-ee7a4393d986",
      "name": "发送 SAP (手动)",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        440,
        700
      ],
      "parameters": {
        "url": "={{ $vars.url_sap }}SBOBobService_SetCurrencyRate",
        "body": "={\n    \"Currency\": \"{{ $('Webhook').item.json.body.currency }}\",\n    \"Rate\": \"{{ $('Webhook').item.json.body.rate }}\",\n    \"RateDate\": \"{{ $('Webhook').item.json.body.rateDate }}\"\n}",
        "method": "POST",
        "options": {
          "allowUnauthorizedCerts": true
        },
        "sendBody": true,
        "contentType": "raw",
        "sendHeaders": true,
        "rawContentType": "application/json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Cookie",
              "value": "=B1SESSION={{ $json.SessionId }}"
            }
          ]
        }
      },
      "typeVersion": 4.2,
      "alwaysOutputData": false
    },
    {
      "id": "15295241-b9d4-4019-a24d-f902e789a49e",
      "name": "OpenAI",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        420,
        -180
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "GPT-4O-MINI"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=Tengo un JSON con estructura variable. Quiero que lo transformes en un JSON uniforme que tenga un solo array llamado `rate`, donde cada objeto del array represente una entrada individual.\n\nNo importa si los datos vienen en:\n- Un objeto con una clave como `data`, `results`, `rows`, etc.\n- Un objeto único que contiene arrays anidados.\n- Un array de objetos directamente.\n\nDevuélveme un JSON así:\n\n{\n  \"rate\": [\n    { ... },\n    { ... },\n    ...\n  ]\n}\n\nEste formato es para procesar fácilmente cada objeto por separado en n8n usando `Item Lists → Split Out Items`.\n\nSolo quiero que me devuelvas el JSON transformado. No expliques nada ni incluyas comentarios.\n\nEste es el json que tienes que arreglar:\n{{ $('Webhook').item.json.body.json }}"
            }
          ]
        },
        "jsonOutput": true
      },
      "credentials": {
        "openAiApi": {
          "id": "bzsMy0qoZwAw3BhM",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "86f8976a-1715-4192-9228-14ae2a451631",
      "name": "拆分输出",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        880,
        -180
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "message.content.rate"
      },
      "typeVersion": 1
    },
    {
      "id": "77b9008d-ff45-4ce9-866d-178fa4d0f2c4",
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        420,
        340
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1xFcJSzQyhPOaC-zeX2dJ7LaUxpg-vxiN3EAOBxLTQ4g/edit#gid=0",
          "cachedResultName": "Hoja 1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1xFcJSzQyhPOaC-zeX2dJ7LaUxpg-vxiN3EAOBxLTQ4g",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1xFcJSzQyhPOaC-zeX2dJ7LaUxpg-vxiN3EAOBxLTQ4g/edit?usp=drivesdk",
          "cachedResultName": "RATE"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "5UMhhnm7ZoIEGIE4",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "cd66ebf5-9266-47dd-9e46-012a64f06fdb",
      "name": "发送 SAP (SHEET)",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        660,
        340
      ],
      "parameters": {
        "url": "={{ $vars.url_sap }}SBOBobService_SetCurrencyRate",
        "body": "={\n    \"Currency\": \"{{ $json.Currency }}\",\n    \"Rate\": \"{{ $json.Rate }}\",\n    \"RateDate\": \"{{ $json.RateDate }}\"\n}",
        "method": "POST",
        "options": {
          "allowUnauthorizedCerts": true
        },
        "sendBody": true,
        "contentType": "raw",
        "sendHeaders": true,
        "rawContentType": "application/json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Cookie",
              "value": "=B1SESSION={{ $('Conectar SAP').item.json.SessionId }}"
            }
          ]
        }
      },
      "typeVersion": 4.2,
      "alwaysOutputData": false
    },
    {
      "id": "fe249d41-6cf2-4bee-bc02-16abb9c58339",
      "name": "成功",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1420,
        -380
      ],
      "parameters": {
        "columns": {
          "value": {
            "url": "={{ $vars.url_sap }}SBOBobService_SetCurrencyRate",
            "json": "={\n    \"Currency\": \"{{ $('Split Out').item.json.Currency }}\",\n    \"Rate\": \"{{ $('Split Out').item.json.Rate }}\",\n    \"RateDate\": \"{{ $('Split Out').item.json.RateDate }}\"\n}",
            "method": "POST",
            "message": "=Enviado correctamente a SAP, pero sin contenido",
            "workflow": "SAPB1-1SBOBobService_SetCurrencyRate",
            "status_code": "=204"
          },
          "schema": [
            {
              "id": "workflow",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "workflow",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "method",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "method",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "url",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "json",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "json",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status_code",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "status_code",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "message",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "message",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1D0qRdFRf8EHH4gAf9JD3tLDofOf8lqcBBXzMl7cmpDM/edit#gid=0",
          "cachedResultName": "Hoja 1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1D0qRdFRf8EHH4gAf9JD3tLDofOf8lqcBBXzMl7cmpDM",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1D0qRdFRf8EHH4gAf9JD3tLDofOf8lqcBBXzMl7cmpDM/edit?usp=drivesdk",
          "cachedResultName": "LOGS_N8N"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "5UMhhnm7ZoIEGIE4",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "54807d8b-df01-4932-8f65-750853fe828c",
      "name": "失败",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1420,
        -200
      ],
      "parameters": {
        "columns": {
          "value": {
            "url": "={{ $vars.url_sap }}SBOBobService_SetCurrencyRate",
            "json": "={\n    \"Currency\": \"{{ $json.Currency }}\",\n    \"Rate\": \"{{ $json.Rate }}\",\n    \"RateDate\": \"{{ $json.RateDate }}\"\n}",
            "method": "POST",
            "message": "={{ $json.error.message }}",
            "workflow": "SAPB1-1SBOBobService_SetCurrencyRate",
            "status_code": "={{ $json.error.status }}"
          },
          "schema": [
            {
              "id": "workflow",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "workflow",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "method",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "method",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "url",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "json",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "json",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status_code",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "status_code",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "message",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "message",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1D0qRdFRf8EHH4gAf9JD3tLDofOf8lqcBBXzMl7cmpDM/edit#gid=0",
          "cachedResultName": "Hoja 1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1D0qRdFRf8EHH4gAf9JD3tLDofOf8lqcBBXzMl7cmpDM",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1D0qRdFRf8EHH4gAf9JD3tLDofOf8lqcBBXzMl7cmpDM/edit?usp=drivesdk",
          "cachedResultName": "LOGS_N8N"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "5UMhhnm7ZoIEGIE4",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "b32f9a30-3ba4-4b45-9bb5-edd3feca7277",
      "name": "成功1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1860,
        -100
      ],
      "parameters": {
        "columns": {
          "value": {
            "url": "={{ $vars.url_sap }}SBOBobService_SetCurrencyRate",
            "json": "={\n    \"Currency\": \"{{ $('Comprobar Fecha').item.json.message.content.Currency }}\",\n    \"Rate\": \"{{ $('Comprobar Fecha').item.json.message.content.Rate }}\",\n    \"RateDate\": \"{{ $('Comprobar Fecha').item.json.message.content.RateDate }}\"\n}",
            "method": "POST",
            "message": "=Enviado correctamente a SAP, pero sin contenido",
            "workflow": "SAPB1-1SBOBobService_SetCurrencyRate",
            "status_code": "=204"
          },
          "schema": [
            {
              "id": "workflow",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "workflow",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "method",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "method",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "url",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "json",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "json",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status_code",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "status_code",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "message",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "message",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1D0qRdFRf8EHH4gAf9JD3tLDofOf8lqcBBXzMl7cmpDM/edit#gid=0",
          "cachedResultName": "Hoja 1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1D0qRdFRf8EHH4gAf9JD3tLDofOf8lqcBBXzMl7cmpDM",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1D0qRdFRf8EHH4gAf9JD3tLDofOf8lqcBBXzMl7cmpDM/edit?usp=drivesdk",
          "cachedResultName": "LOGS_N8N"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "5UMhhnm7ZoIEGIE4",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "f41ae072-181a-4480-bb4a-759418409e6f",
      "name": "检查日期",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1120,
        40
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "GPT-4O-MINI"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=Quiero que verifiques y transformes el campo `RateDate` en un JSON.\n\nToma cualquier JSON que te pase y asegúrate de que:\n- El campo `RateDate` esté en formato `yyyyMMdd` (por ejemplo, `20250612`).\n- Si `RateDate` viene como:\n  - `YYYY-MM-DD` (ejemplo: `2025-06-12`)\n  - `YYYY-MM-DDTHH:mm:ss.sssZ` (ejemplo: `2025-06-12T00:00:00.000Z`)\n  - Timestamp (ejemplo: `1686528000000`)\n  - O cualquier otra variante\n  Entonces debes **convertirlo al formato exacto `yyyyMMdd` como string**.\n\n⚠️ Si el campo `RateDate` ya está en formato `yyyyMMdd`, déjalo igual.\n\nDevuélveme el JSON transformado **con el campo `RateDate` corregido**. No incluyas explicaciones ni comentarios, solo el nuevo JSON.\n\nJSON a comprobar:\n{\n    \"Currency\": \"{{ $json.Currency }}\",\n    \"Rate\": \"{{ $json.Rate }}\",\n    \"RateDate\": \"{{ $json.RateDate }}\"\n}"
            }
          ]
        },
        "jsonOutput": true
      },
      "credentials": {
        "openAiApi": {
          "id": "bzsMy0qoZwAw3BhM",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "88eed1d3-bf5e-4338-b829-a7031134bcba",
      "name": "失败1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1860,
        120
      ],
      "parameters": {
        "columns": {
          "value": {
            "url": "={{ $vars.url_sap }}SBOBobService_SetCurrencyRate",
            "json": "={\n    \"Currency\": \"{{ $json.Currency }}\",\n    \"Rate\": \"{{ $json.Rate }}\",\n    \"RateDate\": \"{{ $json.RateDate }}\"\n}",
            "method": "POST",
            "message": "={{ $json.error.message }}",
            "workflow": "SAPB1-1SBOBobService_SetCurrencyRate",
            "status_code": "={{ $json.error.status }}"
          },
          "schema": [
            {
              "id": "workflow",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "workflow",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "method",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "method",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "url",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "json",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "json",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status_code",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "status_code",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "message",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "message",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1D0qRdFRf8EHH4gAf9JD3tLDofOf8lqcBBXzMl7cmpDM/edit#gid=0",
          "cachedResultName": "Hoja 1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1D0qRdFRf8EHH4gAf9JD3tLDofOf8lqcBBXzMl7cmpDM",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1D0qRdFRf8EHH4gAf9JD3tLDofOf8lqcBBXzMl7cmpDM/edit?usp=drivesdk",
          "cachedResultName": "LOGS_N8N"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "5UMhhnm7ZoIEGIE4",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "6def1d6b-c496-4cb4-91e3-683fe346ffcf",
      "name": "成功2",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        900,
        220
      ],
      "parameters": {
        "columns": {
          "value": {
            "url": "={{ $vars.url_sap }}SBOBobService_SetCurrencyRate",
            "json": "={\n    \"Currency\": \"{{ $('Google Sheets').item.json.Currency }}\",\n    \"Rate\": \"{{ $('Google Sheets').item.json.Rate }}\",\n    \"RateDate\": \"{{ $('Google Sheets').item.json.RateDate }}\"\n}",
            "method": "POST",
            "message": "=Enviado correctamente a SAP, pero sin contenido",
            "workflow": "SAPB1-1SBOBobService_SetCurrencyRate",
            "status_code": "=204"
          },
          "schema": [
            {
              "id": "workflow",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "workflow",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "method",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "method",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "url",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "json",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "json",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status_code",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "status_code",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "message",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "message",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1D0qRdFRf8EHH4gAf9JD3tLDofOf8lqcBBXzMl7cmpDM/edit#gid=0",
          "cachedResultName": "Hoja 1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1D0qRdFRf8EHH4gAf9JD3tLDofOf8lqcBBXzMl7cmpDM",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1D0qRdFRf8EHH4gAf9JD3tLDofOf8lqcBBXzMl7cmpDM/edit?usp=drivesdk",
          "cachedResultName": "LOGS_N8N"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "5UMhhnm7ZoIEGIE4",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "68da45f2-3480-4133-b71c-a2116eff7e25",
      "name": "失败2",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        900,
        440
      ],
      "parameters": {
        "columns": {
          "value": {
            "url": "={{ $vars.url_sap }}SBOBobService_SetCurrencyRate",
            "json": "={\n    \"Currency\": \"{{ $json.Currency }}\",\n    \"Rate\": \"{{ $json.Rate }}\",\n    \"RateDate\": \"{{ $json.RateDate }}\"\n}",
            "method": "POST",
            "message": "={{ $json.error.message }}",
            "workflow": "SAPB1-1SBOBobService_SetCurrencyRate",
            "status_code": "={{ $json.error.status }}"
          },
          "schema": [
            {
              "id": "workflow",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "workflow",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "method",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "method",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "url",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "json",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "json",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status_code",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "status_code",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "message",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "message",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1D0qRdFRf8EHH4gAf9JD3tLDofOf8lqcBBXzMl7cmpDM/edit#gid=0",
          "cachedResultName": "Hoja 1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1D0qRdFRf8EHH4gAf9JD3tLDofOf8lqcBBXzMl7cmpDM",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1D0qRdFRf8EHH4gAf9JD3tLDofOf8lqcBBXzMl7cmpDM/edit?usp=drivesdk",
          "cachedResultName": "LOGS_N8N"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "5UMhhnm7ZoIEGIE4",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "d4bcbae9-d8b8-4e0d-aabb-290adb3a3a84",
      "name": "成功3",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        660,
        580
      ],
      "parameters": {
        "columns": {
          "value": {
            "url": "={{ $vars.url_sap }}SBOBobService_SetCurrencyRate",
            "json": "={\n    \"Currency\": \"{{ $('Webhook').item.json.body.currency }}\",\n    \"Rate\": \"{{ $('Webhook').item.json.body.rate }}\",\n    \"RateDate\": \"{{ $('Webhook').item.json.body.rateDate }}\"\n}",
            "method": "POST",
            "message": "=Enviado correctamente a SAP, pero sin contenido",
            "workflow": "SAPB1-1SBOBobService_SetCurrencyRate",
            "status_code": "=204"
          },
          "schema": [
            {
              "id": "workflow",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "workflow",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "method",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "method",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "url",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "json",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "json",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status_code",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "status_code",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "message",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "message",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1D0qRdFRf8EHH4gAf9JD3tLDofOf8lqcBBXzMl7cmpDM/edit#gid=0",
          "cachedResultName": "Hoja 1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1D0qRdFRf8EHH4gAf9JD3tLDofOf8lqcBBXzMl7cmpDM",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1D0qRdFRf8EHH4gAf9JD3tLDofOf8lqcBBXzMl7cmpDM/edit?usp=drivesdk",
          "cachedResultName": "LOGS_N8N"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "5UMhhnm7ZoIEGIE4",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "029f31d2-3c97-4a66-83f9-e2405053d32c",
      "name": "失败3",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        660,
        780
      ],
      "parameters": {
        "columns": {
          "value": {
            "url": "={{ $vars.url_sap }}SBOBobService_SetCurrencyRate",
            "json": "={\n    \"Currency\": \"{{ $('Webhook').item.json.body.currency }}\",\n    \"Rate\": \"{{ $('Webhook').item.json.body.rate }}\",\n    \"RateDate\": \"{{ $('Webhook').item.json.body.rateDate }}\"\n}",
            "method": "POST",
            "message": "={{ $json.error.message }}",
            "workflow": "SAPB1-1SBOBobService_SetCurrencyRate",
            "status_code": "={{ $json.error.status }}"
          },
          "schema": [
            {
              "id": "workflow",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "workflow",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "method",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "method",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "url",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "url",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "json",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "json",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status_code",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "status_code",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "message",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "message",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1D0qRdFRf8EHH4gAf9JD3tLDofOf8lqcBBXzMl7cmpDM/edit#gid=0",
          "cachedResultName": "Hoja 1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1D0qRdFRf8EHH4gAf9JD3tLDofOf8lqcBBXzMl7cmpDM",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1D0qRdFRf8EHH4gAf9JD3tLDofOf8lqcBBXzMl7cmpDM/edit?usp=drivesdk",
          "cachedResultName": "LOGS_N8N"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "5UMhhnm7ZoIEGIE4",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.6
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "79345188-a7cb-4dc1-beaf-e020fe859782",
  "connections": {
    "Limit": {
      "main": [
        [
          {
            "node": "Comprobar Fecha",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extraer Query",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Enviar SAP (MANUAL)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Conectar SAP",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Enviar SAP (JSON)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Conectar SAP": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extraer Query": {
      "main": [
        [
          {
            "node": "Microsoft SQL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets": {
      "main": [
        [
          {
            "node": "Enviar SAP (SHEET)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Microsoft SQL": {
      "main": [
        [
          {
            "node": "Limit",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Comprobar Fecha": {
      "main": [
        [
          {
            "node": "Enviar SAP (SQL)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enviar SAP (SQL)": {
      "main": [
        [
          {
            "node": "Success1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fallo1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enviar SAP (JSON)": {
      "main": [
        [
          {
            "node": "Success",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fallo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enviar SAP (SHEET)": {
      "main": [
        [
          {
            "node": "Success2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fallo2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enviar SAP (MANUAL)": {
      "main": [
        [
          {
            "node": "Success3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fallo3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 人工智能, IT 运维

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量22
分类2
节点类型9
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

外部链接
在 n8n.io 查看

分享此工作流