Skip to Content

SAP script

hi all,

i made a script for printing and i m calling it in driver program but problem is that while executing then after selecting printer 'LOCL' it is showing error 'WRITE_FORM is invalid and START_FORM is mising'.

can anyone please tell me the meaning of this error and how to remove it. while form is activated properly.

Driver program :

REPORT zpf_trust_print NO STANDARD PAGE HEADING LINE-SIZE 125.

TABLES : zprint, zpf_loan, zprev_emp, zpf_clos_bal, pa0001, pa0587, itcpo.

TYPE-POOLS : slis.

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

DATA : BEGIN OF itab OCCURS 0,

pernr LIKE zprint-pernr,

period LIKE zprint-period,

gjahr LIKE zprint-gjahr,

ename LIKE pa0001-ename,

kostl LIKE pa0001-kostl,

eepfn LIKE pa0587-eepfn,

END OF itab.

DATA : date TYPE d.

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

SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS : pernr FOR zprint-pernr,

period FOR zprint-period NO INTERVALS NO-EXTENSION,

gjahr FOR zprint-gjahr NO INTERVALS NO-EXTENSION.

SELECTION-SCREEN : END OF BLOCK b1.

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

AT SELECTION-SCREEN.

IF period-low LT '01' OR period-low GT '12'.

MESSAGE 'Please Enter Period Betveen 1 to 12' TYPE 'I'.

ENDIF.

START-OF-SELECTION.

PERFORM print_form.

&----


*& Form PRINT_FORM

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM print_form .

itcpo-tdimmed = 'X'.

itcpo-tddelete = 'X'.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

  • APPLICATION = 'TX'

device = 'PRINTER'

dialog = 'X'

form = 'ZPF_TRUST'

language = sy-langu.

SELECT pernr period gjahr FROM zprint INTO TABLE itab WHERE pernr IN pernr AND period IN period AND gjahr IN gjahr.

IF sy-subrc NE 0.

MESSAGE 'Data not found in ZPRINT table.' TYPE 'I'.

ENDIF.

SORT itab BY pernr.

LOOP AT itab.

date = sy-datum.

SELECT SINGLE ename kostl FROM pa0001 INTO (itab-ename , itab-kostl) WHERE pernr = itab-pernr.

SELECT SINGLE eepfn FROM pa0587 INTO itab-eepfn WHERE pernr = itab-pernr AND endda = '99991231'.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

  • ELEMENT = ' '

function = 'SET'

type = 'BODY'

window = 'HEADER2'.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

  • ELEMENT = ' '

function = 'SET'

type = 'BODY'

window = 'MAIN'.

ENDLOOP.

CALL FUNCTION 'CLOSE_FORM'

  • IMPORTING

  • RESULT =

  • RDI_RESULT =

  • TABLES

  • OTFDATA =

  • EXCEPTIONS

  • UNOPENED = 1

  • BAD_PAGEFORMAT_FOR_PRINT = 2

  • SEND_ERROR = 3

  • SPOOL_ERROR = 4

  • CODEPAGE = 5

  • OTHERS = 6

.

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. " PRINT_FORM

regards saurabh.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Apr 01, 2009 at 06:24 AM

    If your outputhas more than one page and if the subsequent pages are not declared in script, then this kind of message may occur.. just chk this once...

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 01, 2009 at 06:20 AM

    hi:

    Try to match

    REPORT ZPSAPSCRIPT.

    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.

    Regards

    Shashi

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.