cancel
Showing results for 
Search instead for 
Did you mean: 

different header for different copies in scriptform

former_member841898
Participant
0 Kudos

hi experts

I am creating a customize sapscript, now the header for different copies will be different,

for. eg header of first copy will come as ORIGINAL ,,,,for second copy as DUPLICATE

third copy as TRIPLICATE and if more than 3 copies it will come as EXTRA..

in smartforms we have concept of copies window and smart form variable SFSY-COPYCOUNT

where it can be easily done.

but how to do in sapscript form?

regards

pankaj

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Change your printprogram.

Within a loop start your sapscript the number of times it has to be printed.

With a counter-parameter (global variable) you can set the TEXT to be printed in the script.

this will work,

Gr., Frank

former_member841898
Participant
0 Kudos

HI Bernsen ,

it is upto enduser how many copies they want to print.

for FIRST COPY(HEADER) - ORIGINAL.

for SECOND COPY(HEADER) - DUPLICATE.

for THIRD COPY(HEADER) - TRIPLICATE.

for FOURTH COPY(HEADER) - DUMMY.

MORE THAN 4 IF ANY(HEADER) - EXTRA.

pls provide ur logic thru a code.

Edited by: pankaj gupta on Apr 9, 2009 5:45 PM

Edited by: pankaj gupta on Apr 9, 2009 5:45 PM

Former Member
0 Kudos

Hi

I think that text is put in the header.

So the loop (with a DO statement) must start before the header get printed.

but to be sure you can do the whole program.

so you have to declare

data gi_printnumber type i. " a global variable)

suppose: lv_number type i is the qty to beprinted

clear gi_printnumber .

do lv_number times

gi_printnumber = gi_printnumber + 1.

.......

Here all you need for 1 print......

.......

.....

....

enddo.

In your SAP-script make the text you print depenable on gi_printnumber

/: case gi_printnumber.

/: when 1.

  • ORIGINAL

/: WHEN 2

  • DUPLICATE

/: WHEN 3

  • TRIPLICATE.

/: WHEN 4

  • DUMMY

/: OTHERS

  • EXTRA

/: ENDCASE

hope this helps enough.

Gr., Frank

former_member841898
Participant
0 Kudos

hi bernsen ,

pls see this which i have applied.

data gi_printnumber type i. " a global variable)

data: lv_number type i.

END-OF-SELECTION.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

device = 'PRINTER'

dialog = 'X'

form = 'YPAN1'

language = sy-langu

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.

clear gi_printnumber .

do lv_number times.

gi_printnumber = gi_printnumber + 1.

enddo.

************printing-header**********************

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'HEADER'

function = 'SET'

type = 'BODY'

window = 'HEADER'

  • * IMPORTING

  • * PENDING_LINES =

EXCEPTIONS

element = 1

function = 2

type = 3

unopened = 4

unstarted = 5

window = 6

bad_pageformat_for_print = 7

spool_error = 8

codepage = 9

OTHERS = 10

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

*************************printing main (ok-coming)***************

printing-footer (ok-coming)

CALL FUNCTION 'CLOSE_FORM'

EXCEPTIONS

unopened = 1

bad_pageformat_for_print = 2

send_error = 3

spool_error = 4

codepage = 5

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.

Edited by: pankaj gupta on Apr 9, 2009 6:33 PM

Former Member
0 Kudos

Hi,

I don't see/know the variable in which you see how much times the form has to be printed.

the variable ''data: lv_number type i'' was only an example. You must that variable instead of my lv_number example.

Gr., Frank.

former_member841898
Participant
0 Kudos

Hi Bernsen,

i also don't no the number of copies user will take printout.

it is not fixed, how to do.

regards

pankaj

former_member841898
Participant
0 Kudos

unsolved

regards

pankaj

Former Member
0 Kudos

Do you solve this problem? I have the same problem and I don't now what to do. Please help me....

former_member841898
Participant
0 Kudos

hi

no this problem is not solved by me till now , it is open in sdn still

pankaj

Former Member
0 Kudos

Hi Pankaj,

Can you paste the current code(full), along with the requiements and problem.

as per your above reply

