‎2006 Dec 05 10:06 AM
Hi,
I used ALV Grid display for output in which i have push buttons also, now my requirement is when i select any row and click on push button it has to go to the next screen by holding that particular row information.
For example i have order number column in the display when i select particular row it has to hold that particular order number, when i click on push button it has to go LT22 transaction for correspoding order number.
hope iam clear, please help me out to resolve this thanks in advance.
‎2006 Dec 05 10:15 AM
Yes it is possible .. U can do it by pussing a button or by making a hot spot.
the logic is same...
you will have to handle the user command event.
refer the code... here i am using the Hot Spot method.. but u can do it by having apush button also... U just need to change the Function code.
In this program I am displaying Accopunting docs.. and when u click on any Doc No. it takes you to the document detail line items.
**********************
&----
*& Report Z_ALV_TRAINING_LIST_HOTSPOT
*&
&----
*&
*&
&----
REPORT Z_ALV_TRAINING_LIST_HOTSPOT.
Type Pools Used **********
TYPE-POOLS : SLIS.
Internal Tables Declare ************
DATA : it_document type standard table of bkpf initial size 0 with header line,
IT_FIELD_CAT TYPE SLIS_T_FIELDCAT_ALV,
it_alv_event type SLIS_T_EVENT,
fl_layout type slis_layout_alv.
Select Data ***********
start-of-selection.
select * from bkpf into table it_document.
Make Field Catalog ******
PERFORM MAKE_FIELD_CATALOG.
Make Layout *********
perform sub_fill_layout.
Make Events Table *******
perform sub_Fill_alv_event.
Display ALV *********
PERFORM DISPLAY_ALV_LIST.
----
&----
*& Form make_field_catalog
&----
text
----
--> p1 text
<-- p2 text
----
FORM MAKE_FIELD_CATALOG .
data : wa type slis_fieldcat_alv.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME =
I_INTERNAL_TABNAME =
I_STRUCTURE_NAME = 'bkpf'
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME =
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = it_field_cat
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
read table it_field_cat into wa index 3.
wa-hotspot = 'X'.
modify it_field_cat index 3 from wa.
ENDFORM. " make_field_catalog
&----
*& Form display_alv_list
&----
text
----
--> p1 text
<-- p2 text
----
FORM DISPLAY_ALV_LIST .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
I_CALLBACK_PF_STATUS_SET = 'SET_MY_PF_STATUS'
I_CALLBACK_USER_COMMAND = ' '
IS_LAYOUT = fl_layout
IT_FIELDCAT = it_field_cat[]
IT_SORT =
I_DEFAULT = 'X'
I_SAVE = 'X'
IS_VARIANT = '/TEST_VV'
IT_EVENTS = it_alv_event
TABLES
T_OUTTAB = it_document.
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_list
&----
*& Form sub_my_pf_event
&----
text
----
--> p1 text
<-- p2 text
----
FORM sub_my_pf_event using p_comm type sy-ucomm p_sEL_FIELD TYPE SLIS_SELFIELD.
read table it_document index p_sel_field-tabindex.
set parameter id 'BLN' field it_document-belnr.
set parameter id 'BUK' field it_document-bukrs.
set parameter id 'GJR' field it_document-gjahr.
case p_comm.
when 'PICK'.
call transaction 'FB03' and skip first screen.
endcase.
ENDFORM. " sub_my_pf_event
&----
*& Form sub_Fill_alv_event
&----
text
----
--> p1 text
<-- p2 text
----
FORM sub_Fill_alv_event .
data : wa type slis_alv_event.
wa-name = 'USER_COMMAND'.
wa-form = 'SUB_MY_PF_EVENT'.
append wa to it_alv_event.
ENDFORM. " sub_Fill_alv_event
&----
*& Form sub_fill_layout
&----
text
----
--> p1 text
<-- p2 text
----
FORM sub_fill_layout .
fl_layout-f2code = 'PICK'.
fl_layout-box_fieldname = 'BELNR'.
ENDFORM. " sub_fill_layout
***********************
hope this helps u out... Plz Reward points if it does..
Cheers...
‎2006 Dec 05 10:24 AM
Hi
If you need to manage only one record, you need to only define the routine for the user command.
This routine has to have an interface like this:
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
ENDFORM.The parameter returns the pushbutton ok-code, RS_SELFIELD returns several informations about selected row (where the cursor is placed).
For example RS_SELFIELD returns the index of the record of output table, so you can read it and the decide the action to be done:
READ TABLE ITAB INDEX RS_SELFIELD-TABINDEX.
But this parameter returns also the value of the selected field.
If you need to select several records in the same time, you have to manage a field for the checkbox:
DATA: BEGIN OF ITAB OCCURS 0,
....................
MARK, " Field for check box
END OF ITAB.You need to indicate the name of the field for the check box in the layout structure:
IS_LAYOUT-BOX_FIELDNAME = 'MARK'.
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
IF R_UCOMM = .....
LOOP ITAB WHERE MARK = 'X'.
ENDLOOP.
ENDIF.
ENDFORM.Max