Application Development and Automation 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: 
Read only

append

Former Member
0 Likes
1,198

friends

if i had to update a table then i had done

DATA: BEGIN OF ITAB_EMP_SAL.

INCLUDE STRUCTURE ZHR_PR_M_SAL.

DATA: END OF ITAB_EMP_SAL.

form data.

ITAB_EMP_SAL-INACT = ZHR_PR_M_SAL-INACT.

UPDATE ZHR_PR_M_SAL SET INACT = ITAB_EMP_SAL-INACT WHERE

PERID = ITAB_EMP_SAL-PERID.

end form.

but friends

now i m changing enteires for this table

so i want to append the whole line with chnaged enteries

that is to append the line in table and a field is their names STATS

for previous entry it should donate 'X'.

Please Help me out

Hope u people got my Problem

With Best Regards

Ruby

13 REPLIES 13
Read only

Former Member
0 Likes
1,171

hi,

Your requirement is not clear. Which table you want to update.

elaborate ur requirement pls.

Regards

Azad.

Read only

0 Likes
1,171

basically

i had a table zhr_pr_m, zhr_pr_m_ad,zhr_pr_m_sal.

i had displayed the values from these above table

these r fields of zhr_pr_m

<u>PERID</u>

OBJID

INACT

<b>STATS</b>

PCODE

CCODE

FNAME

MNAME

zhr_pr_m_ad

MANDT

<u>PERID</u>

OBJID

INACT

<b>STATS</b>ADDR1

ADDR2

in a tabstrip i had displayed all these fields through internal table

now wen i make any changes in fname or nay other field and save in database then

first of all

the previous entry <b>stats</b> should be marked as "X'.

and objid should be incremented by 1

and all the enteries should be appended in the table not updating the current field

<u>perid</u> is primary key

Hope Now u got my problem and will naswer soon

With Best Regards

Ruby

Read only

0 Likes
1,171

Hi ruby,

Do one thing . Store the previous values of fname or any other fields in a some variables. Then compare the previous values with the new values. If the values are different then APPEND, Else let it remain same.

Rewards Points if helpful.

regards

Sourabh Verma

Read only

Former Member
0 Likes
1,171

hi

use this syntax it is usefull to you.

UPDATE

Changes entries in database tables.

Syntax

UPDATE <dbtab> SET <si> = <f>

|<si> = <s i> + <f>

|<si> = <s i> - <f> [WHERE <cond>].

The value in the column <si> is set to the value <f>, increases it by <f>, or decreases it by <f> for all lines selected. The WHERE clause specifies the lines that are changed. If you omit the WHERE clause, all lines are changed.

Syntax

UPDATE <dbtab> FROM <wa>.

UPDATE <dbtab> FROM TABLE <itab>.

This deletes the line that has the same primary key as the work area <wa>, or deletes all the lines in the database that have the same primary key as a line in the internal table <itab>. The work area <wa> or the lines of the internal table <itab> must have at least the same length and alignment as the lines of the database table.

regards,

Santosh

*****reward points for usefull answrs***

Read only

Former Member
0 Likes
1,171

hi

use this syntax it is usefull to you.

Changes entries in database tables.

The value in the column <si> is set to the value <f>, increases it by <f>, or decreases it by <f> for all lines selected. The WHERE clause specifies the lines that are changed. If you omit the WHERE clause, all lines are changed.

UPDATE <dbtab> FROM <wa>.

UPDATE <dbtab> FROM TABLE <itab>.

This deletes the line that has the same primary key as the work area <wa>, or deletes all the lines in the database that have the same primary key as a line in the internal table <itab>. The work area <wa> or the lines of the internal table <itab> must have at least the same length and alignment as the lines of the database table.

*****reward points for usefull answrs***

Message was edited by:

Venkata Santosh Kumar Boddu

Message was edited by:

Venkata Santosh Kumar Boddu

Message was edited by:

Venkata Santosh Kumar Boddu

Read only

Former Member
0 Likes
1,171

Hi Ruby,

Use MODIFY instead of APPEND.

Rewards Points if helpful

regards

Sourabh Verma

Read only

0 Likes
1,171

hi,

Wat u can do is,

see you have data in internal table which you are displaying.

when ever you make change and press save button append a record in that internal table with increased number.

after that use MODIFY database table From your internal table.

hope it will work,

Reward if helpfull.

Regards

Azad.

Read only

0 Likes
1,171

see this

DATA:BEGIN OF ITAB_EMP.

INCLUDE STRUCTURE ZHR_PR_M.

DATA: END OF ITAB_EMP.

module USER_COMMAND_0012 input.

CASE SY-UCOMM.

when 'DISP'.

break-point.

perform get_data.

when 'save'.

endcase.

endmodule. " USER_COMMAND_0012 INPUT

form get_data .

select * from zhr_pR_m into corresponding fields of itab_emp

where perid = zhr_pR_m-perid.

endselect.

zhr_pr_m-FNAME = itab_emp-fname.

zhr_pr_m-MNAME = itab_emp-mname.

zhr_pr_m-LNAME = itab_emp-lname.

endform. " get_data

it displays the data in my input output fields of my screens

Now tell me code for Case 'Save'.

With best Regards

Ruby

Read only

0 Likes
1,171

Hi ruby ,

Can you plese elaborate what action you want to do on save..

I sure i can help you.

Regards

Sourabh Verma

Read only

0 Likes
1,171

had a table zhr_pr_m, zhr_pr_m_ad,zhr_pr_m_sal.

i had displayed the values from these above table

these r fields of zhr_pr_m

PERID

OBJID

INACT

STATS

PCODE

CCODE

FNAME

MNAME

zhr_pr_m_ad

MANDT

PERID

OBJID

INACT

STATSADDR1

ADDR2

in a tabstrip i had displayed all these fields through internal table

now wen i make any changes in fname or nay other field and save in database then

first of all

<b>the previous entry stats should be marked as "X'.</b>and

<b>objid should be incremented by 1</b>

<b>append enteirs shoul dbe their with previous entry</b>

Means Old entries are to be their in database

Hope u got now

and all the enteries should be appended in the table not updating the current field

perid is primary key

Hope Now u got my problem and will naswer soon

<b>BOLD LINES GIVES TEH REQUIREMENT</b>

With Best Regards

Ruby

Read only

0 Likes
1,171

HI Ruby,

Do this,

WHEN SAVE.

select * from zhr_pR_m into corresponding fields of itab_emp

where perid = zhr_pR_m-perid.

endselect.

The idea is to get the existing data into itab_emp based on the particular perid.

Declare declare variable v_fname , v_perid, v_inact, v_stats...and so on.

Pass the values of itab_emp in these variables.

Now get the existing values entered.

Compare these valuse against the previous values.

If the values are different then

STAT = 'X'.

and objid = objid +1.

APPEND itab_empl.

Ruby I can only tell you the logic how to get your requirement.

Rewards points if it helps

regards

Sourabh Verma

Read only

0 Likes
1,171

Thanx Friend but logic is some hw clear to me also

i m not getting how to deal with it

i had tried some of them

its not appending

its just changing the table values means updating

Pata nahi kaise karna hai

Hope somebody post me the code which will help me out

My requirement must be clear

Thanks & Regards

Ruby

Read only

Former Member
0 Likes
1,171

Hi ,

You can do that using MODIFY statement.

Loop at itab into wa.

read table itab1 into wa1 with key field1 = wa-field1.

move wa1-field2 to wa-field2.

MODIFY itab from wa.

Endloop.

If it helps... don't forget REWARD

rgds

harris