Generating reports in SAP NetWeaver with FastReport.Net – Part 2 - Output messages (print documents)

2017-05-08

Part 1 of the article

Task:

To build print form of purchase order and generate it for document type  “NB standard order”.

Example:

1

 

Prepare Data dictionary.

For PO output data we need to create structures in ABAP dictionary. These structures will be used in the report designer as data source.

Run transaction SE11. Create and activate the follow objects:

 

Structure ZZPO_ITEM_S

2

 

Table type ZZPO_ITEM_TT

3

 

Structure ZZPO_PARTNER_S

4


Structure ZZPO_DOC_S

5


Table type ZZPO_DOC_TT

6


Prepare template

Run transaction ZFR_RMAN.

Press on “New” button and add a new report “ZPO_FR” with parameters as presented on the screenshot

7

 Save the report.

 

After saving switch into edit mode (press “Edit” button) and then press “Designer” button.

System will ask to enter Data source table. Enter ZPO_DOC_TT.

8


After confirmation Fast report designer will be opened.

9

 

Configure bands.

Menu: Report->Configure bands.

  • Configure (add\remove) bands as presented on the screenshot

10

 

Press on “Close” button.

  • Double click on 1st level “Data” band and select “ITEMS” as data source.

11


  • Double click on 2d level “Data” band and select “SCHD” as data source.
 
  • Place report elements.
    • Stretch “Report Title” band, place “text elements” from element toolbar and fill them with the static texts. Drag fields from “MYDATASET” data source table to the “Report Title”.
    • Format “Page header” band to display items header ( add static text elements ).   
    • Format “Data: ITEMS” band - place fields from “ITEMS” table.
    • Format “Data: SCHD” band - place fields from “SHDL” table.
    • On “Footer” band place summary fields from “ITEMS” table ([ITEMS.MENGE] and [ITEMS.MEINS]).

 

User and Developer manual for designer can be found here: https://www.fast-report.com/en/product/fast-report-net/documentation/

     Final template:

12

If to press “preview” button - report will be empty because still no “test” data has been generated. Later we will see how generate temporary data and preview report with the data.

Save report template (press SAP standard button) and leave designer.

 

Now press “Save” to save\update report settings.

13

 

Develop print program and perform customizing

We need to develop program\routine to be able to call printing form from purchase order output function.

In ABAP Workbench create new module pool ZZMM_FRPRINTING.

Add subroutine “po_print_fr” with the follow code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
*&---------------------------------------------------------------------*
*& Module Pool ZZMM_FRPRINTING
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
 
PROGRAM zzmm_frprinting.
TABLES: nast.
 
*&---------------------------------------------------------------------*
*& Form po_print_fr
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->ENT_RETCO text
* -->ENT_SCREEN text
*----------------------------------------------------------------------*
FORM po_print_fr USING ent_retco ent_screen.
 
 DATA: lv_druvo LIKE t166k-druvo,
 ls_nast LIKE nast,
 lv_from_memory,
 ls_doc TYPE meein_purchase_doc_print,
 lt_ret TYPE bapiret2_t.
 
 DATA lo_fr TYPE REF TO zcl_frbase_report.
 
 DATA: ls_order TYPE zzpo_doc_s,
 lt_order TYPE zzpo_doc_tt,
 ls_item TYPE zzpo_item_s,
 ls_schd TYPE eket.
 
 FIELD-SYMBOLS: <fs1> TYPE ekpo,
 <fs2> TYPE eket.
 
 CLEAR ent_retco.
 
 IF nast-aende EQ space.
 lv_druvo = '1'.
 ELSE.
 lv_druvo = '2'.
 ENDIF.
 
 CALL FUNCTION 'ME_READ_PO_FOR_PRINTING'
 EXPORTING
 ix_nast = nast
 ix_screen = ent_screen
 IMPORTING
 ex_retco = ent_retco
 ex_nast = ls_nast
 doc = ls_doc
 CHANGING
 cx_druvo = lv_druvo
 cx_from_memory = lv_from_memory.
 
 CHECK ent_retco EQ 0.
 
 MOVE-CORRESPONDING ls_doc-xekko TO ls_order.
 
 SELECT SINGLE * INTO CORRESPONDING FIELDS OF ls_order-provdata
 FROM lfa1 WHERE lifnr = ls_order-lifnr.
 
 LOOP AT ls_doc-xekpo ASSIGNING <fs1>.
 
 CLEAR ls_item.
 MOVE-CORRESPONDING <fs1> TO ls_item.
 
 LOOP AT ls_doc-xeket ASSIGNING <fs2>.
 CLEAR ls_schd.
 CHECK <fs2>-ebelp = ls_item-ebelp.
 MOVE-CORRESPONDING <fs2> TO ls_schd.
 APPEND ls_schd TO ls_item-schd.
 ENDLOOP.
 
 APPEND ls_item TO ls_order-items.
 
 ENDLOOP.
 
 APPEND ls_order TO lt_order.
 
 CREATE OBJECT lo_fr
 EXPORTING
 iv_reportkey = 'ZPO_FR'.
 
 " use for production
 ent_retco = lo_fr->build_report( lt_order ).
 
**********************************************************************
**use for debugging\template correction
" DATA: lv_answer.
 
" lo_fr->set_mode( zcl_frbase_report=>mc_edit ).
" lo_fr->call_designer( lt_order ).
" CALL FUNCTION 'POPUP_TO_CONFIRM'
" EXPORTING
" text_question = 'update report template in DB?'
" IMPORTING
" answer = lv_answer.
" if lv_answer eq '1'.
" lo_fr->save_report( ).
" ENDIF.
**********************************************************************
 
 
ENDFORM. "po_print_fr

 

In the code we call function to retrieve PO information, then map the data to our structure and call method ZCL_FRBASE_REPORT->BUILD_REPORT for report generation. In case we need to debug form with test data  - comment call of “BUILD_REPORT” method and uncomment section below. 


Customizing.

Call transaction NACE and create new output type ZZFR for Purchase order. As printing program select ZZMM_FRPRINTING and routine PO_PRINT_FR. Choose access sequence  0001.

14


Add new output type to your output schema (for example RMBEF1)

15

 

Create condition record for condition type ZZFR and PO type NB. 

16


Open follow settings path: SPRO->Material Management->Purchasing->Messages->Output control->Message types->Define message types for Purchase order-> Fine-Tuned Control: Purchase Order.

Add records for ZZFR

17

 

Now you can open existing purchase order or create a new one and test printing form using standard buttons in the transaction ME23N. Otherwise use transaction ME9F for printing.

18

 

19


August 12, 2024

How to build and install the Postgres plugin in FastReport .NET

This article describes how to connect to the database using the FastReport .NET plugin for the report designer from Visual Studio via the NuGet server.
August 08, 2024

How to install FastReport .NET and its components on Windows

Step-by-step instructions for online and manual installation via the FastReport registration code.NET and its components in Windows.
July 26, 2024

Updating HTMLObject as a plugin for FastReport .NET

Detailed instructions for using the new HTMLObject plugin, which uses splitting DOM HTML into FastReport report objects.
Fast Reports
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314

© 1998-2024 Fast Reports Inc.