VBUP-FKSTA

Hi Guys,
Can you please tell me how to create a delta capable generic datasource on VBUP? I have to create this generic datasource to populate FKSTA. Since 2LIS_11_VASTI does not extract the same.
Now VBUP doesn't have a date or a timestamp field which I could derive the delta from. Numeric pointer to say order number will only bring through new records but not changed status.
Thanks in advance for your help!

why don't you enhance the standard extractor with this field, and populate in the user-exit?
it's not that usefull to create an extractor for one single field.
check the note
2LIS_11_VASTH and 2LIS_11_VASTI billing status not filled
SAP Note Number: 651603 
Symptom
In the two extractors 2LIS_11_VASTH and 2LIS_11_VASTI, which extract status information for the request, the 'billing status' FKSTK or FKSTA is contained in each case.
However, this field is not filled.
Other terms
MC11VA0STH, MC11VA0STI, DataSource, VBUK, VBUP, event VD
Reason and Prerequisites
If 'delivery-related billing' is defined for a request, the billing status is determined for the respective deliveries, but not for the request itself. The billing status is only determined for the document that is actually invoiced.
The 'delivery-related billing status' was incorrectly included in both extractors, although it is not filled, since the status extractors only extract the status information of the requests.
Solution
There is no special solution for this problem.
Edited by: Mti on Jan 15, 2010 4:07 PM

