From 16deafd42d756833d8f62c299f9ee76d4c580cb2 Mon Sep 17 00:00:00 2001 From: laxmanhalaki Date: Wed, 29 Apr 2026 08:26:16 +0530 Subject: [PATCH] sap-client number conflict for new SAP user for IO fetch resolved --- src/services/sapIntegration.service.ts | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/services/sapIntegration.service.ts b/src/services/sapIntegration.service.ts index 897e4c4..3f6b7d8 100644 --- a/src/services/sapIntegration.service.ts +++ b/src/services/sapIntegration.service.ts @@ -16,6 +16,7 @@ export class SAPIntegrationService { private sapServiceName: string; // OData service name for IO validation (e.g., ZFI_BUDGET_CHECK_API_SRV) private sapBlockServiceName: string; // OData service name for budget blocking (e.g., ZFI_BUDGET_BLOCK_API_SRV) private sapRequester: string; // Requester identifier for budget blocking + private sapClientNum?: string; // Optional SAP Client number constructor() { this.sapBaseUrl = process.env.SAP_BASE_URL || ''; @@ -28,6 +29,7 @@ export class SAPIntegrationService { this.sapBlockServiceName = process.env.SAP_BLOCK_SERVICE_NAME || 'ZFI_BUDGET_BLOCK_API_SRV'; // Requester identifier for budget blocking API this.sapRequester = process.env.SAP_REQUESTER || 'REFMS'; + this.sapClientNum = process.env.SAP_CLIENT; // Only use if explicitly provided } /** @@ -59,9 +61,11 @@ export class SAPIntegrationService { try { // Build service root URL with required query parameters const serviceRootUrl = `/sap/opu/odata/sap/${serviceName}/`; - const queryParams = new URLSearchParams({ - '$format': 'json' - }); + const params: Record = { '$format': 'json' }; + if (this.sapClientNum) { + params['sap-client'] = this.sapClientNum; + } + const queryParams = new URLSearchParams(params); const fullUrl = `${this.sapBaseUrl}${serviceRootUrl}?${queryParams.toString()}`; logger.debug(`[SAP] Fetching CSRF token from service: ${serviceName}`); @@ -275,12 +279,18 @@ export class SAPIntegrationService { // $select: Select specific fields (Sender, ResponseDate, GetIODetailsSet01) // $expand: Expand the nested GetIODetailsSet01 entity set to get IO details // $format: Explicitly request JSON format - const queryParams = new URLSearchParams({ + const params: Record = { '$filter': `IONumber eq '${ioNumber}'`, '$select': 'Sender,ResponseDate,GetIODetailsSet01', '$expand': 'GetIODetailsSet01', '$format': 'json' - }); + }; + + if (this.sapClientNum) { + params['sap-client'] = this.sapClientNum; + } + + const queryParams = new URLSearchParams(params); const fullUrl = `${endpoint}?${queryParams.toString()}`; @@ -508,6 +518,7 @@ export class SAPIntegrationService { const requestPayload = { Request_Date_Time: requestDateTime, Requester: this.sapRequester, + IODate: requestDateTime, lt_io_input: [ { IONumber: ioNumber,