Skip to Content
0
Former Member
Sep 16, 2005 at 11:20 AM

SAP Script: Loop write only last record

113 Views

Hi

I have been searching and searching, but haven't find anything usefull.

I have a script where I wan't to print different matnr.

From my printprogram I have an internal table with 2 entries.

When I make the print, it is allways the last entries from the internal table that are printed - in both the window for entry no 1 and in the window for entry no 2.

The code in my print program looks like this:


Code: 

  LOOP AT g_caufv_tab. 

    CASE l_count. 

      WHEN 0. 

        CALL FUNCTION 'WRITE_FORM' 
             EXPORTING 
                  element = 'DESCR' 
                  window  = 'TEXT'. 

        CALL FUNCTION 'WRITE_FORM' 
             EXPORTING 
                  element = 'BARCODE_OUT' 
                  window  = 'BARCL'. 

      WHEN 1. 

        CALL FUNCTION 'WRITE_FORM' 
             EXPORTING 
                  element = 'DESCR' 
                  window  = 'TEXT1'. 

        CALL FUNCTION 'WRITE_FORM' 
             EXPORTING 
                  element = 'BARCODE_OUT' 
                  window  = 'BARCL1'. 

      WHEN 2. 

        CALL FUNCTION 'WRITE_FORM' 
             EXPORTING 
                  element = 'DESCR' 
                  window  = 'TEXT2'. 

        CALL FUNCTION 'WRITE_FORM' 
             EXPORTING 
                  element = 'BARCODE_OUT' 
                  window  = 'BARCL2'. 

      WHEN 3. 

        CALL FUNCTION 'WRITE_FORM' 
             EXPORTING 
                  element = 'DESCR' 
                  window  = 'TEXT'. 

        CALL FUNCTION 'WRITE_FORM' 
             EXPORTING 
                  element = 'BARCODE_OUT' 
                  window  = 'BARCL3'. 

      WHEN OTHERS. 

    ENDCASE. 

    ADD 1 TO l_count. 

  ENDLOOP. 

When I am debugging mode (both in printprogram and Scrip) are looking at my material number, it has the right no. First time Matnr A, and then Matnr B.

Any suggestions ??!!