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

help in increase index

Former Member
0 Likes
1,296

Hallow I have a 2 table with data and the table that I do the read statement I wont to increase the index of score_tab after all read because the problem is when I modify the table score 4 I have the first data in all my table.

How can I do that?

Regards

LOOP AT score_tab_4 INTO wa_score_tab_4.

<b>READ TABLE score_tab INTO wa_score_tab

WITH KEY objid_p = wa_score_tab_4-objid_p.</b>

IF sy-subrc = 0.

MOVE wa_score_tab-stext_vc TO wa_score_tab_4-stext_vc.

MOVE wa_score_tab-score_numric TO wa_score_tab_4-score_numric.

MOVE wa_score_tab-score_from_total TO wa_score_tab_4-score_from_total.

MODIFY score_tab_4 FROM wa_score_tab_4

TRANSPORTING stext_vc score_numric score_from_total.

CLEAR wa_score_tab_4.

ENDIF.

ENDLOOP.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,274

I guess that your table score_tab_4 has no header line.

In that case the coding has to be:

field-symbols: <fs_tab4> type ?

Use for ? the Type description that you are using for your table.

Example:

types: begin of <b>ltyp_test</b>,

line type STRING,

end of ltyp_test.

Data: lt_test type standard table of ltyp_test.

field-symbols: <fs_dat> type ltyp_test.

Hope that helps!

Regards

Nicola

Hallow I have a 2 table with data and the table that I do the read statement I wont to increase the index of score_tab after all read because the problem is when I modify the table score 4 I have the first data in all my table.

How can I do that?

Regards

LOOP AT score_tab_4 INTO wa_score_tab_4.

<b>READ TABLE score_tab INTO wa_score_tab

WITH KEY objid_p = wa_score_tab_4-objid_p.</b>

IF sy-subrc = 0.

MOVE wa_score_tab-stext_vc TO wa_score_tab_4-stext_vc.

MOVE wa_score_tab-score_numric TO wa_score_tab_4-score_numric.

MOVE wa_score_tab-score_from_total TO wa_score_tab_4-score_from_total.

MODIFY score_tab_4 FROM wa_score_tab_4

TRANSPORTING stext_vc score_numric score_from_total.

CLEAR wa_score_tab_4.

ENDIF.

ENDLOOP.

13 REPLIES 13
Read only

Former Member
0 Likes
1,274

data_ l_tabix like sy-tabix.          " CHECK HERE
LOOP AT score_tab_4 INTO wa_score_tab_4.
l_tabix = sy-tabix. " CHECK HERE
READ TABLE score_tab INTO wa_score_tab
WITH KEY objid_p = wa_score_tab_4-objid_p.
IF sy-subrc = 0.

MOVE wa_score_tab-stext_vc TO wa_score_tab_4-stext_vc.
MOVE wa_score_tab-score_numric TO wa_score_tab_4-score_numric.
MOVE wa_score_tab-score_from_total TO wa_score_tab_4-score_from_total.

MODIFY score_tab_4 FROM wa_score_tab_4
TRANSPORTING stext_vc score_numric score_from_total index l_tabix. " CHECK HERE
CLEAR wa_score_tab_4.

ENDIF.
ENDLOOP. 

Vasanth

Read only

0 Likes
1,274

hi Vasanth M

i have erorr in this

TRANSPORTING stext_vc score_numric score_from_total index l_tabix.

the erorr is no component exist with the name index

and i declare it.

Read only

0 Likes
1,274

hi

declare like this:

data l_tabix like sy-tabix.

remove the underscore that next to data:

data<b>_</b> l_tabix like sy-tabix.

    • reward if helpful

regards,

madhu

Read only

0 Likes
1,274

Hi,

change the statement like this

MODIFY score_tab_4 FROM wa_score_tab_4 <b>index l_tabix</b>

TRANSPORTING stext_vc score_numric score_from_total .

Read only

0 Likes
1,274

hi Chandrasekhar

i try this suggstion but its not working

