Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

Scenario

In table LFBK, the field BANKN is of length 18.

In table TIBAN, the field BANKN is of length 35.

The problem arises when we have a For All Entries like below:

  SELECT *
FROM tiban
INTO TABLE lt_tiban
FOR ALL ENTRIES IN lt_lfbk
WHERE banks EQ lt_lfbk-banks
AND   bankl EQ lt_lfbk-bankl
AND   bankn EQ lt_lfbk-bankn
AND   bkont EQ lt_lfbk-bkont.

The yellow line will result in an error because the size of TIBAN-BANKN is bigger than LFBK-BANKN.

Solution

A solution would be to create a new structure and add a new field with length 35:

1. Create a type. 


BEGIN OF ty_lfbk_new.
include TYPE lfbk.
TYPES:
bankn35
TYPE tiban-bankn,
END OF   ty_lfbk_new.

2. Create a new structure and table with the new type.


DATA:    ls_lfbk_new TYPE ty_lfbk_new,
          lt_lfbk_new
TYPE STANDARD TABLE OF ty_lfbk_new.

3. Fill the new field BANKN35 with the data LS_LFBK-BANKN.

LOOP AT lt_lfbk INTO ls_lfbk.
ls_lfbk_new
= ls_lfbk.
ls_lfbk_new
-bankn35 = ls_lfbk-bankn.
APPEND ls_lfbk_new to lt_lfbk_new.
ENDLOOP.

4. In the Select statement, use the new table LT_LFBK_NEW for FOR ALL ENTRIES.

SELECT *
FROM tiban
INTO TABLE lt_tiban
FOR ALL ENTRIES IN lt_lfbk_new
WHERE banks EQ lt_lfbk_new-banks
AND   bankl EQ lt_lfbk_new-bankl
AND   bankn EQ lt_lfbk_new-bankn35
AND   bkont EQ lt_lfbk_new-bkont.