Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

reading multiple records from internal table with out loop

hi,

im reading internal table to fetch records based on few conditions and the records are MORE THAN ONE. is there any way i can retrieve those records with out using LOOP and ENDLOOP. your help would be appreciated.

Thanks,

ravi.

Tags:
Former Member
Former Member replied

You can use a binary read to get the first record. Then read each record sequentially until you have proccessed all the records that meet your critera. You will have to have the internal table sorted so that the binary search and subsequent reads will work:

      
READ TABLE his_data WITH KEY
        ebeln = ekpo_int-ebeln
        ebelp = ekpo_int-ebelp
        BINARY SEARCH.
      IF sy-subrc = 0.
        his_index = sy-tabix.
        DO.
          IF sy-subrc = 0.
            IF his_data-ebeln = ekpo_int-ebeln AND
                his_data-ebelp = ekpo_int-ebelp.
              his_index = his_index + 1.
              menge = menge + his_data-menge.
              READ TABLE his_data INDEX his_index.
            ELSE.
              EXIT.
            ENDIF.
          ELSE.
            EXIT.
          ENDIF.
        ENDDO.
      ENDIF.

Rob

Message was edited by: Rob Burbank

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question