cancel
Showing results for 
Search instead for 
Did you mean: 

output from report

Former Member
0 Kudos

Hi,

I am really new in sapscript and I followed tutorials, manuals ecc in this morning I tried to write my first helloworld sapscript; really simple:

1) i made a form z_test with a text in main window where i wrote: Hi &user&

2) i wrote a z_report where i set variable user = sy-uname and then, open / write / close form ..

But when launching program, output is open, but I can see only "Hi" and no name following.

What am I missing ?

thanks

gabriele

Accepted Solutions (1)

Accepted Solutions (1)

amit_khare
Active Contributor
0 Kudos

Use UPPER CASE between &'s.

&USER&

You may check [this|http://www.erpgenie.com/sap-technical/sapscript-smartforms/sapscript-commands] also.

Former Member
0 Kudos

I put in uppercase, but name is still not showing.

Former Member
0 Kudos

Hi

How and where have u defined the variable USER?

It has to be a global data.

Max

Former Member
0 Kudos

global data in report or in form?

I cannot see where to declare global data in sapscript form

Former Member
0 Kudos

Hi

No It has to define in z_report, but as global data, so don't define it in a routine (perform).

 REPORT Z_REPORT.

DATA: USER TYPE SY-UNAME. " <-------- This is a global data

 REPORT Z_REPORT.

FORM MY_FORM.
  DATA: USER TYPE SY-UNAME. " <-------- This is a local data
ENDFORM.

Anyawy u can check your sapscript by trx SE71: Form->Check->Text

Max

Former Member
0 Kudos

could you paste ur code in driver program, also make sure the variable user in driver program must be a global variable..

Rgds,

Pavan

Former Member
0 Kudos

yes .. it's a global data .. just under 'REPORT' statement .. the more global I can

I think I am missing something basilar in form text writing I cannot see because I am a beginner and you cannot understand because you are skilled ..

Former Member
0 Kudos

update:

if I check text in form, it tells me that symbol SY-UNAME is not recognized (finally!!), so where do I have to declare it for form?

I think I am missing the element, ... how should I put it? just with backslash and E ?

.. I think also I am using an editor more advance then the one I see in tutorial .. for me it's like MS word instead a sort of old abap editor..

Edited by: Gabriele Montori on Sep 10, 2009 11:11 AM

Former Member
0 Kudos

Hi

U don't need to define SY-UNAME because it's a system symbol, so your form can automatically see it.

U see the editor based on MS, so it could be the variable to be printed are not correctly written in the window, u should move to old editor.

When u're in the editor: Goto->Cnange Editor

Now check how the variables are written: they have to have the format &variable&

If you use the new editor you don't write &variable&, but u should use the commands of toolbar in order to get the system o program variable .

Max

Former Member
0 Kudos

I think it's incredible .. I cannot understand the reason why it's not working .. I did exactly what you said and what I found on example on internet ... in 'new' editor, I used the toolbar to add symbol and in the old (on which I switched) I put & surrounding symbol name .. but nothing happens ... the only thing that seems does not work is this: in 'old-style' editor, there is a button for symbols .. I pressed it ad it asked me for a appending program or add global data ... I choose append and put the name of my report .. then clicking on global data I can see the ones I declared in report and it adds directly in text if I double click on them .. but still not showing ...

Former Member
0 Kudos

Hi

Can u post your ABAP code and your MAIN WINDOW?

Max

Former Member
0 Kudos

My drive program is here:

REPORT  z_sapscript.

CLEAR usr01.
SELECT SINGLE * FROM usr01 WHERE bname = sy-uname.

zoption-tddest    = usr01-spld.        "Output device (printer)
zoption-tdimmed   = 'X'.               "Print immediately
zoption-tddelete  = 'X'.               "Delete after printing
zoption-tdprogram = 'ZPQRPRNT'.        "Program Name
DATA TEST_NAME(20) TYPE c.
test_name = sy-uname.

CALL FUNCTION 'OPEN_FORM'
     EXPORTING
         application        = 'TX'
         device             = 'PRINTER'
         dialog             = ' '
         form               = 'Z_TEST_SAPSCRIPT'
         language           = sy-langu
         OPTIONS            = zoption
     IMPORTING
          language           = sy-langu
       EXCEPTIONS
         OTHERS     = 1.

IF sy-subrc <> 0.
  LEAVE PROGRAM.
ENDIF.


CALL FUNCTION 'WRITE_FORM'
     EXPORTING
         window        = 'MAIN'
     EXCEPTIONS
          element       = 1.

CALL FUNCTION 'CLOSE_FORM'
  EXCEPTIONS
    unopened = 1
    OTHERS   = 2.

Main windows has only &TEST_NAME&

Edited by: Gabriele Montori on Sep 10, 2009 11:42 AM

Former Member
0 Kudos

Hi

Something is strange in your code:

REPORT  z_sapscript.  "<--------- Z_SAPSCRIPT


zoption-tdprogram = 'ZPQRPRNT'. "<------???????

Can u try this updating?

REPORT  z_sapscript.

 DATA TEST_NAME(20) TYPE c.

CLEAR usr01.
SELECT SINGLE * FROM usr01 WHERE bname = sy-uname.
 
*zoption-tddest    = usr01-spld.        "Output device (printer)
*zoption-tdimmed   = 'X'.               "Print immediately
*zoption-tddelete  = 'X'.               "Delete after printing
*zoption-tdprogram = 'ZPQRPRNT'.        "Program Name


test_name = sy-uname.
 
CALL FUNCTION 'OPEN_FORM'
     EXPORTING
         application        = 'TX'
         device             = 'PRINTER'
         dialog             = ' X'
         form               = 'Z_TEST_SAPSCRIPT'
*         language           = sy-langu
*         OPTIONS            = zoption
     IMPORTING
          language           = sy-langu
       EXCEPTIONS
         OTHERS     = 1.
 
IF sy-subrc  0.
  LEAVE PROGRAM.
ENDIF.
 
 
CALL FUNCTION 'WRITE_FORM'
     EXPORTING
         window        = 'MAIN'
     EXCEPTIONS
          element       = 1.
 
CALL FUNCTION 'CLOSE_FORM'
  EXCEPTIONS
    unopened = 1
    OTHERS   = 2.

Max

Former Member
0 Kudos

yes .. I saw it just after posting it ...It works ... shame on me for my blame ... damning cut&paste ... Thank you very much for your help and your patience .. now the question is how to give you with more than ten points!

best regards

Gabriele

Former Member
0 Kudos

Hi

That doesn't possible, so don't worry

what U need to consider is zoption-tdprogram has to have the name of main program, so the program where the variable are defined.

This field isn't usually filled, because the main program is the driver program (i.e the program where the sapscript is called), it need to fill it only if the program where the variable are defined is not the driver program.

So i believe this (your) code:

REPORT  z_sapscript.
 
 DATA TEST_NAME(20) TYPE c.
 
CLEAR usr01.
SELECT SINGLE * FROM usr01 WHERE bname = sy-uname.
 
zoption-tddest    = usr01-spld.        "Output device (printer)
zoption-tdimmed   = 'X'.               "Print immediately
zoption-tddelete  = 'X'.               "Delete after printing
 
test_name = sy-uname.
 
CALL FUNCTION 'OPEN_FORM'
     EXPORTING
         application        = 'TX'
         device             = 'PRINTER'
         dialog             = 'space
         form               = 'Z_TEST_SAPSCRIPT'
         language           = sy-langu
         OPTIONS            = zoption
     IMPORTING
          language           = sy-langu
       EXCEPTIONS
         OTHERS     = 1.
 
IF sy-subrc  0.
  LEAVE PROGRAM.
ENDIF.
 
 
CALL FUNCTION 'WRITE_FORM'
     EXPORTING
         window        = 'MAIN'
     EXCEPTIONS
          element       = 1.
 
CALL FUNCTION 'CLOSE_FORM'
  EXCEPTIONS
    unopened = 1
    OTHERS   = 2.

.

It should work now

Max

Former Member
0 Kudos

thank you again very very much .. I am already finishing my firsts complete form with sapscript ...

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Try Hi &SY-UNAME& directly in script.

Or in the driver program use

data user type sy-uname.

user = sy-uname.

and then in script use in editor

  • Hi &USER&

See if the format is default paragraph '*' as above.

Case doesnot matter.

Former Member
0 Kudos

Hi

thanks for hint: it does not work, so my error is not in transferring data from report to form (as I was thinking), but I'm missing something else. For adding text the procedure I followed is this:

1) righr click on layout window

