cancel
Showing results for 
Search instead for 
Did you mean: 

Smartform All pages in one print preview problem

Former Member
0 Kudos

Hi

I am displaying the employee data in ALV with checkbox selection.. i put two user defined buttons like print and print preview. when user clicks on print button, smartform will call for very employee in loop and print it employee wise. But my problem is when user clicks on print preview by selecting multiple checkboxes , I need all pages(employee wise like page1,2,3..) in one print preview. I done but for every employee,i have to press the BACK button. But I need all pages in one preview. I'm pasting my code here. Can anyone suggest??

WHEN 'PREVIEW'.
 w_cparam-no_dialog = 'X'.
  w_cparam-preview = 'X'.
   w_cparam-getotf = ' '.
   w_outoptions-tddest = 'LOCL'.
   w_outoptions-tdnoprev  = ' '.
    w_outoptions-tdimmed  = 'X'.


* to reflect the data changed into internal table
      IF ref_grid IS INITIAL.
        CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
          IMPORTING
            e_grid = ref_grid.
      ENDIF.

      IF NOT ref_grid IS INITIAL.
        CALL METHOD ref_grid->check_changed_data.
      ENDIF.

loop at i_data into wa_data where SEL = 'X'.
MOVE-CORRESPONDING WA_DATA TO WA_PRINT.
  APPEND WA_PRINT TO I_PRINT.

    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        FORMNAME                 = 'ZHRF1_PTAR1001'
*       VARIANT                  = ' '
*       DIRECT_CALL              = ' '
     IMPORTING
       FM_NAME                  = FM_NAME
*     EXCEPTIONS
*       NO_FORM                  = 1
*       NO_FUNCTION_MODULE       = 2
*       OTHERS                   = 3
              .
    IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

  CALL FUNCTION FM_NAME
    EXPORTING
*     ARCHIVE_INDEX              =
*     ARCHIVE_INDEX_TAB          =
*     ARCHIVE_PARAMETERS         =
     CONTROL_PARAMETERS         = W_CPARAM
*     MAIL_APPL_OBJ              =
*     MAIL_RECIPIENT             =
*     MAIL_SENDER                =
     OUTPUT_OPTIONS             = W_OUTOPTIONS
     USER_SETTINGS              = 'X'
      FR_DATE                    = PN-BEGDA
      TO_DATE                    = PN-ENDDA


   IMPORTING

*     DOCUMENT_OUTPUT_INFO       =
    JOB_OUTPUT_INFO            = T_OTF_FROM_FM

*     JOB_OUTPUT_OPTIONS         =
    TABLES
      ITAB                       = I_PRINT
*   EXCEPTIONS
*     FORMATTING_ERROR           = 1
*     INTERNAL_ERROR             = 2
*     SEND_ERROR                 = 3
*     USER_CANCELED              = 4
*     OTHERS                     = 5
            .
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


CLEAR: WA_DATA,WA_PRINT.
CLEAR: I_PRINT.
  ENDLOOP.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Call the Smartform after the loop endloop.

Jshree

Former Member
0 Kudos

Hi Jshree,

If i call smartform after loop endloop. it is showing the print preview for last selected checkbox in ALV. But i have to call the smartform for every employee and if user selects multiple employees in ALV, Every employee data has to be display in one print preview page wise.Can You suggest??

Former Member
0 Kudos

Hi friend,

As per your requirement. You are creating the smart form for each and every employee.

So in your case just check a simple scenario like whether multiple check boxes are checked.

If so create the output table with all those employee details and pass that internal table to the smart form so that you will be creating a simple smart form.

So use the main window for displaying the information because it grows automatically as the record grows just like how we create for header and item details.

I hope i made you clear about the concept if any issues please revert back to me i will help you.

Thanks,

Sri Hari.

Edited by: srihari.kumar on Jan 5, 2012 12:39 PM

Former Member
0 Kudos

Hi,

