Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

SELECT Fetch issue when append itab

glauco
Active Contributor
0 Kudos

Hi folks.

I tryied to find help but didn't find exactly my case.

I'm developeing in ECC 6.0 and want to select in oracle external database. The connection is already configured by BASIS team in DBCO.

The issue is about a Fetch command that give a dump ONLY when I try to use command APPEND itab.

DATA: GT_TEST TYPE STANDARD TABLE OF XPTO. " XPTO IS A STRUCTURE CREATED IN SE11

DATA: GS_TEST TYPE XPTO.

This works:

DO.
    EXEC SQL.
      FETCH NEXT C
             INTO  :GS_TEST-NUM_CONTRACT,
                        :GS_TEST-NAME
    ENDEXEC.
  EXIT.
  ENDDO.

This doesn't work:

DO.
      FETCH NEXT C
             INTO  :GS_TEST-NUM_CONTRACT,
                        :GS_TEST-NAME
    ENDEXEC.
    IF sy-subrc <> 0.
      EXIT.
    ENDIF.
    APPEND GS_TEST to GT_TEST.
  ENDDO.

Any tip ?

thanks.

Glauco

2 REPLIES 2

Former Member
0 Kudos

Please check the below code to get the data from external DB.


    EXEC SQL PERFORMING append_data.
      select fld1, fld2, fld3 into :ls_data-fld1, :ls_data-fld2,
                  :ls_data-fld3
                  from table_name
      where fld1 = :lv_fld5
    ENDEXEC.

    FORM append_data.
      APPEND ls_data TO lt_data.
      CLEAR ls_data.
    ENDFORM.  

0 Kudos

Hi Suman.

Thanks for your help but problem was solved when I put TRYcommand:

TRY.

DO...

FETCH...

Append ls... to gt...

ENDDO.

CATCH CX_SY_NATIVE_SQL_ERROR.

ENDTRY.

BUT problem were about other thing. A specific oracle row has a diferent format that I expected. TRY command took it out...but I had to get out TO_CHAR command of my fields in SELECT. NOW I can get all correct rows of ORACLE database.

Now it works fine !

Thanks.

Glauco