sap-client number conflict for new SAP user for IO fetch resolved
This commit is contained in:
parent
d01e248a35
commit
16deafd42d
@ -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<string, string> = { '$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<string, string> = {
|
||||
'$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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user