cancel
Showing results for 
Search instead for 
Did you mean: 

Capture OK-CODE after Print and Print-Preview

sudarshan_b
Participant
0 Kudos

Hi Folks,

I have a custom program to print a Smartform in which I am storing some data into a Z table after the user clicks on PRINT (sy-ucomm = 'PRNT'). It works fine if the user clicks on PRINT directly from the pop-up, but the logic does not work if the user Prints the smartform while looking into the Preview, i.e. User first clicks on Print Preview and then while the preview is open, user select clicks the print button on the top of the Preview screen.

I am not abe to capture the OK-CODE if user clicks PRINT from the Print Preview screen.

Could you please tell me what is the OK-CODE (sy-ucomm) in this scenario?

Thank you.

Regards,

Sud

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Sudarshan,

If i understand you requirement correctly you are updating a Z table after printing of the form, now the SYTCODE carries back when the user click on the print button, but this is not working if the user chooses to look for a print preview and then chooses to click on the print button from the preview screen.

If yes, then i guess using the SY-TCODE as "SPRI" would also not work, as the control is still in some standard SAP code which handles the PAI of the Print preview screen and for the control to comeback to your Z program the user will have to exit the print preview screen and the sy-ucomm would have changed.

I suggest you try the below option and let me know how it works out, you will have to import the parameter "JOB_OUTPUT_INFO" from your smartform call. This parameter has a field called "OUTPUTDONE" - this is set to "X" as and when the print is issued, irrespective of "PRNT" or "SPRI".

DATA: lw_job_output_info TYPE ssfcrescl.

call "SMARTFORM"

exporting...

....

...

Importing...

....

job_output_info = w_job_output_info

...

exceptions...

....

.

If sy-subrc eq 0.

if w_job_output_info-OUTPUTDONE EQ 'X'.

update the Z table.

else.

do not update the z table

endif.

endif.

Regards,

Chen

Edited by: Chen K V on Apr 25, 2011 11:58 AM

sudarshan_b
Participant
0 Kudos

Thanks Chen,

I tried doing it the way you suggeted and now its working perfectly fine...

Thank you again.

Points awarded. Closing the thread.

Regards,

Sud.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Sudarshan,

Can you try with "SPRI" ok code.

Thanks & Regards,

Harish

sudarshan_b
Participant
0 Kudos

Hello Harish,

Thanks for your input, I tried checking with sy-ucomm = SPRI. But the problem is when I click PRINT from the Preview screen, a spool request is generated and the print is shooted to the printer. The control does not come back into my program until I deliberately press BACK button. And at this point of time, the sy-ucomm value is SBAC.

So what I understand is when I PRINT the form from Preview screen, a print will be generated but my logic will not be performed because the control i still in the preview screen.

Any idea how could I get the code executed when I print from preview screen?

Thank you.

Regards,

Sud