PreviousNext
Help > Programming with LAUNCHER Office > Java classes > Use examples > 9) LNCTOXLS : SAP – Using BAPI
9) LNCTOXLS : SAP – Using BAPI

In this example, the database has the following characteristics :

         Type DB: SAP

         SAP server address: 192.168.1.7

         SAP user: DDIC

         SAP user password: aura

         BAPI name: BAPI_FLBOOKING_GETLIST

         Result table used to export to Excel: BOOKING_LIST

         Parameter of the BAPI: MAX_ROWS=7

 

The command LNCTOXLS is used to generate the following Excel file:
C:\temp\sap_test.xlsx

 

 

     String Destination="C:\\temp\\sap_test.xlsx";

     String template="C:\\temp\\SBOOK_template_BAPI.xlsx";

      // Create a hash map
      Map<String,String> hm = new HashMap<String,String>();

     // Put elements to the map
     hm.put("MAX_ROWS", "70");

     DataSource myDataSource = new DataSource();
     myDataSource.setType("sapbapi");
     myDataSource.setUser("DDIC");
     myDataSource.setPassword("aura");
     myDataSource.setAshostSAP("192.168.1.7");
     myDataSource.setClientSAP("001");
     myDataSource.setLangSAP("");
     myDataSource.setSysnrSAP("00");
     myDataSource.setGwhostSAP("192.168.1.7");
     myDataSource.setGwservSAP("3300");
     myDataSource.setBAPIName("BAPI_FLBOOKING_GETLIST");
     myDataSource.setBAPIResultTable("BOOKING_LIST");
     myDataSource.setParameterMap(hm);

 

     LNCTOXLS myLNCTOXLS = new LNCTOXLS();
     myLNCTOXLS.setToXls("*new");
     myLNCTOXLS.setAutoFit("true");
     myLNCTOXLS.setFmtCells("false");
     myLNCTOXLS.setAddColH("false");
     myLNCTOXLS.setShowDoc("false");
     myLNCTOXLS.setSourceData(myDataSource);
     myLNCTOXLS.setLNCSrvAddr("192.168.1.9");
     myLNCTOXLS.setSavFmt("*NORMAL");
     myLNCTOXLS.setSavDoc(Destination);

     myLNCTOXLS.execute();