2007 Jun 19 10:12 AM
Hi!
SELECT INTERFACENAME ZTABLE EXPDAYS EXPERRORDAYS
FROM ZGL_MPF_CONFIG
INTO TABLE it_configtable.
LOOP AT it_configtable
DELETE FROM (it_configtable-ztable) WHERE (status = 'P' AND
processdat > SY-DATUM + it_configtable-expdays).
ENDLOOP.
SAP tells me status and processdat are unknow.
How i can delete this?
2007 Jun 19 10:18 AM
Hello Manel
Itab's with header lines are messing up any program. Thus, use table types and workareas instead:
DATA:
ld_date TYPE d,
lt_configtable TYPE STANDARD TABLE OF zgl_mpf_config,
ls_config TYPE zgl_mpf_config.
SELECT INTERFACENAME ZTABLE EXPDAYS EXPERRORDAYS
FROM ZGL_MPF_CONFIG
INTO TABLE lt_configtable.
LOOP at lt_configtable INTO ls_config
WHERE ( status = 'P' ).
" You have to calculate your date yourself...
ld_date = syst-datum + ls_config-expdays.
IF ( ls_config-processdat > ld_date ).
DELETE lt_configtable INDEX syst-tabix.
ENDIF.
ENDLOOP.
Regards
Uwe
2007 Jun 19 10:18 AM
Hello Manel
Itab's with header lines are messing up any program. Thus, use table types and workareas instead:
DATA:
ld_date TYPE d,
lt_configtable TYPE STANDARD TABLE OF zgl_mpf_config,
ls_config TYPE zgl_mpf_config.
SELECT INTERFACENAME ZTABLE EXPDAYS EXPERRORDAYS
FROM ZGL_MPF_CONFIG
INTO TABLE lt_configtable.
LOOP at lt_configtable INTO ls_config
WHERE ( status = 'P' ).
" You have to calculate your date yourself...
ld_date = syst-datum + ls_config-expdays.
IF ( ls_config-processdat > ld_date ).
DELETE lt_configtable INDEX syst-tabix.
ENDIF.
ENDLOOP.
Regards
Uwe
2007 Jun 19 12:36 PM
Hello Manel
I did not read your question carefully enough.
Since you are using a dynamic DELETE statement you cannot use a static WHERE clause. Instead define the where clause dynamic, too.
...
DATA:
ld_where_clause TYPE string.
LOOP at lt_configtable INTO ls_config.
" You have to calculate your date yourself...
ld_date = syst-datum + ls_config-expdays.
" Concatenate your dynamic WHERE clause
CONCATENATE ' STATUS = P'
' AND PROCESSDAT > ''' ld_date ''''
INTO gd_where_clause.
DELETE FROM (wa_configtable -ztable) WHERE (ld_where_clause).
ENDLOOP.
For details refer to the ABAP keyword documentation for SELECT & WHERE clause.
Regards
Uwe
2007 Jun 19 10:21 AM
Hi,
Declare the fields <b>status</b> and <b>processdat</b> in ur internal table.
And no need to specify the loop.
SELECT INTERFACENAME ZTABLE EXPDAYS EXPERRORDAYS
FROM ZGL_MPF_CONFIG
INTO TABLE it_configtable.
DELETE FROM (it_configtable-ztable) WHERE (status = 'P' AND
processdat > SY-DATUM + it_configtable-expdays).
2007 Jun 19 10:28 AM
hi,
check whether ur internal table is with or with out header line. your coding only works when internal table is with header line. if internal table is without header line then try like this while creating an work area for internal table as
data: begin of wa_wa_configtable.
.........................
.............................
end of wa_wa_configtable .
LOOP AT wa_configtable from it_configtable
DELETE FROM (wa_configtable -ztable) WHERE (status = 'P' AND
processdat > SY-DATUM + it_configtable-expdays).
ENDLOOP.
if useful reward some points.
with regards,
suresh.
2007 Jun 19 10:32 AM
try with field symbols
field-symbols : <FS> type any.
data : v_date like sy-datum.
LOOP AT it_configtable.
assign (it_configtable-ztable) to <FS>.
v_date = SY-DATUM + it_configtable-expdays.
DELETE FROM <FS> WHERE status = 'P' AND
processdat GT v_date.
ENDLOOP.
2007 Jun 19 11:12 AM
I have not explain the scenario too good,
ZTABLE is the name of the database table where i have to delete the records when status and processdat (fields of all ztables) verify the conditions.
The problem is that status and processdat are not in the internal table. This fields are in table of database!
Thanks!