Skip to Content
author's profile photo Former Member
Former Member

Sales Order Header wise status.

Hy expert,

i going to make Sales order Status Reports. It run successfully fetch data form header wise, but it display all so, that is already closed or completed.

i wnt to which Sales order it is pending or partially deliverd.

Please help me regarding this.

Report in ALV.

Please read this code for fetch Data. if u like change pl do.

Thnks

Bhavesh Panchal

baroda

FORM data_retrieval.
SELECT VBELN  NETWR KUNNR FROM VBAK INTO (ITAB-VBELN,ITAB-NETWR,ITAB-KUNNR) WHERE VBELN IN VBELN .
SELECT NAME1 FROM KNA1 INTO (ITAB-NAME1) WHERE KUNNR = ITAB-KUNNR .
SELECT BSTKD BSTDK FROM VBKD INTO (ITAB-BSTKD,ITAB-BSTDK) WHERE VBELN = ITAB-VBELN.
SELECT VSNMR_V FROM VBAK INTO (ITAB-VSNMR_V) WHERE VBELN = ITAB-VBELN.
*SELECT EDATU FROM VBEP INTO (ITAB-EDATU) WHERE VBELN = ITAB-VBELN.
SELECT LFSTK FROM VBUK INTO (ITAB-LFSTK) WHERE VBELN = ITAB-VBELN and lfstk not like 'C'.
APPEND ITAB.
ENDSELECT.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 13, 2009 at 05:58 AM

    Hi,

    Are u giving input SO No. single or multiple?

    If single then first write,

    data zvbeln type vbak-vbeln.

    select single vbeln from vbuk into zvbeln where lfstk ne 'C' and vbeln = vbeln.

    if sy-dbcnt = 1.

    proceed with ur query (where vbeln = zvbeln ).

    if multiple then -

    data itab like standard table of vbuk with header line.

    select vbeln lfstk into corresponding fields of table itab where lfstk ne 'C' and vbeln in vbeln.

    if sy-dbcnt ne 0.

    loop at itab.

    procceed with ur query. ( where vbeln = itab-vbeln)

    endloop.

    Hope this helps

    Edited by: Vishal Chavan on May 13, 2009 8:00 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 13, 2009 at 06:49 AM

    Hi,

    Please find teh code as follows:-

    TYPES : BEGIN OF tab1,
            vbeln   TYPE vbak-vbeln,
            netwr   TYPE vbak-netwr,
            kunnr   TYPE vbak-kunnr,
            vsnmr_v TYPE vbak-vsnmr_v,
            lfstk   TYPE vbuk-lfstk,
            gbstk   TYPE vbuk-gbstk,
            END OF tab1,
    
            BEGIN OF tab2,
            kunnr   TYPE vbak-kunnr,
            name1   TYPE kna1-name1,
            END OF tab2,
    
    
            BEGIN OF tab3,
            vbeln   TYPE vbak-vbeln,
            bstkd   TYPE vbkd-bstkd,
            bstdk   TYPE vbkd-bstdk,
            END OF tab3,
    
            BEGIN OF tab4,
            vbeln   TYPE vbak-vbeln,
            netwr   TYPE vbak-netwr,
            kunnr   TYPE vbak-kunnr,
            vsnmr_v TYPE vbak-vsnmr_v,
            lfstk   TYPE vbuk-lfstk,
            gbstk   TYPE vbuk-gbstk,
            name1   TYPE kna1-name1,
            bstkd   TYPE vbkd-bstkd,
            bstdk   TYPE vbkd-bstdk,
            END OF tab4.
    
    
    DATA: itab1 TYPE STANDARD TABLE OF tab1,
          itab2 TYPE STANDARD TABLE OF tab2,
          itab3 TYPE STANDARD TABLE OF tab3,
          itab4 TYPE STANDARD TABLE OF tab4.
    
    DATA : wa1 TYPE tab1,
           wa2 TYPE tab2,
           wa3 TYPE tab3,
           wa4 TYPE tab4.
    
    
    
    SELECT-OPTIONS : s_vbeln FOR wa1-vbeln.
    
    START-OF-SELECTION.
    
      SELECT  a~vbeln
              a~netwr
              a~kunnr
              a~vsnmr_v
              b~lfstk
              b~gbstk
    INTO CORRESPONDING FIELDS OF TABLE itab1
    FROM vbak AS a
    INNER JOIN vbuk AS b
    ON b~vbeln = a~vbeln
    WHERE a~vbeln IN s_vbeln
    AND  b~lfstk NE 'C'
    AND  b~gbstk NE 'C'.
      IF sy-subrc EQ 0.
    
        SELECT kunnr
               name1
        FROM kna1
        INTO CORRESPONDING FIELDS OF TABLE itab2
        FOR ALL ENTRIES IN itab1
        WHERE kunnr = itab1-kunnr.
        IF sy-subrc EQ 0.
          SORT itab2 BY kunnr.
        ENDIF.
    
    
        SELECT vbeln
               bstkd
               bstdk
        FROM vbkd INTO CORRESPONDING FIELDS OF TABLE itab3
        FOR ALL ENTRIES IN itab1
        WHERE vbeln = itab1-vbeln.
        IF sy-subrc EQ 0.
          SORT itab3 BY vbeln.
        ENDIF.
    
    
        LOOP AT itab1 INTO wa1.
          MOVE-CORRESPONDING wa1 TO wa4.
    
          READ TABLE itab2 INTO wa2
          WITH KEY kunnr = wa1-kunnr BINARY SEARCH.
          IF sy-subrc EQ 0.
            MOVE wa2-name1 TO wa4-name1.
          ENDIF.
    
          READ TABLE itab3 INTO wa3
          WITH KEY vbeln = wa1-vbeln BINARY SEARCH.
          IF sy-subrc EQ 0.
            MOVE : wa3-bstdk TO wa4-bstdk,
                   wa3-bstkd TO wa4-bstkd.
    
          ENDIF.
    
          APPEND wa4 TO itab4.
        ENDLOOP.
    
    
      ENDIF.
    

    Regards,

    Ankur Parab

    Edited by: Ankur Parab on May 13, 2009 8:50 AM

    Edited by: Ankur Parab on May 13, 2009 8:51 AM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 13, 2009 at 07:17 AM

    Hi,

    Try this out.

    SELECT vbeln auart spart audat netwr

    FROM vbak INTO TABLE it_vbak

    WHERE spart IN so_spart

    AND audat IN so_fkdat

    AND auart IN rg_auart

    AND vbeln IN so_vbeln.

    SELECT vbeln posnr spart werks matnr arktx kwmeng kbmeng abgru pstyv netwr matkl

    INTO CORRESPONDING FIELDS OF TABLE it_vbap

    FROM vbap

    FOR ALL ENTRIES IN it_vbak

    WHERE vbeln = it_vbak-vbeln

    AND posnr LIKE '%'

    AND werks IN so_werks

    AND matkl IN so_matkl

    AND matnr IN so_matnr .

    IF it_vbap IS NOT INITIAL.

    "Get all delivery details

    SELECT vbelv posnv vbeln posnn vbtyp_n vbtyp_v rfmng matnr " vbfa_j for All Delivery details

    FROM vbfa INTO TABLE it_vbfa_j

    FOR ALL ENTRIES IN it_vbap

    WHERE vbelv = it_vbap-vbeln AND

    posnv = it_vbap-posnr AND

    vbeln LIKE '%' AND

    posnn LIKE '%' AND

    vbtyp_n = 'J'.

    ENDIF.

    LOOP AT it_vbap INTO wa_vbap WHERE abgru EQ space.

    "Get cumulative confirmed qty

    wa_final-kbmeng = wa_vbap-kbmeng.

    READ TABLE it_vbfa_J INTO wa_vbfa_j WITH KEY vbelv = wa_vbpa-vbeln

    posnv = wa_vbfa-posnr.

    " BINARY SEARCH.

    IF sy-subrc = 0.

    wa_final-delivery_qty_total = wa_vbfa-rfmng.

    ENDIF.

    IF wa_final-delivery_qty_total NE wa_final-kbmeng .

    wa_final-pending_order = wa_final-kbmeng - wa_final-delivery_qty_total. "(pending order = Order_qty - total delivery qty)

    ENDIF.

    CLEAR wa_final.

    endloop.

    Hope this will help.

    Thanks,

    Archana

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 22, 2009 at 05:54 AM

    gud

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.