05-07-2009 8:16 AM
Hi
I am trying to insert data from a work area into an internal table using a where condition.
And facing a error in using this .the error says :
".", "INDEX numlike-field", "ASSIGNING <fs>", "REFERENCE INTO
data-reference", or "ASSIGNING <fs> CASTING" expected after "IT_SCARR".
my code is:
insert wa_scarr into table it_scarr where it-scarr-carrid = 'AA'.
please help.
Thank u in advance.
Regards.
Abhinandan.
05-07-2009 8:28 AM
Hello,
Its not correct,
Try this
first loop the internal table which contains the data and move to the work area keep where condition wa_scarr = 'AA' then append to the internal table ie. append wa_scarr into it_scarr.
05-07-2009 8:19 AM
HI,
You cannot use Where Clause with INSERT Statement.
http://help.sap.com/saphelp_46c/helpdata/en/34/8e72c56df74873e10000009b38f9b8/content.htm
You need read the internal table and get the index where to insert.
READ TABLE ITAB WITH KEY carrid = 'AA'.
IF SY-SUBRC EQ 0.
insert wa_scarr into table it_scarr index sy-tabix.
ENDIF.
05-07-2009 8:28 AM
Hello,
Its not correct,
Try this
first loop the internal table which contains the data and move to the work area keep where condition wa_scarr = 'AA' then append to the internal table ie. append wa_scarr into it_scarr.
05-07-2009 8:46 AM
Hi,
Insert command is to create a new line in the internal table.
If you want to change a line, use update statement.
If you are not sure about changing/inserting, use modify statement.
Use F1 help for syntax.
05-07-2009 9:42 AM
Hi
'Where' Condition cannot be used along with Insert statement .
instead you can use
1. INSERT (wa INTO|INITIAL LINE INTO) itab (INDEX
idx) (ASSIGNING <fs>|REFERENCE INTO dref).
2. INSERT (wa INTO|INITIAL LINE INTO) TABLE itab
(ASSIGNING <fs>|REFERENCE INTO dref).
3. INSERT LINES OF itab1 (FROM idx1] [TO idx2)
INTO itab2 (INDEX idx3).
4. INSERT LINES OF itab1 (FROM idx1) (TO idx2)
INTO TABLE itab2.
you can also check the keyword help document or if you want to know how they inserted the data with sample codes,
check the tcode - ABAPDOCU. U can find lot of sample codings.
05-07-2009 9:53 AM
Hi..
ur code is not correct..
in place of : insert wa_scarr into table it_scarr where it-scarr-carrid = 'AA'.
Try Following Code :
But before following code data (single record) must be there in wa_scarr.
if wa_scarr-carrid eq 'AA'.
append wa_scarr into it_scarr.
endif.
Hope this helps..
Regards,
Chintan.
06-04-2009 1:12 PM