‎2010 Apr 06 4:36 PM
Hi,
I have created list box in the selection screen.In the list box Iam getting 10 characterstics values like(z_xx_che,z_xx_cof,z_xx_me.......) dynamically.
when user select the particular characterstic then it should display appropriate characterstics dynamically in the ALV layout.
first how it dynamically trigger the particular characterstic when user select the particular characterstic ?
please help me on this.
Regards,
Suresh
‎2010 Apr 06 4:51 PM
Try the below code.
-
DATA: itab_ref TYPE REF TO data,
tabname like RSRD1-TBMA_VAL," VALUE 'pa0001',
fields TYPE string,
where TYPE string.
PARAMETERS: p_tab TYPE tabname default 'pa0001',
p_pernr TYPE PERSNO.
CREATE DATA itab_ref TYPE STANDARD TABLE OF (p_tab)."(tabname).
FIELD-SYMBOLS: <itab> TYPE STANDARD TABLE,
<wa>.
ASSIGN itab_ref->* TO <itab>.
DEFINE dselect.
SELECT (&1) FROM (&2) INTO CORRESPONDING FIELDS OF TABLE &3 WHERE (&4).
END-OF-DEFINITION.
START-OF-SELECTION.
fields = 'PERNR'.
where = 'PERNR = ''00001001'''.
dselect fields p_tab <itab> where.
-
In the above code, pernr field is selected from the table, pa0001. So you can dynamically pass the table here, and pass the p_perne field dynamically to fields.
‎2010 Apr 06 5:02 PM
Hi,
use this cl_alv_table_create, here some exam:
DATA : BEGIN OF g_object,
alv_table TYPE REF TO cl_alv_table_create,
alv_data TYPE REF TO data,
data_fcat TYPE lvc_t_fcat,
alv_fcat TYPE slis_t_fieldcat_alv,
END OF g_object.
FIELD-SYMBOLS : <table> TYPE STANDARD TABLE.
you have to create fcat manuelly,
CREATE OBJECT g_object-alv_table.
CALL METHOD g_object-alv_table->create_dynamic_table
EXPORTING
it_fieldcatalog = g_object-data_fcat
IMPORTING
ep_table = g_object-alv_data
EXCEPTIONS
generate_subpool_dir_full = 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.
ASSIGN g_object-alv_data->* TO <table>.
at last :
CALL FUNCTION 'LVC_TRANSFER_TO_SLIS'
EXPORTING
it_fieldcat_lvc = g_object-data_fcat[]
IMPORTING
et_fieldcat_alv = g_object-alv_fcat[]
EXCEPTIONS
it_data_missing = 1
it_fieldcat_lvc_missing = 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_callback_program = sy-repid
i_callback_pf_status_set = 'MY_PF_STATUS'
i_callback_user_command = 'MY_USER_COMMAND'
is_layout = ls_layo
it_fieldcat = g_object-alv_fcat[]
* IT_SORT =
* I_SAVE = ' '
* IS_VARIANT =
TABLES
t_outtab = <table>
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.