sap-client number conflict for new SAP user for IO fetch resolved

This commit is contained in:
laxmanhalaki 2026-04-29 08:26:16 +05:30
parent d01e248a35
commit 16deafd42d

View File

@ -16,6 +16,7 @@ export class SAPIntegrationService {
private sapServiceName: string; // OData service name for IO validation (e.g., ZFI_BUDGET_CHECK_API_SRV) 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 sapBlockServiceName: string; // OData service name for budget blocking (e.g., ZFI_BUDGET_BLOCK_API_SRV)
private sapRequester: string; // Requester identifier for budget blocking private sapRequester: string; // Requester identifier for budget blocking
private sapClientNum?: string; // Optional SAP Client number
constructor() { constructor() {
this.sapBaseUrl = process.env.SAP_BASE_URL || ''; 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'; this.sapBlockServiceName = process.env.SAP_BLOCK_SERVICE_NAME || 'ZFI_BUDGET_BLOCK_API_SRV';
// Requester identifier for budget blocking API // Requester identifier for budget blocking API
this.sapRequester = process.env.SAP_REQUESTER || 'REFMS'; 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 { try {
// Build service root URL with required query parameters // Build service root URL with required query parameters
const serviceRootUrl = `/sap/opu/odata/sap/${serviceName}/`; const serviceRootUrl = `/sap/opu/odata/sap/${serviceName}/`;
const queryParams = new URLSearchParams({ const params: Record<string, string> = { '$format': 'json' };
'$format': 'json' if (this.sapClientNum) {
}); params['sap-client'] = this.sapClientNum;
}
const queryParams = new URLSearchParams(params);
const fullUrl = `${this.sapBaseUrl}${serviceRootUrl}?${queryParams.toString()}`; const fullUrl = `${this.sapBaseUrl}${serviceRootUrl}?${queryParams.toString()}`;
logger.debug(`[SAP] Fetching CSRF token from service: ${serviceName}`); logger.debug(`[SAP] Fetching CSRF token from service: ${serviceName}`);
@ -275,12 +279,18 @@ export class SAPIntegrationService {
// $select: Select specific fields (Sender, ResponseDate, GetIODetailsSet01) // $select: Select specific fields (Sender, ResponseDate, GetIODetailsSet01)
// $expand: Expand the nested GetIODetailsSet01 entity set to get IO details // $expand: Expand the nested GetIODetailsSet01 entity set to get IO details
// $format: Explicitly request JSON format // $format: Explicitly request JSON format
const queryParams = new URLSearchParams({ const params: Record<string, string> = {
'$filter': `IONumber eq '${ioNumber}'`, '$filter': `IONumber eq '${ioNumber}'`,
'$select': 'Sender,ResponseDate,GetIODetailsSet01', '$select': 'Sender,ResponseDate,GetIODetailsSet01',
'$expand': 'GetIODetailsSet01', '$expand': 'GetIODetailsSet01',
'$format': 'json' '$format': 'json'
}); };
if (this.sapClientNum) {
params['sap-client'] = this.sapClientNum;
}
const queryParams = new URLSearchParams(params);
const fullUrl = `${endpoint}?${queryParams.toString()}`; const fullUrl = `${endpoint}?${queryParams.toString()}`;
@ -508,6 +518,7 @@ export class SAPIntegrationService {
const requestPayload = { const requestPayload = {
Request_Date_Time: requestDateTime, Request_Date_Time: requestDateTime,
Requester: this.sapRequester, Requester: this.sapRequester,
IODate: requestDateTime,
lt_io_input: [ lt_io_input: [
{ {
IONumber: ioNumber, IONumber: ioNumber,