Similar Messages

  • Update VBUP-FKSTA (billing relevancy) during creation of invoice

    Hi,
    We pack items in a delivery. Due to this an extra item is added to the delivery with a ZPAC item category. This item category is set as billing relevancy.
    We have created a requirement in copy control that we only want these items in the intercompany invoice, and not in a regular invoice F2. The invoice is created for the customer without the packaging materials and the intercompany invoice has all the items. This requirement is only in a specific scenario for only one shipping point. The customer does not need to pay for the packaging materials, but the intercompany sales organization does.
    Now the delivery is still open because the billing relevancy is 'A' (vbuk-fksta), but we actually do not copy it to the invoice. The billing relevancy for the intercompany (vbuk-fkivp) is set to 'C'. We would like to set the vbuk-fksta automatically (if possible) during creation of the F2 invoice to 'C'.
    We know transaction VL_COMPLETE we can do this manually.
    I tried some user exits but at the moment I can not find the routine where it actually updates this status. And whether there is a user exit (or enhancement) possible to influence this ourselves, so we do not need to update this by hand.

    Hi
    KIndly check the oss note  445763 it may help you
    or
    write the code with the help of ABAPER  by selecting  and updating the below tables
    VBFA, VBUP & VBUK
    Regards
    Damu

  • Field FKSTA- Billing status of delivery-related billing documents not getting updated

    Hi Experts,
    I have a requirement wherein I need to fetch the FKSTA - Billing status of delivery-related billing documents into the datasource 2lis_11_VASTI. I have checked a lot of threads on this topic but have not found a concrete solution yet.
    I have checked the settings in vov7 and vov8 and everything seems to be in place. I have also checked in table VBUP, when I filter based on field FKSTA = 'C', it shows me the outbound delivery document nos. But when I use the related sales document, it shows me blank values. VBUK as well doesn't show any values for field FKSTK.
    I would like to know how and where I can identify the 'billing status of delivery- related' document.
    I can see in VBUP table that if I enter the sales document no. related to the delivery document, it does not show the correct status.  I believe that the statuses should ideally get updated to the underlying VBUK and VBUP tables. Is there any way to update and align them?
    Is there a workaround, a similar field that i can use for datasource enhancement that will give me the correct values?
    Appreciate any help I can get on this as it is urgent.
    Thanks,
    AM

    Hi,
    You are correct that stauts is updated in table VBUK and VBUP.
    However, a sales order does not determine a billing status for delivery related billing, field
    VBUP-FKSTA is only determined for delivey.
    So, it is correct behavior that VBUP-FKSTA = BLANK when searching VBUP with
    VBUP-VBELN = sales order number.
    Just because of above reason, you will not find billing status field in VA03 -> goto header/item;
    you could only find billing status field for delivery in VL03N -> status overview.
    It seems that you are trying to find out sales orders that have been fully deliveried and fully billed, am I right? As far as I know, there is no directly table/field/tcode that could meet your requirement.
    You could consider following workaround:
    firstly, get a list of deliveries that have been fully billied(search VBUP with VBUP-FKSTA = C or search VBUK with VBUK-FKSTK = C);
    Secondly, using these deliveries to search table VBFA to find out related sales orders.
    Hope this helps.
    Best regards,
    Crystal

  • Table VBUP

    Hi, can anyone advise how and when is field VBUP-FKSTA get updated?  I created a SO, completed delivery and billing.  However, this field is still blank when select the SO number.  Is there anything i missed out?
    Thanks
    PP

    Dear PP,
    Field VBUP-FKSTA stands for Billing status of delivery-related billing documents.
    This will get update when you complete the billing document for the delivery document.
    So please check your billing document is order relevant billing
    or delivery related billing.
    If your billing document is delivery related billing document then check the accounting release status if not release release to accounting then check.
    I hope this will help you,
    Regards,
    Murali.
    Edited by: Murali Mohan.Tallapaneni on Nov 6, 2008 9:44 AM

  • Reg:open sales orders

    Can any body give me the logic to list the oper sales orders.
    Thanks,
    srik

    Hi,
    *& Report  ZOPEN_SALESORDER
    report zopen_salesorder message-id arc no standard page heading.
    tables :kna1,vbak.
    select-options : so_vkorg for vbak-vkorg ,
    so_vtweg for vbak-vtweg ,
    so_spart for vbak-spart,
    so_kunnr for kna1-kunnr.
    data : keybalance like bapi3007_3 occurs 0 with header line.
    data : begin of sales_open occurs 0 ,
    vbeln like vbak-vbeln,
    auart like vbak-auart,
    kunnr like kna1-kunnr,
    bstnk like vbak-bstnk,
    lfstk like vbuk-lfstk,
    fkstk like vbuk-fkstk,
    gbstk like vbuk-gbstk,
    end of sales_open.
    data : begin of itm_sales occurs 0,
    vbeln like vbap-vbeln,
    posnr like vbap-posnr,
    matnr like vbap-matnr,
    lfsta like vbup-lfsta,
    lfgsa like vbup-lfgsa,
    fksta like vbup-fksta,
    fksaa like vbup-fksaa,
    gbsta like vbup-gbsta,
    end of itm_sales.
    data : l_kunnr like kna1-kunnr,
    l_vkorg like vbak-vkorg,
    l_vtweg like vbak-vtweg,
    l_spart like vbak-spart.
    data: v_statusl(20) type c,
    v_statusb(20) type c,
    v_statusf(20) type c,
    v_statusg(20) type c,
    v_status(20) type c,
    v_field(1) type c.
    **Selection Screen Validations.
    at selection-screen.
    perform validations.
    *& Form Validations
    text
    --> p1 text
    <-- p2 text
    form validations.
    **Customer
    if not so_kunnr[] is initial.
    select single kunnr into l_kunnr
    from kna1
    where kunnr in so_kunnr.
    if sy-subrc ne 0.
    message e002 with text-005.
    endif.
    endif.
    **Sales Organization
    if not so_vkorg[] is initial.
    select single vkorg into l_vkorg
    from tvko
    where vkorg in so_vkorg.
    if sy-subrc ne 0.
    message e003 with text-006.
    endif.
    endif.
    **Distribution Channel
    if not so_vtweg[] is initial.
    select single vtweg into l_vtweg
    from tvkov
    where vkorg in so_vkorg
    and vtweg in so_vtweg.
    if sy-subrc ne 0.
    message e004 with text-007.
    endif.
    endif.
    **Division
    if not so_spart[] is initial.
    select single spart into l_spart
    from tvta
    where vkorg in so_vkorg
    and vtweg in so_vtweg
    and spart in so_spart.
    if sy-subrc ne 0.
    message e005 with text-008.
    endif.
    endif.
    endform. " Validations
    top-of-page.
    perform sales_top_of_page.
    start-of-selection.
    perform sales_sel.
    *& Form sales_sel
    text
    --> p1 text
    <-- p2 text
    form sales_sel.
    data: date type sy-datum.
    date = sy-datum - 3000.
    select vbeln auart kunnr bstnk
    lfstk fkstk gbstk
    into table sales_open
    from vbakuk
    where vkorg in so_vkorg
    and vtweg in so_vtweg
    and spart in so_spart
    and kunnr in so_kunnr
    "and gbstk ne 'C'.
      and gbstk in ('A','B')
      and erdat >= date.
    loop at sales_open.
    call function 'BAPI_AR_ACC_GETKEYDATEBALANCE'
          exporting
            companycode = '1919'
            customer    = sales_open-kunnr
            keydate     = sy-datum
          tables
            keybalance  = keybalance.
        read table keybalance index sy-tabix.
    write:/4 sy-vline,
    5 sales_open-vbeln  color 2 intensified on,
    16 sy-vline,
    17 sales_open-auart color 2 intensified on,
    27 sy-vline,
    28 sales_open-kunnr color 2 intensified on,
    40 sy-vline,
    41 sales_open-bstnk color 2 intensified on,
    55 sy-vline,
    56 sales_open-lfstk,
    76 sy-vline,
    77 sales_open-fkstk,
    96 sy-vline,
    97 sales_open-gbstk ,
    117 sy-vline,
    118 keybalance-lc_bal,
    142 sy-vline.
    "hide sales_open-vbeln .
    endloop.
    write :/4 sy-uline(160).
    endform. " sales_sel
    *& Form sales_top_of_page
    text
    --> p1 text
    <-- p2 text
    form sales_top_of_page.
    write:/4 sy-uline(160),
    50 'OPEN SALES ORDERS' color 7 intensified on .
    write: /4 sy-vline,
    5 'SalesOrder' color 1 ,
    16 sy-vline,
    17 'OrderType' color 1,
    27 sy-vline,
    28 'Customer' color 1,
    40 sy-vline,
    41 'PoNumber' color 1,
    55 sy-vline,
    56 'Delivery Status' color 1,
    76 sy-vline,
    77 'Billing Status' color 1,
    96 sy-vline,
    97 'Processing Status' color 1,
    117 sy-vline,
    130 'Balance' color 1,
    142 sy-vline.
    write:/4 sy-uline(160).
    endform. " sales_top_of_page
    "at line-selection.
    "select a~vbeln
    "a~posnr
    "a~matnr
    "* a~kwmeng
    "b~lfsta
    "b~lfgsa
    "b~fksta
    "b~fksaa
    "b~gbsta
    "into table itm_sales
    "from vbap as a join vbup as b
    "on avbeln eq bvbeln
    "and aposnr eq bposnr
    "and b~gbsta ne 'C'
    "where a~vbeln eq sales_open-vbeln.
    "if not sales_open is initial.
    "loop at itm_sales.
    "write:/5 itm_sales-vbeln,
    "itm_sales-posnr,
    "itm_sales-matnr,
    "itm_sales-lfsta,
    "itm_sales-lfgsa,
    "itm_sales-fksta,
    "itm_sales-fksaa,
    "itm_sales-gbsta.
    "endloop.
    "endif.
    thanks
    Ravi

  • Print smartform from background

    Dear Experts,
    I have requirement to create delivery then create bill automatically so i open background job from program (A) and submit the creating program for bill (B) via this job what happened is the delivery creating is ok, the delivery printing is ok and the billing creation is ok but the billing printing program (C) is not ok where the spool is creating with status waiting so can any body help how to print from background job??
    program (A) (Create backgroundjob and submit program via it)
    FORM USEREXIT_SAVE_DOCUMENT.
    DATA: jobcount TYPE tbtcjob-jobcount,
          new_time type TBTCJOB-SDLSTRTTM.
    data : p_vbeln TYPE likp-vbeln.
    DATA : v_JOB_WAS_RELEASED LIKE  BTCH0000-CHAR1.
    break rurik.
    if T180-TRTYP = 'H'
      and ( likp-lfart = 'ZDCF'
    or    likp-lfart = 'ZDCI'
      or    likp-lfart = 'ZDCO'
      or    likp-lfart = 'ZDCP'
      or    likp-lfart = 'ZDCR'
      or    likp-lfart = 'ZDOB'
      or    likp-lfart = 'ZDOT'
      or    likp-lfart = 'ZDQT'
    or    likp-lfart = 'ZDRE' - Ian
      or    likp-lfart = 'ZDSO').
    CALL FUNCTION 'JOB_OPEN'
      EXPORTING
        jobname               = 'SD_AUTOMATION'
      SDLSTRTDT             = NO_DATE
      SDLSTRTTM             = NO_TIME
      JOBCLASS              =
    IMPORTING
       JOBCOUNT               = jobcount
    CHANGING
      RET                   =
    EXCEPTIONS
       CANT_CREATE_JOB        = 1
       INVALID_JOB_DATA       = 2
       JOBNAME_MISSING        = 3
       OTHERS                 = 4.
    SUBMIT zsd_create_billing_document
            with vbeln EQ LIKP-VBELN
            AND RETURN
            VIA JOB 'SD_AUTOMATION'
            NUMBER jobcount.
    new_time = sy-uzeit + 10.  "short delay
    CALL FUNCTION 'JOB_CLOSE'
      EXPORTING
        jobcount                         = jobcount
        jobname                          = 'SD_AUTOMATION'
       STRTIMMED                       = 'X'
        SDLSTRTDT                        = sy-datum
        SDLSTRTTM                        = new_time
    IMPORTING
        JOB_WAS_RELEASED                 = v_JOB_WAS_RELEASED
    EXCEPTIONS
       CANT_START_IMMEDIATE              = 1
       INVALID_STARTDATE                 = 2
       JOBNAME_MISSING                   = 3
       JOB_CLOSE_FAILED                  = 4
       JOB_NOSTEPS                       = 5
       JOB_NOTEX                         = 6
       LOCK_FAILED                       = 7
       INVALID_TARGET                    = 8
       OTHERS                            = 9
    ENDIF.
    ENDFORM.
    Program B (Creat bill)
    REPORT zsd_create_billing_document
           NO STANDARD PAGE HEADING LINE-SIZE 255.
    TABLES: vbup, vbak, vbuk.
    DATA:   bdcdata LIKE bdcdata    OCCURS 0 WITH HEADER LINE.
    DATA done(1).
    PARAMETERS vbeln TYPE likp-vbeln.
    DATA  sal_vbeln TYPE vbeln..
    DATA  messtab LIKE TABLE OF bdcmsgcoll WITH HEADER LINE.
    DATA   billing_doc TYPE vbeln.
    DATA  messagetext(200).
    MESSAGE s002(zsd).
    WRITE: / vbeln.
    DATA :  v_print TYPE i.
    CALL FUNCTION 'ENQUEUE_EVVBLKE'
    EXPORTING
      MODE_LIKP            = 'E'
      MANDT                = SY-MANDT
       vbeln                = vbeln
      X_VBELN              = ' '
      _SCOPE               = '2'
        _wait                = 'X'
    " _wait                 = space
      _COLLECT             = ' '
    EXCEPTIONS
       foreign_lock         = 1
       system_failure       = 2
       OTHERS               = 3
    MESSAGE s005(zsd).
    *In case ZSOT automatic billing once we create delivery and post goods issue manual.
    SELECT SINGLE vbelv
      FROM vbfa
      INTO sal_vbeln
      WHERE vbeln = vbeln
      AND   vbtyp_v = 'C'.
    SELECT SINGLE *
      FROM vbak
      WHERE vbeln = sal_vbeln.
    import v_print to v_print FROM MEMORY id 'PRINTFLAG'.
    IF vbak-auart EQ 'ZSOT'.
    IF v_print eq '1'.
        PERFORM create_document USING vbeln
                              CHANGING sy-subrc.
    ENDIF.
    ELSE.
    *Other than ZSOT Post Goods issue from ZPGI2 and from there automatic billing.
    ENDIF.
    *&      Form  CREATE_DOCUMENT
          text
         -->P_VBELN    text
    FORM create_document USING p_vbeln
                         CHANGING sysubrc.
      PERFORM bdc_dynpro      USING 'SAPMV60A' '0102'.
      PERFORM bdc_field       USING 'BDC_CURSOR'
                                    'KOMFK-VBELN(01)'.
      PERFORM bdc_field       USING 'BDC_OKCODE'
                                    '/00'.
      PERFORM bdc_field       USING 'KOMFK-VBELN(01)'
                                    p_vbeln."'1130010202'.
      PERFORM bdc_dynpro      USING 'SAPMV60A' '0104'.
      PERFORM bdc_field       USING 'BDC_CURSOR'
                                    'VBRK-FKART'.
      PERFORM bdc_field       USING 'BDC_OKCODE'
                                    '=SICH'.
      CALL FUNCTION 'DEQUEUE_EVVBLKE'
       EXPORTING
          MODE_LIKP       = 'E'
          MANDT           = SY-MANDT
            vbeln           = vbeln
          X_VBELN         = ' '
          _SCOPE          = '3'
          _SYNCHRON       = ' '
          _COLLECT        = ' '
      CALL TRANSACTION 'VF01' USING bdcdata
                       MODE   'N'
                       UPDATE 'S'
                       MESSAGES INTO messtab.
      READ TABLE messtab WITH KEY msgtyp = 'E'.
      IF sy-subrc EQ 0.
        sysubrc = 4.
      ELSE.
        sysubrc = 0.
      ENDIF.
      LOOP AT messtab.
        sy-msgty = messtab-msgtyp.
        sy-msgid = messtab-msgid.
        sy-msgno = messtab-msgnr.
        sy-msgv1 = messtab-msgv1.
        sy-msgv2 = messtab-msgv2.
        sy-msgv3 = messtab-msgv3.
        sy-msgv4 = messtab-msgv4.
        CALL FUNCTION '/SAPTRX/GET_MESSAGE_TEXT'
          EXPORTING
            msgid                = sy-msgid
            msgno                = sy-msgno
            msgv1                = sy-msgv1
            msgv2                = sy-msgv2
            msgv3                = sy-msgv3
            msgv4                = sy-msgv4
          IMPORTING
            messagetext          = messagetext
          EXCEPTIONS
            no_message_retrieved = 1
            OTHERS               = 2.
        WRITE: / messagetext.
        CLEAR messagetext.
      ENDLOOP.
    *... refresh tables
      REFRESH: messtab, bdcdata.
    ENDFORM.                    "CREATE_DOCUMENT
    *&      Form  BDC_DYNPRO
          text
         -->PROGRAM    text
         -->DYNPRO     text
    FORM bdc_dynpro USING program dynpro.
      CLEAR bdcdata.
      bdcdata-program  = program.
      bdcdata-dynpro   = dynpro.
      bdcdata-dynbegin = 'X'.
      APPEND bdcdata.
    ENDFORM.                    "BDC_DYNPRO
           Insert field                                                  *
    FORM bdc_field USING fnam fval.
      CLEAR bdcdata.
      bdcdata-fnam = fnam.
      bdcdata-fval = fval.
      APPEND bdcdata.
    ENDFORM.                    "BDC_FIELD
    *&      Form  change_status
          text
    -->  p1        text
    <--  p2        text
    FORM change_status .
    *Change status if delivery and the billing document has been created
      SELECT  *
        FROM vbup
        WHERE vbeln = vbeln
        AND   fksta NE 'C'.
        vbup-fksta = 'C'.
       vbup-gbsta = 'C'.
        MODIFY vbup.
      ENDSELECT.
      UPDATE vbuk
      SET fkstk = 'C'
         gbstk = 'C'
      WHERE vbeln = vbeln.
    ENDFORM.                    " change_status
    Program C (Print Bill)
    REPORT  z_sdps_invoice.
    *&    <Module>:  SD Smart Forms.
    *& Type       : Executable
    *& Request No.:
    *& Author/Co. : Ahmed Al Eryani
    *& Created On : 26.02.2007
    *& Finished   : 24.2007
    *& Description:
    *&                    MODIFICATION LOG
    *& Modified by  :
    *& Request No.  :
    *& Dev. Class   :
    *& Date Modified:
    *& Description  :
    TABLES: vbrk, kna1, vbrp, makt, konv, vbkd.
    SELECTION-SCREEN BEGIN OF BLOCK a.
    PARAMETER: p_vbeln LIKE vbrp-vbeln OBLIGATORY MATCHCODE OBJECT vmcf. "Billing document No
    "SELECT-OPTIONS s_bukrs FOR bkpf-bukrs. "Company Code
    SELECTION-SCREEN END OF BLOCK a.
    *itab is object of our smart form structre
    DATA: itab TYPE zsd_invoice OCCURS 0 WITH HEADER LINE.
    DATA: wa_footer TYPE zsd_invv1.
    DATA: t_items TYPE zsd_inv WITH HEADER LINE,
          w_items TYPE LINE OF zsd_inv,
          it_footer TYPE zsd_inv1,
          w_footer TYPE LINE OF zsd_inv1.
    DATA: amountspell LIKE spell.
    DATA: g_fm_name TYPE rs38l_fnam.
    DATA: mnumvflag(10) TYPE c.
    DATA: coun TYPE i,
          totalforitems TYPE kwert,
          lasttotal(8) TYPE p DECIMALS 2,
          lasttotalc(11) TYPE c,
          firstpart(11) TYPE c,
          secondpart(2) TYPE c.
    DATA: currency TYPE waerk.
    DATA: currtxet(50) TYPE c.
    *Header internal table
    DATA: BEGIN OF t_header OCCURS 0,
      vbeln LIKE vbrk-vbeln,"Document no
      name1 LIKE kna1-name1,"Customer Name
      adrnr LIKE kna1-adrnr,"Customer Address
      bstkd LIKE vbkd-bstkd,"
      kunnr LIKE kna1-kunnr,"Customer Account no
      waerk LIKE vbrk-waerk, "currency key
      aubel LIKE vbrp-aubel,
      kunrg LIKE vbrk-kunrg,
      street LIKE adrc-street,
      fkart LIKE vbrk-fkart,
      lgort LIKE lips-lgort,"Stord bin
      lgobe LIKE t001l-lgobe,
      ktokd LIKE kna1-ktokd,
      PSTYV LIKE vbrp-PSTYV,
      orgbil LIKE vbfa-vbelv,
    END OF t_header.
    *detail internal table
    DATA: BEGIN OF t_items1 OCCURS 0,
      matnr LIKE vbrp-matnr,"Material Number
      posnr LIKE vbrp-posnr,
      vgpos LIKE vbrp-vgpos,
      maktx LIKE makt-maktx,"Material Description
      lgort LIKE vbrp-lgort,"Storage location
      fkimg LIKE vbrp-fkimg,"
      knumv LIKE vbrk-knumv,"
      unitprice LIKE konv-kawrt,
      total LIKE konv-kawrt,
      waers LIKE konv-waers,
      kkurs LIKE konv-kkurs,
      vgbel LIKE vbrp-vgbel,
      lgpbe LIKE lips-lgpbe,
      vgtyp LIKE vbrp-vgtyp,
    END OF t_items1.
    DATA: v_belnr TYPE belnr_d.
    *Unit price internal table
    DATA: BEGIN OF t_untprice OCCURS 0,
      kschl LIKE konv-kschl,"condition type
      kawrt LIKE konv-kawrt,"unit price
    END OF t_untprice.
    *Condition(spcial deduction)
    DATA: BEGIN OF t_spcialcnd OCCURS 0,
      kschl LIKE konv-kschl,"condition type
      kwert LIKE konv-kwert,"Deduction value
    END OF t_spcialcnd.
    DATA: t_tax LIKE TABLE OF t_spcialcnd WITH HEADER LINE,
          v_tax LIKE konv-kwert.
    DATA: BEGIN OF t_curtxt OCCURS 0,
      ltext LIKE tcurt-ltext,
    END OF t_curtxt.
    DATA :return_code TYPE i," VALUE 999,
          us_screen TYPE c. "VALUE 'X'.
    declaration of data
    INCLUDE rlb_invoice_data_declare.
    definition of forms
    INCLUDE rlb_invoice_form01.
    INCLUDE rlb_print_forms.
    START-OF-SELECTION.
      "IF p_vbeln IS NOT INITIAL.
        PERFORM entry USING return_code us_screen.
      "ENDIF.
          FORM ENTRY
    FORM entry USING return_code us_screen.
      DATA: lf_retcode TYPE sy-subrc.
      CLEAR retcode.
      xscreen = us_screen.
    perform processing using us_screen
                        changing lf_retcode.
    if lf_retcode ne 0.
       return_code = 1.
    else.
       return_code = 0.
    endif.
      IF p_vbeln IS INITIAL.
        p_vbeln = nast-objky.
      ENDIF.
      "get header data
      SELECT SINGLE vbrk~vbeln vbrk~waerk vbrp~aubel vbrk~kunrg vbrk~fkart vbrp~lgort vbrp~PSTYV
      INTO (t_header-vbeln, t_header-waerk, t_header-aubel, t_header-kunrg, t_header-fkart,
        t_header-lgort, t_header-PSTYV)
      FROM vbrk JOIN vbrp ON vbrp~vbeln = vbrk~vbeln
                JOIN kna1 ON vbrk~kunrg = kna1~kunnr
      WHERE vbrk~vbeln = p_vbeln.
      IF t_header-PSTYV = 'ZREN'.
        SELECT SINGLE VBELV
          INTO t_header-orgbil
          FROM vbfa
          WHERE vbeln = p_vbeln
          and VBTYP_V = 'M'.
      ENDIF.
      SELECT SINGLE t001l~lgobe
        INTO t_header-lgobe
        FROM t001l
        WHERE t001l~lgort = t_header-lgort.
      SELECT SINGLE kna1~name1 kna1~adrnr kna1~kunnr kna1~ktokd
        INTO (t_header-name1, t_header-adrnr, t_header-kunnr, t_header-ktokd)
      FROM  kna1 "ON vbrk~kunrg = kna1~kunnr
      WHERE kna1~kunnr = t_header-kunrg
        AND spras = 'AR'.
      IF t_header-name1 IS INITIAL.
        SELECT SINGLE kna1~name1 kna1~adrnr kna1~kunnr kna1~ktokd
          INTO (t_header-name1, t_header-adrnr, t_header-kunnr, t_header-ktokd)
        FROM  kna1 "ON vbrk~kunrg = kna1~kunnr
        WHERE kna1~kunnr = t_header-kunrg
          AND spras = 'EN'.
      ENDIF.
      IF t_header-ktokd = 'ZONE'.
        SELECT SINGLE belnr
          INTO v_belnr
        FROM bkpf
        WHERE xblnr = p_vbeln.
        SELECT SINGLE name1
        INTO t_header-name1
        FROM bsec
        WHERE belnr = v_belnr.
      ENDIF.
      SELECT SINGLE adrc~street
        INTO t_header-street
        FROM adrc
        WHERE addrnumber = t_header-adrnr
        AND langu = 'AR'.
      IF t_header-street IS INITIAL.
        SELECT SINGLE adrc~street
          INTO t_header-street
          FROM adrc
          WHERE addrnumber = t_header-adrnr
          AND langu = 'EN'.
      ENDIF.
      "get details data
      SELECT vbrp~matnr vbrp~posnr vbrp~vgpos vbrp~fkimg
             vbrk~knumv vbrp~matnr vbrp~vgbel vbrp~vgtyp"makt~maktx
      INTO CORRESPONDING FIELDS OF TABLE t_items1
      FROM vbrp "JOIN makt ON vbrp~matnr = makt~matnr
                JOIN vbrk ON vbrp~vbeln = vbrk~vbeln
                "join konv on vbrk~knumv = konv~knumv
      WHERE vbrp~vbeln = p_vbeln
        AND vbrp~fkimg NE '0.000'.
      "AND makt~spras = 'E'.
      break arasmy.
      LOOP AT t_items1.
        SELECT SINGLE lips~lgpbe
          INTO t_items1-lgpbe
          FROM lips
          WHERE vbeln = t_items1-vgbel
          AND posnr = t_items1-vgpos.
        SELECT SINGLE makt~maktx
        INTO  t_items1-maktx
        FROM  makt
        WHERE matnr = t_items1-matnr
        AND   makt~spras = 'EN'.
        SELECT SINGLE konv~kbetr konv~kwert konv~waers konv~kkurs
          INTO (t_items1-unitprice, t_items1-total, t_items1-waers,
          t_items1-kkurs)
        FROM konv
        WHERE konv~kschl = 'NETW'"'ZSPC'                               "'ZSP1'
        AND   konv~knumv = t_items1-knumv
        AND   kposn      = t_items1-posnr.
        t_items1-unitprice = ( t_items1-total / t_items1-fkimg ) * t_items1-kkurs.
        MODIFY t_items1.
        mnumvflag = t_items1-knumv."Number of the document condition
      ENDLOOP.
    *get the deduction value for the document condiotion no
      SELECT konvkschl konvkwert
      INTO CORRESPONDING FIELDS OF TABLE t_spcialcnd
      FROM konv
      WHERE konv~kschl IN ('ZSSD', 'ZSCD', 'ZSDD', 'ZSPD', 'ZSWD', 'ZMW1', 'ZSGS', 'ZMW2')
      AND  konv~knumv = mnumvflag.
    Get tax 10%
        SELECT konvkschl konvkwert
        APPENDING CORRESPONDING FIELDS OF TABLE t_tax
        FROM konv
        WHERE konv~kschl = 'MWST'
        AND  konv~knumv = mnumvflag.
      itab-invn  = t_header-vbeln.
      itab-orgbil  = t_header-orgbil.
      itab-cusna = t_header-name1.
      itab-addr  = t_header-street.
      itab-custn = t_header-kunrg.
      itab-sord  = t_header-aubel.
      itab-fkart = t_header-fkart.
      itab-lgort = t_header-lgort.
      itab-lgobe = t_header-lgobe.
      itab-PSTYV = t_header-PSTYV.
      currency   = t_header-waerk.
      LOOP AT t_items1.
        w_items-matn   = t_items1-matnr.
        w_items-matdes = t_items1-maktx.
        w_items-stloc  = t_items1-lgpbe."lgort.
        w_items-qunt   = t_items1-fkimg.
        w_items-total  = t_items1-total.
        totalforitems  = totalforitems + w_items-total.
        COLLECT w_items INTO t_items.
      endloop.
      LOOP AT t_items1.
        LOOP AT t_items WHERE matn = t_items1-matnr.
          t_items-prc = t_items1-unitprice.
          MODIFY t_items.
        ENDLOOP.
      ENDLOOP.
      LOOP AT t_items.
          coun = coun + 1.
          t_items-itmn = coun.
          MODIFY t_items.
      ENDLOOP.
        w_footer-totalforitems = totalforitems.
        LOOP  AT t_spcialcnd.
          CASE t_spcialcnd-kschl.
            WHEN 'ZSSD'.
              w_footer-spdisc    = w_footer-spdisc      + t_spcialcnd-kwert.
            WHEN 'ZSCD'.
              w_footer-comdisc   = w_footer-comdisc     + t_spcialcnd-kwert.
            WHEN 'ZSDD'.
              w_footer-DIFMAT    = w_footer-DIFMAT      + t_spcialcnd-kwert.
            when 'ZSPD'.
              w_footer-trgtdisc  = w_footer-trgtdisc    + t_spcialcnd-kwert.
            WHEN 'ZMW2'.
              w_footer-comindisc = w_footer-comindisc   + t_spcialcnd-kwert.
            WHEN 'ZSWD'.
              w_footer-cshdisc   = w_footer-cshdisc     + t_spcialcnd-kwert.
            WHEN 'ZSGS'.
              w_footer-stampsdisc = w_footer-stampsdisc + t_spcialcnd-kwert.
          ENDCASE.
          w_footer-ttldisc = w_footer-spdisc + w_footer-comdisc + w_footer-trgtdisc
                           + w_footer-cshdisc + w_footer-DIFMAT + w_footer-stampsdisc.
        ENDLOOP.
        w_footer-aftrdiscnts = w_footer-totalforitems + w_footer-ttldisc.
        LOOP AT t_tax WHERE kwert NE '0.00'.
          w_footer-saltax = w_footer-saltax + t_tax-kwert.
        ENDLOOP.
        w_footer-totalaftrtax = w_footer-aftrdiscnts + w_footer-saltax.
        w_footer-total = w_footer-totalaftrtax + w_footer-comindisc.
        lasttotal = w_footer-total.
      APPEND w_footer TO it_footer.
      SELECT tcurt~ltext
      INTO CORRESPONDING FIELDS OF TABLE t_curtxt
      FROM   tcurt
      WHERE tcurt~spras = 'AR'
      AND   tcurt~waers = currency.
      LOOP AT  t_curtxt.
        currtxet = t_curtxt-ltext.
      ENDLOOP.
      itab[] = t_header[].
      lasttotalc = lasttotal.
      SPLIT lasttotalc AT '.' INTO firstpart secondpart.
      lasttotal = firstpart / 100.
      CALL FUNCTION 'SPELL_AMOUNT'
        EXPORTING
          amount    = lasttotal
          currency  = ''"CURRENCY
          filler    = space
          language  = 'A'
        IMPORTING
          in_words  = amountspell
        EXCEPTIONS
          not_found = 1
          too_large = 2
          OTHERS    = 3.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    --split amount--
    BREAK radha.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        formname                 = 'Z_INVOICE_PARTS2'
    VARIANT                  = ' '
    DIRECT_CALL              = ' '
       IMPORTING
         fm_name                  = g_fm_name
       EXCEPTIONS
         no_form                  = 1
         no_function_module       = 2
         OTHERS                   = 3
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      DATA : control_parameters    TYPE  ssfctrlop,
             print_options         TYPE  ssfcompop.
      DATA : document_output_info  TYPE  ssfcrespd,
             job_output_info       TYPE  ssfcrescl,
             job_output_options    TYPE  ssfcresop.
      DATA : count TYPE i.
      control_parameters-langu = 'AR'.
      control_parameters-no_dialog = 'X'."Don't show Dialog
    print_options-tdarmod = '1'.
    print_options-tdcopies = '001'.
    print_options-tddest = 'LP02'.
    print_options-tdprinter = 'ZARSWIN'.
       print_options-tdimmed = 'X'.
    print_options-tddelete = 'X'.
    print_options-tdlifetime = '8'.
       print_options-tddest = 'LP03'."nast-ldest.
      "print_options-tddest = nast-ldest.
      "print_options-tdcopies = pv_copies.
    print_options-tddelete = 'X'.
      print_options-tdfinal = 'X'.
    print_options-tdnewid = 'X'.
    WHILE count ne 1.
       IF job_output_info-outputdone ne 'X'.
         CALL FUNCTION g_fm_name
          EXPORTING
        ARCHIVE_INDEX             =
        ARCHIVE_INDEX_TAB         =
        ARCHIVE_PARAMETERS        =
           control_parameters       = control_parameters
        MAIL_APPL_OBJ             =
        MAIL_RECIPIENT            =
        MAIL_SENDER               =
            output_options          = print_options
            user_settings           = space
            header                  = itab
            amountspell             = amountspell
            currtxt                 = currtxet
            secondpart              = secondpart
         wa_footer                = w_footer
       IMPORTING
         DOCUMENT_OUTPUT_INFO       = document_output_info
         JOB_OUTPUT_INFO            = job_output_info
         JOB_OUTPUT_OPTIONS         = job_output_options
          TABLES
            it_items                = t_items
            it_footer               = it_footer
       EXCEPTIONS
         formatting_error           = 1
         internal_error             = 2
         send_error                 = 3
         user_canceled              = 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.
    ENDFORM.                    "ENTRY

    Hi,
    lw_control_param-device = 'PRINTER'.
    lw_control_param-getotf = c_x.
    lw_control_param-no_dialog = c_x.
    lw_composer_param-tdnoprev = c_x.
    <b>*lw_composer_param-tddest = 'LONSC0P310'.</b>
    <b>lw_composer_param-tddest = 'XXXX'.</b> <b>"Four digits</b>
    <i>lw_composer_param-tdnewid = c_x.
    lw_composer_param-tdfinal = c_x.</i> --> Not required
    In place of 'XXXX', replace it by a 4 digit value. It would be available in transaction SPAD->Output Devices->Double click your output device. On the right hand side there would be a field Short Name. Replace 'XXXX' with that value.
    Best regards,
    Prashant

  • Report - SD module

    Hi,
    I am creating a report for SD module.
    I have to fetch the billing docs for a given date and find the open sales orders & print the report.
    I could fetch the billing docs...open sales order for the given date.
    What is the relation (link) between the Billing and the sales orders. HOw will i find out that the Open sales order and the billing doc. belong to the sales order made by the customer.
    Thank you

    Relation between a sales order and a Billing document ( Invoice ).
    After the sales order is processed then comes the stage of Delivery where the items under the sales order are processed , picked , packed and Pgi'ed (goods issue is completed) .
    once this is done then an Invoice (billing document number is generated for that delivery )
    This is the Sequence.
    For ur understanding goto VF03 and give an invoice number as input and hit an enter.
    Now in the screen at the left top corner in the select Document Flow (shift+F7) and click that .. This will show u the status of the sales order /delivery /invoice number.
    sales order in VBAK---item VBAP
    delivery      in LIKP  ---iteM LIPS
    Invoice       in VBRK---item VBRP
    in order to capture the sales order as open or closed ..
    You need to proceed like
    take the sales order number and goto table VBUK and input the sales order number and check for field VBUK-GBSTK NE C
    if its C then its Closed else if it is A or B then its open .
    GBSTK--is the overall processing status for the order ..
    U need to write a join for this or directly fetch the entry from table VBAKUK.
    here is a sample code to fetch the open orders at header and item level.
    execute the code to understand teh logic
    REPORT ZEX2  MESSAGE-ID arc NO STANDARD PAGE HEADING.
    Tables :kna1,vbak.
    SELECT-OPTIONS : so_vkorg FOR  vbak-vkorg OBLIGATORY, "sales area
                     so_vtweg FOR  vbak-vtweg OBLIGATORY,
                     so_spart FOR  vbak-spart,                                 
                     so_kunnr FOR  kna1-kunnr.                        "ur customer 
    DATA : BEGIN OF sales_open OCCURS 0 ,
           vbeln LIKE vbak-vbeln,
           auart LIKE vbak-auart,
           kunnr LIKE kna1-kunnr,
           bstnk LIKE vbak-bstnk,
           lfstk LIKE vbuk-lfstk,
           fkstk LIKE vbuk-fkstk,
           gbstk LIKE vbuk-gbstk,
           END OF sales_open.
    DATA : BEGIN OF itm_sales OCCURS 0,
           vbeln LIKE vbap-vbeln,
           posnr LIKE vbap-posnr,
           matnr LIKE vbap-matnr,
           kwmeng like vbap-kwmeng,
           lfsta LIKE vbup-lfsta,
           lfgsa LIKE vbup-lfgsa,
           fksta LIKE vbup-fksta,
           fksaa LIKE vbup-fksaa,
           gbsta LIKE vbup-gbsta,
           END OF itm_sales.
    DATA : l_kunnr LIKE kna1-kunnr,
           l_vkorg LIKE vbak-vkorg,
           l_vtweg LIKE vbak-vtweg,
           l_spart LIKE vbak-spart.
    DATA: v_statusl(20) TYPE c,
          v_statusb(20) TYPE c,
          v_statusf(20) TYPE c,
          v_statusg(20) TYPE c,
          v_status(20) TYPE c,
          v_field(1) TYPE c.
    data : v_openqty like vbap-kwmeng.
    **Selection Screen Validations.
    AT SELECTION-SCREEN.
      PERFORM validations.
    *&      Form  Validations
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM validations.
    **Customer
      IF NOT so_kunnr[] IS INITIAL.
        SELECT SINGLE kunnr INTO l_kunnr
               FROM kna1
               WHERE kunnr IN so_kunnr.
        IF sy-subrc NE 0.
          MESSAGE e002 WITH text-005.
        ENDIF.
      ENDIF.
    **Sales Organization
      IF NOT so_vkorg[] IS INITIAL.
        SELECT SINGLE vkorg INTO l_vkorg
               FROM tvko
               WHERE vkorg IN so_vkorg.
        IF sy-subrc NE 0.
          MESSAGE e003 WITH text-006.
        ENDIF.
      ENDIF.
    **Distribution Channel
      IF NOT so_vtweg[] IS INITIAL.
        SELECT SINGLE vtweg INTO l_vtweg
                FROM tvkov
                WHERE   vkorg IN so_vkorg
                 AND    vtweg IN so_vtweg.
        IF sy-subrc NE 0.
          MESSAGE e004 WITH text-007.
        ENDIF.
      ENDIF.
    **Division
      IF NOT so_spart[] IS INITIAL.
        SELECT SINGLE spart INTO l_spart
                FROM tvta
                WHERE   vkorg IN so_vkorg
                AND     vtweg IN so_vtweg
                AND     spart IN so_spart.
        IF sy-subrc NE 0.
          MESSAGE e005 WITH text-008.
        ENDIF.
      ENDIF.
    ENDFORM.                    " Validations
    Top-of-page.
    PERFORM sales_top_of_page.
    Start-of-selection.
    PERFORM sales_sel.
    *&      Form  sales_sel
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM sales_sel.
    SELECT vbeln auart kunnr bstnk
         lfstk fkstk gbstk
         INTO TABLE sales_open
         FROM vbakuk
         WHERE vkorg IN so_vkorg
         AND   vtweg IN so_vtweg
         AND   spart IN so_spart
         AND   kunnr IN so_kunnr
         AND gbstk NE 'C'.
      LOOP AT sales_open.
        WRITE:/4 sy-vline,
               5 sales_open-vbeln HOTSPOT ON COLOR 2 INTENSIFIED OFF,
               16 sy-vline,
               17 sales_open-auart COLOR 2 INTENSIFIED OFF,
               27 sy-vline,
               28 sales_open-kunnr COLOR 2 INTENSIFIED OFF,
               40 sy-vline,
               41 sales_open-bstnk COLOR 2 INTENSIFIED OFF,
               55 sy-vline,
               56 sales_open-lfstk,
               76 sy-vline,
               77 sales_open-fkstk,
               96 sy-vline,
               97 sales_open-gbstk ,
               117 sy-vline.
        HIDE sales_open-vbeln .
      ENDLOOP.
    ENDFORM.                    " sales_sel
    *&      Form  sales_top_of_page
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM sales_top_of_page.
      WRITE:/4 sy-uline(114),
         50 'OPEN SALES ORDERS' COLOR 7 INTENSIFIED ON .
      WRITE: /4 sy-vline,
              5 'SalesOrder' COLOR 1 ,
              16 sy-vline,
             17  'OrderType' COLOR 1,
             27  sy-vline,
             28  'Customer' COLOR 1,
             40  sy-vline,
             41  'PoNumber' COLOR 1,
             55  sy-vline,
             56  'Delivery Status' COLOR 1,
             76  sy-vline,
             77  'Billing Status' COLOR 1,
             96  sy-vline,
             97  'Processing Status' COLOR 1,
             117  sy-vline .
      WRITE:/4 sy-uline(114).
    ENDFORM.                    " sales_top_of_page
    AT LINE-SELECTION.
      SELECT       a~vbeln
                   a~posnr
                   a~matnr
                   a~kwmeng
                   b~lfsta
                   b~lfgsa
                   b~fksta
                   b~fksaa
                   b~gbsta
                   INTO TABLE itm_sales
                   FROM vbap AS a JOIN vbup AS b
                   ON a~vbeln EQ b~vbeln
                   AND a~posnr EQ b~posnr
                   AND b~gbsta NE 'C'
                   WHERE a~vbeln EQ sales_open-vbeln.
      IF NOT sales_open IS INITIAL.
        LOOP AT itm_sales.
          at end of vbeln .
          sum.
          v_openqty = itm_sales-kwmeng.
          endat.
          WRITE:/5  itm_sales-vbeln,
                    itm_sales-posnr,
                    itm_sales-matnr,
                    itm_sales-kwmeng,
                    itm_sales-lfsta,
                    itm_sales-lfgsa,
                    itm_sales-fksta,
                    itm_sales-fksaa,
                    itm_sales-gbsta.
        ENDLOOP.
      ENDIF.
    skip 2.
      write:/  'open Quantity for the order is ', v_openqty .
    in order to fetch the invoice number from sales order ..
    goto table VBFA and give the input as sales order number in Preceding document no(VBELV) and in the Document category of subsequent document (VBTYP_N) give it as caps 'M'
    for fetching delivery from sales order same as above with vbtyp_n = 'J'.
    regards,
    vijay

  • Open Orders Report.

    Hello,
    Can anyone give me the code for the open orders report??Using the tables VBAP,VBAK and VBUK.
    Thanking you in anticipation.
    Regards,
    Sirisha.

    hi sirisha ,
    check this code for open sales order(basic list) + open items (secondary list).
    check the status as A--not yet processed..  
                        B--partially processed
                        C--completely processed
    hope this helps u out in getting the functionality.
    u can take the header data from vbakuk ( vbak + vbuk )
    and items from vbap as shown ..
    fetching the data from vbakuk minimizes joins on vbak and vbuk.
    execute the below code.
    REPORT ZEX2  MESSAGE-ID arc NO STANDARD PAGE HEADING.
    Tables :kna1,vbak.
    SELECT-OPTIONS : so_vkorg FOR  vbak-vkorg OBLIGATORY,
                     so_vtweg FOR  vbak-vtweg OBLIGATORY,
                     so_spart FOR  vbak-spart,
                     so_kunnr FOR  kna1-kunnr.
    DATA : BEGIN OF sales_open OCCURS 0 ,
           vbeln LIKE vbak-vbeln,
           auart LIKE vbak-auart,
           kunnr LIKE kna1-kunnr,
           bstnk LIKE vbak-bstnk,
           lfstk LIKE vbuk-lfstk,
           fkstk LIKE vbuk-fkstk,
           gbstk LIKE vbuk-gbstk,
           END OF sales_open.
    DATA : BEGIN OF itm_sales OCCURS 0,
           vbeln LIKE vbap-vbeln,
           posnr LIKE vbap-posnr,
           matnr LIKE vbap-matnr,
           lfsta LIKE vbup-lfsta,
           lfgsa LIKE vbup-lfgsa,
           fksta LIKE vbup-fksta,
           fksaa LIKE vbup-fksaa,
           gbsta LIKE vbup-gbsta,
           END OF itm_sales.
    DATA : l_kunnr LIKE kna1-kunnr,
           l_vkorg LIKE vbak-vkorg,
           l_vtweg LIKE vbak-vtweg,
           l_spart LIKE vbak-spart.
    DATA: v_statusl(20) TYPE c,
          v_statusb(20) TYPE c,
          v_statusf(20) TYPE c,
          v_statusg(20) TYPE c,
          v_status(20) TYPE c,
          v_field(1) TYPE c.
    **Selection Screen Validations.
    AT SELECTION-SCREEN.
      PERFORM validations.
    *&      Form  Validations
          text
    -->  p1        text
    <--  p2        text
    FORM validations.
    **Customer
      IF NOT so_kunnr[] IS INITIAL.
        SELECT SINGLE kunnr INTO l_kunnr
               FROM kna1
               WHERE kunnr IN so_kunnr.
        IF sy-subrc NE 0.
          MESSAGE e002 WITH text-005.
        ENDIF.
      ENDIF.
    **Sales Organization
      IF NOT so_vkorg[] IS INITIAL.
        SELECT SINGLE vkorg INTO l_vkorg
               FROM tvko
               WHERE vkorg IN so_vkorg.
        IF sy-subrc NE 0.
          MESSAGE e003 WITH text-006.
        ENDIF.
      ENDIF.
    **Distribution Channel
      IF NOT so_vtweg[] IS INITIAL.
        SELECT SINGLE vtweg INTO l_vtweg
                FROM tvkov
                WHERE   vkorg IN so_vkorg
                 AND    vtweg IN so_vtweg.
        IF sy-subrc NE 0.
          MESSAGE e004 WITH text-007.
        ENDIF.
      ENDIF.
    **Division
      IF NOT so_spart[] IS INITIAL.
        SELECT SINGLE spart INTO l_spart
                FROM tvta
                WHERE   vkorg IN so_vkorg
                AND     vtweg IN so_vtweg
                AND     spart IN so_spart.
        IF sy-subrc NE 0.
          MESSAGE e005 WITH text-008.
        ENDIF.
      ENDIF.
    ENDFORM.                    " Validations
    Top-of-page.
    PERFORM sales_top_of_page.
    Start-of-selection.
    PERFORM sales_sel.
    *&      Form  sales_sel
          text
    -->  p1        text
    <--  p2        text
    FORM sales_sel.
    SELECT vbeln auart kunnr bstnk
         lfstk fkstk gbstk
         INTO TABLE sales_open
         FROM vbakuk
         WHERE vkorg IN so_vkorg
         AND   vtweg IN so_vtweg
         AND   spart IN so_spart
         AND   kunnr IN so_kunnr
         AND gbstk NE 'C'.
      LOOP AT sales_open.
        WRITE:/4 sy-vline,
               5 sales_open-vbeln HOTSPOT ON COLOR 2 INTENSIFIED OFF,
               16 sy-vline,
               17 sales_open-auart COLOR 2 INTENSIFIED OFF,
               27 sy-vline,
               28 sales_open-kunnr COLOR 2 INTENSIFIED OFF,
               40 sy-vline,
               41 sales_open-bstnk COLOR 2 INTENSIFIED OFF,
               55 sy-vline,
               56 sales_open-lfstk,
               76 sy-vline,
               77 sales_open-fkstk,
               96 sy-vline,
               97 sales_open-gbstk ,
               117 sy-vline.
        HIDE sales_open-vbeln .
      ENDLOOP.
    ENDFORM.                    " sales_sel
    *&      Form  sales_top_of_page
          text
    -->  p1        text
    <--  p2        text
    FORM sales_top_of_page.
      WRITE:/4 sy-uline(114),
         50 'OPEN SALES ORDERS' COLOR 7 INTENSIFIED ON .
      WRITE: /4 sy-vline,
              5 'SalesOrder' COLOR 1 ,
              16 sy-vline,
             17  'OrderType' COLOR 1,
             27  sy-vline,
             28  'Customer' COLOR 1,
             40  sy-vline,
             41  'PoNumber' COLOR 1,
             55  sy-vline,
             56  'Delivery Status' COLOR 1,
             76  sy-vline,
             77  'Billing Status' COLOR 1,
             96  sy-vline,
             97  'Processing Status' COLOR 1,
             117  sy-vline .
      WRITE:/4 sy-uline(114).
    ENDFORM.                    " sales_top_of_page
    AT LINE-SELECTION.
      SELECT       a~vbeln
                   a~posnr
                   a~matnr
                a~kwmeng
                   b~lfsta
                   b~lfgsa
                   b~fksta
                   b~fksaa
                   b~gbsta
                   INTO TABLE itm_sales
                   FROM vbap AS a JOIN vbup AS b
                   ON avbeln EQ bvbeln
                   AND aposnr EQ bposnr
                   AND b~gbsta NE 'C'
                   WHERE a~vbeln EQ sales_open-vbeln.
      IF NOT sales_open IS INITIAL.
        LOOP AT itm_sales.
          WRITE:/5  itm_sales-vbeln,
                    itm_sales-posnr,
                    itm_sales-matnr,
                    itm_sales-lfsta,
                    itm_sales-lfgsa,
                    itm_sales-fksta,
                    itm_sales-fksaa,
                    itm_sales-gbsta.
        ENDLOOP.
      ENDIF.
    Regards,
    Vijay
    check the entries with t-code va05 for the same criteria.
    Message was edited by: Vijay

  • Function module for document flow

    Hi,
    I am developing a report on sales.
    i need to display the delivery and billing status of the sale order in the report.
    Is there any function module to get both the delivery and billing status for the input parameter sale order number.....?
    Thanks in advance....
    Raghav

    hi , check the code
    REPORT ZEX2  MESSAGE-ID arc NO STANDARD PAGE HEADING.
    Tables :kna1,vbak.
    SELECT-OPTIONS : so_vkorg FOR  vbak-vkorg OBLIGATORY,
                     so_vtweg FOR  vbak-vtweg OBLIGATORY,
                     so_spart FOR  vbak-spart,
                     so_kunnr FOR  kna1-kunnr.
    DATA : BEGIN OF sales_open OCCURS 0 ,
           vbeln LIKE vbak-vbeln,
           auart LIKE vbak-auart,
           kunnr LIKE kna1-kunnr,
           bstnk LIKE vbak-bstnk,
           lfstk LIKE vbuk-lfstk,
           fkstk LIKE vbuk-fkstk,
           gbstk LIKE vbuk-gbstk,
           END OF sales_open.
    DATA : BEGIN OF itm_sales OCCURS 0,
           vbeln LIKE vbap-vbeln,
           posnr LIKE vbap-posnr,
           matnr LIKE vbap-matnr,
           lfsta LIKE vbup-lfsta,
           lfgsa LIKE vbup-lfgsa,
           fksta LIKE vbup-fksta,
           fksaa LIKE vbup-fksaa,
           gbsta LIKE vbup-gbsta,
           END OF itm_sales.
    DATA : l_kunnr LIKE kna1-kunnr,
           l_vkorg LIKE vbak-vkorg,
           l_vtweg LIKE vbak-vtweg,
           l_spart LIKE vbak-spart.
    DATA: v_statusl(20) TYPE c,
          v_statusb(20) TYPE c,
          v_statusf(20) TYPE c,
          v_statusg(20) TYPE c,
          v_status(20) TYPE c,
          v_field(1) TYPE c.
    **Selection Screen Validations.
    AT SELECTION-SCREEN.
      PERFORM validations.
    *&      Form  Validations
          text
    -->  p1        text
    <--  p2        text
    FORM validations.
    **Customer
      IF NOT so_kunnr[] IS INITIAL.
        SELECT SINGLE kunnr INTO l_kunnr
               FROM kna1
               WHERE kunnr IN so_kunnr.
        IF sy-subrc NE 0.
          MESSAGE e002 WITH text-005.
        ENDIF.
      ENDIF.
    **Sales Organization
      IF NOT so_vkorg[] IS INITIAL.
        SELECT SINGLE vkorg INTO l_vkorg
               FROM tvko
               WHERE vkorg IN so_vkorg.
        IF sy-subrc NE 0.
          MESSAGE e003 WITH text-006.
        ENDIF.
      ENDIF.
    **Distribution Channel
      IF NOT so_vtweg[] IS INITIAL.
        SELECT SINGLE vtweg INTO l_vtweg
                FROM tvkov
                WHERE   vkorg IN so_vkorg
                 AND    vtweg IN so_vtweg.
        IF sy-subrc NE 0.
          MESSAGE e004 WITH text-007.
        ENDIF.
      ENDIF.
    **Division
      IF NOT so_spart[] IS INITIAL.
        SELECT SINGLE spart INTO l_spart
                FROM tvta
                WHERE   vkorg IN so_vkorg
                AND     vtweg IN so_vtweg
                AND     spart IN so_spart.
        IF sy-subrc NE 0.
          MESSAGE e005 WITH text-008.
        ENDIF.
      ENDIF.
    ENDFORM.                    " Validations
    Top-of-page.
    PERFORM sales_top_of_page.
    Start-of-selection.
    PERFORM sales_sel.
    *&      Form  sales_sel
          text
    -->  p1        text
    <--  p2        text
    FORM sales_sel.
    SELECT vbeln auart kunnr bstnk
         lfstk fkstk gbstk
         INTO TABLE sales_open
         FROM vbakuk
         WHERE vkorg IN so_vkorg
         AND   vtweg IN so_vtweg
         AND   spart IN so_spart
         AND   kunnr IN so_kunnr
         AND gbstk NE 'C'.
      LOOP AT sales_open.
        WRITE:/4 sy-vline,
               5 sales_open-vbeln HOTSPOT ON COLOR 2 INTENSIFIED OFF,
               16 sy-vline,
               17 sales_open-auart COLOR 2 INTENSIFIED OFF,
               27 sy-vline,
               28 sales_open-kunnr COLOR 2 INTENSIFIED OFF,
               40 sy-vline,
               41 sales_open-bstnk COLOR 2 INTENSIFIED OFF,
               55 sy-vline,
               56 sales_open-lfstk,
               76 sy-vline,
               77 sales_open-fkstk,
               96 sy-vline,
               97 sales_open-gbstk ,
               117 sy-vline.
        HIDE sales_open-vbeln .
      ENDLOOP.
    ENDFORM.                    " sales_sel
    *&      Form  sales_top_of_page
          text
    -->  p1        text
    <--  p2        text
    FORM sales_top_of_page.
      WRITE:/4 sy-uline(114),
         50 'OPEN SALES ORDERS' COLOR 7 INTENSIFIED ON .
      WRITE: /4 sy-vline,
              5 'SalesOrder' COLOR 1 ,
              16 sy-vline,
             17  'OrderType' COLOR 1,
             27  sy-vline,
             28  'Customer' COLOR 1,
             40  sy-vline,
             41  'PoNumber' COLOR 1,
             55  sy-vline,
             56  'Delivery Status' COLOR 1,
             76  sy-vline,
             77  'Billing Status' COLOR 1,
             96  sy-vline,
             97  'Processing Status' COLOR 1,
             117  sy-vline .
      WRITE:/4 sy-uline(114).
    ENDFORM.                    " sales_top_of_page
    AT LINE-SELECTION.
      SELECT       a~vbeln
                   a~posnr
                   a~matnr
                a~kwmeng
                   b~lfsta
                   b~lfgsa
                   b~fksta
                   b~fksaa
                   b~gbsta
                   INTO TABLE itm_sales
                   FROM vbap AS a JOIN vbup AS b
                   ON avbeln EQ bvbeln
                   AND aposnr EQ bposnr
                   AND b~gbsta NE 'C'
                   WHERE a~vbeln EQ sales_open-vbeln.
      IF NOT sales_open IS INITIAL.
        LOOP AT itm_sales.
          WRITE:/5  itm_sales-vbeln,
                    itm_sales-posnr,
                    itm_sales-matnr,
                    itm_sales-lfsta,
                    itm_sales-lfgsa,
                    itm_sales-fksta,
                    itm_sales-fksaa,
                    itm_sales-gbsta.
        ENDLOOP.
      ENDIF.

  • Details of open invoices for the current year/ material price analysis

    Hi,
    I'm very new to SAP SD,MM modules. Can any one help me in the following of my requirements?
    1. How to get the details of open invoices for the current year? Which table should I look into?
    2. I have to create a report to display material price analysis. How should I do that?
    3. How to develope a report to list out all the Open Sales Order with earliest ship date and requested ship date
    4.How to create an interactive report for displaying plant status to know the status of a particular material
    5. How to develope a report on Sales Order displaying Sales order Number, Sales order date, Material, PO Date and Customer requested date
    Thanks in advance!!
    Uma.
    Message was edited by:
            Uma Ravi

    Hi Ravi,
    for 3, 4, 5 --> u can go through the code ...
    REPORT ZEX2  MESSAGE-ID arc NO STANDARD PAGE HEADING.
    Tables :kna1,vbak.
    SELECT-OPTIONS : so_vkorg FOR  vbak-vkorg OBLIGATORY,
                     so_vtweg FOR  vbak-vtweg OBLIGATORY,
                     so_spart FOR  vbak-spart,
                     so_kunnr FOR  kna1-kunnr.
    DATA : BEGIN OF sales_open OCCURS 0 ,
           vbeln LIKE vbak-vbeln,
           auart LIKE vbak-auart,
           kunnr LIKE kna1-kunnr,
           bstnk LIKE vbak-bstnk,
           lfstk LIKE vbuk-lfstk,
           fkstk LIKE vbuk-fkstk,
           gbstk LIKE vbuk-gbstk,
           END OF sales_open.
    DATA : BEGIN OF itm_sales OCCURS 0,
           vbeln LIKE vbap-vbeln,
           posnr LIKE vbap-posnr,
           matnr LIKE vbap-matnr,
           kwmeng like vbap-kwmeng,
           lfsta LIKE vbup-lfsta,
           lfgsa LIKE vbup-lfgsa,
           fksta LIKE vbup-fksta,
           fksaa LIKE vbup-fksaa,
           gbsta LIKE vbup-gbsta,
           END OF itm_sales.
    DATA : l_kunnr LIKE kna1-kunnr,
           l_vkorg LIKE vbak-vkorg,
           l_vtweg LIKE vbak-vtweg,
           l_spart LIKE vbak-spart.
    DATA: v_statusl(20) TYPE c,
          v_statusb(20) TYPE c,
          v_statusf(20) TYPE c,
          v_statusg(20) TYPE c,
          v_status(20) TYPE c,
          v_field(1) TYPE c.
    data : v_openqty like vbap-kwmeng.
    **Selection Screen Validations.
    AT SELECTION-SCREEN.
      PERFORM validations.
    *&      Form  Validations
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM validations.
    **Customer
      IF NOT so_kunnr[] IS INITIAL.
        SELECT SINGLE kunnr INTO l_kunnr
               FROM kna1
               WHERE kunnr IN so_kunnr.
        IF sy-subrc NE 0.
          MESSAGE e002 WITH text-005.
        ENDIF.
      ENDIF.
    **Sales Organization
      IF NOT so_vkorg[] IS INITIAL.
        SELECT SINGLE vkorg INTO l_vkorg
               FROM tvko
               WHERE vkorg IN so_vkorg.
        IF sy-subrc NE 0.
          MESSAGE e003 WITH text-006.
        ENDIF.
      ENDIF.
    **Distribution Channel
      IF NOT so_vtweg[] IS INITIAL.
        SELECT SINGLE vtweg INTO l_vtweg
                FROM tvkov
                WHERE   vkorg IN so_vkorg
                 AND    vtweg IN so_vtweg.
        IF sy-subrc NE 0.
          MESSAGE e004 WITH text-007.
        ENDIF.
      ENDIF.
    **Division
      IF NOT so_spart[] IS INITIAL.
        SELECT SINGLE spart INTO l_spart
                FROM tvta
                WHERE   vkorg IN so_vkorg
                AND     vtweg IN so_vtweg
                AND     spart IN so_spart.
        IF sy-subrc NE 0.
          MESSAGE e005 WITH text-008.
        ENDIF.
      ENDIF.
    ENDFORM.                    " Validations
    Top-of-page.
    PERFORM sales_top_of_page.
    Start-of-selection.
    PERFORM sales_sel.
    *&      Form  sales_sel
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM sales_sel.
    SELECT vbeln auart kunnr bstnk
         lfstk fkstk gbstk
         INTO TABLE sales_open
         FROM vbakuk
         WHERE vkorg IN so_vkorg
         AND   vtweg IN so_vtweg
         AND   spart IN so_spart
         AND   kunnr IN so_kunnr
         AND gbstk NE 'C'.
      LOOP AT sales_open.
        WRITE:/4 sy-vline,
               5 sales_open-vbeln HOTSPOT ON COLOR 2 INTENSIFIED OFF,
               16 sy-vline,
               17 sales_open-auart COLOR 2 INTENSIFIED OFF,
               27 sy-vline,
               28 sales_open-kunnr COLOR 2 INTENSIFIED OFF,
               40 sy-vline,
               41 sales_open-bstnk COLOR 2 INTENSIFIED OFF,
               55 sy-vline,
               56 sales_open-lfstk,
               76 sy-vline,
               77 sales_open-fkstk,
               96 sy-vline,
               97 sales_open-gbstk ,
               117 sy-vline.
        HIDE sales_open-vbeln .
      ENDLOOP.
    ENDFORM.                    " sales_sel
    *&      Form  sales_top_of_page
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM sales_top_of_page.
      WRITE:/4 sy-uline(114),
         50 'OPEN SALES ORDERS' COLOR 7 INTENSIFIED ON .
      WRITE: /4 sy-vline,
              5 'SalesOrder' COLOR 1 ,
              16 sy-vline,
             17  'OrderType' COLOR 1,
             27  sy-vline,
             28  'Customer' COLOR 1,
             40  sy-vline,
             41  'PoNumber' COLOR 1,
             55  sy-vline,
             56  'Delivery Status' COLOR 1,
             76  sy-vline,
             77  'Billing Status' COLOR 1,
             96  sy-vline,
             97  'Processing Status' COLOR 1,
             117  sy-vline .
      WRITE:/4 sy-uline(114).
    ENDFORM.                    " sales_top_of_page
    AT LINE-SELECTION.
      SELECT       a~vbeln
                   a~posnr
                   a~matnr
                   a~kwmeng
                   b~lfsta
                   b~lfgsa
                   b~fksta
                   b~fksaa
                   b~gbsta
                   INTO TABLE itm_sales
                   FROM vbap AS a JOIN vbup AS b
                   ON a~vbeln EQ b~vbeln
                   AND a~posnr EQ b~posnr
                   AND b~gbsta NE 'C'
                   WHERE a~vbeln EQ sales_open-vbeln.
      IF NOT sales_open IS INITIAL.
        LOOP AT itm_sales.
          at end of vbeln .
          sum.
          v_openqty = itm_sales-kwmeng.
          endat.
          WRITE:/5  itm_sales-vbeln,
                    itm_sales-posnr,
                    itm_sales-matnr,
                    itm_sales-kwmeng,
                    itm_sales-lfsta,
                    itm_sales-lfgsa,
                    itm_sales-fksta,
                    itm_sales-fksaa,
                    itm_sales-gbsta.
        ENDLOOP.
      ENDIF.
    skip 2.
      write:/  'open Quantity for the order is ', v_openqty .
    for 1.
    open invoices..
    SELECT vbeln
             fkart
             kunag
             gbstk
             INTO TABLE it_billing_h
             FROM vbrkuk
             WHERE vkorg IN so_vkorg
             AND vtweg IN so_vtweg
    *        AND spart IN so_spart
             AND kunag IN so_kunnr
            and   year in p_year                  ---->"parameter for year..
             AND gbstk NE 'C'.                   "----> open invoices
    for 2..
    2. refer TABLES mara, EINA ..
    regards,
    VIjay

  • Urgent , abap select statement error ...

    Hi all ,
    here i attached my code , has anyone can tell me where is the error ???
    when i active this code , it showed :
    "comma without preceding colon(after select?)"
    thanks a lot !
    SELECT LIPSERDAT LIPSVBELN LIPSPOSNR LIPSVGPOS LIPS~LFIMG
    LIPSVRKME LIKPWADAT_IST LIKPKUNAG LIKPKUNNR LIKP~VBELN
    VBAPVBELN VBAPMATNR VBAPNETWR VBAPWAERK VBAPMWSBP VBAPNETPR
    VBAPPOSNR VBUPKOSTA VBUPWBSTA VBUPFKSTA VBUPPOSNR VBUPVBELN
    VBPAPARVW VBPAVBELN VBUKCMGST VBUKVBELN VBAKAUART VBAKVBELN
    INTO (
    WASTATUS-ERDAT , WASTATUS-VBELN , WASTATUS-POSNR ,
    WASTATUS-VGPOS , WASTATUS-LFIMG , WASTATUS-VRKME ,
    WASTATUS-WADAT_IST , WASTATUS-KUNAG ,WASTATUS-KUNNR ,
    WASTATUS-LIKPVBELN , WASTATUS-VBAPVBELN , WASTATUS-MATNR ,
    WASTATUS-NETWR , WASTATUS-WAERK , WASTATUS-MWSBP ,
    WASTATUS-NETPR , WASTATUS-POSNR , WASTATUS-KOSTA , WASTATUS-WBSTA ,
    WASTATUS-FKSTA , WASTATUS-VBUPPOSNR , WASTATUS-VBUPVBELN ,
    WASTATUS-PARVW , WASTATUS-VBPAVBELN , WASTATUS-CMGST ,
    WASTATUS-VBUKVBELN , WASTATUS-AUART , WASTATUS-VBAKVBELN )
        FROM ( LIPS inner join LIKP
               on  LIKPVBELN = LIPSVBELN
               inner join VBAP
               on  VBAPVBELN = LIPSVGBEL
               and VBAPPOSNR = LIPSVGPOS
               inner join VBUP
               on  VBUPPOSNR = LIPSPOSNR
               and VBUPVBELN = LIPSVBELN
               inner join VBPA
               on  VBPAVBELN = LIPSVBELN
               inner join VBUK
               on  VBUKVBELN = LIPSVBELN
               inner join VBAK
               on  VBAKVBELN = VBAPVBELN )
            WHERE
               LIPS~VBELN in P_SVBELN
               and LIPS~ERDAT in P_ERDAT
               and LIKP~KUNAG in P_KUNAG
               and LIKP~KUNNR in P_KUNNR
               and VBAP~VBELN in P_PVBELN
               and VBUP~KOSTA in P_KOSTA
               and VBUP~WBSTA in P_WBSTA
               and VBUP~FKSTA in P_FKSTA
               and VBPA~PARVW in P_PARVW
               and VBUK~CMGST in P_CMGST .

    sorry all ,
       i already removed the space on my code like that :
       but it still displayed the error .
    SELECT LIPS~ERDAT
    <b>*LIPSVBELN LIPSPOSNR LIPSVGPOS LIPSLFIMG
    *LIPSVRKME LIKPWADAT_IST LIKPKUNAG LIKPKUNNR LIKP~VBELN
    *VBAPVBELN VBAPMATNR VBAPNETWR VBAPWAERK VBAPMWSBP VBAPNETPR
    *VBAPPOSNR VBUPKOSTA VBUPWBSTA VBUPFKSTA VBUPPOSNR VBUPVBELN
    *VBPAPARVW VBPAVBELN VBUKCMGST VBUKVBELN VBAKAUART VBAKVBELN</b>    FROM ( LIPS inner join LIKP
               on  LIKPVBELN = LIPSVBELN
               inner join VBAP
               on  VBAPVBELN = LIPSVGBEL
               and VBAPPOSNR = LIPSVGPOS
               inner join VBUP
               on  VBUPPOSNR = LIPSPOSNR
               and VBUPVBELN = LIPSVBELN
               inner join VBPA
               on  VBPAVBELN = LIPSVBELN
               inner join VBUK
               on  VBUKVBELN = LIPSVBELN
               inner join VBAK
               on  VBAKVBELN = VBAPVBELN )
    INTO (WASTATUS-ERDAT)
    <b>*WASTATUS-VBELN, WASTATUS-POSNR, WASTATUS-VGPOS,WASTATUS-LFIMG)
    *WASTATUS-VRKME,
    *WASTATUS-WADAT_IST, WASTATUS-KUNAG,WASTATUS-KUNNR,
    *WASTATUS-LIKPVBELN, WASTATUS-VBAPVBELN, WASTATUS-MATNR,
    *WASTATUS-NETWR, WASTATUS-WAERK, WASTATUS-MWSBP,
    *WASTATUS-NETPR, WASTATUS-POSNR, WASTATUS-KOSTA, WASTATUS-WBSTA,
    *WASTATUS-FKSTA, WASTATUS-VBUPPOSNR, WASTATUS-VBUPVBELN,
    *WASTATUS-PARVW, WASTATUS-VBPAVBELN, WASTATUS-CMGST,
    *WASTATUS-VBUKVBELN, WASTATUS-AUART, WASTATUS-VBAKVBELN )</b>        WHERE
               LIPS~VBELN in P_SVBELN
               and LIPS~ERDAT in P_ERDAT
               and LIKP~KUNAG in P_KUNAG
               and LIKP~KUNNR in P_KUNNR
               and VBAP~VBELN in P_PVBELN
               and VBUP~KOSTA in P_KOSTA
               and VBUP~WBSTA in P_WBSTA
               and VBUP~FKSTA in P_FKSTA
               and VBPA~PARVW in P_PARVW
               and VBUK~CMGST in P_CMGST .

  • Need info on data retrieval

    1.I have an internal table <b>it_vbak</b> with fields <b>vbeln & auart</b>
    2. Select-options: <b>s_auart</b> for <b>vbak-auart</b>
    3. I need to retrieve data into <b>it_vbak</b> with the following condition :
      VBAK-VBELN = VBFA-VBELV and
      VBFA-VBELN = LIKP-VBELN and
    ( VBTYP_N = 'J'  or VBTYP_N ) and
    (VBTYP_V ='C' or VBTYP_V ='I')  and VBAK-AUART in s_auart.
    If I use Inner Join I can't use in s_auart.
    ...Please let me know

    hi,
    make use of for all entries
    first fetch the data from vbak where auart in s_auart(it_vbak_
    and the pass it to vbfa(it_vbfa)using for all entries
    the pass vbfa to likp using for all entries(it_likp)
    then take one final internal table (it_final) and populate final internal table.
    check this example for reference: my requirement si little bit different
    *& Report  ZRSDREPORT
    REPORT  ZRSDREPORT LINE-SIZE 230
                       NO STANDARD PAGE HEADING
                       MESSAGE-ID ZZ.
    Author           : Sudha Rani Pathuri                                *
    Date             : 07/04/2007                                        *
    Title            : DELIVERY STATUS REPORT                            *
    Program Type     : Executable Program                                *
    Tables Used:     : VBAK,VBAP,LIKP,LIPS,VBFA,VBUP                     *
    Purpose          : This report gives the status od the delivery      *
                       based on sales order data                         *
    *& TABLES DECLARATION                                                  *
    TABLES : VBAK,VBPA,LIKP.
    declaraing TYPEPOLL SLIS                                             *
    TYPE-POOLS : SLIS.
    *& SELECTION-SCREEN                                                    *
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECTION-SCREEN :SKIP 2.
    SELECT-OPTIONS:  S_VKORG FOR VBAK-VKORG NO-EXTENSION,
                     S_VTWEG FOR VBAK-VTWEG NO-EXTENSION,
                     S_SPART FOR VBAK-SPART NO-EXTENSION,
                     S_KUNNR FOR VBPA-KUNNR,
                    SO_KUNNR FOR VBPA-KUNNR,
                     S_VBELN FOR LIKP-VBELN NO-EXTENSION,
                     S_ERDAT FOR LIKP-ERDAT OBLIGATORY NO-EXTENSION,
                    SO_ERDAT FOR VBAK-ERDAT NO-EXTENSION.
    SELECTION-SCREEN :SKIP 2.
    SELECTION-SCREEN END OF BLOCK B1.
    *& TYPES DECARATION                                                    *
    *--types declaration for capturing vbeln from vbak
    TYPES : BEGIN OF TY_VBELN,
              VBELN   TYPE  VBELN,         "Sales Doc No
            END OF TY_VBELN,
    *--types declaration for vbap
            BEGIN OF TY_VBAP,
              VBELN   LIKE  VBAP-VBELN,    "Sales Document
              POSNR   LIKE  VBAP-POSNR,    "Sales Document Item
              MATNR   LIKE  VBAP-MATNR,    "Material Number
              KWMENG  LIKE  VBAP-KWMENG,   "Cumulative order quantity in
                                           "sales units
              KDMAT   LIKE  VBAP-KDMAT,    "Material Number Used by Customer
            END OF TY_VBAP,
    *--types declaration for vbfa
            BEGIN OF TY_VBFA,
              VBELV   LIKE  VBFA-VBELV,    "Preceding sales and distribution
                                           "document
              POSNV   LIKE  VBFA-POSNV,    "Preceding item of an SD document
              VBELN   LIKE  VBFA-VBELN,    "Subsequent s and d document
              POSNN   LIKE  VBFA-POSNN,    "Subsequent item of an SDdocument
            END OF TY_VBFA,
    *--types declaration for likp
            BEGIN OF TY_LIKP,
              VBELN   LIKE  LIKP-VBELN,    "Delivery no
            END OF TY_LIKP,
    *--types declaration for lips
            BEGIN OF TY_LIPS,
              VBELN   LIKE  LIPS-VBELN,    "Delivery
              POSNR   LIKE  LIPS-POSNR,    "Delivery item
              MATNR   LIKE  LIPS-MATNR,    "Material Number
              LFIMG   LIKE  LIPS-LFIMG,    "Actual quantity delivered (in
                                          sales units)
            vgbel   LIKE  lips-vgbel,    "Document number of the reference
                                          "document
            END OF TY_LIPS,
    *--types declaration for vbup
            BEGIN OF TY_VBUP,
              VBELN   LIKE  VBUP-VBELN,    "Sales and Distribution Document
                                           "Number
              POSNR   LIKE  VBUP-POSNR,    "Item number of the SD document
              LFSTA   LIKE  VBUP-LFSTA,    "Delivery status
              WBSTA   LIKE  VBUP-WBSTA,    "Goods movement status
              FKSTA   LIKE  VBUP-FKSTA,    "Billing status of delivery
                                           "related billing document
            END OF TY_VBUP,
    *--types declaration for final internal table for diplaying purpose
            BEGIN OF TY_FINAL,
              VBELN(10) TYPE C,
              POSNR   LIKE  VBAP-POSNR,
              MATNR   LIKE  VBAP-MATNR,
              KWMENG  LIKE  VBAP-KWMENG,
              KDMAT   LIKE  VBAP-KDMAT,
              VBELN1  LIKE  LIKP-VBELN,
              POSNR1  LIKE  LIPS-POSNR,
              LFIMG   LIKE  LIPS-LFIMG,
              MATNR1  LIKE  LIPS-MATNR,
              DS(25)  TYPE  C,
            END OF TY_FINAL.
    *& CONSTANTS DECARATION                                                *
    CONSTANTS: C_DTYPE TYPE C VALUE 'J'.
    *& INTERNAL TABLE DECARATION                                           *
    DATA : I_VBELN     TYPE STANDARD TABLE OF TY_VBELN    WITH HEADER LINE,
           I_VBAP      TYPE STANDARD TABLE OF TY_VBAP     WITH HEADER LINE,
           I_VBFA      TYPE STANDARD TABLE OF TY_VBFA     WITH HEADER LINE,
           I_LIKP      TYPE STANDARD TABLE OF TY_LIKP     WITH HEADER LINE,
           I_LIPS      TYPE STANDARD TABLE OF TY_LIPS     WITH HEADER LINE,
           I_VBUP      TYPE STANDARD TABLE OF TY_VBUP     WITH HEADER LINE,
           I_FINAL     TYPE STANDARD TABLE OF TY_FINAL    WITH HEADER LINE.
    *& FIELDCATALOG   DECARATION                                           *
    DATA : I_FIELDCAT TYPE   SLIS_T_FIELDCAT_ALV,
           W_FIELDCAT TYPE   SLIS_FIELDCAT_ALV,
           LT_SORT    TYPE   SLIS_T_SORTINFO_ALV,
           I_LAYOUT   TYPE   SLIS_LAYOUT_ALV.
    *& START-OF-SELECTION                                                  *
    START-OF-SELECTION.
    *--for fetching slaes and delivery data
      PERFORM GET_DATA.
    *--populating the data into one internal table for output
      PERFORM POPULATE_FINAL.
    *--for displaying the data using alv
      PERFORM CALL_ALV.
    *&      Form  get_data
    FORM GET_DATA .
    *--for retrieving vbeln from VBAK or VbAP
      PERFORM GET_VBELN.
    *--retrieving data from VBAP
      PERFORM GET_VBAP.
    *--fetching delivery document details using VBFA.
      PERFORM GET_VBFA.
    *--fetching delivery data from LIKP
      PERFORM GET_LIKP.
    *--fetching delivery data from LIPS
      PERFORM GET_LIPS.
    *--fetching data from VBUP
      PERFORM GET_VBUP.
    ENDFORM.                    " get_data
    *&      Form  get_vbeln
    FORM GET_VBELN .
    *--retrieving vbeln from either VBAK or VBPA
    *--checking whether payer or sold to values in the selection-screen or
                                                           give or not
      IF S_KUNNR IS INITIAL OR SO_KUNNR IS INITIAL.
    *--select statement for retrieving vbeln from vbak
        SELECT VBELN
               FROM VBAK
               INTO TABLE I_VBELN
               WHERE VKORG IN S_VKORG AND
                     VTWEG IN S_VTWEG  AND
                     SPART IN S_SPART AND
                     ERDAT IN S_ERDAT.
        IF SY-SUBRC = 0.
          SORT I_VBELN BY VBELN.
        ELSE.
          MESSAGE I000 WITH TEXT-002.
         STOP.
          LEAVE LIST-PROCESSING.
        ENDIF.
      ELSE.
    *--select statement for retrieving data from vbpa
        SELECT VBELN
               FROM VBPA
               INTO TABLE I_VBELN
               WHERE KUNNR IN S_KUNNR OR
                     KUNNR IN SO_KUNNR.
        IF SY-SUBRC = 0.
          SORT I_VBELN BY VBELN.
        ELSE.
          MESSAGE I000 WITH TEXT-002.
          LEAVE LIST-PROCESSING.
        ENDIF.
      ENDIF.
    ENDFORM.                    " get_vbeln
    *&      Form  get_vbap
    FORM GET_VBAP .
      IF I_VBELN[] IS NOT INITIAL.
    *--select statement for retrieving data from vbap
        SELECT VBELN
               POSNR
               MATNR
               KWMENG
               KDMAT
               FROM VBAP
               INTO TABLE I_VBAP
               FOR ALL ENTRIES IN I_VBELN
               WHERE VBELN = I_VBELN-VBELN.
        IF SY-SUBRC = 0.
          SORT I_VBAP BY VBELN POSNR.
        ELSE.
          MESSAGE I000 WITH TEXT-002.
         STOP.
           LEAVE LIST-PROCESSING.
        ENDIF.
      ENDIF.
    ENDFORM.                    " get_vbap
    *&      Form  get_vbfa
          text
    -->  p1        text
    <--  p2        text
    FORM GET_VBFA .
    *--select statement to retrieve data from VBFA
      IF I_VBAP[] IS NOT INITIAL.
        SELECT     VBELV
                   POSNV
                   VBELN
                   POSNN
                   FROM VBFA
                   INTO TABLE I_VBFA
                   FOR ALL ENTRIES IN I_VBAP
                   WHERE VBELV   = I_VBAP-VBELN AND
                         POSNV   = I_VBAP-POSNR AND
                         VBTYP_N = C_DTYPE.
        IF SY-SUBRC = 0.
          SORT I_VBFA ."BY vbelv posnv vbeln posnn.
        ELSE.
          MESSAGE I000 WITH TEXT-002.
          STOP.
        ENDIF.
      ENDIF.
    ENDFORM.                    " get_vbfa
    *&      Form  get_likp
    FORM GET_LIKP .
      IF I_VBFA[] IS NOT INITIAL.
    *--Fecthing data fron LIKP
        SELECT VBELN
               FROM LIKP
               INTO TABLE I_LIKP
               FOR ALL ENTRIES IN I_VBFA
               WHERE VBELN = I_VBFA-VBELN.
        IF SY-SUBRC = 0.
          SORT I_LIKP BY VBELN.
        ELSE.
          MESSAGE I000 WITH TEXT-002.
          STOP.
        ENDIF.
      ENDIF.
    ENDFORM.                    " get_likp
    *&      Form  get_lips
    FORM GET_LIPS .
      IF NOT I_LIKP[] IS INITIAL.
    *--select statement for retrieving data from LIPS
        SELECT VBELN
               POSNR
               MATNR
              vgbel
               LFIMG
               FROM LIPS
               INTO TABLE I_LIPS
               FOR ALL ENTRIES IN I_LIKP
               WHERE VBELN = I_LIKP-VBELN.
        IF SY-SUBRC = 0.
          SORT I_LIPS BY VBELN POSNR MATNR.
        ELSE.
          MESSAGE I000 WITH TEXT-002.
          STOP.
        ENDIF.
      ENDIF.
    ENDFORM.                    " get_lips
    *&      Form  get_vbup
    FORM GET_VBUP .
      IF I_LIPS[] IS NOT INITIAL.
    *--select statement for retrieving delivery status from VBUP.
        SELECT VBELN
               POSNR
               LFSTA
               WBSTA
               FKSTA
               FROM VBUP
               INTO TABLE I_VBUP
               FOR ALL ENTRIES IN I_LIPS
               WHERE VBELN = I_LIPS-VBELN AND
                     POSNR = I_LIPS-POSNR.
        IF SY-SUBRC = 0.
          SORT I_VBUP BY VBELN POSNR.
        ELSE.
          MESSAGE I000 WITH TEXT-002.
          STOP.
        ENDIF.
      ENDIF.
    ENDFORM.                    " get_vbup
    *&      Form  populate_final
    FORM POPULATE_FINAL.
    *--populating final internal table with sales and delivery data for
                                                    displaying purpose
      LOOP AT I_LIPS.
        I_FINAL-VBELN1   = I_LIPS-VBELN  .
        I_FINAL-POSNR1   = I_LIPS-POSNR .
        I_FINAL-MATNR1   = I_LIPS-MATNR .
        I_FINAL-LFIMG    = I_LIPS-LFIMG.
        READ TABLE I_VBFA WITH KEY VBELN = I_LIPS-VBELN
                                   POSNN = I_LIPS-POSNR BINARY SEARCH.
        IF SY-SUBRC = 0.
          READ TABLE I_VBAP WITH KEY VBELN = I_VBFA-VBELV
                                     POSNR = I_VBFA-POSNV BINARY SEARCH.
          IF SY-SUBRC = 0.
            I_FINAL-VBELN    = I_VBAP-VBELN  .
            I_FINAL-POSNR    = I_VBAP-POSNR .
            I_FINAL-MATNR    = I_VBAP-MATNR .
            I_FINAL-KWMENG   = I_VBAP-KWMENG.
            I_FINAL-KDMAT    = I_VBAP-KDMAT .
            READ TABLE I_VBUP WITH KEY VBELN = I_LIPS-VBELN
                                       POSNR = I_LIPS-POSNR BINARY SEARCH.
            IF SY-SUBRC = 0.
              IF   I_VBUP-WBSTA = 'C'
               AND I_VBUP-FKSTA <> ' '.
                CONTINUE.
              ENDIF.
              IF I_VBUP-WBSTA = 'C' AND I_VBUP-FKSTA = ' '.
                 I_FINAL-DS    = 'Shipped but not invoiced'.
              ELSEIF I_VBUP-WBSTA <> 'C'.
                I_FINAL-DS    = 'open'.
              ENDIF.
              APPEND I_FINAL.
              CLEAR I_FINAL.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " populate_final
    *&      Form  call_alv
    FORM CALL_ALV .
      DATA: CPROG TYPE SY-CPROG.
      CPROG = SY-CPROG.
    *---populating fieldcatalog
      PERFORM POPULATE_FIELDCATALOG.
    *-----layout
      PERFORM Z_LAYOUT.
    *----for sub totals.
      PERFORM Z_SORT USING LT_SORT.
    *-----calling REUSE_ALV_LIST_DISPLAY
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM = CPROG
          IS_LAYOUT          = I_LAYOUT
          IT_FIELDCAT        = I_FIELDCAT
          IT_SORT            = LT_SORT
        TABLES
          T_OUTTAB           = I_FINAL
        EXCEPTIONS
          PROGRAM_ERROR      = 1
          OTHERS             = 2.
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " call_alv
    *&      Form  populate_fieldcatalog
    FORM POPULATE_FIELDCATALOG .
      CLEAR W_FIELDCAT.
      W_FIELDCAT-FIELDNAME = 'VBELN'.
      W_FIELDCAT-SELTEXT_L = 'Sales Order Number'.
      W_FIELDCAT-TABNAME   = 'I_FINAL'.
      W_FIELDCAT-COL_POS   = 1.
      APPEND W_FIELDCAT TO I_FIELDCAT.
      CLEAR W_FIELDCAT.
      W_FIELDCAT-FIELDNAME = 'POSNR'.
      W_FIELDCAT-SELTEXT_L = 'Order Line Number'.
      W_FIELDCAT-TABNAME   = 'I_FINAL'.
      W_FIELDCAT-COL_POS   = 2.
      APPEND W_FIELDCAT TO I_FIELDCAT.
      CLEAR W_FIELDCAT.
      W_FIELDCAT-FIELDNAME = 'MATNR'.
      W_FIELDCAT-SELTEXT_L = 'MAterial Number'.
      W_FIELDCAT-TABNAME   = 'I_FINAL'.
      W_FIELDCAT-COL_POS   = 3.
      APPEND W_FIELDCAT TO I_FIELDCAT.
      CLEAR W_FIELDCAT.
      W_FIELDCAT-FIELDNAME = 'KWMENG'.
      W_FIELDCAT-SELTEXT_L = 'Qty Ordered'.
      W_FIELDCAT-TABNAME   = 'I_FINAL'.
      W_FIELDCAT-COL_POS   = 4.
      APPEND W_FIELDCAT TO I_FIELDCAT.
      CLEAR W_FIELDCAT.
      W_FIELDCAT-FIELDNAME = 'KDMAT'.
      W_FIELDCAT-SELTEXT_L = 'Customer PO number'.
      W_FIELDCAT-TABNAME   = 'I_FINAL'.
      W_FIELDCAT-COL_POS   = 5.
      W_FIELDCAT-OUTPUTLEN   = 35.
      APPEND W_FIELDCAT TO I_FIELDCAT.
      CLEAR W_FIELDCAT.
      W_FIELDCAT-FIELDNAME = 'VBELN1'.
      W_FIELDCAT-SELTEXT_L = 'Delivery Number'.
      W_FIELDCAT-TABNAME   = 'I_FINAL'.
      W_FIELDCAT-COL_POS   = 6.
      APPEND W_FIELDCAT TO I_FIELDCAT.
      CLEAR W_FIELDCAT.
      W_FIELDCAT-FIELDNAME = 'POSNR1'.
      W_FIELDCAT-SELTEXT_L = 'Delivery Line Number'.
      W_FIELDCAT-TABNAME   = 'I_FINAL'.
      W_FIELDCAT-COL_POS   = 7.
      APPEND W_FIELDCAT TO I_FIELDCAT.
      CLEAR W_FIELDCAT.
      W_FIELDCAT-FIELDNAME = 'MATNR1'.
      W_FIELDCAT-SELTEXT_L = 'Material Number'.
      W_FIELDCAT-TABNAME   = 'I_FINAL'.
      W_FIELDCAT-COL_POS   = 8.
      APPEND W_FIELDCAT TO I_FIELDCAT.
      CLEAR W_FIELDCAT.
      W_FIELDCAT-FIELDNAME = 'LFIMG'.
      W_FIELDCAT-SELTEXT_L = 'Delivery Qty'.
      W_FIELDCAT-TABNAME   = 'I_FINAL'.
      W_FIELDCAT-COL_POS   = 9.
      W_FIELDCAT-DO_SUM   = 'X'.
      APPEND W_FIELDCAT TO I_FIELDCAT.
      CLEAR W_FIELDCAT.
      W_FIELDCAT-FIELDNAME = 'DS'.
      W_FIELDCAT-SELTEXT_L = 'Delivery Status'.
      W_FIELDCAT-TABNAME   = 'I_FINAL'.
      W_FIELDCAT-COL_POS   = 10.
      APPEND W_FIELDCAT TO I_FIELDCAT.
    ENDFORM.                    " populate_fieldcatalog
    *&      Form  Z_LAYOUT
    FORM Z_LAYOUT .
      I_LAYOUT-ZEBRA             = 'X'.
      I_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
      I_LAYOUT-GET_SELINFOS      = 'X'.
    ENDFORM.                    " Z_LAYOUT
    *&      Form  Z_SORT
    FORM Z_SORT  USING    P_LT_SORT.
      DATA :LS_SORT    TYPE   SLIS_SORTINFO_ALV.
      CLEAR LS_SORT.
      LS_SORT-SPOS      = '9'.
      LS_SORT-FIELDNAME = 'VBELN'.
      LS_SORT-TABNAME   = 'I_FINAL'.
      LS_SORT-UP        = 'X'.
      LS_SORT-GROUP     = 'UL'.
      LS_SORT-SUBTOT    = 'X'.
      APPEND LS_SORT TO LT_SORT.
    ENDFORM.                    " Z_SORT

  • Invoice date and Cancel date

    Hi ,
    How to get invoice date and cancellation date of a sales order.
    My requirement is like this: .... i have to list out all the open orders for a particular date, for example today.
    For this i need to display sales orders with any status as well as invoiced and cancelled orders which fall under that particular date.
    Hope it's clear.
    Regards
    Sreenivasa Reddy v.

    okay here is a sample code to find the open sales orders for a customer and sales area.
    just execute the code and see this is fetch ing the open orders .
    <b>now for ur logic enhance the code with date in the select statements so that u will capture the open orders with in the range .</b>
    regards,
    vijay
    REPORT ZEX2  MESSAGE-ID arc NO STANDARD PAGE HEADING.
    Tables :kna1,vbak.
    SELECT-OPTIONS : so_vkorg FOR  vbak-vkorg OBLIGATORY,
                     so_vtweg FOR  vbak-vtweg OBLIGATORY,
                     so_spart FOR  vbak-spart,
                     so_kunnr FOR  kna1-kunnr.
    DATA : BEGIN OF sales_open OCCURS 0 ,
           vbeln LIKE vbak-vbeln,
           auart LIKE vbak-auart,
           kunnr LIKE kna1-kunnr,
           bstnk LIKE vbak-bstnk,
           lfstk LIKE vbuk-lfstk,
           fkstk LIKE vbuk-fkstk,
           gbstk LIKE vbuk-gbstk,
           END OF sales_open.
    DATA : BEGIN OF itm_sales OCCURS 0,
           vbeln LIKE vbap-vbeln,
           posnr LIKE vbap-posnr,
           matnr LIKE vbap-matnr,
           kwmeng like vbap-kwmeng,
           lfsta LIKE vbup-lfsta,
           lfgsa LIKE vbup-lfgsa,
           fksta LIKE vbup-fksta,
           fksaa LIKE vbup-fksaa,
           gbsta LIKE vbup-gbsta,
           END OF itm_sales.
    DATA : l_kunnr LIKE kna1-kunnr,
           l_vkorg LIKE vbak-vkorg,
           l_vtweg LIKE vbak-vtweg,
           l_spart LIKE vbak-spart.
    DATA: v_statusl(20) TYPE c,
          v_statusb(20) TYPE c,
          v_statusf(20) TYPE c,
          v_statusg(20) TYPE c,
          v_status(20) TYPE c,
          v_field(1) TYPE c.
    data : v_openqty like vbap-kwmeng.
    **Selection Screen Validations.
    AT SELECTION-SCREEN.
      PERFORM validations.
    *&      Form  Validations
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM validations.
    **Customer
      IF NOT so_kunnr[] IS INITIAL.
        SELECT SINGLE kunnr INTO l_kunnr
               FROM kna1
               WHERE kunnr IN so_kunnr.
        IF sy-subrc NE 0.
          MESSAGE e002 WITH text-005.
        ENDIF.
      ENDIF.
    **Sales Organization
      IF NOT so_vkorg[] IS INITIAL.
        SELECT SINGLE vkorg INTO l_vkorg
               FROM tvko
               WHERE vkorg IN so_vkorg.
        IF sy-subrc NE 0.
          MESSAGE e003 WITH text-006.
        ENDIF.
      ENDIF.
    **Distribution Channel
      IF NOT so_vtweg[] IS INITIAL.
        SELECT SINGLE vtweg INTO l_vtweg
                FROM tvkov
                WHERE   vkorg IN so_vkorg
                 AND    vtweg IN so_vtweg.
        IF sy-subrc NE 0.
          MESSAGE e004 WITH text-007.
        ENDIF.
      ENDIF.
    **Division
      IF NOT so_spart[] IS INITIAL.
        SELECT SINGLE spart INTO l_spart
                FROM tvta
                WHERE   vkorg IN so_vkorg
                AND     vtweg IN so_vtweg
                AND     spart IN so_spart.
        IF sy-subrc NE 0.
          MESSAGE e005 WITH text-008.
        ENDIF.
      ENDIF.
    ENDFORM.                    " Validations
    Top-of-page.
    PERFORM sales_top_of_page.
    Start-of-selection.
    PERFORM sales_sel.
    *&      Form  sales_sel
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM sales_sel.
    SELECT vbeln auart kunnr bstnk
         lfstk fkstk gbstk
         INTO TABLE sales_open
         FROM vbakuk
         WHERE vkorg IN so_vkorg
         AND   vtweg IN so_vtweg
         AND   spart IN so_spart
         AND   kunnr IN so_kunnr
         AND gbstk NE 'C'.
      LOOP AT sales_open.
        WRITE:/4 sy-vline,
               5 sales_open-vbeln HOTSPOT ON COLOR 2 INTENSIFIED OFF,
               16 sy-vline,
               17 sales_open-auart COLOR 2 INTENSIFIED OFF,
               27 sy-vline,
               28 sales_open-kunnr COLOR 2 INTENSIFIED OFF,
               40 sy-vline,
               41 sales_open-bstnk COLOR 2 INTENSIFIED OFF,
               55 sy-vline,
               56 sales_open-lfstk,
               76 sy-vline,
               77 sales_open-fkstk,
               96 sy-vline,
               97 sales_open-gbstk ,
               117 sy-vline.
        HIDE sales_open-vbeln .
      ENDLOOP.
    ENDFORM.                    " sales_sel
    *&      Form  sales_top_of_page
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM sales_top_of_page.
      WRITE:/4 sy-uline(114),
         50 'OPEN SALES ORDERS' COLOR 7 INTENSIFIED ON .
      WRITE: /4 sy-vline,
              5 'SalesOrder' COLOR 1 ,
              16 sy-vline,
             17  'OrderType' COLOR 1,
             27  sy-vline,
             28  'Customer' COLOR 1,
             40  sy-vline,
             41  'PoNumber' COLOR 1,
             55  sy-vline,
             56  'Delivery Status' COLOR 1,
             76  sy-vline,
             77  'Billing Status' COLOR 1,
             96  sy-vline,
             97  'Processing Status' COLOR 1,
             117  sy-vline .
      WRITE:/4 sy-uline(114).
    ENDFORM.                    " sales_top_of_page
    AT LINE-SELECTION.
      SELECT       a~vbeln
                   a~posnr
                   a~matnr
                   a~kwmeng
                   b~lfsta
                   b~lfgsa
                   b~fksta
                   b~fksaa
                   b~gbsta
                   INTO TABLE itm_sales
                   FROM vbap AS a JOIN vbup AS b
                   ON a~vbeln EQ b~vbeln
                   AND a~posnr EQ b~posnr
                   AND b~gbsta NE 'C'
                   WHERE a~vbeln EQ sales_open-vbeln.
      IF NOT sales_open IS INITIAL.
        LOOP AT itm_sales.
          at end of vbeln .
          sum.
          v_openqty = itm_sales-kwmeng.
          endat.
          WRITE:/5  itm_sales-vbeln,
                    itm_sales-posnr,
                    itm_sales-matnr,
                    itm_sales-kwmeng,
                    itm_sales-lfsta,
                    itm_sales-lfgsa,
                    itm_sales-fksta,
                    itm_sales-fksaa,
                    itm_sales-gbsta.
        ENDLOOP.
      ENDIF.
    skip 2.
      write:/  'open
    Quantity for the order is ', v_openqty .

  • BAPI for knowing the Billing Status of DMR(Resource Related Billing)

    Dear All,
    I need to know the Billing Status of a Debit Memo Request from the External System.
    The Document Flow will be:
    Sales Order>DP91>DMR Creation(DR)[VA01]-->Debit Memo Creation(L2)[VF01]
    From the external system I need to know whether the DMR has been billed or not.
    I have used one BAPI "DISPLAY_DOCUMENT_FLOW_ALV"
    in which it was asking to specify a value in the Input Parameter"IV_TITLE_STATUS_SET".
    Tell me if this is the correct BAPI and if so what value we need to specify in the Input Parameter.
    Needless to say points will be given for helpul replies.
    Regards,
    Raj Kumar Reddy.

    Hi,
    You are correct that stauts is updated in table VBUK and VBUP.
    However, a sales order does not determine a billing status for delivery related billing, field
    VBUP-FKSTA is only determined for delivey.
    So, it is correct behavior that VBUP-FKSTA = BLANK when searching VBUP with
    VBUP-VBELN = sales order number.
    Just because of above reason, you will not find billing status field in VA03 -> goto header/item;
    you could only find billing status field for delivery in VL03N -> status overview.
    It seems that you are trying to find out sales orders that have been fully deliveried and fully billed, am I right? As far as I know, there is no directly table/field/tcode that could meet your requirement.
    You could consider following workaround:
    firstly, get a list of deliveries that have been fully billied(search VBUP with VBUP-FKSTA = C or search VBUK with VBUK-FKSTK = C);
    Secondly, using these deliveries to search table VBFA to find out related sales orders.
    Hope this helps.
    Best regards,
    Crystal

  • Delivery documene is showing in billing due list.

    Good Evening.
    We have a delivery is on the billing due list that was billed but still is on the billing due list.  Can you please let me know how to clear this delivery.
    chakri

    Hi Chakri,
    I am not sure whether you have checked table VBUP for this delivery.
    If this delivery is fully invoiced. VBUP-FKSTA should be C for each item in the delivery.
    If you find this field is incorrect, please run report RVDELSTA which could help update
    the billing status of this delivery.
    And in document flow table VBFA, the correct entry(subsequent billing document) for this delivery should also exsits.
    If the entries in VBUP and VBFA are both OK, you could run report RVV05IVB to rebuild the billing index.
    Regards,
    Alex

Maybe you are looking for

  • I have lost my verizon icon and cannot connect to a cellular connection what can I do?

    I Have verizion as my cellular carrier. I downloaded the last update from Apple for my iPad Air now I can no longer get a cellular connection because I don not have a cellular icon. (the verizon bill is paid and current) can anyone help?

  • Background color in a Region

    Hello all. I currently have 5 Regions on one page and would like to create visual queues by adding a background color to each region. Are there any examples available for me to implement something like this? Your guideance is very much appreciated Th

  • Error When Submit

    Hi Everybody, When, I click on the button submit of one page, I have this error : Error error of contents of total of control of message of success of impression(printing):: 2C4810968EDDDDB0C34EC84C8B548512 OK. However, everything work well. Do you k

  • Two million pixels

    Hi. After uploading my ePub file using iTunes Producer, I got an email from apple: Your book, vendor ID: ... , could not be delivered. The following images are larger than two million pixels and must be resized: I had a look at all my images that I'm

  • Normalization and denormalization

    Hi, what is normalization and denormalization ? How to implement that while design (OLTP,OLAP). I read the oracle documents it is very hard to understand that.. please anyone tell the examples.