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

Delete record from Internal Table based on parameters

Former Member
0 Likes
1,271

Case Situation: Data of 7 fields are fetched in an internal table, based on 7 parameters. 2 parameters refers type to different table. I have to narrow down my internal table based on the rest 5 parameters. Out of them only 1 parameter is mandatory. I don't want to delete any record which satisfies one parameter and accidentally gets deleted if I want to delete record with null parameters.

Example: Based on date(mandatory), category, territory, I fetch data in Internal Table. The parameter field description is empty. I don't want to delete data from the internal table whose description field is empty, but was fetched based on other parameters.

How is it possible?

5 REPLIES 5
Read only

Former Member
0 Likes
923

Hello Soumen,

Could you pls elaborate your requirement as i am not getting what exactly you want. It would be nice if paste your piece of code here for better understanding.

regards,

Deepti

Read only

0 Likes
923

The pasted code was dumped

Read only

Former Member
0 Likes
923

Hello Soumen,

Try this,

loop at intab into wa

  if wa-para_desc is not empty.

    wa-del = 'X'.          " add del as type c in your intab declaration part

    modify intab from wa transporting del

endif.

" now add your other delete logic over here if you need.

endloop.

delete intab where del = 'X'.

Thanks,

Ben

Read only

Former Member
0 Likes
923

The case situation elaboration.

There are 7 parameters, 4 parameters are type of  4 fields from TableA, and  3 parameters are type of  3 fields from TableB. I have extracted necessary fields to an Internal table of type TableA based on a mandatory input parameter. Now I want to narrow down the records of the internal table of Type TableA. Suppose a record was fetched that based on parameter P1 type Field1 of TableA, which has no value for the Field2. This is a valid record. Now if a value was not passed in parameter P2. It will fetch all data with null values in Field2. And when deleting the record of Internal Table with Null Values, the particular record that was fetched based on P1 will also get deleted.

How to prevent this?

Read only

0 Likes
923

Hi,

First thing, declare your own structure of int_tab.( not of type A)

begin of struct,

field1 type tabA-field1,

field2 type tabB-field2,

......

......

flag type c, "     put this flag to 'X' when record is selected from tab with P1 ( put code in sy-subrc EQ 0)

del type c.

end of struct.

Now declare inat and work area...

now set the flag to X after select query with parameter P1..

IF sy-subrc eq 0.

  work_area-del = 'X'.  " you can use flag also... its upto you...

  modify intab based on record..

endif.

clear wa..

thanks,

Ben