Skip to Content
0
May 28, 2008 at 01:34 PM

Howto read Internal table? (novice user)

34 Views

Hello,

I'm trying to manipulate the data of a table in the SAP system. I'm kind of a novice regarding to ABAP, but I have lots of experience with SQL. So I am trying to write a simple ABAP that is able to execute SQL-statements and shows me what he's doing.

First of all, I can't create a query in ABAP that can be properly compiled. Second, I can't see what's the outcome of a select statement, I just want it to print on the screen.

The ABAP below doesn't compile, for two reasons;

The error for the Update section:

The In operator with "Key_table~Key is followed neither by an internal table nor by a value list.

The error for the loop-section:

Internal table "Key_Table" has no header. Addition of "INTO wa", "Assigning", "Reference into" or "Transporting no Fields" required.

Can anyone help me on these two errors?

REPORT ZBL_TEST.

Perform update_zrti_fi01.

FORM update_zrti_fi01 .

TYPES:

BEGIN OF Keys,

key type i,

END OF Keys.

DATA: Key_table TYPE STANDARD TABLE OF Keys INITIAL SIZE 0,

wa_Keys Type Keys.

  • Find some random DIMIDs, store them in the internal table

SELECT DISTINCT ZDIM~DIMID

INTO TABLE Key_table

FROM /BIC/DZRTI_FI017 as ZDIM INNER JOIN /BIC/SZ_BUD_VNR AS ZBUD_VNR on ZDIMSID_Z_BUD_VNR = ZBUD_VNRSID

WHERE ZBUD_VNR~/BIC/Z_BUD_VNR IN ('V0000050', 'v0000051').

  • Change records according to the internal table

UPDATE /bic/fzrti_fi01

SET FM_AMOUNT1 = 1000

WHERE KEY_ZRTI_FI017 in (Key_table~Key).

  • Show all the DIMIDs the select-statement found

Loop at Key_table.

Write line of Key_table.

Endloop.

Write: / 'Update: Finished!',

/ 'sy-subrc:', sy-subrc,

/ 'SY-DBCNT:', sy-dbcnt.

ENDFORM. " update_zrti_fi01