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 using ALV Grid Control

Former Member
0 Likes
1,074

Hi,

I am having a wierd situation while using the ALV Grid Control. I would appriciate if anybody help me as it is bit urgent.

My requirement is as below:

-


I have an ALV Grid Control with ten thousand records and at a time, one can see only 10 records. So, if anybody has to see any record more than 10, he has press the PAGE DOWN or scroll down by using the vertical scroll bar to go to that particular record.

At any time, the user can select only ONE record at any time.

I have an application toolbar, which has 4 buttons which does some operations based on the record selected.

The following the problem I am facing:

-


I have selected more than one row (suppose record 1,2 and 3) and clicked one button on the application toolbar and it is giving an error message "Please select only ONE record" of type 'E'. This functionality is absolutely correct and I dont have any problem. Now, after clicking the okay button on the error message dialog, if I click the page down or the vertical scroll bar to go to record 2000, it is giving the same error message.

Since I need to go to 2000 record, I may need to press the Page down button a couple of times (even same is the case with the vertical scroll bar), I am getting the same error message "Please select only ONE record".

I dont know what is the relation between the Page down button and the button I have clicked.

I have checked whether I have used the same shortcut key of Page down button for the button on the application toolbar. But both are having two differnt shortket keys in the GUI Status.

I have even cleared the OK_CODE value.

I have kept a breakpoint near the error message and then tried clicking the vertical scroll bar (or pressing the page down button), but the control never goes there. The control goes to PAI, but then what ever button I press, be it F5, F6, F7 or F8, it displays the error message and show the screen.

Can anybody please help me out. This is very very urgent.

Thanks in advance.

Priya

8 REPLIES 8
Read only

Former Member
0 Likes
1,002

HI Priya,

I believe the message is bcos of the value stored from

CALL METHOD alv_grid->get_selected_rows

IMPORTING

ET_INDEX_ROWS = <b>G_INDEX_ROW</b>.

if u dont clear this value then it assumes u have selected multiple records..

if it doesn't solve ur problem pls paste part of ur code so we can able to help u

Regards

CNU

Read only

0 Likes
1,002

Hi,

In which event are you validating the checkboxes ? if possible please paste your code.

regards,

Vara

Message was edited by:

varaprasad bhagavatula

Read only

0 Likes
1,002

Hi Srinu,

Thanks for you reply.

But the clearing of GS_INDEX value really doesnt help me as the value woud be not be stored. I have used a local structure inside a PAI form for capturing the selected rows. So, once the control comes out of the form, the strucuture no longer exists.

Anyways, I have pasting the code. Fist is the PBO module, where I am displaying the ALV Grid Control. Second is the PAI Module where I am handling the error messages.

*********************************************************************************************

PROCESS BEFORE OUTPUT

*********************************************************************************************

Form PBO_DISPLAY_MATCH_RECORDS.

*

  • Local structure declaration

DATA:

ls_row_id TYPE lvc_s_roid, " row id

ls_layout TYPE lvc_s_layo, " Layout Structure

ls_variant TYPE disvariant.

*

  • Local Internal table declarations

DATA:

lt_row_id TYPE lvc_t_roid, " Row Index

lt_fcat TYPE lvc_t_fcat, " Fieldcatalog

lt_exclude TYPE ui_functions. " ALV Toolbar User

*

IF gp_match_alv IS NOT BOUND.

*

  • Create the match Details Container

CREATE OBJECT gp_match_cont

EXPORTING

container_name = c_reversal_contain " MATCH_REV_CONT

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

OTHERS = 6.

*

  • If the container object is not created, then raise an error message

IF sy-subrc NE 0.

CALL FUNCTION 'POPUP_TO_INFORM'

EXPORTING

titel = space

txt2 = sy-subrc

txt1 = text-101. " The control could not be created

EXIT.

ENDIF.

*

  • create match Details ALV Grid

CREATE OBJECT gp_match_alv

EXPORTING

i_parent = gp_match_cont

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

OTHERS = 5.

*

  • If the ALV object is not created, then raise an error message

IF sy-subrc NE 0.

CALL FUNCTION 'POPUP_TO_INFORM'

EXPORTING

titel = space

txt2 = sy-subrc

txt1 = text-101. " The control could not be created

EXIT.

ENDIF.

*

  • Build the field catalog

REFRESH lt_fcat.

PERFORM build_match_fcatalog CHANGING lt_fcat.

*

  • Subloan Charges Layout

ls_layout-zebra = c_x. " X

ls_layout-no_rowmark = c_x. " X

ls_layout-cwidth_opt = c_x. " X

*

  • Register the Events

IF gp_handler IS INITIAL.

CREATE OBJECT gp_handler.

ENDIF.

*

  • Remove Insert, delete, edit etc buttons from ALV Toolbar

PERFORM remove_alv_toolbar_icons CHANGING lt_exclude.

*

MOVE sy-repid TO ls_variant-report.

*

  • Display Match alv

CALL METHOD gp_match_alv->set_table_for_first_display

EXPORTING

is_variant = ls_variant

is_layout = ls_layout

it_toolbar_excluding = lt_exclude

