cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in Printing Labels in Smartform

Former Member
0 Kudos

Hi Friends,

I am printing customer address as lables in smartform.. per page 8.

all the lables are printing except main window(last label in the page),

but this 8 the lable is printing in the next page.

I have written the below code in main window(table)

Here it_final is final itab a& data coming to this from driver program

*Push every 8th row if it_final in it_main

I = 8.

if sy-tabix = 8.

do.

read table it_final into wa_final index 1.

if sy-subrc = 0.

append wa_final to it_main.

i = i + 8.

else.

exit.

endif.

enddo.

endif.

*Delete the rows from it_main which are present in it_final

loop at it_main into wa_final.

delete table it_final from wa_final.

endloop.

Can anyone please help me.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Let me tell you what i have understood from your comments ,

1. You are printing 8 labels per page , and using the main and it's table loop.

2. Issue is the 8th lable printing in the next page .

Let me guess you are calling the next page for the loop of 8 th index right ?,

Recently i have worked for 4 lables per page, in order to over come this issue, i have followed thees steps thta would help you.

1. For next page trigerring i have used the main window and table loop.

2. All four lables on four secondary windows with templete.

and given conditions accordingly, it may help you

Edited by: $SAPGURU$ on Jan 6, 2012 8:04 AM

Former Member
0 Kudos

Hi,

Actually the debugger is not going to this code, if sy-tabix = 8.

i put break-point at this code. it goes to break point after one executiion

it comes out without entering into this code printing seven lebels.

The eigth label(main window) is not getting printed because

no data in it_main bcoz of not going into above code.

Former Member
0 Kudos

can you please explain step by step cleary

1. which table your looping first for main window .

2. where you have written code, in the loop or out side the loop.?

3. is there any conditions given for loop processing.

Former Member
0 Kudos

I have created 7 labels next to these main window with table(8 label).

In the initialization i wrote the below code and in the first loop i created

a conditon written below code.

i put one loop in first label before text printing( it_final into wa_final ).

antoher loop in Main window at table( it_final into wa_main ) .

Edited by: anurag.radha on Jan 6, 2012 9:11 AM

Former Member
0 Kudos

Dear Friends,

It is giving only two pages output without main window(8 label).

but it is giving 8 th record in the next page.

Former Member
0 Kudos

Hi friend,

As far as i understand the requirement i can get that you have totally 8 labels in a page all.

8th label you have placed in main window.

All the 7 labels are printing correctly in first page but the 8th label which you have placed is page 1 is not displaying in page 1 its displaying in page 2.

This might be because there may not be space for printing the data. Just try deleting any one label at front and check whether its coming correctly.

Else create a sample smartform with only two labels and main window and see whether everything comes as expected then it will be the problem with the size only nothing else.

Hope it clear. If i am wrong please tell the logic alone we don't need any coding just explain us the logic. From your coding i am not able to get for what purpose you are using delete operation you are using.

Thanks,

Sri Hari

Former Member
0 Kudos

Dear Srihari,

I wrote above code in first label(now i deleted do-enddo) only.

first i am moving seven lebels data into seven wa's.

after that reading the first record and moving another itab(for printing at main window i.e. 8 label).

clearly, there is no space problem..because instead puttting all the required field i put only customer name.

Now it is printing well in first page with 8 labels(main window) also.

But in the second Page it displays only 7 labels and not printing rest of the labels.

for example my itab has 20 records it displays 8 labels in first page &

next 7 labels in second page and not print the rest of the 5 labels i.e. it is not calling third page(?).

code..

CLEAR : WA1, WA2, WA3, WA4, WA5, WA6, WA7.

loop at it_final into wa_final FROM 1 TO 7.

if sy-tabix = '1'.

wa1 = wa_final.

elseif sy-tabix = '2'.

wa2 = wa_final.

elseif sy-tabix = '3'.

wa3 = wa_final.

elseif sy-tabix = '4'.

wa4 = wa_final.

elseif sy-tabix = '5'.

wa5 = wa_final.

elseif sy-tabix = '6'.

wa6 = wa_final.

elseif sy-tabix = '7'.

wa7 = wa_final.

endif.

endloop.

delete it_final from 1 to 7.

**Push every 8th row if it_final in it_main

read table it_final into wa_final index 1. "deleting 8th, 16th,... records

if sy-subrc = 0.

append wa_final to it_main.

else.

exit.

endif.

*Delete the rows from it_main which are present in it_final

loop at it_main into wa_final.

delete table it_final from wa_final. "deleting 8 th row from it_final.

endloop.

Edited by: anurag.radha on Jan 6, 2012 1:09 PM

Former Member
0 Kudos

Hi friend,

Still i am not able to understand the code fully but i can understand the logic.

Let me consider the example mentioned by you, you have 20 labels for printing.

First you loop the first 8 labels into the internal table work area and print all that, then clear the internal table and then again read rest 8 into internal table then move it like wise.....

This is the thing which i can make out of your code.

If your your conversation i can make out that you have two pages and the labels are printing correctly in the first page ie 8 labels,

in the second page you are able to get only 7 labels and reset is not printing.

I have a logic for this concept, I think its the problem with the main window.

In the page1 you have maintained the main window so you are able to accomidatate all the 8 labels but have you maintained the main window in second page too... If not try using the main window in second page too becaise it grows as the content grows.

Just try using main window for the secong page a;lso and then populate the values as you did for page1.

I think this will solve your issue if you have queries please revrt back to me so that i can help you. Just mention the problem which is more sufficient.

Thanks,

Sri Hari

Former Member
0 Kudos

Hi Anu,

As I understood based on your code you need to print 8 label for a page, if I am not wrong!!!

I face this issue recently and then I solve like this.

First count total records in u r Final Internal Table.

for example you have 80 records in final itab,

and then collect 8,16,24,.........64...80th record into one internal table .

for that you need code at Initialization as below.

data : lv_txt(4) type n value 8,

lv_no type i.

describe table it_final lines lv_no.

I = LV_NO MOD 8 ( """ it is use, if itab having more than 80 then have to call next page through node) .

*break-point.

loop at it_final into wa_final.

if sy-tabix = lv_txt.

append wa_final to it_final1.

lv_txt = lv_txt + 8.

endif.

clear wa_final.

endloop .

loop at it_final1 into wa_final.

delete it_final where kunnr = wa_final-kunnr.

endloop.

take 7 window's as normal windows .

place program lines under each and every window and write code as follow.

clear wa_final.

loop at it_final into wa_final.

exit.

endloop.

delete it_final where kunnr = wa_final-kunnr.

and take Mian window at last of page1.

pass it_final1 to main window.

SO IN YOUR ITAB IT_FINAL1 HAVING 8 RECORD'S SO IT WILL CALL NEW PAGE EACH AND EVERY LOOP.

Note : your main window have hieght should allocate space for only one reocrd of itab(it_final1).

Former Member
0 Kudos

Dear nagu,

Your code working superbly.

it solved my issue.

Thnak you so much and to all your valuable responses.

solution :

Along with nagu's code and instructions..

Take care for fitting Main window size.

Create a commnd node after loop(main window) check go to next page.

condition i ne 0.

Answers (0)