cancel
Showing results for 
Search instead for 
Did you mean: 

Routine with intervall in lookup DSO

Former Member
0 Kudos

Hi ABAP experts

We need to fill up the results with master data from a source DSO. This source DSO has the following character:

ZZBRAR1 and ZZBRAR describe an interval, also ZZBRARW1 and ZZBRARW.

The source DSO which delivers the result package doesn't have an interval on these two characteristics, only a valid value which lies between the interval of the lookup DSO.

The following coding has been applied as endroutine. Execution of DTP ends in a short dump TSV_TNEW_PAGE_ALLOC_FAILED.

Any ideas where to optimize the coding?

Thanks

TABLES: /BIC/AZFC_DS9600.
DATA: ITAB TYPE STANDARD TABLE OF /BIC/AZFC_DS9600 WITH HEADER LINE.
DATA: WA LIKE LINE OF ITAB.

*$*$ end of 2nd part global - insert your code only before this line   *

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

*----------------------------------------------------------------------*
*       Method end_routine
*----------------------------------------------------------------------*
*       Calculation of result package via end routine.
*       Note: Update of target fields depends on rule assignment in
*       transformation editor. Only fields that have a rule assigned,
*       are updated to the data target.
*----------------------------------------------------------------------*
*   <-> result package
*----------------------------------------------------------------------*
  METHOD end_routine.
*=== Segments ===

    FIELD-SYMBOLS:
      <RESULT_FIELDS>    TYPE _ty_s_TG_1.

    DATA:
      MONITOR_REC     TYPE rstmonitor.

*$*$ begin of routine - insert your code only below this line        *-*
... "insert your code here
*--  fill table "MONITOR" with values of structure "MONITOR_REC"
*-   to make monitor entries
... "to cancel the update process
*    raise exception type CX_RSROUT_ABORT.

DATA: ITAB_REFRESH TYPE STANDARD TABLE OF _ty_s_TG_1.
    DATA: ITAB_TARGET TYPE STANDARD TABLE OF _ty_s_TG_1.
    DATA: WA_TARGET LIKE LINE OF ITAB_TARGET.
    DATA: ICOUNT TYPE RSARECORD.

  

IF RESULT_PACKAGE[] IS NOT INITIAL.
      ICOUNT = 1.
      REFRESH ITAB.

    

SELECT * FROM /BIC/AZFC_DS9600 INTO TABLE ITAB.

      REFRESH ITAB_TARGET.

      LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.
        LOOP AT ITAB INTO WA.

          IF WA-/BIC/ZZBRA1 <= <RESULT_FIELDS>-/BIC/ZZBRA3
              AND WA-/BIC/ZZBRA >= <RESULT_FIELDS>-/BIC/ZZBRA3
              AND WA-/BIC/ZZBRARW1 <= <RESULT_FIELDS>-/BIC/ZZBRARW
              AND WA-/BIC/ZZBRARW >= <RESULT_FIELDS>-/BIC/ZZBRARW.

            <RESULT_FIELDS>-/BIC/ZWWSIC = WA-/BIC/ZWWSIC.
            <RESULT_FIELDS>-/BIC/ZWWPRD = WA-/BIC/ZWWPRD.

            ICOUNT = ICOUNT + 1.
            APPEND <RESULT_FIELDS> TO ITAB_TARGET.

          ELSE.
          "keep ZZWWSIC and ZZWWPRD initial and transfer result package.


            ICOUNT = ICOUNT + 1.
            APPEND <RESULT_FIELDS> TO ITAB_TARGET.

          ENDIF.


        ENDLOOP.
      ENDLOOP.

      REFRESH RESULT_PACKAGE.
      RESULT_PACKAGE[] = ITAB_TARGET[].
    ENDIF.

Accepted Solutions (1)

Accepted Solutions (1)

former_member185132
Active Contributor
0 Kudos

Hi,

First off, apply a WHERE clause on the SELECT statement. The conditions are the same as the ones used in the IF statement.

Second and most important, reduce the packet size in the DTP. You may need to do a few hit and trials to get at the correct size.

Regards,

Suhas

Former Member
0 Kudos

Hi Suhas

A "where" clause in the select statement is not wished as I also need the result fields which don't fulfill the IF condition.

I have commented this sequence of the code:

