Start of Content Area

Procedure documentation Setting Scalar Import Parameters  Locate the document in its SAP Library structure

Use

This step calls the BAPI CompanyCode.GetDetail for each company code. The corresponding RFM is BAPI_COMPANYCODE_GETDETAIL. For this RFM, you need to set the scalar import parameter COMPANYCODEID.

 

Activities

...

       1.      To access the import parameter list, use getImportParameterList().

       2.      The value of the scalar parameter is set using setValue(), in which first the value, and then the name are entered. There are many different versions of setValue() in the SAP JCo to support all existing Data Types .

       3.      SAP JCo converts the values and transfers them to the data type that is assigned to the field. If an error occurs during the conversion, an exception is thrown. The method setValue() is also available in JCO.Structure, JCO.Table, and JCO.Field . You can therefore set values from structure fields and fields in a row of a table.

Syntax documentation

Setting Scalar Import Parameters

 codes.firstRow();

for (int i = 0; i < codes.getNumRows(); i++, codes.nextRow() ) {

   function = this.createFunction (“BAPI_COMPANYCODE_GETDETAIL“);

   function.getImportParameterList ().

      setValue(codes.getString(“COMP_CODE“),   “COMPANYCODEID“);

   mConnection.execute(function);

   JCO.Structure returnStructure =

      function.getExportParameterList ().getStructure(“RETURN“);

   if  (!  (returnStructure.getString(„Type“).equals(““)  | |

            returnStructure.getString(„Type“).equals(“S“)  | |

            returnStructure.getString(„Type“).equals(“W“) )  )  {

      System.out.println(returnStructure.getString(“MESSAGE“));

   }

   JCO.Structure detail =

      function.getExportParameterList ().

      getStructure(“COMPANYCODE_GETDETAIL“);

   System.out.println(detail.getString(“COMP_CODE“)  +  ‚\t‘  +

                                 detail.getString(“COUNTRY“)  +  ‚\t‘  +

                                 detail.getString(“CITY“) );

}

 

       4.      You call firstRow() before the loop, because the row pointer for the table is located on the last row as a result of the previous loop.

 

Note

Note that in the BAPI error handling displayed here, “W“ (warning) is accepted as well as empty string or ”S“ (success).

This occurs because this particular BAPI sometimes outputs the warning that address data has not been maintained (in the structure parameter COMPANYCODE_ADDRESS). In the current example program this parameter is not relevant, so the warning can be ignored.In a productive program, error handling must be more precisely configured and must also check the number of the warning message.

 

 

End of Content Area