Application Development 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: 

multiple line items in smartform using template

arpitr
Participant
0 Kudos

Dear Experts,

I have created a smartform, in which I have used only templates.

In multiple line item case it only takes last line item and prints.

I have also searched web where experts advice to use tables for multiple line items.

Still , is there any other way out that without changing my SF design same can be achieved.

I am attaching screen shot of output where part no, item and quantity changes in line item (plz see screen shot).

so please help me to solve this issue.

Regards,

Arpit R

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Arpit,

if you want to display multiple line item details table is the best way to display.

But if you still want to use template for that , use that template inside the loop so the template will be repeated and display data like wise.

Regards,

Jaydeep Patel

21 REPLIES 21

Former Member
0 Kudos

Hi Arpit,

if you want to display multiple line item details table is the best way to display.

But if you still want to use template for that , use that template inside the loop so the template will be repeated and display data like wise.

Regards,

Jaydeep Patel

0 Kudos

Thanks Jaydeep,

I changed it as u suggested but it is not working.

also as per my SF design is it possible to use tables?

Regards,

Arpit

0 Kudos

Hi,

except main window, no window grows with dynamic data. I believe you are using secondary windows with template inside loop.

therefore you need to use table in the main window to display line items.

thanks!!

0 Kudos

hi Aprit,

first thing your line item wise data should be display in main window as secondary window have static height. secondly you can use table and you have to create different  lines types according to your requirement , here you require 3-4 different line type .

can you share the format that you want with multiple record ?

Regards,

Jaydeep Patel

0 Kudos

Dear Jaydeep,

I have made changes and now format is as shown in screenshot.

Now req is to print whole smartform for each line item.

for example in current document there are 3 line items.

So three pages should be generated where only table data will be changed.

Table has 5 columns :

part no    Item   cha quan            R qua     acc quan

so how can I proceed now ?

SF is getting printed rightly for only 1 line item

Regards,

Arpit

0 Kudos

Hi,

you can use command for page break.

refer below pic for reference.

Regards,

Jaydeep Patel

0 Kudos

Hi Arpit,

Make use of events(Sort begin or sort end) to create different pages of smartforms for every line item.

Let me know if you need anymore help.

Regards,

Shadab.

0 Kudos

Hi Jaydeep,

as suggested by you I used command under row, but it create problem after all line item.

For example, in a document there are 3 line items so 3 pages are generating which is correct, but additional 4 page is also generated and there is a gap bet main window and next window.

I also checked upper margin and window layout and didn't get the reason.

Regards,

Arpit

0 Kudos

Hi Shadab,

Can you guide me to use events?

I am getting this(screenshot) where 2 line items are getting printed on a single page , but when item name is big enough to occupy all space, I get correct output.

So please guide me.

Regards Shadab,

0 Kudos

Hi Arpit,

This will reduce your extra page.

Regards,

Jaydeep Patel

0 Kudos

Hi Arpit,

Check out the below example, Here one document number from BKPF has multiple line items in BSEG which has to display in multiple smartforms(Each document on single page with correcponding line items on same page).

Check The screen shot for each step.

Steps

1. Define a loop with event sort begin(Here you can use your internal table which contains the line 

    item and use the part No. in event as i have used BELNR here).

In your case whenever the new part No. will come this event will fire and the inner loop gets executed, and after displaying the line item it will again  call the new page with the help of command.

2.Put the validation for table in a loop to have the relation between BKPF and BSEG(In you case the internal table at loop and at main table is same i,e. internal which contains line items partno = wa_itab-partno).

3.And the final step is to call new page(By using Command) when all the corresponding lines are printed on one page.

Let me know if you have any doubts.

Regards,

Shadab.

0 Kudos

Thank you Shadab for the help, u gave clear idea and it helped me a lot.

I have passed all 3 fields (partno, item, qty) in events as adviced by you.

I want little bit help more.

I have a document having 4 line items . All four line items could be seen in debug (screenshot)

but when I checked output all 4 pages are genereted but with different combination of Item(MAKTX)  Part no (MATNR) and Chal Qty(menge).

screenshots are in orderd as they appear in ouput.

pg1

pg2

pg3

pg4

I also debugged the program for getting reason but didn't get it.

So if you have any clue please advice me.

Regards,

Arpit

0 Kudos

Hi Arpit,

Sorry for the late reply, I am not clear about your query, will you please explain me what exactly you want??

Regards,

shadab.

0 Kudos

Hi Arpit,

One more thing I need to add here, Instead of using part no, Item and quantity in event make use of only ZEILE(Which I can see in first screen shot) in a event.

Hope this helps you.

Regards,

Shadab.

0 Kudos

Hi Shadab,

I already tried it, also I tried it with combination of partno, Item and Quantity, but still there are problems.

Now I have changed the whole structure again and I am using templates only inside main window by looping them .

Now Item wise pages are generated, but It generates extra page after all line items

( total no.page = line item + 1), I have also used command inside the loop which is necessary.

So do you have any suggestion to avoid that last page ?

Regards,

Arpit

0 Kudos

Hi Arpit,

I guess the last page will be containing only the hard-code values.

To avoid this kindly do the following steps.

1.  Before the loop, store the count of Table-size(internal table on which you are iterating) into one global variable(say GV_COUNT) using  program-logic

2.  In the 2nd tab[Conditions] of the Command-Line, write the condition as

     SFSY-PAGE LT GV_COUNT

Doing so, the command-Line will not trigger at the last iteration and page-break will not happen.

Let me know if this wont work out.

Thanks,

Gupta

0 Kudos

Hi Arpit,

Try the below to restrict the blank page coming at last.

1.Define two global variables as below with default value for M.

2.Define the program lines after the event and get the value of itab(Of first loop and delete adjacent   

  Duplicates).

3.Define a condition at command line to restrict calling last page.

 

Here you go its done, let me know if you are still facing any issues.

Regards,

Shadab.

0 Kudos

Thanks Jaydeep , Shadab and Gopal for your valuable suggestions.

SF is working correctly in production system also.

I used templates and command  under loop to display dynamic data and put the condition in command that pages < no of recoeds in internal table( vlines) and also in General attributes tab..

Thank you again.

My problem is completely resolved now.

Regards,

Arpit

0 Kudos

Hi Arpit,

Thank you for your feedback, You can close this thread so that people looking for the same issue can get help from this.

Regards,

Shadab.

Chintu6august
Contributor
0 Kudos

Hi,

templates are used when the output is known to us, templates have fixed structure i.e when we display fixed data as it does not grow with dynamic data.

so you must use tables as number of the line items(dynamic data) are not known to you.

thanks!!

0 Kudos

Go with Table, its ultimate solution, remove Template. I agree with Above chintu sharma reply.