Application Development and Automation 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: 
Read only

multiple forms

Former Member
0 Likes
1,269

hi friends,

can we call multiple forms in scripts

if we can do then how to do that.

could u plz give sample code for this

regards,

malleswari.

1 ACCEPTED SOLUTION
Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
1,226

Hi,

We can call multiple forms in scripts based on say COndition type or output type.

10 REPLIES 10
Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
1,227

Hi,

We can call multiple forms in scripts based on say COndition type or output type.

Read only

0 Likes
1,226

could u plz tell me a litle clearly

Read only

0 Likes
1,226

hi Malleswari,

You can use FMs START_FORM and END_FORM for printing different forms in a single Print program.

OPEN_FORM

START_FORM <form1>

END_FORM

START_FORM <form2>

END_FORM

CLOSE_FORM

Reg

Vivek

Reward if helps.

Read only

Former Member
0 Likes
1,226

Hi,

U can call multiple forms with in a script.

You can have any number for WRITE_FORM, START_FORM and END_FORM, but for a script you can have only one OPEN_FORM and CLOSE_FORM.

1. Normally, START_FORM

is not required.

(OPEN_FORM Is compulary in all cases)

2. Its only required,

when we want to different sapscript layouts,

to get merged,

and come in one output.

3. For this purpose,

we use START_FORM,

to START layout 1,

then START Layout 2.

so, u can write multiple start_forms to call multiple forms..

Regards,

Kumar

Read only

Former Member
0 Likes
1,226

hi

try like this

open_form.

start_form.

write_form

end_form.

start_form.

write_form

end_form.

close_form.

regards

shiba dutta

Read only

0 Likes
1,226

hi thank u,

how do we need to write driver program for this

do qwe need to write for each and every form.

regards,

malleswari.

Read only

Former Member
0 Likes
1,226

Hi,

I am not very sure about what you intend to do??

Do you want to call more than 2 scripts in the same print program?

Nishant

Read only

Former Member
0 Likes
1,226

Hi

Try out the following code where i am calling 2 scripts in one driver program based on some conditions.

TABLES : VBAK,VBAP.

DATA : BEGIN OF IT_SALESH_DATA OCCURS 0,

VBELN LIKE VBAK-VBELN,

ERDAT LIKE VBAK-ERDAT,

ERNAM LIKE VBAK-ERNAM,

POSNR LIKE VBAP-POSNR,

MATNR LIKE VBAP-MATNR,

END OF IT_SALESH_DATA.

SELECTION-SCREEN : BEGIN OF SCREEN 100.

SELECT-OPTIONS : S_VBELN FOR VBAK-VBELN,

S_POSNR FOR VBAP-POSNR.

SELECTION-SCREEN : END OF SCREEN 100.

CALL SCREEN 100.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

DEVICE = 'PRINTER'

DIALOG = 'X'

FORM = 'ZSALES_ORDER'

LANGUAGE = SY-LANGU

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 S_VBELN-LOW <> '' OR S_VBELN-HIGH <> ''.

SELECT

VBELN

ERDAT

ERNAM

FROM VBAK

INTO CORRESPONDING FIELDS OF TABLE IT_SALESH_DATA

WHERE VBELN IN S_VBELN.

CALL FUNCTION 'START_FORM'

EXPORTING

FORM = 'ZSALES_ORDER'

LANGUAGE = SY-LANGU

STARTPAGE = 'FIRST'

EXCEPTIONS

FORM = 1

FORMAT = 2

UNENDED = 3

UNOPENED = 4

UNUSED = 5

SPOOL_ERROR = 6

CODEPAGE = 7

OTHERS = 8.

LOOP AT IT_SALESH_DATA.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

FUNCTION = 'SET'

TYPE = 'BODY'

WINDOW = 'MAIN'

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.

ENDLOOP.

CALL FUNCTION 'END_FORM'

.

ELSEIF S_POSNR-LOW <> '' OR S_POSNR-HIGH <> ''.

SELECT

POSNR

MATNR

FROM VBAP

INTO CORRESPONDING FIELDS OF TABLE IT_SALESH_DATA

WHERE POSNR IN S_POSNR.

CALL FUNCTION 'START_FORM'

EXPORTING

FORM = 'ZSALES_ORDER'

LANGUAGE = SY-LANGU

STARTPAGE = 'NEXT'

EXCEPTIONS

FORM = 1

FORMAT = 2

UNENDED = 3

UNOPENED = 4

UNUSED = 5

SPOOL_ERROR = 6

CODEPAGE = 7

OTHERS = 8

.

LOOP AT IT_SALESH_DATA.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

FUNCTION = 'SET'

TYPE = 'BODY'

WINDOW = 'MAIN'

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.

ENDLOOP.

CALL FUNCTION 'END_FORM'

.

ENDIF.

IF S_VBELN-LOW <> '' OR S_VBELN-HIGH <> ''.

IF S_POSNR-LOW <> '' OR S_POSNR-HIGH <> ''.

MESSAGE I000(ZMSG1) WITH 'Enter only one select option data'.

ENDIF.

ELSEIF S_POSNR-LOW <> '' OR S_POSNR-HIGH <> ''.

IF S_VBELN-HIGH <> '' OR S_VBELN-LOW <> ''.

MESSAGE E000(ZMSG1) WITH 'Enter only one select option data'.

ENDIF.

ENDIF.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

DEVICE = 'PRINTER'

DIALOG = 'X'

FORM = 'ZSALES_ORDER'

LANGUAGE = SY-LANGU

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 S_VBELN-LOW <> '' OR S_VBELN-HIGH <> ''.

SELECT

VBELN

ERDAT

ERNAM

FROM VBAK

INTO CORRESPONDING FIELDS OF TABLE IT_SALESH_DATA

WHERE VBELN IN S_VBELN.

CALL FUNCTION 'START_FORM'

EXPORTING

FORM = 'ZSALES_ORDER'

LANGUAGE = SY-LANGU

STARTPAGE = 'FIRST'

EXCEPTIONS

FORM = 1

FORMAT = 2

UNENDED = 3

UNOPENED = 4

UNUSED = 5

SPOOL_ERROR = 6

CODEPAGE = 7

OTHERS = 8.

LOOP AT IT_SALESH_DATA.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

FUNCTION = 'SET'

TYPE = 'BODY'

WINDOW = 'MAIN'

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.

ENDLOOP.

CALL FUNCTION 'END_FORM'

.

ELSEIF S_POSNR-LOW <> '' OR S_POSNR-HIGH <> ''.

SELECT

POSNR

MATNR

FROM VBAP

INTO CORRESPONDING FIELDS OF TABLE IT_SALESH_DATA

WHERE POSNR IN S_POSNR.

CALL FUNCTION 'START_FORM'

EXPORTING

FORM = 'ZSALES_ORDER'

LANGUAGE = SY-LANGU

STARTPAGE = 'NEXT'

EXCEPTIONS

FORM = 1

FORMAT = 2

UNENDED = 3

UNOPENED = 4

UNUSED = 5

SPOOL_ERROR = 6

CODEPAGE = 7

OTHERS = 8

.

LOOP AT IT_SALESH_DATA.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

FUNCTION = 'SET'

TYPE = 'BODY'

WINDOW = 'MAIN'

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.

ENDLOOP.

CALL FUNCTION 'END_FORM'

.

ENDIF.

CALL FUNCTION 'CLOSE_FORM'

Regards

Haritha.

Read only

0 Likes
1,225

thank u Haritha

Read only

Former Member
0 Likes
1,225

yes you have to use write_form for every individual form.

regards

shiba dutta