GETWA_TOO_MANY_SEGMENTS

We are using BAPI   'BAPI_INCOMINGINVOICE_CREATE' to post invoices in our system with the help of file record sent by 3rd party. This is done via background job. It runs successful few days and failes on a regular basis throwing error '  GETWA_TOO_MANY_SEGMENTS '
Below is the  Code written for the same. Can some one point out how to rectify this....
  LOOP AT it_po_head.
    REFRESH: itemdata.
    CLEAR: header,itemdata,invoice,year,counter.
    REFRESH: return. CLEAR: return.
    REFRESH:taxdata.
    CLEAR: taxdata.
    IF it_po_head-blart = 'I'.
      header-doc_type = 'RE'.
      header-invoice_ind = 'X'.
    ELSEIF it_po_head-blart = 'C'.
      header-doc_type = 'KG'.
      header-invoice_ind = ' '.
    ENDIF.
    header-doc_date  = it_po_head-bldat.
    header-pstng_date = it_po_head-budat.
    header-ref_doc_no = it_po_head-xblnr.
    header-comp_code = it_po_head-bukrs.
    header-diff_inv = it_po_head-lifnr.
    header-currency = it_po_head-waers.
    header-gross_amount = it_po_head-rmwwr.
    header-pymt_meth = it_po_head-zlsch.
    IF it_po_head-wmwst1 <> 0.
     taxdata-tax_code = 'I0'.
      taxdata-tax_amount = it_po_head-wmwst1.
      APPEND taxdata. CLEAR taxdata.
    ENDIF.
    LOOP AT it_po_item WHERE catid = it_po_head-catid.
      CLEAR: w_meins, w_bprme, w_isocode.
******Code added by Dimple on 06/26/2008 for Ticket-508381.
      CLEAR: w_menge, wa_percost, wa_cost,wa_item_menge.
      CLEAR: wa_invamount, wa_invquantity.
******End of code added.
      counter = counter + 1.
      itemdata-invoice_doc_item = counter.
      itemdata-po_number = it_po_item-ebeln.
      itemdata-po_item = it_po_item-ebelp.
      itemdata-item_amount  = it_po_item-rmwwr.
      itemdata-quantity = it_po_item-menge.
******Code added by Dimple on 06/26/2008 for Ticket-508381.
******Calculate total invoice amount and total invoice quantity
******from Purchasing Document History.
      IF it_po_head-blart = 'C'.
      LOOP AT it_ekbe WHERE ebeln = it_po_item-ebeln
                      AND   ebelp = it_po_item-ebelp.
        MOVE: it_ekbe-menge TO w_menge,
              it_ekbe-wrbtr TO w_wrbtr1.
        IF it_ekbe-shkzg = 'S'.
          wa_quantity =  wa_quantity + w_menge.
          wa_amount   =  wa_amount + w_wrbtr1.
        ELSEIF it_ekbe-shkzg = 'H'.
          wa_quantity =  wa_quantity - w_menge.
          wa_amount   =  wa_amount - w_wrbtr1.
        ENDIF.
        CLEAR: w_menge, w_wrbtr1, it_ekbe.
      ENDLOOP.
      wa_invamount = wa_amount.
      wa_invquantity = wa_quantity.
      CLEAR: wa_amount,wa_quantity.
      wa_item_menge = it_po_item-menge .
******Logic added to post SD-L item.
      IF ( wa_item_menge <= wa_invquantity ) .
        IF ( wa_item_menge = wa_invquantity ).
          IF ( it_po_item-rmwwr < wa_invamount ).
            itemdata-de_cre_ind = 'X'.
          ELSEIF ( it_po_item-rmwwr = wa_invamount ).
            itemdata-de_cre_ind = ''.
          ENDIF.
        ELSEIF ( wa_item_menge < wa_invquantity ).
          wa_percost = ( wa_invamount / wa_invquantity ).
          wa_cost = ( wa_item_menge * wa_percost ).
          IF ( it_po_item-rmwwr < wa_cost ).
            itemdata-de_cre_ind = 'X'.
          ELSEIF ( it_po_item-rmwwr = wa_cost ).
            itemdata-de_cre_ind = ''.
          ENDIF.
        ENDIF.
      ENDIF.
ENDIF.
******End of code added.
****Reference Doc detail
      IF NOT it_po_item-belnr IS INITIAL.
        itemdata-ref_doc = it_po_item-belnr.
        SELECT SINGLE gjahr buzei FROM ekbe INTO (w_gjahr, w_buzei)
        WHERE ebeln = it_po_item-ebeln
          AND ebelp = it_po_item-ebelp
          AND belnr = it_po_item-belnr.
        itemdata-ref_doc_year = w_gjahr.
        itemdata-ref_doc_it = w_buzei.
      ENDIF.
Get the unit from the purchase order item table
****Unit of Measure
      SELECT SINGLE meins bprme FROM ekpo INTO (w_meins, w_bprme)
        WHERE ebeln = it_po_item-ebeln
          AND ebelp = it_po_item-ebelp.
      itemdata-po_unit = w_meins.
****ISO code
      SELECT SINGLE isocode  FROM t006 INTO w_isocode
      WHERE msehi = w_meins.
      itemdata-po_unit_iso = w_isocode.
      CLEAR w_isocode.
      SELECT SINGLE isocode  FROM t006 INTO w_isocode
      WHERE msehi = w_bprme.
      itemdata-po_pr_uom_iso = w_isocode.
      itemdata-po_pr_uom = w_bprme.
      APPEND itemdata.
      CLEAR itemdata.
    ENDLOOP.
    IF NOT header IS INITIAL.
      CLEAR: w_lifnr.
     select single lifnr from ekko into w_lifnr
     where ebeln = it_po_head-ebeln.
