/scripts/ahub.form.attachments.js
-2

Default Key in hashed table

Apr 22, 2017 at 12:07 PM

185

avatar image

In a DTP using expert routine I am facing problems to define the unique key for a hashed table.

Introduction:

Source DSO: YADSO04
My target DSO YADSO05:

Code:

DATA:
      LTH_RESULT_PACKAGE  LIKE HASHED TABLE OF RESULT_PACKAGE
                          WITH UNIQUE DEFAULT KEY,
                          "all c, d, t, n, x, string, xstring values
      LS_RESULT_PACKAGE   LIKE LINE OF LTH_RESULT_PACKAGE.

LOOP AT SOURCE_PACKAGE ASSIGNING <SOURCE_FIELDS>.
  IF <SOURCE_FIELDS>-/BIC/YKYFD = 'CASHTO'.
    LS_RESULT_PACKAGE-/BIC/YREVENUE = <SOURCE_FIELDS>-/BIC/YKYFA.
  ENDIF.
ENDLOOP.

Error message: E:The default key can be empty for tables of the standard type only.

I thought after the DATA section the default key would have been 0Calmonth, 0Calyear and YPOS.

Why is it still empty?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Horst Keller
Apr 23, 2017 at 10:49 AM
1

I guess your line type leads to an empty standard key according to the rules.

Can you prove that it contains components as you said? Did you check it in the debugger? I assume, it is not a stuctured type.

Why do you want to use the standard key at all? We do not recommend it any more.

Show 6 Share
10 |10000 characters needed characters left characters exceeded

I think the issue is with the LIKE ... RESULT_PACKAGE, because result_package is a table-type parameter in SAP BI DTP "routines". Consequently, as Horst's documentation explains, the empty key will be used.

Instead you should use the type name of the result_package parameter (something like _SC_1) with TYPE:

DATA LTH_RESULT_PACKAGE TYPE HASHED TABLE OF _sc_1 WITH UNIQUE DEFAULT KEY.
1

Dear Sandra,

do you mean
LTH_RESULT_PACKAGE LIKE HASHED TABLE OF _ty_s_TG_1 WITH UNIQUE DEFAULT KEY.

Throws an error: Field "_TY_S_TG_1" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement. "DATA" statement.

I guess the reason is, that it is in the private section?

The complete code.

PROGRAM trans_routine.
*---------------------------------------------------------------------*
*       CLASS routine DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_transform DEFINITION.
  PUBLIC SECTION.


*  Attributs
    DATA:
*-    Rule context
      p_curr_rule
            TYPE cl_rstran_runtime_exe=>ty_s_rule_context READ-ONLY,
      p_check_master_data_exist
            TYPE RSODSOCHECKONLY READ-ONLY,
*-    Instance for getting request runtime attributs;
*     Available information: Refer to methods of
*     interface 'if_rsbk_request_admintab_view'
      p_r_request
            TYPE REF TO if_rsbk_request_admintab_view READ-ONLY.


  PRIVATE SECTION.


    TYPE-POOLS: rsd, rstr.


*   Rule specific types
    TYPES:
      BEGIN OF _ty_s_SC_1,
*      InfoObject: 0CALMONTH Calendar year/month.
        CALMONTH           TYPE /BI0/OICALMONTH,
*      InfoObject: 0CALYEAR Calendar year.
        CALYEAR           TYPE /BI0/OICALYEAR,
*      InfoObject: YPOS POS.
        /BIC/YPOS           TYPE /BIC/OIYPOS,
*      InfoObject: YKYFD Key figures.
        /BIC/YKYFD           TYPE /BIC/OIYKYFD,
*      InfoObject: 0RECORDMODE BW Delta Process: Update Mode.
        RECORDMODE           TYPE RODMUPDMOD,
*      InfoObject: YKYFA Key figure.
        /BIC/YKYFA           TYPE /BIC/OIYKYFA,
*      Field: RECORD.
        RECORD           TYPE RSARECORD,
      END   OF _ty_s_SC_1.
    TYPES:
      _ty_t_SC_1        TYPE STANDARD TABLE OF _ty_s_SC_1
                        WITH NON-UNIQUE DEFAULT KEY.
    TYPES:
      BEGIN OF _ty_s_TG_1,
*      InfoObject: 0REQUEST Request GUID.
        REQUEST           TYPE /BI0/OIREQUEST,
*      InfoObject: 0DATAPAKID Data Package.
        DATAPAKID           TYPE /BI0/OIDATAPAKID,
*      InfoObject: 0RECORDMODE BW Delta Process: Update Mode.
        RECORDMODE           TYPE RODMUPDMOD,
*      InfoObject: 0CALMONTH Calendar year/month.
        CALMONTH           TYPE /BI0/OICALMONTH,
*      InfoObject: 0CALYEAR Calendar year.
        CALYEAR           TYPE /BI0/OICALYEAR,
*      InfoObject: YPOS POS.
        /BIC/YPOS           TYPE /BIC/OIYPOS,
*      InfoObject: YREVENUE Revenue.
        /BIC/YREVENUE           TYPE /BIC/OIYREVENUE,
*      InfoObject: YORDER Order Value.
        /BIC/YORDER           TYPE /BIC/OIYORDER,
*      InfoObject: 0RECORD Data Record Number.
        RECORD           TYPE /BI0/OIRECORD,
      END   OF _ty_s_TG_1.
    TYPES:
      _ty_t_TG_1        TYPE STANDARD TABLE OF _ty_s_TG_1
                        WITH NON-UNIQUE DEFAULT KEY.