DO num_copies TIMES.

ADD 1 TO z_copy.

CASE z_copy.

WHEN '1'.

z_copy_name = 'Original'.

WHEN '2'.

z_copy_name = 'Duplicate'.

WHEN '3'.

z_copy_name = 'Triplicate'.

ENDCASE.

the code will simply return the final value for z_copy_name according to num_copies value.

Also please write something in main window, else other windows are not triggered.

Regards

Vijai

Edited by: Vijai Dixit on Jun 23, 2009 1:23 PM

Edited by: Vijai Dixit on Jun 23, 2009 1:37 PM

Former Member
0 Kudos

Hi

Use the code below. it worked for me.

DATA: itcpo1 TYPE itcpp.

DATA: num_copies TYPE i.

DATA: n TYPE i.

DATA: z_copy TYPE i,

z_copy_name(30) TYPE c.

CLEAR n.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

device = 'PRINTER'

dialog = 'X'

IMPORTING

RESULT = itcpo1

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 NE 0.

MESSAGE e398(00) WITH 'error opening form'.

ENDIF.

num_copies = itcpo1-tdcopies + 1.

DO num_copies TIMES.

n = n + 1.

CALL FUNCTION 'START_FORM'

EXPORTING

form = 'ZTEST'

EXCEPTIONS

form = 1

format = 2

unended = 3

unopened = 4

unused = 5

spool_error = 6

codepage = 7

OTHERS = 8

.

IF sy-subrc <> 0.

  • message

ENDIF.

CASE n.

WHEN 1.

z_copy_name = 'Original'.

WHEN 2.

z_copy_name = 'Duplicate'.

WHEN 3.

z_copy_name = 'Triplicate'.

WHEN OTHERS.

z_copy_name = 'Extra'.

ENDCASE.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

window = 'HEADER'

EXCEPTIONS

element = 1

function = 2

type = 3

unopened = 4

unstarted = 5

window = 6

bad_pageformat_for_print = 7

spool_error = 8

codepage = 9

OTHERS = 10

.

IF sy-subrc NE 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

  • ELEMENT = ' '

function = 'SET'

type = 'BODY'

window = 'MAIN'

EXCEPTIONS

element = 1

function = 2

type = 3

unopened = 4

unstarted = 5

window = 6

bad_pageformat_for_print = 7

spool_error = 8

codepage = 9

OTHERS = 10

.

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 'END_FORM'

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDDO.

CALL FUNCTION 'CLOSE_FORM'

EXCEPTIONS

unopened = 1

bad_pageformat_for_print = 2

send_error = 3

spool_error = 4

codepage = 5

OTHERS = 6.

IF sy-subrc NE 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Regards

Vijai

Former Member
0 Kudos

I use your code, but I have one problem: in selection screen I set 4 pages to print, but the printer make 4x4=16 pages. Why? What do I wrong?

My code is:

......

CALL FUNCTION 'OPEN_FORM'

EXPORTING

form = 'ZFACT_PREST_CA'

language = nast-spras

options = itcpo

device = xdevice

dialog = dialog

  • dialog = ' '

IMPORTING

result = itcpo1

EXCEPTIONS

OTHERS = 1.

.....

nr_copii = itcpo1-tdcopies.

nr_copy = 0.

itcpo-tdcopies = 1.

itcpo1-tdcopies = 1.

DO nr_copii TIMES.

ADD 1 TO nr_copy.

CASE nr_copy.

WHEN 1.

vtext_copie = ' COPY1'.

WHEN 2.

vtext_copie = ' COPY2'.

WHEN OTHERS.

vtext_copie = 'COPY3'.

ENDCASE.

.....

CALL FUNCTION 'START_FORM'

EXPORTING

form = 'ZFACT_PREST_CA'

language = sy-langu.

.....

CALL FUNCTION 'END_FORM'.

ENDDO.

CALL FUNCTION 'CLOSE_FORM'.

....

Please help me....

former_member841898
Participant
0 Kudos

hi padi ,

that is wrong one pls don't use that code.

i m still working on it.

regards

pankaj

Former Member
0 Kudos

Do you have the same problem: print multiple pages?