CHANGING

it_outtab = gt_matchfund

it_fieldcatalog = lt_fcat

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

*

  • If the ALV Cannot be displayed, raise an error message

IF sy-subrc NE 0.

CALL FUNCTION 'POPUP_TO_INFORM'

EXPORTING

titel = space

txt2 = sy-subrc

txt1 = text-102. " Creation of ALV Grid failed "

EXIT.

ENDIF.

*

ELSE.

  • Refresh the Category ALV Grid

CALL METHOD gp_match_alv->refresh_table_display.

ENDIF.

*

ENDFORM.

*********************************************************************************************

PROCESS AFTER INPUT

*********************************************************************************************

*

Form Pai_Validate_match_Records.

*

  • Local Variable

DATA:

lv_lines TYPE i. " Number of Lines

*

  • Local Structure

DATA:

ls_row TYPE lvc_s_roid. " Row Number

*

  • Local Internal Table

DATA:

lt_row TYPE lvc_t_roid. " Row Number

*

lv_f_code = gv_ok_code.

CLEAR gv_ok_code.

*

  • Get the selected Records

CALL METHOD lp_alv->get_selected_rows

IMPORTING

et_row_no = lt_row.

*

  • Get the Number of Selected Match records

DESCRIBE TABLE lt_row LINES lv_lines.

*

  • If the no match records are selected, then give an error message

IF lv_lines EQ 0.

Message 'Select a match record' type 'E'.

elseif lv_lines gt 1.

Message 'Select only One Match Record' type 'E'.

else.

case LV_F_CODE.

.

.

.

.

.

.

endcase.

endif.

*

EndForm.

Read only

0 Likes
1,002

Hi priya,

Move the case statement b4 getting the rows.

CASE LV_F_CODE.

Refresh lt_row.

clear lv_lines.

  • Get the selected Records

CALL METHOD lp_alv->get_selected_rows

IMPORTING

et_row_no = lt_row.

*

  • Get the Number of Selected Match records

DESCRIBE TABLE lt_row LINES lv_lines.

*

  • If the no match records are selected, then give an error message

IF lv_lines EQ 0.

Message 'Select a match record' type 'E'.

elseif lv_lines gt 1.

Message 'Select only One Match Record' type 'E'.

else.

DO THE OPERATION OF UR EVENT BUTTON.

ENDIF.

ENDCASE.

regards

CNU

Read only

Former Member
0 Likes
1,002

Hi,

Try moving the CASE LV_F_CODE statement above the describe table..

Changes are marked in bold..

Form Pai_Validate_match_Records.

*

  • Local Variable

DATA:

lv_lines TYPE i. " Number of Lines

*

  • Local Structure

DATA:

ls_row TYPE lvc_s_roid. " Row Number

*

  • Local Internal Table

DATA:

lt_row TYPE lvc_t_roid. " Row Number

*

lv_f_code = gv_ok_code.

CLEAR gv_ok_code.

*

<b>case LV_F_CODE.

WHEN 'ANOTHER BUTTON IN THE APPLICATION TOOLBAR IS PRESSED'.</b>

  • Get the selected Records

CALL METHOD lp_alv->get_selected_rows

IMPORTING

et_row_no = lt_row.

*

  • Get the Number of Selected Match records

DESCRIBE TABLE lt_row LINES lv_lines.

*

  • If the no match records are selected, then give an error message

IF lv_lines EQ 0.

Message 'Select a match record' type 'E'.

elseif lv_lines gt 1.

Message 'Select only One Match Record' type 'E'.

endif.

.

..

<b>WHEN 'PAGE DOWN IS PRESSED'.</b>

.

.

<b>WHEN 'PAGE UP IS PRESSED'.</b>

.

.

endcase.

EndForm.

Hope this helps...

Thanks,

Naren

Read only

0 Likes
1,002

Hi Narendran,

I dont understand what is the user of moving the LV_F_CODE ahead. I have not declared any status for Page Up or Page Down. Then why is the control going to PAI.

Secondly, I have pressing any buttons (page up or page down). I am clicking the Vertical scroll bar. but still i am having the same problem.

Priya

Read only

Former Member
0 Likes
1,002

Hi,

Since in your code you are doing the describe table and giving the error message irrespective of what the function code is..

That is the reason I moved the code inside the function code where you have to check if only row is selected..

<b>* Get the selected Records

CALL METHOD lp_alv->get_selected_rows

IMPORTING

et_row_no = lt_row.

*

  • Get the Number of Selected Match records

DESCRIBE TABLE lt_row LINES lv_lines.

*

  • If the no match records are selected, then give an error message

IF lv_lines EQ 0.

Message 'Select a match record' type 'E'.

elseif lv_lines gt 1.

Message 'Select only One Match Record' type 'E'</b>

Thanks,

Naren

Read only

Former Member
0 Likes
1,002

Priya,

Did you ever find out why your message was being displayed multiple times while scrolling down?

I'm having the same problem, which seems to be a problem with the ALV scrolling functionality and not with my code. My "s" message at the bottom of the screen keeps dinging and flashing while I scroll down through hundreds of records.

Thanks,

John