Check whether the itab I_PRINT is having all your customers in it.

If everthing is working fine,then check the smartform.

You should trigger it for the number of customer it has.

Loop your records, so that it prints all the customers that are in the itab I_PRINT.

i.e if you have selected 3 checkboxes,your itab should contain 3 records.

Jshree

Former Member
0 Kudos

Hi Srihari and Jshree

Thanks for your replies. I done whatever you said. In main window loop is repeating and records are coming.

But outside main window i created two more secondary windows. These windows have Employee name,employee number,section ,department.For this two windows also loop has to repeat. I applied Loop to these two windows. But for every page same information coming. Can You suggest??

Former Member
0 Kudos

Hi friend,

Just create two more pages and place those two windows in two pages and execute and see.

That is after completing the first page give the next page by setting it in option also do the same for next page.

So what happens is after the main window finishes in first page next page gets called and displays the content and then the third page.

I think this will solve your issue if not please revert back to me i will help you.

Thanks,

Sri Hari

Former Member
0 Kudos

Hi,

Hope then you have used a seperate loop for the rest two windows.

Instead create a program lines inside the window and read the itab using index and display the customer details accordingly.

i.e when the first records populates,assign the index as 1 and read the first customer record details,

when the secnd record populates,increment the index variable and print the other customer address details

Jshree

Former Member
0 Kudos

Hi Srihari,

I done what you said. i included two more pages and looping was done and displayed the values. but it causes strucking of the program. Can you elaborate more clear??

Former Member
0 Kudos

HI friend

Do like this,

Create a main window secondary window and third window.

Inside Main window put a loop inside loop put one program lines inside program lines get the index and the number of lines in the table.

After printing the details which needs to printed in main table for one employee just put one alternatives. Alternative condition is is the index less that lines in internal table count.

If yes then put a break so the next windows data will be printed.

For populating the other windows use read statement with the global index variable and assign values to that windows.

This is the logic what i have used for displying data when i used checque printing just see this.

I think this will solve else please revert back to me what issues you face.

Thanks,

Sri Hari

Edited by: srihari.kumar on Jan 5, 2012 3:40 PM

Former Member
0 Kudos

Hi Srihari,

Thank you Very Much for Your replies.I'll do,if any issues occur i'll get back to you. Thanks.

Former Member
0 Kudos

Hi SriHari,

I am applying the read statement for the windows employee name,employee number,section,department. when i select multiple checkboxes in ALV, first checkbox i.e. first page these window entries are missing.from next page onwards everything getting fine. Can you help me?

I'm using this one.

DATA: IND TYPE I VALUE 1.

READ TABLE ITAB INDEX IND.

IND = IND + 1.

Former Member
0 Kudos

HI friend,

Check are you getting the value in the internal table if so it should work fine.

In table index starts with 1. So it must read.

Just add break point before the read table statement and see whether the table is having the first value or not.

Else try index 0 but i think it will show an error. Just check and see.

First check whether the values of getting filled before the read statement.

If you face issues please revert back to me.

Thanks,

Sri Hari

Edited by: srihari.kumar on Jan 6, 2012 10:31 AM

Former Member
0 Kudos

Hi Srihari,

I checked through debugging the first table value is reading. but i was surprised it is always taking the index value 1.because i given in data statement 1 to the index in program lines. so whenever repeating this one,it is always taking one. then How it was showing the remaining page values displaying fine??My read statement is correct??How to solve this?? can u provide with sample read statement?? please help me..

Former Member
0 Kudos

Hi friend sure.

You need to increment the index only at the loop no where else and the variable for holding the index value is global.

If you create before the read every time it gets trigerred.

After each loop you assign the sy-tabix value to that variable.

Just like this ,

v_index = sy-tabix.

Then at the window just read the table as shown

READ TABLE t_chq INTO x_chq INDEX v_index.

This will do friend.

I will update the flow of my code here, then you many understand it much clear.

