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 specified records from IT Table

Former Member
0 Likes
562

HI,

I've this SELECT statement

SELECT com01 num01 com02 num02 com03 num03

com04 num04 com05 num05 com06 num06 FROM pa0006

INTO CORRESPONDING FIELDS OF TABLE lt_zgestor

WHERE pernr EQ l_pernr.

and I want delete select from LT_ZGESTOR , field num(xx) where com(xx) eq 'WORK'

How can I do this ?

Thanks,

1 ACCEPTED SOLUTION
Read only

MarcinPciak
Active Contributor
0 Likes
527

Do you want to empty field num(xx) if corresponding field com(xx) eq 'WORK' ? Do I understand it correctly?

If so then you can use this code


field-symbols: <num>, <com>.

data: com(5) type c, 
         num(5) type c.
        idx(2) type n.

Loop at LT_ZGESTOR.
 do 6 times.
   idx = sy-index.   "01, 02, 03, ...
   concatenate 'COM' idx into com.  "COM01, COM02,....
   concatenate 'NUM' idx into num.  "NUM01, NUM02 ...
   
   assign component: COM of structure LT_ZGESTOR to <com>,
                                  NUM of structure LT_ZGESTOR to <num>.
   if <com> = 'WORK'.
       clear <num>.
   endif.        
 enddo.
endloop.

or if you want to delete records where COM(XX) eq 'WORK'.


"just change this
...
   if <com> = 'WORK'.
       delete LT_ZGESTOR index sy-tabix.
       exit.  "exit DO loop and get next record
   endif.    

Regards

Marcin

HI,

I've this SELECT statement

SELECT com01 num01 com02 num02 com03 num03

com04 num04 com05 num05 com06 num06 FROM pa0006

INTO CORRESPONDING FIELDS OF TABLE lt_zgestor

WHERE pernr EQ l_pernr.

and I want delete select from LT_ZGESTOR , field num(xx) where com(xx) eq 'WORK'

How can I do this ?

Thanks,

2 REPLIES 2
Read only

Former Member
0 Likes
527

Are you looking for something like this?


delete lt_zgestor where com01 = 'WORK' OR com02 = 'WORK' ......com05 = 'WORK'.

Vikranth

Read only

MarcinPciak
Active Contributor
0 Likes
528

Do you want to empty field num(xx) if corresponding field com(xx) eq 'WORK' ? Do I understand it correctly?

If so then you can use this code


field-symbols: <num>, <com>.

data: com(5) type c, 
         num(5) type c.
        idx(2) type n.

Loop at LT_ZGESTOR.
 do 6 times.
   idx = sy-index.   "01, 02, 03, ...
   concatenate 'COM' idx into com.  "COM01, COM02,....
   concatenate 'NUM' idx into num.  "NUM01, NUM02 ...
   
   assign component: COM of structure LT_ZGESTOR to <com>,
                                  NUM of structure LT_ZGESTOR to <num>.
   if <com> = 'WORK'.
       clear <num>.
   endif.        
 enddo.
endloop.

or if you want to delete records where COM(XX) eq 'WORK'.


"just change this
...
   if <com> = 'WORK'.
       delete LT_ZGESTOR index sy-tabix.
       exit.  "exit DO loop and get next record
   endif.    

Regards

Marcin