AT line selection in ALV
Hi Experts,
How to apply the below logic in ALV. ( how to apply at line selection in ALV )
AT LINE-SELECTION.
DATA NO TYPE I.
DATA F(16).
DATA G(16).
CASE SY-LSIND.
WHEN 1.
GET CURSOR FIELD F.
IF F EQ 'IT_FIRST-MATNR'.
PERFORM DRILL_DOWN.
ENDIF.
ENDCASE.
FORM DRILL_DOWN.
LOOP AT IT_EBAN WHERE MATNR = IT_FIRST-MATNR
AND WERKS = IT_FIRST-WERKS.
WRITE: /2 IT_EBAN-BANFN,
15 IT_EBAN-FKZTX,
35 IT_EBAN-MENGE,
55 IT_EBAN-MEINS.
ENDLOOP.
ENDFORM.
Hi,
When an Interactive Report is needed in Classical Display, we go for AT LINE-SELECTION. But when the same is needed in ALV Display, this method won't work. Instead, we need to use other way which is explained below:
We use REUSE_ALV_GRID_DISPLAY for ALV Display. Now, normally we call that FM in the following way:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = 'PROGRAM_NAME'
it_fieldcat = tb_fieldcat
TABLES
t_outtab = tb_output.
When it is needed to get an Interactive ALV, call the same FM in the following manner:
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = 'ZTEST75599_1'
it_fieldcat = tb_fieldcat
i_callback_user_command = 'USER_COMMAND'
TABLES
t_outtab = tb_output.
Now, in the report, create a subroutine with the name USER_COMMAND as follows:
FORM user_command USING p_ucomm LIKE sy-ucomm
p_selfield TYPE slis_selfield.
CASE p_ucomm.
WHEN '&IC1'. " &IC1 - SAP standard code for double-clicking
Based on the requirement, write the logic *
ENDCASE.
ENDFORM.
No need to call the subroutine as PERFORM user_command. This will be takane care by REUSE_ALV_GRID_DISPLAY. We need to just write the subroutine in the report. That suffices.
Some more useful points for Interactive ALV:
1. If Hotspot is needed, then that should be done by declaring hotspot (one field in slis_t_fieldcat_alv) as 'X' in tb_fieldcat which is of type slis_t_fieldcat_alv. When hotspot is active, single click will be enough or else you should double click on the output data.
2. In Classical Display, when it is needed to read the record on which we double clicked, we do that in following way:
AT LINE-SELECTION.
GET CURSOR LINE wf_line. " wf_line gives the line number on which it has been clicked
READ LINE wf_line OF CURRENT PAGE.
But this won't work for ALV. Instead, the following logic can be used:
FORM user_command USING p_ucomm LIKE sy-ucomm
p_selfield TYPE slis_selfield.
CASE p_ucomm.
WHEN '&IC1'. " &IC1 - SAP standard code for double-clicking
READ TABLE tb_output INTO wa_output INDEX p_selfield-tabindex.
IF sy-subrc EQ 0.
Based on the requirement, write the logic *
ENDIF.
ENDCASE.
ENDFORM.
Hope this helps you...
Similar Messages
-
At Line-selection in ALV for more than one field.
How to use At Line-selection in ALV Basic Report where there are more than one field for displaying Secondary Lists.
Ex: In Basic List there are 3 fields Volume_m Volume_y and Volume_i.When i click on any of the field i need to display the secondary list for that particular field.Hi Pavan,
Use User-command event of ALV.
Refer this code :
form BUILD_EVENTCAT using p_i_eventcat TYPE SLIS_T_EVENT.
DATA: I_EVENT TYPE SLIS_ALV_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = P_I_EVENTCAT
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
clear I_event.
read table p_i_eventcat with key name = slis_ev_user_command into I_event.
if sy-subrc = 0.
move 'USER_COMMAND' to I_event-form.
append I_event to p_i_eventcat.
endif.
form USER_COMMAND' using p_ucomm type sy-ucomm
p_selfield type slis_selfield.
case p_ucomm.
WHEN '&IC1'. "&IC1 is the Fcode for double click
Use P_ELFIELD-VALUE for further processing . this will contain the value on which u will double click
endcase.
Reward points if helpful.
Regards,
Hemant -
At line selection in alv report
hi,
i had developed a code in which at 1st execution the normal output is displayed and if i click on a purticular Itemid it displays the whole of items and i want to display only that item's data which i had clicked on.
following is the code which i am using for the at line-selection.
**BEGIN - TEST CODE FOR LINE SELECTION**
data: fld LIKE ITAB-ITEMID,
val LIKE ITAB-ITEMID.
at line-selection.
get cursor field fld value val.
IF fld = 'ITAB-ITEMID'.
SET PARAMETER ID 'ANR' FIELD val.
CLEAR ITAB-ITEMID.
ENDIF.
PERFORM PRN_SMSTOCK_ALV USING VAL.
IF SY-SUBRC <> 0.
MESSAGE 'NO RECORD FOUND' TYPE 'W'.
ENDIF.
FORM PRN_SMSTOCK_ALV USING VAL.
*****END OF TEST CODE FOR LINE SELECTION******
plzz help me out by providing the solution for this problem.Hi,
You need to add extra piece of code as below:
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE'
I_callback_user_command = 'USER_COMMAND' "see FORM
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
i_save = 'X'
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.
* FORM USER_COMMAND *
* --> R_UCOMM *
* --> RS_SELFIELD *
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
* Check function code
CASE r_ucomm.
WHEN '&IC1'.
* Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'EBELN'.
* Read data table, using index of row user clicked on
READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
* Set parameter ID for transaction screen field
SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
* Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM.
"For further information please refer the link below :
http://www.sapdev.co.uk/reporting/alv/alvgrid_ucomm.htm
Thanks,
Sriram Ponna. -
Hi guys: I need to double click on a field in the ALV report that should bring up another structure (which I have created) called s_det
s_det has only document number & company code.
Please provide the code for doing this in ALV. I know I cant use At Line Selection. Please give me simple code.
thanks so much
BrianHi
take this as an example for ur solution.
In this if we double click on first level display then it opens second level display.Just have a look on the following code.
This is Interactive ALV report of displaying each row with colours and Headers.
TYPE-POOLS SLIS.
TYPES: BEGIN OF I_EKKO,
EBELN LIKE EKKO-EBELN,
AEDAT LIKE EKKO-AEDAT,
BUKRS LIKE EKKO-BUKRS,
BSART LIKE EKKO-BSART,
LIFNR LIKE EKKO-LIFNR,
L_COLOR(4) TYPE C,
END OF I_EKKO.
DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,
WA_EKKO TYPE I_EKKO.
TYPES: BEGIN OF I_EKPO,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
MATNR LIKE EKPO-MATNR,
MENGE LIKE EKPO-MENGE,
MEINS LIKE EKPO-MEINS,
NETPR LIKE EKPO-NETPR,
L_COLOR1(4) TYPE C,
END OF I_EKPO.
DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,
WA_EKPO TYPE I_EKPO.
DATA: V_REPID TYPE SY-REPID,
I_FLDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FLDCAT TYPE SLIS_FIELDCAT_ALV,
I_EVENTS TYPE SLIS_T_EVENT,
WA_EVENT TYPE SLIS_ALV_EVENT,
GD_LAYOUT TYPE SLIS_LAYOUT_ALV,
GD_LAYOUT1 TYPE SLIS_LAYOUT_ALV.
DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST ALV REPORT',
I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDARY ALV REPORT'.
INITIALIZATION.
V_REPID = SY-REPID.
PERFORM FLDCATALOG.
PERFORM CALL_EVENTS.
PERFORM POPULATE_EVENT.
PERFORM BLD_LAYOUT.
PERFORM BLD_LAYOUT1.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM DISPLAY_ALV_REPORT.
FORM FLDCATALOG.
WA_FLDCAT-TABNAME = 'IT_EKKO'.
WA_FLDCAT-FIELDNAME = 'EBELN'.
WA_FLDCAT-SELTEXT_M = 'PO NUMBER'.
APPEND WA_FLDCAT TO I_FLDCAT.
CLEAR WA_FLDCAT.
WA_FLDCAT-TABNAME = 'IT_EKKO'.
WA_FLDCAT-FIELDNAME = 'AEDAT'.
WA_FLDCAT-SELTEXT_M = 'DATE'.
APPEND WA_FLDCAT TO I_FLDCAT.
CLEAR WA_FLDCAT.
WA_FLDCAT-TABNAME = 'IT_EKKO'.
WA_FLDCAT-FIELDNAME = 'BUKRS'.
WA_FLDCAT-SELTEXT_M = 'DOCUMENT TYPE'.
APPEND WA_FLDCAT TO I_FLDCAT.
CLEAR WA_FLDCAT.
WA_FLDCAT-TABNAME = 'IT_EKKO'.
WA_FLDCAT-FIELDNAME = 'LIFNR'.
WA_FLDCAT-SELTEXT_M = 'VENDOR CODE'.
APPEND WA_FLDCAT TO I_FLDCAT.
CLEAR WA_FLDCAT.
ENDFORM.
FORM CALL_EVENTS.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = I_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
FORM POPULATE_EVENT.
*READ TABLE I_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
*IF SY-SUBRC = 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY I_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME = WA_EVENT-FORM.
*ENDIF.
READ TABLE I_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.
IF SY-SUBRC = 0.
WA_EVENT-FORM = 'USER_COMMAND'.
MODIFY I_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME = WA_EVENT-NAME.
ENDIF.
ENDFORM.
FORM BLD_LAYOUT.
GD_LAYOUT-INFO_FIELDNAME = 'L_COLOR'.
ENDFORM.
FORM DATA_RETRIEVAL.
DATA LN_COLOR(1) TYPE C.
SELECT EBELN AEDAT BUKRS BSART LIFNR
FROM EKKO INTO TABLE IT_EKKO.
LOOP AT IT_EKKO INTO WA_EKKO.
LN_COLOR = LN_COLOR + 1.
IF LN_COLOR = 8.
LN_COLOR = 1.
ENDIF.
CONCATENATE 'C' LN_COLOR '11' INTO WA_EKKO-L_COLOR.
MODIFY IT_EKKO FROM WA_EKKO.
ENDLOOP.
ENDFORM.
FORM DISPLAY_ALV_REPORT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE = I_TITLE_EKKO
I_GRID_SETTINGS =
IS_LAYOUT = GD_LAYOUT
IT_FIELDCAT = I_FLDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = 'A'
IS_VARIANT =
IT_EVENTS = I_EVENTS
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_EKKO
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
FORM TOP_OF_PAGE.
DATA: T_HEADER TYPE SLIS_T_LISTHEADER,
WA_HEADER TYPE SLIS_LISTHEADER.
WA_HEADER-TYP = 'H'.
WA_HEADER-INFO = 'THIS IS MY FIRST ALV'.
APPEND WA_HEADER TO T_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = T_HEADER
I_LOGO =
I_END_OF_LIST_GRID =
I_ALV_FORM =
ENDFORM.
FORM USER_COMMAND USING R_COMM TYPE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_COMM.
WHEN '&IC1'.
READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
PERFORM FLDCAT_EKPO.
PERFORM CALL_EVENT_EKPO.
PERFORM POPULATE_EVENT_EKPO.
PERFORM DATA_RETRIEVAL_EKPO.
PERFORM DISPLAY_ALV_REPORT_EKPO.
ENDCASE.
ENDFORM.
FORM FLDCAT_EKPO.
WA_FLDCAT-TABNAME = 'IT_EKPO'.
WA_FLDCAT-FIELDNAME = 'EBELN'.
WA_FLDCAT-SELTEXT_M = 'PO NUMBER'.
APPEND WA_FLDCAT TO I_FLDCAT.
CLEAR WA_EKPO.
WA_FLDCAT-TABNAME = 'IT_EKPO'.
WA_FLDCAT-FIELDNAME = 'EBELP'.
WA_FLDCAT-SELTEXT_M = 'LINE NO'.
APPEND WA_FLDCAT TO I_FLDCAT.
CLEAR WA_EKPO.
WA_FLDCAT-TABNAME = 'IT_EKPO'.
WA_FLDCAT-FIELDNAME = 'MATNR'.
WA_FLDCAT-SELTEXT_M = 'MATERIAL NUMBER'.
APPEND WA_FLDCAT TO I_FLDCAT.
CLEAR WA_FLDCAT.
WA_FLDCAT-TABNAME = 'IT_EKPO'.
WA_FLDCAT-FIELDNAME = 'MENGE'.
WA_FLDCAT-SELTEXT_M = 'QUANTITY'.
APPEND WA_FLDCAT TO I_FLDCAT.
CLEAR WA_FLDCAT.
WA_FLDCAT-TABNAME = 'IT_EKPO'.
WA_FLDCAT-FIELDNAME = 'MEINS'.
WA_FLDCAT-SELTEXT_M = 'BASE UNIT OF MEASURE'.
APPEND WA_FLDCAT TO I_FLDCAT.
CLEAR WA_FLDCAT.
WA_FLDCAT-TABNAME = 'IT_EKPO'.
WA_FLDCAT-FIELDNAME = 'NETPR'.
WA_FLDCAT-SELTEXT_M = 'PRICE'.
APPEND WA_FLDCAT TO I_FLDCAT.
CLEAR WA_FLDCAT.
ENDFORM.
FORM CALL_EVENT_EKPO.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = I_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
*FORM POPULATE_EVENT_EKPO.
*READ TABLE I_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
*IF SY-SUBRC = 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY I_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME = WA_EVENT-FORM.
*ENDIF.
*ENDFORM.
FORM BLD_LAYOUT1.
GD_LAYOUT1-INFO_FIELDNAME = 'L_COLOR1'.
ENDFORM.
FORM DATA_RETRIEVAL_EKPO.
DATA LN_COLOR1(1) TYPE C.
SELECT EBELN EBELP MATNR MENGE MEINS NETPR
INTO TABLE IT_EKPO
FROM EKPO.
LOOP AT IT_EKPO INTO WA_EKPO.
LN_COLOR1 = LN_COLOR1 + 1.
IF LN_COLOR1 = 8.
LN_COLOR1 = 1.
ENDIF.
CONCATENATE 'C' LN_COLOR1 '11' INTO WA_EKPO-L_COLOR1.
MODIFY IT_EKPO FROM WA_EKPO.
ENDLOOP.
ENDFORM.
FORM DISPLAY_ALV_REPORT_EKPO.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE1'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE = I_TITLE_EKPO
I_GRID_SETTINGS =
IS_LAYOUT = GD_LAYOUT1
IT_FIELDCAT = I_FLDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = 'A'
IS_VARIANT =
IT_EVENTS = I_EVENTS
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_EKPO
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
FORM TOP_OF_PAGE1.
DATA: T_HEADER1 TYPE SLIS_T_LISTHEADER,
WA_HEADER1 TYPE SLIS_LISTHEADER.
WA_HEADER1-TYP = 'H'.
WA_HEADER1-INFO = 'SECONDARY ALV LEVEL'.
APPEND WA_HEADER1 TO T_HEADER1.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = T_HEADER1
I_LOGO =
I_END_OF_LIST_GRID =
I_ALV_FORM = .
ENDFORM.
reward points,if it is useful.
Thanks,
chandu. -
TOP-OF-PAGE During line-selection in alv report
Hi Expart
In intractive Alv report u using top-of-page during line-selection . If u using so u give me one example with codeing .
Regards
BhabaniHi,
try this code...
*& Report ZCS_PRG8
REPORT Z_SJALV__PRG8.
TYPE-POOLS: SLIS.
*type declaration for values from ekko
TYPES: BEGIN OF I_EKKO,
EBELN LIKE EKKO-EBELN,
AEDAT LIKE EKKO-AEDAT,
BUKRS LIKE EKKO-BUKRS,
BSART LIKE EKKO-BSART,
LIFNR LIKE EKKO-LIFNR,
END OF I_EKKO.
DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,
WA_EKKO TYPE I_EKKO.
*type declaration for values from ekpo
TYPES: BEGIN OF I_EKPO,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
MATNR LIKE EKPO-MATNR,
MENGE LIKE EKPO-MENGE,
MEINS LIKE EKPO-MEINS,
NETPR LIKE EKPO-NETPR,
END OF I_EKPO.
DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,
WA_EKPO TYPE I_EKPO .
*variable for Report ID
DATA: V_REPID LIKE SY-REPID .
*declaration for fieldcatalog
DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
declaration for events table where user comand or set PF status will
be defined
DATA: V_EVENTS TYPE SLIS_T_EVENT,
WA_EVENT TYPE SLIS_ALV_EVENT.
declartion for layout
DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
declaration for variant(type of display we want)
DATA: I_VARIANT TYPE DISVARIANT,
I_VARIANT1 TYPE DISVARIANT,
I_SAVE(1) TYPE C.
*PARAMETERS : p_var TYPE disvariant-variant.
*Title displayed when the alv list is displayed
DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.
DATA: I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.
INITIALIZATION.
V_REPID = SY-REPID.
PERFORM BUILD_FIELDCATLOG.
PERFORM EVENT_CALL.
PERFORM POPULATE_EVENT.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_REPORT.
*& Form BUILD_FIELDCATLOG
Fieldcatalog has all the field details from ekko
FORM BUILD_FIELDCATLOG.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'AEDAT'.
WA_FIELDCAT-SELTEXT_M = 'DATE.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'LIFNR'.
WA_FIELDCAT-NO_OUT = 'X'.
WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG
*& Form EVENT_CALL
we get all events - TOP OF PAGE or USER COMMAND in table v_events
FORM EVENT_CALL.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "EVENT_CALL
*& Form POPULATE_EVENT
Events populated for TOP OF PAGE & USER COMAND
FORM POPULATE_EVENT.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'USER_COMMAND'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-NAME.
ENDIF.
ENDFORM. "POPULATE_EVENT
*& Form data_retrieval
retreiving values from the database table ekko
FORM DATA_RETRIEVAL.
SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.
ENDFORM. "data_retrieval
*& Form bUild_listheader
text
-->I_LISTHEADEtext
FORM BUILD_LISTHEADER USING IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA HLINE TYPE SLIS_LISTHEADER.
HLINE-INFO = 'this is my first alv pgm'.
HLINE-TYP = 'H'.
ENDFORM. "build_listheader
*& Form display_alv_report
text
FORM DISPLAY_ALV_REPORT.
V_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = I_TITLE_EKKO
I_GRID_SETTINGS =
IS_LAYOUT = ALV_LAYOUT
IT_FIELDCAT = I_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
i_default = 'ZLAY1'
I_SAVE = 'A'
is_variant = i_variant
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_EKKO
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "display_alv_report
*& Form TOP_OF_PAGE
text
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
i_logo =
I_END_OF_LIST_GRID =
ENDFORM. "TOP_OF_PAGE
*& Form USER_COMMAND
text
-->R_UCOMM text
-->, text
-->RS_SLEFIELDtext
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
PERFORM BUILD_FIELDCATLOG_EKPO.
PERFORM EVENT_CALL_EKPO.
PERFORM POPULATE_EVENT_EKPO.
PERFORM DATA_RETRIEVAL_EKPO.
PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_EKPO.
ENDCASE.
ENDFORM. "user_command
*& Form BUILD_FIELDCATLOG_EKPO
text
FORM BUILD_FIELDCATLOG_EKPO.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELP'.
WA_FIELDCAT-SELTEXT_M = 'LINE NO'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MENGE'.
WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MEINS'.
WA_FIELDCAT-SELTEXT_M = 'UOM'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'NETPR'.
WA_FIELDCAT-SELTEXT_M = 'PRICE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG_EKPO
*& Form event_call_ekpo
we get all events - TOP OF PAGE or USER COMMAND in table v_events
FORM EVENT_CALL_EKPO.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = V_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "event_call_ekpo
*& Form POPULATE_EVENT
Events populated for TOP OF PAGE & USER COMAND
FORM POPULATE_EVENT_EKPO.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
ENDFORM. "POPULATE_EVENT
*& Form TOP_OF_PAGE
text
FORM F_TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
i_logo =
I_END_OF_LIST_GRID =
ENDFORM. "TOP_OF_PAGE
*& Form USER_COMMAND
text
-->R_UCOMM text
-->, text
-->RS_SLEFIELDtext
*retreiving values from the database table ekko
FORM DATA_RETRIEVAL_EKPO.
SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.
ENDFORM.
FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA: HLINE1 TYPE SLIS_LISTHEADER.
HLINE1-TYP = 'H'.
HLINE1-INFO = 'CHECKING PGM'.
ENDFORM.
FORM DISPLAY_ALV_EKPO.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE = I_TITLE_EKPO
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = I_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT =
I_SAVE = 'A'
IS_VARIANT =
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_EKPO
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
reward if helpful
regards
Shashi -
How to process Line Selection on ALV Table in ABAP WebDynpro
Hi there,
I have a view with an ALV table whose context node retrieves its data from a Service Call for a method.
The method provides certain data of a database table which the ALV displays.
Now I would like to be able to select one row of that ALV table and after pressing a button or doubleclicking on the row or whatever a different view (as for me it is also ok on the same view) should appear to display the details of that selection.
I only need to know how to retrieve the selected data.
Or its index within the internal table.
I am already looking for hours for a useful thread and actually there is one which obviously is about a similar issue apart from the multiple selection part:
How to process multiple row selection in ALV table in Wendynpro ABAP? Help!
but i am afraid that i don't understand it. Or at least I misunderstand it since it does not work with me.
The system example mentioned in the thread does not help me either because it somehow does not correspond to my needs, does it?
It would be GREAT if somebody could help me with that. Please keep it simple for I am not an expert in webdynpro yet (obviously ^^) and also please explain in detail what I have to do with the context nodes since I am not sure whether the selection is stored in my already existing node or whether I need a special one for that.
Thanks!!
christinaHi Christina,
If you just want to get one column data of the line that user clicked, use the Web Dynpro Code Wizard to Read Context of attibute you needed, then you will get code as follow:
* Define data for read attribute
node_alv TYPE REF TO if_wd_context_node,
elem_alv TYPE REF TO if_wd_context_element,
stru_alv TYPE if_view_display=>element_alv ,
item_column_name LIKE stru_alv-column_name.
* navigate from <CONTEXT> to <ALV> via lead selection
node_alv = wd_context->get_child_node( name = if_view_display=>wdctx_alv ).
* get element via lead selection
elem_alv = node_alv->get_element( ).
* get single attribute
elem_alv->get_attribute(
EXPORTING
name = `COLUMN_NAME'
IMPORTING
value = item_column_name ).
The value of column_name is stored in item_column_name.
If you need the index that the user clicked, try this:
* Definition of field symbol for index
FIELD-SYMBOLS : <fs_index> TYPE data.
* Get the selected index
ASSIGN r_param->index->* TO <fs_index>.
The index of clicked line is stored in field symbol <fs_index>.
Hope it will help.
Best Regards,
Stephanie -
Hello experts ,
can anybody plz tell me How to implement the line selection event in alv ? I want to retrieve value of the filed clicked by the user and query another table with that field value and display that data ....Hi,
Below is the sample code.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = G_REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = i_FCAT[]
TABLES
T_OUTTAB = i_invoice[]
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
FORM user_command USING pv_ucomm TYPE syucomm
ps_selfield TYPE slis_selfield.
*Handle the specific user-commands. *
CASE pv_ucomm.
Or some other GUI-functions *
Handle double click or hotspot on a specific field. *
These are some examples *
WHEN gc_double_click.
CASE ps_selfield-fieldname.
WHEN 'BELNR'.
i_invoice-belnr = g_belnr.
i_invoice-gjahr = g_gjahr.
READ TABLE i_invoice INDEX ps_selfield-tabindex.
IF sy-subrc EQ 0 AND NOT i_invoice-belnr IS INITIAL.
SET PARAMETER ID 'RBN' FIELD i_invoice-belnr.
SET PARAMETER ID 'GJR' FIELD i_invoice-gjahr.
CALL TRANSACTION 'MIR4' AND SKIP FIRST SCREEN.
ENDIF.
WHEN 'EBELN'.
READ TABLE i_invoice INDEX ps_selfield-tabindex.
IF sy-subrc EQ 0 AND NOT i_invoice IS INITIAL.
SET PARAMETER ID 'BES' FIELD i_invoice-ebeln.
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
endcase.
endcase.
endform. "user_command
Regards,
Jayanth G -
How do I find an event which is triggered on line selection for ALV grid?
Hi,
I'm trying to find an event which is triggered when a user selects a row in the ALV grid. I want to add my own code in to add up the total values of selected lines, but can't find any event which will trigger my method.
I found CLICK_ROW_COL but it's protected so when I try and add a method for it:
PROTECTED SECTION.
METHODS:
select_row
FOR EVENT click_row_col OF cl_gui_alv_grid.
I get the syntax error:
Access to protected event "CLICK_ROW_COL" is not allowed.
Am I using the right event? Am I implementing it correctly?
Any help appreciated. Thanks in advance.
GillI chose to solve this by removing the line select buttons from the ALV and replacing them with a checkbox defined as a hotspot. I then used EVENT hotspot_click FROM cl_gui_alv_grid to highlight the line and change my totals on a single click.
-
Multi Line Selection with ALV Grid
Dear all
what do I have to do to make multiple line selection available in an ALV Grid (Version 4.7)?
HerbertHi Herbert again,
Once you displayed your alv output display, then select rows in the alv display.
then when you click for interactive buttion (ie. like Refresh functionality), In debug mode you can see internal table with Sell field active (i.e. marked "X") which you have selected.
e.g.
FORM user_command USING lv_ucomm TYPE sy-ucomm ls_selfield TYPE slis_selfield.
DATA:
lv_ref_grid TYPE REF TO cl_gui_alv_grid.
CLEAR : gv_tcode.
*-- to ensure that only new processed data is displayed
IF lv_ref_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = lv_ref_grid.
ENDIF.
IF NOT lv_ref_grid IS INITIAL.
CALL METHOD lv_ref_grid->check_changed_data.
ENDIF.
CASE lv_ucomm.
WHEN '&IC1'.
IF ls_selfield-fieldname = 'MATNR'.
READ TABLE gt_gi INTO gs_gi INDEX ls_selfield-tabindex.
IF sy-subrc = 0.
gv_tcode = 'MMBE'.
SET PARAMETER ID 'MAT' FIELD gs_gi-matnr.
CALL TRANSACTION gv_tcode AND SKIP FIRST SCREEN. "#EC CI_CALLTA "MMBE
ENDIF.
ENDIF.
WHEN 'COPY'.
LOOP AT gt_gi INTO gs_gi WHERE sel = 'X'.
gs_gi-sel = ' '.
APPEND gs_gi TO gt_gi.
CLEAR gs_gi.
ENDLOOP.
WHEN 'POST'.
REFRESH : gt_error[].
WHEN OTHERS.
ENDCASE.
ENDFORM. " USER_COMMAND
I hope you clear now.
Feel free to ask any doubts.
Thanks and regards,
Vijay -
Hi,
Am creating a FM where all data declaration,subroutines and selection screen will be in separate includes.Delivary order number is fetched based on sales order number given as input by the user.
Output is displayed using ALV.
Interactive List:Now in the list,when i click on sales document number it should take me to the trasaction VA03 and when i double click on delivary document number it should take me to VL03.
AT LINE-SELECTION is not working.where should i insert at line-selection?
INCLUDE ZSU_3TOP
INCLUDE ZSU_SELECTION_SCREEN.
INCLUDE ZSU_FORMS2.
START-OF-SELECTION.
PERFORM DISPLAY.
PERFORM BUILD_ALV.
PERFORM ALV_GRID.
AT LINE-SELECTION.
SET PARAMETER ID 'SAL' FIELD S_VBELN.
CALL TRANSACTION 'VA03'.
s_vbeln is the selection option for sales order number as input.Hi,
I am helping u with just a part of my code with similar to ur requirement, in this my code dynamic Subrubroutines are being called u can work accordingly i hope it will help u out .and u can call as other transactions also.
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
DATA : wa_out LIKE LINE OF it_output.
CASE ucomm.
Double click => launches whatever you want
WHEN '&IC1'.
CHECK sy-lsind = 1.
CLEAR wa_output2.
READ TABLE it_output INDEX SELFIELD-TABINDEX INTO wa_out.
LOOP AT it_output2 INTO wa_output2 WHERE matnr EQ wa_out-matnr AND
vstel EQ wa_out-vstel.
IF wa_output2-lsmeng NE wa_output2-kwmeng.
CLEAR wa_output2.
CONTINUE.
ENDIF.
FORMAT INTENSIFIED ON COLOR 3.
wa_orders-vbeln = wa_output2-vbeln.
wa_orders-audat = wa_output2-audat.
wa_orders-kunnr = wa_output2-kunnr.
SELECT SINGLE * FROM kna1 WHERE kunnr = wa_orders-kunnr.
wa_orders-name1 = kna1-name1.
wa_orders-vstel = wa_output2-vstel.
wa_orders-kwmeng = wa_output2-kwmeng.
PERFORM get_dqty.
wa_orders-lsmeng = n_dqty.
APPEND wa_orders TO it_orders.
CLEAR wa_orders.
CLEAR wa_output2.
ENDLOOP.
FORMAT RESET.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = SY-REPID
i_structure_name = 'IT_ORDERS'
it_fieldcat = FIELD_CAT2
i_callback_user_command = 'CALL_VA02'
TABLES
t_outtab = IT_ORDERS
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
REFRESH IT_ORDERS.
ENDCASE.
ENDFORM.
*& Form call_va02
text
-->SELFIELD text
FORM call_va02 USING ucom TYPE sy-ucomm
selfield TYPE slis_selfield.
DATA : wa_out2 LIKE LINE OF it_orders.
READ TABLE it_orders INDEX SELFIELD-TABINDEX INTO wa_out2.
SET PARAMETER ID 'AUN' FIELD WA_OUT2-VBELN.
CALL TRANSACTION 'VA02' .
ENDFORM. "call_va02
FORM build_fldcat2 CHANGING ix_fldcat TYPE slis_t_fieldcat_alv.
field_cat-fieldname = 'VBELN'.
field_cat-tabname = 'IT_ORDERS'.
field_cat-col_pos = 1.
field_cat-seltext_m = 'Order No.'.
field_cat-ddictxt = 'M'.
field_cat-outputlen = 15.
APPEND field_cat TO ix_fldcat.
CLEAR field_cat.
field_cat-fieldname = 'AUDAT'.
field_cat-tabname = 'IT_ORDERS'.
field_cat-col_pos = 2.
field_cat-seltext_m = 'Date'.
field_cat-ddictxt = 'M'.
field_cat-outputlen = 10.
APPEND field_cat TO ix_fldcat.
CLEAR field_cat.
field_cat-fieldname = 'KUNNR'.
field_cat-tabname = 'IT_ORDERS'.
field_cat-col_pos = 3.
field_cat-seltext_m = 'Dealer'.
field_cat-ddictxt = 'M'.
field_cat-outputlen = 10.
APPEND field_cat TO ix_fldcat.
CLEAR field_cat.
field_cat-fieldname = 'NAME1'.
field_cat-tabname = 'IT_ORDERS'.
field_cat-col_pos = 4.
field_cat-seltext_m = 'Name'.
field_cat-ddictxt = 'M'.
field_cat-outputlen = 25.
APPEND field_cat TO ix_fldcat.
CLEAR field_cat.
field_cat-fieldname = 'VSTEL'.
field_cat-tabname = 'IT_ORDERS'.
field_cat-col_pos = 5.
field_cat-seltext_m = 'Plant'.
field_cat-ddictxt = 'M'.
field_cat-outputlen = 5.
APPEND field_cat TO ix_fldcat.
CLEAR field_cat.
field_cat-fieldname = 'KWMENG'.
field_cat-tabname = 'IT_ORDERS'.
field_cat-col_pos = 6.
field_cat-seltext_m = 'Order Qty'.
field_cat-ddictxt = 'M'.
field_cat-outputlen = 10.
APPEND field_cat TO ix_fldcat.
CLEAR field_cat.
field_cat-fieldname = 'LSMENG'.
field_cat-tabname = 'IT_ORDERS'.
field_cat-col_pos = 7.
field_cat-seltext_m = 'Delivered Qty'.
field_cat-ddictxt = 'M'.
field_cat-outputlen = 15.
APPEND field_cat TO ix_fldcat.
CLEAR field_cat.
ENDFORM.
FORM get_dqty.
CLEAR n_dqty.
SELECT vbeln
posnn
vbelv
vbtyp_n
FROM vbfa
INTO TABLE it_delivery
WHERE vbelv = wa_output2-vbeln AND
vbtyp_n = 'J' AND
posnv = wa_output2-posnr.
LOOP AT it_delivery INTO wa_delivery.
SELECT vbeln
matnr
lfimg
FROM lips
INTO TABLE it_link
WHERE vbeln = wa_delivery-vbeln AND
posnr = wa_delivery-posnn.
LOOP AT it_link INTO wa_link.
n_dqty = n_dqty + wa_link-lfimg.
ENDLOOP.
ENDLOOP.
REFRESH: it_delivery, it_link.
ENDFORM.
Regards,
Chandresh. -
How to use at-line selection in ALV
Can someone help me about how to use at-line selection in an ALV
u can try in user_command
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = G_REPID
IT_FIELDCAT = GT_FIELDCATALOG
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS_SET'
I_CALLBACK_HTML_END_OF_LIST = G_HTML_END_OF_LIST
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_GRID_SETTINGS = GS_SETTINGS
IS_LAYOUT = GS_LAYOUT
I_SAVE = G_SAVE
IS_VARIANT = GS_VARIANT
IT_EVENTS = GT_EVENTS[]
* I_SCREEN_START_COLUMN = 0 "Use coordinates for
* I_SCREEN_START_LINE = 0 "display as dialog box
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER = G_EXIT_CAUSED_BY_CALLER
ES_EXIT_CAUSED_BY_USER = GS_EXIT_CAUSED_BY_USER
TABLES
T_OUTTAB = I_REP
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
FORM USER_COMMAND USING R_UCOMM TYPE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
CASE RS_SELFIELD-FIELDNAME.
WHEN 'XXXXX'.
READ TABLE I_xxx INTO V_xxx
WITH KEY XXX = RS_SELFIELD-VALUE.
IF SY-SUBRC = 0.
ENDIF.
WHEN OTHERS
ENDCASE.
ENDCASE.
ENDFORM. -
Multiple Line selection in ALV
Hi All,
I have an alv report. In which, i have to get the selected row index values in return. Those selected row index will be used for further processing. I do not need check box selection, as ALV provide that inbuilt facility. Please tell me the parameter name.
It is urgent.
Regards
GajendraHi,
Your Call to ALV
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-cprog
I_CALLBACK_USER_COMMAND = 'USER_COMMAND1'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
IS_LAYOUT = wa_layout
IT_FIELDCAT = it_fieldcat
T_OUTTAB = it_rfq
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
Implement a Form Routine with the name you gave for the I_CALLBACK_USER_COMMAND
eg.,
FORM user_command1 using ucomm type sy-ucomm
selfield type slis_selfield.
case ucomm.
when '&IC1'.
read table it_rfq into wa_rfq index selfield-tabindex.
if sy-subrc eq 0.
if selfield-fieldname = 'EBELN' " EBELN is the fieldname in Fieldcat
Do the necessary coding to call the screen here
endif.
endif.
ENDFORM.
regards,
Omkar. -
Multilple line selection in alv
Hi All,
I am dispalying a simple alv grid report using function module
reuse_alv_grid_display.i have used check box for selection but it is only applicable for single selection.Could anybody tell me how to select multiple line items at a time without using control key.if somebody provide the sample code it will be more helpful.
Regards
LalitHi,
Please refer to the standard demo program.
BCALV_EDIT_05
or Search as BCALV_EDIT* and press F4.
OR
Please refer to the code below:
*& Report ZDEMO_ALVGRID_SELROW *
*& Example of a simple ALV Grid Report *
*& The basic ALV grid, Enhanced to display capture each row a user has *
*& selected *
REPORT zdemo_alvgrid_selrow .
TABLES: ekko.
type-pools: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
SEl, "stores which row user has selected
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid.
*Start-of-selection.
START-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform display_alv_report.
*& Form BUILD_FIELDCATALOG
* Build Fieldcatalog for ALV Report
form build_fieldcatalog.
* There are a number of ways to create a fieldcat.
* For the purpose of this example i will build the fieldcatalog manualy
* by populating the internal table fields individually and then
* appending the rows. This method can be the most time consuming but can
* also allow you more control of the final product.
* Beware though, you need to ensure that all fields required are
* populated. When using some of functionality available via ALV, such as
* total. You may need to provide more information than if you were
* simply displaying the result
* I.e. Field type may be required in-order for
* the 'TOTAL' function to work.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
* fieldcatalog-do_sum = 'X'.
* fieldcatalog-no_zero = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-do_sum = 'X'. "Display column total
fieldcatalog-datatype = 'CURR'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
* Build layout for ALV grid report
form build_layout.
gd_layout-box_fieldname = 'SEL'.
"set field name to store row selection
gd_layout-edit = 'X'. "makes whole ALV table editable
gd_layout-zebra = 'X'.
endform. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
* Display report using ALV grid
form display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
* i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
* i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
* it_special_groups = gd_tabgroup
* IT_EVENTS = GT_XEVENTS
i_save = 'X'
* is_variant = z_template
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
* Retrieve data form EKPO table and populate itab it_ekko
form data_retrieval.
select ebeln ebelp statu aedat matnr menge meins netpr peinh
up to 10 rows
from ekpo
into corresponding fields of table it_ekko.
endform. " DATA_RETRIEVAL
* FORM USER_COMMAND *
* --> R_UCOMM *
* --> RS_SELFIELD *
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
* Check function code
CASE r_ucomm.
WHEN '&IC1'.
* Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'EBELN'.
* Read data table, using index of row user clicked on
READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
* Set parameter ID for transaction screen field
SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
* Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
WHEN '&DATA_SAVE'. "user presses SAVE
loop at it_ekko into wa_ekko.
if wa_ekko-sel EQ 'X'.
* Process records that have been selected
endif.
endloop.
ENDCASE.
ENDFORM.
Thanks,
Sriram Ponna
Edited by: Sriram Ponna on Feb 8, 2008 9:31 PM -
Hi Experts!
I need to make lines of ALV multiselectable (like in table control) how can do that?
I need to use ALV factory
Message was edited by:
LOS'OK, I've sold it!
lr_selections->set_selection_mode( if_salv_c_selection_mode=><b>row_column</b> ). -
CL_GUI_ALV_GRID: Line selection and backend table
Dear community,
is there a way to propagate line selection of ALV GRID GUI automagically to the backend data table?
This is my scenario:
1) A table containing several records with one column 'SELECTED' for selection status
2) ALV_GRID to display the table with layout info for line selection
alv_layo-sel_mode = 'A'.
alv_layo-box_fname = 'SELECTED'.
3) At PBO methods set_table_for_first_display and refresh_table_display are called with the table containing some records marked as 'SELECTED'.
First problem here: 'SELECTED' entries are not propagated to the ALV grid (the lines in the GUI are not marked). I know I could use set_selected_rows to force the selection, but is this really necessary?
4) Then, at PAI method check_changed_data is called (and yes, event mc_evt_modified is registered).
Second problem: Changes in selection are not propagated automagically to the underlying table. I also know I could use get_selected_rows to force this update manually, but again: is this really necessary?
Can anyone explain the behavior why sorting etc. is propagated automatically to the underlying table, but not the selection of rows? Am I missing something?
Hint: Removing box_fname = 'SELECTED' and setting the fieldcatalog to display the column 'SELECTED' as editable checkbox works also. But our users are familiar with the rowmark, so this is no option.
Any suggestions are welcome.
Thanks,
Torsten.
Here an (almost) complete listing of the code:
PROCESS BEFORE OUTPUT.
MODULE SET_STATUS_TITLE_0100.
MODULE INIT_ALV_GRID_0100.
MODULE DISPLAY_DATA_0100.
MODULE SET_GRID_SELECTION_0100.
PROCESS AFTER INPUT.
MODULE EXIT_COMMAND_0100 AT EXIT-COMMAND.
MODULE UPDATE_TABLE_DATA_0100.
MODULE USER_COMMAND_0100.
MODULE init_alv_grid_0100 OUTPUT.
IF NOT gr_container IS BOUND.
* Container erzeugen
CREATE OBJECT gr_container ...
* ALV Grid erstellen
CREATE OBJECT gr_alv_grid ...
* ALV für die erste Anzeige vorbereiten
gs_alv_layo-zebra = on. " Gestreifte Anzeige
gs_alv_layo-no_toolbar = on. " Keine Toolbar
gs_alv_layo-no_rowmark = off. " Keine Zeilenmarkierung
gs_alv_layo-edit = off. " Editieren ermöglichen
gs_alv_layo-sel_mode = 'A'. " Selektionsmodus
gs_alv_layo-cwidth_opt = off. " Optimierte Spaltenbreite!
gs_alv_layo-info_fname = 'LCOLOR'. " ALV-Control: Feldname mit
" einfacher Farbcodierung für
" Zeile
gs_alv_layo-ctab_fname = 'CCOLOR'. " ALV-Control: Feldname mit
" komplexer Farbcodierung
" für Zellen
gs_alv_layo-box_fname = 'SELECTED'. " Markierte Zeilen
* Feldkatalog für die Anzeige vorbereiten
* CLEAR gs_fcat. " Mehrfachsel. ermöglichen
* gs_fcat-fieldname = 'SELECTED'. " Dazu muss das Feld für die
* gs_fcat-edit = on. " Selektion editierbar sein.
* gs_fcat-checkbox = on. " Ausserdem muss die
** gs_fcat-outputlen = '3'. " Zeilenmark. eingeschaltet
* APPEND gs_fcat TO gt_fcat. " und box_fname gesetzt sein.
* Ereignisbehandlung
SET HANDLER
lcl_event_handler=>on_click
lcl_event_handler=>on_hotspot
lcl_event_handler=>on_double_click
lcl_event_handler=>on_user_command
lcl_event_handler=>on_data_changed
FOR gr_alv_grid.
CALL METHOD gr_alv_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified
EXCEPTIONS
error = 1
OTHERS = 2.
ENDIF.
ENDMODULE. " INIT_ALV_GRID_0100 OUTPUT
MODULE display_data_0100 OUTPUT.
* PBO Modul für alle weiteren Anzeigezyklen.
IF gr_alv_grid IS BOUND.
CALL METHOD gr_alv_grid->set_table_for_first_display ...
ENDIF.
ENDMODULE. " DISPLAY_DATA_0100 OUTPUT
MODULE set_grid_selection_0100 OUTPUT.
IF gr_alv_grid IS BOUND.
CALL METHOD gr_alv_grid->refresh_table_display.
ENDIF.
* Alterative: Set selected rows manually
* CALL METHOD gr_alv_grid->set_selected_rows
ENDMODULE. " SET_GRID_SELECTION_0100 OUTPUT
MODULE update_table_data_0100 INPUT.
CALL METHOD gr_alv_grid->check_changed_data.
* Alternative: Get selected rows and update table manually
* CALL METHOD gr_alv_grid->get_selected_rows ...
ENDMODULE. " UPDATE_TABLE_DATA_0100 INPUTHello Torsten
I may be wrong but I think the field LVC_S_LAYO-BOX_FNAME is a relict from the stone-age SLIS-based ALV programming.
Using modern OO-based ALV we do not need any kind of "MARK" row but we have the appropriate methods available.
Regards
Uwe
Maybe you are looking for
-
How do i create and save a genius playlist in iTunes 12?
I can see my genius playlists from older versions of iTunes but I can't figure out how to make a new one!
-
We are implementing such that users will not be able to access SAP GUI or RRMX (No Analyzer). All reports will be delivered through web templates. We do want the users to be able to save Views of their reports that they have access to into their Favo
-
The value is not passing to l_text1 field from transaction code screen field DATA: l_text1 TYPE vekp-exidv, l_vekp TYPE vekp-exidv. IF l_text1 IS NOT INITIAL. SELECT SINGLE exidv FROM vekp INTO l_vekp WHERE exidv EQ l_text1. IF sy-s
-
Change email address in this forum?
Simple problem, the email address I used when became member of this forum is dead thanks to millions of shitheads spamming me, THANKS! So I am using a new address, how do I alter my settings so my address can be changed (looking qickly in 'settings t
-
Hi, I am trying to install Oracle 11G R2 Grid(for installing RAC) on virtualbox. VirtualBox-4.0.4-70112-Win rhel-server-5.3-i386-dvd - iso file Oracle Grid - linux.x64_11gR2_grid After completeting the preinstllation tasks, When i try to run, $ ./run