SAP Adobe Form Tutorial. Part XIII. How to Print two Tables Adjacent to each other?

0
82
Nested Table in SAP

Displaying two tables side by side on an SAP Adobe Form is a very common requirement. Most of us find it difficult to meet this requirement the first time. If you search for the solution using the keywords, How to print two tables adjacent to each other in SAP Adobe Form or Data Overflow issue in SubForms Tables in SAP Adobe Forms then you would get the below two links as the first few search results.

How to print two tables adjacent to each other in SAP Adobe Form?
Data overflow – in repeated SubForm & Tables Western Text Issue.

Both the links have a similar issue and both are marked as resolved. But, the resolution is not clear.

When members of SAPYard Technical WhatApp Group asked the same question and when another member pointed to these two links, but it was still not clear to the questioner, we decided to write our own post to clarify it once and for all.

Scenario 1 asked by one User

I have a form with a body page and two tables. The property of the body page is set to ‘Flowed’, ‘top to bottom’ as flow direction and the check box for page break is set.

Requirement

The two tables need to be printed adjacent to each other.

Approach followed until now

  1. Since the body page is ‘Flowed’ type, the two tables are placed one below the other (Tab1 & Tab2). So I tried to set the Flow direction of the Body page to ‘Western text’. But this did not solve the issue as since it is set to ‘western text’, only after Tab1 is rendered, table Tab2 starts printing itself, which is not desired. Both the tables should be printed at the same time.
  2. I wrapped both the tables in one subform with ‘Type’ set to ‘Positioned’ and set the checkbox for the page break. Now I arranged the tables adjacent to each other. But the checkbox for page break for both the tables was disabled and because of this if there is not enough space to print the total records of both the tables, the complete tables are shifted to another page leaving the previous page blank.

 Similar Scenario asked by another User

 “I have an issue with 2 tables lying side by side – say Table A on the left and Table B on the right.
When Table B has an overflow of data in the next page. Then the overflown dataset rows of Table B goes to the left on the next page instead of its column head i.e .right of Table A.
This happens only when table B is overflowing and Table A on the left remaining on Page 1.”

If you did not understand the issue scenario, then the below two images should help. Check on page 2, the right-hand side table is overflowing to page 2 from page 1, but it has shifted to the left instead of staying on the right side.

print two tables adjacent to each other

Hope you understand the scenario now.

There are many suggestions to achieve this. Some said to concatenate all the internal tables to one big internal table to be displayed. It would work, but that is really cumbersome if you have multiple tables.

The other most common practical solution provided is to put the tables in two different SubForms, make them Flowed with page break and print them together. Let us do the same.

Also, Read – SAP S/4 HANA Technical Overview from an ABAPer

We are not showing you how to create the tables and SubForm. We assume, you know it so we are just displaying the Interface and Form settings and codes.

Adobe Form Interface

SAP Adobe Form Issue

TYPES

print adjacent tables

Global Data

Global Data

Code Initialization

initialization in sap adobe

Form Routines

The Form is designed as below.

Two SubForms LHS and RHS are wrapped in one SubForm LHSandRHS. MARA_Table SubForm and MARC_Table SubForm are wrapped inside LHS SubForm. Similarly, EKPO_Table SubForm is wrapped inside RSH SubForm.

Below is the expanded view of all the Hierarchy Objects.

All the SubForms are Contents are Flowed with Flow Direction Western Text.

top to bottom vs western text

Also, do not forget to make the Page DetailBody Content as Flowed and Allow Page Breaks with Content.

We wrote the below Driver Program to test our form.

Let’s test it. In order to keep the left side table within the first page, we give a lower number to select on the selection screen. Whilright-handt hand side table we pull more rows to force it to overflow to the next page.

The first page looks good. The left hand side stops growing while the right hand side grows to next page.

print two tables adjacent to each other

But look, on the next page the right hand side has been shifted to the left side. This is not what our end users want. The Purch Doc column should be aligned with the column from the first page.

Where did it go wrong? Let us check the layout and settings again.

We have set the Subform Content as Flowed for Detail, LeftHandSide (LHS), RHS and all SubForms are Flowed. Still, the layout in the second page is shifted to left. We tried to change the Flow Direction from Top to Bottom to Western Text. But, it did not help.

So we were compelled to try a different strategy. Our plan is to create a table with 1 row and 2 columns i.e it would have only 2 cells. Row 1 Column 1 would have all the LHS subforms (2 tables mara and marc data) and Row1 Column 2 would have all the RHS subforms (1 table with ekpo data).

We need to wrap the two cells into subform and make them Flowed.

Below is a table with 2 cells and in each cell we would put subforms for our data.

Nested Table in SAP

Let’s do it. Let us first create a Table with one Row and two Columns.

We have renamed the table to TwoColTables. Let us rename Cell1 to LHS and Cell2 to RHS.

Now right click on Cell1 and Wrap in SubForm. Wrap Cell2 to SubForm too.

sap adobe

After wrapping and renaming, it would look like below.

adobe forms

Delete the texts LHS and RHS.

Now drag LHS from SubformToHold2SubForms above and put into this LHS in the Row1 of the table.

Similarly drag RHS from SubformToHold2SubForms above and put into this RHS in the Row1 of the table.

Alternatively, you can create these subforms in the LHS and RHS cell fresh. But we are lazy and we want to use what we did earlier. J

interactive Adobe

It should look like below.

adobe form tutorials

You need to have all the SubForms as Flowed expect the two Cells which were wrapped as SubForms. They need to be Positioned.

sub form

Positioned SubForm Cell 1 (LHS)

adobe form tutorials

Positioned SubForm Cell 2 (RHS)

This is the trick of this post. All flowed except the two cells which have to be Positioned. The two cells Content has to be set as Positioned because you do not want to allow the cells to move around freely. The width (and starting x,y coordinates) of the cells are fixed to the position you set. So when any one cell overflows to the next page, it still is on the same alignment as at the first page.

Let’s test now. Run the  Print Program

adobe form

sap adobe free tutorial

Your table now is flowing correctly. In case your left side table or right side table do not start from the same level of the page or position (Y Coordinate), then you might want to make them 0, 0 in the Layout or any other value you want. So that both the tables start from the same position and flow down.

Hope you liked this tutorial. The issue is very common and the solution is also very simple. But as we always say at SAPYard, solutions once found looks simple but to find that simple solution is the most challenging part for ABAPers.

Do you have any tips, tricks, tutorial, concept, config, business case or anything related to SAP to share? Write articles at SAPYard and EARN up to 500 INR per article? Please contact us at mail@sapyard.com to know more.

If you GENUINELY like our articles then it would be a HUGE help if you shared, subscribed and liked us on FacebookIt might seem insignificant, but it helps more than you might think.

Check all the Step by Step Tutorials on Adobe Forms

 

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here