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

stream of data in scripts

Former Member
0 Likes
1,019

hello friends,

for the print program below.....

when i execute it i am getting only one record in the layout. (supposed to get 5 records).

so i looped the write_form for main window.

when i do this i dont get any thing other than header and footer contents.

hope i am doing it in the right way.....

plz suggest me.....

REPORT ZNEW1 .

TABLES: MARA.

DATA: BEGIN OF ITAB OCCURS 10,

MATNR LIKE MARA-MATNR,

ERSDA LIKE MARA-ERSDA,

ERNAM LIKE MARA-ERNAM,

LAEDA LIKE MARA-LAEDA,

END OF ITAB.

SELECT * FROM MARA INTO CORRESPONDING FIELDS OF ITAB

WHERE VPSTA = 'KDALSBG'.

ENDSELECT.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

*DEVICE = ' '

  • DIALOG = 'X'

FORM = 'ZNEWLAY1'

LANGUAGE = SY-LANGU

EXCEPTIONS

OTHERS = 1.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'HEADER'

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

WINDOW = 'HEADER'

EXCEPTIONS

UNOPENED = 1

OTHERS = 2.

*LOOP AT ITAB.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'MAIN '

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

WINDOW = 'MAIN'

EXCEPTIONS

UNOPENED = 1

OTHERS = 2.

*ENDLOOP.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'FOOTER'

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

WINDOW = 'FOOTER'

EXCEPTIONS

UNOPENED = 1

OTHERS = 2.

CALL FUNCTION 'CLOSE_FORM'

EXCEPTIONS

UNOPENED = 1

OTHERS = 2.

hello friends,

for the print program below.....

when i execute it i am getting only one record in the layout. (supposed to get 5 records).

so i looped the write_form for main window.

when i do this i dont get any thing other than header and footer contents.

hope i am doing it in the right way.....

plz suggest me.....

REPORT ZNEW1 .

TABLES: MARA.

DATA: BEGIN OF ITAB OCCURS 10,

MATNR LIKE MARA-MATNR,

ERSDA LIKE MARA-ERSDA,

ERNAM LIKE MARA-ERNAM,

LAEDA LIKE MARA-LAEDA,

END OF ITAB.

SELECT * FROM MARA INTO CORRESPONDING FIELDS OF ITAB

WHERE VPSTA = 'KDALSBG'.

ENDSELECT.

CALL FUNCTION 'OPEN_FORM'

EXPORTING

*DEVICE = ' '

  • DIALOG = 'X'

FORM = 'ZNEWLAY1'

LANGUAGE = SY-LANGU

EXCEPTIONS

OTHERS = 1.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'HEADER'

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

WINDOW = 'HEADER'

EXCEPTIONS

UNOPENED = 1

OTHERS = 2.

*LOOP AT ITAB.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'MAIN '

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

WINDOW = 'MAIN'

EXCEPTIONS

UNOPENED = 1

OTHERS = 2.

*ENDLOOP.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'FOOTER'

  • FUNCTION = 'SET'

  • TYPE = 'BODY'

WINDOW = 'FOOTER'

EXCEPTIONS

UNOPENED = 1

OTHERS = 2.

CALL FUNCTION 'CLOSE_FORM'

EXCEPTIONS

UNOPENED = 1

OTHERS = 2.

7 REPLIES 7
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
901

Your LOOP and ENDLOOP are commented out.

Regards,

Rich Heilman

Read only

0 Likes
901

Hi,

Your loop should be like this:

LOOP AT ITAB.

CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'MAIN '
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'MAIN'
EXCEPTIONS
UNOPENED = 1
OTHERS = 2.

ENDLOOP.

Regards,

Ville

Read only

0 Likes
901

When writing multiple records, make sure that you have setup an element in your MAIN window of the sapscript.

/E  THE_ELEMENT_NAME
PF  &ITAB-FIELDA&,,&ITAB-FIELDB&

LOOP AT ITAB.


CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'THE_ELEMENT_NAME'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'MAIN'
EXCEPTIONS
UNOPENED = 1
OTHERS = 2.



ENDLOOP.

Regards,

Rich Heilman

Read only

0 Likes
901

i am trying to say that, when i have not looped it i am getting one record in the layout. but when i looped write_form......i am not getting anything in the layout other than header and footer content.

my loop isn't working when i have uncommented it.

Read only

0 Likes
901

That's because you are not adding anything to the internal table only the header line of ITAB. Change your select statement to be like this.




SELECT * FROM MARA 
     INTO CORRESPONDING FIELDS OF <b>TABLE ITAB</b>
                WHERE VPSTA = 'KDALSBG'.

Get rid of ENDSELECT.

Then it should all work.

Please don't forget to award points accordingly. Thanks.

Regards,

Rich Heilman

Read only

0 Likes
901

Thanks Rich.

It worked.

Read only

0 Likes
901

Please mark this post as being solved. Thanks.

Regards,

Rich Heilman