Connector for SAP Business Suite - Developer's Guide, Part 5 - Add-ons

The connector for SAP Business Suite offers functional enhancements in the form of add-ons. These add-ons can be used on Intrexx pages with Velocity calls or in Intrexx processes using Groovy scripts. Please note that add-ons may be subject to specific licensing terms or require a minimum license.

Use in Velocity

On application pages, add-ons can be created using the " Static Text " element with the option "Programming, Standard Language Only"

or included using a VTL include element.

The add-on is initialized via the connector for SAP Business Suite and references

  • the add-on's ID

  • the SAP data source

  • the application that uses it

Example (for the "sapbop" add-on):

            #set( $api = $GSAP.getAddOn('sapbop', 'saperp', $Request) )

        

The variable "$api" then provides access to the add-on's functions and can also be called using the shorthand form:

            $GSAP.getAddOn('sapbop', 'saperp', $Request).<api-methode-addon>

        

Usage in a Groovy script

The usage in Groovy is similar to that in Velocity. The following sample code is used for all add-ons (here, "sapbop").

            import net.initall.ixapi.groovy.IxSapGroovyAPI;
def g_sap = IxSapGroovyAPI.getInstance();
if(g_sap == null){
g_log.error("No SAP Adapter access");
}else{
// syntax: getAddOn(<addonname>, <sap instance>, g_record);
def g_api = g_sap.getAddOn("sapbop", "saperp", g_record);
if(g_api == null){
g_log.error("No SAP Adapter Addon access");
}else{
// use addon api -- insert your code
// destroy addon api
g_api.destroy();
}
g_sap.destroy();
}

        

sapbop Add-On – Business Object Documents

Business Object Documents are the implementation of object-oriented forms that are designed to look the same across all user interfaces (e.g., SAPGUI, Internet Portal, mobile devices). The connector for SAP Business Suite provides functions for handling documents such as PDFs, technical drawings, and the like. to make it available on all user interfaces. Documents are generated in the SAP system, and in most cases, this process uses the SAP standard "Smartforms" and "Report" features. This allows various forms (e.g., customer master sheet, visit report, surgery list, etc.) to be made available across different areas for the "Customer" object (technically "KNA1"), for example.

Configuration

Business object documents are configured in the SAP system under the Customizing settings for the portal plug-in in the "Extensions" folder.

Handler

Handlers have already been prepared for the most important generation types and are included in the standard delivery:

  • /IATL/POPI_IXAPI_SMARTFORM

    Calling Smart Forms Using the POPI API

  • /IATL/POPI_IXAPI_REPORT

    Retrieving Reports Using the POPI API

  • /IATL/POPI_IXAPI_NO_DOC

    Dummy handler for hiding

  • /IATL/POPI_IXAPI_CFW_FORM

    Opening Forms in the FW Cockpit

  • /IATL/POPI_IXAPI_DEFAULT

    Template; also Quick Save

There may be additional handlers in the systems. With just a few adjustments, you can also integrate your own handlers using inheritance. This is necessary, for example, to customize the API of specific SmartForm forms or reports. In most cases, no configuration is required here.

Documents and Variants

In the Customizing option "Business Object Documents – Configuration," you maintain business objects, their variants, and their association with a handler.

The following entry, for example, allows you to run the report "/IATL/POPI_IXAPI_BODOC_REP" using the parameters "Object Type = 'KNA1'" and "Variant/Subtype = 'TEST'". The "/IATL/POPI_IXAPI_BODOC_REP" report can also be used as a template for your own implementations.

Test

The "Test Business Object Document" option provides a simple way to test the system.

The "popup" test is supported only if the handler supports it. However, this is the case with Smartforms and reports.

When you run this, the document is displayed in the SAP system—here as a PDF. This function can also be used in the SAPGUI within standard processes.

Running as a file stream (with the pop-up option disabled) performs the actual operation—making a file available for external use.

This call displays only the file information that would be available to an external call.

This test program can also be used to clear the internal cache or to pre-generate documents in batch mode.

Custom Handlers

Custom handlers are required if the programs that generate the data already exist (e.g., reports, Smartforms). At the very least, the call interface needs to be modified here. This section describes the procedure for calling transaction "MB53." The program "RM07MWRKK" is associated with this transaction.

To generate a PDF version of this report, you must implement your own handler that precisely implements the report's interface. To call reports, the connector for SAP Business Suite provides the class "/IATL/POPI_CL_IXAPI_BUSDOC_REP" on the ABAP side. First, create an SAP ABAP class that inherits from this handler. Next, the "REPORT_MODIFY_PARAMETERS" method is inherited and modified. The code for calling transaction "MB53" is shown below.

            METHOD report_modify_parameters.
* -------- local data
DATA: ls_params LIKE LINE OF ct_params.
DATA: lv_matnr TYPE matnr.
* -------- call super
CALL METHOD super->report_modify_parameters
CHANGING
cv_program = cv_program
cv_variant = cv_variant
ct_params = ct_params
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
RAISE failed.
ENDIF.
* -------- set defaults for report calling
cv_program = 'RM07MWRKK'.
* -------- get prefilled id and map
LOOP AT ct_params INTO ls_params
WHERE selname = 'ID'.
ls_params-selname = 'MATNR'.
lv_matnr = ls_params-low.
ls_params-low = lv_matnr.
MODIFY ct_params FROM ls_params.
ENDLOOP.
ENDMETHOD.

        

This code should be easy to understand. The selection parameters are made available in the "RSPARAMS" structure within the "ct_params" parameter. The ID passed from an external source is stored as the "ID" selection parameter and must be converted. If necessary, the ID can also be checked and, if needed, modified (e.g., by adding leading zeros). The next step registers the class you just created as a handler in Customizing.

