cancel
Showing results for 
Search instead for 
Did you mean: 

Print Problems

Former Member
0 Kudos

Hi experts!

I have a problem on printing with adobe print forms. I have a WebDynpro application with a lot of views. Each view has its own print from. If i make a mass print all of this Views will be printed using the print forms. On spool request will be created with on part for each view. But i don't know how to print out this spool job to the printer. The users normally has no acces to transaction SP01.

Jan

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

YOU can have some idea from this.

TABLES: nast, tnapr.

***********************************************************************

*- Internal Table Declarations

***********************************************************************

DATA: tb_ship TYPE TABLE OF vttp,

tb_lips TYPE TABLE OF lips,

tb_likp TYPE TABLE OF likp,

tb_vtpa TYPE TABLE OF vtpa,

tb_konv TYPE TABLE OF konv,

tb_vekp TYPE TABLE OF vekp,

tb_makt TYPE TABLE OF makt,

tb_peza TYPE TABLE OF ypeza.

***********************************************************************

*- Work Areas Definition

***********************************************************************

DATA: wa_vttk TYPE vttk,

wa_vtpa TYPE vtpa,

wa_output_options TYPE ssfcompop,

wa_control_parameters TYPE ssfctrlop,

wa_peza TYPE ypeza,

wa_lips TYPE lips,

wa_lips1 TYPE lips,

wa_makt TYPE makt,

wa_konv TYPE konv,

wa_vekp TYPE vekp, "0001

wa_likp TYPE likp.

***********************************************************************

*- Constants Definition

***********************************************************************

CONSTANTS: co_c_vp(2) TYPE c VALUE 'VP',

co_c_we(2) TYPE c VALUE 'WE',

co_c_04(2) TYPE c VALUE '04',

co_c_zpez(4) TYPE c VALUE 'ZPEZ'.

DATA: dg_shippt_adrnr TYPE ad_addrnum,

dg_soldto_adrnr TYPE ad_addrnum,

dg_shipto_adrnr TYPE ad_addrnum,

dg_c_ship TYPE vttk-tknum,

dg_c_inco TYPE knvv-inco1,

dg_total_boxes TYPE i,

dg_item_total_qty TYPE i,

dg_tot_weight TYPE gsgew, "0001

dg_retcode LIKE sy-subrc. "Return Code

IF sy-tcode EQ 'SE38'.

***********************************************************************

  • SELECTION SCREEN

***********************************************************************

  • Selection criteria

SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-t01.

PARAMETERS: pa_ship TYPE vttk-tknum OBLIGATORY.

SELECTION-SCREEN END OF BLOCK blk1.

ENDIF.

***********************************************************************

*- START OF SELECTION.

***********************************************************************

START-OF-SELECTION.

  • For direct execution

IF sy-tcode EQ 'SE38'.

  • Select data to write in the invoice from the DB tables into the

  • internal tables

PERFORM select_data.

  • Call the smartform to create the invoice

PERFORM call_smartform.

ENDIF.

***********************************************************************

  • FORM ENTRY

***********************************************************************

  • This is the initial form called for the output type ZSH1

***********************************************************************

  • --> RETURN_CODE Status

  • --> US_SCREEN

***********************************************************************

*

FORM entry USING return_code LIKE sy-subrc "#EC CALLED

us_screen TYPE c. "#EC CALLED

CLEAR dg_retcode.

  • Main processiang module of YWMRPEZA.

PERFORM processing USING us_screen

CHANGING dg_retcode.

IF dg_retcode NE 0.

return_code = 1.

ELSE.

return_code = 0.

ENDIF.

ENDFORM. "ENTRY

***********************************************************************

  • FORM PROCESSING

***********************************************************************

  • This is the main processiang module of YWMRPEZA.

***********************************************************************

FORM processing USING proc_screen TYPE c

CHANGING dg_retcode LIKE sy-subrc. "#EC *

  • Select data to write in the invoice from the DB tables into the

  • internal tables

PERFORM select_data.

CHECK dg_retcode = 0.

  • Call the smartform to create the invoice

PERFORM call_smartform.

CHECK dg_retcode = 0.

ENDFORM. "PROCESSING

&----


*& Form select_data

&----


  • Select data to write in the invoice from the DB tables into

  • the internal tables

----


FORM select_data.

DATA: dl_msgid TYPE syst-msgid,

dl_msgnr TYPE syst-msgno,

dl_msgty TYPE syst-msgty,

dl_msgv1 TYPE syst-msgv1,

dl_msgv2 TYPE syst-msgv2.

  • For direct execution

IF sy-tcode EQ 'SE38'.

dg_c_ship = pa_ship.

ELSE.

  • For execution from output type

dg_c_ship = nast-objky.

ENDIF.

  • shipment details

SELECT * FROM vttp INTO TABLE tb_ship

WHERE tknum = dg_c_ship.

IF tb_ship[] IS NOT INITIAL.

SORT tb_ship BY tknum.

  • Delivery number

SELECT * FROM likp INTO TABLE tb_likp

FOR ALL ENTRIES IN tb_ship

WHERE vbeln = tb_ship-vbeln.

IF tb_likp[] IS NOT INITIAL.

