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

Problem with Read Line

Former Member
0 Likes
753

Hi friends,

i have internal table with header line.

displaying them on the screen with check box defaulted under certain conditions.

From the screen user want to uncheck certain records. so i have quoted as below. it is working if user unchecks the records other than the last record.

if user unchecks the last record still the last record is picking.

any one give me reson why? is it becasue i haven't cleared the itab before DO? am bit puzzled..

at user-Command.

case sy-ucomm.

when 'exec'.

DO.

read line sy-index field value itab-check.

IF sy-subrc NE 0.

EXIT.

ENDIF.

CHECK itab-check = 'X'.

MODIFY itab INDEX sy-index TRANSPORTING check.

ENDDO.

1 ACCEPTED SOLUTION
Read only

former_member194669
Active Contributor
0 Likes
731

May be try this way



start-of-selection.
   perform f_write_output.
   v_lines = sy-linno.  "<-----

at user-Command.
case sy-ucomm.
when 'exec'.
DO v_lines times.       "<-----
read line sy-index field value itab-check.
IF sy-subrc NE 0.
EXIT.
ENDIF.
CHECK itab-check = 'X'.
MODIFY itab INDEX sy-index TRANSPORTING check.
ENDDO.

a®

5 REPLIES 5
Read only

naimesh_patel
Active Contributor
0 Likes
731

You must update the CHECK field if the user un-selects that.

This Statment must be like:


* CHECK itab-check = 'X'.
* MODIFY itab INDEX sy-index TRANSPORTING check.

MODIFY ITAB INDEX SY-INDEX TRANSPORTING CHECK.

Regards,

Naimesh Patel

Read only

0 Likes
731

Hi

Thanks for prompt reply.

But why this peculiarity happening if only the last record from itab unchecked..

If the previous records unchecked, no issue with them..

Read only

0 Likes
731

May be somewhere else in the code, it is getting cleared.

Regards,

Naimesh Patel

Read only

former_member194669
Active Contributor
0 Likes
732

May be try this way



start-of-selection.
   perform f_write_output.
   v_lines = sy-linno.  "<-----

at user-Command.
case sy-ucomm.
when 'exec'.
DO v_lines times.       "<-----
read line sy-index field value itab-check.
IF sy-subrc NE 0.
EXIT.
ENDIF.
CHECK itab-check = 'X'.
MODIFY itab INDEX sy-index TRANSPORTING check.
ENDDO.

a®

Read only

Former Member
0 Likes
731

Hi

FYI

Issue resolved with the following code:

DATA: LINENO TYPE I.

lineno = 0.

DO.

lineno = lineno + 1.

READ LINE lineno FIELD VALUE itab-check.

  • To check the endpoint

IF SY-SUBRC NE 0.

EXIT.

ENDIF.

IF itab-check = 'X'.

READ CURRENT LINE

FIELD VALUE itab-belnr INTO itab1-belnr.

APPEND itab1.

CLEAR itab1.

ENDIF.

Enddo