cancel
Showing results for 
Search instead for 
Did you mean: 

Print dummy receipt from screen painter using application form + SAPscript

Former Member
0 Kudos

Good morning, experts.

I have a requirement to allow a user to enter in information for a dummy receipt, but I'm not quite sure how to do it. I asked if it was to be done using smartforms or SAPscript, and was given the name of the application form and associated SAPscript. Also I was told that the development of the application form is near completion, but not yet.

The screen is accessible via a customer function at the cash desk in FPCJ and has 4 input fields, and the print receipt button, which was assigned the function code, but I'm not sure what I'm supposed to use in the PAI. Some googling led me to the function modules OPEN_FORM and CLOSE_FORM, but I don't think I'm using them right, because when I execute the program, nothing happens. This is what I have:

Note: ZSCR_01is the name of the SAPscript; ZPWB_01 is the name of the application form.

CASE tmp_okcode.
  WHEN 'PRINT'.
    CALL FUNCTION 'OPEN_FORM'
     EXPORTING
       DEVICE                            = 'PRINTER'
       DIALOG                            = 'X'
       FORM                              = 'ZSCR_01'
       LANGUAGE                          = SY-LANGU
     EXCEPTIONS
       CANCELED                          = 1
       DEVICE                            = 2
       FORM                              = 3
       OTHERS                            = 12
              .
    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 'CLOSE_FORM'
*     IMPORTING
*       RESULT                         = ''
     EXCEPTIONS
       UNOPENED                       = 1
       OTHERS                         = 6
              .
    IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

NOTE: I've tried replacing PRINTER with SCREEN with same result..

I've read about START_FORM, WRITE_FORM and others but am not sure how to use them.

Any help will be greatly appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi!

So you have to display a popup window, where the user can enter some additional data, and then print this data on the ZSCR_01 sapscript?

If yes, you can do it somehow like this (I'll show only some milestones)

DATA: gv_text TYPE string.

CASE tmp_okcode.

WHEN 'PRINT'.

CALL SCREEN '9190'.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

DEVICE = 'PRINTER'

Now double click on the 9190 screen number to create it. Add a field to the gv_text variable, and a button with the "OK" ok-code.

On the PAI, handle the OK-CODE

IF sy-ucomm = 'OK'.

LEAVE TO SCREEN 0.

ENDIF.

And of course you have to put this gv_text field to the sapscript also.

Regards

Tamá

Former Member
0 Kudos

Thanks for your quick reply, Tamás.

The way it actually works is, from the cash desk, there is a customer function which will open the receipts screen, where he/she enters in dummy data. In the application toolbar, there is a Print receipt button, which takes me to the PAI for that screen, which is where I have the code.

So if I understand you correctly, the SAPscript will need the variables that will be passed from the program? What I mean is, in this case, gv_text will be the input from the user, and this will be sent to the SAPscript for printing? I've never used SAPscript before, so I apologize if I'm a little slow, I don't really understand the process for using them for receipt printing. 😛

Also, is the only parameter I need for this functionality the device?

Answers (1)

Answers (1)

Former Member
0 Kudos

you should know exactly when is this script triggred and what values are required for that.

In your transaction print the output and check the print preview option.If you are able to view this, then print the page.(Your script should be triggred at this place).

For minor things you can also go in layout option in SE71, for that script.

Former Member
0 Kudos

Thanks for your reply, Harsh.

I'm not sure I understand when you say to check the print preview. Is there a specific function module provided by SAP that gives the functionality to take inputs and create a print preview with those values? Or is that something that needs to be coded by me with a list report or something similar?

I do agree with you that the script should be triggered after a print preview (even if the requirements for the project don't mention this functionality), but the problem is that I'm not sure how to "trigger" it per se. The way I was doing it was as soon as the user hit Print receipt, the data would be sent to the script...as I mentioned above, I've never used SAPscripts, and different google results mention open_form, start_form, write_form etc, but very few examples, and none that I found that can be used as a guide.

Former Member
0 Kudos

hi

Check these links which will help you how to call scripts and print and will resolve ur problem.

http://www.sap-img.com/sapscripts.htm

http://www.sapbrain.com/TUTORIALS/TECHNICAL/SAPSCRIPTS_tutorial.html

http://www.sapmaterial.com/sap_scripts.html

http://www.abapprogramming.net/2007/10/sap-script-2.html

let us know if u still find issues after refering the above links.

surya