Hi,

I have 100 records in a table, how to read every 7Th record
each in that...

Answer Posted / vamshi reddy chaduvu

Try this sample code..........

REPORT ZHGSL__TEST.

DATA: IT_KNA1 TYPE STANDARD TABLE OF KNA1,
IT_KNA2 TYPE STANDARD TABLE OF KNA1,
WA_KNA1 LIKE LINE OF IT_KNA1.

DATA: T TYPE I.

SELECT * FROM KNA1 INTO TABLE IT_KNA1 UP TO 100 ROWS.


DO .
T = SY-INDEX * 7.
READ TABLE IT_KNA1 INTO WA_KNA1 INDEX T .
IF SY-SUBRC EQ 0.
APPEND WA_KNA1 TO IT_KNA2.
ELSE.
EXIT.
ENDIF.
ENDDO.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
I_STRUCTURE_NAME = 'KNA1'
TABLES
T_OUTTAB = IT_KNA2
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Is This Answer Correct ?    37 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the advantages and disadvantages of ABAP query tool?

579


Where do you code the hide statement?

572


Fallback class

1744


What is an abap?

558


When will the current screen processing terminates?

551






What are the components of sap scripts? : abap hr

589


What is a multiple line field?

589


ABAP : Classical reports events name

903


What do you mean by cluster tables in sap abap? Also explain what do you mean by table cluster? : abap data dictionary

520


What is the difference between ABAP and HR ABAP

2982


How to create a link between modified form and modified print program?

587


How many default tab strips are there? How to insert more tabs in it?

608


What are authorization objects and what statement is used to perform an authorization check in an abap program?

565


Can you define a field without a data element?

560


What are the advantages of logical databases : abap hr

606