ABAP: smartforms-disk Table Design

Source: Internet
Author: User

 

Report requirements: (see the table below)

Requirements:
1. Table lines also need to be output instead of table lines.
2. Eight rows of records are printed for each report, and insufficient blank rows need to be output.
3. Print documents by creden. You can print multiple reports consecutively.

1. Create a style:

Before creating a form, you must create multiple paragraphs and font styles for the text in the form. You must set multiple "section Formats" and set "standard section" in "header data"

1. Create a paragraph in the format of Rh (Report header), Pd (page header), Pb (page bottom), LD (line header and details), Font: cnsong, 9pt. Note that it is best to set the indentation of 1mm in the "first line" of each section. Otherwise, there will be no gap between the table line and text in the form.

2. Set "standard section" in "header data"

3. Save and activate the style file.

2. Create a smartform

1. In "global settings"> "Table properties"> "output options ",

Set "page format": the size of the paper

"Style": Set the default style file used by this form, which is specified as the Style File Created in step 1.

2. Choose "global settings"> "Table Interface"> "import"

Set two parameters:

Ptr_header Type C

Ptr_items Type C

These two parameters are used to pass in the handle (ID key) of the table data in the export in the report ).

3. perform multiple settings in "global settings"> "global definition ".

A. For "type" setting, four types must be defined here. One is the workspace and inner table used to save the header data, and the other is the workspace and inner table used to save the detailed data, their structure must be exactly the same as that of the export to the table in the database in the report. Otherwise, we cannot recover the data in the table from the input handle (ID key.

* Picking ticket header information

Types:

Begin of typ_header_row,

Certificate Nr like mseg-certificate NR, "credential No.

Bldat like rkpf-rsdat, "credential date

C_so (16) type C, "sales order No.

C_issdt like sy-datum, "date of shipment

Werks like mseg-werks, "Location

Plnat_name like t001w-name1, "Shipping Organization Name

Kokrs like mseg-kokrs, "control scope

Kostl like mseg-kostl, "cost center

Cc_name like cskt-ktext, "cost center name

C_depart (45) type C, "Picking Department

BG like mseg-BG, "Mobile Code

Btext_mt like t156t-btext, "mobile type description

C_btext_mt (60) type C, "Number of mobile types

C_total (17) type C, "manually fill in the total output

End of typ_header_row.

Types: typ_header_table type typ_header_row occurs 0.

* Detailed information of the picking ticket

Types:

Begin of typ_items_row,

Material Nr like mseg-material NR, "material credential No.: Material credential

Rsnum like rkpf-rsnum, "credential No.: reserved ticket

Mjahr like mseg-mjahr, "material credential year

Zeile like mseg-zeile, "no.

BG like mseg-BG, "Mobile Code

Werks like mseg-werks, "Location

Kokrs like mseg-kokrs, "control scope

Kostl like mseg-kostl, "cost center

Matnr like mseg-matnr, "material number

Maktx like Makt-maktx, "material description

Erfme like mseg-erfme, "measurement unit

C_planc like resb-bdmng, "quantity of plans (manually entered)

C_outc like mseg-erfmg, "real-time quantity

C_count (6) type C, "quantity (manually filled in)

Lgort like mseg-lgort, "storage location

Charg like mseg-charg, "Remarks

End of typ_items_row.

Types: typ_items_table type typ_items_row occurs 0.

B. Define global variables in "Global Data". We need to define the following variables:

Wa_header type typ_header_row "header data workspace. Because the internal table in smartforms cannot have headerline, you must define a workspace with the same structure as the internal table.

Ig_header type typ_header_table "internal table of the header

Wa_items type typ_items_row "Form details Workspace

Ig_items type typ_items_table "Table Details table

Wa_blanks type typ_items_row "Blank row Workspace

Ig_blanks type typ_items_table "Blank intra-Row Table

G_count type I "records the number of detailed records of a report

G_currline type I "records the total number of rows printed in all reports, used to determine the last page

G_totallines type I "records the total number of ig_items rows in the table, used to determine the last page

G_currpage type I "Current page number of a credential

G_totalpage type I "total page number of a credential

C. In "initialization", restore the internal table in the Data handle to the newly set global variable.

Input parameters: ptr_header, ptr_items, ig_header, ig_items, g_totallines

Perform restor_buffer using ptr_header changing ig_header.

Perform restor_buffer using ptr_items changing ig_items.

Describe table ig_items lines g_totallines.

D. Define the form restor_buffer function in freecode "formatting program ".

Form restor_buffer using typeid Type C changing T type table.

IMPOrt t from database indx (HK) ID typeid.

Endform.

At this point, we have obtained the data of the table header and details. The following prepare a report and output the data.

4. In "pages and Windows", add three windows under "% page1"

"Main Window": In smartform, only windows with the window type of "Main Window" can be recycled. For example, in the first sample table, there are 20 detailed data records, and the output cannot be printed on one page. Four pages must be output to print the data of one document, in the four documents, the header and the end of the table remain unchanged, but the data in the middle of the table changes. The window in the middle needs to be output cyclically four times. Therefore, you need to set the window type to "Main Window ". In this example, the actual detailed data is used.

"Window 1": The title bar from the top of the table to the details column (including the title bar)

"Window 2": the bottom two rows.

Note: The padding of the window width cannot be greater than the width of the paper.

Create these three windows, set the window width, height, and position information. Is the structure of the entire smartform

 

Note: I placed the "% windows1 page header" of the output header under the "Main Window" of the output detail data. This is required, because the data in the header needs to come from the ig_header table in the header. Loop1 is the ig_header of the loop table, which is placed in the wa_header of the header workspace. Therefore, the % windows1 page header window can directly use the data in the wa_header of the workspace. If the window is placed in front of the main window, at least the header of the first page will have no data, and the header of each subsequent page will display the content of the next header.

Note: During Printer output, the % windows1 page header is printed, the main window is printed, and the % window2 page tail window is printed. However, when the program is executed, however, it is processed from top to bottom according to the tree structure. The main window is processed first, followed by the % windows1 page header, and the logic sequence of the % window2 page tail window is known from the smartforms tracking program.

The following describes the entire logical process and code in detail:

1.% loop1 header Loop

Set: DATA> loop> operand: ig_header into wa_header

Purpose: print the row project data of a credential each time based on the data in the table in the loop header. Because the inner table does not have a workspace here, each header data is placed in another workspace.

2.% loop4 calculate the total page number of a single credential

Set: DATA> loop> operand: ig_items into wa_items

Where condition: iblnr = WA_HEADER-IBLNR

Purpose: before printing each credential and row item, you need to know the total number of pages of the Credential. Therefore, you need to calculate the number of Row Records of the current credential in the ig_items table.

3.% CoDe4 cumulative number of line items for a single credential

Input parameter: g_count

Code:

G_count = g_count + 1.

Purpose: Accumulate the number of line items of the current credential.

4.% CoDe1 calculates the total page number of the current credential

Input parameters: g_totalpage, g_count

Code:

G_totalpage = 0.

* Calculate the total page number of a single credential

G_totalpage = g_count mod 8.

If g_totalpage = 0.

G_totalpage = g_count Div 8.

Else.

G_totalpage = g_count Div 8 + 1.

Endif.

G_count = 0.

Purpose: calculate the total number of items to be printed for a single Credential Based on the total number of items accumulated in step 3 and the number of Row Records printed on each page (8. After calculation, g_count is reset to 0.

6.% loop2 loop output details

Set: DATA> loop> operand: ig_items into wa_items

Where condition: iblnr = WA_HEADER-IBLNR

Purpose: The cyclic condition here is exactly the same as the condition in step 1. It is prepared to print all row items of the current credential cyclically.

7.% CoDe2 record lines plus 1

Input parameters: g_count, g_currline

Code:

* Each row of records is printed. The number of records is increased by 1.

G_count = g_count + 1.

G_currline = g_currline + 1.

Purpose: for each cycle, the number of Row Records printed by the current credential plus 1, and the number of total Row Records printed by all creden plus 1.

8.% template4 data details

Role: Template, row record table, and related text content. Loop2 prints a line of the template and text content each time it cyclically. The row height is generally 5mm (adjusted based on actual conditions). Note that the width of the template cannot exceed the window width. In "details", you can adjust the width of each cell in the template and the height of each row.

9.% text22-% text30 text content

% Text22 No.: & g_count (czt4r) & output option-> output structure: 1st rows and 1st Columns

% Text23 item number: & WA_ITEMS-MATNR & output option-> output structure: 1st rows, 2nd Columns

And so on.

10, % CoDe5 calculates the current page number

Input parameters: g_count, g_currpage

Code:

DaTa: l_line type I.

Rochelle line = g_count mod 8.

If l_line = 0.

G_currpage = g_count/8.

Else.

G_currpage = g_count Div 8 + 1.

Endif.

Purpose: Calculate the page number of the current row for each output row, that is, the current page.

11.% CoEmpty rows calculated by DE3

Input parameters: g_count, ig_blks, wa_blks

Code:

G_count = g_count mod 8.

* Required number of empty records

If g_count <> 0.

G_count = 8-g_count.

Endif.

Clear ig_blanks [].

Do g_count times.

Append wa_balanks to ig_balanks.

Enddo.

G_count = 0.

Purpose: After all valid data rows of the current credential are printed, You need to calculate how many blank rows need to be printed to print a piece of paper. Fill the inner table ig_blks with the calculated quantity. After calculation, g_count must be cleared by 0.

12.% loop3 add blank lines

Set: DATA> loop> operand: ig_blankss into wa_blanks

Where condition: None

Purpose: in the cyclic table ig_blks, the number of times is the number of records in the internal table, that is, the number of empty rows, and the output blank rows.

13.% template5 NULL data details

Purpose: The template is exactly the same as step 4 template4, but the template does not need text, and only outputs the table line of the template by serial number.

In this step, all valid data rows and empty supplementary rows of the current credential have been printed. If the current credential needs to print multiple pages, for example, 30 rows of records, three full pages need to be printed, 4th pages output 6 rows of data and add 2 blank rows. The three pages are automatically paged by the system. Before the split, the system automatically processes the page header and the page end window, output the content of these two windows. The condition for automatic paging is that the height of the "Main Window" is fully printed, so be sure to note that the height of the main window must be equal to the height you need, either too many or less, in this example, the height is 8 rows x 5mm = 40mm

14.% condition1 page

Set: general property-> node condition: g_currline <> g_totallines

Purpose: After a certificate is printed, the page is displayed before the next certificate is printed. However, no page is displayed after the last page of the last certificate is printed, otherwise, an empty line is added.

15.% command1 force Paging

Set: general property-> to new page: % page1

Purpose: Force paging when the g_currline <> g_totallines condition is true (not the last row.

You may say that there is no forced paging here, and the system will automatically pagination, because the height of the previous output is exactly the height of each window, and the page is automatically displayed, the system automatically performs paging. However, it is emphasized that force paging is required and automatic paging cannot be used. The reason is: the time when automatic paging occurs is not what we expected, we need to paging the page immediately after Step 1 is completed. At this time, the content in the wa_header is still the data of the current credential. In this way, the data is correct when processing the page header and footer window. Automatic paging does not happen at this time, but after the loop in step 1 loop1 is executed again, that is, the content in wa_header is changed to the next one, in this way, we cannot output the correct header and end table data. Therefore, we must use the mandatory paging command.

16. Table header and table tail window

Since these two windows are very simple, only the text description and content in wa_header are output, so they are not described in detail.

Q &

1. The print preview table lines are normal, but some table lines cannot be output using the dot matrix printer.

A: This may be because the resolution of the dot matrix printer is small. The laser or inkjet printer can be used for normal output, or a rough table line can be added to smartforms to use 30tw.

2. When the punched paper is used for continuous printing, the paper on the back is misplaced.

 

A: The reason is not very clear. You need to set the paper format in the printer to add or subtract the paper height based on the dislocation distance. After multiple adjustments, there will be no dislocation.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.