11-08-2006 9:40 PM
hi folks,
I am trying to modify the records in the internal table. It is not happening.
data: it_pb4000 type standard table of pb4000 with header line.
select * from pb4000 up to 1 rows into table it_pb4000
where pernr = g_app ORDER BY begda DESCENDING.
if sy-subrc = 0.
read table it_pb4000 index 1.
******the value is cleared...
clear it_pb4000-endda.
*****NOT HAPPENING****
modify it_pb4000 transporting endda where
endda = '99991231'.
modify pb4000 from it_pb4000.
can anyone tell me where I am doing wrong?
Thanks
Vinu.
11-08-2006 9:49 PM
hi Vinu,
From the code it seems like you have only 1 record in the internal table.
hence you can change the code a little, as shown below:
modify it_pb4000 index 1.
modify pb4000 rom it_pb4000.
if this is not working, you can use internal table (without header line ) and work area, which would be more advicable.
Hope this helps.
Sajan.
11-08-2006 9:45 PM
Hi,
Check if there is any record available in IT_PB4000 for ENDDA = '99991231'.
THanks,
Naren
11-08-2006 9:49 PM
hi Vinu,
From the code it seems like you have only 1 record in the internal table.
hence you can change the code a little, as shown below:
modify it_pb4000 index 1.
modify pb4000 rom it_pb4000.
if this is not working, you can use internal table (without header line ) and work area, which would be more advicable.
Hope this helps.
Sajan.
11-08-2006 9:56 PM
sorry folks, the logic is wrong.. I realized. Let me tell you what I am trying to do..
I have one record in table 'it_pb4000' and I have to change the enddate to '9999/12/31' hecne i cleared the field 'endda'.
My question is how can i insert this date into the internal table first?
After inserting the data I need to update the same record with this new date into the database table from this internal table?
Sorry for the confusion.
thanks in advance
vinu
11-08-2006 10:00 PM
Instead of clearing the enddate, whay aren't you setting it to '99991231'?
it_pb4000-endda = '99991231'.
modify it_pb4000 transporting endda.
Rob
Message was edited by: Rob Burbank
11-08-2006 10:11 PM
11-08-2006 10:16 PM
Try:
it_pb4000-endda = '99991231'.
modify it_pb4000 index 1 transporting endda.
Rob
11-08-2006 10:25 PM
A more elegant solution would be to use field symbols:
FIELD-SYMBOLS: <data> TYPE pb4000.
...
READ TABLE it_pb4000 INDEX 1 ASSIGNING <data>.
CLEAR <data>-endda.
Rob
11-08-2006 10:44 PM
hi,
I am trying something like this...
Actually I am trying to delimit the last record to '12/31/9999' in the table. Since the last record will have the enddate one day less than the begin date of the current record.
Hence I reading the current date into a variable and subtracting one day from it and tracking the record in the table using that date and changing the enddate to '12/31/9999' using 'UPDATE'.
update pb4000 from wa_p4000 where endda = g_endda.
But this command is not working.
Thanks for help.
Vinu
11-08-2006 11:02 PM
hi Vinu,
Use the following logic.
Data wa_p4000 type p4000.
data lv_endda type p4000-endda.
select * from pb4000 up to 1 rows into wa_p4000 where pernr = g_app ORDER BY begda DESCENDING.
endselect.
lv_endda = wa_04000-endda.
wa_p4000-endda = '99991231'.
update pb4000 set endda = wa_p4000-endda
where PERNR = wa_p4000-pernr and
SUBTY = wa_p4000-subty and
OBJPS = wa_p4000-objps and
SPRPS = wa_p4000-sprps and
ENDDA = lv_endda
BEGDA = wa_p4000-begda
SEQNR = wa_p4000-seqnr.
hope this helps.
Sajan.
yeah you can change the type to PB4000..
Reward points if helped....
Message was edited by: Sajan Joseph
11-08-2006 11:41 PM
hi,
I think this should work,but the wa_p400 has been defined with structure p4000. But the table has MANDT field and henec all the records are pushed by three chars. let me try by declaring the table and see.
Thanks
Vinu
11-08-2006 11:54 PM
hi Sajan,
I used with the internal table instead of work area. it worked.Thanks a lot for your help. I shall award the points.
Vinu
11-08-2006 9:54 PM
The code you wrote should work (at least as far as modifying the internal table). Are you asking about that or the database table update?
Rob
11-08-2006 10:05 PM
Hi,
Changes are marked in bold..
select * from pb4000 up to 1 rows into table it_pb4000
where pernr = g_app ORDER BY begda DESCENDING.
if sy-subrc = 0.
read table it_pb4000 index 1.
******the value is cleared...
<b>it_pb4000-endda = '99991231'.
modify it_pb4000 index 1.</b>
modify pb4000 from it_pb4000.
Thanks,
Naren
11-08-2006 10:08 PM
hi Vinu,
Since your requirement is to retrieve the last record (based on date) and set the date to 31.12.9999, you dont need to store the date to an internal table.
you just need on work area of type PB4000.
Data wa_p4000 type p4000.
select * from pb4000 upto 1 rows into in wa_p4000 <where condition>.
wa_p4000-endda = '99993112'.
modify pb4000 from wa_p4000.
Hope this resolves your issue.
Sajan.
11-08-2006 10:25 PM
Sajan,
Thanks that helped. But it is creating another record in the databse table, actually it hsould update the enddate of the existing record in the databse table.should I need to use Update and update the existing record??
Thanks
Vinu
11-08-2006 10:18 PM
Hi,
Please try the solution posted in my earlier post..
Thanks,
Naren
11-08-2006 10:21 PM
Data wa_p4000 type p4000.
select * from pb4000 up to 1 rows into wa_p4000 where pernr = g_app ORDER BY begda DESCENDING.
endselect.
wa_p4000-endda = '99991231'.
modify pb4000 from wa_p4000.
this should work Vinu...or else, there is no data in wa_p4000...thats why it is dumping.
Sajan.