Application Development 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: 

records not modifying

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

17 REPLIES 17

Former Member
0 Kudos

Hi,

Check if there is any record available in IT_PB4000 for ENDDA = '99991231'.

THanks,

Naren

Former Member
0 Kudos

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.

0 Kudos

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

0 Kudos

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

0 Kudos

It results in short dump.

Thanks

Vinu

0 Kudos

Try:

it_pb4000-endda = '99991231'.
modify it_pb4000 index 1 transporting endda.

Rob

0 Kudos

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

0 Kudos

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

0 Kudos

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

0 Kudos

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

0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

0 Kudos

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

Former Member
0 Kudos

Hi,

Please try the solution posted in my earlier post..

Thanks,

Naren

0 Kudos

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.