SORT tb_likp BY vbeln.

ENDIF.

ENDIF.

  • INFO like Shipping Condition, waybill number of shipment

SELECT SINGLE * FROM vttk INTO wa_vttk

WHERE tknum = dg_c_ship.

  • SHIPPING-POINT Address Number

CLEAR dg_shippt_adrnr.

SELECT SINGLE adrnr FROM ttds INTO dg_shippt_adrnr

WHERE tplst = wa_vttk-tplst.

  • Delivery line items and Unit Price

IF tb_likp[] IS NOT INITIAL.

SELECT * FROM lips INTO TABLE tb_lips

FOR ALL ENTRIES IN tb_likp

WHERE vbeln = tb_likp-vbeln.

IF tb_lips[] IS NOT INITIAL.

SORT tb_lips BY vbeln posnr.

ENDIF.

SELECT * FROM konv INTO TABLE tb_konv

FOR ALL ENTRIES IN tb_likp

WHERE knumv = tb_likp-knump AND

kschl = co_c_zpez.

IF tb_konv[] IS NOT INITIAL.

SORT tb_konv BY knumv kposn kschl.

ENDIF.

ENDIF.

IF tb_lips[] IS NOT INITIAL.

  • Material Description

SELECT * FROM makt INTO TABLE tb_makt

FOR ALL ENTRIES IN tb_lips

WHERE matnr = tb_lips-matnr.

IF tb_makt[] IS NOT INITIAL.

SORT tb_makt BY matnr spras.

ENDIF.

ENDIF.

  • Start of 0001.

    • Total No. Of Boxes

  • SELECT * FROM vekp INTO TABLE tb_vekp

  • WHERE vpobjkey = dg_c_ship

  • AND uevel = space

  • AND vpobj = co_c_04.

  • DESCRIBE TABLE tb_vekp LINES dg_total_boxes.

REFRESH tb_vekp.

CLEAR: dg_total_boxes,

dg_tot_weight.

SELECT * FROM vekp INTO TABLE tb_vekp

WHERE vpobjkey = dg_c_ship

AND vpobj = co_c_04.

CLEAR wa_vekp.

LOOP AT tb_vekp INTO wa_vekp.

  • Total No. Of Boxes

IF wa_vekp-uevel EQ space.

dg_total_boxes = dg_total_boxes + 1.

ENDIF.

  • If in Gram

IF wa_vekp-gewei = 'G'.

dg_tot_weight = dg_tot_weight + ( wa_vekp-brgew / 1000 ).

ENDIF.

  • If in Kilogram

IF wa_vekp-gewei = 'KG'.

dg_tot_weight = dg_tot_weight + wa_vekp-brgew .

ENDIF.

  • If in Tonne

IF wa_vekp-gewei = 'TO'.

dg_tot_weight = dg_tot_weight + ( wa_vekp-brgew * 1000 ).

ENDIF.

  • If in Pound

IF wa_vekp-gewei = 'LB'.

dg_tot_weight = dg_tot_weight + ( wa_vekp-brgew / '2.205' ).

ENDIF.

  • If in Ounce

IF wa_vekp-gewei = 'OZ'.

dg_tot_weight = dg_tot_weight + ( wa_vekp-brgew / '35.27' ).

ENDIF.

CLEAR wa_vekp.

ENDLOOP.

  • End of 0001

  • SOLD-TO and SHIP-TO

REFRESH tb_vtpa.

SELECT * FROM vtpa INTO TABLE tb_vtpa WHERE

vbeln = dg_c_ship AND

( parvw = co_c_vp OR parvw = co_c_we ).

IF tb_vtpa[] IS NOT INITIAL.

SORT tb_vtpa BY vbeln parvw.

ENDIF.

  • SOLD-TO Address Number

CLEAR dg_soldto_adrnr.

CLEAR wa_vtpa.

READ TABLE tb_vtpa INTO wa_vtpa

WITH KEY vbeln = dg_c_ship

parvw = co_c_vp.

IF wa_vtpa-adrnr IS NOT INITIAL.

dg_soldto_adrnr = wa_vtpa-adrnr.

ENDIF.

  • SHIP-TO Address Number

CLEAR dg_shipto_adrnr.

CLEAR wa_vtpa.

READ TABLE tb_vtpa INTO wa_vtpa

WITH KEY vbeln = dg_c_ship

parvw = co_c_we.

IF wa_vtpa-adrnr IS NOT INITIAL.

dg_shipto_adrnr = wa_vtpa-adrnr.

ENDIF.

  • Begin of 0004

  • Suppl. 1 - Incoterm

IF wa_vttk-add01 IS NOT INITIAL.

dg_c_inco = wa_vttk-add01.

ELSE.

  • then take the incoterm from the ship-to partner

  • End of 0004

IF wa_vtpa-kunnr IS NOT INITIAL.

  • INCOTERM

CLEAR dg_c_inco.

SELECT SINGLE inco1 FROM knvv INTO dg_c_inco

WHERE kunnr = wa_vtpa-kunnr. "#EC *

ENDIF.

ENDIF. "0004

CLEAR wa_vtpa.

  • Populate the internal table TB_PEZA

