IBM BPM, V8.0.1, All platforms > Authoring services in Integration Designer > Services and service-related functions > Access external services with adapters > Configure and using adapters > IBM WebSphere Adapters > SAP Software > Troubleshooting and support

Resolving errors during Query interface for SAP Software processing

To avoid data being wrongly truncated with a delimiter, you must change the default function module used by the adapter to retrieve data from SAP tables in the query interface for SAP Software, which processes non-unicode systems for other than English languages.

You must have developer access to SAP system and you should have basic knowledge of advanced business application programming (ABAP) to create a custom module.

On non-unicode systems, the default function used to retrieve data from SAP tables (RFC_READ_TABLE) might truncate the data wrongly. To avoid the data being wrongly truncated, create a custom function on the SAP server and use this newly created function to retrieve data.

Use the following procedure to create the custom retrieve function and to specify it during configuration:


Procedure

  1. Enter an appropriate delimiter in the XSD schema file. In the case of KNA1, the schema generated is SapKna1.xsd.
  2. Open this file in a text editor. Ensure that the entered delimiter is unique. By default, the value is set to the pipe symbol (|).

  3. In the SAP EIS, Go to SE37 tcode, click Goto > Function Groups > Create Group. The Create Function Group window is displayed.

  4. In the Function Group field, type ZRFC_READ_TABLE as the function group name.

  5. In the Short text field, type a short description for the function group.

    For example, type function Group for ZRFC_READ_TABLE as short text for the function group.

  6. In the Person Responsible field, type the name of the person responsible for creating the function group. Click Save.

  7. Go to SE80 tcode to activate the function group.

  8. Select the package name where you have saved the ZRFC_READ_TABLE.

  9. Click the display button and expand Function Groups.

  10. Select ZRFC_READ_TABLE , select Activate using right-click option.

  11. Go to SE37 tcode to copy the function group.

  12. In the Function Module field, enter ZRFC_READ_TABLE.

  13. Click Function Module > Other Functions > Copy. The Copy Function Module window is displayed.

  14. In the fr. Function module field, type RFC_READ_TABLE.

  15. In the To Function module field, type ZRFC_READ_TABLE.

  16. In the Function group field, type ZRFC_READ_TABLE. Click Copy. Click Change in the SE37 tcode window.

  17. Select Source code tab and copy the following code:

    FUNCTION ZRFC_READ_TABLE.
    *"----------------------------------------------------------------------
    *"*"Local interface:
    *"  IMPORTING
    *"     VALUE(QUERY_TABLE) LIKE  DD02L-TABNAME
    *"     VALUE(DELIMITER) LIKE  SONV-FLAG DEFAULT SPACE
    *"     VALUE(NO_DATA) LIKE  SONV-FLAG DEFAULT SPACE
    *"     VALUE(ROWSKIPS) LIKE  SOID-ACCNT DEFAULT 0
    *"     VALUE(ROWCOUNT) LIKE  SOID-ACCNT DEFAULT 0
    *"  TABLES
    *"      OPTIONS STRUCTURE  RFC_DB_OPT
    *"      FIELDS STRUCTURE  RFC_DB_FLD
    *"      DATA STRUCTURE  TAB512
    *"      WA1 STRUCTURE  TAB512
    *"  EXCEPTIONS
    *"      TABLE_NOT_AVAILABLE
    *"      TABLE_WITHOUT_DATA
    *"      OPTION_NOT_VALID
    *"      FIELD_NOT_VALID
    *"      NOT_AUTHORIZED
    *"      DATA_BUFFER_EXCEEDED
    *"----------------------------------------------------------------------
    "
    CALL FUNCTION 'VIEW_AUTHORITY_CHECK'
         EXPORTING
              VIEW_ACTION                    = 'S'
              VIEW_NAME                      = QUERY_TABLE
         EXCEPTIONS
              NO_AUTHORITY                   = 2
              NO_CLIENTINDEPENDENT_AUTHORITY = 2
              NO_LINEDEPENDENT_AUTHORITY     = 2
              OTHERS                         = 1.
    
    IF SY-SUBRC = 2.
      RAISE NOT_AUTHORIZED.
    ELSEIF SY-SUBRC = 1.
      RAISE TABLE_NOT_AVAILABLE.
    ENDIF.
    
    * ----------------------------------------------------------------------
    *  find out about the structure of QUERY_TABLE
    * ----------------------------------------------------------------------
    DATA BEGIN OF TABLE_STRUCTURE OCCURS 10.
            INCLUDE STRUCTURE DFIES.
    DATA END OF TABLE_STRUCTURE.
    "DATA TABLE_HEADER LIKE X030L.
    DATA TABLE_TYPE TYPE DD02V-TABCLASS.
    
    CALL FUNCTION 'DDIF_FIELDINFO_GET'
      EXPORTING
        TABNAME              = QUERY_TABLE
    *   FIELDNAME            = ' '
    *   LANGU                = SY-LANGU
    *   LFIELDNAME           = ' '
    *   ALL_TYPES            = ' '
    *   GROUP_NAMES          = ' '
      IMPORTING
    *   X030L_WA             =
        DDOBJTYPE            = TABLE_TYPE
    *   DFIES_WA             =
    *   LINES_DESCR          =
      TABLES
        DFIES_TAB            = TABLE_STRUCTURE
    *   FIXED_VALUES         =
      EXCEPTIONS
        NOT_FOUND            = 1
        INTERNAL_ERROR       = 2
        OTHERS               = 3
              .
    IF SY-SUBRC <> 0.
      RAISE TABLE_NOT_AVAILABLE.
    ENDIF.
    IF TABLE_TYPE = 'INTTAB'.
      RAISE TABLE_WITHOUT_DATA.
    ENDIF.
    
    * ----------------------------------------------------------------------
    *  isolate first field of DATA as output field
    *  (i.e. allow for changes to structure DATA!)
    * ----------------------------------------------------------------------
    DATA LINE_LENGTH TYPE I.
    FIELD-SYMBOLS <D>.
    ASSIGN COMPONENT 0 OF STRUCTURE DATA TO <D>.
    DESCRIBE FIELD <D> LENGTH LINE_LENGTH in character mode.
    
    * ----------------------------------------------------------------------
    *  if FIELDS are not specified, read all available fields
    * ----------------------------------------------------------------------
    DATA NUMBER_OF_FIELDS TYPE I.
    DESCRIBE TABLE FIELDS LINES NUMBER_OF_FIELDS.
    IF NUMBER_OF_FIELDS = 0.
      LOOP AT TABLE_STRUCTURE.
        MOVE TABLE_STRUCTURE-FIELDNAME TO FIELDS-FIELDNAME.
        APPEND FIELDS.
      ENDLOOP.
    ENDIF.
    * ----------------------------------------------------------------------
    *  for each field which has to be read, copy structure information *  into tables FIELDS_INT (internal use) and FIELDS (output)
    * ----------------------------------------------------------------------
    DATA: BEGIN OF FIELDS_INT OCCURS 10,         FIELDNAME  LIKE TABLE_STRUCTURE-FIELDNAME,         TYPE       LIKE TABLE_STRUCTURE-INTTYPE,         DECIMALS   LIKE TABLE_STRUCTURE-DECIMALS,         LENGTH_SRC LIKE TABLE_STRUCTURE-INTLEN,         LENGTH_DST LIKE TABLE_STRUCTURE-LENG,         OFFSET_SRC LIKE TABLE_STRUCTURE-OFFSET,         OFFSET_DST LIKE TABLE_STRUCTURE-OFFSET,       END OF FIELDS_INT,       LINE_CURSOR TYPE I.
    
    LINE_CURSOR = 0.
    *  for each field which has to be read ...
    LOOP AT FIELDS.
    
      READ TABLE TABLE_STRUCTURE WITH KEY FIELDNAME = FIELDS-FIELDNAME.
      IF SY-SUBRC NE 0.
        RAISE FIELD_NOT_VALID.
      ENDIF.
    
    * compute the place for field contents in DATA rows:
    * if not first field in row, allow space for delimiter
      IF LINE_CURSOR <> 0.
        IF NO_DATA EQ SPACE AND DELIMITER NE SPACE.
          LINE_CURSOR = LINE_CURSOR + 1. "SARMA
          MOVE DELIMITER TO DATA+LINE_CURSOR .
        ENDIF.
        LINE_CURSOR = LINE_CURSOR + STRLEN( DELIMITER ).
      ENDIF.
    
    * ... copy structure information into tables FIELDS_INT
    * (which is used internally during SELECT) ...
      FIELDS_INT-FIELDNAME  = TABLE_STRUCTURE-FIELDNAME.
      FIELDS_INT-LENGTH_SRC = TABLE_STRUCTURE-INTLEN .
      FIELDS_INT-LENGTH_DST = TABLE_STRUCTURE-LENG  .
      FIELDS_INT-OFFSET_SRC = TABLE_STRUCTURE-OFFSET .
      FIELDS_INT-OFFSET_DST = LINE_CURSOR .
      FIELDS_INT-TYPE       = TABLE_STRUCTURE-INTTYPE.
      FIELDS_INT-DECIMALS   = TABLE_STRUCTURE-DECIMALS.
    * compute the place for contents of next field in DATA rows
      LINE_CURSOR = LINE_CURSOR + TABLE_STRUCTURE-LENG.
      IF LINE_CURSOR > LINE_LENGTH AND NO_DATA EQ SPACE.
        RAISE DATA_BUFFER_EXCEEDED.
      ENDIF.
      APPEND FIELDS_INT.
    
    * ... and into table FIELDS (which is output to the caller)
      FIELDS-FIELDTEXT = TABLE_STRUCTURE-FIELDTEXT.
      FIELDS-TYPE      = TABLE_STRUCTURE-INTTYPE.
      FIELDS-LENGTH    = FIELDS_INT-LENGTH_DST + 2 .
      FIELDS-OFFSET    = FIELDS_INT-OFFSET_DST + 2.
      MODIFY FIELDS.
    
    ENDLOOP.
    * end of loop at FIELDS
    
    * ----------------------------------------------------------------------
    *  read data from the database and copy relevant portions into DATA
    * ----------------------------------------------------------------------
    * output data only if NO_DATA equals space (otherwise the structure * information in FIELDS is the only result of the module)
    IF NO_DATA EQ SPACE.
    
    DATA: BEGIN OF WORK, BUFFER(30000), END OF WORK.
    FIELD-SYMBOLS: <WA> TYPE ANY, <COMP> TYPE ANY.
    ASSIGN WORK TO <WA>> CASTING TYPE (QUERY_TABLE).
    IF ROWCOUNT > 0.
      ROWCOUNT = ROWCOUNT + ROWSKIPS.
    ENDIF.
    SELECT * FROM (QUERY_TABLE) INTO <WA>WHERE (OPTIONS).
    
        IF SY-DBCNT GT ROWSKIPS.
    
    *   copy all relevant fields into DATA (output) table
          LOOP AT FIELDS_INT.
            IF FIELDS_INT-TYPE = 'P'.
            ASSIGN COMPONENT FIELDS_INT-FIELDNAME
                OF STRUCTURE <WA> TO <COMP>
               TYPE FIELDS_INT-TYPE
                DECIMALS FIELDS_INT-DECIMALS.
            ELSE.
            ASSIGN COMPONENT FIELDS_INT-FIELDNAME
                OF STRUCTURE <WA> TO <COMP>
                TYPE     FIELDS_INT-TYPE.
                ENDIF.
                MOVE <COMP> TO
                <D>+FIELDS_INT-OFFSET_DST(FIELDS_INT-LENGTH_DST).
          ENDLOOP.
    *   end of loop at FIELDS_INT
          APPEND DATA.
          IF ROWCOUNT > 0 AND SY-DBCNT GE ROWCOUNT. EXIT. ENDIF.
    
        ENDIF.
    
      ENDSELECT.
    
    ENDIF.
    
    ENDFUNCTION.

  18. Go to SE37 tcode and select ZRFC_READ_TABLE. Click Change.

  19. Click Attributes tab, select Remote-Enabled Module in the Processing Type pane.

  20. Click Save.

  21. Click Activate.

  22. To configure the function you just created for Query interface for SAP Software in the external service wizard, specify the name of the custom function you created in step 1, in the Custom retrieve function name field in the Configure Composite Properties window.


Results

The adapter retrieves an error-free data from the SAP tables during query interface.

Troubleshooting and support


Related tasks:

Configure the selected objects