cancel
Showing results for 
Search instead for 
Did you mean: 

Script Issue while printing Internal table.

Former Member
0 Kudos

Hi,

I am trying to print an internal table. I want to print all rows of that internal table.

I am calling write_form FM between loop - endloop.

When I am looking at that form, Its only printing the last row of that Internal table.

Can any body Plz help ?

Regards,

Nikita GIradkar.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Nikita,

Ok, silly question: The internal table you're trying to print, is it going into the MAIN window or into a window of type VAR (or CONST)?

I'd suspect it goes into the MAIN window, but if you try printing a table in a VAR/CONST window, your print program should make sure to use the parameter FUNCTION = 'APPEND' in the corresponding call of WRITE_FORM where you populate the data (default is 'SET', so the data should be overwritten each time you call <i>WRITE_FORM</i>).

For the MAIN window output area BODY my comment would be useless, because there you can only APPEND...

Cheers, harald

Former Member
0 Kudos

Thanks a lot.

Actually I am not that familiar with Script.

I did the same.

Now suppose my Internal table is having 4 Lines, its pritning Last row 4 times.

Can u plz help.

Regards,

Nikita.

Former Member
0 Kudos

Hhmmm, sounds weird. Can you please check where you print the data, i.e. is it MAIN window (parameter WINDOW) and which output area (parameter TYPE)? If you're printing in MAIN/BODY it should just work fine.

I must admit that I've never printed multiple rows using APPEND in another window. It sounded like it should work, but maybe the way the SAPscript engine processes the data causes the problem that you're seeing.

Only other thing I can think of at the moment is that your SAPscript should have the data grouped under an ELEMENT (so SAPscript should have the /E heading and you should write to that specific element in WRITE_FORM.

Former Member
0 Kudos

I am sending the code used by me.

If you can really help me out, I would be very greatful.

I am not using Main window.

If you want any more Information I can give it to you.

CALL FUNCTION 'START_FORM'

EXPORTING

  • ARCHIVE_INDEX =

  • FORM = 'YPOEMAIL_DEVELOP1' "'YPOEMAIL_DEVELOP'

FORM = 'YPOEMAIL_DEVELOP'

LANGUAGE = SY-LANGU

STARTPAGE = 'PAGE7'

  • PROGRAM = 'YM04_DEVELOP1'

  • MAIL_APPL_OBJECT =

  • IMPORTING

  • LANGUAGE =

EXCEPTIONS

FORM = 1

FORMAT = 2

UNENDED = 3

UNOPENED = 4

UNUSED = 5

SPOOL_ERROR = 6

CODEPAGE = 7

OTHERS = 8

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CLEAR : EKPO.

SELECT * FROM EKPO WHERE EBELN = ekko-ebeln.

CONCATENATE EKPO-ebeln EKPO-ebeLP INTO HDTEXT.

  • CLEAR TLINES.

  • REFRESH TLINES.

CALL FUNCTION 'READ_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = 'F03'

LANGUAGE = SY-LANGU

NAME = HDTEXT

OBJECT = 'EKPO'

  • ARCHIVE_HANDLE = 0

  • importing

  • header = thead

TABLES

LINES = TLINES

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

NOT_FOUND = 4

OBJECT = 5

REFERENCE_CHECK = 6

WRONG_ACCESS_TO_ARCHIVE = 7

OTHERS = 8.

LOOP AT TLINES.

ITEMLINE1 = TLINES-TDLINE.

PERFORM WRITE_FORM USING 'TERMSNCOND' 'APPEND' 'BODY' 'WINDOW12'.

  • PERFORM NEW-line.

ENDLOOP.

clear : tlines.

REFRESH : tlines.

ENDSELECT.

CALL FUNCTION 'END_FORM'

  • IMPORTING

  • RESULT =

EXCEPTIONS

UNOPENED = 1

BAD_PAGEFORMAT_FOR_PRINT = 2

SPOOL_ERROR = 3

CODEPAGE = 4

OTHERS = 5

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

FORM WRITE_FORM USING A B C D.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = A

FUNCTION = B

TYPE = C

WINDOW = D

  • importing

  • PENDING_LINES =

EXCEPTIONS

ELEMENT = 1

FUNCTION = 2

TYPE = 3

UNOPENED = 4

UNSTARTED = 5

WINDOW = 6

BAD_PAGEFORMAT_FOR_PRINT = 7

OTHERS = 8.

ENDFORM. " WRITE_FORM

Scritp Code :

/E TERMSNCOND

* &ITEMLINE1&

/E END OF TERMSNCOND

Thanks & Regards,

Nikita.

Former Member
0 Kudos

Ok, so in your special case I'd say let's skip the problem and simplify the processing by using the appropriate SAPscript commands. You can include other SAPscript texts (i.e. the ones that you're retrieving via function module READ_TEXT) via the SAPscript command [INCLUDE|http://help.sap.com/saphelp_nw70/helpdata/en/d1/80321e454211d189710000e8322d00/frameset.htm].

So within your print program build the object ID HDTEXT via purchase order number and line. Then remove all coding for function call to READ_TEXT and the loop and instead call only once the output for your form element TERMSNCOND. Your SAPscript should have the following line (instead of the

  • &ITEMLINE1&
😞


INCLUDE &HDTEXT& OBJECT EKPO ID F03.

I'd expect that this should solve your problem.

P.S.: I hope I got the syntax right, because I think there's no quotes around the object and ID (i.e. what I listed instead of <i>OBJECT 'EKPO' ID 'F03'</i>).

If you want some examples from SAP you can also look at form MEDRUCK. Then in SE71 use the menu entry <i>Utilities -> Form info</i> and search for <i>INCLUDE</i>. This will show you several places where SAP also included standard text objects...

Former Member
0 Kudos

Hiii,

Thanks a lot. I have done the same coding. Its working fine,

But there is 1 issue over it.

Suppose my PO contains 3 items. In that case the Item PO text of Last Material no is

getting Printed Thrice. I have checked coding, The HDTEXT value is varying according to each Material PO

No. Its over writting the content. I think I am losing some basic.

Can you please guide.

Regards,

Nikita Giradkar.

Edited by: nikita_giradkar02 on Mar 9, 2010 6:34 AM

Former Member
0 Kudos

Ok, now on second thought I'm wondering how your SAPscript form looks like. You said you're not using the MAIN window, but you're actually printing out item information. This sounds highly unusual, because the MAIN window should contain the bulk of the information, other windows are used for header, footer etc.

So just to be sure we're on the same page. When you look at your SAPscript and go to Page windows and doubleclick on the window where you're outputting the duplicate data. What type do you see at the bottom in the field <i>Window type</i>? I'd expect this to be MAIN.

Former Member
0 Kudos

Its 'VAR'.

thanks & Regards,

Nikita Giradkar.

Former Member
0 Kudos

Not sure if I'm off here, but I wonder if you'd see the expected results when you'd output the data in a window of type MAIN. Only idea I have at the moment is to check what happens when you add the text include's in your MAIN window and then call this from the print program. Maybe anybody else has some better ideas?

Maybe we're missing something really simple here. I must admit I'm a bit rusty on SAPscript, because it's been a while... (and it's one of those skills you rather forget, because you don't really want to keep doing forms)

Former Member
0 Kudos

Thanks,

No issues. Its ok. What right now I did is I tried printing Material text of each Item at different pages.

That is working fine.

So right now I am getting ahead with that.

Anyways Thankyou very much for your support.

I am here closing this Issue.

Thanks & Regards,

Nikita Giradkar.

Answers (0)