2014 Mar 02 10:52 AM
Dear All,
Good day.
Developing an smartform which will print levels based on counter number. For this reason i am doing the below code.
i = 6.
DO.
READ TABLE it_final INTO wa_final INDEX i.
IF sy-subrc = 0.
APPEND wa_final TO it_main.
i = i + 6.
ELSE.
EXIT.
ENDIF.
ENDDO.
LOOP AT it_main INTO wa_final.
DELETE it_final WHERE container_no = wa_final-container_no.
ENDLOOP.
So, it_main will contain only 6,12 or 18th row number from it_final. So, if i have to print 6 levels per page, then for counter number 20 there should be 4 pages. But using this condition, counter number 13 and 20 also going to it_main.i, e 5 pages are showing now. Can you solve the problem?
Note: First 2 pages shows right result but from page 3 it starts problem. According to my logic now it_main is containing data 6,12,18,13,20 !!!
2014 Mar 03 4:16 AM
The solution is done by doing 1st portion of code in initialization event.
Dear All,
Good day.
Developing an smartform which will print levels based on counter number. For this reason i am doing the below code.
i = 6.
DO.
READ TABLE it_final INTO wa_final INDEX i.
IF sy-subrc = 0.
APPEND wa_final TO it_main.
i = i + 6.
ELSE.
EXIT.
ENDIF.
ENDDO.
LOOP AT it_main INTO wa_final.
DELETE it_final WHERE container_no = wa_final-container_no.
ENDLOOP.
So, it_main will contain only 6,12 or 18th row number from it_final. So, if i have to print 6 levels per page, then for counter number 20 there should be 4 pages. But using this condition, counter number 13 and 20 also going to it_main.i, e 5 pages are showing now. Can you solve the problem?
Note: First 2 pages shows right result but from page 3 it starts problem. According to my logic now it_main is containing data 6,12,18,13,20 !!!
2014 Mar 02 11:12 AM
Hi Taniya,
The coding itself what you post should work fine, but I'm not sure, if you described your real problem.
Where do you call this coding, initialize or before the interface?
Perhaps you call the coding in the loop, so it_final itself is modified. If so, move the coding to initialize-event or better, before the interface is called.
DELETE it_final WHERE container_no = wa_final-container_no.
Another point clould be, that you didn't clear your it_main before and call the print twice
If this doesnt help, you have to share more informations about it.
Without having a look at your itab and the surrounded content, it will be hard, to give you more helpful answers. Also post a screenshot of the smartforms-tree and mark the relevant parts.
Hope this helps you out, if not, you know what to do
~Florian
2014 Mar 02 11:30 AM
Thanks Florian for your reply. The code not works if written in initialize event. The code is written under secondary window. I am not sure where to clear it_main, the rest of code are,
clear : wa_1, wa_2, wa_3, wa_4, wa_5.
LOOP AT it_final INTO wa_final.
IF sy-tabix = 1.
wa_1 = wa_final.
ELSEIF sy-tabix = 2.
wa_2 = wa_final.
ELSEIF sy-tabix = 3.
wa_3 = wa_final.
ELSEIF sy-tabix = 4.
wa_4 = wa_final.
ELSEIF sy-tabix = 5.
wa_5 = wa_final.
* ELSE.
* EXIT.
ENDIF.
ENDLOOP.
DELETE it_final FROM 1 TO 5.
2014 Mar 02 11:51 AM
For desire result 6,12,18,24
it_final contain value 6,7,8,9,10,11,12....
it_main contain value 6,12,18,24 ....
LOOP AT it_main INTO wa_final WHERE container_no NE wa_final-container_no.
DELETE it_final from wa_final.
ENDLOOP.
in it_final only 6,12,18,24 ...wiil be left.
2014 Mar 02 11:57 AM
2014 Mar 03 4:16 AM
The solution is done by doing 1st portion of code in initialization event.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |