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

insert statements while using tablecontrols.

raji_v
Explorer
0 Likes
895

Hi,

i am doing modulepool programming using table controls.

can anybody suggest me how to write insert and dalete statements in my program.

Thanks&Regards,

Raji.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
867

Hi,

simply as use in REPORT.


"for insert

      INSERT t352r FROM wa_work1.   " t352r is the name of data bse table,wa_work1 is the name of     work area  of internal table


"for delete
      DELETE t352r FROM TABLE it_del. 

Thanks

Arun

7 REPLIES 7
Read only

Former Member
0 Likes
868

Hi,

simply as use in REPORT.


"for insert

      INSERT t352r FROM wa_work1.   " t352r is the name of data bse table,wa_work1 is the name of     work area  of internal table


"for delete
      DELETE t352r FROM TABLE it_del. 

Thanks

Arun

Read only

raji_v
Explorer
0 Likes
867

hi,

other than this ,shall i write any code.its not working .i alreaady i tried with dis.

Thanks&Regards,

raji

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
867

Hi,

You will be displaying data into table control using an internal table so use this internal table to insert/update/delete your ztable from table control.

Use these statements:-


INSERT Y00MOVIES FROM TABLE MOVIE_TAB. "insert new records

UPDATE Y00MOVIES FROM TABLE MOVIE_TAB. "update existing records

MODIFY Y00MOVIES FROM TABLE MOVIE_TAB.
"insert if no record found
"else update

DELETE Y00MOVIES FROM TABLE MOVIE_TAB. "delete existing records

Y00MOVIES is a ztable and MOVIE_TAB is the internal table which is used to display data in table control on module pool screen.

Hope this solves your problem.

Thanks & Regards,

Tarun Gambhir

Read only

Former Member
0 Likes
867

Hi,

Try the code below.

PROCESS BEFORE OUTPUT.
LOOP AT itab WITH CONTROL TC. "table control name
   MODULE status_0500.
ENDLOOP.

PROCESS AFTER INPUT.
 LOOP AT itab.
    MODULE user_0500.
 ENDLOOP

.

MODULE user_0500 INPUT.

CASE ok_code.

WHEN 'INSERT'.

insert into tbl values struct. "struct is the work area with reqd values to be inserted

ENDCASE.

Hope this helps.

Regards.

Read only

Former Member
0 Likes
867

hi!

for insert

INSERT<table name> FROM <work area>.

for delete

DELETE <table name> FROM <work area>.

use this in your module where u want to perform this on which ever criteria it will work...

Read only

Former Member
0 Likes
867

hi raji,

you question is not very much clear where and what you want to insert and delete.

here i am explaining that you are selecting some record in table control and it is going to save in another internal table from where you can insert it into any ztable where you want and that record will delete from your table control.

in internal table take one more field FLAG.

and in table control define this field so that when you will select the perticuler record it will put 'X' in internal tabel.

in PAI.

modify your internal table ITAB1.

In PBO.

copy this selected record into another internal table ITAB2.

and delete that selected records from ITAB1.

insert itab2 into your ztable.

and display itab1 into table control with less records.

i think this will solve your problem.

thanks

abhishek prakash

Read only

sagarmehta
Product and Topic Expert
Product and Topic Expert
0 Likes
867

Hi raji,

you can see SAP provided examples for the same:-

Step 1: Go to transaction SE38 and then in the menu choose --->

Environment > Examples > Controls

Step 2: now, select Table Control and click on Source Code {double click to execute}

Step 3: scroll down to line 92 you will get your answer.

Alternatively, You can dirctly go to the Report Program RSDEMO02 in SE38 then to line 92.

{Also, there is another report called RSDEMO_TABLE_CONTROL which shows how to delete rows from a table control}

Hope this was of some help.

Best regards,

Sagar.