..3 Программа печати

Создайте отчет Z_FORM_ORDER и поместите в него следующий код:

REPORT z_form_order .


* declare the context

DATA gs_context TYPE zcontext .


* fill the context

PERFORM fill_context .


* call the form

CALL FUNCTION 'ZXLWB_CALLFORM'

EXPORTING

iv_formname = 'FORM_ORDER'

iv_context_ref = gs_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_header TYPE zcontext_header ,

ls_position TYPE zcontext_position ,

ls_footer TYPE zcontext_footer ,

lv_poscount TYPE char10 .


* -->> header

ls_header-name = 'John Doe' .

ls_header-address = '123 Main street #45' .

ls_header-city = 'Brooklyn' .

ls_header-state = 'NY' .

ls_header-zip = '11201' .

ls_header-phone = '1-234-567-8910' .

ls_header-email = 'John.Doe.12345@gmail.com' .

gs_context-header = ls_header .


* -->> positions

DO 10 TIMES .

ls_position-name(3) = sy-index .

ls_position-name+3 = 'Position' .

ls_position-qty = sy-index .

ls_position-price = sy-index + 555 .

ls_position-total = '=RC[-5]*RC[-3]' . " -->> formula

APPEND ls_position TO gs_context-positions .

ENDDO .


* -->> footer

lv_poscount = LINES( gs_context-positions[] ) .

CONCATENATE '=SUM(R[-' lv_poscount ']C:R[-1]C)' INTO ls_footer-subtotal .

CONDENSE ls_footer-subtotal NO-GAPS . " -->> formula: =SUM(R[-10]C:R[-1]C)

ls_footer-total = '=R[-2]C' . " -->> formula

ls_footer-card_visa = space .

ls_footer-card_mc = 'V' .

ls_footer-card_discover = space .

ls_footer-card_number = '1234567890123456' .

ls_footer-expiry_date = '20140601' .

gs_context-footer = ls_footer .


ENDFORM . "fill_context

Результат работы программы: