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: 

How to make an insert from a work area over several fields

Former Member
0 Kudos
285

Hi please how can I help make an insert from a Work Area of several fields into a table?

Because in the model that I wrote when I debug it only inserts the last line

So I thing its the insert command that must be changed

Thanks in advance

1 ACCEPTED SOLUTION

JJosh
Active Participant
0 Kudos
190

Hi,

Use Modify ---- Using Index . . .

This should solve ur problem.

Regards,

Josh

9 REPLIES 9

JJosh
Active Participant
0 Kudos
191

Hi,

Use Modify ---- Using Index . . .

This should solve ur problem.

Regards,

Josh

Former Member
0 Kudos
190

Hi Josh my command is:

Insert into zlook values wa_lk.

wa_lk-cima = up.

wa_lk-baixo = dw.

wa_lk-saltar = sh.

wa_lk-acessorio = ac.

But the only line that is executed is the last line

wa_lk-acessorio = ac.

JJosh
Active Participant
0 Kudos
190

Hi Caio,

Use.

INSERT ITAB FROM WA_LK.

** ITAB should have all the fields that u have mentioned above.

Regards,

Josh

Former Member
0 Kudos
190

When I use that returns the message:

Field From is unknown it is neither in one of the specified tables....

JJosh
Active Participant
0 Kudos
190

HI,

Check ur internal table and work area declaration.

eg: ITAB TYPE STANDARD TABLE OF <TABLE NAME>,

     WA    LIKE LINE OF ITAB.

or if u are using TYPES (BEST PRACTISE) .

TYPES: BEGIN of ty_itab,

              field1 type ....,

              field2 type. . . ,

             END of ty_itab,

             tt_itab TYPE STANDARD TABLE OF ty_itab.

DATA: ITAB TYPE TT_ITAB,

          WA   TYPE TY_ITAB.

Try these declaration.

Regards,

Josh

Former Member
0 Kudos
190

Hi,

Please find the below Demo reports provided by SAP. I think you will understand the concept of inserting lines in a table.

DEMO_INT_TABLES_INSERT     Inserting Individual Table Lines

DEMO_INT_TABLES_INSERT_IND_1   Inserting Individual Lines Using the Index

DEMO_INT_TABLES_INSERT_IND_2   Inserting Individual Lines Using the Index

DEMO_INT_TABLES_INSERT_IND_3   Inserting Several Lines Using the Index

DEMO_INT_TABLES_INSERT_LINES   Inserting More Than One Line

DEMO_SPECIAL_TECH_DYN_INSERT   Creating a New Program Dynamically

Former Member
0 Kudos
190

Add/Change a row in internal table

modify <itab> from <wa>  index sy-tabix

append <wa> to <itab>

MODIFY a database table from a work area

modify <ztab> from <wa>

0 Kudos
190

But how could I modify if there is no register yet in the table?

Arun_Prabhu_K
Active Contributor
0 Kudos
190

Hello Caio Malentaqui.

     I guess you are trying to insert data into a Z database table. Right?

     If your internal table is of the same structure as your Z table, you can use

          MODIFY Z_table from table ITAB. COMMIT WORK.

     This statement will insert fresh records and modify existing records of Z table.

Regards.