‎2009 Dec 19 9:25 AM
Hello Experts,
Am using the preview AS version to learn abap.I just encountered a Run time error.Please help.
It says TABLE ILLEGAL STATEMENT.
You attempted to change , delete , or create a line in the internal table it_sflight but no valid cursor exists.
Source Code.
REPORT ZBC400_47_SELECT_FLIGHT_ITAB.
TYPES: BEGIN OF sbc400focc,
carrid TYPE sflight-carrid,
connid TYPE sflight-connid,
fldate TYPE sflight-fldate,
seatsocc TYPE sflight-seatsocc,
seatsmax TYPE sflight-seatsmax,
percentage TYPE i,
END of sbc400focc.
TYPES sbc_400_focc
TYPE STANDARD TABLE OF sbc400focc
WITH NON-UNIQUE KEY carrid connid fldate.
DATA it_sflight TYPE sbc_400_focc.
DATA wa_sflight LIKE LINE OF it_sflight.
PARAMETER pa_carr TYPE sflight-carrid.
SELECT carrid connid fldate seatsmax seatsocc
FROM sflight
INTO CORRESPONDING FIELDS OF wa_sflight
WHERE carrid = pa_carr.
wa_sflight-percentage = 100 * wa_sflight-seatsocc / wa_sflight-seatsmax.
INSERT wa_sflight INTO it_sflight.
ENDSELECT.
IF sy-subrc = 0.
SORT it_sflight by percentage.
LOOP AT it_sflight INTO wa_sflight.
WRITE: / wa_sflight-carrid,
wa_sflight-connid,
wa_sflight-fldate,
wa_sflight-seatsocc,
wa_sflight-seatsmax,
wa_sflight-percentage.
ENDLOOP.
WRITE: 'Sorted'.
ELSE.
WRITE: 'NOT FOUND' .
ENDIF.
‎2009 Dec 19 9:30 AM
Use APPEND instead of INSERT.
INSERT wa_sflight INTO it_sflight." Replace this by APPEND
‎2009 Dec 19 9:30 AM
Use APPEND instead of INSERT.
INSERT wa_sflight INTO it_sflight." Replace this by APPEND
‎2009 Dec 19 9:39 AM
Thanks a lot that worked.Could u explain why INSERT was giving error and why APPEND was to be used?
‎2009 Dec 19 9:44 AM
Hi,
You have declared your Internal Table as Standard Internal Table and so you need to use APPEND. Insert can be used once you have sorted the Standard internal Table.
Hope this is clear.
Thanks,
Prashanth
‎2009 Dec 19 9:39 AM
Hi,
You have to use APPEND to insert a line to the internal table instead of INSERT.
Regards
Abhii