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

Program to Print sapscript

Former Member
0 Likes
1,960

Hi All The past two days I have been learning how create SAPSCRIPTS preparing for an upcoming project.

I created a form with only three elements a graph(logo), our address and a main window.

When I do a test print the form comes out fine but on SE38 when I execute the below code I get the message that the elements are not defined in the program.

REPORT Z_DEMO_TESTSCRIPT.

*----------------------------------------------------------------------*

CALL FUNCTION 'OPEN_FORM'   

     EXPORTING     

          device                            = 'PRINTER'     

          form                               = 'Z_DEMO_TEMPLATE'. *    

CALL FUNCTION 'WRITE_FORM'     

     EXPORTING       

          element                        = 'GRAPH1'       

          function                        = 'SET'        

          type                              = 'BODY'        

          window                         = 'MAIN' . *    

CALL FUNCTION 'WRITE_FORM'     

     EXPORTING       

          element                        = 'OUR_ADDR'       

          function                        = 'SET'        

          type                              = 'BODY'        

          window                        = 'MAIN' .   

CALL FUNCTION 'WRITE_FORM'     

     EXPORTING       

          element                        = 'LOGO'       

          function                        = 'SET'        

          type                              = 'BODY'        

          window                         = 'MAIN' .   

CALL FUNCTION 'CLOSE_FORM'.

What could I be missing?

9 REPLIES 9
Read only

Former Member
0 Likes
1,926

Hi khani,

In the form window you need to specify the element names graph1,logo,OUR_ADDR in the main window of the form.

/E GRAPH1

/E LOGO

/E OUR_ADDR.

Read only

0 Likes
1,926

Hi Chaitanya

I have them defined: You meant in this way right?

Read only

0 Likes
1,926

add the screenshots of the text inside the windows...

Read only

0 Likes
1,926

Hi Stefan

See attached text for the 3 window elements:

Read only

0 Likes
1,926

Hi Khani Ramatlo,

as i thought and as

CALL FUNCTION 'WRITE_FORM'     

     EXPORTING       

          element                        = 'LOGO'       

          function                        = 'SET'        

          type                              = 'BODY'        

          window                         = 'MAIN' .   

in this example you need the window "MAIN"

and the command line /E LOGO insode the window main.

only if you do so, all the text after this command line gets printed.

or better to say: all text between this element-command-line and the next element-command-line

Regards

Stefan Seeburger

Read only

0 Likes
1,926

It makes sense now that the text elements carry what I need to output.

Read only

Former Member
0 Likes
1,926

Hi Khani,

No need to create 3 window.

Just keep MAIN window and in Main Page Window define 3 elements

/E GRAPH1

/E LOGO

/E OUR_ADDR.


and then from your print program call as follows:


CALL FUNCTION 'OPEN_FORM'  

     EXPORTING    

          device                            = 'PRINTER'    

          form                               = 'Z_DEMO_TEMPLATE'. *   

CALL FUNCTION 'WRITE_FORM'    

     EXPORTING      

          element                        = 'GRAPH1'      

          function                        = 'SET'       

          type                              = 'BODY'       

          window                         = 'MAIN' . *   

CALL FUNCTION 'WRITE_FORM'    

     EXPORTING      

          element                        = 'OUR_ADDR'      

          function                        = 'SET'       

          type                              = 'BODY'       

          window                        = 'MAIN' .  

CALL FUNCTION 'WRITE_FORM'    

     EXPORTING      

          element                        = 'LOGO'      

          function                        = 'SET'       

          type                              = 'BODY'       

          window                         = 'MAIN' .  

CALL FUNCTION 'CLOSE_FORM'.

Read only

0 Likes
1,926

Aaaah thank you guys it now makes sense, I had misunderstood how the text elements work in this context. Thank you so much all the answers were helpful.

Read only

0 Likes
1,926

In this case I need to call the three windows in one page so instead of deleting them I will call different windows with each function module call. Thank you so much for brining this to my attention.