CLEAR: wa_lips,

wa_peza.

  • LOOP AT tb_lips INTO wa_lips WHERE posnr NA '9*'. "0003

LOOP AT tb_lips INTO wa_lips WHERE posnr LT 900000. "0003

wa_peza-vbeln = wa_lips-vbeln.

wa_peza-posnr = wa_lips-posnr.

wa_peza-matnr = wa_lips-matnr.

  • Material description.

CLEAR wa_makt.

READ TABLE tb_makt INTO wa_makt

WITH KEY matnr = wa_lips-matnr

spras = sy-langu

BINARY SEARCH.

IF sy-subrc EQ 0.

wa_peza-maktx = wa_makt-maktx.

ENDIF.

  • Quantity

CLEAR dg_item_total_qty.

IF wa_lips-lfimg EQ 0.

*- 0002 Start

  • CLEAR wa_lips1.

  • LOOP AT tb_lips into wa_lips1 where vbeln EQ wa_lips-vbeln and

  • VGPOS EQ wa_lips-posnr.

*

  • DG_ITEM_TOTAL_QTY = DG_ITEM_TOTAL_QTY + wa_lips1-lfimg.

  • CLEAR wa_lips1.

  • endloop.

dg_item_total_qty = wa_lips-kcmeng.

*- 0002 End

ELSE.

dg_item_total_qty = wa_lips-lfimg.

ENDIF.

CLEAR wa_lips1.

wa_peza-quantity = dg_item_total_qty.

  • Unit price

CLEAR: wa_konv,

wa_likp.

READ TABLE tb_likp INTO wa_likp

WITH KEY vbeln = wa_lips-vbeln

BINARY SEARCH.

IF sy-subrc EQ 0.

READ TABLE tb_konv INTO wa_konv

WITH KEY knumv = wa_likp-knump

kposn = wa_lips-posnr

kschl = co_c_zpez

BINARY SEARCH.

IF sy-subrc EQ 0.

IF wa_konv-waers = 'US4'.

wa_peza-unitprice = wa_konv-kbetr / 100.

ELSE.

wa_peza-unitprice = wa_konv-kbetr.

ENDIF.

ENDIF.

ENDIF.

CLEAR wa_likp.

  • Total Price

wa_peza-totalprice = wa_peza-unitprice * dg_item_total_qty.

IF wa_peza-totalprice IS INITIAL AND sy-tcode NE 'SE38'.

dg_retcode = '4'.

dl_msgid = 'YM'.

dl_msgnr = '007'.

dl_msgty = 'E'.

dl_msgv1 = wa_peza-vbeln.

dl_msgv2 = wa_peza-posnr.

CALL FUNCTION 'NAST_PROTOCOL_UPDATE'

EXPORTING

msg_arbgb = dl_msgid

msg_nr = dl_msgnr

msg_ty = dl_msgty

msg_v1 = dl_msgv1

msg_v2 = dl_msgv2

EXCEPTIONS

message_type_not_valid = 1

no_sy_message = 2

OTHERS = 3.

IF sy-subrc <> 0.

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

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

ENDIF.

EXIT.

ENDIF.

APPEND wa_peza TO tb_peza.

CLEAR wa_peza.

CLEAR wa_lips.

ENDLOOP.

ENDFORM. " select_data

&----


*& Form Call_smartform

&----


  • Call the smartform to create the invoice

----


FORM call_smartform .

DATA: dl_c_fname TYPE rs38l_fnam,

dl_c_formname TYPE tnapr-sform.

  • For direct execution

IF sy-tcode EQ 'SE38'.

dl_c_formname = 'Y_PEZA_SHIP'.

ELSE.

  • For execution from output type

dl_c_formname = tnapr-sform.

ENDIF.

  • Generate the FM for the smartform

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = dl_c_formname

IMPORTING

fm_name = dl_c_fname

EXCEPTIONS

no_form = 1

no_function_module = 2

OTHERS = 3.

IF sy-subrc <> 0.

  • MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

  • WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

IF sy-tcode EQ 'SE38'.

  • To get the dialog box

wa_control_parameters-no_dialog = ' '.

ELSE.

  • For printing - when executed from output type

wa_output_options-tddest = nast-ldest.

wa_output_options-tdimmed = nast-dimme.

wa_output_options-tddelete = nast-delet.

wa_output_options-tddataset = nast-dsnam.

wa_control_parameters-device = 'PRINTER'.

wa_control_parameters-no_dialog = 'X'.

ENDIF.

  • Call the FM

CALL FUNCTION dl_c_fname

EXPORTING

output_options = wa_output_options

control_parameters = wa_control_parameters

user_settings = ''

wa_vttk = wa_vttk

dg_shippt_adrnr = dg_shippt_adrnr

dg_soldto_adrnr = dg_soldto_adrnr

dg_shipto_adrnr = dg_shipto_adrnr

dg_c_inco = dg_c_inco

dg_total_boxes = dg_total_boxes

dg_tot_weight = dg_tot_weight "0001

TABLES

tb_peza = tb_peza

tb_likp = tb_likp

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 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.

ENDFORM. " Call_smartform