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

loops problem

Former Member
0 Likes
970

Hellow I wont in field wa_itab_final-status_resom = text-004. to be a defrent text from the text in 003 but it not working all the text in the field is text-003 and in the second select I bring difrent value so the text have to to change accordingly thankes

LOOP AT itab_final INTO wa_itab_final.

MOVE wa_c_itab-begda TO wa_itab_final-begda.

MOVE wa_c_itab-endda TO wa_itab_final-endda.

MOVE wa_c_itab-priox TO wa_itab_final-priox.

MOVE wa_c_itab-istat TO wa_itab_final-istat.

SELECT SINGLE stext

FROM hrp1000

INTO wa_itab_final-stext

WHERE objid = wa_c_itab-objid.

<b>wa_itab_final-status_resom = text-003</b>.

MODIFY itab_final FROM wa_itab_final.

ENDLOOP.

*--


employye that register to the course-----

LOOP AT itab INTO wa_itab.

READ TABLE d_itab INTO wa_d_itab WITH KEY employee_num_reg = wa_itab-objid.

IF sy-subrc = 0.

wa_itab_final-objid = wa_itab-objid.

wa_itab_final-firstname = wa_itab-firstname.

wa_itab_final-lastname = wa_itab-lastname.

<b> wa_itab_final-status_resom = text-004.

</b> APPEND wa_itab_final TO itab_final.

ENDIF.

ENDLOOP.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
944

I did not get your exact requirement but if below is what you want..then check the given solution.

U wish to update the itab_final-status_resom field to be text-003 or text-004 depending on the loop. In the first loop you would set it to 003 and if the employee has registered for the course it should be 004.

If that is the case change the below loop -->

LOOP AT itab INTO wa_itab.

READ TABLE d_itab INTO wa_d_itab WITH KEY employee_num_reg = wa_itab-objid.

IF sy-subrc = 0.

read table itab_final into wa_itab_final with key objid = wa_d_itab-objid.

*wa_itab_final-objid = wa_itab-objid.

wa_itab_final-firstname = wa_itab-firstname.

wa_itab_final-lastname = wa_itab-lastname.

wa_itab_final-status_resom = text-004.

*APPEND wa_itab_final TO itab_final.

MODIFY itab_final from wa_itab_final index sy-tabix.

ENDIF.

ENDLOOP.

9 REPLIES 9
Read only

Former Member
0 Likes
944

Introduce a CLEAR WA_ITAB_FINAL staement between the two LOOP statements and try.

Regards,

Ravi

Note : Please mark all the helpful answers

Read only

0 Likes
944

helloe ravi its not working i thihnk becouse of append and modify

Read only

0 Likes
944

Hello,

If the WA_FINAL-SATUS_RESOM should always TEXT-004, then make the change in the first loop also..

Vasanth

Read only

0 Likes
944

hi vasanthits not i just wont that when the first loop is happens in wa_itab_final-status_resom = <b>text-003</b>.

and when the second loop happen wa_itab_final-status = <b>text-004</b><b></b>

Read only

Former Member
0 Likes
944

Hello,

After APPEND Statement <b>Clear wa_itab_final</b> in both the loops.

If useful reward.

Vasanth

Read only

0 Likes
944

hellow vasanth its not working

Read only

Former Member
0 Likes
944

It is not recommended to use TEXT SYMBOLS in WHERE CLAUSES instead use variables. This may give dumps.

Read only

Former Member
0 Likes
945

I did not get your exact requirement but if below is what you want..then check the given solution.

U wish to update the itab_final-status_resom field to be text-003 or text-004 depending on the loop. In the first loop you would set it to 003 and if the employee has registered for the course it should be 004.

If that is the case change the below loop -->

LOOP AT itab INTO wa_itab.

READ TABLE d_itab INTO wa_d_itab WITH KEY employee_num_reg = wa_itab-objid.

IF sy-subrc = 0.

read table itab_final into wa_itab_final with key objid = wa_d_itab-objid.

*wa_itab_final-objid = wa_itab-objid.

wa_itab_final-firstname = wa_itab-firstname.

wa_itab_final-lastname = wa_itab-lastname.

wa_itab_final-status_resom = text-004.

*APPEND wa_itab_final TO itab_final.

MODIFY itab_final from wa_itab_final index sy-tabix.

ENDIF.

ENDLOOP.

Read only

Former Member
0 Likes
944

Hi Antonio,

As u r appending second time u r getting new record into table itab_final.

Please check it by changing Append with Modify.

Regards,

Sanjeev