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: 

internal table

Former Member
0 Kudos

hi all

i have created a table with empid,empsalary,created dare ,created time.

initially i have some entries in the table.

whenever i update the salary of the existing records in the table i want to modify the time and date too.so that i can keep track of when the record is lastly updated

can anyone tell me on how to do that.

1 ACCEPTED SOLUTION

kiran_k8
Active Contributor
0 Kudos

Hemavathi,

use control break statements.

Loop at itab.

on change of itab-sal.

modify itab.

endon.

endloop.

K.Kiran.

11 REPLIES 11

Former Member
0 Kudos

Hello,

create two more fields in the table modity date and time and when u modify the salary modify date and time to current date and time.

Regards,

Neelambari

kiran_k8
Active Contributor
0 Kudos

Hemavathi,

use control break statements.

Loop at itab.

on change of itab-sal.

modify itab.

endon.

endloop.

K.Kiran.

Former Member
0 Kudos

Simply update the fields from the ABAP system fields for date and time.

e.g.

select single * from ztable

where empid = p_empid.

check sy-subrc eq 0.

ztable-empsalary = 40000.

ztable-crdate = sy-datum.

ztable-crtime = sy-uzeit.

modify ztable.

commit work and wait.

Regards,

Darren

alex_m
Active Contributor
0 Kudos

Create a new fields date and time in your existing custom table, when ever you r updating the records pass the current system date and time for the new fields and do commit.

Add user name also a new field.

Former Member
0 Kudos

hi,

try like this.

data: itab like mara occurs 0 wit header line.

data: rcno tye i value 1.

itab - salary = '1000'.

modify itab.

if sy-subrc eq 0.

rcno = rcno + 1.

itab- date = '12.06.07'.

itab-time = '12.00.00'.

modify itab.

write:/10 rcno 'records modified'.

else.

write:/10 ' no record modified'.

endif.

if useful reward some points.

with regards,

Suresh.A

Former Member
0 Kudos

thanks for your answers,

but when i tried to update the date and time when there is a change in salary all the records which are there in the z-table are updated with the date and time

I want only the record which i updated with the new salry to be changed with new date and time.

since i am using an excel file here to upload the data to an internal tableI think all the records are inserted once again in the custom table....thats why for all the records the date and time is updated.can anyone tell me where i am going wrong

0 Kudos

Please supply a copy of the code you are using.

Regards

Darren

0 Kudos

try to use

select single *

i hope that can help you out

thnkx

bhanu

0 Kudos

REPORT ZLOADZPCPPDM.

TABLES:ZPCPPDM.

TYPE-POOLS: truxs.

DATA: it_raw TYPE truxs_t_text_data.

data: begin of ITAB occurs 10,

mandt like zpcppdm-mandt,

plant like zpcppdm-plant,

material like zpcppdm-material,

Z_period like zpcppdm-Z_period,

Z_year like zpcppdm-Z_year,

Z_savings like zpcppdm-z_savings,

end of ITAB.

DATA: ITAB1 TYPE TABLE OF ZPCPPDM WITH HEADER LINE.

DATA FILENAME TYPE rlgrap-filename VALUE 'C:\Documents and Settings\279089\Desktop\NEW.XLS'.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

  • I_FIELD_SEPERATOR =

I_LINE_HEADER = ' '

i_tab_raw_data = IT_RAW

i_filename = FILENAME

tables

i_tab_converted_data = ITAB

EXCEPTIONS

CONVERSION_FAILED = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

loop at itab.

SELECT COUNT(*) FROM zpcppdm.

if sy-dbcnt <> 0.

select * from zpcppdm where plant = itab-plant and material = itab-material and z_period = itab-z_period and z_year = itab-z_year.

if sy-subrc = 0. "sucess for select

if zpcppdm-Z_savings <> itab-Z_savings.

update zpcppdm set Z_savings = itab-z_savings where plant = itab-plant and material = itab-material and z_period = itab-z_period and z_year = itab-z_year.

if sy-subrc = 0. "success for update

write 'updatd'.

else .

write 'not update'.

endif.

ELSE.

CONTINUE.

endif.

endif.

endselect.

endif.

move-corresponding ITAB to ITAB1.

ITAB1-Z_user = sy-uname.

ITAB1-Z_DATE = SY-DATUM.

ITAB1-z_TIME = SY-UZEIT.

append ITAB1.

if not ITAB1[] is initial.

modify zpcppdm from ITAB1.

endif.

endloop.

0 Kudos

Try this logic within the loop....

loop at itab.

select single * from zpcppdm

where plant = itab-plant

and material = itab-material

and z_period = itab-z_period

and z_year = itab-z_year.

if sy-subrc = 0. "sucess for select

if zpcppdm-Z_savings <> itab-Z_savings.

  • UPDATE EXISTING

zpcppdm-z_date = SY-DATUM.

zpcppdm-z_time = sy-uzeit.

zpcppdm-Z_savings = itab-Z_savings.

modify zpcppdm.

else.

  • NO UPDATE

continue.

endif.

else.

  • NEW RECORD

clear zpcppdm.

move-corresponding itab to zpcppdm.

zpcppdm-Z_user = sy-uname.

zpcppdm-Z_DATE = SY-DATUM.

zpcppdm-z_TIME = SY-UZEIT.

insert zpcppdm.

endif.

endloop.

Regards,

Darren

Former Member
0 Kudos

"Supposing ur database table name is ZTAB

DATA:

ITAB LIKE TABLE OF ZTAB WITH HEADER LINE.

*now suppose ur excel file contained EMPID and EMPSALARY fields only,

*and ur program has uploaded data into ITAB.

*now u have to code something like this in ur program:-

data:WA_ZTAB like ZTAB.

loop at ITAB.

select SINGLE * from ZTAB

into WA_ZTAB

where EMPID = ITAB-EMPID.

if sy-subrc eq 0.

if WA_ZTAB-EMPSALARY ne ITAB-EMPSALARY.

WA_ZTAB-CR_DATE = SY-DATUM.

WA_ZTAB-CR_TIME = SY-UZEIT.

MODIFY ZTAB FROM WA_ZTAB. "modify database

endif.

else. "SY-SUBRC ne 0

ITAB-CR_DATE = SY-DATUM.

ITAB-CR_TIME = SY-UZEIT.

insert into ZTAB values ITAB.

endif. "sy-subrc

endloop.

Message was edited by:

Tripat Pal Singh