Code: Alles auswählen.
SELECT *
FROM zzz_kontrakt1 INTO CORRESPONDING FIELDS OF TABLE it_ekko where ekorg in ekorg1 and ebeln in ekbel and matnr in p_matnr and lifnr in lfnr and ekgrp in ekgrup.
cALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
* I_PROGRAM_NAME = sy-cprog
* I_INTERNAL_TABNAME =
i_structure_name = 'ZZZ_KONTRAKT1'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_INCLNAME =
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
CHANGING
ct_fieldcat = lt_fc2
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.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = sy-cprog
* I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'ALV_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 = lt_fc2
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = ' '
i_save = 'A'
* IS_VARIANT = 'A'
* 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 = 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.
*&---------------------------------------------------------------------*
*& Form alv_user_command
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->R_UCOMM text
* -->RS_SELFIELD text
*----------------------------------------------------------------------*
FORM alv_user_command CHANGING r_ucomm LIKE sy-ucomm "#EC CALLED
rs_selfield TYPE slis_selfield.
clear it_ekab.
DATA: ls_ekko LIKE LINE OF it_ekko.
READ TABLE it_ekko INDEX rs_selfield-tabindex INTO ls_ekko.
CASE r_ucomm.
WHEN '&IC1'.
SELECT * FROM ekab INTO CORRESPONDING FIELDS OF TABLE it_ekab WHERE ekab~konnr = ls_ekko-ebeln.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
* I_PROGRAM_NAME = sy-cprog
* I_INTERNAL_TABNAME =
i_structure_name = 'EKAB'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_INCLNAME =
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
CHANGING
ct_fieldcat = lt_fc3
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.
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 = 'ALV_USER_COMMAND1'
* 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 = lt_fc3
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = ' '
i_save = 'A'
*
* IS_VARIANT = G_REPID
* IT_EVENTS = gt_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_ekab
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.
WHEN OTHERS.
BREAK-POINT.
endcase.
IF rs_selfield-refresh = 'X'.
rs_selfield-col_stable = 'X'.
rs_selfield-row_stable = 'X'.
ENDIF.
endform. "alv_user_command
*&---------------------------------------------------------------------*
*& Form alv_user_command1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->R_UCOMM text
* -->RS_SELFIELD text
*----------------------------------------------------------------------*
FORM alv_user_command1 CHANGING r_ucomm LIKE sy-ucomm "#EC CALLED
rs_selfield TYPE slis_selfield.
data: ls_ekab LIKE LINE OF it_ekab.
READ TABLE it_ekab INDEX rs_selfield-tabindex INTO ls_ekab.
* break knueppel.
CASE r_ucomm .
WHEN '&IC1'.
SET PARAMETER ID 'BES' FIELD ls_ekab-ebeln.
call TRANSACTION 'ME23N'.
endcase.
endform. "alv_user_command1
FORM alv_user_command1 CHANGING r_ucomm LIKE sy-ucomm "#EC CALLED
rs_selfield TYPE slis_selfield.
data: ls_ekab LIKE LINE OF it_ekab.
READ TABLE it_ekab INDEX rs_selfield-tabindex INTO ls_ekab.
* break knueppel.
CASE r_ucomm.
WHEN '&IC1'.
SET PARAMETER ID 'MAT' FIELD ls_ekab-matnr.
call TRANSACTION 'MD04'.
endcase.
endform.
Code: Alles auswählen.
data : GT_EVENTS TYPE SLIS_T_EVENT.
constants : C_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND'.
* get event
PERFORM BUILD_EVENT_TOPOFPAGE USING GT_EVENTS[].
* display alv data
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = W_xxxxx
IT_FIELDCAT = GT_xxxx
IT_EVENTS = GT_EVENTS[]
TABLES
T_OUTTAB = T_xxxx
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
* get event perform
FORM BUILD_EVENT_TOPOFPAGE USING LT_EVENTS TYPE SLIS_T_EVENT.
DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
*
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = LT_EVENTS.
* DOUBLE CLICK EVENT
READ TABLE LT_EVENTS WITH KEY NAME = SLIS_EV_USER_COMMAND
INTO LS_EVENT.
IF SY-SUBRC = 0.
MOVE C_USER_COMMAND TO LS_EVENT-FORM.
APPEND LS_EVENT TO LT_EVENTS.
ENDIF.
ENDFORM. " BUILD_EVENT_TOPOFPAGE
* define user_command ( perform user_command -> x )
* only form user_command ........ endform -> o )
FORM USER_COMMAND USING L_UCOMM LIKE SY-UCOMM
LS_SELFIELD TYPE SLIS_SELFIELD.
CASE L_UCOMM.
WHEN '&IC1'. "f2code
READ TABLE T_xxxxx INDEX LS_SELFIELD-TABINDEX.
CASE LS_SELFIELD-SEL_TAB_FIELD. "select Column
WHEN 'T_xxx-xxx'. " double click column
WHEN 'T_xxxx-xxxx'. " double click column
ENDCASE.
ENDCASE.
ENDFORM. " USER_COMMAND
Code: Alles auswählen.
FORM alv_user_command CHANGING r_ucomm LIKE sy-ucomm "#EC CALLED
rs_selfield TYPE slis_selfield.
CLEAR it_ekab.
DATA: ls_ekko LIKE LINE OF it_ekko.
READ TABLE it_ekko INDEX rs_selfield-tabindex INTO ls_ekko.
CASE r_ucomm.
WHEN '&IC1'.
case rs_selfield-fieldname.
when 'EBELN'.
SELECT * FROM ekab INTO CORRESPONDING FIELDS OF TABLE it_ekab WHERE ekab~konnr = ls_ekko-ebeln.
*
when 'MATNR'.
SET PARAMETER ID 'MAT' FIELD ls_ekko-matnr.
CALL TRANSACTION 'MD04'.
Vielleicht erkennst du nun selber die Nachteile, wenn man zwar ein OO-Experte ist, aber mit anderen Techniken nicht so firm ist.weigo hat geschrieben:hättest du auf mich gehört und die OO Variante genommen, dann hätte ich dir das jetzt einfach erklären können