Archive

Posts Tagged ‘API’

SAP KM API – Copy KM Folders

August 3rd, 2011 No comments

Below code snip can be used to copy one KM folder and its subfolders to another location.

Note:

1. The destination folder shouldn’t exist before the copy. Otherwise the copy method will raise an exception.

2. The source folder display name are copied too. It might need to be changed if necessary.

String source = ";/documents/source";;
String destination = ";/documents/destination";;
 
try {
	//1. Create a RID
	RID aRid = RID.getRID(source);
	logger.errorT(aRid.getPath());
	//2. Get Resource Factory
	IResourceFactory resourceFactory = ResourceFactory.getInstance();
	//3. Get user and resource context
	com.sapportals.portal.security.usermanagement.IUser user =
		WPUMFactory.getServiceUserFactory().getServiceUser(";cmadmin_service";);
	ResourceContext rContext = new ResourceContext(user);
	//4. Retrieve the collection for Resource using the resource context
	IResource aResource = resourceFactory.getResource(aRid, rContext);
	//5. Get Destination RID
	RID dRid = RID.getRID(destination);
	logger.errorT(dRid.getPath());
	IResource dResource = aResource.copy(dRid, new CopyParameter());
 
	dResource.setProperty(new Property(PropertyName.createDisplayname(), ";destination";));
 
	logger.errorT(";After Copy";);
} catch (ResourceException e) {
	logger.errorT(";ResourceException INSIDE copy(): "; + e.toString());
} catch (UserManagementException e) {
	logger.errorT(";UserManagementException INSIDE copy(): "; + e.toString());
}
 
wdControllerAPI.getComponent().getMessageManager().reportSuccess(";Files are copied successfully.";);

SAP UME API

May 26th, 2010 2 comments

In my previous blog SAP UME Configuration, I explained how to configure UME utilize ABAP user management. During web development, we always need to do coding for authorization or  user management like search, creation and change. SAP provides an set of API for this purpose.

The UME API document can be visited at: http://help.sap.com/javadocs/NW04S/current/se/com/sap/security/api/IUserFactory.html

Before using these API, you need to add the public part of DC com.sap.security.api to your custom DCs like web dynpro which locates in software component SAP-JEE.

Read more…

ALSM_EXCEL_TO_INTERNAL_TABLE

April 29th, 2010 1 comment

Many customers need a function that allows them to transfer values from an Excel table to the SAP system. Up to now there has been no formally released interface for this.

For the Asset Accounting legacy data transfer, a module was written to transfer the Excel data using the clipboard of the Windows system by OLE (Object Linking and Embedding. This module is called ALSM_EXCEL_TO_INTERNAL_TABLE. The module was only designed for the requirements of the Asset Accounting legacy data transfer. This leads to some restrictions, including the following:

Read more…

BAPI_GOODSMVT_CREATE for goods movements

April 17th, 2010 2 comments

SAP Note 520813 – FAQ: BAPIs for goods movements contains frequently asked questions/answers regarding ‘BAPIs for goods movements’. I just picked out some questions for your reference. For detail information, please visit SAP service marketplace.

Question:
Which function modules must be called after the BAPI is called to complete the posting once the material document has been created successfully? What should I do if there is an error?

Answer:
The BAPI returns a return table for the error handling, that is, if the posting is incorrect, this table contains an entry describing the cause of the error. The ‘caller’ is responsible for evaluating this table and for triggering the update that is dependent on this.

If the posting is correct (return table is initial), a ‘Commit Work’ must be carried out in order to complete the posting. To do this, call BAPI_TRANSACTION_COMMIT.

The Commit or rollback always applies to the current LUW (Logical Unit of Work). Therefore, you must make sure that it is carried out at the correct point in the source code. More information about this is available in the documentation for BAPI_TRANSACTION_COMMIT or …_ROLLBACK.

A detailed description is available in Note 457499.

Read more…

CS_BOM_EXPL_MAT_V2

April 10th, 2010 No comments

Application Area – ERP-PP

Description

Function module CS_BOM_EXPL_MAT_V2 is used for BOM explosion for a given material. It belongs to function group CSS4 – BOM explosions. This function module can explose multi-level BOM with a given validation date.

You need to specify necessary input parameters to call this function module, such as CAPID – App ID, DATUV – Validation date, MEHRS – Multi-level, MTNRV – Material number, STLAL – alternate, STLAN – BOM usage.

Some useful tables are also listed here.

TABLES: MARA,                               "Master Data
        MAKT,                               "Matl Desc.
        MARC,                               "Plant Data for Matl.
        MAST,                               "Bom to material link
        STKO,                               "Bom Header
        STPO.                               "Bom Item

Read more…

CRM_ORDER_MAINTAIN

April 9th, 2010 No comments

Application Area – CRM,Solution Manager

Description

Function module CRM_ORDER_MAINTAIN is one of the most important function modules in SAP CRM and SAP Solution Manager business transactions processing. Other useful function modules are CRM_ORDER_READ and CRM_ORDER_SAVE.

The function module will call some underlying function modules to save the changes to database. The most important task of calling this function module is to maintain the input fields internal table. You can maintain every information belongs to the business transaction.

The input field structure contains several components. Field ref_guid represents the GUID of the changed structure. Ref_kind has several possible values. A for Administration Header, B for Administration Item, C for Header Extension, D for Item Extension. You also need to populate FIELD_NAMES internal tables to decide which fields in the destination structure needs to be changed.

Read more…

Common ABAP Function Modules – 2

March 9th, 2010 2 comments

Application Area – BC

Overview

This post lists function modules related to data formatting and conversion.

Function Modules Detail – Data Formatting and Conversion

a) CONVERSION_EXIT_ALPHA_INPUT – ALPHA conversion is used especially with account numbers. During conversion from the external to the internal format, the system checks to see if input in the INPUT field is purely numeric, that is, if this input consists only of numbers, possibly with spaces before and after them. If this is the case, then the number string is inserted right- justified in the display field OUTPUT and all spaces to the left of the value are filled with zeroes (’0′). If the input is not purely numeric, it is inserted in the display field from left to right and all extra spaces are filled with blanks.

Example:

(Input field and output field are both eight characters in length)

1. ’1234 ‘ –> ’00001234′
2. ‘ABCD ‘ –> ‘ABCD ‘
3. ‘ 1234 ‘ –> ’00001234′

Read more…