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: 

line selection in SET_TABLE_FOR_FIRST_DISPLAY

ramiz_sipai
Explorer
0 Kudos

Hi All,

I am using SET_TABLE_FOR_FIRST_DISPLAY method to display my data in control in screen 100.

In IT_OUTTAB I am passing internal table with fields like…

Button (Expand/Element)

Business Area.

Cost Element

… etc.

Now… After pressing Expand button, Object number for particular business area should be shown bellow in the same display.

Eg.

Button BA Obj.No Cost.Elem.

+ b1

After pressing +

Button BA Obj.No. Cost.Elem.

- b1

.............o1................c1

.............o2................c2

But, I am not getting my control to USER COMMAND in PAI after pressing EXPAND button.

How can I do this ?

Kindly help.

1 ACCEPTED SOLUTION

sharat_chandra
Active Participant
0 Kudos

Hi,

To handle the ALV events in the PAI , you would need to set the below parameter when creating the grid:

CREATE OBJECT <ref_toGrid>
    EXPORTING
      i_parent          = <ref_toCont>
      I_APPL_EVENTS*     = 'X'

This would enable the Application Events i.e. event handling can be done in PAI. If nothing is passed over, then the events are handled as system events.

5 REPLIES 5

sharat_chandra
Active Participant
0 Kudos

Hi,

To handle the ALV events in the PAI , you would need to set the below parameter when creating the grid:

CREATE OBJECT <ref_toGrid>
    EXPORTING
      i_parent          = <ref_toCont>
      I_APPL_EVENTS*     = 'X'

This would enable the Application Events i.e. event handling can be done in PAI. If nothing is passed over, then the events are handled as system events.

0 Kudos

Hi Sharat,

Yes I am getting my control to user command in PAI.

But, How can I get the values of line selected ?

I checked syst table but not getting any useful info.

Thanks a lot for your help.

0 Kudos

How can I get the values of line selected ?

It is generally required to select some cells, rows or columns in ALV Grid. The structure of the control gives the opportunity to set different selection modes through the value of the field “SEL_MODE” in the layout structure. Here are those modes and their functionalities

You can set “NO_ROWMARK” option to hide the mark column, which is normally visible when the selection mode allows multiple row selection.

After a selection is made, the rest being important about the developer is to figure out what is selected. This will be essential if you implement your functions as interacting with selections made. Certainly, ALV Grid tells this information. You use methods:

GET_SELECTED_CELLS:

This method returns the exact addresses of selected cells in a table of type “LVC_T_CELL” via the output parameter “et_cell”. The ALV Grid Control returns only the indexes of cells that are selected individually.

GET_SELECTED_CELLS_ID: This method also returns the addresses of selected cells. The difference is, first its output type is “LVC_T_CENO” via the output parameter “et_cells” and it returns the IDs for columns and rows of selected cells.

GET_SELECTED_ROWS: For the selection mode ‘A’, ‘C’ or ‘D’ you can select rows. To get information about selected rows, this method is utilized. It has two output table parameters. However, the parameter “et_index_rows” is obsolete. The other parameter “et_row_no” is of type “LVC_T_ROID” and returns row indexes for selected rows (but not cells or columns) in it.

GET_SELECTED_COLUMNS: As understood so far, this method returns information about selected columns. Its output table parameter “et_index_columns” is of type “LVC_T_COL” and consist of the names of selected columns.

In program, you may want to make some cells, rows or columns to be selected during execution. For those purposes, you can use “SET” versions of methods above whose interfaces are similar but the direction is reverse.

After a screen transition, when you come back to the screen with your ALV, your selections may be lost. You can utilize “GET” methods before transition, to backup those information and after returning to the screen, you can use “SET” methods to restore them.

0 Kudos

Hi,

Use the method GET_SELECTED_ROWS of the ALV class CL_GUI_ALV_GRID.

This would return you the row ID's. You can then use these row ID's as index to identify the rows in your output table which is the source for the ALV data.

Former Member
0 Kudos

HI

sample report

&----


*& Report ZLCL_ALV_BIL *

*& *

&----


*& *

*& *

&----


REPORT ZLCL_ALV_BIL .

DATA: O_CONT1 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

O_CONT2 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