Page1

Main window (below page1)

Loop (inside Main win)

program lines. code : v_index = sy-tabix. v_lines = lines( t_chq ). (inside loop)

Condition (inside loop)

True

check the v_index < v_lines if true break page, for page break create a command and do it (Inside true condition)

false

blank.

Secondary window (below page1)

program line (inside sec wind)

Inside program lines the code is READ TABLE t_chq INTO x_chq INDEX v_index. (inside sec wind)

Secondary window2 (below page1)

program line (inside sec wind2)

Inside program lines some other code. (inside sec wind2)

This is my logic try like this friend.

I think for other records its coming fine because since it is an local variable its getting updated some where and also showing 1 bec its always initializing.

Try this you will get if any issues please revert back to me

Thanks,

Sri Hari

Edited by: srihari.kumar on Jan 6, 2012 11:04 AM

Edited by: srihari.kumar on Jan 6, 2012 11:05 AM

Former Member
0 Kudos

Hi Srihari,

thank You very much for your replies. I done whatever u said Initial. Everything getting fine. Just one issue...when i select multiple checkboxes in ALV, the first checkbox selection print preview is coming last. remaining everything coming fine.

Why this is happeneing?? I need sequentially print preview whatever user select checkbox. Can u suggest please.

I done

Main window--


>table--


>loop

After loop--


> program lines--


> v_index = sy-tabix.

secondary window--


>program lines-->

read table itab into wa index v_index.

Former Member
0 Kudos

Hi friend,

Just keep break points in the program lines and check whether the index is getting increment correctly.

I faced an issues that extra line is getting added at the end that is because of the selection condition at alternatives and commands.

I gave v_index LE v_lines so i got an extra page at end. But i did not get the first page at last. I think it must be the problem of index or the condition.

Just check that give the condition LT table lines instead of LE table lines then i think it will work fine just keep break point step by step and check whether it is good because i have did the same in my program it worked fine so only saying.

If possible take printout and see whether the order is coming correctly.

If you still face issues please revert back to me i will help you.

Thanks,

Sri Hari.

Former Member
0 Kudos

Hi Srihari,

I didn't put any condition. i just follow whatever first approach whatever you said. i done debugging. In debuuging the cursor first going to secondary window and after that it is going to main window when i select multiple checkboxes. if i select one check box ,it is going main window and after that secondary window. and also first time when v_index = 0 (sy-tabix = 0).it is taking the second index record. If you don't mind can you give ur mail?i'll send my smartform..you can upload and check..please

Former Member
0 Kudos

Hi friend,

Sorry if moderators sees that then they will block our ids.

What you can do is just hard code the index value and see whether are you are you getting the correct record displayed for the correct page.

Hard code inside the program lines and see.

If its taking second record values for index 1 then surely there must be any increment or

do like this create a global variable of type the primary key of your table.

After the loop pas the primary key into that variable.

Read the values in other windows using that variable. I think this must work please do it and let me know.

This must work and if not then some where some how the value is getting affected.

Thanks,

Sri Hari

Former Member
0 Kudos

Hi Srihari,

Thank you very much for your support and replies. My problem has been solved.

Answers (1)

Answers (1)

nabheetscn
Active Contributor
0 Kudos

Please find below the one of the thing which you can do.

Print option

The smartform will have I_PRINT parametrs as table. In case it is to be printed i will call it between loop endloop as you are doing.

Print Preview. In this case i_PRINT will have n lines as selected and will not be called in loop endloop.

change in smartform needed.

In the main window where this table you have given you need to put a command for page break for every record of emloyee.

Overall what will happen is in print for i_print will have one line item so only one page per print but in preview multiple line items each on separte page as page break is there

Nabheet

Former Member
0 Kudos

Hi Nabheetmadan,

can you tell me what condition i have to put in the command for every employee. and also i have to loop outside main window also.it contains employee no,name,section,department. can u suggest??