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: 

New ABAP synatx for LOOP Counter Issue

0 Kudos
578

Hi All.

I am writing new ABAP syantx for LOOP.

I have count as one of the column where SY-TABIX value of LOOP is stored as record counter. Below Code is not populating any value : Please suggsest

Material and Batch are populated but count field is blank

ct_data = VALUE #( FOR ls_details IN lt_details
( count = sy-tabix
material = ls_details-matnr
batch = ls_details-charg ) ).

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
517

SY-TABIX is not changed by FOR. It's different from LOOP AT.

Use INDEX INTO:

ct_data = VALUE #( FOR ls_details IN lt_details INDEX INTO index
          ( count    = index
            material = ls_details-matnr
            batch    = ls_details-charg ) ).
4 REPLIES 4

FredericGirod
Active Contributor
517

I am like the compiler, I don't understand what you are trying to do

Sandra_Rossi
Active Contributor
518

SY-TABIX is not changed by FOR. It's different from LOOP AT.

Use INDEX INTO:

ct_data = VALUE #( FOR ls_details IN lt_details INDEX INTO index
          ( count    = index
            material = ls_details-matnr
            batch    = ls_details-charg ) ).

0 Kudos
517

Thanks Sandra !! I was using SY-TABIX from conventional ABAP LOOP - ENDLOOP to update counter.But with code correction suggsted by you, its woeking !!

Sandra_Rossi
Active Contributor
517

Please edit your question, select your code and press the button [CODE], which makes the code appear colored/indented, it will be easier for people to look at it. Thank you!