2023 Oct 26 5:56 PM
Hello everyone. I'm developing a program in which I show the user the data of the productions orders and when he clicks on the details button (I added gui status), it should show the details of that specific production order. How do I get the data from this cell to use in the where clause?
(obs: Please skip the code repetition, I'll deal with that later.)
My code:
REPORT ZPRODUCTION_ORDER.
TYPE-POOLS: slis.
FORM user_command USING ucomm TYPE sy-ucomm selfield TYPE slis_selfield.
DATA: lv_order_number TYPE AUFK-AUFNR,
it_fieldcat2 type slis_t_fieldcat_alv,
IT_DETAIL TYPE TABLE OF ZSORDER.
IF ucomm = 'DETAIL'.
SELECT AUFK~AUFNR AS PORDER AUFK~WERKS AS PLANT
AUFK~STORT AS SLOCAT AFPO~STRMP AS PODATE
AFPO~MATNR AS PMATERIAL AFKO~GAMNG AS QUANTITY AFPO~MEINS AS UNIT
INTO CORRESPONDING FIELDS OF TABLE IT_DETAIL
FROM AUFK
LEFT JOIN AFPO ON AUFK~AUFNR = AFPO~AUFNR
LEFT JOIN AFKO ON AUFK~AUFNR = AFKO~AUFNR.
"WHERE AUFK~AUFNR = ... Here -> WHERE Prod.Order = selected.
wa_fieldcat-FIELDNAME = 'PORDER'.
wa_fieldcat-seltext_m = 'Production Order'.
APPEND wa_fieldcat to it_fieldcat2.
wa_fieldcat-FIELDNAME = 'PLANT'.
wa_fieldcat-seltext_m = 'Plant'.
APPEND wa_fieldcat to it_fieldcat2.
wa_fieldcat-FIELDNAME = 'SLOCAT'.
wa_fieldcat-seltext_m = 'Storage Location'.
APPEND wa_fieldcat to it_fieldcat2.
wa_fieldcat-FIELDNAME = 'PODATE'.
wa_fieldcat-seltext_m = 'Production Order Date'.
APPEND wa_fieldcat to it_fieldcat2.
wa_fieldcat-FIELDNAME = 'PMATERIAL'.
wa_fieldcat-seltext_m = 'Production Material'.
APPEND wa_fieldcat to it_fieldcat2.
wa_fieldcat-FIELDNAME = 'QUANTITY'.
wa_fieldcat-seltext_m = 'Quantity'.
APPEND wa_fieldcat to it_fieldcat2.
wa_fieldcat-FIELDNAME = 'UNIT'.
wa_fieldcat-seltext_m = 'Unit'.
APPEND wa_fieldcat to it_fieldcat2.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IT_FIELDCAT = it_fieldcat2
TABLES
T_OUTTAB = it_detail
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
lv_error_message = 'Error opening details.'.
MESSAGE lv_error_message TYPE 'E'.
ENDIF.
ENDIF.
ENDFORM.
END-OF-SELECTION.
2023 Oct 26 7:08 PM
Hi, I think you don't need a "detail" button in the gui status. You can do for example the column production order clickable. I have an ALV version for this but OO. I hope be helpful for you. Look below example with sales orders:
After clicking sales order, it will take to the corresponding document:
You have to do something similar but with production orders.
For this, you have to define an event handler:
CLASS lcl_event_receiver_0100 DEFINITION.
PUBLIC SECTION.
METHODS:
hotspot_click
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING
e_row_id
e_column_id
es_row_no,
on_f4
FOR EVENT onf4 OF cl_gui_alv_grid
IMPORTING
sender
e_fieldname
e_fieldvalue
es_row_no
er_event_data
et_bad_cells
e_display.
ENDCLASS.
And then the implementation. In my case it was:
CLASS lcl_event_receiver_0100 IMPLEMENTATION.
METHOD hotspot_click.
DATA:
lt_data LIKE gs_dynpro_data-dynpro_0100-t_alv_data,
lt_data_copy LIKE gs_dynpro_data-dynpro_0100-t_alv_data,
lt_sort_criteria TYPE lvc_t_sort,
lv_es_row_no TYPE lvc_s_roid,
lv_es_row_info TYPE lvc_s_row,
lv_es_col_info TYPE lvc_s_col,
lv_is_row_id TYPE lvc_s_row,
lv_stable TYPE lvc_s_stbl VALUE 'XX'.
FIELD-SYMBOLS:
<data> LIKE LINE OF gs_dynpro_data-dynpro_0100-t_alv_data,
<vbeln> LIKE LINE OF s_vbeln.
READ TABLE gs_dynpro_data-dynpro_0100-t_alv_data[] ASSIGNING <data> INDEX es_row_no-row_id.
IF sy-subrc = 0.
IF e_column_id-fieldname = 'VBELN'.
SET PARAMETER ID 'AUN' FIELD <data>-vbeln.
ENDIF.
endif.
CALL TRANSACTION 'VA02' AND SKIP FIRST SCREEN.
COMMIT WORK AND WAIT.
And in the field catalogue you will have to set the corresponding field as hotspot:
READ TABLE gs_dynpro_data-dynpro_0100-t_fieldcat WITH KEY fieldname = 'VBELN' ASSIGNING <fcat>.
IF sy-subrc = 0.
<fcat>-hotspot = abap_true.
<fcat>-key = abap_true.
ENDIF.
And to finish, you will have to set the handler also:
SET HANDLER:
gs_dynpro_data-dynpro_0100-o_event_handler->hotspot_click FOR gs_dynpro_data-dynpro_0100-o_grid,
2023 Oct 26 7:11 PM
Just a clarification. The last statement "SET HANDLER" goes after calling the ALV. It means, after the method:
CALL METHOD gs_dynpro_data-dynpro_0100-o_grid->set_table_for_first_display
EXPORTING
is_layout = ls_layout
it_toolbar_excluding = lt_uifun
i_structure_name = gc_alv-alv_structure_
hope this helps
2023 Oct 27 8:50 AM
For information, instead of a comment, I'd recommend using menu Actions > Edit to improve your answer (possibly indicate "EDIT" to mention what change you did).
2023 Oct 26 8:23 PM
I'm not answering your question, just two remarks:
REUSE_ALV_GRID_DISPLAY is obsolete. Use CL_SALV_TABLE instead.
END-OF-SELECTION is useless/is obsolete.
2023 Oct 27 8:17 AM
Hi Paulo,
there are several ways for the ALV to make this work. I would suggest to use an OO version of the ALV and make the column AUFNR either a hotspot (see fieldcat) or sensitive to double click. Then you can get the value of your cell in the event listener.
I usually add the navigation profile (if_navp) to our cl_gui_alv_grid. You just call the factory and hand over your internal table after instantiating your ALV. As a result the end users can define their own calls to other transactions .
data(go_navp) = cl_navp_factory=>factory(
io_alv = go_alv
is_profile_key = ls_disvariant
it_table = lt_table ).
Hope this helps.