2) click on 'edit text' in context menu

3) write 'Hi' in editor

4) click on '+' (insert command) button to add data

5) select 'Symbols' radio button

6) entered '&SY-UNAME&'

Am I doing some mistake?

regards

gabriele

Former Member
0 Kudos

Hi,

In the text editor write the plain text and also the dynamically passed variables( using '&'), neednot use radiobuttons etc.

Make sure that u pass the variables from driver program.

Former Member
0 Kudos

If I don't use radiobutton, but only surrounding with &, I can see &SY-UNAME& as is written and not it's value

Former Member
0 Kudos

Hi

I did this and it works:

Report:

REPORT  ZPROVAMAX5.

DATA: USER LIKE SY-UNAME.

CALL FUNCTION 'OPEN_FORM'
  EXPORTING
    FORM                        = 'Z_TEST'
  EXCEPTIONS
    CANCELED                    = 1
    DEVICE                      = 2
    FORM                        = 3
    OPTIONS                     = 4
    UNCLOSED                    = 5
    MAIL_OPTIONS                = 6
    ARCHIVE_ERROR               = 7
    INVALID_FAX_NUMBER          = 8
    MORE_PARAMS_NEEDED_IN_BATCH = 9
    SPOOL_ERROR                 = 10
    CODEPAGE                    = 11
    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.
ELSE.
  USER = SY-UNAME.

  CALL FUNCTION 'WRITE_FORM'
    EXPORTING
      ELEMENT = 'INTRO'
      WINDOW  = 'MAIN'.

  CALL FUNCTION 'CLOSE_FORM'.

ENDIF.

Sapscript (MAIN window):

/E	 	INTRO
*	 	Hi &USER&

Max