Application Development 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: 

User selected records

Former Member
0 Kudos
134

Hi,

I tried to select the user selected records from a table by useing check box, I am always getting the 2nd next record from the selected record. Suppose if user selcts record no 1 then I am getting record no 3 in to my itab. Can some one please guide me where I am doing wrong.

AT USER-COMMAND.

CASE sy-ucomm.

WHEN 'CMEMO'.

DATA: lv_cnt TYPE i.

DESCRIBE TABLE gt_zprice LINES lv_cnt.

  • lv_cnt = lv_cnt + 2.

DO lv_cnt TIMES.

READ LINE sy-index FIELD VALUE chbox.

IF sy-index > 0 AND chbox = 'X'.

READ TABLE gt_zprice INTO gs_zprice INDEX sy-index.

IF sy-subrc EQ 0.

APPEND gs_zprice TO gt2_zprice.

CLEAR gs_zprice.

ENDIF.

ENDIF.

ENDDO.

Thanks,

Neelu.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
102

would be issue at HIDE Command.

Use HIDE Command after write statement within loop.

see the example code :

&----


*& Report ZHK_INTER1

*&

&----


*&

*&

&----


REPORT ZHK_INTER1 no standard page heading

message-id ztest_msg

line-size 130

line-count 50(4).

tables: kna1.

data: begin of i_kna1 occurs 0,

kunnr like kna1-kunnr,

name1 like kna1-name1,

land1 like kna1-land1,

end of i_kna1.

select-options s_kunnr for kna1-kunnr.

start-of-selection.

select kunnr

name1

land1

from kna1 into table i_kna1

where kunnr in s_kunnr.

loop at i_kna1.

write:/ i_kna1-kunnr,25 i_kna1-name1.

hide: i_kna1-name1."kunnr.

endloop.

end-of-selection.

at line-selection.

break sy-uname.

case sy-ucomm.

when 'PICK'.

write:/ i_kna1-name1, 'list # =',sy-lsind.

endcase.

Thanks

Seshu

9 REPLIES 9

Former Member
0 Kudos
102

Hi,

First 2 lines of your report may have heading.. that is the reason y u r always getting 3 rd line..

start reading from line 3 onwards....

READ LINE sy-index FIELD VALUE chbox.

thanks

mahesh

Former Member
0 Kudos
102

HI,

data : lv_index type sy-index.

DATA: lv_cnt TYPE i.

DESCRIBE TABLE gt_zprice LINES lv_cnt.

  • lv_cnt = lv_cnt + 2.

lv_index = 2.

DO lv_cnt TIMES.

lv_index = sy-index + 2.

READ LINE lv_index FIELD VALUE chbox.

IF chbox = 'X'.

READ TABLE gt_zprice INTO gs_zprice INDEX sy-index.

IF sy-subrc EQ 0.

APPEND gs_zprice TO gt2_zprice.

CLEAR gs_zprice.

ENDIF.

ENDIF.

ENDDO

Hope this will work..

Thanks

Mahesh

Former Member
0 Kudos
102

Hi,

You better to take a seperate field in first internal table itself as a check box. so that you can loop the first internal table based on field1 = 'X' [if check box selected].

Please let me know if u need more clarification on this.

regards

*dj

reward for all helpful answers.

Former Member
0 Kudos
103

would be issue at HIDE Command.

Use HIDE Command after write statement within loop.

see the example code :

&----


*& Report ZHK_INTER1

*&

&----


*&

*&

&----


REPORT ZHK_INTER1 no standard page heading

message-id ztest_msg

line-size 130

line-count 50(4).

tables: kna1.

data: begin of i_kna1 occurs 0,

kunnr like kna1-kunnr,

name1 like kna1-name1,

land1 like kna1-land1,

end of i_kna1.

select-options s_kunnr for kna1-kunnr.

start-of-selection.

select kunnr

name1

land1

from kna1 into table i_kna1

where kunnr in s_kunnr.

loop at i_kna1.

write:/ i_kna1-kunnr,25 i_kna1-name1.

hide: i_kna1-name1."kunnr.

endloop.

end-of-selection.

at line-selection.

break sy-uname.

case sy-ucomm.

when 'PICK'.

write:/ i_kna1-name1, 'list # =',sy-lsind.

endcase.

Thanks

Seshu

0 Kudos
102

Hi Mahesh,

I tried it this way also, no luck. not selecting the selected record.

The report output is data of custom table. There are no headings.

AT USER-COMMAND.

CASE sy-ucomm.

WHEN 'CMEMO'.

DATA: lv_cnt TYPE i.

DESCRIBE TABLE gt_zprice LINES lv_cnt.

lv_cnt = lv_cnt + 2.

DO lv_cnt TIMES.

READ LINE sy-index FIELD VALUE chbox.

IF sy-index > 2 AND chbox = 'X'.

READ TABLE gt_zprice INTO gs_zprice INDEX sy-index.

IF sy-subrc EQ 0.

APPEND gs_zprice TO gt2_zprice.

CLEAR gs_zprice.

ENDIF.

ENDIF.

ENDDO.

Hi Dj,

My first field in the custom table is chbox. How can loop on this so that I get all user selected records.

Hi Seshu,

I didnot understand the Hide stmt. I just wants to read selected records from internal table. I am not writing anything.

Thank you all. Please help me solve the issue.

Thanks,

Neelu.

0 Kudos
102

Add two fields to your internal table at the end, one for storing page number and another for storing line number as below.

Add these two fields at the end of internal table

pageno like sy-pagno,

lineno like sy-linno.

Put these statements where you are looping at the internal table and writing it out to the report.

itab-pageno = sy-pagno.

itab-lineno = sy-linno.

and just before endloop, add the statement "modify itab".

Now in your AT USER-COMMAND, do the following

AT USER-COMMAND.

CASE sy-ucomm.

WHEN 'CMEMO'.

LOOP AT gt_zprice INTO gs_price.

READ LINE gs_price-lineno OF PAGE gs_price-pageno FIELD VALUE chbox.

IF chbox = 'X'.

APPEND gs_zprice TO gt2_zprice.

CLEAR gs_zprice.

ENDIF.

ENDLOOP.

0 Kudos
102

Neelu,

Check my code.. You are not doing what this code is doing..

data : lv_index type sy-index.

DATA: lv_cnt TYPE i.

DESCRIBE TABLE gt_zprice LINES lv_cnt.

  • lv_cnt = lv_cnt + 2.

lv_index = 2.

DO lv_cnt TIMES.

lv_index = sy-index + 2.

READ LINE lv_index FIELD VALUE chbox.

IF chbox = 'X'.

READ TABLE gt_zprice INTO gs_zprice INDEX sy-index.

IF sy-subrc EQ 0.

APPEND gs_zprice TO gt2_zprice.

CLEAR gs_zprice.

ENDIF.

ENDIF.

ENDDO

Thanks

Mahesh

0 Kudos
102

HI,

I think you are struggling with this code since last week.. Send your complete code so that i can fix it and send you back.

thanks

Mahesh

0 Kudos
102

Hi Mahesh,

I really appriciate your help. Your suggetion solved my issue.

If have any error I will ask you.

Thank you once again.

Regards,

Neelu.