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 is value table? : abap data dictionary

643


What is your approach to find exit and BAdi?

863


Value table VS check Table.

955


Have you set up a back ground job? How to create a background job without a variant ? : abap bdc

593


How many main windows will be there in a page window?

557






What is asap methodology? : sap abap hr

564


What is meant by exclusive, not cumulative lock? : sap abap data dictionary

586


How the at-user command serves mainly in lists?

616


What is the difference between collect and append statements?

562


What are the uses of the information in the data dictionary? : abap data dictionary

726


In which time constraint does the infotype records depend on the subtype ? : abap hr

631


When, how and how would you control changes to standard SAP objects.

1426


Event handling in oops

1124


What is a development class? : abap data dictionary

699


What is the maximum number of structures that can be included in a table or structure : abap data dictionary

804