You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在JavaScript中将数组/列值传入HashMap调用SAP函数模块

Passing SAP Internal Table Parameter IT_VALUES via JavaScript

Hey there! I see you've nailed the single parameter passing part, but need a hand with the internal table IT_VALUES—let's get that sorted out quickly.

In the Java-JavaScript bridge environment you're working with (since you're using java.util.HashMap), SAP internal tables are typically represented using Java ArrayList objects. Each entry in the ArrayList is a HashMap that maps the internal table's column names to their corresponding values, representing one row of data.

Here's the complete working code:

function ztest(Par){
    importClass(java.util.HashMap);
    importClass(java.util.ArrayList); // Don't forget this import!
    
    var inputParams = new HashMap();
    
    // Your existing single parameter setup
    inputParams.put("ID_DIALOG", 'DIA_LO_SRS');
    inputParams.put("ID_PERSKEYTYP", 'U');
    inputParams.put("ID_PERSKEY", 'USERID');
    inputParams.put("ID_ORIGIN", 'A' );
    
    // Handle the IT_VALUES internal table
    var itValuesTable = new ArrayList();
    
    // Create a row for your target data: APPLID=LO_SRS, FIELDNAME=PLANT, F=V, LOW=4060
    var tableRow = new HashMap();
    tableRow.put("APPLID", "LO_SRS");
    tableRow.put("FIELDNAME", "PLANT");
    tableRow.put("F", "V");
    tableRow.put("LOW", "4060");
    
    // Add the row to the internal table list
    itValuesTable.add(tableRow);
    
    // If you need to pass multiple rows, just repeat the row creation step and add each to itValuesTable
    
    // Attach the internal table to your input parameters
    inputParams.put("IT_VALUES", itValuesTable);
    
    return inputParams;
}

// Execute the function module as you normally would
var bapiRet = mConnection.runFunction("FPB_PERS_POST_FOR_DIALOG", ztest());

Quick Tips to Avoid Issues:

  • Ensure you import java.util.ArrayList—this is essential for mimicking the SAP internal table structure.
  • Double-check that the keys in each row's HashMap (like APPLID, FIELDNAME) exactly match the column names of the IT_VALUES internal table in your SAP function module. SAP uses uppercase for these by default, so keep the casing consistent.
  • For multiple rows in IT_VALUES, just create additional HashMap objects for each row and add them to itValuesTable with itValuesTable.add(anotherRow).

内容的提问来源于stack exchange,提问作者user9856431

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 07:16:24