cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic tray selection - SAPScript

former_member1110335
Participant
0 Kudos

Hi,

I need to dynamically select a tray to print a form using SAPScript, depending on some condition.

Need to know how to do this?

Thanks in advance!

regards,

Karen

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

There are 2 options. The first one I have not used before but I think it is the better way.

Example: You want print out an invoice on different paper.

In SAPscript you have in this invoice 2 pages:  "FIRST" and "NEXT"

Salesorganization 1000 = TRY01

Salesorganization 2000 = TRY02

**************************************************************************************** 1st option

1st option: (As mentioned in this thread): Create not 2 but 4 pages:

F_01 and N_01          both with Resource Name = TRY01

F_02 and N_02          both with Resource Name = TRY02

Page F_01:   in field "Next page":  N_01

Page N_01:   in field "Next page":  N_01

Page F_02:   in field "Next page":  N_02

Page N_02:   in field "Next page":  N_02

In the print-program you have to decide if you want to have page F_01 and N_01 or F_02 and N_02.

For this reason call function  "OPEN_FORM"  without the name of the form (SAPscript) because in

call function START_FORM you can export the page.

data:   GV_STARTPAGE type TDPAGE.

if vbdkr-vkorg = '1000'.

  GV_STARTPAGE = 'F_01'.

endif.

if vbdkr-vkorg = '2000'.

  GV_STARTPAGE = 'F_02'.

endif.

call function START_FORM

  FORM = name of form

  LANGUAGE = nast-spras

  STARTPAGE = GV_STARTPAGE

  and so on

  call function WRITE_FORM

  call function WRITE_FORM

  call function WRITE_FORM

call function END_FORM.

call fuction CLOSE_FORM.

**************************************************************************************** 2st option

Short description:

Normal SAPscript only FIRST and NEXT, both with same tray.

ABAP: Do not print, only get OTF-data.

Change the tray in OTF-data.

Print OTF-data.

I have done this before and I know it works. But I think the 1st option is better.

You can change the field for the "Recource name" from TRY01 to TRY02 in the print program but only with a trick.

Do not print out in a normal way (Open_form; write_form; close_form).

Solution:

In function OPEN_FORM     set field    OPTIONS-TDGETOTF to 'X'.

This means: The function CLOSE_FORM will not print into spool and maybe from spool to the printer but the print data will only be stored into a table.

In SAPscript you have 2 Pages. FIRST and NEXT; both with Recource name = 'TRY01'.

At the end nn CLOSE_FORM you can receive the table OTFDATA.

data: GS_OTFDATA type ITCOO,

        GT_OTFDATA type standard table of ITCOO.

call function CLOSE_FORM

    .

  tables OTFDATA = GT_OTFDATA.

* Up to now no data have been sent to spool.

* If you have a look now into table GT_OTFDATA (field TDPRINTPAR) you will

* find in the first lines  "TRY01"

* You can change this

If vbdkr-vkorg = '2000'.

  loop at GT_OTFDATA into GS_OTFDATA.

*   Find the pattern "TRY01" in GS_OTFDATA-TDPRINTPAR

*   with commands FIND or SEARCH or something like that.

*   Change the pattern "TRY01" in GS_OTFDATA-TDPRINTPAR to "TRY02"

*   and take over this change to table GT_OTFDATA with command "MODIFY".

*   Please notice: In table GT_OTFDATA the pattern "TRY01" can occure more than 1 time.

    modify GT_OTFDATA from GS_OTFDATA.

  endloop.

endif.

* Now print the OTF-Data

call function PRINT_OTF

* the paramters are   PRINTOPTIONS (same as in OPEN_FORM)

*                   and tables OTF = GT_OTFDATA.

Ok, I know the problem and the thread are very old but maybe someone wants to have a more detailed solution.

Keywords in English: SAP ABAP SAPscript  Resource Name ITCTG-TDPAPERRES   from program dynamically dynamic dynamically

TRAY  TRY01 TRY02 TRY03

Keywords in German: SAP ABAP SAPscript  Resourcenname   ITCTG-TDPAPERRES vom Programm aus dynamisch TRAY  TRY01 TRY02 TRY03 Druckerschacht Schachtsteuerung Druckerschachtsteuerung verschiedenes Papier

best regards

Norbert Zanders

0 Kudos

Hi,

Check out SAPSCRIPT-TRAYTEST in so10, this shows how you can select trays.

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

Hi

Their is no Dynamic Tray selction in SAPSCRIPT , but u can check with your BASIS consultant and ask him to print those particular SCripts to a specific tray , which he can do... but via program u cannot do dynamic selection of program in scripts.

surya

Former Member
0 Kudos

If you have to do it dynamically, you could create different PAGEs with the resource set for different trays. In your SAPscript logic you can check the conditions, and then issue a NEW-PAGE command with the page you need.

Sandra_Rossi
Active Contributor
0 Kudos

See [sap library - sapscript - page|http://help.sap.com/saphelp_nw04/helpdata/en/d1/802e77454211d189710000e8322d00/frameset.htm] (tray must be entered in "resource" field in page attributes)

Former Member
0 Kudos

Hi!

What do you mean on tray? There are no trays on SAPScripts (AFAIK).

Regards

Tamá