2023 Nov 23 8:45 PM
Hi everyone !
I just have start learning Abap and was working in a Mini project where after displaying the table if the user does a double click in any fields the report should open a little information window where to display the field name. Just like in the pic.
And here is the code :
REPORT zrd_exercises.
TABLES: ekko,ekpo.
TYPE-POOLS : slis.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
wt_fieldcat TYPE slis_fieldcat_alv.
TYPES:
BEGIN OF ty_ekko,
ebeln TYPE ekko-ebeln,
bukrs TYPE ekko-bukrs,
bstyp TYPE ekko-bstyp,
ebelp TYPE ekpo-ebelp,
matnr TYPE ekpo-matnr,
END OF ty_ekko.
DATA gt_ekko TYPE STANDARD TABLE OF ty_ekko.
SELECT-OPTIONS : s_ebeln FOR ekko-ebeln.
START-OF-SELECTION.
SELECT * FROM ekko
LEFT JOIN ekpo ON ekko~ebeln = ekpo~ebeln
INTO CORRESPONDING FIELDS OF TABLE gt_ekko
WHERE ekko~ebeln IN s_ebeln.
wt_fieldcat-fieldname = 'EBELN'.
wt_fieldcat-seltext_l = 'Purchasing document'.
wt_fieldcat-key = 'X'.
APPEND wt_fieldcat TO it_fieldcat.
CLEAR wt_fieldcat.
wt_fieldcat-fieldname = 'BUKRS'.
wt_fieldcat-seltext_l = 'Company code'.
wt_fieldcat-key = 'X'.
APPEND wt_fieldcat TO it_fieldcat.
CLEAR wt_fieldcat.
wt_fieldcat-fieldname = 'BSTYP'.
wt_fieldcat-seltext_l = 'Purchasing document category'.
APPEND wt_fieldcat TO it_fieldcat.
CLEAR wt_fieldcat.
wt_fieldcat-fieldname = 'EBELP'.
wt_fieldcat-seltext_m = 'Item number'.
APPEND wt_fieldcat TO it_fieldcat.
CLEAR wt_fieldcat.
wt_fieldcat-fieldname = 'MATNR'.
wt_fieldcat-seltext_l = 'Material number'.
APPEND wt_fieldcat TO it_fieldcat.
CLEAR wt_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_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_GRID_SETTINGS =
* IS_LAYOUT =
it_fieldcat = it_fieldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
i_default = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_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 = gt_ekko
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
2023 Nov 24 10:59 AM
For anyone with the same issue this is the solution I found :
FORM HANDLE_USER_COMMAND USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA: lv_fieldname TYPE slis_fieldname.
CASE r_ucomm.
WHEN '&IC1'. " Double-click event
lv_fieldname = rs_selfield-fieldname.
MESSAGE lv_fieldname TYPE 'I'.
ENDCASE.
ENDFORM.
2023 Nov 24 6:36 AM
You should not trying to learn using old FM.
Restart from begining using SALV
all the examples are available in SAP, the program start with SALV_DEMO_TABLE
2023 Nov 24 10:59 AM
For anyone with the same issue this is the solution I found :
FORM HANDLE_USER_COMMAND USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA: lv_fieldname TYPE slis_fieldname.
CASE r_ucomm.
WHEN '&IC1'. " Double-click event
lv_fieldname = rs_selfield-fieldname.
MESSAGE lv_fieldname TYPE 'I'.
ENDCASE.
ENDFORM.