Visualizzare Dinamicamente i dati delle Tabelle Standard usando i concetti dei Field Symbols.
Come parametri di selezione, inseriamo il nome della tabella da visualizzare e il numero di record da visualizzare.
Dichiariamo un Field Symbols di tipo Tabella Standard.
Creiamo una tabella interna che a Run Time, viene popolata con i dati selezionati dalla tabella inserita come parametro di input.
Successivamente viene creato un Field Catalog per visualizzare i Dati.
*&---------------------------------------------------------------------*
*& Report Z_VIEW_TABLE_DINAMIC
*&---------------------------------------------------------------------*
REPORT z_view_table_dinamic NO STANDARD PAGE HEADING.
TYPE-POOLS : slis.
*"Parameters elements..................................................
PARAMETERS : p_table TYPE tabname OBLIGATORY, " Table Name
p_no TYPE i . " No of Records to be displayed
DATA:
w_dref TYPE REF TO data, " w_dref reference variable
t_line TYPE c LENGTH 20. " w_line to hold a line
DATA :
t_fcat TYPE slis_t_fieldcat_alv.
FIELD-SYMBOLS: <t_itab> TYPE STANDARD TABLE.
START-OF-SELECTION.
SELECT SINGLE
tabname " Table Name
FROM dd02l
INTO t_line
WHERE tabname EQ p_table
AND as4vers EQ ' '
AND as4local EQ 'A'
AND tabclass NE 'INTTAB'
AND tabclass NE 'APPEND'.
IF sy-subrc EQ 0.
CREATE DATA w_dref TYPE STANDARD TABLE OF (p_table).
ASSIGN w_dref->* TO <t_itab>.
IF sy-subrc EQ 0.
SELECT * " All Fields
FROM (p_table)
INTO TABLE <t_itab> UP TO p_no ROWS.
IF sy-subrc EQ 0.
PERFORM fill_catalog.
PERFORM display.
ELSE.
MESSAGE sy-msgv1 TYPE 'S'.
EXIT.
ENDIF.
ELSE.
MESSAGE sy-msgv1 TYPE 'S'.
EXIT.
ENDIF.
ELSE.
MESSAGE sy-msgv1 TYPE 'S'.
LEAVE LIST-PROCESSING.
ENDIF.
FORM display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = t_fcat
TABLES
t_outtab = <t_itab>
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno DISPLAY LIKE 'E'
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
ENDFORM. " DISPLAY
FORM fill_catalog .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_structure_name = p_table
CHANGING
ct_fieldcat = t_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno DISPLAY LIKE 'E'
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
ENDFORM. " FILL_CATALOG
Dichiariamo un Field Symbols di tipo Tabella Standard.
Creiamo una tabella interna che a Run Time, viene popolata con i dati selezionati dalla tabella inserita come parametro di input.
Successivamente viene creato un Field Catalog per visualizzare i Dati.
*&---------------------------------------------------------------------*
*& Report Z_VIEW_TABLE_DINAMIC
*&---------------------------------------------------------------------*
REPORT z_view_table_dinamic NO STANDARD PAGE HEADING.
TYPE-POOLS : slis.
*"Parameters elements..................................................
PARAMETERS : p_table TYPE tabname OBLIGATORY, " Table Name
p_no TYPE i . " No of Records to be displayed
DATA:
w_dref TYPE REF TO data, " w_dref reference variable
t_line TYPE c LENGTH 20. " w_line to hold a line
DATA :
t_fcat TYPE slis_t_fieldcat_alv.
FIELD-SYMBOLS: <t_itab> TYPE STANDARD TABLE.
START-OF-SELECTION.
SELECT SINGLE
tabname " Table Name
FROM dd02l
INTO t_line
WHERE tabname EQ p_table
AND as4vers EQ ' '
AND as4local EQ 'A'
AND tabclass NE 'INTTAB'
AND tabclass NE 'APPEND'.
IF sy-subrc EQ 0.
CREATE DATA w_dref TYPE STANDARD TABLE OF (p_table).
ASSIGN w_dref->* TO <t_itab>.
IF sy-subrc EQ 0.
SELECT * " All Fields
FROM (p_table)
INTO TABLE <t_itab> UP TO p_no ROWS.
IF sy-subrc EQ 0.
PERFORM fill_catalog.
PERFORM display.
ELSE.
MESSAGE sy-msgv1 TYPE 'S'.
EXIT.
ENDIF.
ELSE.
MESSAGE sy-msgv1 TYPE 'S'.
EXIT.
ENDIF.
ELSE.
MESSAGE sy-msgv1 TYPE 'S'.
LEAVE LIST-PROCESSING.
ENDIF.
FORM display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = t_fcat
TABLES
t_outtab = <t_itab>
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno DISPLAY LIKE 'E'
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
ENDFORM. " DISPLAY
FORM fill_catalog .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_structure_name = p_table
CHANGING
ct_fieldcat = t_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno DISPLAY LIKE 'E'
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
ENDFORM. " FILL_CATALOG
EBOOK: le mie guide sono visualizzabili cliccando sui link:
1. SAP EWM (Extended Warehouse Management)
3. SAP VIM (Vendor Invoice Management)
1. SAP EWM (Extended Warehouse Management)
3. SAP VIM (Vendor Invoice Management)
SE MI CONTATTATE IN PRIVATO, PAGATE LA META' DEL PREZZO DI AMAZON, E POTETE SCEGLIERE IL FORMATO WORD o PDF.
>>> RECENSIONI DEI LIBRI su Amazon Kindle <<<
Ebook: SAP CDS: https://www.amazon.it/dp/B0B9BD1RN3#customerReviews
Ebook: SAP MM: https://www.amazon.it/dp/B0C3MKD9BR#customerReviews
Ebook: SAP MII: https://www.amazon.it/dp/B0C4392MY9#customerReviews
Ebook: SAP VIM: https://www.amazon.it/dp/B0C6FBK8QN#customerReviews
Ebook: SAP MM: https://www.amazon.it/dp/B0C3MKD9BR#customerReviews
Ebook: SAP MII: https://www.amazon.it/dp/B0C4392MY9#customerReviews
Ebook: SAP VIM: https://www.amazon.it/dp/B0C6FBK8QN#customerReviews
Ebook: SAP EWM: https://www.amazon.it/dp/B0CL6TXP1V#customerReviews
Nessun commento:
Posta un commento