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

modifying one table from two internal tables

Former Member
0 Likes
719

Hi All,

I am a having a basic alv list records with check boxes .

For Example in the Basic list :

WH Rectyp Count List No Docmnt no Count No. Status No Blocking Reason Code

012 CC 0001 0000000001 001 13 A

When I select the check box for the above record and click on a push button "Recount'.

system has to create a new record in the database table (ex:/tdit/sc_workltu) with the same record details but by incrementing Count No by 1 and it has to change the status to 10 .After creating a new record it has to update the original record with the status 14 instead of 13 . as shown below

WH Rectyp Count List No Docmnt no Count No. Status No Blocking Reason Code

Orig 012 CC 0001 0000000001 001 13 A

New 012 CC 0001 0000000001 002 10 A

Updorg 012 CC 0001 0000000001 001 14 A

I had written the code but I am unable to create a new with all field data it is only updating the status with 10 and remainig fields are getting empty .

like

WH Rectyp Count List No Docmnt no Count No. Status No Blocking Reason Code

New 10

Updorg 012 CC 0001 0000000001 001 14 A

My Code :

DATA: lt_tasks TYPE STANDARD TABLE OF zrf2_tasks,

ls_tasks LIKE LINE OF lt_tasks,

lt_new TYPE STANDARD TABLE OF /tdit/sc_workltu,

ls_new LIKE LINE OF lt_new,

lt_orig TYPE STANDARD TABLE OF /tdit/sc_workltu,

ls_orig LIKE LINE OF lt_orig.

LOOP AT gt_final INTO ls_final WHERE check_box EQ 'X' .

IF ls_final-status EQ '13' .

  • Increase the count number by 1

ls_new = ls_final.

ls_new-counum = ls_final-counum + 1.

ls_new-status = '10'.

APPEND ls_new TO lt_new.

CLEAR ls_new.

  • MODIFY /tdit/sc_workltu FROM table lt_new.

  • update original task to status 14

ls_orig = ls_new = ls_final.

ls_orig-belnum = ls_final-belnum.

ls_orig-status = '14'.

APPEND ls_orig TO lt_orig.

CLEAR ls_orig.

*Determine input parameters for walksequence

ls_tasks-belnum = ls_final-belnum.

ls_tasks-wzone = ls_final-wzone.

ls_tasks-lgnum = ls_final-lgnum.

SELECT SINGLE reihf

FROM lagp

INTO ls_tasks-reihf

WHERE lgnum = ls_final-lgnum.

APPEND ls_tasks TO lt_tasks.

CLEAR ls_tasks.

ELSE.

IF ls_final-status = '10' OR

ls_final-status = '11' OR

ls_final-status = '12' OR

ls_final-status = '16' OR

ls_final-status = '17'.

ls_tasks-belnum = ls_final-belnum.

ls_tasks-wzone = ls_final-wzone.

ls_tasks-lgnum = ls_final-lgnum.

SELECT SINGLE reihf

FROM lagp

INTO ls_tasks-reihf

WHERE lgnum = ls_final-lgnum.

APPEND ls_tasks TO lt_tasks.

CLEAR ls_tasks.

ENDIF.

ENDIF.

ENDLOOP.

MODIFY /tdit/sc_workltu FROM table lt_orig.

MODIFY /tdit/sc_workltu FROM table lt_new.

Please verify the code and provide me the solution

<< Moderator message - Everyone's problem is important. But the answers in the forum are provided by volunteers. Please do not ask for help quickly. >>

Thank you .

Regards,

Bharat Kumar

Edited by: Rob Burbank on Jul 14, 2011 10:44 AM

4 REPLIES 4
Read only

Former Member
0 Likes
621

Hi Bharat,

Though I am not sure if your table key field got changed or not. If not then it should not create a new entry. Also you can out commit work after modifying the table.

Thanks and Regards,

Mrinmoy

Read only

0 Likes
621

Hi Mrinmoy,

No Key field has been changed .

System has to create a new records with status 10 by incrementing the countno by 1 and update the table and update the original record with status 14 .

Thank you .

Regards,

Bharat

Read only

shafiqahmed_khan
Explorer
0 Likes
621

Hi Bharath,

When u modify the standard table check for sy-subrc if its 0, then use insert statement to add a new record.

regards,

Shafiq.

Read only

Former Member
0 Likes
621

Hi,

if i understand the problem correctly, try

loop at lt_orig .

read table lt_new with <key_fields> .

move-corresponding lt_orig to <db_table> .

move-corresponding lt_new to <db_table>.

modify <db_table> .

endloop .

Best Regards,

Burak