*         ELSE.

          "keep ZZWWSIC and ZZWWPRD initial and transfer result package.


*            ICOUNT = ICOUNT + 1.
*           APPEND <RESULT_FIELDS> TO ITAB_TARGET.

And the DTP works.

But I also need the result fields which don't fit with the IF conditions....probably this is the place of the code to get adjusted(?).

Thanks

Thomas

former_member185132
Active Contributor
0 Kudos

If you need to records that don't satisfy the condition, then it's fine if you leave the code as it is.

The DTP packet size however, must be reduced. The reason is that when your TRFN explodes the Result Package volume (as it does above) then you often have a situation where the RP is too big for the server to handle. To control that, you should reduce the packet size, because the output RP size is roughly proportional to the packet size.

Former Member
0 Kudos

Thanks Suhas

I am trying to replace the the second loop  with a READ statement:

I have changed the SELECT statement  ...and get the syntax check error:

Implicit key specification is no longer allowed in the OO context. You

must use an INDEX, KEY, or FROM specification. must use an INDEX, KEY

or FROM specification.

 

SELECT * FROM /BIC/AZFC_DS2600 INTO TABLE ITAB
WHERE

/BIC/ZZBRA1 <= <RESULT_FIELDS>-/BIC/ZZBRA3
AND /BIC/ZZBRA >= <RESULT_FIELDS>-/BIC/ZZBRA3
AND /BIC/ZZBRARW1 <= <RESULT_FIELDS>-/BIC/ZZBRARW
AND /BIC/ZZBRARW >= <RESULT_FIELDS>-/BIC/ZZBRARW.

REFRESH ITAB_TARGET.


LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.
READ TABLE ITAB INTO WA.
.....

Can you help?

former_member185132
Active Contributor
0 Kudos

I don't think you can use a READ statement instead of the LOOP. Logically they both work in totally different ways.

If the logic with the LOOP was correct, then retain it.

sriramvijay_ravidoss
Contributor
0 Kudos

Hi,

I recommend you change loop into Reaad statement. You have to use key for ITAB, that why getting this error.

A Sample code.

Structure Definition.

TYPES: BEGIN OF STR_HDR,

Structure elements Definition.


END OF STR_HDR.

Internal table declaration

DATA: I_T_DATA_HDR TYPE SORTED TABLE OF STR_HDR WITH UNIQUE KEY <Ex:OI_EBELN>,

      W_A_DATA_HDR LIKE LINE OF I_T_DATA_HDR.

Select Statement:

SELECT OI_EBELN DOCTYPE VENDOR /BIC/ZFRGKE DOC_CAT /BIC/ZZPOIC PUR_GROUP

FROM

/BIC/AZPUR_O0200

  INTO TABLE I_T_DATA_HDR FOR ALL ENTRIES IN SOURCE_PACKAGE

  WHERE OI_EBELN = SOURCE_PACKAGE-OI_EBELN.

Read Statement:

READ TABLE I_T_DATA_HDR1 INTO W_A_DATA_HDR WITH TABLE KEY OI_EBELN = SOURCE_FIELDS-OI_EBELN.

-Sriram

Former Member
0 Kudos

Can I also use this key statement if I need to lookup a value from the interval described above?

The key in result package would be ZZBRARW, the one in the lookup DSO would be ZZBRARW1 or ZZBRARW?

ZZBRARW1 and ZZBRARW are describing the interval of the lookup DSO.

Former Member
0 Kudos

Hi

I have changed the coding as below, the SELECT statement gives an error saying that the where clause is not related to the FOR ALL ENTRIES table...?

 

TYPES

: BEGIN OF STR_HDR,
/BIC/ZZBRARW
TYPE /BIC/OIZZBRARW,
/BIC/ZZBRA3
TYPE /BIC/OIZZBRA3,
/BIC/ZWWSIC
TYPE /BIC/OIZWWSIC,
/BIC/ZWWPRD
TYPE /BIC/OIZWWPRD,
END OF STR_HDR

.

 

DATA

: I_T_DATA_HDR TYPE SORTED TABLE OF STR_HDR
WITH UNIQUE KEY /BIC/ZZBRA3 /BIC/ZZBRARW,
W_A_DATA_HDR
LIKE LINE OF I_T_DATA_HDR.


