..3 Printing program
Create a report Z_DYNTABLE_2 and paste below code into it:
REPORT z_dyntable_2 .
* declare the context
DATA gt_context TYPE zcontext_dyntable .
* fill the context
PERFORM fill_context .
* call the form
CALL FUNCTION 'ZXLWB_CALLFORM'
EXPORTING
iv_formname = 'DYNTABLE_2'
iv_context_ref = gt_context
EXCEPTIONS
process_terminated = 1
OTHERS = 2.
IF sy-subrc NE 0 .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 .
ENDIF .
*&---------------------------------------------------------------------*
*& Form fill_context
*&---------------------------------------------------------------------*
FORM fill_context .
DATA:
ls_row TYPE zcontext_dyntable_row ,
ls_cell TYPE zcontext_dyntable_cell ,
lv_rows_number TYPE i ,
lv_cols_number TYPE i ,
lv_index_row TYPE char10 ,
lv_index_col TYPE char10 .
*======================================================================
CALL FUNCTION 'BKK_RANDOM'
EXPORTING
i_modulo = 100
IMPORTING
e_random_number = lv_rows_number.
CALL FUNCTION 'BKK_RANDOM'
EXPORTING
i_modulo = 100
IMPORTING
e_random_number = lv_cols_number.
*======================================================================
* ==>> top row (HEADER)
CLEAR ls_row .
CLEAR ls_cell .
ls_cell-format_1 = 'X' .
APPEND ls_cell TO ls_row-cells .
DO lv_cols_number TIMES .
lv_index_col = sy-index .
CLEAR ls_cell .
ls_cell-format_3 = 'X' .
CONCATENATE 'Column' lv_index_col
INTO ls_cell-value SEPARATED BY space .
CONDENSE ls_cell-value .
APPEND ls_cell TO ls_row-cells .
ENDDO .
APPEND ls_row TO gt_context .
* <<== top row (HEADER)
*======================================================================
* ==>> other rows
DO lv_rows_number TIMES .
lv_index_row = sy-index .
CLEAR ls_row .
* ---->> left column
CLEAR ls_cell .
ls_cell-format_2 = 'X' .
CONCATENATE 'Row' lv_index_row
INTO ls_cell-value SEPARATED BY space .
CONDENSE ls_cell-value .
APPEND ls_cell TO ls_row-cells .
* <<---- left column
* ---->> other cells
DO lv_cols_number TIMES .
lv_index_col = sy-index .
CLEAR ls_cell .
ls_cell-format_1 = 'X' .
CONCATENATE 'Cell' lv_index_row '/' lv_index_col
INTO ls_cell-value SEPARATED BY space .
CONDENSE ls_cell-value .
APPEND ls_cell TO ls_row-cells .
ENDDO .
* <<---- other cells
APPEND ls_row TO gt_context .
ENDDO .
* <<== other rows
ENDFORM . "fill_context