cancel
Showing results for 
Search instead for 
Did you mean: 

Why only the last records printed?

former_member208517
Participant
0 Kudos

I programed a simple driver program for a form to show the item info a Sales order, but on the output of the form, only the last item's information will be printed for line count's time. Who knows the reason?

SELECT *

INTO TABLE it_VBAP

FROM VBAP

WHERE VBELN = I_VBELN.

CLEAR VBAP.

  • FILL ITCPO

CLEAR itcpo.

itcpo-tdpageslct = space. "all pages

itcpo-tdnewid = 'X'. "create new spool dataset

itcpo-tdcopies = 1. "one copy

itcpo-tddest = NAST-LDEST. "name of printer

itcpo-tdpreview = space. "no preview

itcpo-tdcover = space. "no cover page

  • itcpo-tddataset = p_tddataset. "dataset name

itcpo-tdsuffix1 = NAST-LDEST. "name or printer

  • itcpo-tdsuffix2 = par_vari. "name of report variant

itcpo-tdimmed = ''. "print immediately?

itcpo-tddelete = space. "do not delete after print

  • itcpo-tdtitle = t042z-text1. "title of pop-up-window

  • itcpo-tdcovtitle = t042z-text1. "title of print-cover

itcpo-tdautority = ''. "print authority

itcpo-tdarmod = ''. "print only

CALL FUNCTION 'OPEN_FORM'

EXPORTING

archive_index = toa_dara

archive_params = arc_params

form = 'ZTEST'

device = 'PRINTER'

language = NAST-SPRAS

OPTIONS = itcpo

dialog = 'X'

EXCEPTIONS

CANCELED = 1

DEVICE = 2

FORM = 3

OPTIONS = 4

UNCLOSED = 5

MAIL_OPTIONS = 6

ARCHIVE_ERROR = 7

OTHERS = 8.

IF sy-subrc EQ 1. "abend:

ENDIF.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

window = 'ZTEST2'

EXCEPTIONS

window = 1

element = 2.

loop at it_vbap into VBAP.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = '525'

FUNCTION = 'APPEND'

TYPE = 'BODY'

WINDOW = 'MAIN'

EXCEPTIONS

window = 1

element = 2.

endloop.

CALL FUNCTION 'CLOSE_FORM'

EXCEPTIONS

OTHERS = 1.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

I'd try putting a breakpoint inside the "loop at it_vbap into VBAP" to see that VBAP is being populated correctly.

How did you define VBAP in the program? It should be a line, not a table.

former_member208517
Participant
0 Kudos

VBAP is a line. I used TABLES:VBAP. to announce it.

Former Member
0 Kudos

Hello,

I'm not entirely sure what you mean by "only the last item's information will be printed for line count's time" but if you mean it's printing the same information multiple times I'd look at the SAPScript element 525 and make sure you're using VBAP and not IT_VBAP.

Regards,

Michael

former_member208517
Participant
0 Kudos

Hi Michael,

I do use the VBAP rather than the IT_VBAP.

This is what in the main window:

/E 525

T1 &VBAP-POSNR&,,&VBAP-MATNR&

Kangbo.

Former Member
0 Kudos

HI,

did u debug the program & checked how many records u get in it_vbap ?

chk wat the height of the main window, if less increase

Edited by: Madhukar Shetty on Jun 4, 2010 2:05 PM

former_member208517
Participant
0 Kudos

It is only a test program.

there is nothing but the following in the main window.

/E 525

T1 &VBAP-POSNR&,,&VBAP-MATNR&

I've debuged the driver proram, there are for records, it supposed to print like:

000010 ISU_TEST

000020 ISU_FLOWER

000030 ISU_TEST

000040 ISU_FLOWER

But now, it always print like:

000040 ISU_FLOWER

000040 ISU_FLOWER

000040 ISU_FLOWER

000040 ISU_FLOWER

Former Member
0 Kudos

I'd try putting a breakpoint inside the "loop at it_vbap into VBAP" to see that VBAP is being populated correctly.

How did you define VBAP in the program? It should be a line, not a table.

Former Member
0 Kudos

I'd try putting a breakpoint inside the "loop at it_vbap into VBAP" to see that VBAP is being populated correctly.

How did you define VBAP in the program? It should be a line, not a table.

Former Member
0 Kudos

I'd try putting a breakpoint inside the "loop at it_vbap into VBAP" to see that VBAP is being populated correctly.

How did you define VBAP in the program? It should be a line, not a table.