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

Help Needed on Read/Modify Line Statement

Former Member
0 Likes
1,414

Hi,

I am writing a report which is having a check box as first column, followed by sales data. I am giving F4 Key to user to Select ALL the check box. I have used Modify Line to do this, but it is not working for me.

Here is the pseudo code which i am using.

Report <report name>.

data cb1 value SPACE.

Write 😕 cb1 as CHECKBOX, 'X'.

Write 😕 cb1 as CHECKBOX, 'Y'.

Write 😕 cb1 as CHECKBOX, 'Z'.

AT PF04.

DO 3 times.

MODIFY LINE sy-index field value cb1 from 'X'.

ENDDO.

This is not working and giving weird results.

I tried the following things too.

Trial a:

cb1 = 'X'.

modify line sy-index field value cb1.

Trial b:

modify line sy-index of current page value cb1 from 'X'.

Trial c:

read line sy-index....

modify line sy-index..

But none of them were working.

Please let me know if my approach to select all check box is correct. Is there any alternate way to select all the checkbox in the list?..What is wrong with my modify line statement.

Regards

Mitesh

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,360

Hi Lakshmam,

I tried the same thing before in my program..

In Demo program, it is

box = space.

MODIFY LINE sy-index FIELD VALUE box

FIELD FORMAT box INPUT OFF

num COLOR 6 INVERSE ON.

In my program/trial it is

cb1 = 'X'.

modify line sy-index field value cb1.

But then also its not working for me..no sure where i m wrong.

Thanks

Mitesh

15 REPLIES 15
Read only

Lakshmant1
Active Contributor
0 Likes
1,360

Hi Mitesh,

Have a look at demo program DEMO_LIST_READ_LINE and DEMO_LIST_MODIFY_FIELD_FORMAT.

Thanks

Lakshman

Read only

Former Member
0 Likes
1,361

Hi Lakshmam,

I tried the same thing before in my program..

In Demo program, it is

box = space.

MODIFY LINE sy-index FIELD VALUE box

FIELD FORMAT box INPUT OFF

num COLOR 6 INVERSE ON.

In my program/trial it is

cb1 = 'X'.

modify line sy-index field value cb1.

But then also its not working for me..no sure where i m wrong.

Thanks

Mitesh

Read only

0 Likes
1,360

Hi Mitesh,

If you directly use MODIFY, which line it will take into consideration for modifying. Check the SY-INDEX value.

Thanks

Lakshman

Read only

0 Likes
1,360

Hi Lakshman,

I am passing sy-index as an parameter

AT PF04.

DO 3 times.

MODIFY LINE <b>sy-index</b> field value cb1 from 'X'.

ENDDO

Regards

Mitesh

Read only

0 Likes
1,360

Hi Mitesh,

Is the checkbox part of the internal table along with sales data. If so modify the internal table for the records which are selected and then process the records whch are selected.

Thanks

Lakshman

Message was edited by: Lakshman Tandra

Read only

0 Likes
1,360

Hi Lakshman,

cb1 is the external variable defined using data.

data: cb1 type c value SPACE.

Whereas other sales order information are stored in internal table.

Regards

Mitesh

Read only

0 Likes
1,360

Hi Mitesh,

There is nothing wrong in the code which you had written. The problem is in the SY-INDEX as I mentioned earlier.

In the report statement use No STANDARD PAGE HEADING or increase the counter t0 5 in the DO loop.

Thanks

Lakshman

Read only

0 Likes
1,360

Hi Lakshman, Poornanad,

Thanks for the reply. I guess i was not having the proper output because my program was reading lines from the page header.

Today on my PC , i will try to supress the header and/or increase modify the lines accordingly by increasing the temporary loop counter.

Regards

Mitesh

Read only

0 Likes
1,360

Hello Mitesh,

I'm just posting here the coe that would wrok as well. Just try it out.



REPORT <report_name> NO STANDARD PAGE HEADING.

DATA CB1 VALUE SPACE.

WRITE :/ CB1 AS CHECKBOX, 'X'.
WRITE :/ CB1 AS CHECKBOX, 'Y'.
WRITE :/ CB1 AS CHECKBOX, 'Z'.