i have the same data in score_tab_4 like before

regards

Read only

0 Likes
1,274

all looks ok , but try this..

Try sorting the table used in READ statement

<b>sort score_tab by objid_p.</b>

LOOP AT score_tab_4 INTO wa_score_tab_4.

READ TABLE score_tab INTO wa_score_tab

WITH KEY objid_p = wa_score_tab_4-objid_p <b>binary search</b>.

IF sy-subrc = 0.

MOVE wa_score_tab-stext_vc TO wa_score_tab_4-stext_vc.

MOVE wa_score_tab-score_numric TO wa_score_tab_4-score_numric.

MOVE wa_score_tab-score_from_total TO wa_score_tab_4-score_from_total.

MODIFY score_tab_4 FROM wa_score_tab_4

TRANSPORTING stext_vc score_numric score_from_total.

CLEAR wa_score_tab_4.

ENDIF.

ENDLOOP.

also check in debugging if the sy-subrc eq 0 after read statement

Read only

0 Likes
1,274

hi Chandrasekhar

theb problem is that i need to increase the index in the <b>read statment</b> and i dont now how to do it.

regards

Read only

0 Likes
1,274
I did not fully understand ur question,

Is it this what u r looking for 

sort score_tab by objid_p.

LOOP AT score_tab_4 INTO wa_score_tab_4.

loop at score_tab INTO wa_score_tab
where  objid_p = wa_score_tab_4-objid_p.

MOVE wa_score_tab-stext_vc TO wa_score_tab_4-stext_vc.
MOVE wa_score_tab-score_numric TO wa_score_tab_4-score_numric.
MOVE wa_score_tab-score_from_total TO wa_score_tab_4-score_from_total.

MODIFY score_tab_4 FROM wa_score_tab_4

CLEAR wa_score_tab_4.
endloop.



ENDIF.
ENDLOOP.</b>

Message was edited by:

Chandrasekhar Jagarlamudi

null

Read only

Former Member
0 Likes
1,274

Hi

Instead of modifying the table contents with in a loop .. endloop.. (This is not recommended approach)

Create a new internal table and populate it with the required data and use it as per your requirements.

Hope this will help.

Regards

- Atul

Read only

Former Member
0 Likes
1,274

Hi Antonio,

I'm not sure if I understand your problem but I wonder why you fill 3 fields in structure wa_score_tab_4 and with using transporting while doing the modify you try to update a field that hasn't changed before? Could you please give us more information which fields you are trying to change?

Regards

Nicola

P.S.: Try to use shorter structure and field names; it's pretty confusing with the long names

Read only

Former Member
0 Likes
1,274

I just saw that your "transporting" is correct (I was confused with the long names) so please forget my first post.

Could you try the following coding?

field-symbols: <fs_tab4> like score_tab_4 (if your table has a header line, otherwise use 'type xxx').

Loop at score_tab_4 assigning <fs_tab4>.

READ TABLE score_tab INTO wa_score_tab

WITH KEY objid_p = <fs_tab4>-objid_p.

IF sy-subrc = 0.

MOVE wa_score_tab-stext_vc to <fs_tab4>-stext_vc.

MOVE wa_score_tab-score_numric TO <fs_tab4>-score_numric.

MOVE wa_score_tab-score_from_total TO <fs_tab4>-score_from_total.

endif.

endloop.

You don't need the modify anymore than.

Regards

Nicola

Read only

0 Likes
1,274

hi Schwab

i have an error score_tab_4 is not comptebole with <fs_tab4>.

what can i do with that thankes

Read only

Former Member
0 Likes
1,275

I guess that your table score_tab_4 has no header line.

In that case the coding has to be:

field-symbols: <fs_tab4> type ?

Use for ? the Type description that you are using for your table.

Example:

types: begin of <b>ltyp_test</b>,

line type STRING,

end of ltyp_test.

Data: lt_test type standard table of ltyp_test.

field-symbols: <fs_dat> type ltyp_test.

Hope that helps!

Regards

Nicola