The handler can then be assigned to a specific business object (in this case, "MARA" and "MB53").

You can use the test transaction to immediately verify whether the class works. You can also debug from here.

Selecting "as a popup" launches the report in view mode.

The PDF is generated without the pop-up feature, but it cannot be viewed here.

If there are existing Smart Forms that you want to open, the procedure is the same as for reports. Use "/IATL/POPI_CL_IXAPI_BUSDOC_SF" as the base class. The Smartform API function module is called in the "SMARTFORM_CALL" method. Depending on the SmartForm API, data retrieval may be more extensive. The following code demonstrates this for calling Smart Forms for delivery slips.

            method smartform_call.
data: ls_nast type nast.
data: ls_likp type likp.
data: ls_document_output_info type ssfcrespd.
data: ls_job_output_info type ssfcrescl.
data: ls_job_output_options type ssfcresop.
data: ls_dlv_delnote type ledlv_delnote.
data: ls_delivery_key type leshp_delivery_key.
data: ls_print_data_to_read type ledlv_print_data_to_read.
data: lf_parvw type sna_parvw.
data: lf_parnr type na_parnr.
data: lf_language type na_spras.
data: lv_vbeln type vbeln.
data: lv_saved_langu type sylangu.
field-symbols: <parnr> type any.
* -------- check likp
lv_vbeln = me->current_id.
select single * from likp
into ls_likp
where vbeln = lv_vbeln.
if sy-subrc ne 0.
trace( 'wrong likp' ).
raise failed.
endif.
* -------- prepare access
lf_language = me->current_language.
ls_delivery_key-vbeln = lv_vbeln.
translate ls_print_data_to_read using ' X'.
lf_parvw = 'AG'.
if me->cust_doc-param_2 ne space.
lf_parvw = me->cust_doc-param_2.
endif.
lf_parnr = ls_likp-kunag.
if me->cust_doc-param_3 ne space.
unassign <parnr>.
assign component me->cust_doc-param_3 of structure ls_likp
to <parnr>.
if <parnr> is not assigned.
trace( 'wrong param 3. field not exists in table likp.' ).
raise failed.
endif.
endif.
* --------- call data preparation
call function 'LE_SHP_DLV_OUTP_READ_PRTDATA'
exporting
is_delivery_key = ls_delivery_key
is_print_data_to_read = ls_print_data_to_read
if_parvw = lf_parvw
if_parnr = lf_parnr
if_language = lf_language
importing
es_dlv_delnote = ls_dlv_delnote
exceptions
records_not_found = 1
records_not_requested = 2
Intrexx Business Adapter - SAP
United Planet Seite 306
others = 4.
if sy-subrc <> 0.
trace( 'Error calling data likp read module.' ).
raise failed.
endif.
* ----------- call smartform
lv_saved_langu = sy-langu.
sy-langu = me->current_language.
catch system-exceptions others = 1.
call function me->sf_function
exporting
archive_index = archive_index
archive_index_tab = archive_index_tab
archive_parameters = archive_parameters
control_parameters = control_parameters
mail_appl_obj = mail_appl_obj
mail_recipient = mail_recipient
mail_sender = mail_sender
output_options = output_options
user_settings = user_settings
is_dlv_delnote = ls_dlv_delnote
is_nast = ls_nast
importing
document_output_info = document_output_info
job_output_info = job_output_info
job_output_options = job_output_options
exceptions
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
others = 5.
sy-langu = lv_saved_langu.
if sy-subrc ne 0.
trace( 'Error calling smartform.' ).
raise failed.
endif.
endcatch.
if sy-subrc ne 0.
trace( 'Error calling smartform module.' ).
raise failed.
endif.
endmethod.

        

API Methods

Creating Links:

  • String getBoImage(String p_objtype, String p_subobj, String p_objid)

    Creates an icon with a link to the document if the business object has been configured in the SAP system. For example, this icon can always be placed after an object ID in the interface.

  • String getBoLink(String p_objtype, String p_subobj, String p_objid, String p_text, String p_style)

    This function creates a text link to the document. Here, you can specify the text to be displayed in the "p_text" parameter and a style for the HTML element <a></a> (optional).

  • String getBoURL(String p_objtype, String p_subobj, String p_objid)

    If only the URL to the document is needed (e.g., because it is to be used in your own HTML generation), you can use this function.

Configuration:

setImageNormal(String p_image) setImageHover(String p_image) Set a custom image for the link

Examples

Velocity long call:

            #set( $Api = $GSAP.getAddOn('sapbop', 'saperp', $Request) )
#if( $Api )
#set( $strId = $DC.getValueHolder('textvcontrol159CC346').getValue())
$Api.getBoImage('LIKP', '', $strId)
#else
##<b>No API<b/>#end

        

Velocity Quick Guide:

            $GSAP.getAddOn('sapbop', 'saperp', $Request).$Api.getBoLink('LIKP', '', '0080000031', 'Text', '')

        

More Information

General Information

Installation

Create a connection

Integration into Applications

SAP Script Generator

SAP Trust Manager SSO Configuration

API Description, Part 1 - Overview

API Description, Part 2 - SAP Portal Plugin

API Description, Part 3 - Implementing Custom Processing Modules

API Description, Part 4 - Sample Code

Developer's Guide, Part 1

Developer's Guide, Part 2 - Integration Scenario: SAP External Data Group

Developer's Guide, Part 3 - Integration Scenario: Scripting

Developer's Guide, Part 4 - Personalized SAP Access / Single Sign-On (SSO)

Developer's Guide: Appendix

Developer's Guide - Sample Code