I think the problem is: how do I set tdcopies to 1 after I get this value in my variable (nr_copii = itcpo1-tdcopies). Once I call the function OPEN_FORM, I think that this is not possible. That why, when I set in selection screen 4 pages, the program list 4x4=16 pages.

I hope that Vijai Dixit help us. He said that in his case it is work.

former_member841898
Participant
0 Kudos

hi padi,

i m currently working on vijay dixit's code.

pankaj

former_member841898
Participant
0 Kudos

hi vijai ,

thanks for ur reply and code.

i have used ur logic.........

see when i m giving no. of copies = 1 , sapscipt pages are becoming 2,

when 2 it becomes 3 , similarly 3 to 4 , 4 to 5 and so on.........remember pages not copies

for e.g.

when i m giving 5 copies to print , we should have 5 pages. with headings as follows

original (for page 1)

duplicate (for page 2)

triplicate (for page 3)

extra (for page 4)

extra (for page 5)

but instead of that i m getting 5 copies with 6 page each i.e total 30 pages.

headings are coming perfect (cheers to u),

for 1st copy 6 pages,

original (for page 1)

duplicate (for page 2)

triplicate (for page 3)

extra (for page 4)

extra (for page 5)

extra (for page 6)

similary for 2nd, 3rd , 4th, 5th copy.. 6 pages are coming for each copy. so a total of 30 pages.

if this is solved ur code is perfect.

thanks

pankaj

Former Member
0 Kudos

The problem with the number of pages (6 pages instead 5 pages - in your example) appear because in code is: num_copies = itcpo1-tdcopies + 1. If you put: num_copies = itcpo1-tdcopies. (I think this is correct) this problem is solved.

former_member841898
Participant
0 Kudos

hi padi,

no it will not work, just try.

regards

pankaj

Former Member
0 Kudos

Hi Pankaj

Do not provide number of copies in your selection screen.

I have incorporated that requirement in Dialog box that appear . If you wish to have full code then provide me with full program code.

For that extra page that is appearing you can comment the statement where I have incremented the number of copies.

Regards

Vijai

Edited by: Vijai Dixit on Jun 24, 2009 11:30 AM

former_member841898
Participant
0 Kudos

hi .

see the full program .

REPORT z_test_sapscript1.

TABLES: itcpp.

DATA: itcpp1 TYPE itcpp.

DATA: num_copies TYPE i.

DATA: n TYPE i.

DATA: z_copy_name(30) TYPE c.

CLEAR n.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

device = 'PRINTER'

dialog = 'X'

  • form = 'ZXXX'

  • language = sy-langu

  • OPTIONS =

IMPORTING

  • LANGUAGE =

  • NEW_ARCHIVE_PARAMS =

RESULT = itcpp1

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 e398(00) WITH 'error opening form'.

ENDIF.

num_copies = itcpp1-tdcopies + 1.

DO num_copies TIMES.

n = n + 1.

CALL FUNCTION 'START_FORM'

EXPORTING

  • ARCHIVE_INDEX =

form = 'ZXXX'

  • LANGUAGE = ' '

  • STARTPAGE = ' '

  • PROGRAM = ' '

  • MAIL_APPL_OBJECT =

  • IMPORTING

  • LANGUAGE =

EXCEPTIONS

form = 1

format = 2

unended = 3

unopened = 4

unused = 5

spool_error = 6

codepage = 7

OTHERS = 8

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CASE n.

WHEN '1'.

z_copy_name = 'Original'.

WHEN '2'.

z_copy_name = 'Duplicate'.

WHEN '3'.

z_copy_name = 'Triplicate'.

WHEN OTHERS.

z_copy_name = 'Extra'.

ENDCASE.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'HEAD'

function = 'SET'

type = 'BODY'

window = 'HEADER'

  • IMPORTING

  • PENDING_LINES =

EXCEPTIONS

element = 1

function = 2

type = 3

unopened = 4

unstarted = 5

window = 6

bad_pageformat_for_print = 7

spool_error = 8

codepage = 9

OTHERS = 10

.

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 'WRITE_FORM'

EXPORTING

