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

Get invoice list

Former Member
0 Likes
458

Hi all

I have come accross an anomaly while testing invoice list. The following is my code for getting the invoice list. The problem its that when i test it with customer no 1000 it displays invoice list of 1050 too. This happens ONLY for cutomer no 1000, testing with other entries gives the desired result. Is there anything that i am doing wrong w.r.to the coding part? Thanks

FORM get_invoice_list  TABLES   pt_customer_list
                                    TYPE /artec/msf_tab_cust_list
                                pet_invoice_list
                                    TYPE /artec/msf_tab_invoice_list
                                pet_return
                                    TYPE bapiret2_t
                         USING pv_open_invoice
                                    TYPE /artec/msf_dte_flag
                               pv_close_invoice
                                    TYPE /artec/msf_dte_flag.
  TYPES:BEGIN OF ty_cus_name,
    cus_no TYPE kunnr,
    cus_name TYPE name1_gp,
    END OF ty_cus_name.

*-- Declaring internal table
  DATA:
        r_fkdat   TYPE TABLE OF ty_fkdat,
        lt_vrkpa  TYPE TABLE OF ty_vrkpa.

*
*Declare a date range table.
*  DATA: r_rfbsk TYPE TABLE OF ty_rfbsk. "#EC NEEDED
*-- Declaring workarea
   DATA:  lw_fkdat     TYPE ty_fkdat,
*         lw_vbrk      TYPE ty_vbrk, "#EC NEEDED
         lw_vrkpa     TYPE ty_vrkpa,
*         lw_rfbsk     TYPE ty_rfbsk,
*         lw_cust_list TYPE /artec/msf_str_cust_list, "#EC NEEDED
         lw_invoice_list TYPE /artec/msf_str_invoice_list,
         lw_datcfg        TYPE /artec/msfdatcfg.

*-- Clearing export table
  CLEAR: pet_invoice_list[], pet_return[] .
*-- Get closed invoices within the date range.

  IF  pv_close_invoice IS INITIAL AND
      pv_open_invoice IS NOT INITIAL.

*-- Get open invoices within the date range.
  ELSEIF pv_close_invoice IS NOT INITIAL AND
         pv_open_invoice IS INITIAL.

    SELECT SINGLE * FROM /artec/msfdatcfg "#EC *
           INTO lw_datcfg
           WHERE type = /artec/msf_cl_common=>gc_price_list ."'PRICE_LIST'.
    lw_fkdat-sign = /artec/msf_cl_common=>gc_sign_i.
    lw_fkdat-option = /artec/msf_cl_common=>gc_option_bt.

    lw_fkdat-low =  sy-datum - lw_datcfg-retain_day .
    lw_fkdat-high = sy-datum.
    APPEND lw_fkdat TO r_fkdat.
    CLEAR lw_fkdat.


*--Fetch both the open and closed invoices
  ELSEIF pv_close_invoice IS NOT INITIAL AND
         pv_open_invoice  IS NOT INITIAL.

  ELSEIF pv_close_invoice IS INITIAL AND
         pv_close_invoice IS INITIAL.
  ENDIF.


* Select required entries from the database view /artec/msf_v_inv
  SELECT kunde
         parvw
         vkorg
         fkdat
         vtweg
         fkart
         kunnr
         kunag
         vbtyp
         ernam
         vbeln
         netwr
         waerk
  FROM /artec/msf_v_inv "Database view of vrkpa and vbrk
      INTO TABLE lt_vrkpa
      FOR ALL ENTRIES IN pt_customer_list
      WHERE kunde = pt_customer_list-customer_no
      AND fkdat IN r_fkdat AND
      rfbsk = /artec/msf_cl_common=>gc_close_invoice.


  LOOP AT lt_vrkpa INTO lw_vrkpa.
    lw_invoice_list-cust_no      = lw_vrkpa-kunnr.
    lw_invoice_list-invoice_no   = lw_vrkpa-vbeln.
    APPEND lw_invoice_list TO pet_invoice_list.
    CLEAR:lw_invoice_list.
  ENDLOOP.

Sort pet_invoice_list by cust_no invoice_no.
Delete Adjacent Duplicates From pet_invoice_list  comparing all fields.
  IF pet_invoice_list[] IS NOT INITIAL.
    DELETE pet_invoice_list WHERE invoice_date BETWEEN '19900101' AND '20090101'.
  ENDIF.
ENDFORM.

1 REPLY 1
Read only

Former Member
0 Likes
364

hard to read the code, but did you check to see if FOR ALL ENTRIES IN pt_customer_list has rows in the PT_customer_list? If you didn't I'd suggest a review of documentation of FOR ALL ENTRIES. If you did make sure pt_customer_list isn't empty, then disregard.