cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Script parameters in SAP Build Process Automation

eliasfa
Discoverer
0 Kudos
175

I am trying to figure out how to input and output custom variables in a custom script in SAP Build Process Automation. It seems that the input parameter is not inputting any value into the script and it is not outputting anything either. The error I receive when trying to use the output param is 

"Invalid Argument: CommonFunctions.set: no valid value provided"

The script(step 116 of the automation) is as follows:

 

function convertWarehouseNum(warehouseNumOfPlantToCopyFrom) {
   
    const match = warehouseNumOfPlantToCopyFrom.match(/^([a-zA-Z]+)(\d+)$/);
   
    if (!match) {
        throw new Error('Invalid input format');
    }

    const letter = match[1];
    const number = match[2];
   
    // Increment the number by 1
    const incrementedNumber = (parseInt(number, 10) + 1).toString().padStart(number.length, '0');
   
    // Return the new string with the incremented number
    const warehouseNum = letter + incrementedNumber;

    return warehouseNum;
}
 
The input parameter is Step115.warehouseNumOfPlantToCopyFrom (output param of previous step)
The output parameter is Step116.warehouseNum
 
Please let me know if there is a solution.
 
Thanks
eliasfa
Discoverer
0 Kudos
Figured it out, new code had an error listed in the console but ran it anyways and it worked.
View Entire Topic
eliasfa
Discoverer
0 Kudos

Figured it out, new code had an error listed in the console but ran it anyways and it worked.

 

var match = copiedPlant.match(/^([a-zA-Z]+)(\d+)$/);
   
if (!match) {
    throw new Error('Invalid input format');
}

var letter = match[1];
var number = match[2];
   
// Increment the number by 1
var incrementedNumber = (parseInt(number, 10) + 1).toString().padStart(number.length, '0');
   
//Return the new string with the incremented number
var warehouseNum = letter + incrementedNumber;

return warehouseNum;