‎2007 Dec 28 9:51 PM
The following codes are not enough to call sapscript in aprogram. Any other configuration if available please let me know.
'OPEN_FORM', 'WRITE_FORM', 'CLOSE_FORM'.
Possibly supply the codes/programms with exapmle as I'm new to ABAP, basically I'm into SAP-SD.
Please guide me with an example.
Thanks very much
Regards.
‎2007 Dec 28 10:42 PM
HI!
I have this code:
REPORT ZSAPSCRIPT.
TABLES : EKKO,
EKPO,
KNA1,
USR01,
MARA,
MAKT.
DATA : BEGIN OF ZOPTION.
INCLUDE STRUCTURE ITCPO.
DATA : END OF ZOPTION.
PARAMETERS: P_EBELN LIKE EKKO-EBELN,
P_EBELP LIKE EKPO-EBELP.
CLEAR EKPO.
SELECT SINGLE * FROM EKPO
WHERE EBELN = P_EBELN AND
EBELP = P_EBELP.
CLEAR KNA1.
SELECT SINGLE NAME1 FROM KNA1
INTO KNA1-NAME1
WHERE KUNNR = EKPO-KUNNR.
CLEAR MAKT.
SELECT SINGLE MAKTX FROM MAKT
INTO MAKT-MAKTX
WHERE MATNR = EKPO-MATNR AND
SPRAS = SY-LANGU.
CLEAR USR01.
SELECT SINGLE * FROM USR01 WHERE BNAME = SY-UNAME.
ZOPTION-TDDEST = USR01-SPLD. "Output device (printer)
ZOPTION-TDIMMED = 'X'. "Print immediately
ZOPTION-TDDELETE = 'X'. "Delete after printing
ZOPTION-TDPROGRAM = 'ZPQRPRNT'. "Program Name
CALL FUNCTION 'OPEN_FORM'
EXPORTING
APPLICATION = 'TX'
ARCHIVE_INDEX = ' '
ARCHIVE_PARAMS = ' '
DEVICE = 'PRINTER'
DIALOG = ' '
FORM = 'Z_TESTSCRIPT'
LANGUAGE = SY-LANGU
OPTIONS = ZOPTION
IMPORTING
LANGUAGE = SY-LANGU
EXCEPTIONS
OTHERS = 1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'HEADER'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'HEADER'
EXCEPTIONS
ELEMENT = 1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'MAIN'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'MAIN'
EXCEPTIONS
ELEMENT = 1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'FOOTER'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'FOOTER'
EXCEPTIONS
ELEMENT = 1.
CALL FUNCTION 'CLOSE_FORM'
EXCEPTIONS
UNOPENED = 1
OTHERS = 2.
I hope this help you...
Regards
‎2007 Dec 28 10:49 PM
Check this link for sample program.
U should link a form to the driver program by using NACE Tcode .
In NACE t-code we have the application for each one. based on the application output type can be defined, based on output type script and print progrma can be defined.
If suppose data can be read from EDI then we should go for condition records.
So whenever we execute the script first composer checks the output type and then execute the program. in program whenever opn form FM will be populate then script will open first. After that again program till another FM will populate if it then script will populate........like it is cycle proces. Composer does all these things and at last it will submit that output to spool.
Assigning Form and Driver proram to an Output type is as follows.
Go to the Transaction NACE.
choose the related sub module.. like billing or shipping
doubel click on Output Types
Choose the Output Type for which whcih you wanted your script to trigger
Then select the Output Type and double click on Processing Routine
Then go to create new entries--> Select the Medium (1- print output), then enter your Script and Print Program detls --> Save and come out
Now go to the Transaction (for which you have created the output type)... Issue output--> Select the output type --> Print....
You should know the Output type for each document like ,
for sales order it is BAoo
for Purchase order it is NEU
for delivery it is LD00
for Invoice it is RD00
and the application for each document:
for PO it is EF
for Sales doc's it is V1
delivery it is V2
billing Doc's it is V3.
Select the Application from NACE and click on output types.
select the right output type and click on the processing routines on the left hand side.
it displays the Medium(print,Fax,Mail, edi etc), Output type, Program and the Script form or Smart form.
The print program is used to print the actual form ,the functions the print program has to do include retrieving of data from database tables , selecting a FORM and printing of TEXT ELEMENTS in a desired sequence.
The function modules used in a print prgram are :
OPEN_FORM
START_FORM
WRITE_FORM
CONTROL_FORM
END_FORM
CLOSE_FROM
To start printing a form we must use OPEN_FORM and in the end we should use CLOSE_FORM to complete the spool request.
Function modules in detail.
OPEN_FORM function module
This function module should be called first before any printing can take place , here we specify the name of the form and the print language.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
DIALOG = 'X'
DEVICE = 'PRINTER'
FORM = form name
LANGUAGE = SY-LANGU
OPTIONS =
EXCEPTIONS
CANCELLED = 1
DEVICE = 2
FORM = 3
OTHERS = 11
.
IF SY-SUBRC NE 0.
MESSAGE ...
ENDIF.
In the above function module the parameter
FORM = Name of form
DEVICE = PRINTER (print using spool),TELEFAX (fax output)
SCREEN (output to screen)
OPTIONS = It is a structure of type ITCPO and it controls the various
attributes like number of copies , print preview etc.
START_FROM function module
This function module is called if we want to use different forms with similar characterstics in a single spool request,it must be closed by END_FORM function module.
CALL FUNCTION 'START_FORM'
EXPORTING
FORM =
LANGUAGE =
STARTPAGE =
EXCEPTIONS
FORM = 1
OTHERS = 7
.
IF SY-SUBRC NE 0.
MESSAGE ...
ENDIF.
WRITE_FORM Function module
This function module is used to write text in a window in the form using
text elements (/:E element). We can specify whether the text is to be appended , replaced or added and in which portion of the window it will be printed i.e TOP, BOTTOM ,BODY. In this function module actual printing takes place.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT =
FUNCTION =
TYPE =
WINDOW =
EXCEPTIONS
ELEMENT = 1
OTHERS = 9
.
IF SY-SUBRC NE 0.
MESSAGE ...
ENDIF.
Here in this function module the ELEMENT specifies which textelement is
printed . WINDOW specifies which window of the form to be print in.
TYPE specifies the output area of the window TOP,BOTTOM,BODY.
FUNCTION specifies whether the text is to be appended , replaced or added.
CLOSE_FORM function module
This function module should be called in the end and it has no exporting
parameter.
CALL FUNCTION 'CLOSE_FROM'
IMPORTING
RESULT =
EXCEPTIONS
UNOPENED = 1
OTHERS = 5
.
IF SY-SUBRC NE 0.
MESSAGE ...
ENDIF.
Here the result parameteer returns the status information and print/fax parameters after the form has been printed.
CONTROL_FORM function module
This function module is used to insert SAPScript control commands like NEW-PAGE etc from whithin the ABAP program.
CALL FUNCTION 'CONTROL_FORM'
EXPORTING
COMMAND =
EXCEPTIONS
UNOPENED = 1
OTHERS = 3
.
IF SY-SUBRC NE 0.
MESSAGE ...
ENDIF.
The print program and the form are stored in the table TNAPR.
Regards,
Maha