element = 'MAIN'

function = 'SET'

type = 'BODY'

window = 'MAIN'

  • IMPORTING

  • PENDING_LINES =

EXCEPTIONS

element = 1

function = 2

type = 3

unopened = 4

unstarted = 5

window = 6

bad_pageformat_for_print = 7

spool_error = 8

codepage = 9

OTHERS = 10

.

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 'END_FORM'

  • IMPORTING

  • RESULT =

  • EXCEPTIONS

  • UNOPENED = 1

  • BAD_PAGEFORMAT_FOR_PRINT = 2

  • SPOOL_ERROR = 3

  • CODEPAGE = 4

  • OTHERS = 5

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDDO.

CALL FUNCTION 'CLOSE_FORM'

EXCEPTIONS

unopened = 1

bad_pageformat_for_print = 2

send_error = 3

spool_error = 4

codepage = 5

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: the main window of script just contains a message 'hi'.

Former Member
0 Kudos

Hi

I got your problem. will get back to you.

Another querry- are you using any selection screen in above requirement or calling the form from some standard transaction.

Regards

Vijai

Former Member
0 Kudos

Hi Pankaj

Now its coming perfect.

REPORT z_test_sapscript1.

DATA: ITCPO1 TYPE ITCPO.

DATA: itcpp1 TYPE itcpp.

DATA: num_copies TYPE i.

DATA: n TYPE i.

DATA: z_copy_name(30) TYPE c.

CLEAR n.

CALL FUNCTION 'OPEN_FORM'

EXPORTING device = 'PRINTER'

dialog = 'X'

  • form = 'ZXXX' *

language = sy-langu

  • OPTIONS =

IMPORTING

  • LANGUAGE =

  • NEW_ARCHIVE_PARAMS =

RESULT = itcpp1

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 NE 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

num_copies = itcpp1-tdcopies.

MOVE-CORRESPONDING itcpp1 to itcpo1.

itcpo1-tdcopies = 1.

CALL FUNCTION 'CLOSE_FORM'

EXCEPTIONS

unopened = 1

bad_pageformat_for_print = 2

send_error = 3

spool_error = 4

codepage = 5

OTHERS = 6.

CALL FUNCTION 'OPEN_FORM'

EXPORTING device = 'PRINTER'

dialog = space

  • form = 'ZXXX' *

  • language = sy-langu

OPTIONS = itcpo1

*IMPORTING

  • LANGUAGE =

  • NEW_ARCHIVE_PARAMS =

*RESULT = itcpp1

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 NE 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

DO num_copies TIMES.

n = n + 1.

CALL FUNCTION 'START_FORM'

EXPORTING

  • ARCHIVE_INDEX =

form = 'ZTEST'

EXCEPTIONS

form = 1

format = 2

unended = 3

unopened = 4

unused = 5

spool_error = 6

codepage = 7

OTHERS = 8 .

IF sy-subrc NE 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CASE n.

WHEN '1'.

z_copy_name = 'Original'.

WHEN '2'.

z_copy_name = 'Duplicate'.

WHEN '3'.

z_copy_name = 'Triplicate'.

WHEN OTHERS.

z_copy_name = 'Extra'.

ENDCASE.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'HEAD'

function = 'SET'

type = 'BODY'

window = 'HEADER'

EXCEPTIONS

element = 1

function = 2

type = 3

unopened = 4

unstarted = 5

window = 6

bad_pageformat_for_print = 7

spool_error = 8

codepage = 9

OTHERS = 10.

IF sy-subrc NE 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'MAIN'

function = 'SET'

type = 'BODY'

window = 'MAIN'

EXCEPTIONS

element = 1

function = 2

type = 3

unopened = 4

unstarted = 5

window = 6

bad_pageformat_for_print = 7

spool_error = 8

codepage = 9

OTHERS = 10.

IF sy-subrc NE 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'END_FORM'

.

IF sy-subrc NE 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDDO.

CALL FUNCTION 'CLOSE_FORM'

EXCEPTIONS

unopened = 1

bad_pageformat_for_print = 2

send_error = 3

spool_error = 4

codepage = 5

OTHERS = 6.

