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

Level printing problem in smartform.

Former Member
0 Likes
1,021

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 !!!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
988

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 !!!

5 REPLIES 5
Read only

Florian
SAP Champion
SAP Champion
0 Likes
988

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

Read only

Former Member
0 Likes
988

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.

Read only

Former Member
0 Likes
988

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.

Read only

0 Likes
988

What you are trying to do with the secondary window? Can you share the SF-Tree and a printout, that I can see, what you want finally the Smartforms to do.

I'm not sure, if this is possible, what you are trying and I'm not sure, if I understand your problem at all

Regards

Florian

Read only

Former Member
0 Likes
989

The solution is done by doing 1st portion of code in initialization event.