Application Development 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: 

Print Purchase Order Document

Former Member
0 Kudos

Hi,

is there a function, that lets you print a purchase order from the system, if not , what would the best way of doing this be?

I did try

Function 'ME_DISPLAY_PURCHASE_DOCUMENT'

which works , I belive , if the document has been printed before, but not if it has not, am I correct?

Once printed I need the spool no.

Thanks

7 REPLIES 7

Former Member
0 Kudos

Create a Z Function module using the code below.

One import parameter for PO num say I_PO.

You can have few exceptions.

Declare NAST Table in the global data of the function group.

Replace 'XXXX' with proper values.

clear nast.

  • Raise exception if there is no delivery no.

IF I_PO IS INITIAL.

RAISE Exception.

ENDIF.

  • Fill in the NAST header line for this label.

CLEAR NAST.

NAST-OBJKY = I_PO.

NAST-LDEST = 'XXXX'.

NAST-SPRAS = 'EN'.

NAST-TDSPRAS = 'EN'.

NAST-DIMME = 'X'. " Print Immediate' flag

NAST-DELET = 'X'. " Release after print'

NAST-ANZAL = 1. " Specify one copy

NAST-NACHA = 1. " output to printer

NAST-VSZTP = 4.

NAST-KAPPL = 'XXXX'.

NAST-KSCHL = 'XXXX'.

NAST-EDIKEY = 0.

NAST-MANUE = 'X'.

NAST-VSTAT = '0'. " set status = not yet processed

NAST-ERUHR = SY-UZEIT.

NAST-ERDAT = SY-DATUM.

NAST-USNAM = SY-UNAME.

  • Insert entry into NAST

INSERT NAST.

COMMIT WORK AND WAIT.

  • Call sap STANDARD routines to process the message request

LW_SUBRC = 999.

PERFORM EINZELNACHRICHT(RSNAST00)

USING LW_SUBRC.

IF LW_SUBRC <> 0.

RAISE Exception.

ENDIF.

Thanks,

Rajesh.

0 Kudos

hi,

tried that in a small prog,

not sure what the Kappl parameter should be, but anyway it complains about

LW_SUBRC being unknown.

Thanks

0 Kudos

Put this at the top of your program.

data: lw_subrc type sy-subrc.

Regards,

Rich Heilman

0 Kudos

hi,

now keep getting

Processing program missing for output ZARG (medium 1)

REPORT zstprintpreview2 .

TABLES nast.

DATA lw_subrc LIKE sy-subrc.

CLEAR nast.

  • Fill in the NAST header line for this label.

CLEAR nast.

nast-objky = '4500006302'.

nast-ldest = '$LT4F'.

nast-spras = 'EN'.

nast-tdspras = 'EN'.

nast-dimme = 'X'. " Print Immediate' flag

nast-delet = 'X'. " Release after print'

nast-anzal = 1. " Specify one copy

nast-nacha = 1. " output to printer

nast-vsztp = 4.

nast-kappl = 'XXXX'.

nast-kschl = 'ZARG'.

nast-edikey = 0.

nast-manue = 'X'.

nast-vstat = '0'. " set status = not yet processed

nast-eruhr = sy-uzeit.

nast-erdat = sy-datum.

nast-usnam = sy-uname.

  • Insert entry into NAST

INSERT nast.

COMMIT WORK AND WAIT.

  • Call sap STANDARD routines to process the message request

lw_subrc = 999.

PERFORM einzelnachricht(rsnast00)

USING lw_subrc.

IF lw_subrc <> 0.

RAISE exception.

ENDIF.

0 Kudos

Sounds like the config has not been done. Check the config in transaction SPRO. Here is the path.

Materials Management
       Purchasing
             Messages
                   Output Control
                          Message Types
                                 Define Message Types for PUrchase ORder

Regards,

Rich Heilman

0 Kudos

This is what I had in there

AUFB Dunning Ord Confirm

ERIN Reminder

MAHN Dunning

MAIL New PO printout

NEU New PO printout

NEUS New PO printout

ZEDI Glens EDI Output

And i've tried it with NEUS

?

0 Kudos

Hi

Rajesh Mandalapu's suggestion has fixed the problem,

The spool number is returned in sy-msgv1, how reliable is it use this as the spool number I have just created, in a multi user environment?