O_GRID1 TYPE REF TO CL_GUI_ALV_GRID,

O_GRID2 TYPE REF TO CL_GUI_ALV_GRID.

DATA: IT_VBRK LIKE VBRK OCCURS 1 WITH HEADER LINE.

DATA: IT_VBRP LIKE VBRP OCCURS 1 WITH HEADER LINE.

TABLES: VBRK.

START-OF-SELECTION.

SET SCREEN 100.

&----


*& Form GET_DATA

&----


  • text

----


FORM GET_DATA .

SELECT *

FROM VBRK

INTO TABLE IT_VBRK

WHERE VBELN = VBRK-VBELN.

SELECT *

FROM VBRP

INTO TABLE IT_VBRP

WHERE VBELN = VBRK-VBELN.

ENDFORM. " GET_DATA

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'MENU'.

IF O_CONT1 IS INITIAL.

*--Linking screen custom control to custon container object

CREATE OBJECT O_CONT1

EXPORTING

CONTAINER_NAME = 'VBRK_CONT' "custom control

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

CREATE_ERROR = 3

LIFETIME_ERROR = 4

LIFETIME_DYNPRO_DYNPRO_LINK = 5

OTHERS = 6.

IF SY-SUBRC <> 0.

MESSAGE I000(Z00) WITH 'Error in container'.

EXIT.

ENDIF.

*--linking the custom container object as a parent to alv grid

CREATE OBJECT O_GRID1

EXPORTING

I_PARENT = O_CONT1 "custom container object

EXCEPTIONS

ERROR_CNTL_CREATE = 1

ERROR_CNTL_INIT = 2

ERROR_CNTL_LINK = 3

ERROR_DP_CREATE = 4

OTHERS = 5.

IF SY-SUBRC <> 0.

MESSAGE I000(Z00) WITH 'Error in alv grid'.

EXIT.

ENDIF.

*--Linking screen custom control to custon container object

CREATE OBJECT O_CONT2

EXPORTING

CONTAINER_NAME = 'VBRP_CONT' "Custom control

EXCEPTIONS

CNTL_ERROR = 1

CNTL_SYSTEM_ERROR = 2

CREATE_ERROR = 3

LIFETIME_ERROR = 4

LIFETIME_DYNPRO_DYNPRO_LINK = 5

OTHERS = 6.

IF SY-SUBRC <> 0.

MESSAGE I000(Z00) WITH 'Error in container'.

EXIT.

ENDIF.

*--linking the custom container object as a parent to alv grid

CREATE OBJECT O_GRID2

EXPORTING

I_PARENT = O_CONT2 "custom container object

EXCEPTIONS

ERROR_CNTL_CREATE = 1

ERROR_CNTL_INIT = 2

ERROR_CNTL_LINK = 3

ERROR_DP_CREATE = 4

OTHERS = 5.

IF SY-SUBRC <> 0.

MESSAGE I000(Z00) WITH 'Error in alv grid'.

EXIT.

ENDIF.

ENDIF.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

CASE SY-UCOMM.

WHEN 'BACK'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Module SHOW_GRIDS INPUT

&----


  • text

----


MODULE SHOW_GRIDS INPUT.

PERFORM GET_DATA.

*--showing the 1st grid

CALL METHOD O_GRID1->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

I_STRUCTURE_NAME = 'VBRK'

CHANGING

IT_OUTTAB = IT_VBRK[]

EXCEPTIONS

INVALID_PARAMETER_COMBINATION = 1

PROGRAM_ERROR = 2

TOO_MANY_LINES = 3

OTHERS = 4.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

*--showing the 2nd grid

CALL METHOD O_GRID2->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

I_STRUCTURE_NAME = 'VBRP'

CHANGING

IT_OUTTAB = IT_VBRP[]

EXCEPTIONS

INVALID_PARAMETER_COMBINATION = 1

PROGRAM_ERROR = 2

TOO_MANY_LINES = 3

OTHERS = 4.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDMODULE. " SHOW_GRIDS INPUT

SCREEN 100

PROCESS BEFORE OUTPUT.

MODULE STATUS_0100.

PROCESS AFTER INPUT.

FIELD VBRK-VBELN MODULE SHOW_GRIDS ON INPUT.

MODULE USER_COMMAND_0100.