AT PF05.
* When the user hits F5....
  DO 3 TIMES.
    READ LINE SY-INDEX.
    MODIFY LINE SY-INDEX FIELD VALUE CB1 FROM 'X'.
  ENDDO.

Please do get back if you have any further doubts. If not, then please reward the useful answers and mark this question as answered.

Regards,

Anand Mandalika.

By the way, there's a small point of interest here. In the above code , if you omit the READ LINE SY-INDEX. statement, what would happen? And why would that happen? Try to find that out. I just did and got my memory refreshed.

Read only

0 Likes
1,360

I dont think we should worry about finding the exact line where the check box starts appearing.

If you look at the code sample i have given i was trying the read the filed value of <b>box</b> (check box filed name in the list) where i dont have check boxes it will fail.

this way we will only hit the lines with check box .

One can just copy paste the above code and modify box with the corresponding filed name in your program.

Regards

Raja

Read only

0 Likes
1,360

Hi Anand,

Thanks for throwing a light on the "Read Statement". This cleared up my concept of modify line too.

When I dont use Read Line, the output will be:

Checked X

Checked X

Checked X

Let me try to answer the question as "Why it is happening".Correct me if i am wrong as i am only 15 days Old for ABAP ;-((.

Here is how I will now defining modify line statement. Modify Line Statement modify the current line or line number n with the value of sy-lisel. With Field Addition in Modify line, you change the content of sy-lisel.

So in our case, the sy-lisel value is (Checked,'X').

So if we dont use read line, only first column will get updated , whereas second field will remain in the sy-lisel.

So to get the value of other lines, we use read line. This will fill up the sy-lisel with the the line content of sy-index and so modify will work.

So, if we are using AT LINE-SELECTION event to select line, in that case, there is no need to do a read line as sy-lisel is already in the buffer.

Please correct me if i am wrong.

Regards

Mitesh

Read only

0 Likes
1,360

Hi Raja,

Thanks for the code. Initially I was confused as why you need to do a read line, whereas modify line could solve the problem. But now why you use read line [Replied to Anand Problem].

Another good thing i got to learn in this is that you have made the use of sy-subrc , so that the correct line will get updated. So in this case we dont have to worry as whether there is a header in page or not.

Thanks Again!!

Regards

Mitesh

Read only

0 Likes
1,360

Hi Mitesh,

That is absolutely correct. I'm I'm happy that you've understood the concept with just 15 days' experience in ABAP!! Great going.

I guess your problem is now resolved. Now as you can see, quite a few people have tried to answer your doubt. You might want to reward the answers that have helped you.

Also mark this question as answered -

1. By rewarding 10 points to the answer that you think has solved your problem.

2. choosing the option "I have solved it on my own".

It is the SDN way of saying thanks !!

Regards,

Anand Mandalika.

Read only

Former Member
0 Likes
1,360

Hello Mitesh,

There's one important thing that I would like to mention here. Please avoid using the F1 and F4 keys for your purposes. I hope you're aware that they have a got a standard purpose throughout the SAP system - to provide for <i>Help</i> and <i>Possible Values</i> respectively.

The second point is that the line numbers start from the report header. So using the sy-index will not help you really. You need to either :

1. suppress the report header.

or

2. modify the sy-index value accordingly.

Regards,

Anand Mandalika.

Read only

0 Likes
1,360

Here is the code sample:

In the list screen(GUI STATUS) set two button for select all and deselect all and on user command you can use one of the forms below.


data : wf_n type i ,
       box .


form select_all. 
 wf_n = 1 . 
 do.   
 read line wf_n  field value box.   
 if sy-subrc ne 0 .    
  exit.    endif.  
  if box = space .   
   box = 'X'.     
 modify line wf_n field value box .  
  endif.  
  wf_n = wf_n + 1 . 
 enddo.
endform.                    " select_allform 

deselect_all. 
 clear wf_line1. 
 clear wf_line. 
 wf_n = 1 .  
do.  
  read line wf_n  field value box.
    if sy-subrc ne 0 .  
    exit.    
endif.    
if box = 'X' .  
    box = space. 
     modify line wf_n field value box .  
    modify line  wf_n  line format color col_normal      intensified on . 
   endif.  
  wf_n = wf_n + 1 .  
enddo.
endform.                    " deselect_all

Regards

Raja