cancel
Showing results for 
Search instead for 
Did you mean: 

print two copies of sap script

former_member389853
Participant
0 Kudos

How to create two copies of sap script one as original and the other one as copy of original?

Can anyone please help me out to resolve this issue?

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member213851
Active Contributor
0 Kudos

Hi Geetha,

please change ur code as below :

data: WA_count type nast-anzal.

WA_count =  nast-anzal.

/:        Box frame 10 tw

*         If &WA_count& EQ '1'

ph        Company copy

*         Else

PH     Customer copy

*           Endif.

former_member389853
Participant
0 Kudos

Hi sachin,

giving ur code also its printing 2 copies with customer copy only.

former_member213851
Active Contributor
0 Kudos

H Geetha,

Have you put breakpoint and checked value of WA_count during First and second iteration?

If yes, please mention that values..

former_member389853
Participant
0 Kudos

Hi sachin,

For the first iteration wa_count is taking value 0.

I put that also in if condition, bt its giving the same output.

former_member389853
Participant
0 Kudos

and i hv called write_form  for that window to call that element to print company copy and customer copy

former_member213851
Active Contributor
0 Kudos

Hi Geetha,

You need to call the window in loop using write form.

/:        Box frame 10 tw

*         If &WA_count& EQ '0'                   *------ For first iteration WA_count = 0 and for next will be 1

ph        Company copy

*         Else

PH     Customer copy

*           Endif.

 

/:  clear &WA_count&

former_member389853
Participant
0 Kudos

Then also its printing customer copy only on the two copies

former_member213851
Active Contributor
0 Kudos

Hi Sangeetha,

I am not sure if you are calling the window where check for Customer/company copy is kept.

can u plz mention WA_count values in 1st amd 2nd iteration ?

former_member389853
Participant
0 Kudos

first iteration its 0 nd second iteration its 0 only.

former_member213851
Active Contributor
0 Kudos

Hi Sangeetha,

Just try below code now :

  WA_count = 1.   *------  write this stmt inside  driver prog above LOOP stmt and pass the                                 *------ value to script using   FORM-PERFORM.

                          

inside script, use below code


/:        Box frame 10 tw

*         If &WA_count& EQ '1'                   *------ For first iteration WA_count = 0 and for next will be 1

ph        Company copy

/:  &WA_count&  = &WA_count& + 1.

*         Else

PH     Customer copy

*           Endif.

former_member389853
Participant
0 Kudos

Hi sachin,

I got the output.

Instead of nast-anzal,

Just give sy-index.

This will give u the correct output

former_member389853
Participant
0 Kudos

I have two copies now. I have to print grand total in the last page of each copy. wht should i do for that?

former_member213851
Active Contributor
0 Kudos

Hi Geetha,

You can calculate total in Driver program and store it to GV_SUM  and pass that  GV_SUM variable to script.

In script you need to add below code to dispaly Grand total:

/: IF &NEXTPAGE& = '0'

/:    Grand total : &GV_SUM&

/: ENDIF

Best Regards,

Sachin

former_member389853
Participant
0 Kudos

I was getting grand total in last page. But now i have two copies as customer copy and company copy....i hv to get the grandtotal in last page of each copy.. How to get that?

former_member213851
Active Contributor
0 Kudos

Hi Sangeetha,

Please refer below link:

http://scn.sap.com/thread/121448

former_member389853
Participant
0 Kudos

Hi sachin,

am getting only the subtotal.......and not the grandtotal

former_member209818
Active Contributor
0 Kudos

Hi Geetha,

While calling the OPEN_FORM Function module, generally we do not pass the structure "OPTIONS". But if you pass this structure, it has a field "TDCOPIES". here you can mention how many copies you want to print.

ONly thing is that, if you want to print any specific window only on original and not on the copies, then that you need to handle separately.. hope this helps

former_member389853
Participant
0 Kudos

Hi harshad,

How to pass TDCOPIES?

former_member209818
Active Contributor
0 Kudos

As i told, while calling Script using OPEN_FORM, there is a structure "OPTIONS" in the importing parameter. in this structure you will find this field..

former_member213851
Active Contributor
0 Kudos

Hi Getha,

In order to print 2 copies of document , you need to add check on every window to check if it how many times page window is printed.

For that you may use a variable gv_copy in each window which will get incremented at each loop.

Now use Do while loop such that Page windows will be printed while gv_copy < 3.

Also you can make use of nast-anzal to distinguish between Origina l(  nast-anza = 1) and Duplicate copy.

former_member389853
Participant
0 Kudos

Hi sachin,

Thnks for ur reply..Can u explain me n deatil as am a fresher?

I hv to print on page that its original and the other as copy.

How to use it in form and print program?

former_member213851
Active Contributor
0 Kudos

Chack nast-anzal contents in script

IF nast-anzal = 1

print Original

else.

Duplicate.

also 2 print multiple times, in driver program use below Logic:

DO nast_anzal TIMES.  "in ur case it's  2

*--- call  open_form

*--- cal   lwrite_form

*--- call  close_form etc....

enddo.

former_member389853
Participant
0 Kudos

Thanks sachin.

Vl try using this.

former_member389853
Participant
0 Kudos

Do i  hv to gv the if condition in form?

former_member213851
Active Contributor
0 Kudos

For determining original copy, give condtion in script and to print twice , use do while loop in driver program as suggested

former_member389853
Participant
0 Kudos

I gav the above if condition in form and the do condition in program.

Its not working properly.its printing twice but with the copy name duplicate.

former_member213851
Active Contributor
0 Kudos

Hi Geetha,

Please activate the script for Debug mode in SE71 and check nast-anzal contents and do the changes accordingly.

former_member389853
Participant
0 Kudos

Hi sachin,

in script the code i hv given is

/:        Box frame 10 tw

/:         If nast-anzal EQ '1'

ph        Company copy

/:          Else

PH     Customer copy

/:            Endif.

In z program

Do 2 times.

--------open form

-------write form

--------close form

ENDDO.

Is this correct? Its givimg me nly company copy.

former_member213851
Active Contributor
0 Kudos

Hi Geetha,

Please replace nast-anzal by  &wa_count&  .

also replace /: by * in IF , ELSE AND ENDIF.

former_member389853
Participant
0 Kudos

So hv to declare wa_count in program rt?

former_member213851
Active Contributor
0 Kudos

Hi Geetha,

please change ur code as below :

data: WA_count type nast-anzal.

WA_count =  nast-anzal.

/:        Box frame 10 tw

*         If &WA_count& EQ '1'

ph        Company copy

*         Else

PH     Customer copy

*           Endif.

Message was edited by: Sachin Adak