cancel
Showing results for 
Search instead for 
Did you mean: 

Prob in calling internal table in different event handlers

Former Member
0 Kudos

Hi friends,

I have a UI table displaying data from a database table..In the view i have a Delete button,I was able to remove a row from a table or i was able to delete the row from a database table from UI table..

My requirement when the user clicks on delete button the row must be removed from the UI table and once he clicks on the SAVE button,then the record shld be deleted from the database table...

I have other options like insert ,modify rows...i was able to achieve these by writing code in SAVE button.

Please help me how to invoke the delete code also in the SAVE button..

Regards

Ravikanth

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Ravi,

In order to display table in the VIEW we genrally have an internal table of same type as present in Database. Thus deleting row from TABLE in VIEW will not delete the record automatically from the Database table, instead you will have to keep hold of the row that was deleted in local structure.

Finally when user hits SAVE you will have to call DELETE on the SQL table specifying the Primary Key to identify the records to be deleted. Dont forget to call COMMIT to save the changes permanantly.

Greetings

Prashant

Former Member
0 Kudos

Hi Prasanth,

thank you for the reply..

in the save button i already have code for insertion and modification of the rows ...

this is the code im using in the save button

CALL METHOD LO_ND_N2->GET_LEAD_SELECTION_INDEX

RECEIVING

INDEX = INDEX.

CALL METHOD LO_ND_N2->GET_STATIC_ATTRIBUTES_TABLE

  • EXPORTING

  • FROM = 1

  • TO = 2147483647

IMPORTING

TABLE = ITAB.

loop at itab into wa.

read table itab into wa with key cs_unit = wa-cs_unit.

endloop.

if sy-subrc = 0.

modify /BI0/PCS_UNIT from table itab.

else.

insert /BI0/PCS_UNIT from table itab.

endif.

In this code i need to invoke DELETE Code also...please help me with invoking the delete code ..

Regards

ravikanth

Former Member
0 Kudos

Hello,

First of all, like described by Prasanth, in the action for the delete button save the deleted lines from the table UI in an internal table visible in the view and after this remove them from the context binded to the table UI element.

After this in the save button use the command DELETE to eliminate from transparent table all records from this new table that you created in the first step that I described.


* Just insert the following code after the last command that you passed.

DELETE /BI0/PCS_UNIT FROM TABLE it_deleted.

Regards.

Former Member
0 Kudos

Hi,

I have already done that,In Delete button code i have collected the rows that r removed into a internal table named DTAB,

When I write the following code in the save button

DELETE /BI0/PCS_UNIT FROM TABLE DTAB,...iam getting an error message tht DTAB is not Found...

I havent declared DTAB in SAVE Button code...so how do i call the DTAB in Delete event handler to SAVE event handler..

Regards,

Ravikanth

Former Member
0 Kudos

Hello,

You need to declare the internal table in the attributes area of the view, this way the internal table will be visible to all methods of the view.

To access it in any method of the view use the following sintax.


* In the save button, for example:
DELETE /BI0/PCS_UNIT FROM TABLE wd_this->dbtab.

*Do a loop in the internal table
DATA: ls_dbtab LIKE LINE OF wd_this->dbtab.

LOOP AT wd_this->dbtab INTO ls_dbtab.

ENDLOOP.

Regards.

Former Member
0 Kudos

HI David,

Thanks a lot ...my problem is solved.....

Hi Prasanth ..thanks for your support....

regards,

Ravikanth

Answers (1)

Answers (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

There is a DELETE command in Open SQL as well as the INSERT and MODIFY that you are already using.