*$*$ begin of global - insert your declaration only below this line  *-*
... "insert your code here
*$*$ end of global - insert your declaration only before this line   *-*
    METHODS
      new_record__expert_routine
        IMPORTING
          log                      type ref to cl_rsbm_log_cursor_step
          source_segid             type rstran_segid
          source_record            type sytabix
          target_segid             type rstran_segid
        EXPORTING
          record_new               type sytabix.


    METHODS
      expert_routine
        IMPORTING
          request                  type rsrequest
          datapackid               type rsdatapid
          log                      type ref to cl_rsbm_log_cursor_step
        EXPORTING
          RESULT_PACKAGE              type _ty_t_TG_1
        CHANGING
          SOURCE_PACKAGE              type _ty_t_SC_1.


    METHODS
      inverse_expert_routine
        IMPORTING
          i_th_fields_outbound         TYPE rstran_t_field_inv
          i_r_selset_outbound          TYPE REF TO cl_rsmds_set
          i_r_universe_inbound         TYPE REF TO cl_rsmds_universe
        CHANGING
          c_th_fields_inbound          TYPE rstran_t_field_inv
          c_r_selset_inbound           TYPE REF TO cl_rsmds_set
          c_exact                      TYPE rs_bool.
ENDCLASS.                    "routine DEFINITION


*$*$ begin of 2nd part global - insert your code only below this line  *
... "insert your code here
*$*$ end of 2nd part global - insert your code only before this line   *


*---------------------------------------------------------------------*
*       CLASS routine IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_transform IMPLEMENTATION.


*----------------------------------------------------------------------*
*       Method expert_routine
*----------------------------------------------------------------------*
*       Calculation of result package via expert routine
*----------------------------------------------------------------------*
*   -> package of source segments
*   <- result package
*----------------------------------------------------------------------*
  METHOD expert_routine.
*=== Segments ===


    FIELD-SYMBOLS:
      <SOURCE_FIELDS>    TYPE _ty_s_SC_1.


    DATA:
      RESULT_FIELDS      TYPE _ty_s_TG_1.


*$*$ begin of routine - insert your code only below this line        *-*
... "insert your code here
DATA:
      LTH_RESULT_PACKAGE  LIKE HASHED TABLE OF RESULT_PACKAGE
                          WITH UNIQUE DEFAULT KEY,
                          "all c, d, t, n, x, string, xstring values
      LS_RESULT_PACKAGE   LIKE LINE OF LTH_RESULT_PACKAGE.




*$*$ end of routine - insert your code only before this line         *-*
  ENDMETHOD.                    "expert_routine
  
*----------------------------------------------------------------------*
*       Inverse method inverse_expert_routine
*----------------------------------------------------------------------*
*       This subroutine needs to be implemented only for direct access
*       (for better performance) and for the Report/Report Interface
*       (drill through).
*       The inverse routine should transform a projection and
*       a selection for the target to a projection and a selection
*       for the source, respectively.
*       If the implementation remains empty all fields are filled and
*       all values are selected.
*----------------------------------------------------------------------*
*       Customer comment:
*----------------------------------------------------------------------*
  METHOD inverse_expert_routine.


*   IMPORTING
*     i_r_selset_outbound          TYPE REF TO cl_rsmds_set
*     i_th_fields_outbound         TYPE HASHED TABLE
*     i_r_selset_outbound_complete TYPE REF TO cl_rsmds_set
*     i_r_universe_inbound         TYPE REF TO cl_rsmds_universe
*   CHANGING
*     c_r_selset_inbound           TYPE REF TO cl_rsmds_set
*     c_th_fields_inbound          TYPE HASHED TABLE
*     c_exact                      TYPE rs_bool


*$*$ begin of inverse routine - insert your code only below this line*-*
... "insert your code here
*$*$ end of inverse routine - insert your code only before this line *-*


  ENDMETHOD.                    "inverse_expert_routine


  METHOD new_record__expert_routine.


***** IMPLEMENTATION  is only visible in generated program *****


  ENDMETHOD.
ENDCLASS.                    "routine IMPLEMENTATION


0

I just got the exact definition of the "expert routine" method :

    METHODS
      expert_routine
        IMPORTING
          request                  type rsrequest
          datapackid               type rsdatapid
          log                      type ref to cl_rsbm_log_cursor_step
        EXPORTING
          RESULT_PACKAGE              type _ty_t_TG_1
        CHANGING
          SOURCE_PACKAGE              type _ty_t_SC_1.

And we have:

_ty_t_TG_1 TYPE ... TABLE OF _ty_s_TG_1 ...

So, as you already guessed, it's:

LTH_RESULT_PACKAGE TYPE HASHED TABLE OF _ty_s_TG_1 WITH UNIQUE DEFAULT KEY.
1

Thx, since I don't see the application types in my basis systems, I couldn't check. But Sandra confirms my guess. I also thought that the linetype might be a table type.

1

Mr Keller, first thumbs up on your working morale: working on a Sunday night.

> Did you check it in the debugger?
I can not activate the DTP due to the syntax error - can not have a look.

> Why do you want to use the standard key at all?
It is part of my training program, I guess I should learn something about using it.

0

"I can not activate the DTP due to the syntax error - can not have a look."

Simply comment the lines with and after the syntax error ....

1
Oliver Söder Apr 24, 2017 at 05:04 AM
0

Solution:

LTH_RESULT_PACKAGE TYPE HASHED TABLE OF _ty_s_TG_1 WITH UNIQUE DEFAULT KEY.

Thank you for your help!

Share
10 |10000 characters needed characters left characters exceeded
Skip to Content