cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding how to use the function module *control_form* in scripts

Former Member
0 Kudos

HI friends,

Can any one tell why and where do we use the function module control_form in scripts. Can you give me a small scenario how to use in scripts.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member

hi satish,

by using this function module we can pass the control

commands to FORM THROUGH ABAP/4 PROGRAM.

see the following example:

TABLES: kna1.

DATA: BEGIN OF it_kna1 OCCURS 0,

kunnr LIKE kna1-kunnr,

name1 LIKE kna1-name1,

ort01 LIKE kna1-ort01,

land1 LIKE kna1-land1,

END OF it_kna1.

DATA:records TYPE i,

window TYPE i value 1.

select-options:s_kunnr for kna1-kunnr.

SELECT kunnr name1 ort01 land1 FROM kna1 INTO TABLE it_kna1

where kunnr in s_kunnr.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

form = 'ZSCRIPT4'

language = sy-langu.

LOOP AT it_kna1.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'ELE1'

function = 'SET'

type = 'BODY'

window = 'MAIN'.

DESCRIBE TABLE it_kna1 LINES records.

IF window lt records.

window = window + 1.

CALL FUNCTION 'CONTROL_FORM'

EXPORTING

command = 'NEW-WINDOW'

  • EXCEPTIONS

  • UNOPENED = 1

  • UNSTARTED = 2

  • OTHERS = 3

.

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.

thanks,

raji

Former Member
0 Kudos

answered

Former Member
0 Kudos

hi

CONTROL_FORM: Use this function module to pass SAP Script Control Commands to the layout set. The Control command is passed through the export parameter u2018COMMANDu2019 in quotes.

Regards,

sre

Former Member
0 Kudos

hi,

Use CONTROL_FORM to pass SAPscript control statements to the layout set.

Function call:

CALL FUNCTION 'CONTROL_FORM'

EXPORTING COMMAND = ?...

EXCEPTIONS UNOPENED =

UNSTARTED =

Export parameters:

COMMAND Enter the SAPscript statement you want to execute in ITF format, but without the statement paragraph attribute '/:'.

Exceptions:

UNOPENED The current layout set function could not be executed, since the layout set output was no yet initialized using OPEN_FORM.

UNSTARTED No layout set was opened yet.Possible reasons:

u2022 The layout set processing was started using OPEN_FORM without specifying a layout set name, but no layout set was opened yet using START_FORM.

u2022 The last used layout set was closed using END_FORM, but no new layout set was opened using START_FORM.

u2022 The last filled page of the current layout set has no subsequent page. In this case, the system automatically terminates layout set printing after this page. You need no explicit END_FORM call.

u2022 In the current layout set, no page contains a main window, but a text element shall be output in the main window.

reward me if helpful.