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

Count in Loop at Internal Table

Former Member
0 Likes
1,579

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:

 

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
Read only

Former Member
0 Likes
1,336

Hi,

Use Sy-DBCNT for the records successfully processed count.

Thanks,

Kranthi.

Read only

Former Member
0 Likes
1,336

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

Read only

Former Member
0 Likes
1,336

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.

Read only

Former Member
0 Likes
1,336

This message was moderated.

Read only

Former Member
0 Likes
1,336

This issue is resolved.

Read only

0 Likes
1,336

This question is Not Answered.

Regards Clemens