Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Dynamically changing layout in smartforms

former_member694142
Participant
0 Likes
4,095

Hi Experts,

We have a requirement of printing two shipment smartforms of different layouts in SAP SD.When I say ,two different smartfoms , I mean one for shipment of Object XYZ and other for Object ABC.

Layouts differ in the way as :

For Shipment of Object XYZ, Page 1 will have header details and some constant text and Page 2 will have item data and customer details and so one.

For Shipment of Object ABC,header data and item details starts form here itself.

It wud have been easier if we wud have executed it via se38 directly by calling two smartforms based upon some condition of a field.

But, in our project the smartform needs to be configured to a specific output type and it wud be called when that particular output type will be triggered.

Hence , we cannot go with two smartforms with different layouts. Now functional want the two different layouts in a single smartform as the client is not willing to create separate output types.But the problem is how wud I be able to print page 1 with constant text in case of object XYZ while same page will be used for item details for object ABC.

There are some fields as well which have different  names and may be missing in one but present in other.

please help with your ideas and experience.

Regards,

Ashish.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,170

Hi

In this case put two windows (One for text and another one for line item ) in page 1.

Add condition to print the information based on requirement.

Page 2 Add a window to print line item , In this case it should print line item for particular case.

because it printed in page 1 for alternate case.

Hope you are clear now.Please let me know, if you need more information.

Thanks

Gowrishankar

10 REPLIES 10
Read only

Former Member
0 Likes
2,171

Hi

In this case put two windows (One for text and another one for line item ) in page 1.

Add condition to print the information based on requirement.

Page 2 Add a window to print line item , In this case it should print line item for particular case.

because it printed in page 1 for alternate case.

Hope you are clear now.Please let me know, if you need more information.

Thanks

Gowrishankar

Read only

0 Likes
2,170

Thanks Gowrishankar. But can you please elaborate as I am still not clear

Read only

0 Likes
2,170

Requirement 1 - Print Text and line item in Page1

Requirement 2 - Print line item in Page2.

Page 1 :

Add two windows one for text and another one for line item.

Before printing text or line item add program line to write your code to validate the condition.

if the condition met set some flag and use that one in condition tab while printing object.

        Page 1

           --Window(To print Text)

                  program line - Write your logic to validate requirement 1. if condtion met, set flag x.

                  text line - flag eq X - Print the required text.

            

           --Window 2(To print line item)

              Program Line - Add condition to validate requriement 1. if condition met, set flag X.

              Text line - if  flag eq X - Print the line item

Page 2 :

Add line item window and use the same line item table to print line items.

in this case you have to write logic in program line to check for your requirement 2.

if it meets it should print the line item.This line item will not print for requirement 1 because it will not pass your condition.

            

           --Window 1(To print line item)

              Program Line - Add condition to validate requriement 2. if condition met, set flag X.

              Text line - if  flag eq X - Print the line item.

Hope you are clear now 🙂

Thanks

Gowrishankar

Read only

rosenberg_eitan
Active Contributor
0 Likes
2,170

Hi,

If it is easy to create a single form go for it (less maintenance in the long run) .

If not:

Create 2 forms .

You can HARD CODE the form names when using FUNCTION

'SSF_FUNCTION_MODULE_NAME' .

Call in your print program the one you need .

As for HARD CODE Objects like that are not changed every 5 minutes....

Also table TNAPR have 5 "PDF/Smart Form: Form Name" fields maybe it is possible to have one program name and two forms.

  
Regards.

Read only

Former Member
0 Likes
2,170

Better 2 smartforms and the driver program has logic to decide the smartforms.

Else you can create 2 pages with different main windows and change the first page dynamically based on the driver program value

Read only

Jelena_Perfiljeva
Active Contributor
0 Likes
2,170

I'd say that having two output types with two forms would probably be a more "clean" and rational solution if there are major layout differences.

But in the Smartforms it is possible to apply conditions to pretty much every element. There is also 'goto page' command. So to me it seems that one would just need to pass the criteria to the form and then add the conditions accordingly. It's pretty straightforward, so what exactly is a problem here?

Read only

Former Member
0 Likes
2,170

Hi you can  accomplish this by using "window conditions"( we can call windows by providing conditions) at runtime

Read only

Private_Member_7726
Active Contributor
0 Likes
2,170

Hi,

Just in case you didn't know this: you can control the starting page of smartform via control parameters STARTPAGE, it can be set in "driver" program (preferable) or the INITIALIZATION part/tab of the form itself. So create all the necessary page layouts and then control the page sequence per type.

cheers

Jānis

Read only

former_member694142
Participant
0 Likes
2,170

Thanks guyz for your help. I am trying the way Gowrishankar has explained .Will definitely update you all on this.

Read only

former_member694142
Participant
0 Likes
2,170

Thnaks Gowrishankar and all others.

Have successfully able to achieve my requirement with your help. Thanks buddy!!!

Regards,

Ashish.