‎2010 May 27 12:49 PM
HI all,
I have to test some programs and want to clear values in tables to check the behavior of a program when dealing with initial values.
I using this code:
parameters: p_pernr type pa0105-pernr,
p_val type pa0105-usrid.
data: ls_pa0105 type pa0105.
select single * from pa0105 into ls_pa0105
where subty = '0001'
and pernr = p_pernr.
if sy-subrc = 0.
if p_val is initial.
clear ls_pa0105-usrid.
else.
ls_pa0105-usrid = p_val.
endif.
modify pa0105 from ls_pa0105.
endif.
This works if I put a value in p_val but it does nothing if I leave p_val initial.
Even if I clear the field, when I execute the modify, nothing has change in the table.
Thanks for any help.
‎2010 May 27 1:21 PM
Hi,
try the below code.
select single * from pa0105 into ls_pa0105
where subty = '0001'
and pernr = p_pernr.
if sy-subrc = 0.
if p_val is initial.
clear ls_pa0105-usrid.
else.
ls_pa0105-usrid = p_val.
endif.
modify pa0105 from ls_pa0105 TRANSPORTING USRID.
endif.
Hope it helps.
Regards
Shruti
‎2010 May 27 12:56 PM
Hi
try this code.
if sy-subrc = 0 .
clear ls_pa0105-usrid.
else.
ls_pa0105-usrid = p_val.
endif.
Modify pa0105 from ls_pa0105.
‎2010 May 27 1:08 PM
Hi,
It's the same code has I have tried, except for the p_val checking.
Checking p_val is not the problem, I debug the program and it goes through the clearing and modify part of the program.
In the debugger I can see that the usrid field is empty, but this does nothing in the table itself.
‎2010 May 27 1:21 PM
Hi,
try the below code.
select single * from pa0105 into ls_pa0105
where subty = '0001'
and pernr = p_pernr.
if sy-subrc = 0.
if p_val is initial.
clear ls_pa0105-usrid.
else.
ls_pa0105-usrid = p_val.
endif.
modify pa0105 from ls_pa0105 TRANSPORTING USRID.
endif.
Hope it helps.
Regards
Shruti
‎2010 May 27 1:29 PM
Hello,
This works only for an internal table, I'm updating a database table.
If I put this I get a syntax error.
‎2010 May 27 2:03 PM
Hi,
I have tried implementing this in my system with the code below, which seems to work fine. Here, the table tbl5 has 2 columns PARAMNAME and PARAMVALUE. The PARAMVALUE initially has the value 'X' which is cleared in the program and the database table is modified corretly.
Please check if you are missing out something by refering this.
DATA: wa_tbl5 type tbl5.
select single * from tbl5 into wa_tbl5
where paramname = 'param1'.
clear wa_tbl5-PARAMVALUE.
modify tbl5 from tbl5.
if sy-subrc EQ 0.
write: 'success'.
else.
write:/ 'fail'.
endif.
Thanks,
Sowmiya M
‎2010 May 27 2:18 PM
How silly of me,
I had multiple rows in that table so I was actually writing to one row and the other program was reading the other row!
My code was working all this time.
Thanks all for your help.