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

sap script

Former Member
0 Likes
294

How can we use tables in sap scripts

2 REPLIES 2
Read only

Former Member
0 Likes
276

Hi,

It is not a problem to print table data in the main window of the script. Here is an example code snippet.

  • Populate internal table

SELECT * FROM <dbtab>

INTO TABLE itab

WHERE.................

CALL FUNCTION 'OPEN_FORM'

...............................................

...............................................

LOOP AT ITAB.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = ' '

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 'CLOSE_FORM'

.................................................

.................................................

In the script you can refer to this itab.

However the same process will not work for a variable window in script. This is because unlike the main window, whenever we call write_form FM for variable window, values are not mapped to script from print program immediately, but when

close_form/end_form FM is called. This means if we loop at an internal table from print progeam and call a variable window inside the loop, only the last row of internal table will be mapped to that variable window of the script.

For more info check this URL.

http://www.sap-img.com/sapscripts/faq-for-sap-scripts.htm

Regards

Read only

Former Member
0 Likes
276

refer

<b>material regd script</b>

http://www.sap-img.com/sapscripts.htm

http://www.sap-img.com/sapscripts/a-sample-sap-scripts-reports.htm

http://help.sap.com/saphelp_crm40/helpdata/en/16/c832857cc111d686e0000086568e5f/content.htm

<b>transporting a script</b>

<b>to test a script</b>

regards,

srinivas

<b>*reward for useful answers*</b>