cancel
Showing results for 
Search instead for 
Did you mean: 

driver program

Former Member
0 Kudos

Could u please tell how to write driver program for SAP Scripts

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

If you need to write your own driver program you have to base it around the function modules, OPEN_FORM, START_FORM, WRITE_FORM, END_FORM and CLOSE_FORM. There are plenty of posts on this subject so if you search the forum using one of these names you'll find plenty of explanation of how to use them.

Regards,

Nick

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi pallavi,

i also posted regarding this in ABAP general,

YOU CAN JUST CALL THE FUNCTION MODULES AND PLAY AROUND ITS NOT THAT TOUGH.

if you need any sample program get back to me or else use the code which is already given by someone here.i thought of giving the code but thats not so important.

print program:

The execution of script is done through an ABAP program, which is referred as Print Program. Each print program should have an ENTRY form , which will be called from customization.

For a standard configuration we can see the form name (script name), print program name and output type in the table TNAPR

The print program uses the Form control functions to call the script.

The print program call either all or some of the form control functions to execute the script

OPEN_FORM (Mandatory) Opens the layout set output

CLOSE_FORM (Mandatory) Ends the layout set output

START_FORM (Optional) Starts a new layout set

WRITE_FORM (Mandatory) Calls a layout set element

END_FORM (Optional) Ends the current layout set

the print program is same as a report except that you can above mentioned function modules.

plz get back to me for further queries.

also plz award if you find it helpful,.

thanks and regards.

Srikanth Tulasi.

Former Member
0 Kudos

This is the sample code.Here zpavscript1 is the form name.

Just neglect the other parameters which r commented out.

In Write _form,Address,Logo,Main etc are the Text element names which u've created in the form & where u want to place the particular code,just go through this.I hope will b useful for u..

CALL FUNCTION 'OPEN_FORM'

EXPORTING

  • APPLICATION = 'TX'

  • ARCHIVE_INDEX =

  • ARCHIVE_PARAMS =

  • DEVICE = 'PRINTER'

  • DIALOG = 'X'

FORM = 'ZPAVSCRIPT1 '

LANGUAGE = SY-LANGU

  • OPTIONS =

  • MAIL_SENDER =

  • MAIL_RECIPIENT =

  • MAIL_APPL_OBJECT =

  • RAW_DATA_INTERFACE = '*'

  • SPONUMIV =

  • IMPORTING

  • LANGUAGE =

  • NEW_ARCHIVE_PARAMS =

  • RESULT =

  • EXCEPTIONS

  • CANCELED = 1

  • DEVICE = 2

  • FORM = 3

  • OPTIONS = 4

  • UNCLOSED = 5

  • MAIL_OPTIONS = 6

  • ARCHIVE_ERROR = 7

  • INVALID_FAX_NUMBER = 8

  • MORE_PARAMS_NEEDED_IN_BATCH = 9

  • SPOOL_ERROR = 10

  • CODEPAGE = 11

  • OTHERS = 12

.

IF sy-subrc <> 0.

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

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

ENDIF.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'ADDRESS'

FUNCTION = 'APPEND'

TYPE = 'BODY'

WINDOW = 'ADDRESS'

  • IMPORTING

  • PENDING_LINES =

  • EXCEPTIONS

  • ELEMENT = 1

  • FUNCTION = 2

  • TYPE = 3

  • UNOPENED = 4

  • UNSTARTED = 5

  • WINDOW = 6

  • BAD_PAGEFORMAT_FOR_PRINT = 7

  • SPOOL_ERROR = 8

  • CODEPAGE = 9

  • OTHERS = 10

.

IF sy-subrc <> 0.

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

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

ENDIF.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'ADDRESS1'

FUNCTION = 'APPEND'

TYPE = 'BODY'

WINDOW = 'ADDRESS1'

  • IMPORTING

  • PENDING_LINES =

  • EXCEPTIONS

  • ELEMENT = 1

  • FUNCTION = 2

  • TYPE = 3

  • UNOPENED = 4

  • UNSTARTED = 5

  • WINDOW = 6

  • BAD_PAGEFORMAT_FOR_PRINT = 7

  • SPOOL_ERROR = 8

  • CODEPAGE = 9

  • OTHERS = 10

.

IF sy-subrc <> 0.

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

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

ENDIF.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'LOGO'

FUNCTION = 'APPEND'

TYPE = 'BODY'

WINDOW = 'LOGO'

  • IMPORTING

  • PENDING_LINES =

  • EXCEPTIONS

  • ELEMENT = 1

  • FUNCTION = 2

  • TYPE = 3

  • UNOPENED = 4

  • UNSTARTED = 5

  • WINDOW = 6

  • BAD_PAGEFORMAT_FOR_PRINT = 7

  • SPOOL_ERROR = 8

  • CODEPAGE = 9

  • OTHERS = 10

.

IF sy-subrc <> 0.

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

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

ENDIF.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'LOGO1'

FUNCTION = 'APPEND'

TYPE = 'BODY'

WINDOW = 'LOGO1'.

  • IMPORTING

  • PENDING_LINES =

  • EXCEPTIONS

  • ELEMENT = 1

  • FUNCTION = 2

  • TYPE = 3

  • UNOPENED = 4

  • UNSTARTED = 5

  • WINDOW = 6

  • BAD_PAGEFORMAT_FOR_PRINT = 7

  • SPOOL_ERROR = 8

  • CODEPAGE = 9

  • OTHERS = 10

  • .

*IF sy-subrc <> 0.

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

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

*ENDIF.

*CALL FUNCTION 'WRITE_FORM'

  • EXPORTING

  • ELEMENT = 'HEADER'

  • FUNCTION = 'APPEND'

  • TYPE = 'BODY'

  • WINDOW = 'MAIN'.

LOOP AT I_VBAP INTO WA_VBAP.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'MAIN'

FUNCTION = 'APPEND'

TYPE = 'BODY'

WINDOW = 'MAIN'

  • IMPORTING

  • PENDING_LINES =

  • EXCEPTIONS

  • ELEMENT = 1

  • FUNCTION = 2

  • TYPE = 3

  • UNOPENED = 4

  • UNSTARTED = 5

  • WINDOW = 6

  • BAD_PAGEFORMAT_FOR_PRINT = 7

  • SPOOL_ERROR = 8

  • CODEPAGE = 9

  • OTHERS = 10

.

IF sy-subrc <> 0.

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

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

ENDIF.

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.

Reward if Useful.

Pavan

Former Member
0 Kudos

Hi Pallavi,

Driver program is also a normal program,which is to b created in SE38 or SE80.

But,in the driver program,u need to use some functions such as OPEN_FORM,WRITE_FORM,CLOSE_FORM etc.....

We've one option called Pattern in the tool bar,click that & type OPEN_FORM in that,then automatically the function comes into ur code.That function will have one importing parameter related to the Layoutset or Form.U just mention the form name over there,then automatically that form will b opened.Then use WRITE_FORM if u want to do some manipulations on that.

Finally dont forget to close the form using CLOSE_FORM.

Still if u've any doubts,just rply me,i'll give u sample code.

Reward Points if useful.

Pavan.

Former Member
0 Kudos

Hiii

u no need to write any driver program

SAP has provided each form layout with its own driver program

regards

Jaipal