Wednesday, August 27, 2014

SAP JCo - An example program to establish the connection

import java.io.File;
import java.io.FileOutputStream;
import java.util.Properties;
import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoDestinationManager;
import com.sap.conn.jco.JCoFunction;
import com.sap.conn.jco.ext.DestinationDataProvider;

public class BAPICallTest {

    static String DESTINATION_NAME1 = "ABAP_AS_WITHOUT_POOL";

    static String DESTINATION_NAME2 = "ABAP_AS_WITH_POOL";

    static {
        Properties connectProperties = new Properties();
        connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, "host name");
        connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, "system number");
        connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, "Client");
        connectProperties.setProperty(DestinationDataProvider.JCO_USER, "user name");
        connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, "password");

        connectProperties.setProperty(DestinationDataProvider.JCO_LANG, "en");
        createDestinationDataFile(DESTINATION_NAME1, connectProperties);
        connectProperties.setProperty(DestinationDataProvider.JCO_POOL_CAPACITY, "3");
        connectProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT, "10");
        createDestinationDataFile(DESTINATION_NAME2, connectProperties);
    }

    static void createDestinationDataFile(String destinationName, Properties connectProperties) {
        File destCfg = new File(destinationName + ".jcoDestination");
        try {
            FileOutputStream fos = new FileOutputStream(destCfg, false);
            connectProperties.store(fos, "for tests only !");
            fos.close();
        } catch (Exception e) {
            throw new RuntimeException("Unable to create thedestination files", e);
        }
    }

    public static void main(String[] args) throws Exception {
        JCoDestination destination1 = JCoDestinationManager.getDestination("DESTINATION_NAME1");
        System.out.println(destination1);
        System.out.println("Destination 1 Attributes:");
        System.out.println(destination1.getAttributes());

        JCoDestination destination2 = JCoDestinationManager.getDestination("DESTINATION_NAME2");
        System.out.println(destination2);
        System.out.println("Destination 2 Attributes:");
        System.out.println(destination2.getAttributes());

        JCoFunction function = destination2.getRepository().getFunction("STFC_CONNECTION");
        function.execute(destination2);
    }
}


The above program gets attributes of SAP server. It uses direct connection and connection pool.

Saturday, August 16, 2014

BAPI for Material master - Number range

BAPI_MATERIAL_SAVEDATA is the BAPI available for Material master creation.

Material number range is (i.e internal or external) depending on the Material type. BAPI_MATERIAL_GETINTNUMBER BAPI can be used for getting material number based on the Material type.

CALL FUNCTION 'BAPI_MATERIAL_GETINTNUMBER' "Assign New Internal Numbers for a Material Type
EXPORTING
material_type = " bapimatdoa-matl_type Material type
* industry_sector = SPACE " bapimatdoa-ind_sector Industry sector
* required_numbers = 1 " bapimatall-req_numbers Set of material numbers required
IMPORTING
return = " bapireturn1 Return Parameter
TABLES
material_number = " bapimatinr Material numbers assigned
. " BAPI_MATERIAL_GETINTNUMBER

Wednesday, August 13, 2014

BAPI Vendor master data



There is no standard BAPI for Vendor master data. BAPI_VENDOR_CREATE it simply calls the transaction code 'XK01'. It can be used to create an online vendor.

      There are two alternative ways you can follow,

1.First, you can use the function module VENDOR_INSERT - To insert the vendor in vendor master.

2. Creating a custom BAPI using standard API class VMD_EI_API.
VMD_EI_API-->GET_NUMBER - Get Vendor Number
VMD_EI_API-->MAINTAIN - Create vendor

Login to SAP through Windows command prompt


Start -> Run -> CMD,
execute the following command
sapshcut.exe -system=SID -client=CLIENT -user=NAME -pw=PASSWORD

where
SID - 3 characters system ID.  i.e ECC
CLIENT - Logon client.  i.e 800
NAME - Username
Password - Logon Password

Note : SAP GUI must be installed in your system. 

Open SAP A Great Opportunity!!


How can you balance your busy work schedule, while learning how SAP innovations could potentially transform your business? With openSAP, of course! Whether you’re an SAP professional, developer, consultant, entrepreneur, professor or student you can keep up to date with the latest innovations from SAP.


openSAP is SAP’s innovative learning platform and a thought leader for Enterprise MOOCs (Massive Open Online Courses).


openSAP gives you maximum flexibility to learn at your convenience. Compared to traditional e-learning, it provides you with an engaging and effective learning experience through gamification and by connecting you with other learners and SAP experts.


openSAP courses are free of charge (except for optional system access) and are offered in English. See our openSAP course listings for more information.


Visit SAP Education to find out about further training related to your openSAP course. You can also find a complete overview of SAP Education´s training offerings under SAP Training and Certification Shop.

https://open.sap.com/