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

Loop in sapscript

Former Member
0 Likes
1,902

Hi All,

Can we use loop in sapscript editor,if yes then plz tell me how.

Thanks in advance

2 REPLIES 2
Read only

Former Member
0 Likes
1,106

Hi,

The LOOP logic of a SAPscript is held in the print program, not the form. Your ABAP print program will typically extract the data, open the form, loop through the data, call elements in the main window then close the form.

There is no LOOP statement in SAPscript.

Regards,

Shiva Kumar

Read only

Former Member
0 Likes
1,106

Hi Sheelesh,

See below it..

You find loop statement in sapscript.

REPORT ZSUR9.

TABLES:ZST2.

DATA: LANG LIKE SY-LANGU.

Data: itab LIKE zst2 OCCURS 0 WITH HEADER LINE.

select * from zst2 into TABLE itab.

call function 'OPEN_FORM'

EXPORTING

DEVICE = 'PRINTER'

DIALOG = 'X'

FORM = 'ZFORM4'

LANGUAGE = LANG

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.

call function 'WRITE_FORM'

EXPORTING

ELEMENT = 'ZS1'

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.

LOOP at itab.

call function 'WRITE_FORM'

EXPORTING

ELEMENT = 'ZS2'

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 .

ENDLOOP.

call function 'CLOSE_FORM'

EXCEPTIONS

UNOPENED = 1

BAD_PAGEFORMAT_FOR_PRINT = 2

SEND_ERROR = 3

SPOOL_ERROR = 4

CODEPAGE = 5 .

Reward if useful,

Regards,

S.Suresh.