****Check for Vendor head office
*****If head office exist the consider the head office for checking the
*****duplicate record else consider the vendor(invoicing party).
     if not w_lifnr is initial.
      SELECT SINGLE lnrze FROM lfb1 INTO w_lnrze
      WHERE lifnr = header-diff_inv
      AND bukrs = header-comp_code.
      IF NOT w_lnrze IS INITIAL.
        w_lifnr = w_lnrze.
      ELSE.
        w_lifnr = header-diff_inv.
      ENDIF.
     endif.
****Check duplicate Invoice
     w_lifnr = header-diff_inv.
      w_wrbtr = header-gross_amount.
      w_bukrs = header-comp_code.
      w_waers = header-currency.
      w_bldat = header-doc_date.
      w_xblnr = header-ref_doc_no.
      CALL FUNCTION '2054_TRANSLATE_2_UPPERCASE'
           EXPORTING
                i_string = w_xblnr
           IMPORTING
                e_string = w_xblnr.
      CALL FUNCTION 'Z_BAPI_FI_DUPLICATE_INV_CHECK'
           EXPORTING
                i_bukrs = w_bukrs
                i_lifnr = w_lifnr
                i_waers = w_waers
                i_bldat = w_bldat
                i_xblnr = w_xblnr
                i_wrbtr = w_wrbtr
                i_reprf = 'X'
                i_shkzg = '0'
           IMPORTING
                return  = return2.
****If duplicate invoice exist the create log else create new invoice
      IF return2-message_v1 IS INITIAL.
        REFRESH : return. CLEAR: return,errlines.
        CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'
             EXPORTING
                  headerdata       = header
             IMPORTING
                  invoicedocnumber = invoice
                  fiscalyear       = year
             TABLES
                  itemdata         = itemdata
                  taxdata          = taxdata
                  return           = return.
        DESCRIBE TABLE return LINES errlines.
        IF errlines = 0.
Call the transaction commit only if the function module is successful
          CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
               EXPORTING
                    wait   = 'X'
               IMPORTING
                    return = commit_return.
          DESCRIBE TABLE commit_return LINES commiterr.
****Create Message and update Catalyst ID
          PERFORM create_message.
        ELSE.
          LOOP AT return.
            CONCATENATE it_po_head-catid '|' return-type '|'
                       return-message ' for po->'
                       it_po_head-ebeln INTO it_message-text.
            APPEND it_message.CLEAR it_message.
          ENDLOOP.
        ENDIF.
      ELSE.
        CONCATENATE it_po_head-catid '|' 'E' '|'
                   return2-message_v1 ' for po->'
                   it_po_head-ebeln INTO it_message-text.
        APPEND it_message.CLEAR: it_message, return2.
      ENDIF.
    ENDIF.
  ENDLOOP.

The Job Log Shows
05/18/2009 22:36:22 House bank ID  does not exist for company code 0120                        
05/18/2009 22:36:24 EN-Non-Standard Mac 2645849 has been saved                                 
05/18/2009 22:36:25 Payee  is not defined for account 17646 0120                               
05/18/2009 22:36:25 House bank ID  does not exist for company code 0120                        
05/18/2009 22:36:27 EN-Non-Standard Mac 2645760 has been saved                                 
05/18/2009 22:36:28 Payee  is not defined for account 17646 0120                               
05/18/2009 22:36:28 House bank ID  does not exist for company code 0120                        
05/18/2009 22:36:30 EN-Non-Standard Mac 2645950 has been saved                                 
05/18/2009 22:36:31 Payee  is not defined for account 1007972 0120                             
05/18/2009 22:36:31 House bank ID  does not exist for company code 0120                        
05/18/2009 22:36:39 ABAP/4 processor: GETWA_TOO_MANY_SEGMENTS                                                                               
What happened?                                                                               
The current program "SAPLPS_RPSCO_K " had to be terminated because                           
a capacity limit has been reached.                                                                               
What can you do?                                                                               
Please make a note of the actions and input which caused the error.                          
Please make a note of the actions and input which caused the error.                                                                               
To resolve the problem, contact your                                                         
SAP system administrator.                                                                               
Choose "Print" for a hard coopy of the termination message. You can                          
display and adminster short dump messages using Transaction ST22.                                                                               
Error analysis                                                                               
The system attempted to create a new data segment, but this                                  
exceeded the capacity limit of 32767 data segments per roll area.                                                                               
How to correct the error                                                                               
If the error occurred in a non-modified SAP program, you may be                              
able to find a solution in the SAP note system.                                              
If you have access to the note system yourself, use the following                            
search criteria:                                                                               
Information on where termination occurred                                                                               
The termination occurred in the ABAP/4 program "SAPLPS_RPSCO_K " in                                 
"PS_FILL_RPSCO_KEY".                                                                               
The main program was "ZSNT_PO_INVOICE ".                                                                               
The termination occurred in line 0                                                                  
of the source code of program " " (when calling the editor 00).                                     
The program "SAPLPS_RPSCO_K " was started as a background job.                                                                               
Contents of system fields                                                                               
SY field contents..................... SY field contents.....................                                                                               
SY-SUBRC 0                             SY-INDEX 1                                                   
SY-TABIX 25                            SY-DBCNT 0                                                   
SY-FDPOS 0                             SY-LSIND 0                                                   
SY-PAGNO 0                             SY-LINNO 1                                                   
SY-COLNO 1                                                                               
Chosen variables

Similar Messages

Maybe you are looking for