如何在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(likeAPPLID,FIELDNAME) exactly match the column names of theIT_VALUESinternal 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 additionalHashMapobjects for each row and add them toitValuesTablewithitValuesTable.add(anotherRow).
内容的提问来源于stack exchange,提问作者user9856431
相关产品推荐
相关产品推荐

