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: 

Insert a row in table

Former Member
0 Kudos
175

Hi All,

I am very new to ABAP. I have created a new table with fields 1. Client type mandt 2.Emp_Name 3. Emp_id.

I need to create a report to upload a set of values to this table.

My report is like this.

REPORT ZJAITESTREPORT .

DATA : begin of z_jai,

client like zjaitable-client,

Emp_Name like zjaitable-emp_name,

Emp_Id like zjaitable-emp_id,

end of z_jai.

z_jai-client = '501'.

z_jai-Emp_Name = 'Mani'.

z_jai-Emp_Id = '0001'.

insert zjaitable from z_jai.

commit work.

But the code is not working. Can any one tell me where I am going wrong?

Thanks & Regards,

Jai Shankar.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
147

Hi,

Declare the Internal table properly.


REPORT zjaitestreport .
DATA : BEGIN OF z_jai <b>OCCURS 0</b>,
       client LIKE zjaitable-client,
       emp_name LIKE zjaitable-emp_name,
       emp_id LIKE zjaitable-emp_id,
       END OF z_jai.


z_jai-client = '501'.
z_jai-emp_name = 'Mani'.
z_jai-emp_id = '0001'.

<b>APPEND z_jai.</b>

INSERT zjaitable <b>FROM TABLE z_jai</b>.
COMMIT WORK.

Read the F1 help for INSERT statement for more Info.

Regards,

AS.

12 REPLIES 12

Former Member
0 Kudos
147

Hello Jai,

REPORT ZJAITESTREPORT .

DATA : begin of z_jai,

client like zjaitable-client,

Emp_Name like zjaitable-emp_name,

Emp_Id like zjaitable-emp_id,

end of z_jai.

z_jai-client = '501'.

z_jai-Emp_Name = 'Mani'.

z_jai-Emp_Id = '0001'.

insert zjaitable from z_jai.

commit work.

If ur code change this part alone

<b>insert zjaitable VAlues z_jai.</b>

If useful reward.

Vasanth

0 Kudos
147

Hi Vasanth,

I tried that. It gives me an error unable to interpret "values".

Regards,

Jai Shankar.

0 Kudos
147

Hello,

Jai,

Sorry .There is a mistake the my prevous syntax.

write: like this.

<b>INSERT INTO ZTABLE VALUE ZSTRUCTURE</b>

vasanth

0 Kudos
147

Hi Vasanth,

Sorry. I missed "INTO" in that statement. Now I executed it. Still not successful.

Regards,

Jai Shankar.

0 Kudos
147

Hellp Jai,

Check the key fields.

Change the employee name and Employee ID and Try.

Vasanth

Former Member
0 Kudos
147

Hi Jai,

REPORT ZJAITESTREPORT .

DATA : begin of z_jai.

<b>include structure zjaitable .</b>

end of z_jai.

z_jai-Emp_Name = 'Mani'.

z_jai-Emp_Id = '0001'.

insert zjaitable from z_jai.

commit work.

Try this way andsee if it works .

Regards,

Varun .

former_member223537
Active Contributor
0 Kudos
147

Hi,

REPORT ZJAITESTREPORT .

DATA : begin of z_jai,

Emp_Name like zjaitable-emp_name,

Emp_Id like zjaitable-emp_id,

end of z_jai.

z_jai-Emp_Name = 'Mani'.

z_jai-Emp_Id = '0001'.

insert into zjaitable values z_jai.

commit work.

Best regards,

Prashant

Former Member
0 Kudos
147

Hi

Create an internal table ITAB for the structure z_jai.

Use following statement:

INSERT zjaitable FROM TABLE ITAB.

At the mean time go to SE11 and try adding contents to the table manually (Utilities->Table Contents->Create Entries). If it is working fine then the above should work.

Thanks

Inder

Former Member
0 Kudos
148

Hi,

Declare the Internal table properly.


REPORT zjaitestreport .
DATA : BEGIN OF z_jai <b>OCCURS 0</b>,
       client LIKE zjaitable-client,
       emp_name LIKE zjaitable-emp_name,
       emp_id LIKE zjaitable-emp_id,
       END OF z_jai.


z_jai-client = '501'.
z_jai-emp_name = 'Mani'.
z_jai-emp_id = '0001'.

<b>APPEND z_jai.</b>

INSERT zjaitable <b>FROM TABLE z_jai</b>.
COMMIT WORK.

Read the F1 help for INSERT statement for more Info.

Regards,

AS.

Former Member
0 Kudos
147

z_jai-client = '501'.

z_jai-Emp_Name = 'Mani'.

z_jai-Emp_Id = '0001'.

INSERT INTO zjaitable VALUES z_jai.

And remove the COMMIT WORK. SAP's Logic Unit of Work concept will perform a Commit Work at the conclusion of the program. You (usually) do not want to perform one earlier. This allows for restarting an update program with data that has not been partially changed by a previous failed execution.

Don't forget the points.

0 Kudos
147

Jai,

Have you completed your task?

If so, please close the thread and reward points accordingly.

If not, plz provide more details of the current error.

0 Kudos
147

Hi All,

Thanks a lot for ur help.

Regards,

Jai Shankar.