04-27-2006 6:53 AM
Hi all,
I have created a custom print program for PO form,it is working fine but it is picking up the output device of the user ID creating the PO form as opposed to the output control for the PO.so i need piece of code for detecting the correct output device when we go for printing.I had a look on the standard print program (SAPFM06P),but iam unable to trace the exact piece of code for this.
code for custom print program for PO -:
REPORT ZMMPTPF1_PO
NO STANDARD PAGE HEADING
MESSAGE-ID ZMM
LINE-COUNT 65
LINE-SIZE 120.
&----
*& TABLES *
&----
TABLES: LFA1, "Vendor Master (General Section)
EKKO, "Purchasing Document Head
T001, "Company Codes
ADR2, "Telephone Numbers (Business Address Services)
ADRC, "Addresses (Business Address Services)
ADRP, "Persons (Business Address Servic
ADR6, "E-Mail Addresses (Business Address Ser
TVZBT, "Customers: Terms of Payment Tex
T006A, "Assign Internal to Language-Depende
TWLAD, "Determination of Address from Plant and Storage
NAST,
EKET. "Scheduling Agreement Schedule Lines
&----
*& PROGRAM VARIABLES *
&----
DATA : G_NAME_LAST LIKE ADRP-NAME_LAST,
G_NAME_FIRST LIKE ADRP-NAME_FIRST,
G_TEL_NUMBER LIKE ADR2-TEL_NUMBER,
G_SMTP_ADDR LIKE ADR6-SMTP_ADDR,
G_VTEXT LIKE TVZBT-VTEXT,
G_WAERS LIKE EKKO-WAERS,
G_MSEHT LIKE T006A-MSEHT,
G_ADRNR LIKE TWLAD-ADRNR,
G_EBELN LIKE EKKO-EBELN,
G_BEDAT LIKE EKKO-BEDAT,
G_NAME1 LIKE T001W-NAME1,
G_STRAS LIKE T001W-STRAS,
G_ORT01 LIKE T001W-ORT01,
G_PSTLZ LIKE T001W-PSTLZ,
G_LAND1 LIKE T001W-LAND1,
G_NAMEADRC LIKE ADRC-NAME1,
G_HOUSE_NUM1 LIKE ADRC-HOUSE_NUM1,
G_STREET LIKE ADRC-STREET,
G_CITY1 LIKE ADRC-CITY1,
G_POST_CODE2 LIKE ADRC-POST_CODE2,
G_COUNTRY LIKE ADRC-COUNTRY,
G_BUKRS LIKE EKKO-BUKRS,
G_EINDT LIKE EKET-EINDT,
g_output type ssfcompop,
g_control type ssfctrlop,
fp_outputparams TYPE sfpoutputparams,
l_errstr TYPE string.
DATA G_FMNAME TYPE RS38L_FNAM. "Calling function module of smartforms
&----
*& INTERNAL TABLES *
&----
" Internal table containing LFA1 table contents
DATA: I_LFA1 LIKE LFA1 OCCURS 0 WITH HEADER LINE.
" Internal table containing LFA1 table contents
DATA: I_USR21 LIKE USR21 OCCURS 0 WITH HEADER LINE.
DATA I_EKET LIKE EKET OCCURS 0 WITH HEADER LINE.
" Internal table containing EKKO table contents
DATA: I_EKKO LIKE EKKO OCCURS 0 WITH HEADER LINE.
" Internal table containing EKPO table contents
DATA: I_EKPO LIKE EKPO OCCURS 0 WITH HEADER LINE.
" Internal table containing T001W table contents
DATA: I_T001W LIKE T001W OCCURS 0 WITH HEADER LINE.
DATA: I_T001 LIKE T001 OCCURS 0 WITH HEADER LINE.
" Internal table containing ADRC table contents
DATA: I_ADRC LIKE ADRC OCCURS 0 WITH HEADER LINE.
DATA: RETCODE LIKE SY-SUBRC. "Returncode
DATA I_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
DATA: XSCREEN(1) TYPE C. "Output on printer or screen
&----
AT SELECTION-SCREEN
&----
Event which occurs each time the user hits enter on the selection
screen
AT SELECTION-SCREEN.
IF EKKO-EBELN IS INITIAL.
*---Enter the Purchase Order Number
MESSAGE E111.
ENDIF.
***********************************************************************
START-OF-SELECTION
***********************************************************************
START-OF-SELECTION.
" Retrieving data from table EKKO
&----
*& Form PO_FORM
&----
text
----
-->RETURN_CODEtext
-->US_SCREEN text
----
FORM entry_neu using RETURN_CODE US_SCREEN. " PO_FORM
DATA: lf_retcode TYPE sy-subrc.
CLEAR retcode.
xscreen = us_screen.
PERFORM processing USING us_screen
CHANGING lf_retcode.
IF lf_retcode NE 0.
return_code = 1.
ELSE.
return_code = 0.
ENDIF.
ENDFORM. "PO_FORM
&----
*& Form PROCESSING
&----
text
----
-->US_SCREEN text
-->IF_RETCODE text
----
FORM PROCESSING USING US_SCREEN CHANGING IF_RETCODE.
GET PARAMETER ID 'BES' FIELD EKKO-EBELN.
"Retrieving data from the table EKKO.
SELECT * FROM EKKO INTO TABLE I_EKKO WHERE EBELN = NAST-OBJKY.
****ADDRESS DATA FIELDS
CLEAR I_EKKO.
READ TABLE I_EKKO INDEX 1.
IF SY-SUBRC = 0.
****LOGO
SELECT SINGLE BUKRS INTO G_BUKRS FROM EKKO WHERE EBELN = NAST-OBJKY.
" Retrieving data from table LFA1
SELECT * FROM LFA1 INTO TABLE I_LFA1 WHERE LIFNR = I_EKKO-LIFNR.
****INFO DATA FIELDS
SELECT SINGLE EBELN FROM EKKO INTO G_EBELN WHERE EBELN = NAST-OBJKY.
SELECT SINGLE BEDAT FROM EKKO INTO G_BEDAT WHERE EBELN = NAST-OBJKY.
SELECT SINGLE * INTO I_USR21 FROM USR21 WHERE BNAME = I_EKKO-ERNAM.
IF SY-SUBRC = 0.
"Retrieving data from table ADRP
SELECT SINGLE NAME_LAST NAME_FIRST
FROM ADRP
INTO (G_NAME_LAST,G_NAME_FIRST)
WHERE PERSNUMBER = I_USR21-PERSNUMBER.
"Retrieving data from table ADR2 & ADR6
SELECT SINGLE TEL_NUMBER
FROM ADR2
INTO G_TEL_NUMBER
WHERE PERSNUMBER = I_USR21-PERSNUMBER AND ADDRNUMBER = I_USR21-ADDRNUMBER.
SELECT SINGLE SMTP_ADDR
FROM ADR6
INTO G_SMTP_ADDR
WHERE PERSNUMBER = I_USR21-PERSNUMBER AND ADDRNUMBER = I_USR21-ADDRNUMBER.
ENDIF. "I_USR21
" Retrieving data from table TVZBT
SELECT SINGLE VTEXT FROM TVZBT INTO G_VTEXT WHERE ZTERM = I_EKKO-ZTERM AND SPRAS = 'E'.
MAIN DATA FIELDS
SELECT SINGLE WAERS FROM EKKO INTO G_WAERS WHERE EBELN = I_EKKO-EBELN.
"Retrieving data from the table EKPO.
SELECT * FROM EKPO INTO TABLE I_EKPO WHERE EBELN = I_EKKO-EBELN.
CLEAR I_EKPO.
READ TABLE I_EKPO INDEX 1.
IF SY-SUBRC = 0.
SELECT * FROM EKET INTO TABLE I_EKET WHERE EBELN = I_EKPO-EBELN.
SELECT SINGLE MSEHT FROM T006A INTO G_MSEHT WHERE MSEHI = I_EKPO-MEINS AND SPRAS = 'E'.
IF NOT I_EKPO-WERKS IS INITIAL .
SELECT SINGLE NAME1 STRAS ORT01 PSTLZ LAND1 FROM T001W INTO (G_NAME1,G_STRAS,G_ORT01,G_PSTLZ,G_LAND1)
WHERE WERKS = I_EKPO-WERKS.
ELSEIF NOT I_EKPO-LGORT IS INITIAL.
SELECT SINGLE ADRNR FROM TWLAD INTO G_ADRNR WHERE LGORT = I_EKPO-LGORT AND LFDNR = '01'.
" Check whether retrieval from TWLAD is successful
IF SY-SUBRC = 0.
" Retrieving data from table ADRC
SELECT SINGLE NAME1 HOUSE_NUM1 STREET CITY1 POST_CODE2 COUNTRY
FROM ADRC
INTO (G_NAMEADRC,G_HOUSE_NUM1,G_STREET,G_CITY1,G_POST_CODE2,G_COUNTRY)
WHERE ADDRNUMBER = G_ADRNR.
ENDIF. "TWLAD
ENDIF. "I_EKPO-WERKS
ENDIF. "I_EKPO
ENDIF. "I_EKKO
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZMM_SERCO_PO_SMARTFORM'
IMPORTING
FM_NAME = G_FMNAME.
G_OUTPUT-TDDEST = NAST-LDEST.
G_OUTPUT-TDIMMED = 'X'.
G_CONTROL-DEVICE = NAST-LDEST.
*
CALL FUNCTION G_FMNAME
EXPORTING
archive_index = toa_dara
archive_parameters = arc_params
control_parameters = ls_control_param
mail_appl_obj =
mail_recipient = ls_recipient
mail_sender = ls_sender
output_options = ls_composer_param
user_settings = space
WA_EKKO = i_ekko
G_NAME_LAST = G_NAME_LAST
G_NAME_FIRST = G_NAME_FIRST
G_TEL_NUMBER = G_TEL_NUMBER
G_SMTP_ADDR = G_SMTP_ADDR
G_VTEXT = G_VTEXT
G_BUKRS = G_BUKRS
G_EBELN = G_EBELN
G_WAERS = G_WAERS
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO =
JOB_OUTPUT_OPTIONS =
TABLES
I_EKPO = i_ekpo
I_EKET = I_EKET
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5
.
ENDFORM. "PROCESSING
04-27-2006 6:56 AM
Hi
Check <b>NACE</b> transaction also check <b>message type</b> and
Local printer setting of ur <b>user profile-> own data</b>.
regards
vinod
04-27-2006 7:06 AM
Hi vinod
i checked it,its assigned properly.
we need to add some piece of code for that.
04-27-2006 7:10 AM
Hello Swaminathan,
As inidcated in ur code it is accessing NAST table and passing LDEST. However this may be getting changed in the function module which it calls to print the PO. Check the Call function (dynamic) to c where exactly the printer name is getting reset.
04-27-2006 7:14 AM
Hi swamy!
This has nothing to do with your print program.Probably the assignment of your form in the NACE is creating this problem.
When it is working for you on your id. there should not be any problem with others.Check whether the clients have changed.
Also as per my knowledge there is no code for detecting correct output device.
Also you can get the output device name of the user and check with your id.Please let us know the result for further help.
Regards
Prasanna Kumar