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

Regarding subroutine (Form-EndForm)

Former Member
0 Likes
992

How do I trigger a Subroutine ( It creates a new ticket/insurance claim number/Invoice number) only when print command is given and not when print preview is given so that un-necessarily new ticket/claim/invoice NUMBERS are not generated?

How do I trigger a Subroutine ( It creates a new ticket/insurance claim number/Invoice number) only when print command is given and not when print preview is given so that un-necessarily new ticket/claim/invoice NUMBERS are not generated?

6 REPLIES 6
Read only

former_member212854
Participant
0 Likes
946

 Hi,

So it is a script or the smartform ?

In the sap script you can call the perform as shown below

You could make a condition to call the below subroutine in sap script window editor.

Example: if sy-ucomm = 'PRINT '.

perform TABLES fp_it_intab STRUCTURE itcsy      

                                        fp_it_outtab STRUCTURE itcsy.

.....

.....

Endform.

 Please let me know if you want the fuction code for print command.

Edited by: Ashwin Kumar Chitram on Oct 1, 2011 7:21 AM

Read only

Former Member
0 Likes
946

Hi,

Are your commands PRINT and PRINT PREVIEW, buttons / check boxes / radio buttons ?



* For Radio Buttons and Check Boxes.
  IF p_prntpr = 'X'.
    PERFORM print_preview.
  ELSEIF p_print = 'X'.
    PERFORM print.
  ENDIF.

* For Buttons.
  CASE sy-ucomm.
    WHEN 'PRINT_PR'.
      PERFORM print_preview.
    WHEN 'PRINT'.
      PERFORM print.
  ENDCASE.

Regards,

Danish.

Read only

0 Likes
946

Actually what I'm doing is there is a screen where you need to enter few values and press F8 for processing then the pop-up where we need to give the printer name etc comes up, in this pop-up in bottom right corner we have few buttons "PRINT", "PRINT-PREVIEW" etc. So If I press the "PRINT PREVIEW" button my sub-routine should NOT get executed. If I press the "PRINT" button my subroutine should get executed. Is there a solution for this situation?

Read only

0 Likes
946

A method you can adopt is to put a code line inside the smartform in such a way that :

Check for JOB_OUTPUT_OPTIONS-TDPREVIEW ;

if TDPREVIEW is 'X'. "X if Print preview is selected

"do ur coding here.

else .

"execute alternate code..."

I hope this will meet ur requirement...

Read only

0 Likes
946

My form is a Adobe form output. How will the solution change now. The adobe form has been designed in SFP and is being called from Module pool program. The input is given in the screen and F8 is used to process and then the PRINT pop-up comes up for the printer name etc. here if PRINT PREVIEW is selected my subroutine should not get process and if PRINT is selected my sub-routine shouls get processed.

Read only

0 Likes
946

I have found out the way to capture the sy-ucomm value given back from default print dialogue pop-up. After the functional module 'FP JOB OPEN' is called the default print dialogue box will appear, you might select "print" or "print preview", after either of this is selected and before the adobe form is called" check for sy-ucomm value, and trigger your sub-routine accordingly.