Actually we were creating aur own copies along with the system generated copies.

Find the code above.

Regards

Vijai

former_member841898
Participant
0 Kudos

hi vijai

no it is not a standard form , nor calling from any standard transaction.

it is self developed one . no selection screen . the main window only prints a text 'hello'.

regards

pankaj

former_member841898
Participant
0 Kudos

hi vijai ,

yes finally ur code works for me

cheers to u and awarded.

thanks & regards

pankaj

Edited by: pankaj gupta on Jun 24, 2009 4:24 PM

former_member841898
Participant
0 Kudos

hi padi

pls see vijai dixit"s last post

it really works for me.

regards

pankaj

Former Member
0 Kudos

hi pankaj,

I am very happy. It works also for me.

Vijai thank you very much. You are a genius. Your idea was brilliant.

Former Member
0 Kudos

Just want to give Vijai some props (I'd give points if I could). The extra open_form:close_form to populate the OPTIONS for the real OPEN_FORM (itcpo1) is a great idea that I'm sure to be stealing in the near future.

Former Member
0 Kudos

Hi

Work arounds always come as great help.

Regards

Vijai

Answers (3)

Answers (3)

former_member196280
Active Contributor
0 Kudos

I guess this can be done, by small alteration in your driver program.

Make sure your selection screen is having the number of copies to be printed.

DO <No. of copies entered in your selection screen > Times.

lv_Page = lv_page + 1.

CALL FM (OPEN_FORM)

CALL FM(WRITE_FORM)

.........

........

........

CALL FM(CLOSE_FORM)

ENDDO.

Now inside your SAP script write following condition

/: IF lv_page = '1'.

  • ORIGINAL.

/: ELSEIF lv_page = '2'.

  • DUPLICATE.

/: ELSEIF lv_page = '3'.

  • TRIPLICATE.

/: ELSEIF lv_page = '4'.

  • DUMMY.

/: ELSE

  • EXTRA.

/: ENDIF.

Close the thread once your question is answered.

Regards,

SaiRam

Former Member
0 Kudos

If the number of copies is set in the print dialog screen you need to modify you print program before the OPEN_FORM call.


num_copies = itcpo-tdcopies.
itcpo-tdcopies = 1.
do num_copies times.
  add 1 to z_copy.
  case z_copy.
    when '1'.
      z_copy_name = 'Original'.
    when '2'.
      z_copy_name = 'Duplicate'.
    when '3'.
      z_copy_name = 'Triplicate'.
   etc...
  endcase.
* print logic OPEN_FORM to CLOSE_FORM
enddo.

If you don't change itcpo-tdcopies (or whatever variable you pass to the Options parameter of OPEN_FORM) it will just send one copy to the printer with instructions to print it multiple times.

former_member841898
Participant
0 Kudos

hi michal,

i have used ur logic but the o/p is not coming

DATA: num_copies LIKE itcpo-tdcopies.

DATA: z_copy TYPE i,

z_copy_name(30) TYPE c.

num_copies = itcpo-tdcopies.

itcpo-tdcopies = 1.

DO num_copies TIMES.

ADD 1 TO z_copy.

CASE z_copy.

WHEN '1'.

z_copy_name = 'Original'.

WHEN '2'.

z_copy_name = 'Duplicate'.

WHEN '3'.

z_copy_name = 'Triplicate'.

ENDCASE.

                        • call fn open_form , write_form , close_form**************

enddo.

then i m writing the variable &z_copy_name& in script-editor(se71).

regards

pankaj

Former Member
0 Kudos

Do you get ANY output or is it just not outputing what you expect?

Please include your CALL FUNCTION 'OPEN_FORM' code.

former_member841898
Participant
0 Kudos

HI MICHAEL ,

pls see my code ....................when i m execiting the code via se38 print dialog box is not coming.

REPORT z_test_sapscript1.

TABLES: ITCPO.

DATA: num_copies LIKE itcpo-tdcopies.

DATA: z_copy TYPE i,

z_copy_name(30) TYPE c.

num_copies = itcpo-tdcopies.

itcpo-tdcopies = 1.

DO num_copies TIMES.

ADD 1 TO z_copy.

CASE z_copy.

WHEN '1'.

z_copy_name = 'Original'.

WHEN '2'.

z_copy_name = 'Duplicate'.

WHEN '3'.

z_copy_name = 'Triplicate'.

ENDCASE.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

device = 'PRINTER'

dialog = 'X'

form = 'ZXXX'

language = sy-langu

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.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'HEAD'

function = 'SET'

type = 'BODY'

window = 'HEADER'

  • IMPORTING

  • PENDING_LINES =

EXCEPTIONS

element = 1

function = 2

type = 3

unopened = 4

unstarted = 5

window = 6

bad_pageformat_for_print = 7

spool_error = 8

codepage = 9

OTHERS = 10

.

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'

EXCEPTIONS

unopened = 1

bad_pageformat_for_print = 2

send_error = 3

spool_error = 4

codepage = 5

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.

ENDIF.

ENDDO.

thanks

pankaj

Former Member
0 Kudos

Hi,

I modified your code. I used START_FORM AND END_FORM FM's.May be this code will help you.

For your reference please check this link

http://help.sap.com/saphelp_nw04/helpdata/en/d6/0dc169494511d182b70000e829fbfe/frameset.htm

REPORT z_test_sapscript1.

TABLES: ITCPO.

DATA: num_copies LIKE itcpo-tdcopies.

DATA: z_copy TYPE i,

z_copy_name(30) TYPE c.

num_copies = itcpo-tdcopies.

itcpo-tdcopies = 1.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

device = 'PRINTER'

dialog = 'X'

form = 'ZXXX'

language = sy-langu

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.

DO num_copies TIMES.

ADD 1 TO z_copy.

CASE z_copy.

WHEN '1'.

z_copy_name = 'Original'.

WHEN '2'.

z_copy_name = 'Duplicate'.

WHEN '3'.

z_copy_name = 'Triplicate'.

ENDCASE.

CALL FUNCTION 'START_FORM'. <----


CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'HEAD'

function = 'SET'

type = 'BODY'

window = 'HEADER'

  • IMPORTING

  • PENDING_LINES =

EXCEPTIONS

element = 1

function = 2

type = 3

unopened = 4

unstarted = 5

window = 6

bad_pageformat_for_print = 7

spool_error = 8

codepage = 9

OTHERS = 10

.

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 'END_FORM' . <----


ENDDO.

CALL FUNCTION 'CLOSE_FORM'

EXCEPTIONS

unopened = 1

bad_pageformat_for_print = 2

send_error = 3

spool_error = 4

codepage = 5

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.

Regards,

Jagadeesh.

Former Member
0 Kudos

Hello,

Changing itcpo-tdcopies only matters if you pass itcpo to the OPTIONS export parameter of open_form. Normally itcpo (or some other structure of type itcpo) is populated by the print parameters dialog box but you can also manually populate it. In your test program there's nothing in itcpo and you are missing OPTIONS = itcpo from the export parameters.

former_member841898
Participant
0 Kudos

HI JAGDEESH,

i have used ur logic , print dialog box is coming now but no print preview of the form

REPORT z_test_sapscript1.

TABLES: itcpo.

DATA: num_copies LIKE itcpo-tdcopies.

DATA: z_copy TYPE i,

z_copy_name(30) TYPE c.

num_copies = itcpo-tdcopies.

itcpo-tdcopies = 1.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

device = 'PRINTER'

dialog = 'X'

  • form = 'ZXXX'

language = sy-langu

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.

DO num_copies TIMES.

ADD 1 TO z_copy.

CASE z_copy.

WHEN '1'.

z_copy_name = 'Original'.

WHEN '2'.

z_copy_name = 'Duplicate'.

WHEN '3'.

z_copy_name = 'Triplicate'.

ENDCASE.

CALL FUNCTION 'START_FORM'

EXPORTING

  • ARCHIVE_INDEX =

FORM = 'ZXXX'

  • LANGUAGE = ' '

  • STARTPAGE = ' '

  • PROGRAM = ' '

  • MAIL_APPL_OBJECT =

  • IMPORTING

  • LANGUAGE =

  • EXCEPTIONS

  • FORM = 1

  • FORMAT = 2

  • UNENDED = 3

  • UNOPENED = 4

  • UNUSED = 5

  • SPOOL_ERROR = 6

  • CODEPAGE = 7

  • OTHERS = 8

.

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 'WRITE_FORM'

EXPORTING

element = 'HEAD'

function = 'SET'

type = 'BODY'

window = 'HEADER'

  • IMPORTING

  • PENDING_LINES =

EXCEPTIONS

element = 1

function = 2

type = 3

unopened = 4

unstarted = 5

window = 6

bad_pageformat_for_print = 7

spool_error = 8

codepage = 9

OTHERS = 10

.

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 'END_FORM'

  • IMPORTING

  • RESULT =

EXCEPTIONS

UNOPENED = 1

BAD_PAGEFORMAT_FOR_PRINT = 2

SPOOL_ERROR = 3

CODEPAGE = 4

OTHERS = 5

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDDO.

CALL FUNCTION 'CLOSE_FORM'

EXCEPTIONS

unopened = 1

bad_pageformat_for_print = 2

send_error = 3

spool_error = 4

codepage = 5

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.

regards

pankaj

Former Member
0 Kudos

hi,

try this,,,

call OPEN_FORM FM - pass itcpo value to options parameter in exporting parameters

num_copies = itcpo-tdcopies.

itcpo-tdcopies = 1.

DO num_copies TIMES.

ADD 1 TO z_copy.

CASE z_copy.

WHEN '1'.

z_copy_name = 'Original'.

WHEN '2'.

z_copy_name = 'Duplicate'.

WHEN '3'.

z_copy_name = 'Triplicate'.

-


if more number of pages are given eg 5... then the last value set for z_copy_name will be displayed-----

ENDCASE.

call WRITE_FORM FM

ENDDO.

Call CLOSE_FORM FM

regards

padma

former_member841898
Participant
0 Kudos

hi padmavathi

i have tried the following : but when i give the no of pages in print dialog box

and then print preview it goes to se38 editor.

REPORT z_test_sapscript1.

TABLES: itcpo.

data: itcpo1 type itcpo.

DATA: num_copies LIKE itcpo-tdcopies.

DATA: z_copy TYPE i,

z_copy_name(30) TYPE c.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

device = 'PRINTER'

dialog = 'X'

form = 'ZXXX'

language = sy-langu

OPTIONS = itcpo1

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 e398(00) WITH 'error opening form'.

ENDIF.

num_copies = itcpo-tdcopies.

itcpo-tdcopies = 1.

DO num_copies TIMES.

ADD 1 TO z_copy.

CASE z_copy.

WHEN '1'.

z_copy_name = 'Original'.

WHEN '2'.

z_copy_name = 'Duplicate'.

WHEN '3'.

z_copy_name = 'Triplicate'.

ENDCASE.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'HEAD'

function = 'SET'

type = 'BODY'

window = 'HEADER'

  • IMPORTING

  • PENDING_LINES =

EXCEPTIONS

element = 1

function = 2

type = 3

unopened = 4

unstarted = 5

window = 6

bad_pageformat_for_print = 7

spool_error = 8

codepage = 9

OTHERS = 10

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDDO.

CALL FUNCTION 'CLOSE_FORM'

EXCEPTIONS

unopened = 1

bad_pageformat_for_print = 2

send_error = 3

spool_error = 4

codepage = 5

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.

Former Member
0 Kudos

Hi,

Just go for select query with NAST table

and check with you Output type

check the count and print accordingly...

SELECT * INTO *NAST FROM NAST WHERE KAPPL = NAST-KAPPL

AND OBJKY = NAST-OBJKY

AND KSCHL = NAST-KSCHL

AND SPRAS = NAST-SPRAS

AND PARNR = NAST-PARNR

AND PARVW = NAST-PARVW

AND NACHA BETWEEN '1' AND '4'.

Thanks...

Former Member
0 Kudos

HI Pankaj,

In the sap scripts we don't have any copies window only it is possible with the smart forms.

Regards,

Sravanthi