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: 

Count in Loop at Internal Table

Former Member
0 Kudos

Hi,

I need to find out the count of new Materials from an Internal Table based on the old Material no. I am providing a Table Parameter in a Function Module in which old Materials are entered. Based on that I'm selecting new Material and few other fields from a cross reference table. I want to check if there are multiple new materials for an existing old material.How to check this count? I do not want to use two Loops. Code snippet:

 

6 REPLIES 6

0 Kudos

Hi,

Use Sy-DBCNT for the records successfully processed count.

Thanks,

Kranthi.

Former Member
0 Kudos

Hi Saurabh,

Try below code...

DATA: W_OLDMATERIAL TYPE ZMMAT_PLANT_ESUPPLI....,
           W_NEWMATERIAL TYPE ZMM_MAT_ELPREX,
           L_COUNT       TYPE I.
     
CLEAR L_COUNT.
LOOP AT P_NEWMATERIAL INTO W_NEWMATERIAL.
  CLEAR W_OLDMATERIAL.
  READ TABLE P_OLDMATERIAL INTO W_OLDMATERIAL

       WITH KEY (matrial_no_field) = W_NEWMATERIAL-(matrial_no_field).
  IF SY-SUBRC NE 0.
*    New Material
    ADD 1 TO L_COUNT.
  ENDIF.
ENDLOOP.

WRITE:/ 'Total New Materials:', L_COUNT.

Regards,

Mordhwaj

Former Member
0 Kudos

Hi Saurabh,

You can check SY-DBCNT  at the end of select from internal table.

You can also use ::  Describe table it_final index lv_index.

where it_final is ur internal table & lv_index is local variable which contains no of records.

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

This issue is resolved.

0 Kudos

This question is Not Answered.

Regards Clemens