IF RESULT_PACKAGE[] IS NOT INITIAL.
ICOUNT
= 1.
REFRESH ITAB.

SELECT /BIC/ZWWSIC /BIC/ZWWPRD FROM /BIC/AZFC_DS2600 INTO TABLE
I_T_DATA_HDR
FOR ALL ENTRIES IN RESULT_PACKAGE
WHERE
/BIC/ZZBRA1 <= <RESULT_FIELDS>
-/BIC/ZZBRA3
AND /BIC/ZZBRA >= <RESULT_FIELDS>-/BIC/ZZBRA3
AND /BIC/ZZBRARW1 <= <RESULT_FIELDS>-/BIC/ZZBRARW
AND /BIC/ZZBRARW >= <RESULT_FIELDS>-/BIC/ZZBRARW

.

anshu_lilhori
Active Contributor
0 Kudos

Try replacing <RESULT_FIELDS> with RESULT_PACKAGE in your where clause.

Regards,

AL

Former Member
0 Kudos

Hi Anshu

Thanks for this hint.

I have defined  the sorted table with two keys:

DATA: I_T_DATA_HDR TYPE SORTED TABLE OF STR_HDR
WITH UNIQUE KEY /BIC/ZZBRA3 /BIC/ZZBRARW,

How should the READ clause be described in this case?

 

READ TABLE

I_T_DATA_HDR INTO W_A_DATA_HDR

WITH TABLE KEY

Former Member
0 Kudos

Hi,

Please try below.

DATA: I_T_DATA_HDR TYPE SORTED TABLE OF STR_HDR
WITH UNIQUE KEY /BIC/ZZBRA3 /BIC/ZZBRARW,

How should the READ clause be described in this case?

 

READ TABLE

I_T_DATA_HDR INTO W_A_DATA_HDR

WITH TABLE KEY

/BIC/ZZBRA3 =  <RESULT_FIELDS>-"Field name

/BIC/ZZBRARW = <RESULT_FIELDS>-"Field name

Regards,

Gaurav

former_member185132
Active Contributor
0 Kudos

Hi,

You cannot write a READ statement that is equivalent to the original code. The reason is that the original code did not use equality operators, it used operators such as >=, which ABAP does not allow in the READ statement.

A read statement is also not logically equivalent to your original code. The read statement is not logically a substitute for Nested loops. Your code (the one with nested loops) will generate N records for each original RESULT_PACKAGE record. A READ-based logic will generate only 1 record for each RESULT_PACKAGE record. So please re-check the requirement to determine whether the READ-based logic is suitable.

Regards,

Suhas

Answers (3)

Answers (3)

sriramvijay_ravidoss
Contributor
0 Kudos

Hi,

This is very costly code. It has  loop inside a loop.

LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.

        LOOP AT ITAB INTO WA.

instead of second loop. Read the ITAB with the conditions that you used in ÏF".

IF WA-/BIC/ZZBRA1 <= <RESULT_FIELDS>-/BIC/ZZBRA3

              AND WA-/BIC/ZZBRA >= <RESULT_FIELDS>-/BIC/ZZBRA3

              AND WA-/BIC/ZZBRARW1 <= <RESULT_FIELDS>-/BIC/ZZBRARW

              AND WA-/BIC/ZZBRARW >= <RESULT_FIELDS>-/BIC/ZZBRARW.

Example;

LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.

READ ITAB where  WA-/BIC/ZZBRA >= <RESULT_FIELDS>-/BIC/ZZBRA3 and ...

some thing like above one. you have to write to optimize the code.

-Sriram

0 Kudos

Hi,

What is data type of those fields? If this is key figure then your code would work.

If the data type is of CHAR then u should think some other way to find the difference in range.

Because <,> will not work in CHAR, ZZBRARW1 and ZZBRARW looks like it is not number.

Regards,

Poomagal S.

Former Member
0 Kudos

Yes, you are right. It is CHAR.

anshu_lilhori
Active Contributor
0 Kudos

Thomas,instead of Select * try fetching the fields which are required and declare the structure of the same fields.

Make use of hashed table if not then sorted table instead of standard table.

See if the above two pointers help in improving the performance of the code.

Regards,

AL

Former Member
0 Kudos

Hi Anshu

This lookup table consist only of 500 records.

Thanks

Thomas