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 inside a Script editor

Former Member
0 Likes
817

Hi all,

1) Is it posible to use a loop a inside a sap script editor..if program symbol is internal table with text how to display that..

2) How to create dynamic variables

Thank you,

4 REPLIES 4
Read only

Former Member
0 Likes
668

Hi,

It is not possible to use a LOOP inside the script, insted, you can write a PERFORM and ENDPERFORM using a PROGRAM, and inside that Program you can use the LOOP statment.

you can create a Dynamic Varible using DEFINE statment

Regards

Sudheer

Read only

Former Member
0 Likes
668

Hi,

You can't use LOOP... ENDLOOP inside script editor.

Only in program you have to use them and that loop data will come to Script.

You can define variable like:

/: DEFINE &V_TEXT& = 'SAPSCRIPT'

write

/ &V_TEXT&

reward if useful

regards,

Anji

Read only

Former Member
0 Likes
668

Hi Haritha,

Yes it is possible to do so.

LOOP

...

...

...

..

..

..

ENDLOOP.

Dynamic Varible also using DEFINE statement in script.

<b>Reward if helpful.</b>

Regards,

V.Raghavender.

Read only

Former Member
0 Likes
668

Hai,

Here is the solution for ur problem.

In your Print Program(REPORT) write like:

CALL FUNCTION 'OPEN_FORM'

EXPORTING

  • APPLICATION = 'TX'

  • ARCHIVE_INDEX =

  • ARCHIVE_PARAMS =

  • DEVICE = 'PRINTER'

  • DIALOG = 'X'

FORM = 'YH650_060203'

  • 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. " IF SY-SUBRC <> 0.

<b>LOOP AT T_EMP INTO FS_EMP.</b>

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'DATA'

  • FUNCTION = 'SET'

  • 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. " IF SY-SUBRC <> 0.

  • ADD FS_EMP-SALARY TO W_F_TOTAL.

  • ADD FS_EMP-SALARY TO W_P_TOTAL.

  • ADD FS_EMP-SALARY TO W_G_TOTAL.

<b>ENDLOOP. </b> " LOOP AT T_EMP INTO FS_EMP.

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. " IF SY-SUBRC <> 0.

In your script write:

/: &FS_EMP-FIELD1& &FS_EMP-FIELD2& &FS_EMP-FIELD3& ...

OR &W_TOTAL& = &W_TOTAL& + &FS_EMP-FIELD1& etc what ever you want...

So now you can work with all the internal table data.

Hope you got solution.

<b>Reward points if it helps you.</b>

Regds,

Rama.Pammi