Application Development and Automation 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: 
Read only

Inserting data into append structure

Former Member
0 Likes
1,695

Hiee friends ,

I inserted a append strucuture into spfli table. I inserted carrname which is of scarr-carrname type .

Now my requirement is to insert corresponding values in carrname in spfli table from the scarr table .

For that i got the corresponding values of spfli-carrname in my internal table . I tried to insert it with insert command but its showing some error ..i.e column type not equal

Friends any ideas how to insert the carrname values into the spfli append strucutre.

Edited by: lokesh pattnayak on Jan 23, 2009 1:59 PM

6 REPLIES 6
Read only

matt
Active Contributor
0 Likes
830

Why not help us and help yourself, by showing us the actual ABAP you tried, (wrapped in tags), and the specific error you are getting.

Read only

Former Member
0 Likes
830

Here is my code that i am using to insert values into carrname field.

NB- YSPFLI and YSCARR are copies of tables of spfli and scarr with the respective datas resp.

REPORT  zappend_structure.
TABLES : yspfli, yscarr.

DATA: BEGIN OF wa,
         carrid TYPE yspfli-carrid,
         carrname TYPE yscarr-carrname,
      END OF wa.

DATA itab LIKE STANDARD TABLE OF wa.


SELECT  c~carrname
       INTO CORRESPONDING FIELDS OF TABLE itab
       FROM  yspfli AS p
         INNER JOIN yscarr AS c ON c~carrid   = p~carrid.


LOOP AT itab INTO wa.
  WRITE:/ wa-carrname.
  INSERT into yspfli values wa.
ENDLOOP.

ERROR : --- When i am checking the syntax it shows that "The work area wa is not alligned correctly" .

Edited by: lokesh pattnayak on Jan 23, 2009 3:58 PM

Read only

0 Likes
830

I tried with the update table but still the same error is coming .

i.e "The workarea "WA" is not aligned correctly".

REPORT  zappend_structure.
TABLES : yspfli, yscarr.

DATA: BEGIN OF wa,
         carrid TYPE yspfli-carrid,
         carrname TYPE yscarr-carrname,
      END OF wa.

DATA itab LIKE STANDARD TABLE OF wa.


SELECT  c~carrname
       INTO CORRESPONDING FIELDS OF TABLE itab
       FROM  yspfli AS p
         INNER JOIN yscarr AS c ON c~carrid   = p~carrid.


LOOP AT itab INTO wa.
  WRITE:/ wa-carrname.
  update yspfli from  wa.
*  INSERT into yspfli values wa.
ENDLOOP.

Friends any ideas how to insert the values into the carrname field from the workarea .

thanking you lokesh.

Edited by: lokesh pattnayak on Jan 24, 2009 3:49 AM

Read only

0 Likes
830

REPORT zappend_structure.

TABLES : yspfli, yscarr.

DATA: BEGIN OF wa,

include structure yspfli, workarea should be like that of database table (it should contain all fields) *

data: END OF wa.

DATA itab LIKE STANDARD TABLE OF wa.

SELECT c~carrname

INTO CORRESPONDING FIELDS OF TABLE itab

FROM yspfli AS p

INNER JOIN yscarr AS c ON ccarrid = pcarrid.

LOOP AT itab INTO wa.

WRITE:/ wa-carrname.

update yspfli from wa.

  • INSERT into yspfli values wa.

ENDLOOP.

Read only

0 Likes
830

Hi,

REPORT zappend_structure.

TABLES : yspfli, yscarr.

DATA : itab LIKE STANDARD TABLE OF yspfli.

DATA : wa_itab like line of yspfli.

SELECT c~carrname

INTO CORRESPONDING FIELDS OF TABLE itab

FROM yspfli AS p

INNER JOIN yscarr AS c ON ccarrid = pcarrid.

insert yspfli from table itab.

Read only

0 Likes
830

Hi,

For SQL statements, the work area or rows of the internal table must be at least as long as the database structure and the alignment must match.

So, declare another for inserting in database.

DATA : WA2 TYPE SPFLI.

LOOP AT itab INTO wa2.

   INSERT into spfli VALUES wa2.


ENDLOOP.